From: Sean Paul <sean@poorly.run>
To: Jeykumar Sankaran <jsanka@codeaurora.org>
Cc: Sean Paul <sean@poorly.run>,
dri-devel@lists.freedesktop.org,
Sean Paul <seanpaul@chromium.org>,
linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org
Subject: Re: [PATCH v2 15/24] drm/msm: dpu: Stop using encoder->crtc pointer
Date: Mon, 26 Nov 2018 16:53:36 -0500 [thread overview]
Message-ID: <20181126215336.GE154160@art_vandelay> (raw)
In-Reply-To: <8676ddf837e19e27f2483d262290a345@codeaurora.org>
On Mon, Nov 19, 2018 at 12:03:53PM -0800, Jeykumar Sankaran wrote:
> On 2018-11-16 13:14, Sean Paul wrote:
> > On Fri, Nov 16, 2018 at 12:05:09PM -0800, Jeykumar Sankaran wrote:
> > > On 2018-11-16 10:42, Sean Paul wrote:
> > > > From: Sean Paul <seanpaul@chromium.org>
> > > >
> > > > It's for legacy drivers, for atomic drivers crtc->state->encoder_mask
> > > > should be used to map encoder to crtc.
> > > >
> > > > Changes in v2:
> > > > - None
> > > >
> > > > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> > > > ---
> > > > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 46
> > ++++++++----------------
> > > > drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 +++++++---
> > > > 2 files changed, 29 insertions(+), 36 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > index 156f4c77ca44..a008a87a8113 100644
> > > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > @@ -284,9 +284,9 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct
> > > > drm_crtc *crtc)
> > > > return INTF_MODE_NONE;
> > > > }
> > > >
> > > > - drm_for_each_encoder(encoder, crtc->dev)
> > > > - if (encoder->crtc == crtc)
> > > > - return dpu_encoder_get_intf_mode(encoder);
> > > > + /* 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);
> > > >
> > > > return INTF_MODE_NONE;
> > > > }
> > > > @@ -551,13 +551,9 @@ static void dpu_crtc_atomic_begin(struct drm_crtc
> > > > *crtc,
> > > > spin_unlock_irqrestore(&dev->event_lock, flags);
> > > > }
> > > >
> > > > - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
> > > > {
> > > > - if (encoder->crtc != crtc)
> > > > - continue;
> > > > -
> > > > - /* encoder will trigger pending mask now */
> > > > + /* encoder will trigger pending mask now */
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > crtc->state->encoder_mask)
> > > > dpu_encoder_trigger_kickoff_pending(encoder);
> > > > - }
> > > >
> > > > /*
> > > > * If no mixers have been allocated in dpu_crtc_atomic_check(),
> > > > @@ -704,7 +700,6 @@ static int _dpu_crtc_wait_for_frame_done(struct
> > > > drm_crtc *crtc)
> > > > void dpu_crtc_commit_kickoff(struct drm_crtc *crtc)
> > > > {
> > > > struct drm_encoder *encoder;
> > > > - struct drm_device *dev = crtc->dev;
> > > > struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
> > > > struct dpu_kms *dpu_kms = _dpu_crtc_get_kms(crtc);
> > > > struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state);
> > > > @@ -720,16 +715,13 @@ void dpu_crtc_commit_kickoff(struct drm_crtc
> > > > *crtc)
> > > >
> > > > DPU_ATRACE_BEGIN("crtc_commit");
> > > >
> > > > - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
> > > > {
> > > > + /*
> > > > + * Encoder will flush/start now, unless it has a tx pending. If
> > > > so, it
> > > > + * may delay and flush at an irq event (e.g. ppdone)
> > > > + */
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > + crtc->state->encoder_mask) {
> > > > struct dpu_encoder_kickoff_params params = { 0 };
> > > > -
> > > > - if (encoder->crtc != crtc)
> > > > - continue;
> > > > -
> > > > - /*
> > > > - * Encoder will flush/start now, unless it has a tx
> > > > pending.
> > > > - * If so, it may delay and flush at an irq event (e.g.
> > > > ppdone)
> > > > - */
> > > > dpu_encoder_prepare_for_kickoff(encoder, ¶ms);
> > > > }
> > > >
> > > > @@ -754,12 +746,8 @@ void dpu_crtc_commit_kickoff(struct drm_crtc
> > *crtc)
> > > >
> > > > dpu_vbif_clear_errors(dpu_kms);
> > > >
> > > > - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
> > > > {
> > > > - if (encoder->crtc != crtc)
> > > > - continue;
> > > > -
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > crtc->state->encoder_mask)
> > > > dpu_encoder_kickoff(encoder);
> > > > - }
> > > We wont be holding the modeset locks here (and in crtc_atomic_begin)
> > > in
> > the
> > > display thread. Is
> > > it safe to iterate over encoder_mask?
> >
> > Hmm, I'm not sure I follow. AFAICT, there are 2 callsites for
> > dpu_crtc_commit_kickoff():
> >
> > 1- dpu_kms_encoder_enable() which is called via the
> > encoder->funcs->enable
> > hook
> > 2- dpu_kms_commit() which is called in the
> > mode_config->funcs->atomic_commit_tail
>
> atomic_commit_tail will be called from the WQ. Do we hold
> the modeset locks in the WQ? I believe userspace thread will drop
> the locks at the end of drm_mode_atomic_ioctl.
Accessing state is safe in non-blocking commits due to stalling any subsequent
commits until the previous one has completed. Check out the comment at:
https://cgit.freedesktop.org/drm-tip/tree/drivers/gpu/drm/drm_atomic_helper.c#n1754
Sean
>
> Thanks
> >
> > Both of these callsites will hold the modeset locks.
> >
> > Am I missing something?
> >
> > Thanks for your review,
> >
> > Sean
> >
> > > >
> > > > end:
> > > > reinit_completion(&dpu_crtc->frame_done_comp);
> > > > @@ -883,11 +871,8 @@ static void dpu_crtc_disable(struct drm_crtc
> > *crtc)
> > > >
> > > > dpu_core_perf_crtc_update(crtc, 0, true);
> > > >
> > > > - drm_for_each_encoder(encoder, crtc->dev) {
> > > > - if (encoder->crtc != crtc)
> > > > - continue;
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > crtc->state->encoder_mask)
> > > > dpu_encoder_register_frame_event_callback(encoder, NULL,
> > > > NULL);
> > > > - }
> > > >
> > > > memset(cstate->mixers, 0, sizeof(cstate->mixers));
> > > > cstate->num_mixers = 0;
> > > > @@ -922,12 +907,9 @@ static void dpu_crtc_enable(struct drm_crtc
> > *crtc,
> > > > DRM_DEBUG_KMS("crtc%d\n", crtc->base.id);
> > > > dpu_crtc = to_dpu_crtc(crtc);
> > > >
> > > > - drm_for_each_encoder(encoder, crtc->dev) {
> > > > - if (encoder->crtc != crtc)
> > > > - continue;
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > crtc->state->encoder_mask)
> > > > dpu_encoder_register_frame_event_callback(encoder,
> > > > dpu_crtc_frame_event_cb, (void *)crtc);
> > > > - }
> > > >
> > > > mutex_lock(&dpu_crtc->crtc_lock);
> > > > trace_dpu_crtc_enable(DRMID(crtc), true, dpu_crtc);
> > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> > > > b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> > > > index 1bec4540f3e1..64134d619748 100644
> > > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> > > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> > > > @@ -320,7 +320,10 @@ static void dpu_kms_prepare_commit(struct msm_kms
> > > > *kms,
> > > > struct dpu_kms *dpu_kms;
> > > > struct msm_drm_private *priv;
> > > > struct drm_device *dev;
> > > > + struct drm_crtc *crtc;
> > > > + struct drm_crtc_state *crtc_state;
> > > > struct drm_encoder *encoder;
> > > > + int i;
> > > >
> > > > if (!kms)
> > > > return;
> > > > @@ -332,9 +335,13 @@ static void dpu_kms_prepare_commit(struct msm_kms
> > > > *kms,
> > > > priv = dev->dev_private;
> > > > pm_runtime_get_sync(&dpu_kms->pdev->dev);
> > > >
> > > > - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
> > > > - if (encoder->crtc != NULL)
> > > > + /* Call prepare_commit for all affected encoders */
> > > > + for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
> > > > + drm_for_each_encoder_mask(encoder, crtc->dev,
> > > > + crtc_state->encoder_mask) {
> > > > dpu_encoder_prepare_commit(encoder);
> > > > + }
> > > > + }
> > > > }
> > > >
> > > > /*
> > > > @@ -344,13 +351,17 @@ static void dpu_kms_prepare_commit(struct
> > msm_kms
> > > > *kms,
> > > > void dpu_kms_encoder_enable(struct drm_encoder *encoder)
> > > > {
> > > > const struct drm_encoder_helper_funcs *funcs =
> > > > encoder->helper_private;
> > > > - struct drm_crtc *crtc = encoder->crtc;
> > > > + struct drm_device *dev = encoder->dev;
> > > > + struct drm_crtc *crtc;
> > > >
> > > > /* Forward this enable call to the commit hook */
> > > > if (funcs && funcs->commit)
> > > > funcs->commit(encoder);
> > > >
> > > > - if (crtc && crtc->state->active) {
> > > > + drm_for_each_crtc(crtc, dev) {
> > > > + if (!(crtc->state->encoder_mask &
> > > > drm_encoder_mask(encoder)))
> > > > + continue;
> > > > +
> > > > trace_dpu_kms_enc_enable(DRMID(crtc));
> > > > dpu_crtc_commit_kickoff(crtc);
> > > > }
> > >
> > > --
> > > Jeykumar S
>
> --
> Jeykumar S
--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-11-26 21:53 UTC|newest]
Thread overview: 52+ 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
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
[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 [this message]
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
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 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=20181126215336.GE154160@art_vandelay \
--to=sean@poorly.run \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jsanka@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox