Skip to contentSkip to conversation

drm/shmobile: Convert to Linux IRQ interfaces

PATCH Superseded Thomas Zimmermann 2 participants 3 messages Jul 15, 2021

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH v2 1/1 drm/shmobile: Convert to Linux IRQ interfaces

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers don't benefit from using it.

v2:
* handle errors in platform_get_irq() (Geert, Sergei)
* store IRQ number in struct shmob_drm_device (Laurent)

---
 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 16 +++++++++++-----
 drivers/gpu/drm/shmobile/shmob_drm_drv.h |  1 +
 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/shmobile/shmob_drm_drv.c +11 -5
index 0a02b7092c04..07878f4ef23e 100644
@@ -18,7 +18,6 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_gem_cma_helper.h>
-#include <drm/drm_irq.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
@@ -130,7 +129,6 @@ DEFINE_DRM_GEM_CMA_FOPS(shmob_drm_fops);
 
 static const struct drm_driver shmob_drm_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
-	.irq_handler		= shmob_drm_irq,
 	DRM_GEM_CMA_DRIVER_OPS,
 	.fops			= &shmob_drm_fops,
 	.name			= "shmob-drm",
@@ -183,7 +181,7 @@ static int shmob_drm_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(ddev);
 	drm_kms_helper_poll_fini(ddev);
-	drm_irq_uninstall(ddev);
+	free_irq(sdev->irq, ddev);
 	drm_dev_put(ddev);
 
 	return 0;
@@ -258,7 +256,15 @@ static int shmob_drm_probe(struct platform_device *pdev)
 		goto err_modeset_cleanup;
 	}
 
-	ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
+	ret = platform_get_irq(pdev, 0);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to get IRQ number\n");
+		goto err_modeset_cleanup;
+	}
+	sdev->irq = ret;
+
+	ret = request_irq(sdev->irq, shmob_drm_irq, 0, ddev->driver->name,
+			  ddev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to install IRQ handler\n");
 		goto err_modeset_cleanup;
@@ -275,7 +281,7 @@ static int shmob_drm_probe(struct platform_device *pdev)
 	return 0;
 
 err_irq_uninstall:
-	drm_irq_uninstall(ddev);
+	free_irq(sdev->irq, ddev);
 err_modeset_cleanup:
 	drm_kms_helper_poll_fini(ddev);
 err_free_drm_dev:
drivers/gpu/drm/shmobile/shmob_drm_drv.h +1 -0
index 80dc4b1020aa..4964ddd5ab74 100644
@@ -29,6 +29,7 @@ struct shmob_drm_device {
 	u32 lddckr;
 	u32 ldmt1r;
 
+	unsigned int irq;
 	spinlock_t irq_lock;		/* Protects hardware LDINTR register */
 
 	struct drm_device *ddev;
Signature · 1 line
2.32.0
#1 lore raw

Hi Thomas,

Quoted 9 lines · Thomas Zimmermann

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers don't benefit from using it.

v2:
* handle errors in platform_get_irq() (Geert, Sergei)
* store IRQ number in struct shmob_drm_device (Laurent)

Thanks for the update!

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 260

Quoted 9 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +2 -1
@@ -258,7 +256,15 @@ static int shmob_drm_probe(struct platform_device *pdev)
                goto err_modeset_cleanup;
        }
 
-       ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
+       ret = platform_get_irq(pdev, 0);
+       if (ret) {

if (ret < 0) {

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 261

Quoted 1 line
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -0
+               dev_err(&pdev->dev, "failed to get IRQ number\n");

platform_get_irq() already prints an error message, so no need to repeat it.

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 270

Quoted 9 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +6 -0
+               goto err_modeset_cleanup;
+       }
+       sdev->irq = ret;
+
+       ret = request_irq(sdev->irq, shmob_drm_irq, 0, ddev->driver->name,
+                         ddev);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to install IRQ handler\n");
                goto err_modeset_cleanup;

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#2 lore raw

Am 15.07.21 um 12:16 schrieb Geert Uytterhoeven:

Quoted 21 lines

Hi Thomas,

Quoted 9 lines · Thomas Zimmermann

Drop the DRM IRQ midlayer in favor of Linux IRQ interfaces. DRM's IRQ helpers are mostly useful for UMS drivers. Modern KMS drivers don't benefit from using it.

v2:
* handle errors in platform_get_irq() (Geert, Sergei)
* store IRQ number in struct shmob_drm_device (Laurent)

Thanks for the update!

Quoted 6 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +0 -0
@@ -258,7 +256,15 @@ static int shmob_drm_probe(struct platform_device *pdev)
                 goto err_modeset_cleanup;
         }
 
Quoted 5 lines

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 260

Quoted 3 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +2 -1
-       ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
+       ret = platform_get_irq(pdev, 0);
+       if (ret) {

if (ret < 0) {

Indeed :/

Quoted 20 lines

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 261

Quoted 2 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +1 -0
+               dev_err(&pdev->dev, "failed to get IRQ number\n");

platform_get_irq() already prints an error message, so no need to repeat it.

drivers/gpu/drm/shmobile/shmob_drm_drv.c static int shmob_drm_probe(struct platform_device *pdev) · line 270

Quoted 9 lines
drivers/gpu/drm/shmobile/shmob_drm_drv.c +6 -0
+               goto err_modeset_cleanup;
+       }
+       sdev->irq = ret;
+
+       ret = request_irq(sdev->irq, shmob_drm_irq, 0, ddev->driver->name,
+                         ddev);
         if (ret < 0) {
                 dev_err(&pdev->dev, "failed to install IRQ handler\n");
                 goto err_modeset_cleanup;

Gr{oetje,eeting}s,

Geert

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer