dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 1/6] drm/atomic: Ensure that drm_connector_index is stable
Date: Wed, 19 Nov 2014 15:21:39 -0500	[thread overview]
Message-ID: <CAF6AEGuT7eNkggo8joSvK17VLxVba5GgoGKn7OAuz9mVhFUiKg@mail.gmail.com> (raw)
In-Reply-To: <1416418691-24747-1-git-send-email-daniel.vetter@ffwll.ch>

On Wed, Nov 19, 2014 at 12:38 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> I've totally forgotten that with DP MST connectors can now be
> hotplugged. And failed to adapt Rob's drm_atomic_state code (which
> predates connector hotplugging) to the new realities.
>
> The first step is to make sure that the connector indices used to
> access the arrays of pointers are stable. The connection mutex gives
> us enough guarantees for that, which means we won't unecessarily block
> on concurrent modesets or background probing.
>
> So add a locking WARN_ON and shuffle the code slightly to make sure we
> always hold the right lock.
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/drm_atomic.c | 8 ++++----
>  drivers/gpu/drm/drm_crtc.c   | 5 +++++
>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index ed22a719440f..90b2d1644bd7 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -295,15 +295,15 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
>         struct drm_mode_config *config = &connector->dev->mode_config;
>         struct drm_connector_state *connector_state;
>
> +       ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
> +       if (ret)
> +               return ERR_PTR(ret);
> +
>         index = drm_connector_index(connector);
>
>         if (state->connector_states[index])
>                 return state->connector_states[index];
>
> -       ret = drm_modeset_lock(&config->connection_mutex, state->acquire_ctx);
> -       if (ret)
> -               return ERR_PTR(ret);
> -
>         connector_state = connector->funcs->atomic_duplicate_state(connector);
>         if (!connector_state)
>                 return ERR_PTR(-ENOMEM);
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 56737e74b59d..5c878f172365 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -867,6 +867,8 @@ int drm_connector_init(struct drm_device *dev,
>
>         drm_connector_get_cmdline_mode(connector);
>
> +       /* We should add connectors at the end to avoid upsetting the connector
> +        * index too much. */
>         list_add_tail(&connector->head, &dev->mode_config.connector_list);
>         dev->mode_config.num_connector++;
>
> @@ -930,6 +932,9 @@ unsigned int drm_connector_index(struct drm_connector *connector)
>  {
>         unsigned int index = 0;
>         struct drm_connector *tmp;
> +       struct drm_mode_config *config = &connector->dev->mode_config;
> +
> +       WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
>
>         list_for_each_entry(tmp, &connector->dev->mode_config.connector_list, head) {
>                 if (tmp == connector)
> --
> 2.1.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2014-11-19 20:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 17:38 [PATCH 1/6] drm/atomic: Ensure that drm_connector_index is stable Daniel Vetter
2014-11-19 17:38 ` [PATCH 2/6] drm/atomic: Only destroy connector states with connection mutex held Daniel Vetter
2014-11-19 20:22   ` [Intel-gfx] " Rob Clark
2014-11-19 17:38 ` [PATCH 3/6] drm/atomic: Don't overrun the connector array when hotplugging Daniel Vetter
2014-11-19 20:24   ` Rob Clark
2014-11-20  8:53   ` Thierry Reding
2014-11-19 17:38 ` [PATCH 4/6] drm/crtc: Polish kerneldoc Daniel Vetter
2014-11-19 20:28   ` Rob Clark
2014-11-19 17:38 ` [PATCH 5/6] drm: s/enum_blob_list/enum_list/ in drm_property Daniel Vetter
2014-11-19 20:25   ` Rob Clark
2014-11-19 17:38 ` [PATCH 6/6] drm/atomic_helper: Make it clear that commit_planes gets the old state Daniel Vetter
2014-11-19 20:29   ` Rob Clark
2014-11-19 20:55     ` Daniel Vetter
2014-11-19 20:21 ` Rob Clark [this message]

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=CAF6AEGuT7eNkggo8joSvK17VLxVba5GgoGKn7OAuz9mVhFUiKg@mail.gmail.com \
    --to=robdclark@gmail.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;
as well as URLs for NNTP newsgroup(s).