All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: Stefan Wahren <stefan.wahren@i2se.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: vc4: Fix race during binding
Date: Sun, 08 Oct 2017 10:09:29 -0700	[thread overview]
Message-ID: <87zi91bm7q.fsf@anholt.net> (raw)
In-Reply-To: <1623255519.108982.1507363997162@email.1und1.de>


[-- Attachment #1.1: Type: text/plain, Size: 2615 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

> Hi Eric,
>
>> Eric Anholt <eric@anholt.net> hat am 6. Oktober 2017 um 21:42 geschrieben:
>> 
>> 
>> Stefan Wahren <stefan.wahren@i2se.com> writes:
>> 
>> > This fixes the race between vc4_overflow_mem_work and the init of the
>> > job lock. Otherwise we could trigger a NULL pointer dereference
>> > during VC4 binding.
>> >
>> > Link: https://github.com/anholt/linux/issues/114
>> > Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>> > Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
>> > ---
>> >  drivers/gpu/drm/vc4/vc4_gem.c | 1 -
>> >  drivers/gpu/drm/vc4/vc4_irq.c | 1 +
>> >  2 files changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
>> > index d0c6bfb..47d964f 100644
>> > --- a/drivers/gpu/drm/vc4/vc4_gem.c
>> > +++ b/drivers/gpu/drm/vc4/vc4_gem.c
>> > @@ -1088,7 +1088,6 @@ vc4_gem_init(struct drm_device *dev)
>> >  	INIT_LIST_HEAD(&vc4->render_job_list);
>> >  	INIT_LIST_HEAD(&vc4->job_done_list);
>> >  	INIT_LIST_HEAD(&vc4->seqno_cb_list);
>> > -	spin_lock_init(&vc4->job_lock);
>> >  
>> >  	INIT_WORK(&vc4->hangcheck.reset_work, vc4_reset_work);
>> >  	setup_timer(&vc4->hangcheck.timer,
>> > diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
>> > index 7d7af3a..d508d13 100644
>> > --- a/drivers/gpu/drm/vc4/vc4_irq.c
>> > +++ b/drivers/gpu/drm/vc4/vc4_irq.c
>> > @@ -195,6 +195,7 @@ vc4_irq_preinstall(struct drm_device *dev)
>> >  	struct vc4_dev *vc4 = to_vc4_dev(dev);
>> >  
>> >  	init_waitqueue_head(&vc4->job_wait_queue);
>> > +	spin_lock_init(&vc4->job_lock);
>> >  	INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work);
>> >  
>> >  	/* Clear any pending interrupts someone might have left around
>> 
>> Are you sure this is a fix?  We don't attach the IRQ handler until V3D
>> bind, and vc4_gem_init happens before component_bind_all(), right?
>
> i agree i should have mark it as a RFC. But is it really impossible
> that vc4_overflow_mem_work is triggered before vc4_gem_init?

As far as I can see, it gets queued from the IRQ handler, the IRQ
handler is added during V3D bind, and binding happens after GEM init.

Hmm.  If we fail out of component binding and try again, we'll end up
doing the job_wait_queue and overflow_mem_work initialization on the
same pointer twice.  Will that cause any trouble?  We cancel any pending
work during uninstall (V3D unbind path), but does drm_irq_uninstall()
make sure that the irq handler has finished?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-10-08 17:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06 18:43 [PATCH] drm: vc4: Fix race during binding Stefan Wahren
2017-10-06 19:42 ` Eric Anholt
2017-10-07  8:13   ` Stefan Wahren
2017-10-08 17:09     ` Eric Anholt [this message]
2017-10-08 18:51       ` Stefan Wahren

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=87zi91bm7q.fsf@anholt.net \
    --to=eric@anholt.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=stefan.wahren@i2se.com \
    /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.