Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/arm/hdlcd: 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.

v2:
* name struct drm_device variables 'drm' (Sam)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210803090704.32152-3-tzimmermann@suse.de

+97 -78
+96 -78
drivers/gpu/drm/arm/hdlcd_drv.c
··· 29 29 #include <drm/drm_fb_helper.h> 30 30 #include <drm/drm_gem_cma_helper.h> 31 31 #include <drm/drm_gem_framebuffer_helper.h> 32 - #include <drm/drm_irq.h> 33 32 #include <drm/drm_modeset_helper.h> 34 33 #include <drm/drm_of.h> 35 34 #include <drm/drm_probe_helper.h> ··· 36 37 37 38 #include "hdlcd_drv.h" 38 39 #include "hdlcd_regs.h" 40 + 41 + static irqreturn_t hdlcd_irq(int irq, void *arg) 42 + { 43 + struct drm_device *drm = arg; 44 + struct hdlcd_drm_private *hdlcd = drm->dev_private; 45 + unsigned long irq_status; 46 + 47 + irq_status = hdlcd_read(hdlcd, HDLCD_REG_INT_STATUS); 48 + 49 + #ifdef CONFIG_DEBUG_FS 50 + if (irq_status & HDLCD_INTERRUPT_UNDERRUN) 51 + atomic_inc(&hdlcd->buffer_underrun_count); 52 + 53 + if (irq_status & HDLCD_INTERRUPT_DMA_END) 54 + atomic_inc(&hdlcd->dma_end_count); 55 + 56 + if (irq_status & HDLCD_INTERRUPT_BUS_ERROR) 57 + atomic_inc(&hdlcd->bus_error_count); 58 + 59 + if (irq_status & HDLCD_INTERRUPT_VSYNC) 60 + atomic_inc(&hdlcd->vsync_count); 61 + 62 + #endif 63 + if (irq_status & HDLCD_INTERRUPT_VSYNC) 64 + drm_crtc_handle_vblank(&hdlcd->crtc); 65 + 66 + /* acknowledge interrupt(s) */ 67 + hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, irq_status); 68 + 69 + return IRQ_HANDLED; 70 + } 71 + 72 + static void hdlcd_irq_preinstall(struct drm_device *drm) 73 + { 74 + struct hdlcd_drm_private *hdlcd = drm->dev_private; 75 + /* Ensure interrupts are disabled */ 76 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, 0); 77 + hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, ~0); 78 + } 79 + 80 + static void hdlcd_irq_postinstall(struct drm_device *drm) 81 + { 82 + #ifdef CONFIG_DEBUG_FS 83 + struct hdlcd_drm_private *hdlcd = drm->dev_private; 84 + unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 85 + 86 + /* enable debug interrupts */ 87 + irq_mask |= HDLCD_DEBUG_INT_MASK; 88 + 89 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 90 + #endif 91 + } 92 + 93 + static int hdlcd_irq_install(struct drm_device *drm, int irq) 94 + { 95 + int ret; 96 + 97 + if (irq == IRQ_NOTCONNECTED) 98 + return -ENOTCONN; 99 + 100 + hdlcd_irq_preinstall(drm); 101 + 102 + ret = request_irq(irq, hdlcd_irq, 0, drm->driver->name, drm); 103 + if (ret) 104 + return ret; 105 + 106 + hdlcd_irq_postinstall(drm); 107 + 108 + return 0; 109 + } 110 + 111 + static void hdlcd_irq_uninstall(struct drm_device *drm) 112 + { 113 + struct hdlcd_drm_private *hdlcd = drm->dev_private; 114 + /* disable all the interrupts that we might have enabled */ 115 + unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 116 + 117 + #ifdef CONFIG_DEBUG_FS 118 + /* disable debug interrupts */ 119 + irq_mask &= ~HDLCD_DEBUG_INT_MASK; 120 + #endif 121 + 122 + /* disable vsync interrupts */ 123 + irq_mask &= ~HDLCD_INTERRUPT_VSYNC; 124 + hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 125 + 126 + free_irq(hdlcd->irq, drm); 127 + } 39 128 40 129 static int hdlcd_load(struct drm_device *drm, unsigned long flags) 41 130 { ··· 177 90 goto setup_fail; 178 91 } 179 92 180 - ret = drm_irq_install(drm, platform_get_irq(pdev, 0)); 93 + ret = platform_get_irq(pdev, 0); 94 + if (ret < 0) 95 + goto irq_fail; 96 + hdlcd->irq = ret; 97 + 98 + ret = hdlcd_irq_install(drm, hdlcd->irq); 181 99 if (ret < 0) { 182 100 DRM_ERROR("failed to install IRQ handler\n"); 183 101 goto irq_fail; ··· 212 120 drm->mode_config.max_width = HDLCD_MAX_XRES; 213 121 drm->mode_config.max_height = HDLCD_MAX_YRES; 214 122 drm->mode_config.funcs = &hdlcd_mode_config_funcs; 215 - } 216 - 217 - static irqreturn_t hdlcd_irq(int irq, void *arg) 218 - { 219 - struct drm_device *drm = arg; 220 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 221 - unsigned long irq_status; 222 - 223 - irq_status = hdlcd_read(hdlcd, HDLCD_REG_INT_STATUS); 224 - 225 - #ifdef CONFIG_DEBUG_FS 226 - if (irq_status & HDLCD_INTERRUPT_UNDERRUN) 227 - atomic_inc(&hdlcd->buffer_underrun_count); 228 - 229 - if (irq_status & HDLCD_INTERRUPT_DMA_END) 230 - atomic_inc(&hdlcd->dma_end_count); 231 - 232 - if (irq_status & HDLCD_INTERRUPT_BUS_ERROR) 233 - atomic_inc(&hdlcd->bus_error_count); 234 - 235 - if (irq_status & HDLCD_INTERRUPT_VSYNC) 236 - atomic_inc(&hdlcd->vsync_count); 237 - 238 - #endif 239 - if (irq_status & HDLCD_INTERRUPT_VSYNC) 240 - drm_crtc_handle_vblank(&hdlcd->crtc); 241 - 242 - /* acknowledge interrupt(s) */ 243 - hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, irq_status); 244 - 245 - return IRQ_HANDLED; 246 - } 247 - 248 - static void hdlcd_irq_preinstall(struct drm_device *drm) 249 - { 250 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 251 - /* Ensure interrupts are disabled */ 252 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, 0); 253 - hdlcd_write(hdlcd, HDLCD_REG_INT_CLEAR, ~0); 254 - } 255 - 256 - static int hdlcd_irq_postinstall(struct drm_device *drm) 257 - { 258 - #ifdef CONFIG_DEBUG_FS 259 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 260 - unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 261 - 262 - /* enable debug interrupts */ 263 - irq_mask |= HDLCD_DEBUG_INT_MASK; 264 - 265 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 266 - #endif 267 - return 0; 268 - } 269 - 270 - static void hdlcd_irq_uninstall(struct drm_device *drm) 271 - { 272 - struct hdlcd_drm_private *hdlcd = drm->dev_private; 273 - /* disable all the interrupts that we might have enabled */ 274 - unsigned long irq_mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK); 275 - 276 - #ifdef CONFIG_DEBUG_FS 277 - /* disable debug interrupts */ 278 - irq_mask &= ~HDLCD_DEBUG_INT_MASK; 279 - #endif 280 - 281 - /* disable vsync interrupts */ 282 - irq_mask &= ~HDLCD_INTERRUPT_VSYNC; 283 - 284 - hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask); 285 123 } 286 124 287 125 #ifdef CONFIG_DEBUG_FS ··· 258 236 259 237 static const struct drm_driver hdlcd_driver = { 260 238 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, 261 - .irq_handler = hdlcd_irq, 262 - .irq_preinstall = hdlcd_irq_preinstall, 263 - .irq_postinstall = hdlcd_irq_postinstall, 264 - .irq_uninstall = hdlcd_irq_uninstall, 265 239 DRM_GEM_CMA_DRIVER_OPS, 266 240 #ifdef CONFIG_DEBUG_FS 267 241 .debugfs_init = hdlcd_debugfs_init, ··· 334 316 err_unload: 335 317 of_node_put(hdlcd->crtc.port); 336 318 hdlcd->crtc.port = NULL; 337 - drm_irq_uninstall(drm); 319 + hdlcd_irq_uninstall(drm); 338 320 of_reserved_mem_device_release(drm->dev); 339 321 err_free: 340 322 drm_mode_config_cleanup(drm); ··· 356 338 hdlcd->crtc.port = NULL; 357 339 pm_runtime_get_sync(dev); 358 340 drm_atomic_helper_shutdown(drm); 359 - drm_irq_uninstall(drm); 341 + hdlcd_irq_uninstall(drm); 360 342 pm_runtime_put(dev); 361 343 if (pm_runtime_enabled(dev)) 362 344 pm_runtime_disable(dev);
+1
drivers/gpu/drm/arm/hdlcd_drv.h
··· 11 11 struct clk *clk; 12 12 struct drm_crtc crtc; 13 13 struct drm_plane *plane; 14 + unsigned int irq; 14 15 #ifdef CONFIG_DEBUG_FS 15 16 atomic_t buffer_underrun_count; 16 17 atomic_t bus_error_count;