Skip to content

Commit b636681

Browse files
author
Thomas Zimmermann
committed
drm/tilcdc: 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. DRM IRQ callbacks are now being called directly or inlined. Calls to platform_get_irq() can fail with a negative errno code. Abort initialization in this case. The DRM IRQ midlayer does not handle this case correctly. For most drivers, only the DRM IRQ helpers use irq_enabled from struct drm_device. Tilcdc also uses irq_enabled to make its error rollback work correctly. As the field will become legacy, duplicated the state in the driver's local private structure. Signed-off-by: Thomas Zimmermann <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 5518572 commit b636681

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

drivers/gpu/drm/tilcdc/tilcdc_drv.c

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <drm/drm_fourcc.h>
2121
#include <drm/drm_gem_cma_helper.h>
2222
#include <drm/drm_gem_framebuffer_helper.h>
23-
#include <drm/drm_irq.h>
2423
#include <drm/drm_mm.h>
2524
#include <drm/drm_probe_helper.h>
2625
#include <drm/drm_vblank.h>
@@ -124,6 +123,39 @@ static int cpufreq_transition(struct notifier_block *nb,
124123
}
125124
#endif
126125

126+
static irqreturn_t tilcdc_irq(int irq, void *arg)
127+
{
128+
struct drm_device *dev = arg;
129+
struct tilcdc_drm_private *priv = dev->dev_private;
130+
131+
return tilcdc_crtc_irq(priv->crtc);
132+
}
133+
134+
static int tilcdc_irq_install(struct drm_device *dev, unsigned int irq)
135+
{
136+
struct tilcdc_drm_private *priv = dev->dev_private;
137+
int ret;
138+
139+
ret = request_irq(irq, tilcdc_irq, 0, dev->driver->name, dev);
140+
if (ret)
141+
return ret;
142+
143+
priv->irq_enabled = false;
144+
145+
return 0;
146+
}
147+
148+
static void tilcdc_irq_uninstall(struct drm_device *dev)
149+
{
150+
struct tilcdc_drm_private *priv = dev->dev_private;
151+
152+
if (!priv->irq_enabled)
153+
return;
154+
155+
free_irq(priv->irq, dev);
156+
priv->irq_enabled = false;
157+
}
158+
127159
/*
128160
* DRM operations:
129161
*/
@@ -145,7 +177,7 @@ static void tilcdc_fini(struct drm_device *dev)
145177
drm_dev_unregister(dev);
146178

147179
drm_kms_helper_poll_fini(dev);
148-
drm_irq_uninstall(dev);
180+
tilcdc_irq_uninstall(dev);
149181
drm_mode_config_cleanup(dev);
150182

151183
if (priv->clk)
@@ -336,7 +368,12 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
336368
goto init_failed;
337369
}
338370

339-
ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
371+
ret = platform_get_irq(pdev, 0);
372+
if (ret < 0)
373+
goto init_failed;
374+
priv->irq = ret;
375+
376+
ret = tilcdc_irq_install(ddev, priv->irq);
340377
if (ret < 0) {
341378
dev_err(dev, "failed to install IRQ handler\n");
342379
goto init_failed;
@@ -360,13 +397,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
360397
return ret;
361398
}
362399

363-
static irqreturn_t tilcdc_irq(int irq, void *arg)
364-
{
365-
struct drm_device *dev = arg;
366-
struct tilcdc_drm_private *priv = dev->dev_private;
367-
return tilcdc_crtc_irq(priv->crtc);
368-
}
369-
370400
#if defined(CONFIG_DEBUG_FS)
371401
static const struct {
372402
const char *name;
@@ -454,7 +484,6 @@ DEFINE_DRM_GEM_CMA_FOPS(fops);
454484

455485
static const struct drm_driver tilcdc_driver = {
456486
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
457-
.irq_handler = tilcdc_irq,
458487
DRM_GEM_CMA_DRIVER_OPS,
459488
#ifdef CONFIG_DEBUG_FS
460489
.debugfs_init = tilcdc_debugfs_init,

drivers/gpu/drm/tilcdc/tilcdc_drv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct tilcdc_drm_private {
4646
struct clk *clk; /* functional clock */
4747
int rev; /* IP revision */
4848

49+
unsigned int irq;
50+
4951
/* don't attempt resolutions w/ higher W * H * Hz: */
5052
uint32_t max_bandwidth;
5153
/*
@@ -82,6 +84,7 @@ struct tilcdc_drm_private {
8284

8385
bool is_registered;
8486
bool is_componentized;
87+
bool irq_enabled;
8588
};
8689

8790
/* Sub-module for display. Since we don't know at compile time what panels

0 commit comments

Comments
 (0)