dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state
       [not found] <565C1BE2.3000607@linux.intel.com>
@ 2015-11-30 23:22 ` Matt Roper
  2015-12-01  7:24   ` Daniel Vetter
  2015-12-01  7:37   ` Maarten Lankhorst
  0 siblings, 2 replies; 3+ messages in thread
From: Matt Roper @ 2015-11-30 23:22 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, dri-devel

Callers of drm_atomic_helper_duplicate_state() may not have grabbed
locks before calling this function.  We're not supposed to iterate over
connectors without holding connection_mutex (since MST allows new
connectors to be spawned at hotplug), so make sure we grab that
ourselves before invoking drm_for_each_connector().  Failure to grab
this lock would cause us to stumble over the assertion added in commit:

        commit 7a3f3d6667f5f9ffd1517f6b21d64bbf5312042c
        Author: Daniel Vetter <daniel.vetter@ffwll.ch>
        Date:   Thu Jul 9 23:44:28 2015 +0200

            drm: Check locking in drm_for_each_connector

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 3731a26..e5d0b21 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2478,6 +2478,10 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	err = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
+	if (err)
+		goto free;
+
 	drm_for_each_connector(conn, dev) {
 		struct drm_connector_state *conn_state;
 
-- 
2.1.4

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

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

* Re: [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state
  2015-11-30 23:22 ` [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state Matt Roper
@ 2015-12-01  7:24   ` Daniel Vetter
  2015-12-01  7:37   ` Maarten Lankhorst
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2015-12-01  7:24 UTC (permalink / raw)
  To: Matt Roper; +Cc: Daniel Vetter, intel-gfx, dri-devel

On Mon, Nov 30, 2015 at 03:22:49PM -0800, Matt Roper wrote:
> Callers of drm_atomic_helper_duplicate_state() may not have grabbed
> locks before calling this function.  We're not supposed to iterate over
> connectors without holding connection_mutex (since MST allows new
> connectors to be spawned at hotplug), so make sure we grab that
> ourselves before invoking drm_for_each_connector().  Failure to grab
> this lock would cause us to stumble over the assertion added in commit:
> 
>         commit 7a3f3d6667f5f9ffd1517f6b21d64bbf5312042c
>         Author: Daniel Vetter <daniel.vetter@ffwll.ch>
>         Date:   Thu Jul 9 23:44:28 2015 +0200
> 
>             drm: Check locking in drm_for_each_connector
> 
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

These helpers are wip and Thierry is working on some additional
higher-level wrappers for bullet proof save/restore for atomic drivers.
It's very much intentinoal that this function here does _not_ grab any
locks - if it does the higher-level magic would be impossible.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 3731a26..e5d0b21 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2478,6 +2478,10 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
>  		}
>  	}
>  
> +	err = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
> +	if (err)
> +		goto free;
> +
>  	drm_for_each_connector(conn, dev) {
>  		struct drm_connector_state *conn_state;
>  
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
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] 3+ messages in thread

* Re: [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state
  2015-11-30 23:22 ` [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state Matt Roper
  2015-12-01  7:24   ` Daniel Vetter
@ 2015-12-01  7:37   ` Maarten Lankhorst
  1 sibling, 0 replies; 3+ messages in thread
From: Maarten Lankhorst @ 2015-12-01  7:37 UTC (permalink / raw)
  To: Matt Roper, intel-gfx; +Cc: Daniel Vetter, dri-devel

Op 01-12-15 om 00:22 schreef Matt Roper:
> Callers of drm_atomic_helper_duplicate_state() may not have grabbed
> locks before calling this function.  We're not supposed to iterate over
> connectors without holding connection_mutex (since MST allows new
> connectors to be spawned at hotplug), so make sure we grab that
> ourselves before invoking drm_for_each_connector().  Failure to grab
> this lock would cause us to stumble over the assertion added in commit:
>
>         commit 7a3f3d6667f5f9ffd1517f6b21d64bbf5312042c
>         Author: Daniel Vetter <daniel.vetter@ffwll.ch>
>         Date:   Thu Jul 9 23:44:28 2015 +0200
>
>             drm: Check locking in drm_for_each_connector
>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 3731a26..e5d0b21 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2478,6 +2478,10 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
>  		}
>  	}
>  
> +	err = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
> +	if (err)
> +		goto free;
> +
>  	drm_for_each_connector(conn, dev) {
>  		struct drm_connector_state *conn_state;
>  
Thanks, that's a lot better than just a random hunk without explanation.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-12-01  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <565C1BE2.3000607@linux.intel.com>
2015-11-30 23:22 ` [PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state Matt Roper
2015-12-01  7:24   ` Daniel Vetter
2015-12-01  7:37   ` Maarten Lankhorst

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