Skip to contentSkip to conversation

drm/msm/dp: several fixes for the IRQ handling

RFC PATCH In review Dmitry Baryshkov 4 participants 12 messages Sep 1, 2022 – Sep 13, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/msm/dp: several fixes for the IRQ handling

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

Dmitry Baryshkov (3):
drm/msm/dp: fold disable_irq into devm_request_irq drm/msm/dp: switch to using platform_get_irq() drm/msm/dp: move dp_request_irq() call to dp_display_probe()

 drivers/gpu/drm/msm/dp/dp_display.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

RFC PATCH 1/3 drm/msm/dp: fold disable_irq into devm_request_irq

Calling disable_irq() right after devm_request_irq() is a bad practice. it leaves a small window when the driver doesn't expect the IRQ, but the hardware still can trigger it. Use the IRQF_NO_AUTOEN flag to prevent the request_irq from enabling the IRQ line.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +1 -2
index bfd0aeff3f0d..3173e6962a78 100644
@@ -1251,13 +1251,12 @@ int dp_display_request_irq(struct msm_dp *dp_display)
 
 	rc = devm_request_irq(&dp->pdev->dev, dp->irq,
 			dp_display_irq_handler,
-			IRQF_TRIGGER_HIGH, "dp_display_isr", dp);
+			IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN, "dp_display_isr", dp);
 	if (rc < 0) {
 		DRM_ERROR("failed to request IRQ%u: %d\n",
 				dp->irq, rc);
 		return rc;
 	}
-	disable_irq(dp->irq);
 
 	return 0;
 }
Signature · 1 line
2.35.1
#2 lore raw

Re: [RFC PATCH 1/3] drm/msm/dp: fold disable_irq into devm_request_irq

Quoting Dmitry Baryshkov (2022-09-01 02:15:25)

Quoted 6 lines
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
index bfd0aeff3f0d..3173e6962a78 100644
@@ -1251,13 +1251,12 @@ int dp_display_request_irq(struct msm_dp *dp_display)
 

drivers/gpu/drm/msm/dp/dp_display.c int dp_display_request_irq(struct msm_dp *dp_display) · line 1260

Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +1 -2
        rc = devm_request_irq(&dp->pdev->dev, dp->irq,
                        dp_display_irq_handler,
-                       IRQF_TRIGGER_HIGH, "dp_display_isr", dp);
+                       IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN, "dp_display_isr", dp);
        if (rc < 0) {
                DRM_ERROR("failed to request IRQ%u: %d\n",
                                dp->irq, rc);
                return rc;
        }
-       disable_irq(dp->irq);

It would be better to not disable the irq at all and mask the irq in the hardware before requesting the irq. Can you add at least add a TODO for that?

#3 lore raw

RFC PATCH 2/3 drm/msm/dp: switch to using platform_get_irq()

In reply to Dmitry Baryshkov

There is little point in using irq_of_parse_and_map(). Switch to plain and usual platform_get_irq() for parsing the DP IRQ line.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +2 -2
index 3173e6962a78..40c7f91abec9 100644
@@ -1243,8 +1243,8 @@ int dp_display_request_irq(struct msm_dp *dp_display)
 
 	dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-	dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
-	if (!dp->irq) {
+	dp->irq = platform_get_irq(dp->pdev, 0);
+	if (dp->irq < 0) {
 		DRM_ERROR("failed to get irq\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.35.1
#4 lore raw

Re: [RFC PATCH 2/3] drm/msm/dp: switch to using platform_get_irq()

Quoting Dmitry Baryshkov (2022-09-01 02:15:26)

Quoted 13 lines

There is little point in using irq_of_parse_and_map(). Switch to plain and usual platform_get_irq() for parsing the DP IRQ line.

---
 drivers/gpu/drm/msm/dp/dp_display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +0 -0
index 3173e6962a78..40c7f91abec9 100644

drivers/gpu/drm/msm/dp/dp_display.c int dp_display_request_irq(struct msm_dp *dp_display) · line 1248

Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_display.c +2 -2
@@ -1243,8 +1243,8 @@ int dp_display_request_irq(struct msm_dp *dp_display)
 
        dp = container_of(dp_display, struct dp_display_private, dp_display);
 
-       dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
-       if (!dp->irq) {
+       dp->irq = platform_get_irq(dp->pdev, 0);
+       if (dp->irq < 0) {
                DRM_ERROR("failed to get irq\n");

Can drop the error as well because platform_get_irq() prints an error on failure.

#5 lore raw

RFC PATCH 3/3 drm/msm/dp: move dp_request_irq() call to dp_display_probe()

In reply to Dmitry Baryshkov

As the MDSS registers the IRQ domain before populating child devices, there is little point in deferring the IRQ request up to the msm_dp_modeset_init(). Following the 'get resources as early as possible' paradigm, move dp_request_irq() call to dp_display_probe().

---
 drivers/gpu/drm/msm/dp/dp_display.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +6 -6
index 40c7f91abec9..0fb3cb773bec 100644
@@ -1309,6 +1309,12 @@ static int dp_display_probe(struct platform_device *pdev)
 	dp->dp_display.is_edp =
 		(dp->dp_display.connector_type == DRM_MODE_CONNECTOR_eDP);
 
+	rc = dp_display_request_irq(&dp->dp_display);
+	if (rc) {
+		DRM_ERROR("request_irq failed, ret=%d\n", rc);
+		return rc;
+	}
+
 	rc = dp_init_sub_modules(dp);
 	if (rc) {
 		DRM_ERROR("init sub module failed\n");
@@ -1600,12 +1606,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;
Signature · 1 line
2.35.1
Reviewed-by on v1 3/3
#6 lore raw

Re: [RFC PATCH 3/3] drm/msm/dp: move dp_request_irq() call to dp_display_probe()

Quoting Dmitry Baryshkov (2022-09-01 02:15:27)

Quoted 7 lines

As the MDSS registers the IRQ domain before populating child devices, there is little point in deferring the IRQ request up to the msm_dp_modeset_init(). Following the 'get resources as early as possible' paradigm, move dp_request_irq() call to dp_display_probe().

---

#7 lore raw
In reply to Dmitry Baryshkov
Quoted 4 lines · Dmitry Baryshkov

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

Please try to reproduce the issue yourself before posting untested RFCs. We're all short on time.

Johan

#8 lore raw
Quoted 8 lines · Johan Hovold
Quoted 4 lines · Dmitry Baryshkov

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

Please try to reproduce the issue yourself before posting untested RFCs. We're all short on time.

I do not have a working DP setup. Thus it's either this, or nothing.

Signature · 2 lines
With best wishes
Dmitry
#9 lore raw
Quoted 11 lines · Dmitry Baryshkov
Quoted 8 lines · Johan Hovold
Quoted 4 lines · Dmitry Baryshkov

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

Please try to reproduce the issue yourself before posting untested RFCs. We're all short on time.

I do not have a working DP setup. Thus it's either this, or nothing.

Ok, you could have mentioned that as the above sounds a bit lazy.

I don't have time to work on this right now as I mentioned elsewhere. Avoiding probe deferral by fiddling with the config serves as a fragile workaround until then.

Johan

#10 lore raw
In reply to Dmitry Baryshkov
Quoted 5 lines · Dmitry Baryshkov

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

This series fixes the probe deferral issue on Lenovo Thinkpad X13s. But I didn't look close enough to verify if all other resource deallocation are just fine.

Thanks for the quick series, Dmitry!

Regards,
Mani

Quoted 11 lines

Dmitry Baryshkov (3):
drm/msm/dp: fold disable_irq into devm_request_irq drm/msm/dp: switch to using platform_get_irq() drm/msm/dp: move dp_request_irq() call to dp_display_probe()

 drivers/gpu/drm/msm/dp/dp_display.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.35.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#11 lore raw
In reply to Dmitry Baryshkov
Quoted 4 lines · Dmitry Baryshkov

Johan Hovold has reported that returning a probe deferral from the msm_dp_modeset_init() can cause issues because the IRQ is not freed properly. This (compile-tested only) series tries to fix the issue by moving devm_request_irq() to the probe callback.

For reference, here's an analysis of the underlying problem and a series of fixes that addresses this:

	https://lore.kernel.org/all/[email protected]/

Note that moving the irq request to probe also fixes the immediate issue, but that can now be done as a follow-on cleanup (optimisation) instead.

Quoted 7 lines

Dmitry Baryshkov (3):
drm/msm/dp: fold disable_irq into devm_request_irq drm/msm/dp: switch to using platform_get_irq() drm/msm/dp: move dp_request_irq() call to dp_display_probe()

 drivers/gpu/drm/msm/dp/dp_display.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Johan