From: Dave Airlie Date: Mon, 12 Aug 2019 04:20:21 +0000 (+1000) Subject: Merge tag 'drm-next-5.4-2019-08-09' of git://people.freedesktop.org/~agd5f/linux... X-Git-Tag: v5.4-rc1~106^2~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e7f7287bf5f746d29f3607178851246a005dd398;p=users%2Fjedix%2Flinux-maple.git Merge tag 'drm-next-5.4-2019-08-09' of git://people.freedesktop.org/~agd5f/linux into drm-next drm-next-5.4-2019-08-09: Same as drm-next-5.4-2019-08-06, but with the readq/writeq stuff fixed and 5.3-rc3 backmerged. amdgpu: - Add navi14 support - Add navi12 support - Add Arcturus support - Enable mclk DPM for Navi - Misc DC display fixes - Add perfmon support for DF - Add scatter/gather display support for Raven - Improve SMU handling for GPU reset - RAS support for GFX - Drop last of drmP.h - Add support for wiping memory on buffer release - Allow cursor async updates for fb swaps - Misc fixes and cleanups amdkfd: - Add navi14 support - Add navi12 support - Add Arcturus support - CWSR trap handlers updates for gfx9, 10 - Drop last of drmP.h - Update MAINTAINERS radeon: - Misc fixes and cleanups - Make kexec more reliable by tearing down the GPU ttm: - Add release_notify callback uapi: - Add wipe memory on release flag for buffer creation Signed-off-by: Dave Airlie [airlied: resolved conflicts with ttm resv moving] From: Alex Deucher Link: https://patchwork.freedesktop.org/patch/msgid/20190809184807.3381-1-alexander.deucher@amd.com --- e7f7287bf5f746d29f3607178851246a005dd398 diff --cc drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 8ae44d383a137,0c0a8e83ab832..2d07f16f17897 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@@ -80,14 -80,11 +80,11 @@@ static void amdgpu_bo_destroy(struct tt if (bo->pin_count > 0) amdgpu_bo_subtract_pin_size(bo); - if (bo->kfd_bo) - amdgpu_amdkfd_unreserve_memory_limit(bo); - amdgpu_bo_kunmap(bo); - if (bo->gem_base.import_attach) - drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg); - drm_gem_object_release(&bo->gem_base); + if (bo->tbo.base.import_attach) + drm_prime_gem_destroy(&bo->tbo.base, bo->tbo.sg); + drm_gem_object_release(&bo->tbo.base); /* in case amdgpu_device_recover_vram got NULL of bo->parent */ if (!list_empty(&bo->shadow_list)) { mutex_lock(&adev->shadow_list_lock); @@@ -1211,6 -1217,42 +1217,42 @@@ void amdgpu_bo_move_notify(struct ttm_b trace_amdgpu_bo_move(abo, new_mem->mem_type, old_mem->mem_type); } + /** + * amdgpu_bo_move_notify - notification about a BO being released + * @bo: pointer to a buffer object + * + * Wipes VRAM buffers whose contents should not be leaked before the + * memory is released. + */ + void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) + { + struct dma_fence *fence = NULL; + struct amdgpu_bo *abo; + int r; + + if (!amdgpu_bo_is_amdgpu_bo(bo)) + return; + + abo = ttm_to_amdgpu_bo(bo); + + if (abo->kfd_bo) + amdgpu_amdkfd_unreserve_memory_limit(abo); + + if (bo->mem.mem_type != TTM_PL_VRAM || !bo->mem.mm_node || + !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)) + return; + - reservation_object_lock(bo->resv, NULL); ++ reservation_object_lock(bo->base.resv, NULL); + - r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->resv, &fence); ++ r = amdgpu_fill_buffer(abo, AMDGPU_POISON, bo->base.resv, &fence); + if (!WARN_ON(r)) { + amdgpu_bo_fence(abo, fence, false); + dma_fence_put(fence); + } + - reservation_object_unlock(bo->resv); ++ reservation_object_unlock(bo->base.resv); + } + /** * amdgpu_bo_fault_reserve_notify - notification about a memory fault * @bo: pointer to a buffer object diff --cc drivers/gpu/drm/ttm/ttm_bo.c index 10a861a1690c9,2070e8a57ed80..9157dcc897a23 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@@ -672,7 -671,10 +672,10 @@@ static void ttm_bo_release(struct kref struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; + if (bo->bdev->driver->release_notify) + bo->bdev->driver->release_notify(bo); + - drm_vma_offset_remove(&bdev->vma_manager, &bo->vma_node); + drm_vma_offset_remove(&bdev->vma_manager, &bo->base.vma_node); ttm_mem_io_lock(man, false); ttm_mem_io_free_vm(bo); ttm_mem_io_unlock(man);