mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Vinod Polimera <vpolimer@qti.qualcomm.com>,
	"Vinod Polimera (QUIC)" <quic_vpolimer@quicinc.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"freedreno@lists.freedesktop.org"
	<freedreno@lists.freedesktop.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"dianders@chromium.org" <dianders@chromium.org>,
	"swboyd@chromium.org" <swboyd@chromium.org>,
	"Kalyan Thota (QUIC)" <quic_kalyant@quicinc.com>,
	"Kuogee Hsieh (QUIC)" <quic_khsieh@quicinc.com>,
	"Vishnuvardhan Prodduturi (QUIC)" <quic_vproddut@quicinc.com>,
	"Bjorn Andersson (QUIC)" <quic_bjorande@quicinc.com>,
	"Aravind Venkateswaran (QUIC)" <quic_aravindh@quicinc.com>,
	"Abhinav Kumar (QUIC)" <quic_abhinavk@quicinc.com>,
	"Sankeerth Billakanti (QUIC)" <quic_sbillaka@quicinc.com>
Subject: Re: [PATCH v9 01/15] drm/msm/disp/dpu: clear dpu_assign_crtc and get crtc from connector state instead of dpu_enc
Date: Wed, 21 Dec 2022 21:43:47 +0200	[thread overview]
Message-ID: <87837483-93eb-823a-508a-4e163f969de0@linaro.org> (raw)
In-Reply-To: <BN0PR02MB8173B06FA578D6BC22AC6424E4EB9@BN0PR02MB8173.namprd02.prod.outlook.com>

On 21/12/2022 16:10, Vinod Polimera wrote:
> 
> 
>> -----Original Message-----
>> From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Sent: Wednesday, December 14, 2022 9:05 PM
>> To: Vinod Polimera (QUIC) <quic_vpolimer@quicinc.com>; dri-
>> devel@lists.freedesktop.org; linux-arm-msm@vger.kernel.org;
>> freedreno@lists.freedesktop.org; devicetree@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org; robdclark@gmail.com;
>> dianders@chromium.org; swboyd@chromium.org; Kalyan Thota (QUIC)
>> <quic_kalyant@quicinc.com>; Kuogee Hsieh (QUIC)
>> <quic_khsieh@quicinc.com>; Vishnuvardhan Prodduturi (QUIC)
>> <quic_vproddut@quicinc.com>; Bjorn Andersson (QUIC)
>> <quic_bjorande@quicinc.com>; Aravind Venkateswaran (QUIC)
>> <quic_aravindh@quicinc.com>; Abhinav Kumar (QUIC)
>> <quic_abhinavk@quicinc.com>; Sankeerth Billakanti (QUIC)
>> <quic_sbillaka@quicinc.com>
>> Subject: Re: [PATCH v9 01/15] drm/msm/disp/dpu: clear dpu_assign_crtc and
>> get crtc from connector state instead of dpu_enc
>>
>> WARNING: This email originated from outside of Qualcomm. Please be wary
>> of any links or attachments, and do not enable macros.
>>
>> On 14/12/2022 12:05, Vinod Polimera wrote:
>>> Update crtc retrieval from dpu_enc to dpu_enc connector state,
>>> since new links get set as part of the dpu enc virt mode set.
>>> The dpu_enc->crtc cache is no more needed, hence cleaning it as
>>> part of this change.
>>>
>>> This patch is dependent on the series:
>>> https://patchwork.freedesktop.org/series/110969/
>>>
>>> Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com>
>>> ---
>>>    drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c    |  4 ---
>>>    drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 42 +++++++++---------
>> -----------
>>>    drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h |  8 ------
>>>    3 files changed, 13 insertions(+), 41 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> index 3f72d38..289d51e 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> @@ -1029,7 +1029,6 @@ static void dpu_crtc_disable(struct drm_crtc *crtc,
>>>                 */
>>>                if (dpu_encoder_get_intf_mode(encoder) == INTF_MODE_VIDEO)
>>>                        release_bandwidth = true;
>>> -             dpu_encoder_assign_crtc(encoder, NULL);
>>>        }
>>>
>>>        /* wait for frame_event_done completion */
>>> @@ -1099,9 +1098,6 @@ static void dpu_crtc_enable(struct drm_crtc *crtc,
>>>        trace_dpu_crtc_enable(DRMID(crtc), true, dpu_crtc);
>>>        dpu_crtc->enabled = true;
>>>
>>> -     drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state-
>>> encoder_mask)
>>> -             dpu_encoder_assign_crtc(encoder, crtc);
>>> -
>>>        /* Enable/restore vblank irq handling */
>>>        drm_crtc_vblank_on(crtc);
>>>    }
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> index a585036..b9b254d 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>>> @@ -132,11 +132,6 @@ enum dpu_enc_rc_states {
>>>     * @intfs_swapped:  Whether or not the phys_enc interfaces have been
>> swapped
>>>     *                  for partial update right-only cases, such as pingpong
>>>     *                  split where virtual pingpong does not generate IRQs
>>> - * @crtc:            Pointer to the currently assigned crtc. Normally you
>>> - *                   would use crtc->state->encoder_mask to determine the
>>> - *                   link between encoder/crtc. However in this case we need
>>> - *                   to track crtc in the disable() hook which is called
>>> - *                   _after_ encoder_mask is cleared.
>>>     * @connector:              If a mode is set, cached pointer to the active
>> connector
>>>     * @crtc_kickoff_cb:                Callback into CRTC that will flush & start
>>>     *                          all CTL paths
>>> @@ -181,7 +176,6 @@ struct dpu_encoder_virt {
>>>
>>>        bool intfs_swapped;
>>>
>>> -     struct drm_crtc *crtc;
>>>        struct drm_connector *connector;
>>>
>>>        struct dentry *debugfs_root;
>>> @@ -1317,7 +1311,7 @@ static void dpu_encoder_vblank_callback(struct
>> drm_encoder *drm_enc,
>>>                struct dpu_encoder_phys *phy_enc)
>>>    {
>>>        struct dpu_encoder_virt *dpu_enc = NULL;
>>> -     unsigned long lock_flags;
>>> +     struct drm_crtc *crtc;
>>>
>>>        if (!drm_enc || !phy_enc)
>>>                return;
>>> @@ -1325,12 +1319,13 @@ static void dpu_encoder_vblank_callback(struct
>> drm_encoder *drm_enc,
>>>        DPU_ATRACE_BEGIN("encoder_vblank_callback");
>>>        dpu_enc = to_dpu_encoder_virt(drm_enc);
>>>
>>> -     atomic_inc(&phy_enc->vsync_cnt);
>>> +     if (!dpu_enc->connector || !dpu_enc->connector->state ||
>>> +         !dpu_enc->connector->state->crtc)
>>> +             return;
>>>
>>> -     spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags);
>>> -     if (dpu_enc->crtc)
>>> -             dpu_crtc_vblank_callback(dpu_enc->crtc);
>>> -     spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags);
>>> +     atomic_inc(&phy_enc->vsync_cnt);
>>> +     crtc = dpu_enc->connector->state->crtc;
>>> +     dpu_crtc_vblank_callback(crtc);
>>>
>>>        DPU_ATRACE_END("encoder_vblank_callback");
>>>    }
>>> @@ -1353,33 +1348,22 @@ static void
>> dpu_encoder_underrun_callback(struct drm_encoder *drm_enc,
>>>        DPU_ATRACE_END("encoder_underrun_callback");
>>>    }
>>>
>>> -void dpu_encoder_assign_crtc(struct drm_encoder *drm_enc, struct
>> drm_crtc *crtc)
>>> -{
>>> -     struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc);
>>> -     unsigned long lock_flags;
>>> -
>>> -     spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags);
>>> -     /* crtc should always be cleared before re-assigning */
>>> -     WARN_ON(crtc && dpu_enc->crtc);
>>> -     dpu_enc->crtc = crtc;
>>> -     spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags);
>>> -}
>>> -
>>>    void dpu_encoder_toggle_vblank_for_crtc(struct drm_encoder
>> *drm_enc,
>>>                                        struct drm_crtc *crtc, bool enable)
>>>    {
>>>        struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc);
>>> -     unsigned long lock_flags;
>>> +     struct drm_crtc *new_crtc;
>>>        int i;
>>>
>>>        trace_dpu_enc_vblank_cb(DRMID(drm_enc), enable);
>>>
>>> -     spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags);
>>> -     if (dpu_enc->crtc != crtc) {
>>> -             spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags);
>>> +     if (!dpu_enc->connector || !dpu_enc->connector->state)
>>> +             return;
>>> +
>>> +     new_crtc = dpu_enc->connector->state->crtc;
>>> +     if (!new_crtc || new_crtc != crtc) {
>>
>> I don't like going through all the pointers and states without locks.
>> The connector->state can potentially check. So, I'd propose even simpler
>> solution: just store the crtc in the dpu_enc at the creation time. Then
>> you can use the rest of the current dpu_enc->crtc as expected.
> 
> Can i do as below.
> After encoder to crtc is pinned, i can update dpu_encoder structure that is attached with drm_enc with the crtc created during drm_obj_init
> 
> @@ -816,6 +816,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
>                  }
>                  priv->crtcs[priv->num_crtcs++] = crtc;
>                  encoder->possible_crtcs = 1 << drm_crtc_index(crtc);
>                + dpu_encoder_assign_crtc(encoder, crtc);
>                  i++;
>          }

Yes.

>>
>>>                return;
>>>        }
>>> -     spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags);
>>>
>>>        for (i = 0; i < dpu_enc->num_phys_encs; i++) {
>>>                struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>>> index 7f3d823..eb9fc7c 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
>>> @@ -40,14 +40,6 @@ struct msm_display_info {
>>>    };
>>>
>>>    /**
>>> - * dpu_encoder_assign_crtc - Link the encoder to the crtc it's assigned to
>>> - * @encoder: encoder pointer
>>> - * @crtc:    crtc pointer
>>> - */
>>> -void dpu_encoder_assign_crtc(struct drm_encoder *encoder,
>>> -                          struct drm_crtc *crtc);
>>> -
>>> -/**
>>>     * dpu_encoder_toggle_vblank_for_crtc - Toggles vblank interrupts on or
>> off if
>>>     *  the encoder is assigned to the given crtc
>>>     * @encoder:        encoder pointer
>>
>> --
>> With best wishes
>> Dmitry
> 

-- 
With best wishes
Dmitry


  reply	other threads:[~2022-12-21 19:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 10:05 [PATCH v9 00/15] Add PSR support for eDP Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 01/15] drm/msm/disp/dpu: clear dpu_assign_crtc and get crtc from connector state instead of dpu_enc Vinod Polimera
2022-12-14 15:34   ` Dmitry Baryshkov
2022-12-21 14:10     ` Vinod Polimera
2022-12-21 19:43       ` Dmitry Baryshkov [this message]
2022-12-14 10:05 ` [PATCH v9 02/15] drm: add helper functions to retrieve old and new crtc Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 03/15] drm/msm/dp: use atomic callbacks for DP bridge ops Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 04/15] drm/msm/dp: Add basic PSR support for eDP Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 05/15] drm/msm/dp: use the eDP bridge ops to validate eDP modes Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 06/15] drm/msm/dp: disable self_refresh_aware after entering psr Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 07/15] drm/bridge: use atomic enable/disable callbacks for panel bridge Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 08/15] drm/bridge: add psr support for panel bridge callbacks Vinod Polimera
2023-01-05 13:11   ` Daniel Vetter
2023-01-05 13:16     ` Dmitry Baryshkov
2022-12-14 10:05 ` [PATCH v9 09/15] drm/msm/disp/dpu: use atomic enable/disable callbacks for encoder functions Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 10/15] drm/msm/disp/dpu: check for crtc enable rather than crtc active to release shared resources Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 11/15] drm/msm/disp/dpu: add PSR support for eDP interface in dpu driver Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 12/15] drm/msm/disp/dpu: get timing engine status from intf status register Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 13/15] drm/msm/disp/dpu: wait for extra vsync till timing engine status is disabled Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 14/15] drm/msm/disp/dpu: reset the datapath after timing engine disable Vinod Polimera
2022-12-14 10:05 ` [PATCH v9 15/15] drm/msm/disp/dpu: clear active interface in the datapath cleanup Vinod Polimera

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=87837483-93eb-823a-508a-4e163f969de0@linaro.org \
    --to=dmitry.baryshkov@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_aravindh@quicinc.com \
    --cc=quic_bjorande@quicinc.com \
    --cc=quic_kalyant@quicinc.com \
    --cc=quic_khsieh@quicinc.com \
    --cc=quic_sbillaka@quicinc.com \
    --cc=quic_vpolimer@quicinc.com \
    --cc=quic_vproddut@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=swboyd@chromium.org \
    --cc=vpolimer@qti.qualcomm.com \
    /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

all inboxes | Powered by JetHome®