diff mbox series

[v2,08/14] drm/msm/hdmi: add runtime PM calls to DDC transfer function

Message ID 20240522-fd-hdmi-hpd-v2-8-c30bdb7c5c7e@linaro.org (mailing list archive)
State New, archived
Headers show
Series drm/msm/hdmi: rework and fix the HPD even generation | expand

Commit Message

Dmitry Baryshkov May 22, 2024, 10:51 a.m. UTC
We must be sure that the HDMI controller is powered on, while performing
the DDC transfer. Add corresponding runtime PM calls to
msm_hdmi_i2c_xfer().

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/gpu/drm/msm/hdmi/hdmi_i2c.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Jessica Zhang June 19, 2024, 12:05 a.m. UTC | #1
On 5/22/2024 3:51 AM, Dmitry Baryshkov wrote:
> We must be sure that the HDMI controller is powered on, while performing
> the DDC transfer. Add corresponding runtime PM calls to
> msm_hdmi_i2c_xfer().
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com>

> ---
>   drivers/gpu/drm/msm/hdmi/hdmi_i2c.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c b/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
> index 7aa500d24240..ebefea4fb408 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
> @@ -107,11 +107,15 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
>   	if (num == 0)
>   		return num;
>   
> +	ret = pm_runtime_resume_and_get(&hdmi->pdev->dev);
> +	if (ret)
> +		return ret;
> +
>   	init_ddc(hdmi_i2c);
>   
>   	ret = ddc_clear_irq(hdmi_i2c);
>   	if (ret)
> -		return ret;
> +		goto fail;
>   
>   	for (i = 0; i < num; i++) {
>   		struct i2c_msg *p = &msgs[i];
> @@ -169,7 +173,7 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
>   				hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS),
>   				hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS),
>   				hdmi_read(hdmi, REG_HDMI_DDC_INT_CTRL));
> -		return ret;
> +		goto fail;
>   	}
>   
>   	ddc_status = hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS);
> @@ -202,7 +206,13 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
>   		}
>   	}
>   
> +	pm_runtime_put(&hdmi->pdev->dev);
> +
>   	return i;
> +
> +fail:
> +	pm_runtime_put(&hdmi->pdev->dev);
> +	return ret;
>   }
>   
>   static u32 msm_hdmi_i2c_func(struct i2c_adapter *adapter)
> 
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c b/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
index 7aa500d24240..ebefea4fb408 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
@@ -107,11 +107,15 @@  static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
 	if (num == 0)
 		return num;
 
+	ret = pm_runtime_resume_and_get(&hdmi->pdev->dev);
+	if (ret)
+		return ret;
+
 	init_ddc(hdmi_i2c);
 
 	ret = ddc_clear_irq(hdmi_i2c);
 	if (ret)
-		return ret;
+		goto fail;
 
 	for (i = 0; i < num; i++) {
 		struct i2c_msg *p = &msgs[i];
@@ -169,7 +173,7 @@  static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
 				hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS),
 				hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS),
 				hdmi_read(hdmi, REG_HDMI_DDC_INT_CTRL));
-		return ret;
+		goto fail;
 	}
 
 	ddc_status = hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS);
@@ -202,7 +206,13 @@  static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
 		}
 	}
 
+	pm_runtime_put(&hdmi->pdev->dev);
+
 	return i;
+
+fail:
+	pm_runtime_put(&hdmi->pdev->dev);
+	return ret;
 }
 
 static u32 msm_hdmi_i2c_func(struct i2c_adapter *adapter)