Skip to contentSkip to conversation

drm/atomic: Make the kerneldoc a bit clearer

PATCH In review Daniel Vetter 2 participants 4 messages Oct 2, 2020 – Oct 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic: Make the kerneldoc a bit clearer

Crank up the warning a notch and point at the right set of locking functions for atomic drivers.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic.c +5 -5
index aac9122f1da2..b2d20eb6c807 100644
@@ -1642,11 +1642,11 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
  * to dmesg in case of error irq's.  (Hint, you probably want to
  * ratelimit this!)
  *
- * The caller must drm_modeset_lock_all(), or if this is called
- * from error irq handler, it should not be enabled by default.
- * (Ie. if you are debugging errors you might not care that this
- * is racey.  But calling this without all modeset locks held is
- * not inherently safe.)
+ * The caller must wrap this drm_modeset_lock_all_ctx() and
+ * drm_modeset_drop_locks(). If this is called from error irq handler, it should
+ * not be enabled by default - if you are debugging errors you might
+ * not care that this is racey, but calling this without all modeset locks held
+ * is inherently unsafe.
  */
 void drm_state_dump(struct drm_device *dev, struct drm_printer *p)
 {
Signature · 6 lines
2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 24 lines · Daniel Vetter

Crank up the warning a notch and point at the right set of locking functions for atomic drivers.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic.c +0 -3
index aac9122f1da2..b2d20eb6c807 100644
@@ -1642,11 +1642,11 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
  * to dmesg in case of error irq's.  (Hint, you probably want to
  * ratelimit this!)
  *
- * The caller must drm_modeset_lock_all(), or if this is called
- * from error irq handler, it should not be enabled by default.
- * (Ie. if you are debugging errors you might not care that this

drivers/gpu/drm/drm_atomic.c static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, · line 1652

Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5 -2
- * is racey.  But calling this without all modeset locks held is
- * not inherently safe.)
+ * The caller must wrap this drm_modeset_lock_all_ctx() and
+ * drm_modeset_drop_locks(). If this is called from error irq handler, it should
+ * not be enabled by default - if you are debugging errors you might
+ * not care that this is racey, but calling this without all modeset locks held
+ * is inherently unsafe.
  */
 void drm_state_dump(struct drm_device *dev, struct drm_printer *p)
 {

For the comment itself:

But maybe we should add some lockdep assertion to make sure we can catch someone actually doing this?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 40 lines · Maxime Ripard

Hi,

Quoted 24 lines · Daniel Vetter

Crank up the warning a notch and point at the right set of locking functions for atomic drivers.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic.c +0 -3
index aac9122f1da2..b2d20eb6c807 100644
@@ -1642,11 +1642,11 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
  * to dmesg in case of error irq's.  (Hint, you probably want to
  * ratelimit this!)
  *
- * The caller must drm_modeset_lock_all(), or if this is called
- * from error irq handler, it should not be enabled by default.
- * (Ie. if you are debugging errors you might not care that this

drivers/gpu/drm/drm_atomic.c static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, · line 1652

Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5 -2
- * is racey.  But calling this without all modeset locks held is
- * not inherently safe.)
+ * The caller must wrap this drm_modeset_lock_all_ctx() and
+ * drm_modeset_drop_locks(). If this is called from error irq handler, it should
+ * not be enabled by default - if you are debugging errors you might
+ * not care that this is racey, but calling this without all modeset locks held
+ * is inherently unsafe.
  */
 void drm_state_dump(struct drm_device *dev, struct drm_printer *p)
 {

For the comment itself:

Quoted 1 line

Thanks for taking a look, will merge.

Quoted 2 lines

But maybe we should add some lockdep assertion to make sure we can catch someone actually doing this?

I think it has some use for ad-hoc debugging in random places, or maybe as a an opt-in "tains your kernel" debug option. And then you really don't want your useful debug output burried in a few pages of lockdep splat first :-)
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 42 lines · Daniel Vetter
Quoted 37 lines · Maxime Ripard
Quoted 24 lines · Daniel Vetter

Crank up the warning a notch and point at the right set of locking functions for atomic drivers.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic.c +0 -3
index aac9122f1da2..b2d20eb6c807 100644
@@ -1642,11 +1642,11 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,
  * to dmesg in case of error irq's.  (Hint, you probably want to
  * ratelimit this!)
  *
- * The caller must drm_modeset_lock_all(), or if this is called
- * from error irq handler, it should not be enabled by default.
- * (Ie. if you are debugging errors you might not care that this

drivers/gpu/drm/drm_atomic.c static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, · line 1652

Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +5 -2
- * is racey.  But calling this without all modeset locks held is
- * not inherently safe.)
+ * The caller must wrap this drm_modeset_lock_all_ctx() and
+ * drm_modeset_drop_locks(). If this is called from error irq handler, it should
+ * not be enabled by default - if you are debugging errors you might
+ * not care that this is racey, but calling this without all modeset locks held
+ * is inherently unsafe.
  */
 void drm_state_dump(struct drm_device *dev, struct drm_printer *p)
 {

For the comment itself:

Quoted 1 line

Thanks for taking a look, will merge.

Quoted 7 lines
Quoted 2 lines

But maybe we should add some lockdep assertion to make sure we can catch someone actually doing this?

I think it has some use for ad-hoc debugging in random places, or maybe as a an opt-in "tains your kernel" debug option. And then you really don't want your useful debug output burried in a few pages of lockdep splat first :-)

Yeah, but at the same time reducing the discoverability of this locking expectation for the common case to favor some one-off debugging by someone that has more chance to know better seems like not the best trade-off.

Or maybe make the assertion conditional on drm.debug not being set or something?

Maxime

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel