[PATCH v7 01/15] drm/msm/disp/dpu: clear dpu_assign_crtc and get crtc from connector state instead of dpu_enc
Dmitry Baryshkov
dmitry.baryshkov at linaro.org
Tue Sep 13 17:05:35 UTC 2022
On 13/09/2022 20:04, Dmitry Baryshkov wrote:
> On 13/09/2022 17:51, 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.
>>
>> Signed-off-by: Vinod Polimera <quic_vpolimer at quicinc.com>
>> ---
>> drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 4 ----
>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 35
>> ++++++++++++-----------------
>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 8 -------
>> 3 files changed, 14 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>> index 13ce321..8ec9a13 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 9c6817b..0c7d8b5 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;
>> @@ -1288,6 +1282,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;
>> + struct drm_crtc *crtc;
>> unsigned long lock_flags;
>> if (!drm_enc || !phy_enc)
>> @@ -1298,9 +1293,14 @@ static void dpu_encoder_vblank_callback(struct
>> drm_encoder *drm_enc,
>> atomic_inc(&phy_enc->vsync_cnt);
>> + if (!dpu_enc->connector || !dpu_enc->connector->state)
>> + return;
>> +
>> + crtc = dpu_enc->connector->state->crtc;
>> +
>> spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags);
>> - if (dpu_enc->crtc)
>> - dpu_crtc_vblank_callback(dpu_enc->crtc);
>> + if (crtc)
>> + dpu_crtc_vblank_callback(crtc);
>> spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags);
>
> Stephen's comment about reading the state from outside of the lock and
> then using local variable under spinlock is still valid. Moreover I'm
> not sure that enc_spinlock protects connector's state. I'd say one has
> to take the modesetting lock here.
s/Stephen's/Doug's/
--
With best wishes
Dmitry
More information about the dri-devel
mailing list