diff mbox

drm/radeon: fix vm lock in radeon_gem_va_update_vm

Message ID 1414056758-2267-1-git-send-email-deathsimple@vodafone.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christian König Oct. 23, 2014, 9:32 a.m. UTC
From: Christian König <christian.koenig@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@amd.com>
---
 drivers/gpu/drm/radeon/radeon_gem.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Alex Deucher Oct. 27, 2014, 4:03 p.m. UTC | #1
On Thu, Oct 23, 2014 at 5:32 AM, Christian König
<deathsimple@vodafone.de> wrote:
> From: Christian König <christian.koenig@amd.com>
>
> Without the lock we might corrupt the BO lists.
>
> Might be squashed into "update the VM after setting BO address" for upstreaming.

Squashed into that commit.

Thanks!

Alex

>
> Signed-off-by: Christian König <christian.koenig@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
>
diff mbox

Patch

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);