From 5d94091aa4e0497f14e53604cfbbcb9faa979c69 Mon Sep 17 00:00:00 2001 From: Ben Goz Date: Mon, 21 Dec 2015 17:39:47 +0200 Subject: [PATCH 1379/4131] drm/amdgpu: Verify amdgpu_bo only if amdgpu_bo allocated from amdgpu Change-Id: Id75381226beacc5c176b9f02cc28b185654fcae5 Signed-off-by: Ben Goz Conflicts: drivers/gpu/drm/amd/amdgpu/amdgpu.h drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index d6d7924..b20c0e4 100755 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1969,3 +1969,4 @@ static inline int amdgpu_dm_display_resume(struct amdgpu_device *adev) { return #include "amdgpu_object.h" #endif + diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index b5595eb..fabddbb 100755 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -83,6 +83,7 @@ struct amdgpu_bo { struct ttm_bo_kmap_obj dma_buf_vmap; struct amdgpu_mn *mn; + bool is_kfd_bo; struct kfd_process_device *pdd; union { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index de4634f..cb6aaea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -276,11 +276,19 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo, static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp) { - struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo); - struct drm_file *file_priv = filp->private_data; + struct amdgpu_bo *abo; + struct drm_file *file_priv; struct amdgpu_gem_object *gobj; - if (filp == NULL) + + + abo = container_of(bo, struct amdgpu_bo, tbo); + /* + * Don't verify access for KFD BO as it doesn't necessary has + * KGD file pointer + */ + if (!abo || abo->is_kfd_bo || !filp) return 0; + file_priv = filp->private_data; if (amdgpu_ttm_tt_get_usermm(bo->ttm)) return -EPERM; @@ -1494,6 +1502,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) NULL, NULL); if (r) return r; + DRM_INFO("amdgpu: %uM of VRAM memory ready\n", (unsigned) (adev->mc.real_vram_size / (1024 * 1024))); @@ -1574,6 +1583,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) if (!adev->mman.initialized) return; amdgpu_ttm_debugfs_fini(adev); + if (adev->stolen_vga_memory) { r = amdgpu_bo_reserve(adev->stolen_vga_memory, true); if (r == 0) { @@ -1584,6 +1594,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) } amdgpu_ssg_fini(adev); amdgpu_direct_gma_fini(adev); + ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM); ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT); if (adev->gds.mem.total_size) -- 2.7.4