Signed-off-by: Andrey Grodzovsky <andrey.grodzov...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 +++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 11410a9..338b946 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -1145,7 +1145,11 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 
        drm_dev_unplug(dev);
 
+       /* Will trigger SIGBUS on all subsequent CPU accesses */
        amdgpu_force_unmap_user_space_mappings(dev);
+
+       /* Will trigger VMFAULTs on all subsequent GPU successes */
+       amdgpu_bo_destroy_mms(adev);
        wait_event(adev->user_clients_done,
                   !atomic_read(&dev->open_count) &&
                   !atomic_read(&adev->exported_dma_bufs_count));
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 82d43d0..7eac00b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1049,6 +1049,17 @@ int amdgpu_bo_evict_vram(struct amdgpu_device *adev)
        return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, false);
 }
 
+int amdgpu_bo_destroy_mms(struct amdgpu_device *adev)
+{
+       int r;
+
+       r = ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, true);
+       if (!r)
+               return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_TT, true);
+
+       return r;
+}
+
 static const char *amdgpu_vram_names[] = {
        "UNKNOWN",
        "GDDR1",
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
index 7d41f7b..4892265 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
@@ -269,6 +269,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 
domain,
                             u64 min_offset, u64 max_offset);
 int amdgpu_bo_unpin(struct amdgpu_bo *bo);
 int amdgpu_bo_evict_vram(struct amdgpu_device *adev);
+int amdgpu_bo_destroy_mms(struct amdgpu_device *adev);
 int amdgpu_bo_init(struct amdgpu_device *adev);
 int amdgpu_bo_late_init(struct amdgpu_device *adev);
 void amdgpu_bo_fini(struct amdgpu_device *adev);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to