* [PATCH] drm: Assert correct locking for drm_send_vblank_event @ 2014-09-12 13:40 Daniel Vetter 2014-09-12 15:23 ` Chris Wilson 0 siblings, 1 reply; 7+ messages in thread From: Daniel Vetter @ 2014-09-12 13:40 UTC (permalink / raw) To: Intel Graphics Development; +Cc: Daniel Vetter, dri-devel The comment says that the caller must hold the dev->event_lock spinlock, so let's enforce this. A quick audit over all driver shows that except for the one place in i915 which motivated this all callers fullfill this requirement already. Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: dri-devel@lists.freedesktop.org Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> --- drivers/gpu/drm/drm_irq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 80ff94ada75e..bf248eb9ffb2 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -907,6 +907,9 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc, { struct timeval now; unsigned int seq; + + assert_spin_locked(&dev->event_lock); + if (crtc >= 0) { seq = drm_vblank_count_and_time(dev, crtc, &now); } else { -- 1.9.3 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 13:40 [PATCH] drm: Assert correct locking for drm_send_vblank_event Daniel Vetter @ 2014-09-12 15:23 ` Chris Wilson 2014-09-12 15:34 ` Daniel Vetter 0 siblings, 1 reply; 7+ messages in thread From: Chris Wilson @ 2014-09-12 15:23 UTC (permalink / raw) To: Daniel Vetter; +Cc: Intel Graphics Development, dri-devel On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: > The comment says that the caller must hold the dev->event_lock > spinlock, so let's enforce this. > > A quick audit over all driver shows that except for the one place in > i915 which motivated this all callers fullfill this requirement > already. Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in send_vblank_event() as well then. -Chris -- Chris Wilson, Intel Open Source Technology Centre ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 15:23 ` Chris Wilson @ 2014-09-12 15:34 ` Daniel Vetter 2014-09-12 16:04 ` [Intel-gfx] " Chris Wilson 0 siblings, 1 reply; 7+ messages in thread From: Daniel Vetter @ 2014-09-12 15:34 UTC (permalink / raw) To: Chris Wilson, Daniel Vetter, Intel Graphics Development, dri-devel On Fri, Sep 12, 2014 at 04:23:29PM +0100, Chris Wilson wrote: > On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: > > The comment says that the caller must hold the dev->event_lock > > spinlock, so let's enforce this. > > > > A quick audit over all driver shows that except for the one place in > > i915 which motivated this all callers fullfill this requirement > > already. > > Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in > send_vblank_event() as well then. Meh, I've missed that one, that's actually better I think. I'll drop my patch here. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 15:34 ` Daniel Vetter @ 2014-09-12 16:04 ` Chris Wilson 2014-09-12 17:03 ` Peter Hurley 0 siblings, 1 reply; 7+ messages in thread From: Chris Wilson @ 2014-09-12 16:04 UTC (permalink / raw) To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, dri-devel On Fri, Sep 12, 2014 at 05:34:56PM +0200, Daniel Vetter wrote: > On Fri, Sep 12, 2014 at 04:23:29PM +0100, Chris Wilson wrote: > > On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: > > > The comment says that the caller must hold the dev->event_lock > > > spinlock, so let's enforce this. > > > > > > A quick audit over all driver shows that except for the one place in > > > i915 which motivated this all callers fullfill this requirement > > > already. > > > > Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in > > send_vblank_event() as well then. > > Meh, I've missed that one, that's actually better I think. I'll drop my > patch here. I thought assert_spin_lock was the preferred form? -Chris -- Chris Wilson, Intel Open Source Technology Centre ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 16:04 ` [Intel-gfx] " Chris Wilson @ 2014-09-12 17:03 ` Peter Hurley 2014-09-12 17:25 ` [Intel-gfx] " Daniel Vetter 0 siblings, 1 reply; 7+ messages in thread From: Peter Hurley @ 2014-09-12 17:03 UTC (permalink / raw) To: Chris Wilson, Daniel Vetter, Daniel Vetter, Intel Graphics Development, dri-devel On 09/12/2014 12:04 PM, Chris Wilson wrote: > On Fri, Sep 12, 2014 at 05:34:56PM +0200, Daniel Vetter wrote: >> On Fri, Sep 12, 2014 at 04:23:29PM +0100, Chris Wilson wrote: >>> On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: >>>> The comment says that the caller must hold the dev->event_lock >>>> spinlock, so let's enforce this. >>>> >>>> A quick audit over all driver shows that except for the one place in >>>> i915 which motivated this all callers fullfill this requirement >>>> already. >>> >>> Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in >>> send_vblank_event() as well then. >> >> Meh, I've missed that one, that's actually better I think. I'll drop my >> patch here. > > I thought assert_spin_lock was the preferred form? Actually, lockdep_assert_held() is the preferred form. See https://lkml.org/lkml/2014/9/3/171 Regards, Peter Hurley ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Intel-gfx] [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 17:03 ` Peter Hurley @ 2014-09-12 17:25 ` Daniel Vetter 2014-09-12 17:42 ` Peter Hurley 0 siblings, 1 reply; 7+ messages in thread From: Daniel Vetter @ 2014-09-12 17:25 UTC (permalink / raw) To: Peter Hurley; +Cc: Daniel Vetter, Intel Graphics Development, dri-devel On Fri, Sep 12, 2014 at 01:03:51PM -0400, Peter Hurley wrote: > On 09/12/2014 12:04 PM, Chris Wilson wrote: > > On Fri, Sep 12, 2014 at 05:34:56PM +0200, Daniel Vetter wrote: > >> On Fri, Sep 12, 2014 at 04:23:29PM +0100, Chris Wilson wrote: > >>> On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: > >>>> The comment says that the caller must hold the dev->event_lock > >>>> spinlock, so let's enforce this. > >>>> > >>>> A quick audit over all driver shows that except for the one place in > >>>> i915 which motivated this all callers fullfill this requirement > >>>> already. > >>> > >>> Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in > >>> send_vblank_event() as well then. > >> > >> Meh, I've missed that one, that's actually better I think. I'll drop my > >> patch here. > > > > I thought assert_spin_lock was the preferred form? > > Actually, lockdep_assert_held() is the preferred form. > > See https://lkml.org/lkml/2014/9/3/171 Which unfortunately doesn't warn for all the normal users which are not insane enough to enable lockdep and so is totally useless to validate a driver that runs on metric piles of different chips (with a resulting combinatorial explosion of code-paths because hw designers are creative). And we rely a lot on random drive-by testers to report such issues. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drm: Assert correct locking for drm_send_vblank_event 2014-09-12 17:25 ` [Intel-gfx] " Daniel Vetter @ 2014-09-12 17:42 ` Peter Hurley 0 siblings, 0 replies; 7+ messages in thread From: Peter Hurley @ 2014-09-12 17:42 UTC (permalink / raw) To: Daniel Vetter; +Cc: Daniel Vetter, Intel Graphics Development, dri-devel On 09/12/2014 01:25 PM, Daniel Vetter wrote: > On Fri, Sep 12, 2014 at 01:03:51PM -0400, Peter Hurley wrote: >> On 09/12/2014 12:04 PM, Chris Wilson wrote: >>> On Fri, Sep 12, 2014 at 05:34:56PM +0200, Daniel Vetter wrote: >>>> On Fri, Sep 12, 2014 at 04:23:29PM +0100, Chris Wilson wrote: >>>>> On Fri, Sep 12, 2014 at 03:40:56PM +0200, Daniel Vetter wrote: >>>>>> The comment says that the caller must hold the dev->event_lock >>>>>> spinlock, so let's enforce this. >>>>>> >>>>>> A quick audit over all driver shows that except for the one place in >>>>>> i915 which motivated this all callers fullfill this requirement >>>>>> already. >>>>> >>>>> Replace the rogue WARN_ON_SMP(!spin_is_locked(&dev->event_lock)) in >>>>> send_vblank_event() as well then. >>>> >>>> Meh, I've missed that one, that's actually better I think. I'll drop my >>>> patch here. >>> >>> I thought assert_spin_lock was the preferred form? >> >> Actually, lockdep_assert_held() is the preferred form. >> >> See https://lkml.org/lkml/2014/9/3/171 > > Which unfortunately doesn't warn for all the normal users which are not > insane enough to enable lockdep and so is totally useless to validate a > driver that runs on metric piles of different chips (with a resulting > combinatorial explosion of code-paths because hw designers are creative). > And we rely a lot on random drive-by testers to report such issues. I know. When I wrote [in that thread linked above]: On Wed, Sep 03, 2014 at 10:50:01AM -0400, Peter Hurley wrote: > So a lockdep-only assert is unlikely to draw attention to existing bugs, > especially in established drivers. here's the replies I got: Peter Zijlstra <peterz@infradead.org> wrote: > By the same logic lockdep will not find locking errors in established > drivers. and On 09/04/2014 01:14 AM, Ingo Molnar wrote: > Indeed, this patch is ill-advised in several ways: > > - it extends an API variant that we want to phase > > - emits a warning even if say lockdep has already emitted a > warning and locking state is not guaranteed to be consistent. > > - makes the kernel more expensive once fully debugged, in that > non-fatal checks are unconditional. :/ Regards, Peter Hurley ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-09-12 17:42 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-12 13:40 [PATCH] drm: Assert correct locking for drm_send_vblank_event Daniel Vetter 2014-09-12 15:23 ` Chris Wilson 2014-09-12 15:34 ` Daniel Vetter 2014-09-12 16:04 ` [Intel-gfx] " Chris Wilson 2014-09-12 17:03 ` Peter Hurley 2014-09-12 17:25 ` [Intel-gfx] " Daniel Vetter 2014-09-12 17:42 ` Peter Hurley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox