All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/atomic: Make the kerneldoc a bit clearer
@ 2020-10-02  7:56 Daniel Vetter
  2020-10-02 12:31 ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2020-10-02  7:56 UTC (permalink / raw)
  To: DRI Development
  Cc: David Airlie, Daniel Vetter, Thomas Zimmermann, Daniel Vetter

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

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/drm_atomic.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index aac9122f1da2..b2d20eb6c807 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -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)
 {
-- 
2.28.0

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/atomic: Make the kerneldoc a bit clearer
  2020-10-02  7:56 [PATCH] drm/atomic: Make the kerneldoc a bit clearer Daniel Vetter
@ 2020-10-02 12:31 ` Maxime Ripard
  2020-10-02 12:37   ` Daniel Vetter
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Ripard @ 2020-10-02 12:31 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Thomas Zimmermann, David Airlie, DRI Development, Daniel Vetter


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

Hi,

On Fri, Oct 02, 2020 at 09:56:20AM +0200, Daniel Vetter wrote:
> Crank up the warning a notch and point at the right set of locking
> functions for atomic drivers.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_atomic.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index aac9122f1da2..b2d20eb6c807 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -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)
>  {

For the comment itself:
Acked-by: Maxime Ripard <mripard@kernel.org>

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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/atomic: Make the kerneldoc a bit clearer
  2020-10-02 12:31 ` Maxime Ripard
@ 2020-10-02 12:37   ` Daniel Vetter
  2020-10-02 14:54     ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2020-10-02 12:37 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: David Airlie, Daniel Vetter, Thomas Zimmermann, DRI Development

On Fri, Oct 2, 2020 at 2:31 PM Maxime Ripard <maxime@cerno.tech> wrote:
>
> Hi,
>
> On Fri, Oct 02, 2020 at 09:56:20AM +0200, Daniel Vetter wrote:
> > Crank up the warning a notch and point at the right set of locking
> > functions for atomic drivers.
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Maxime Ripard <mripard@kernel.org>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > ---
> >  drivers/gpu/drm/drm_atomic.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index aac9122f1da2..b2d20eb6c807 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -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)
> >  {
>
> For the comment itself:
> Acked-by: Maxime Ripard <mripard@kernel.org>

Thanks for taking a look, will merge.

> 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
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/atomic: Make the kerneldoc a bit clearer
  2020-10-02 12:37   ` Daniel Vetter
@ 2020-10-02 14:54     ` Maxime Ripard
  0 siblings, 0 replies; 4+ messages in thread
From: Maxime Ripard @ 2020-10-02 14:54 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: David Airlie, Daniel Vetter, Thomas Zimmermann, DRI Development


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

On Fri, Oct 02, 2020 at 02:37:25PM +0200, Daniel Vetter wrote:
> On Fri, Oct 2, 2020 at 2:31 PM Maxime Ripard <maxime@cerno.tech> wrote:
> > On Fri, Oct 02, 2020 at 09:56:20AM +0200, Daniel Vetter wrote:
> > > Crank up the warning a notch and point at the right set of locking
> > > functions for atomic drivers.
> > >
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Maxime Ripard <mripard@kernel.org>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > ---
> > >  drivers/gpu/drm/drm_atomic.c | 10 +++++-----
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > > index aac9122f1da2..b2d20eb6c807 100644
> > > --- a/drivers/gpu/drm/drm_atomic.c
> > > +++ b/drivers/gpu/drm/drm_atomic.c
> > > @@ -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)
> > >  {
> >
> > For the comment itself:
> > Acked-by: Maxime Ripard <mripard@kernel.org>
> 
> Thanks for taking a look, will merge.
> 
> > 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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-03  9:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02  7:56 [PATCH] drm/atomic: Make the kerneldoc a bit clearer Daniel Vetter
2020-10-02 12:31 ` Maxime Ripard
2020-10-02 12:37   ` Daniel Vetter
2020-10-02 14:54     ` Maxime Ripard

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.