drm/msm/dp: tie dp_display_irq_handler() with dp driver
authorKuogee Hsieh <quic_khsieh@quicinc.com>
Fri, 1 Dec 2023 23:19:43 +0000 (15:19 -0800)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sun, 3 Dec 2023 00:13:17 +0000 (03:13 +0300)
Currently the dp_display_request_irq() is executed at
msm_dp_modeset_init() which ties irq registering to the DPU device's
life cycle, while depending on resources that are released as the DP
device is torn down. Move register DP driver irq handler to
dp_display_probe() to have dp_display_irq_handler() IRQ tied with DP
device. In addition, use platform_get_irq() to retrieve irq number
from platform device directly.

Changes in v5:
-- reworded commit text as review comments at change #4
-- tear down component if failed at dp_display_request_irq()

Changes in v4:
-- delete dp->irq check at dp_display_request_irq()

Changes in v3:
-- move calling dp_display_irq_handler() to probe

Signed-off-by: Kuogee Hsieh <quic_khsieh@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/570069/
Link: https://lore.kernel.org/r/1701472789-25951-2-git-send-email-quic_khsieh@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/dp/dp_display.c
drivers/gpu/drm/msm/dp/dp_display.h

index 2ac9d61501c7511b54d7fc7ccf343e308283417a..36bdba19467adf28b92432ac241d1bd91836647c 100644 (file)
@@ -1183,26 +1183,18 @@ static irqreturn_t dp_display_irq_handler(int irq, void *dev_id)
        return ret;
 }
 
-int dp_display_request_irq(struct msm_dp *dp_display)
+static int dp_display_request_irq(struct dp_display_private *dp)
 {
        int rc = 0;
-       struct dp_display_private *dp;
-
-       if (!dp_display) {
-               DRM_ERROR("invalid input\n");
-               return -EINVAL;
-       }
-
-       dp = container_of(dp_display, struct dp_display_private, dp_display);
+       struct platform_device *pdev = dp->dp_display.pdev;
 
-       dp->irq = irq_of_parse_and_map(dp->dp_display.pdev->dev.of_node, 0);
+       dp->irq = platform_get_irq(pdev, 0);
        if (!dp->irq) {
                DRM_ERROR("failed to get irq\n");
                return -EINVAL;
        }
 
-       rc = devm_request_irq(dp_display->drm_dev->dev, dp->irq,
-                       dp_display_irq_handler,
+       rc = devm_request_irq(&pdev->dev, dp->irq, dp_display_irq_handler,
                        IRQF_TRIGGER_HIGH, "dp_display_isr", dp);
        if (rc < 0) {
                DRM_ERROR("failed to request IRQ%u: %d\n",
@@ -1277,13 +1269,21 @@ static int dp_display_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, &dp->dp_display);
 
+       rc = dp_display_request_irq(dp);
+       if (rc)
+               goto err;
+
        rc = component_add(&pdev->dev, &dp_display_comp_ops);
        if (rc) {
                DRM_ERROR("component add failed, rc=%d\n", rc);
-               dp_display_deinit_sub_modules(dp);
+               goto err;
        }
 
        return rc;
+
+err:
+       dp_display_deinit_sub_modules(dp);
+       return rc;
 }
 
 static void dp_display_remove(struct platform_device *pdev)
@@ -1536,12 +1536,6 @@ int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev,
 
        dp_priv = container_of(dp_display, struct dp_display_private, dp_display);
 
-       ret = dp_display_request_irq(dp_display);
-       if (ret) {
-               DRM_ERROR("request_irq failed, ret=%d\n", ret);
-               return ret;
-       }
-
        ret = dp_display_get_next_bridge(dp_display);
        if (ret)
                return ret;
index 5e2fbd8318e93f5c49f6e88046b5110b2ffa04c5..b4a8be0abd9a63d8bdcf783690b1839ecd78c339 100644 (file)
@@ -36,7 +36,6 @@ struct msm_dp {
 int dp_display_set_plugged_cb(struct msm_dp *dp_display,
                hdmi_codec_plugged_cb fn, struct device *codec_dev);
 int dp_display_get_modes(struct msm_dp *dp_display);
-int dp_display_request_irq(struct msm_dp *dp_display);
 bool dp_display_check_video_test(struct msm_dp *dp_display);
 int dp_display_get_test_bpp(struct msm_dp *dp_display);
 void dp_display_signal_audio_start(struct msm_dp *dp_display);