All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Sean Paul <sean@poorly.run>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	freedreno <freedreno@lists.freedesktop.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	Sean Paul <seanpaul@chromium.org>
Subject: Re: [PATCH v2 16/24] drm/msm: dpu: Add modeset lock checks where applicable
Date: Thu, 10 Oct 2019 00:20:56 +0200	[thread overview]
Message-ID: <CAKMK7uEx2fL69jPGXVpQhhcj8Q8zEzb3ogCv-uVyGrX3QYFeWQ@mail.gmail.com> (raw)
In-Reply-To: <20181116184238.170034-17-sean@poorly.run>

On Fri, Nov 16, 2018 at 7:44 PM Sean Paul <sean@poorly.run> wrote:
>
> From: Sean Paul <seanpaul@chromium.org>
>
> Add modeset lock checks to functions that could be called outside the
> core atomic stack.
>
> Changes in v2:
> - None
>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 ++
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 +
>  2 files changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index a008a87a8113..cd0a0bea4335 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -284,6 +284,8 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
>                 return INTF_MODE_NONE;
>         }
>
> +       WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
> +
>         /* TODO: Returns the first INTF_MODE, could there be multiple values? */
>         drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
>                 return dpu_encoder_get_intf_mode(encoder);
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 64134d619748..5104fc01147e 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -358,6 +358,7 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
>         if (funcs && funcs->commit)
>                 funcs->commit(encoder);
>
> +       WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
>         drm_for_each_crtc(crtc, dev) {
>                 if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
>                         continue;

I'm fairly sure this is called in the atomic_commit path, and in there
you might not actually hold these locks (if you do a nonblocking
modeset).

The locking rules for ->state are pretty fun: Either hold the lock, or
be in atomic commit. In the later case atomic helpers' commit ordering
guarantees that you can safely access ->state (but read-only only)
without hodling any locks. You might want to revert.

Don't ask why I stumbled over this.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
To: Sean Paul <sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
Cc: Sean Paul <seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	linux-arm-msm
	<linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	freedreno
	<freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>,
	dri-devel
	<dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH v2 16/24] drm/msm: dpu: Add modeset lock checks where applicable
Date: Thu, 10 Oct 2019 00:20:56 +0200	[thread overview]
Message-ID: <CAKMK7uEx2fL69jPGXVpQhhcj8Q8zEzb3ogCv-uVyGrX3QYFeWQ@mail.gmail.com> (raw)
In-Reply-To: <20181116184238.170034-17-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>

On Fri, Nov 16, 2018 at 7:44 PM Sean Paul <sean@poorly.run> wrote:
>
> From: Sean Paul <seanpaul@chromium.org>
>
> Add modeset lock checks to functions that could be called outside the
> core atomic stack.
>
> Changes in v2:
> - None
>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 ++
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 1 +
>  2 files changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index a008a87a8113..cd0a0bea4335 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -284,6 +284,8 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
>                 return INTF_MODE_NONE;
>         }
>
> +       WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
> +
>         /* TODO: Returns the first INTF_MODE, could there be multiple values? */
>         drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
>                 return dpu_encoder_get_intf_mode(encoder);
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 64134d619748..5104fc01147e 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -358,6 +358,7 @@ void dpu_kms_encoder_enable(struct drm_encoder *encoder)
>         if (funcs && funcs->commit)
>                 funcs->commit(encoder);
>
> +       WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
>         drm_for_each_crtc(crtc, dev) {
>                 if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
>                         continue;

I'm fairly sure this is called in the atomic_commit path, and in there
you might not actually hold these locks (if you do a nonblocking
modeset).

The locking rules for ->state are pretty fun: Either hold the lock, or
be in atomic commit. In the later case atomic helpers' commit ordering
guarantees that you can safely access ->state (but read-only only)
without hodling any locks. You might want to revert.

Don't ask why I stumbled over this.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2019-10-09 22:21 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 18:42 [PATCH v2 00/24] drm/msm: Various dpu locking and legacy cleanups Sean Paul
2018-11-16 18:42 ` [PATCH v2 01/24] drm/msm: dpu: Remove dpu_power_handle_get_dbus_name() Sean Paul
2018-11-16 18:42 ` [PATCH v2 03/24] drm/msm: dpu: Remove dpu_power_client Sean Paul
2018-11-16 18:42 ` [PATCH v2 04/24] drm/msm: dpu: Don't use power_event for vbif_init_memtypes Sean Paul
     [not found]   ` <20181116184238.170034-5-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-12-03 19:49     ` Jeykumar Sankaran
2018-11-16 18:42 ` [PATCH v2 09/24] drm/msm: dpu: Remove dpu_power_handle Sean Paul
2018-11-16 18:42 ` [PATCH v2 11/24] drm/msm: dpu: Add ->enabled to dpu_encoder_virt Sean Paul
2018-12-03 19:51   ` Jeykumar Sankaran
     [not found] ` <20181116184238.170034-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-16 18:42   ` [PATCH v2 02/24] drm/msm: dpu: Remove unused trace_dpu_perf_update_bus() Sean Paul
2018-11-16 18:42   ` [PATCH v2 05/24] drm/msm: dpu: Handle crtc pm_runtime_resume() directly Sean Paul
     [not found]     ` <20181116184238.170034-6-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 19:41       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 06/24] drm/msm: dpu: Remove power_handle from core_perf Sean Paul
2018-11-16 18:42   ` [PATCH v2 07/24] drm/msm: dpu: Include dpu_io_util.h directly in dpu_kms.h Sean Paul
2018-11-16 18:42   ` [PATCH v2 08/24] drm/msm: dpu: Move DPU_POWER_HANDLE_DBUS_ID to core_perf Sean Paul
2018-11-16 18:42   ` [PATCH v2 10/24] drm/msm: dpu: Fix typo in dpu_encoder Sean Paul
2018-11-16 18:42   ` [PATCH v2 12/24] drm/msm: dpu: Move crtc runtime resume to encoder Sean Paul
     [not found]     ` <20181116184238.170034-13-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-12-03 19:52       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 13/24] drm/msm: dpu: Don't drop locks in crtc_vblank_enable Sean Paul
2018-11-19 19:43     ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 14/24] drm/msm: dpu: Grab the modeset locks in frame_event Sean Paul
2018-11-16 20:02     ` Jeykumar Sankaran
     [not found]       ` <0405e429330ba1de19d96a6918a6daae-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-11-16 21:18         ` Sean Paul
     [not found]     ` <20181116184238.170034-15-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-30 22:00       ` [PATCH v3 " Sean Paul
2018-12-03 19:53         ` Jeykumar Sankaran
     [not found]         ` <20181130220011.39644-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-12-03 21:45           ` Daniel Vetter
2018-11-16 18:42   ` [PATCH v2 15/24] drm/msm: dpu: Stop using encoder->crtc pointer Sean Paul
     [not found]     ` <20181116184238.170034-16-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-16 20:05       ` Jeykumar Sankaran
     [not found]         ` <580ced340265a3c45b31836291bfbb4c-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-11-16 21:14           ` Sean Paul
2018-11-19 20:03             ` Jeykumar Sankaran
2018-11-26 21:53               ` Sean Paul
2018-12-03 19:43                 ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 16/24] drm/msm: dpu: Add modeset lock checks where applicable Sean Paul
2018-11-16 20:05     ` Jeykumar Sankaran
2019-10-09 22:20     ` Daniel Vetter [this message]
2019-10-09 22:20       ` Daniel Vetter
2019-10-10 13:13       ` Sean Paul
2019-10-10 13:13         ` Sean Paul
2018-11-16 18:42   ` [PATCH v2 17/24] drm/msm: dpu: Move pm_runtime_(get|put) from vblank_enable Sean Paul
2018-11-19 20:09     ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 18/24] drm/msm: dpu: Remove crtc_lock from setup_mixers Sean Paul
     [not found]     ` <20181116184238.170034-19-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:09       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 20/24] drm/msm: dpu: Use atomic_disable for dpu_crtc_disable Sean Paul
     [not found]     ` <20181116184238.170034-21-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:12       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 21/24] drm/msm: dpu: Don't bother checking ->enabled in dpu_crtc_vblank Sean Paul
     [not found]     ` <20181116184238.170034-22-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:13       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 23/24] drm/msm: dpu: Remove vblank_requested flag from dpu_crtc Sean Paul
     [not found]     ` <20181116184238.170034-24-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:14       ` Jeykumar Sankaran
2018-11-16 18:42   ` [PATCH v2 24/24] drm/msm: dpu: Remove crtc_lock Sean Paul
     [not found]     ` <20181116184238.170034-25-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:14       ` Jeykumar Sankaran
2018-11-16 18:42 ` [PATCH v2 19/24] drm/msm: dpu: Remove vblank_callback from encoder Sean Paul
     [not found]   ` <20181116184238.170034-20-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:11     ` Jeykumar Sankaran
2018-11-16 18:42 ` [PATCH v2 22/24] drm/msm: dpu: Separate crtc assignment from vblank enable Sean Paul
     [not found]   ` <20181116184238.170034-23-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org>
2018-11-19 20:13     ` Jeykumar Sankaran
2018-12-04 15:15 ` [PATCH v2 00/24] drm/msm: Various dpu locking and legacy cleanups Sean Paul

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=CAKMK7uEx2fL69jPGXVpQhhcj8Q8zEzb3ogCv-uVyGrX3QYFeWQ@mail.gmail.com \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=sean@poorly.run \
    --cc=seanpaul@chromium.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 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.