public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Dave Airlie <airlied@redhat.com>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 05/14] drm: Check locking in drm_for_each_connector
Date: Wed, 29 Jul 2015 01:40:10 +0300	[thread overview]
Message-ID: <2083383.tARSUAcNlB@avalon> (raw)
In-Reply-To: <1436478277-10861-6-git-send-email-daniel.vetter@ffwll.ch>

Hi Daniel,

On Thursday 09 July 2015 23:44:28 Daniel Vetter wrote:
> Because of DP MST connectors can now be hotplugged and we must hold
> the right lock when walking the connector lists.  Enforce this by
> checking the locking in our shiny new list walking macros.
> 
> v2: Extract the locking check into a small static inline helper to
> help readability. This will be more important when we make the
> read list access rules more complicated in later patches. Inspired by
> comments from Chris. Unfortunately, due to header loops around the
> definition of struct drm_device the function interface is a bit funny.
> 
> v3: Encoders aren't hotadded/removed. For each dp mst encoder we
> statically create one fake encoder per pipe so that we can support as
> many mst sinks as the hw can (Dave).
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  include/drm/drm_crtc.h | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 7c95a7df6065..499562274353 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1589,8 +1589,18 @@ static inline struct drm_property
> *drm_property_find(struct drm_device *dev, #define drm_for_each_crtc(crtc,
> dev) \
>  	list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
> 
> +static inline void
> +assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config)
> +{
> +	WARN_ON(!mutex_is_locked(&mode_config->mutex));

I believe this introduced a regression for all drivers that call 
drm_mode_config_reset() at .load() time (and there's lots of them), as the 
mode config mutex isn't locked then.

> +}
> +
>  #define drm_for_each_connector(connector, dev) \
> -	list_for_each_entry(connector, &(dev)->mode_config.connector_list, head)
> +	for (assert_drm_connector_list_read_locked(&(dev)->mode_config),	\
> +	     connector = list_first_entry(&(dev)->mode_config.connector_list,	
\
> +					  struct drm_connector, head);		\
> +	     &connector->head != (&(dev)->mode_config.connector_list);		\
> +	     connector = list_next_entry(connector, head))
> 
>  #define drm_for_each_encoder(encoder, dev) \
>  	list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head)

-- 
Regards,

Laurent Pinchart

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

  reply	other threads:[~2015-07-28 22:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 21:44 [PATCH 00/14] drm_connector locking rules, v2 Daniel Vetter
2015-07-09 21:44 ` [PATCH 01/14] drm: Simplify drm_for_each_legacy_plane arguments Daniel Vetter
2015-07-09 21:44 ` [PATCH 02/14] drm: Add modeset object iterators Daniel Vetter
2015-07-09 21:44 ` [PATCH 03/14] drm/probe-helper: Grab mode_config.mutex in poll_init/enable Daniel Vetter
2015-07-09 21:44 ` [PATCH 04/14] drm/fbdev-helper: Grab mode_config.mutex in drm_fb_helper_single_add_all_connectors Daniel Vetter
2015-07-09 21:44 ` [PATCH 05/14] drm: Check locking in drm_for_each_connector Daniel Vetter
2015-07-28 22:40   ` Laurent Pinchart [this message]
2015-07-09 21:44 ` [PATCH 06/14] drm/i915: Use drm_for_each_fb in i915_debugfs.c Daniel Vetter
2015-07-10  7:53   ` [Intel-gfx] " Ville Syrjälä
2015-07-10 17:02   ` [PATCH] " Daniel Vetter
2015-07-09 21:44 ` [PATCH 07/14] drm: Check locking in drm_for_each_fb Daniel Vetter
2015-07-09 21:44 ` [PATCH 08/14] drm/i915: Take all modeset locks for DP MST hotplug Daniel Vetter
2015-07-09 21:44 ` [PATCH 09/14] drm/radeon: " Daniel Vetter
2015-07-09 21:44 ` [PATCH 10/14] drm: Amend connector list locking rules Daniel Vetter
2015-07-09 21:44 ` [PATCH 11/14] drm: Roll out drm_for_each_connector more Daniel Vetter
2015-07-09 21:44 ` [PATCH 12/14] drm: Roll out drm_for_each_{plane,crtc,encoder} Daniel Vetter
2015-07-09 21:44 ` [PATCH 13/14] drm: Stop filtering according to mode_group in getresources Daniel Vetter
2015-07-09 21:44 ` [PATCH 14/14] drm: gc now dead mode_group code Daniel Vetter
2015-07-22 13:05   ` Maarten Lankhorst
2015-07-22 14:46     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2083383.tARSUAcNlB@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox