Commit 587f3c70 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: always wait before kmap a BO

When a BO is currently moving we otherwise would blindly
access the new location without checking.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 102534b0
...@@ -308,7 +308,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, ...@@ -308,7 +308,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
{ {
bool is_iomem; bool is_iomem;
int r; long r;
if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
return -EPERM; return -EPERM;
...@@ -319,14 +319,20 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr) ...@@ -319,14 +319,20 @@ int amdgpu_bo_kmap(struct amdgpu_bo *bo, void **ptr)
} }
return 0; return 0;
} }
r = reservation_object_wait_timeout_rcu(bo->tbo.resv, false, false,
MAX_SCHEDULE_TIMEOUT);
if (r < 0)
return r;
r = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages, &bo->kmap); r = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages, &bo->kmap);
if (r) { if (r)
return r; return r;
}
bo->kptr = ttm_kmap_obj_virtual(&bo->kmap, &is_iomem); bo->kptr = ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
if (ptr) { if (ptr)
*ptr = bo->kptr; *ptr = bo->kptr;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment