From: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/nouveau: add locking around instobj list operations
Date: Sun, 2 Dec 2012 15:15:22 +0100 [thread overview]
Message-ID: <20121202141522.GB3094@joi.lan> (raw)
In-Reply-To: <20121202135301.GA3094-OI9uyE9O0yo@public.gmane.org>
On Sun, Dec 02, 2012 at 02:53:01PM +0100, Marcin Slusarz wrote:
> Fixes memory corruptions (unrelated to nouveau!), oopses, gpu lockups and
> xserver crashes when multiple gpuobjs are simultaneously created / destroyed.
>
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> Piglit, with concurrency enabled, can finally finish without crashes or lockups
> (most of the time :).
It would be awesome to have this in 3.7/3.7.x ;).
> ---
> drivers/gpu/drm/nouveau/core/subdev/instmem/base.c | 35 +++++++++++++++++-----
> 1 file changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
> index 1188227..6565f3d 100644
> --- a/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
> +++ b/drivers/gpu/drm/nouveau/core/subdev/instmem/base.c
> @@ -40,15 +40,21 @@ nouveau_instobj_create_(struct nouveau_object *parent,
> if (ret)
> return ret;
>
> + mutex_lock(&imem->base.mutex);
> list_add(&iobj->head, &imem->list);
> + mutex_unlock(&imem->base.mutex);
> return 0;
> }
>
> void
> nouveau_instobj_destroy(struct nouveau_instobj *iobj)
> {
> - if (iobj->head.prev)
> - list_del(&iobj->head);
> + struct nouveau_subdev *subdev = nv_subdev(iobj->base.engine);
> +
> + mutex_lock(&subdev->mutex);
> + list_del(&iobj->head);
> + mutex_unlock(&subdev->mutex);
> +
> return nouveau_object_destroy(&iobj->base);
> }
>
> @@ -88,6 +94,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
> if (ret)
> return ret;
>
> + mutex_lock(&imem->base.mutex);
> +
> list_for_each_entry(iobj, &imem->list, head) {
> if (iobj->suspend) {
> for (i = 0; i < iobj->size; i += 4)
> @@ -97,6 +105,8 @@ nouveau_instmem_init(struct nouveau_instmem *imem)
> }
> }
>
> + mutex_unlock(&imem->base.mutex);
> +
> return 0;
> }
>
> @@ -104,17 +114,26 @@ int
> nouveau_instmem_fini(struct nouveau_instmem *imem, bool suspend)
> {
> struct nouveau_instobj *iobj;
> - int i;
> + int i, ret = 0;
>
> if (suspend) {
> + mutex_lock(&imem->base.mutex);
> +
> list_for_each_entry(iobj, &imem->list, head) {
> iobj->suspend = vmalloc(iobj->size);
> - if (iobj->suspend) {
> - for (i = 0; i < iobj->size; i += 4)
> - iobj->suspend[i / 4] = nv_ro32(iobj, i);
> - } else
> - return -ENOMEM;
> + if (!iobj->suspend) {
> + ret = -ENOMEM;
> + break;
> + }
> +
> + for (i = 0; i < iobj->size; i += 4)
> + iobj->suspend[i / 4] = nv_ro32(iobj, i);
> }
> +
> + mutex_unlock(&imem->base.mutex);
> +
> + if (ret)
> + return ret;
> }
>
> return nouveau_subdev_fini(&imem->base, suspend);
> --
> 1.7.12
>
prev parent reply other threads:[~2012-12-02 14:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-02 13:53 [PATCH] drm/nouveau: add locking around instobj list operations Marcin Slusarz
[not found] ` <20121202135301.GA3094-OI9uyE9O0yo@public.gmane.org>
2012-12-02 14:15 ` Marcin Slusarz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121202141522.GB3094@joi.lan \
--to=marcin.slusarz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.