aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_tt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_tt.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 9c2b1cc5dba5..3d47a2c12322 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -196,23 +196,34 @@ EXPORT_SYMBOL(ttm_tt_populate);
196 196
197#ifdef CONFIG_X86 197#ifdef CONFIG_X86
198static inline int ttm_tt_set_page_caching(struct page *p, 198static inline int ttm_tt_set_page_caching(struct page *p,
199 enum ttm_caching_state c_state) 199 enum ttm_caching_state c_old,
200 enum ttm_caching_state c_new)
200{ 201{
202 int ret = 0;
203
201 if (PageHighMem(p)) 204 if (PageHighMem(p))
202 return 0; 205 return 0;
203 206
204 switch (c_state) { 207 if (c_old != tt_cached) {
205 case tt_cached: 208 /* p isn't in the default caching state, set it to
206 return set_pages_wb(p, 1); 209 * writeback first to free its current memtype. */
207 case tt_wc: 210
208 return set_memory_wc((unsigned long) page_address(p), 1); 211 ret = set_pages_wb(p, 1);
209 default: 212 if (ret)
210 return set_pages_uc(p, 1); 213 return ret;
211 } 214 }
215
216 if (c_new == tt_wc)
217 ret = set_memory_wc((unsigned long) page_address(p), 1);
218 else if (c_new == tt_uncached)
219 ret = set_pages_uc(p, 1);
220
221 return ret;
212} 222}
213#else /* CONFIG_X86 */ 223#else /* CONFIG_X86 */
214static inline int ttm_tt_set_page_caching(struct page *p, 224static inline int ttm_tt_set_page_caching(struct page *p,
215 enum ttm_caching_state c_state) 225 enum ttm_caching_state c_old,
226 enum ttm_caching_state c_new)
216{ 227{
217 return 0; 228 return 0;
218} 229}
@@ -245,7 +256,9 @@ static int ttm_tt_set_caching(struct ttm_tt *ttm,
245 for (i = 0; i < ttm->num_pages; ++i) { 256 for (i = 0; i < ttm->num_pages; ++i) {
246 cur_page = ttm->pages[i]; 257 cur_page = ttm->pages[i];
247 if (likely(cur_page != NULL)) { 258 if (likely(cur_page != NULL)) {
248 ret = ttm_tt_set_page_caching(cur_page, c_state); 259 ret = ttm_tt_set_page_caching(cur_page,
260 ttm->caching_state,
261 c_state);
249 if (unlikely(ret != 0)) 262 if (unlikely(ret != 0))
250 goto out_err; 263 goto out_err;
251 } 264 }
@@ -259,7 +272,7 @@ out_err:
259 for (j = 0; j < i; ++j) { 272 for (j = 0; j < i; ++j) {
260 cur_page = ttm->pages[j]; 273 cur_page = ttm->pages[j];
261 if (likely(cur_page != NULL)) { 274 if (likely(cur_page != NULL)) {
262 (void)ttm_tt_set_page_caching(cur_page, 275 (void)ttm_tt_set_page_caching(cur_page, c_state,
263 ttm->caching_state); 276 ttm->caching_state);
264 } 277 }
265 } 278 }