diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index c729cd1..57f6edd 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -286,6 +286,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, uint32_t proposed_placement; int r; + bo->glob->debug_bo = true; rdev = radeon_get_rdev(bo->bdev); tmp_mem = *new_mem; tmp_mem.mm_node = NULL; @@ -295,16 +296,29 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, if (unlikely(r)) { return r; } + if (bo->glob->debug_bo) + printk("%s: %p prebind %x %x\n", __func__, bo->ttm, proposed_placement, tmp_mem.placement); + + r = ttm_tt_set_placement_caching(bo->ttm, tmp_mem.placement); + if (unlikely(r)) { + goto out_cleanup; + } + r = ttm_tt_bind(bo->ttm, &tmp_mem); if (unlikely(r)) { goto out_cleanup; } + if (bo->glob->debug_bo) + printk("%s: ttm %p move blit\n", __func__, bo->ttm); r = radeon_move_blit(bo, true, no_wait, &tmp_mem, old_mem); if (unlikely(r)) { goto out_cleanup; } + if (bo->glob->debug_bo) + printk("%s: ttm %p move ttm\n", __func__, bo->ttm); r = ttm_bo_move_ttm(bo, true, no_wait, new_mem); out_cleanup: + bo->glob->debug_bo = false; if (tmp_mem.mm_node) { struct ttm_bo_global *glob = rdev->mman.bdev.glob; diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index a55ee1a..2cecfd5 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -170,6 +170,11 @@ int ttm_tt_populate(struct ttm_tt *ttm) struct ttm_backend *be; int ret; + if (ttm->glob->debug_bo == true) + printk("%s: ttm %p: state: %d, page_flags %d, num pages %ld, cstate %d\n", __func__, + ttm, + ttm->state, ttm->page_flags, ttm->num_pages, + ttm->caching_state); if (ttm->state != tt_unpopulated) return 0; @@ -223,12 +228,18 @@ static inline int ttm_tt_set_page_caching(struct page *p, */ static int ttm_tt_set_caching(struct ttm_tt *ttm, - enum ttm_caching_state c_state) + enum ttm_caching_state c_state, const char *caller) { int i, j; struct page *cur_page; int ret; + if (ttm->glob->debug_bo == true) + printk("%s: ttm %p: state: %d, page_flags %d, num pages %ld, caching %d/%d from %s\n", + __func__, + ttm, + ttm->state, ttm->page_flags, ttm->num_pages, + ttm->caching_state, c_state, caller); if (ttm->caching_state == c_state) return 0; @@ -277,8 +288,9 @@ int ttm_tt_set_placement_caching(struct ttm_tt *ttm, uint32_t placement) else state = tt_cached; - return ttm_tt_set_caching(ttm, state); + return ttm_tt_set_caching(ttm, state, __func__); } +EXPORT_SYMBOL(ttm_tt_set_placement_caching); static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) { @@ -288,7 +300,7 @@ static void ttm_tt_free_alloced_pages(struct ttm_tt *ttm) if (be) be->func->clear(be); - (void)ttm_tt_set_caching(ttm, tt_cached); + (void)ttm_tt_set_caching(ttm, tt_cached, __func__); for (i = 0; i < ttm->num_pages; ++i) { cur_page = ttm->pages[i]; ttm->pages[i] = NULL; @@ -433,6 +445,11 @@ int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem) if (!ttm) return -EINVAL; + if (ttm->glob->debug_bo == true) + printk("%s: ttm %p: state: %d, page_flags %d, num pages %ld, cstate %d\n", __func__, + ttm, + ttm->state, ttm->page_flags, ttm->num_pages, + ttm->caching_state); if (ttm->state == tt_bound) return 0; diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index e8cd6d2..8133803 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -420,6 +420,7 @@ struct ttm_bo_global { * Internal protection. */ atomic_t bo_count; + bool debug_bo; };