Skip to contentSkip to conversation

drm/atmel-hlcdc: drop use of drm_irq mid-layer

PATCH In review Sam Ravnborg 2 participants 5 messages Jul 11, 2021 – Jul 15, 2021

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

cover drm/atmel-hlcdc: drop use of drm_irq mid-layer

[Ignore the first mail - wrong patch was attached]

Two small patches to drop the use of the drm irq mid-layer.
My atmel hlcdc target has stopped working - so unfortunately un-tested :-( I picked up this to continue the work of Thomas Zimmermann.

Sam

Sam Ravnborg (2):
drm/atmel-hlcdc: Move interrupt helper funtions drm/atmel-hlcdc: Convert to Linux IRQ interfaces

 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 63 +++++++++++++---------------
 1 file changed, 30 insertions(+), 33 deletions(-)
#1 lore raw

PATCH 1/2 drm/atmel-hlcdc: Move interrupt helper funtions

This is in preparation for removal of drm_irq use. Functions are moved without any other changes.

Cc Sam Ravnborg <[email protected]>
Cc Boris Brezillon <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Ludovic Desroches <[email protected]>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 52 ++++++++++----------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +26 -26
index 65af56e47129..f67363188cbc 100644
@@ -521,6 +521,32 @@ atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
 	return MODE_OK;
 }
 
+static int atmel_hlcdc_dc_irq_postinstall(struct drm_device *dev)
+{
+	struct atmel_hlcdc_dc *dc = dev->dev_private;
+	unsigned int cfg = 0;
+	int i;
+
+	/* Enable interrupts on activated layers */
+	for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
+		if (dc->layers[i])
+			cfg |= ATMEL_HLCDC_LAYER_STATUS(i);
+	}
+
+	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, cfg);
+
+	return 0;
+}
+
+static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
+{
+	struct atmel_hlcdc_dc *dc = dev->dev_private;
+	unsigned int isr;
+
+	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, 0xffffffff);
+	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
+}
+
 static void atmel_hlcdc_layer_irq(struct atmel_hlcdc_layer *layer)
 {
 	if (!layer)
@@ -684,32 +710,6 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
 	clk_disable_unprepare(dc->hlcdc->periph_clk);
 }
 
-static int atmel_hlcdc_dc_irq_postinstall(struct drm_device *dev)
-{
-	struct atmel_hlcdc_dc *dc = dev->dev_private;
-	unsigned int cfg = 0;
-	int i;
-
-	/* Enable interrupts on activated layers */
-	for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
-		if (dc->layers[i])
-			cfg |= ATMEL_HLCDC_LAYER_STATUS(i);
-	}
-
-	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, cfg);
-
-	return 0;
-}
-
-static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
-{
-	struct atmel_hlcdc_dc *dc = dev->dev_private;
-	unsigned int isr;
-
-	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, 0xffffffff);
-	regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
-}
-
 DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static const struct drm_driver atmel_hlcdc_dc_driver = {
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 drm/atmel-hlcdc: Convert to Linux IRQ interfaces

In reply to Sam Ravnborg

The drm mid-layer for irq's is not relevant for atomic display drivers, and will be available only for legacy drivers in the future. Drop usage in the atmel hlcdc driver.

Cc Sam Ravnborg <[email protected]>
Cc Boris Brezillon <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Ludovic Desroches <[email protected]>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +8 -11
index f67363188cbc..6b3f353e1cc7 100644
@@ -22,7 +22,6 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
-#include <drm/drm_irq.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
 
@@ -521,9 +520,8 @@ atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc,
 	return MODE_OK;
 }
 
-static int atmel_hlcdc_dc_irq_postinstall(struct drm_device *dev)
+static int atmel_hlcdc_dc_irq_postinstall(struct atmel_hlcdc_dc *dc)
 {
-	struct atmel_hlcdc_dc *dc = dev->dev_private;
 	unsigned int cfg = 0;
 	int i;
 
@@ -538,9 +536,8 @@ static int atmel_hlcdc_dc_irq_postinstall(struct drm_device *dev)
 	return 0;
 }
 
-static void atmel_hlcdc_dc_irq_uninstall(struct drm_device *dev)
+static void atmel_hlcdc_dc_irq_reset(struct atmel_hlcdc_dc *dc)
 {
-	struct atmel_hlcdc_dc *dc = dev->dev_private;
 	unsigned int isr;
 
 	regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, 0xffffffff);
@@ -672,12 +669,14 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
 	drm_mode_config_reset(dev);
 
 	pm_runtime_get_sync(dev->dev);
-	ret = drm_irq_install(dev, dc->hlcdc->irq);
+	atmel_hlcdc_dc_irq_reset(dc);
+	ret = request_irq(dc->hlcdc->irq, atmel_hlcdc_dc_irq_handler, 0, dev->driver->name, dev);
 	pm_runtime_put_sync(dev->dev);
 	if (ret < 0) {
 		dev_err(dev->dev, "failed to install IRQ handler\n");
 		goto err_periph_clk_disable;
 	}
+	atmel_hlcdc_dc_irq_postinstall(dc);
 
 	platform_set_drvdata(pdev, dev);
 
@@ -701,7 +700,9 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
 	drm_mode_config_cleanup(dev);
 
 	pm_runtime_get_sync(dev->dev);
-	drm_irq_uninstall(dev);
+
+	atmel_hlcdc_dc_irq_reset(dc);
+	free_irq(dc->hlcdc->irq, dev);
 	pm_runtime_put_sync(dev->dev);
 
 	dev->dev_private = NULL;
@@ -714,10 +715,6 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static const struct drm_driver atmel_hlcdc_dc_driver = {
 	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
-	.irq_handler = atmel_hlcdc_dc_irq_handler,
-	.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
-	.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
-	.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
 	DRM_GEM_CMA_DRIVER_OPS,
 	.fops = &fops,
 	.name = "atmel-hlcdc",
Signature · 1 line
2.30.2
#4 lore raw

Hi Dan,

Quoted 3 lines · On Thu, Jul 15, 2021 at 09:55:09PM +0000, [email protected] wrote:

I tested this patch set on the 9x60ek board and unfortunately it causes errors.  The vbltest returns -1 and I also see the display get out of sync while testing with a gui application.

Thanks a lot for the testing, I will take a look tomorrow and see if I can figure out what is wrong.

Sam