diff mbox

[01/13] drm/msm: Take the mutex before calling msm_gem_new_impl

Message ID 1494275709-25782-2-git-send-email-jcrouse@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jordan Crouse May 8, 2017, 8:34 p.m. UTC
Amongst its other duties, msm_gem_new_impl adds the newly created
GEM object to the shared inactive list which may also be actively
modifiying the list during submission.  All the paths to modify
the list are protected by the mutex except for the one through
msm_gem_import which can end up causing list corruption.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/msm/msm_gem.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Rob Clark May 8, 2017, 8:39 p.m. UTC | #1
On Mon, May 8, 2017 at 4:34 PM, Jordan Crouse <jcrouse@codeaurora.org> wrote:
> Amongst its other duties, msm_gem_new_impl adds the newly created
> GEM object to the shared inactive list which may also be actively
> modifiying the list during submission.  All the paths to modify
> the list are protected by the mutex except for the one through
> msm_gem_import which can end up causing list corruption.

hmm, I guess it would be a good idea to also throw one of these into
msm_gem_new_impl():

    WARN_ON(!mutex_is_locked(&dev->struct_mutex));

BR,
-R

> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/msm_gem.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index 68e509b..7a82eaa 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -853,7 +853,11 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
>
>         size = PAGE_ALIGN(dmabuf->size);
>
> +       /* Take mutex so we can modify the inactive list in msm_gem_new_impl */
> +       mutex_lock(&dev->struct_mutex);
>         ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj);
> +       mutex_unlock(&dev->struct_mutex);
> +
>         if (ret)
>                 goto fail;
>
> --
> 1.9.1
>
> _______________________________________________
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 68e509b..7a82eaa 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -853,7 +853,11 @@  struct drm_gem_object *msm_gem_import(struct drm_device *dev,
 
 	size = PAGE_ALIGN(dmabuf->size);
 
+	/* Take mutex so we can modify the inactive list in msm_gem_new_impl */
+	mutex_lock(&dev->struct_mutex);
 	ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj);
+	mutex_unlock(&dev->struct_mutex);
+
 	if (ret)
 		goto fail;