From a1776eb3ace6a4d0ea097db604eb21853d45637d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 14 Jun 2018 17:12:56 +0200 Subject: [PATCH 3/3] drm/amdgpu: Add debugging output related to bogus pin_size values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michel Dänzer --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 64 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index c2ab9c3b019f..cc7722acd99b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -67,6 +67,14 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) { struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo); + int i; + + for (i = 0; i < bo->placement.num_placement; i++) { + if (bo->placements[i].flags & TTM_PL_FLAG_NO_EVICT) { + DRM_WARN_ONCE("Destroying pinned BO of size %lu\n", + amdgpu_bo_size(bo)); + } + } if (bo->kfd_bo) amdgpu_amdkfd_unreserve_system_memory_limit(bo); @@ -918,12 +926,34 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type); if (domain == AMDGPU_GEM_DOMAIN_VRAM) { u64 visible, invisible; + u64 old, old_invisible; + u64 new, new_invisible; amdgpu_vram_mgr_bo_sizes(bo, &visible, &invisible); - adev->vram_pin_size += visible + invisible; - adev->invisible_pin_size += invisible; + old = adev->vram_pin_size; + old_invisible = adev->invisible_pin_size; + new = adev->vram_pin_size += visible + invisible; + new_invisible = adev->invisible_pin_size += invisible; + + if (new != old + visible + invisible) { + DRM_WARN_ONCE("VRAM new = %llu != %llu + %llu + %llu\n", + new, old, visible, invisible); + } + + if (new_invisible != old_invisible + invisible) { + DRM_WARN_ONCE("new_invisible = %llu != %llu + %llu\n", + new_invisible, old_invisible, invisible); + } } else if (domain == AMDGPU_GEM_DOMAIN_GTT) { - adev->gart_pin_size += amdgpu_bo_size(bo); + u64 old, new; + + old = adev->gart_pin_size; + new = adev->gart_pin_size += amdgpu_bo_size(bo); + + if (new != old + amdgpu_bo_size(bo)) { + DRM_WARN_ONCE("GART new = %llu != %llu + %lu\n", + new, old, amdgpu_bo_size(bo)); + } } error: @@ -983,12 +1013,34 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo) if (bo->tbo.mem.mem_type == TTM_PL_VRAM) { u64 visible, invisible; + u64 old, old_invisible; + u64 new, new_invisible; amdgpu_vram_mgr_bo_sizes(bo, &visible, &invisible); - adev->vram_pin_size -= visible + invisible; - adev->invisible_pin_size -= invisible; + old = adev->vram_pin_size; + old_invisible = adev->invisible_pin_size; + new = adev->vram_pin_size -= visible + invisible; + new_invisible = adev->invisible_pin_size -= invisible; + + if (new != old - (visible + invisible)) { + DRM_WARN_ONCE("new = %llu != %llu - (%llu + %llu)\n", + new, old, visible, invisible); + } + + if (new_invisible != old_invisible - invisible) { + DRM_WARN_ONCE("new_invisible = %llu != %llu - %llu\n", + new_invisible, old_invisible, invisible); + } } else if (bo->tbo.mem.mem_type == TTM_PL_TT) { - adev->gart_pin_size -= amdgpu_bo_size(bo); + u64 old, new; + + old = adev->gart_pin_size; + new = adev->gart_pin_size -= amdgpu_bo_size(bo); + + if (new != old - amdgpu_bo_size(bo)) { + DRM_WARN_ONCE("GART new = %llu != %llu - %lu\n", + new, old, amdgpu_bo_size(bo)); + } } error: -- 2.17.1