drm: Assert correct locking for drm_send_vblank_event
Subsystems (2)
PATCH 1/1 drm: Assert correct locking for drm_send_vblank_event
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.
--- drivers/gpu/drm/drm_irq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_irq.c +3 -0
@@ -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 {
Signature · 1 line
1.9.3
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 10 lines · Chris Wilson
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Chris Wilson
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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.
Quoted 5 lines
Quoted 2 lines
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
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Chris Wilson
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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_lockwas the preferred form?
Actually, lockdep_assert_held() is the preferred form.
See https://lkml.org/lkml/2014/9/3/171
Regards,
Peter Hurley
Quoted 14 lines · Peter Hurley
Quoted 13 lines · Chris Wilson
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Chris Wilson
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Meh, I've missed that one, that's actually better I think. I'll drop my patch here.
I thought
assert_spin_lockwas the preferred form?Actually,
lockdep_assert_held()is the preferred form.
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
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Peter Hurley
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Daniel Vetter
Quoted 8 lines · Chris Wilson
Quoted 6 lines · Daniel Vetter
The comment says that the caller must hold the
dev->event_lockspinlock, 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.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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_lockwas the preferred form?Actually,
lockdep_assert_held()is the preferred form.
Quoted 7 lines
Quoted 1 line
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]:
Quoted 2 lines · Peter Hurley
So a lockdep-only assert is unlikely to draw attention to existing bugs, especially in established drivers.
here's the replies I got:
Quoted 2 lines · Peter Zijlstra
By the same logic lockdep will not find locking errors in established drivers.
and
Quoted 9 lines · Ingo Molnar
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