diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-01-10 13:06:00 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-01-27 11:13:28 -0500 |
commit | 36ea83d1512008ab6631c54971e8de8cf2f0a7b4 (patch) | |
tree | 2a69aafab3903216dbb6036de0bde7a525f23e65 /drivers/gpu/drm | |
parent | 54170226a6c9a2122620a3c5c432a76e84026794 (diff) |
drm/amd/amdgpu: lock reservation object while creating shadow bo
ttm_bo_init checks that the reservation object is locked. This is
the caller's responsibility when resv != NULL. Otherwise, the inline
reservation object of the newly allocated buffer is used and must
explicitly be locked.
Uninterruptible w/w locks without an acquire context are always
successful.
v2: use ww_mutex_lock
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net> (v1)
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index d94cdeff0617..ac6b074b8821 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -472,7 +472,16 @@ int amdgpu_bo_create(struct amdgpu_device *adev, | |||
472 | return r; | 472 | return r; |
473 | 473 | ||
474 | if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) { | 474 | if (amdgpu_need_backup(adev) && (flags & AMDGPU_GEM_CREATE_SHADOW)) { |
475 | if (!resv) { | ||
476 | r = ww_mutex_lock(&(*bo_ptr)->tbo.resv->lock, NULL); | ||
477 | WARN_ON(r != 0); | ||
478 | } | ||
479 | |||
475 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); | 480 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); |
481 | |||
482 | if (!resv) | ||
483 | ww_mutex_unlock(&(*bo_ptr)->tbo.resv->lock); | ||
484 | |||
476 | if (r) | 485 | if (r) |
477 | amdgpu_bo_unref(bo_ptr); | 486 | amdgpu_bo_unref(bo_ptr); |
478 | } | 487 | } |