[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e5c16697-5919-bafa-4ec5-294c94d7a740@linaro.org>
Date: Thu, 12 May 2022 03:41:50 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Kuogee Hsieh <quic_khsieh@...cinc.com>, robdclark@...il.com,
sean@...rly.run, swboyd@...omium.org, dianders@...omium.org,
vkoul@...nel.org, daniel@...ll.ch, airlied@...ux.ie,
agross@...nel.org, bjorn.andersson@...aro.org
Cc: quic_abhinavk@...cinc.com, quic_aravindh@...cinc.com,
quic_sbillaka@...cinc.com, freedreno@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] drm/msm/dp: Always clear mask bits to disable
interrupts at dp_ctrl_reset_irq_ctrl()
On 12/05/2022 03:02, Kuogee Hsieh wrote:
> dp_catalog_ctrl_reset() will software reset DP controller. But it will
> not reset programmable registers to default value. DP driver still have
> to clear mask bits to interrupt status registers to disable interrupts
> after software reset of controller.
>
> At current implementation, dp_ctrl_reset_irq_ctrl() will software reset dp
> controller but did not call dp_catalog_ctrl_enable_irq(false) to clear hpd
> related interrupt mask bits to disable hpd related interrupts due to it
> mistakenly think hpd related interrupt mask bits will be cleared by software
> reset of dp controller automatically. This mistake may cause system to crash
> during suspending procedure due to unexpected irq fired and trigger event
> thread to access dp controller registers with controller clocks are disabled.
>
> This patch fixes system crash during suspending problem by removing "enable"
> flag condition checking at dp_ctrl_reset_irq_ctrl() so that hpd related
> interrupt mask bits are cleared to prevent unexpected from happening.
ok. This is the main part of the description.
> In addition, this patch also add suspended flag to prevent new events be
> added into event Q to wake up event thread after system suspended.
And this describes the major part of the patch. First, it should go to a
separate patch. Second, can you please describe, how can this happen
once you disable the HPD interrupt?
>
> Changes in v2:
> -- add more details commit text
>
> Changes in v3:
> -- add synchrons_irq()
> -- add atomic_t suspended
>
> Changes in v4:
> -- correct Fixes's commit ID
> -- remove synchrons_irq()
>
> Changes in v5:
> -- revise commit text
>
> Fixes: 989ebe7bc446 ("drm/msm/dp: do not initialize phy until plugin interrupt received")
> Signed-off-by: Kuogee Hsieh <quic_khsieh@...cinc.com>
> ---
> drivers/gpu/drm/msm/dp/dp_ctrl.c | 9 +++++++--
> drivers/gpu/drm/msm/dp/dp_display.c | 11 +++++++++++
> 2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
> index af7a80c..f3e333e 100644
> --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
> +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
> @@ -1389,8 +1389,13 @@ void dp_ctrl_reset_irq_ctrl(struct dp_ctrl *dp_ctrl, bool enable)
>
> dp_catalog_ctrl_reset(ctrl->catalog);
>
> - if (enable)
> - dp_catalog_ctrl_enable_irq(ctrl->catalog, enable);
> + /*
> + * all dp controller programmable registers will not
> + * be reset to default value after DP_SW_RESET
> + * therefore interrupt mask bits have to be updated
> + * to enable/disable interrupts
> + */
> + dp_catalog_ctrl_enable_irq(ctrl->catalog, enable);
> }
>
> void dp_ctrl_phy_init(struct dp_ctrl *dp_ctrl)
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index c388323..79439b8 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -98,6 +98,8 @@ struct dp_display_private {
> struct dp_ctrl *ctrl;
> struct dp_debug *debug;
>
> + atomic_t suspended;
I think it'd be better to protect it with event_lock rather than using
atomics.
> +
> struct dp_usbpd_cb usbpd_cb;
> struct dp_display_mode dp_mode;
> struct msm_dp dp_display;
> @@ -187,6 +189,11 @@ static int dp_add_event(struct dp_display_private *dp_priv, u32 event,
> int pndx;
>
> spin_lock_irqsave(&dp_priv->event_lock, flag);
> + if (atomic_read(&dp_priv->suspended)) {
> + spin_unlock_irqrestore(&dp_priv->event_lock, flag);
> + return -EPERM;
> + }
> +
> pndx = dp_priv->event_pndx + 1;
> pndx %= DP_EVENT_Q_MAX;
> if (pndx == dp_priv->event_gndx) {
> @@ -1362,6 +1369,8 @@ static int dp_pm_resume(struct device *dev)
> dp->dp_display.connector_type, dp->core_initialized,
> dp->phy_initialized, dp_display->power_on);
>
> + atomic_set(&dp->suspended, 0);
> +
> /* start from disconnected state */
> dp->hpd_state = ST_DISCONNECTED;
>
> @@ -1431,6 +1440,8 @@ static int dp_pm_suspend(struct device *dev)
> dp->dp_display.connector_type, dp->core_initialized,
> dp->phy_initialized, dp_display->power_on);
>
> + atomic_inc(&dp->suspended);
> +
> /* mainlink enabled */
> if (dp_power_clk_status(dp->power, DP_CTRL_PM))
> dp_ctrl_off_link_stream(dp->ctrl);
--
With best wishes
Dmitry
Powered by blists - more mailing lists