diff mbox series

drm/msm/dpu: handle pm_runtime_get_sync() errors in bind path

Message ID 20220518195540.30459-1-quic_abhinavk@quicinc.com (mailing list archive)
State New, archived
Headers show
Series drm/msm/dpu: handle pm_runtime_get_sync() errors in bind path | expand

Commit Message

Abhinav Kumar May 18, 2022, 7:55 p.m. UTC
If there are errors while trying to enable the pm in the
bind path, it will lead to unclocked access of hw revision
register thereby crashing the device.

This will not address why the pm_runtime_get_sync() fails
but at the very least we should be able to prevent the
crash by handling the error and bailing out earlier.

Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Stephen Boyd May 18, 2022, 7:57 p.m. UTC | #1
Quoting Abhinav Kumar (2022-05-18 12:55:40)
> If there are errors while trying to enable the pm in the
> bind path, it will lead to unclocked access of hw revision
> register thereby crashing the device.
>
> This will not address why the pm_runtime_get_sync() fails
> but at the very least we should be able to prevent the
> crash by handling the error and bailing out earlier.
>
> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 2b9d931474e0..2fd1f5b70a06 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -1089,7 +1089,11 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
>
>         dpu_kms_parse_data_bus_icc_path(dpu_kms);
>
> -       pm_runtime_get_sync(&dpu_kms->pdev->dev);
> +       rc = pm_runtime_get_sync(&dpu_kms->pdev->dev);

Any reason to not use pm_runtime_resume_and_get()?

> +       if (rc < 0) {
> +               pm_runtime_put_autosuspend(&dpu_kms->pdev->dev);
> +               goto error;

Then this is a single goto error
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 2b9d931474e0..2fd1f5b70a06 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1089,7 +1089,11 @@  static int dpu_kms_hw_init(struct msm_kms *kms)
 
 	dpu_kms_parse_data_bus_icc_path(dpu_kms);
 
-	pm_runtime_get_sync(&dpu_kms->pdev->dev);
+	rc = pm_runtime_get_sync(&dpu_kms->pdev->dev);
+	if (rc < 0) {
+		pm_runtime_put_autosuspend(&dpu_kms->pdev->dev);
+		goto error;
+	}
 
 	dpu_kms->core_rev = readl_relaxed(dpu_kms->mmio + 0x0);