[PATCH] drm/radeon: fix vm lock in radeon_gem_va_update_vm

Christian König deathsimple at vodafone.de
Thu Oct 23 02:32:38 PDT 2014


From: Christian König <christian.koenig at amd.com>

Without the lock we might corrupt the BO lists.

Might be squashed into "update the VM after setting BO address" for upstreaming.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 drivers/gpu/drm/radeon/radeon_gem.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 0002575..49d56b5 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -559,12 +559,16 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
 			goto error_unreserve;
 	}
 
+	mutex_lock(&bo_va->vm->mutex);
 	r = radeon_vm_clear_freed(rdev, bo_va->vm);
 	if (r)
-		goto error_unreserve;
+		goto error_unlock;
 
 	r = radeon_vm_bo_update(rdev, bo_va, &bo_va->bo->tbo.mem);
 
+error_unlock:
+	mutex_unlock(&bo_va->vm->mutex);
+
 error_unreserve:
 	ttm_eu_backoff_reservation(&ticket, &list);
 
-- 
1.9.1



More information about the dri-devel mailing list