public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/atomic: Paper over locking WARN in default_state_clear
@ 2015-07-29 10:51 Daniel Vetter
  2015-07-30 11:23 ` shuang.he
  2015-07-31  8:34 ` Maarten Lankhorst
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Vetter @ 2015-07-29 10:51 UTC (permalink / raw)
  To: Intel Graphics Development, DRI Development; +Cc: Daniel Vetter, Daniel Vetter

In

commit 6f75cea66c8dd043ced282016b21a639af176642
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Wed Nov 19 18:38:07 2014 +0100

    drm/atomic: Only destroy connector states with connection mutex held

I tried to fix races of atomic commits against connector
hot-unplugging. The idea is to ensure lifetimes by holding the
connection_mutex long enough. That works for synchronous commits, but
not for async ones.

For async atomic commit we really need to fix up connector lifetimes
for real. But that's a much bigger task, so just add more duct-tape:
For cleaning up connector states we currently don't need the connector
itself. So NULL it out and remove the locking check. Of course that
check was to protect the entire sequence, but the modeset itself
should be save since currently DP MST hot-removal does a dpms-off. And
that should synchronize with any outstanding async atomic commit.

Or at least that's my hope, this is all a giant mess.

Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_atomic.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3efd91c0c6cb..434915448ea0 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -153,9 +153,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 		if (!connector)
 			continue;
 
-		WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
-		connector->funcs->atomic_destroy_state(connector,
+		/*
+		 * FIXME: Async commits can race with connector unplugging and
+		 * there's currently nothing that prevents cleanup up state for
+		 * deleted connectors. As long as the callback doesn't look at
+		 * the connector we'll be fine though, so make sure that's the
+		 * case by setting all connector pointers to NULL.
+		 */
+		state->connector_states[i]->connector = NULL;
+		connector->funcs->atomic_destroy_state(NULL,
 						       state->connector_states[i]);
 		state->connectors[i] = NULL;
 		state->connector_states[i] = NULL;
-- 
2.5.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/atomic: Paper over locking WARN in default_state_clear
  2015-07-29 10:51 [PATCH] drm/atomic: Paper over locking WARN in default_state_clear Daniel Vetter
@ 2015-07-30 11:23 ` shuang.he
  2015-07-31  8:34 ` Maarten Lankhorst
  1 sibling, 0 replies; 5+ messages in thread
From: shuang.he @ 2015-07-30 11:23 UTC (permalink / raw)
  To: shuang.he, julianx.dumez, christophe.sureau, lei.a.liu, intel-gfx,
	daniel.vetter

Tested-By: Intel Graphics QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
Task id: 6888
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
ILK                 -1              297/297              296/297
SNB                                  315/315              315/315
IVB                                  342/342              342/342
BYT                                  282/282              282/282
HSW                                  378/378              378/378
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
*ILK  igt@kms_flip@rcs-wf_vblank-vs-dpms-interruptible      PASS(1)      DMESG_WARN(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/atomic: Paper over locking WARN in default_state_clear
  2015-07-29 10:51 [PATCH] drm/atomic: Paper over locking WARN in default_state_clear Daniel Vetter
  2015-07-30 11:23 ` shuang.he
@ 2015-07-31  8:34 ` Maarten Lankhorst
  2015-07-31 13:41   ` Daniel Vetter
  1 sibling, 1 reply; 5+ messages in thread
From: Maarten Lankhorst @ 2015-07-31  8:34 UTC (permalink / raw)
  To: Daniel Vetter, Intel Graphics Development, DRI Development; +Cc: Daniel Vetter

Hey,

Op 29-07-15 om 12:51 schreef Daniel Vetter:
> In
>
> commit 6f75cea66c8dd043ced282016b21a639af176642
> Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> Date:   Wed Nov 19 18:38:07 2014 +0100
>
>     drm/atomic: Only destroy connector states with connection mutex held
>
> I tried to fix races of atomic commits against connector
> hot-unplugging. The idea is to ensure lifetimes by holding the
> connection_mutex long enough. That works for synchronous commits, but
> not for async ones.
>
> For async atomic commit we really need to fix up connector lifetimes
> for real. But that's a much bigger task, so just add more duct-tape:
> For cleaning up connector states we currently don't need the connector
> itself. So NULL it out and remove the locking check. Of course that
> check was to protect the entire sequence, but the modeset itself
> should be save since currently DP MST hot-removal does a dpms-off. And
> that should synchronize with any outstanding async atomic commit.
>
> Or at least that's my hope, this is all a giant mess.
>
> Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/gpu/drm/drm_atomic.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 3efd91c0c6cb..434915448ea0 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -153,9 +153,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
>  		if (!connector)
>  			continue;
>  
> -		WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
> -
> -		connector->funcs->atomic_destroy_state(connector,
> +		/*
> +		 * FIXME: Async commits can race with connector unplugging and
> +		 * there's currently nothing that prevents cleanup up state for
> +		 * deleted connectors. As long as the callback doesn't look at
> +		 * the connector we'll be fine though, so make sure that's the
> +		 * case by setting all connector pointers to NULL.
> +		 */
> +		state->connector_states[i]->connector = NULL;
> +		connector->funcs->atomic_destroy_state(NULL,
>  						       state->connector_states[i]);
>
This wouldn't provide any additional guarantee during the async commit itself, so please don't do this. :-)
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/atomic: Paper over locking WARN in default_state_clear
  2015-07-31  8:34 ` Maarten Lankhorst
@ 2015-07-31 13:41   ` Daniel Vetter
  2015-08-10 12:10     ` Daniel Vetter
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2015-07-31 13:41 UTC (permalink / raw)
  To: Maarten Lankhorst
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Fri, Jul 31, 2015 at 10:34:43AM +0200, Maarten Lankhorst wrote:
> Hey,
> 
> Op 29-07-15 om 12:51 schreef Daniel Vetter:
> > In
> >
> > commit 6f75cea66c8dd043ced282016b21a639af176642
> > Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Date:   Wed Nov 19 18:38:07 2014 +0100
> >
> >     drm/atomic: Only destroy connector states with connection mutex held
> >
> > I tried to fix races of atomic commits against connector
> > hot-unplugging. The idea is to ensure lifetimes by holding the
> > connection_mutex long enough. That works for synchronous commits, but
> > not for async ones.
> >
> > For async atomic commit we really need to fix up connector lifetimes
> > for real. But that's a much bigger task, so just add more duct-tape:
> > For cleaning up connector states we currently don't need the connector
> > itself. So NULL it out and remove the locking check. Of course that
> > check was to protect the entire sequence, but the modeset itself
> > should be save since currently DP MST hot-removal does a dpms-off. And
> > that should synchronize with any outstanding async atomic commit.
> >
> > Or at least that's my hope, this is all a giant mess.
> >
> > Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/gpu/drm/drm_atomic.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index 3efd91c0c6cb..434915448ea0 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -153,9 +153,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
> >  		if (!connector)
> >  			continue;
> >  
> > -		WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
> > -
> > -		connector->funcs->atomic_destroy_state(connector,
> > +		/*
> > +		 * FIXME: Async commits can race with connector unplugging and
> > +		 * there's currently nothing that prevents cleanup up state for
> > +		 * deleted connectors. As long as the callback doesn't look at
> > +		 * the connector we'll be fine though, so make sure that's the
> > +		 * case by setting all connector pointers to NULL.
> > +		 */
> > +		state->connector_states[i]->connector = NULL;
> > +		connector->funcs->atomic_destroy_state(NULL,
> >  						       state->connector_states[i]);
> >
> This wouldn't provide any additional guarantee during the async commit
> itself, so please don't do this. :-)

Nope, it's really just a big reminder that we have a bug here.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/atomic: Paper over locking WARN in default_state_clear
  2015-07-31 13:41   ` Daniel Vetter
@ 2015-08-10 12:10     ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2015-08-10 12:10 UTC (permalink / raw)
  To: Maarten Lankhorst
  Cc: Daniel Vetter, Intel Graphics Development, DRI Development,
	Daniel Vetter

On Fri, Jul 31, 2015 at 03:41:15PM +0200, Daniel Vetter wrote:
> On Fri, Jul 31, 2015 at 10:34:43AM +0200, Maarten Lankhorst wrote:
> > Hey,
> > 
> > Op 29-07-15 om 12:51 schreef Daniel Vetter:
> > > In
> > >
> > > commit 6f75cea66c8dd043ced282016b21a639af176642
> > > Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Date:   Wed Nov 19 18:38:07 2014 +0100
> > >
> > >     drm/atomic: Only destroy connector states with connection mutex held
> > >
> > > I tried to fix races of atomic commits against connector
> > > hot-unplugging. The idea is to ensure lifetimes by holding the
> > > connection_mutex long enough. That works for synchronous commits, but
> > > not for async ones.
> > >
> > > For async atomic commit we really need to fix up connector lifetimes
> > > for real. But that's a much bigger task, so just add more duct-tape:
> > > For cleaning up connector states we currently don't need the connector
> > > itself. So NULL it out and remove the locking check. Of course that
> > > check was to protect the entire sequence, but the modeset itself
> > > should be save since currently DP MST hot-removal does a dpms-off. And
> > > that should synchronize with any outstanding async atomic commit.
> > >
> > > Or at least that's my hope, this is all a giant mess.
> > >
> > > Reported-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_atomic.c | 12 +++++++++---
> > >  1 file changed, 9 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > > index 3efd91c0c6cb..434915448ea0 100644
> > > --- a/drivers/gpu/drm/drm_atomic.c
> > > +++ b/drivers/gpu/drm/drm_atomic.c
> > > @@ -153,9 +153,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
> > >  		if (!connector)
> > >  			continue;
> > >  
> > > -		WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
> > > -
> > > -		connector->funcs->atomic_destroy_state(connector,
> > > +		/*
> > > +		 * FIXME: Async commits can race with connector unplugging and
> > > +		 * there's currently nothing that prevents cleanup up state for
> > > +		 * deleted connectors. As long as the callback doesn't look at
> > > +		 * the connector we'll be fine though, so make sure that's the
> > > +		 * case by setting all connector pointers to NULL.
> > > +		 */
> > > +		state->connector_states[i]->connector = NULL;
> > > +		connector->funcs->atomic_destroy_state(NULL,
> > >  						       state->connector_states[i]);
> > >
> > This wouldn't provide any additional guarantee during the async commit
> > itself, so please don't do this. :-)
> 
> Nope, it's really just a big reminder that we have a bug here.

Ok, picked up to drm-misc with Maarten's irc r-b.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-08-10 12:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-29 10:51 [PATCH] drm/atomic: Paper over locking WARN in default_state_clear Daniel Vetter
2015-07-30 11:23 ` shuang.he
2015-07-31  8:34 ` Maarten Lankhorst
2015-07-31 13:41   ` Daniel Vetter
2015-08-10 12:10     ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox