Skip to content

Commit 5fc40f4

Browse files
author
Thomas Zimmermann
committed
drm/mxsfb: 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. Signed-off-by: Thomas Zimmermann <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f026e43 commit 5fc40f4

File tree

2 files changed

+52
-31
lines changed

2 files changed

+52
-31
lines changed

drivers/gpu/drm/mxsfb/mxsfb_drv.c

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <drm/drm_fourcc.h>
2525
#include <drm/drm_gem_cma_helper.h>
2626
#include <drm/drm_gem_framebuffer_helper.h>
27-
#include <drm/drm_irq.h>
2827
#include <drm/drm_mode_config.h>
2928
#include <drm/drm_of.h>
3029
#include <drm/drm_probe_helper.h>
@@ -153,6 +152,49 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
153152
return 0;
154153
}
155154

155+
static irqreturn_t mxsfb_irq_handler(int irq, void *data)
156+
{
157+
struct drm_device *drm = data;
158+
struct mxsfb_drm_private *mxsfb = drm->dev_private;
159+
u32 reg;
160+
161+
reg = readl(mxsfb->base + LCDC_CTRL1);
162+
163+
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
164+
drm_crtc_handle_vblank(&mxsfb->crtc);
165+
166+
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
167+
168+
return IRQ_HANDLED;
169+
}
170+
171+
static void mxsfb_irq_disable(struct drm_device *drm)
172+
{
173+
struct mxsfb_drm_private *mxsfb = drm->dev_private;
174+
175+
mxsfb_enable_axi_clk(mxsfb);
176+
mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
177+
mxsfb_disable_axi_clk(mxsfb);
178+
}
179+
180+
static int mxsfb_irq_install(struct drm_device *dev, int irq)
181+
{
182+
if (irq == IRQ_NOTCONNECTED)
183+
return -ENOTCONN;
184+
185+
mxsfb_irq_disable(dev);
186+
187+
return request_irq(irq, mxsfb_irq_handler, 0, dev->driver->name, dev);
188+
}
189+
190+
static void mxsfb_irq_uninstall(struct drm_device *dev)
191+
{
192+
struct mxsfb_drm_private *mxsfb = dev->dev_private;
193+
194+
mxsfb_irq_disable(dev);
195+
free_irq(mxsfb->irq, dev);
196+
}
197+
156198
static int mxsfb_load(struct drm_device *drm,
157199
const struct mxsfb_devdata *devdata)
158200
{
@@ -226,8 +268,13 @@ static int mxsfb_load(struct drm_device *drm,
226268

227269
drm_mode_config_reset(drm);
228270

271+
ret = platform_get_irq(pdev, 0);
272+
if (ret < 0)
273+
goto err_vblank;
274+
mxsfb->irq = ret;
275+
229276
pm_runtime_get_sync(drm->dev);
230-
ret = drm_irq_install(drm, platform_get_irq(pdev, 0));
277+
ret = mxsfb_irq_install(drm, mxsfb->irq);
231278
pm_runtime_put_sync(drm->dev);
232279

233280
if (ret < 0) {
@@ -255,46 +302,18 @@ static void mxsfb_unload(struct drm_device *drm)
255302
drm_mode_config_cleanup(drm);
256303

257304
pm_runtime_get_sync(drm->dev);
258-
drm_irq_uninstall(drm);
305+
mxsfb_irq_uninstall(drm);
259306
pm_runtime_put_sync(drm->dev);
260307

261308
drm->dev_private = NULL;
262309

263310
pm_runtime_disable(drm->dev);
264311
}
265312

266-
static void mxsfb_irq_disable(struct drm_device *drm)
267-
{
268-
struct mxsfb_drm_private *mxsfb = drm->dev_private;
269-
270-
mxsfb_enable_axi_clk(mxsfb);
271-
mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
272-
mxsfb_disable_axi_clk(mxsfb);
273-
}
274-
275-
static irqreturn_t mxsfb_irq_handler(int irq, void *data)
276-
{
277-
struct drm_device *drm = data;
278-
struct mxsfb_drm_private *mxsfb = drm->dev_private;
279-
u32 reg;
280-
281-
reg = readl(mxsfb->base + LCDC_CTRL1);
282-
283-
if (reg & CTRL1_CUR_FRAME_DONE_IRQ)
284-
drm_crtc_handle_vblank(&mxsfb->crtc);
285-
286-
writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
287-
288-
return IRQ_HANDLED;
289-
}
290-
291313
DEFINE_DRM_GEM_CMA_FOPS(fops);
292314

293315
static const struct drm_driver mxsfb_driver = {
294316
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
295-
.irq_handler = mxsfb_irq_handler,
296-
.irq_preinstall = mxsfb_irq_disable,
297-
.irq_uninstall = mxsfb_irq_disable,
298317
DRM_GEM_CMA_DRIVER_OPS,
299318
.fops = &fops,
300319
.name = "mxsfb-drm",

drivers/gpu/drm/mxsfb/mxsfb_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct mxsfb_drm_private {
3333
struct clk *clk_axi;
3434
struct clk *clk_disp_axi;
3535

36+
unsigned int irq;
37+
3638
struct drm_device *drm;
3739
struct {
3840
struct drm_plane primary;

0 commit comments

Comments
 (0)