From 22770dde78c2e552edb1e686f23dd992b1c2f4fa Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 23 Aug 2022 13:51:41 +0000 Subject: [PATCH] WIP: radeon: track down framebuffer mapping flags --- sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c | 1 + .../bsd/drm2/dist/drm/radeon/radeon_object.c | 14 +++++++++++++- sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c | 3 +++ sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c b/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c index 6a6e19dbaf96..d199ea12608c 100644 --- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c +++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_fb.c @@ -256,6 +256,7 @@ static int radeonfb_create(struct drm_fb_helper *helper, } rbo = gem_to_radeon_bo(gobj); + printf("%s:%d: bo=%p\n", __func__, __LINE__, &rbo->tbo); #ifdef __NetBSD__ ret = radeon_framebuffer_init(rdev->ddev, &rfbdev->fb, &mode_cmd, gobj); diff --git a/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c b/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c index 6d160155ec57..2b6e39d6d7dc 100644 --- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c +++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c @@ -184,6 +184,11 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) rbo->rdev->mc.visible_vram_size >> PAGE_SHIFT; else rbo->placements[i].lpfn = 0; + printf("%s:%d: bo %p placement[%u] fpfn=0x%x lpfn=0x%x flags=0x%x\n", + __func__, __LINE__, &rbo->tbo, i, + rbo->placements[i].fpfn, + rbo->placements[i].lpfn, + rbo->placements[i].flags); } } @@ -240,6 +245,8 @@ int radeon_bo_create(struct radeon_device *rdev, /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit * See https://bugs.freedesktop.org/show_bug.cgi?id=84627 */ + printf("%s:%d: clear WC|UC in 0x%x -> 0x%x\n", __func__, __LINE__, + bo->flags, bo->flags & ~(RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC)); bo->flags &= ~(RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC); #elif defined(CONFIG_X86) && !defined(CONFIG_X86_PAT) /* Don't try to enable write-combining when it can't work, or things @@ -254,13 +261,18 @@ int radeon_bo_create(struct radeon_device *rdev, if (bo->flags & RADEON_GEM_GTT_WC) DRM_INFO_ONCE("Please enable CONFIG_MTRR and CONFIG_X86_PAT for " "better performance thanks to write-combining\n"); + printf("%s:%d: clear WC|UC in 0x%x -> 0x%x\n", __func__, __LINE__, + bo->flags, bo->flags & ~(RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC)); bo->flags &= ~(RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC); #else /* For architectures that don't support WC memory, * mask out the WC flag from the BO */ - if (!drm_arch_can_wc_memory()) + if (!drm_arch_can_wc_memory()) { + printf("%s:%d: clear WC in 0x%x -> 0x%x\n", __func__, __LINE__, + bo->flags, bo->flags & ~RADEON_GEM_GTT_WC); bo->flags &= ~RADEON_GEM_GTT_WC; + } #endif radeon_ttm_placement_from_domain(bo, domain); diff --git a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c index 063ce959e30d..a88b5a89b13f 100644 --- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c +++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c @@ -1284,6 +1284,9 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, if (ret) return ret; } + printf("%s:%d: bo=%p mem_type=0x%x placement=0x%x is_iomem=%d\n", + __func__, __LINE__, + bo, bo->mem.mem_type, bo->mem.placement, bo->mem.bus.is_iomem); return 0; } EXPORT_SYMBOL(ttm_bo_validate); diff --git a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c index 035c49a0fefd..9680c34bca05 100644 --- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c +++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c @@ -644,6 +644,8 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem = &bo->mem; if (bo->mem.bus.addr) { + printf("%s:%d: bo=%p placement=0x%x premapped %p\n", + __func__, __LINE__, bo, mem->placement, bo->mem.bus.addr); map->bo_kmap_type = ttm_bo_map_premapped; map->virtual = (void *)(((u8 *)bo->mem.bus.addr) + offset); } else { @@ -657,6 +659,8 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, addr = (bo->mem.bus.base + bo->mem.bus.offset + offset); if (ISSET(mem->placement, TTM_PL_FLAG_WC)) flags |= BUS_SPACE_MAP_PREFETCHABLE; + printf("%s:%d: bo=%p placement=0x%x bus_space_map flags=0x%x\n", + __func__, __LINE__, bo, mem->placement, flags); /* XXX errno NetBSD->Linux */ ret = -bus_space_map(bo->bdev->memt, addr, size, flags, &map->u.io.memh); @@ -698,6 +702,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, return ret; if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) { + printf("%s:%d: bo=%p placement=0x%x kmap\n", + __func__, __LINE__, bo, mem->placement); /* * We're mapping a single page, and the desired * page protection is consistent with the bo. @@ -717,6 +723,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, * or to make the buffer object look contiguous. */ prot = ttm_io_prot(mem->placement, PAGE_KERNEL); + printf("%s:%d: bo=%p placement=0x%x vmap prot=0x%x\n", + __func__, __LINE__, bo, mem->placement, prot); map->bo_kmap_type = ttm_bo_map_vmap; map->virtual = vmap(ttm->pages + start_page, num_pages, 0, prot);