From 7f53a9108a17a8086269fd27c7fec02dec3947d1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sat, 30 Jul 2022 09:10:27 +0000 Subject: [PATCH] WIP: ttm: print mappings --- .../bsd/drm2/dist/drm/ttm/ttm_bo_util.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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..25e1a9023ece 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 @@ -646,6 +646,9 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (bo->mem.bus.addr) { map->bo_kmap_type = ttm_bo_map_premapped; map->virtual = (void *)(((u8 *)bo->mem.bus.addr) + offset); + device_printf(bo->base.dev->dev, + "premap va=%p placement=0x%x\n", + map->virtual, mem->placement); } else { map->bo_kmap_type = ttm_bo_map_iomap; #ifdef __NetBSD__ @@ -664,6 +667,10 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, return ret; map->u.io.size = size; map->virtual = bus_space_vaddr(bo->bdev->memt, map->u.io.memh); + device_printf(bo->base.dev->dev, + "bus_space_map linear ba=%"PRIxBUSADDR" va=%p" + " size=0x%"PRIxBUSSIZE" flags=0x%x placement=0x%x\n", + addr, map->virtual, size, flags, mem->placement); } #else if (mem->placement & TTM_PL_FLAG_WC) @@ -707,6 +714,11 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, #ifdef __NetBSD__ map->u.kmapped.page = ttm->pages[start_page]; map->virtual = kmap(map->u.kmapped.page); + device_printf(bo->base.dev->dev, + "kmap pa=0x%"PRIxPADDR" va=%p prot=0x%x\n", + page_to_phys(ttm->pages[start_page]), + map->virtual, + VM_PROT_READ|VM_PROT_WRITE); #else map->page = ttm->pages[start_page]; map->virtual = kmap(map->page); @@ -720,6 +732,14 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, map->bo_kmap_type = ttm_bo_map_vmap; map->virtual = vmap(ttm->pages + start_page, num_pages, 0, prot); + for (unsigned i = 0; i < num_pages; i++) { + device_printf(bo->base.dev->dev, + "vmap pa[%u]=0x%"PRIxPADDR" va=%p prot=0x%x\n", + i, + page_to_phys(ttm->pages[start_page + i]), + (char *)map->virtual + i*PAGE_SIZE, + prot); + } #ifdef __NetBSD__ map->u.vmapped.vsize = (vsize_t)num_pages << PAGE_SHIFT; #endif