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

drm: IRQ midlayer is now legacy

Hide the DRM midlayer behind CONFIG_DRM_LEGACY, make functions use
the prefix drm_legacy_, and move declarations to drm_legacy.h.
In struct drm_device, move the fields irq and irq_enabled behind
CONFIG_DRM_LEGACY.

All callers have been updated.

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

+27 -155
+7 -56
drivers/gpu/drm/drm_irq.c
··· 60 60 #include <drm/drm.h> 61 61 #include <drm/drm_device.h> 62 62 #include <drm/drm_drv.h> 63 - #include <drm/drm_irq.h> 63 + #include <drm/drm_legacy.h> 64 64 #include <drm/drm_print.h> 65 65 #include <drm/drm_vblank.h> 66 66 67 67 #include "drm_internal.h" 68 68 69 - /** 70 - * DOC: irq helpers 71 - * 72 - * The DRM core provides very simple support helpers to enable IRQ handling on a 73 - * device through the drm_irq_install() and drm_irq_uninstall() functions. This 74 - * only supports devices with a single interrupt on the main device stored in 75 - * &drm_device.dev and set as the device parameter in drm_dev_alloc(). 76 - * 77 - * These IRQ helpers are strictly optional. Since these helpers don't automatically 78 - * clean up the requested interrupt like e.g. devm_request_irq() they're not really 79 - * recommended. 80 - */ 81 - 82 - /** 83 - * drm_irq_install - install IRQ handler 84 - * @dev: DRM device 85 - * @irq: IRQ number to install the handler for 86 - * 87 - * Initializes the IRQ related data. Installs the handler, calling the driver 88 - * &drm_driver.irq_preinstall and &drm_driver.irq_postinstall functions before 89 - * and after the installation. 90 - * 91 - * This is the simplified helper interface provided for drivers with no special 92 - * needs. 93 - * 94 - * @irq must match the interrupt number that would be passed to request_irq(), 95 - * if called directly instead of using this helper function. 96 - * 97 - * &drm_driver.irq_handler is called to handle the registered interrupt. 98 - * 99 - * Returns: 100 - * Zero on success or a negative error code on failure. 101 - */ 102 - int drm_irq_install(struct drm_device *dev, int irq) 69 + #if IS_ENABLED(CONFIG_DRM_LEGACY) 70 + static int drm_legacy_irq_install(struct drm_device *dev, int irq) 103 71 { 104 72 int ret; 105 73 unsigned long sh_flags = 0; ··· 112 144 113 145 return ret; 114 146 } 115 - EXPORT_SYMBOL(drm_irq_install); 116 147 117 - /** 118 - * drm_irq_uninstall - uninstall the IRQ handler 119 - * @dev: DRM device 120 - * 121 - * Calls the driver's &drm_driver.irq_uninstall function and unregisters the IRQ 122 - * handler. This should only be called by drivers which used drm_irq_install() 123 - * to set up their interrupt handler. 124 - * 125 - * Note that for kernel modesetting drivers it is a bug if this function fails. 126 - * The sanity checks are only to catch buggy user modesetting drivers which call 127 - * the same function through an ioctl. 128 - * 129 - * Returns: 130 - * Zero on success or a negative error code on failure. 131 - */ 132 - int drm_irq_uninstall(struct drm_device *dev) 148 + int drm_legacy_irq_uninstall(struct drm_device *dev) 133 149 { 134 150 unsigned long irqflags; 135 151 bool irq_enabled; ··· 159 207 160 208 return 0; 161 209 } 162 - EXPORT_SYMBOL(drm_irq_uninstall); 210 + EXPORT_SYMBOL(drm_legacy_irq_uninstall); 163 211 164 - #if IS_ENABLED(CONFIG_DRM_LEGACY) 165 212 int drm_legacy_irq_control(struct drm_device *dev, void *data, 166 213 struct drm_file *file_priv) 167 214 { ··· 189 238 ctl->irq != irq) 190 239 return -EINVAL; 191 240 mutex_lock(&dev->struct_mutex); 192 - ret = drm_irq_install(dev, irq); 241 + ret = drm_legacy_irq_install(dev, irq); 193 242 mutex_unlock(&dev->struct_mutex); 194 243 195 244 return ret; 196 245 case DRM_UNINST_HANDLER: 197 246 mutex_lock(&dev->struct_mutex); 198 - ret = drm_irq_uninstall(dev); 247 + ret = drm_legacy_irq_uninstall(dev); 199 248 mutex_unlock(&dev->struct_mutex); 200 249 201 250 return ret;
+1 -2
drivers/gpu/drm/drm_legacy_misc.c
··· 35 35 36 36 #include <drm/drm_device.h> 37 37 #include <drm/drm_drv.h> 38 - #include <drm/drm_irq.h> 39 38 #include <drm/drm_print.h> 40 39 41 40 #include "drm_internal.h" ··· 77 78 void drm_legacy_dev_reinit(struct drm_device *dev) 78 79 { 79 80 if (dev->irq_enabled) 80 - drm_irq_uninstall(dev); 81 + drm_legacy_irq_uninstall(dev); 81 82 82 83 mutex_lock(&dev->struct_mutex); 83 84
+4 -4
drivers/gpu/drm/drm_vblank.c
··· 1739 1739 1740 1740 static bool drm_wait_vblank_supported(struct drm_device *dev) 1741 1741 { 1742 - if (IS_ENABLED(CONFIG_DRM_LEGACY)) { 1743 - if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY))) 1744 - return dev->irq_enabled; 1745 - } 1742 + #if IS_ENABLED(CONFIG_DRM_LEGACY) 1743 + if (unlikely(drm_core_check_feature(dev, DRIVER_LEGACY))) 1744 + return dev->irq_enabled; 1745 + #endif 1746 1746 return drm_dev_has_vblank(dev); 1747 1747 } 1748 1748
+1 -2
drivers/gpu/drm/i810/i810_dma.c
··· 38 38 #include <drm/drm_drv.h> 39 39 #include <drm/drm_file.h> 40 40 #include <drm/drm_ioctl.h> 41 - #include <drm/drm_irq.h> 42 41 #include <drm/drm_print.h> 43 42 #include <drm/i810_drm.h> 44 43 ··· 208 209 * is freed, it's too late. 209 210 */ 210 211 if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled) 211 - drm_irq_uninstall(dev); 212 + drm_legacy_irq_uninstall(dev); 212 213 213 214 if (dev->dev_private) { 214 215 int i;
+1 -1
drivers/gpu/drm/mga/mga_dma.c
··· 949 949 * is freed, it's too late. 950 950 */ 951 951 if (dev->irq_enabled) 952 - drm_irq_uninstall(dev); 952 + drm_legacy_irq_uninstall(dev); 953 953 954 954 if (dev->dev_private) { 955 955 drm_mga_private_t *dev_priv = dev->dev_private;
-1
drivers/gpu/drm/mga/mga_drv.h
··· 38 38 #include <drm/drm_device.h> 39 39 #include <drm/drm_file.h> 40 40 #include <drm/drm_ioctl.h> 41 - #include <drm/drm_irq.h> 42 41 #include <drm/drm_legacy.h> 43 42 #include <drm/drm_print.h> 44 43 #include <drm/drm_sarea.h>
+1 -2
drivers/gpu/drm/r128/r128_cce.c
··· 39 39 40 40 #include <drm/drm_device.h> 41 41 #include <drm/drm_file.h> 42 - #include <drm/drm_irq.h> 43 42 #include <drm/drm_legacy.h> 44 43 #include <drm/drm_print.h> 45 44 #include <drm/r128_drm.h> ··· 602 603 * is freed, it's too late. 603 604 */ 604 605 if (dev->irq_enabled) 605 - drm_irq_uninstall(dev); 606 + drm_legacy_irq_uninstall(dev); 606 607 607 608 if (dev->dev_private) { 608 609 drm_r128_private_t *dev_priv = dev->dev_private;
+1 -2
drivers/gpu/drm/via/via_mm.c
··· 29 29 30 30 #include <drm/drm_device.h> 31 31 #include <drm/drm_file.h> 32 - #include <drm/drm_irq.h> 33 32 #include <drm/via_drm.h> 34 33 35 34 #include "via_drv.h" ··· 85 86 /* Last context, perform cleanup */ 86 87 if (list_is_singular(&dev->ctxlist)) { 87 88 DRM_DEBUG("Last Context\n"); 88 - drm_irq_uninstall(dev); 89 + drm_legacy_irq_uninstall(dev); 89 90 via_cleanup_futex(dev_priv); 90 91 via_do_cleanup_map(dev); 91 92 }
+4 -14
include/drm/drm_device.h
··· 192 192 struct list_head clientlist; 193 193 194 194 /** 195 - * @irq_enabled: 196 - * 197 - * Indicates that interrupt handling is enabled, specifically vblank 198 - * handling. Drivers which don't use drm_irq_install() need to set this 199 - * to true manually. 200 - */ 201 - bool irq_enabled; 202 - 203 - /** 204 - * @irq: Used by the drm_irq_install() and drm_irq_unistall() helpers. 205 - */ 206 - int irq; 207 - 208 - /** 209 195 * @vblank_disable_immediate: 210 196 * 211 197 * If true, vblank interrupt will be disabled immediately when the ··· 358 372 359 373 /* Scatter gather memory */ 360 374 struct drm_sg_mem *sg; 375 + 376 + /* IRQs */ 377 + bool irq_enabled; 378 + int irq; 361 379 #endif 362 380 }; 363 381
+4 -40
include/drm/drm_drv.h
··· 137 137 * @DRIVER_HAVE_IRQ: 138 138 * 139 139 * Legacy irq support. Only for legacy drivers. Do not use. 140 - * 141 - * New drivers can either use the drm_irq_install() and 142 - * drm_irq_uninstall() helper functions, or roll their own irq support 143 - * code by calling request_irq() directly. 144 140 */ 145 141 DRIVER_HAVE_IRQ = BIT(30), 146 142 /** ··· 266 270 * managed resources functions. 267 271 */ 268 272 void (*release) (struct drm_device *); 269 - 270 - /** 271 - * @irq_handler: 272 - * 273 - * Interrupt handler called when using drm_irq_install(). Not used by 274 - * drivers which implement their own interrupt handling. 275 - */ 276 - irqreturn_t(*irq_handler) (int irq, void *arg); 277 - 278 - /** 279 - * @irq_preinstall: 280 - * 281 - * Optional callback used by drm_irq_install() which is called before 282 - * the interrupt handler is registered. This should be used to clear out 283 - * any pending interrupts (from e.g. firmware based drives) and reset 284 - * the interrupt handling registers. 285 - */ 286 - void (*irq_preinstall) (struct drm_device *dev); 287 - 288 - /** 289 - * @irq_postinstall: 290 - * 291 - * Optional callback used by drm_irq_install() which is called after 292 - * the interrupt handler is registered. This should be used to enable 293 - * interrupt generation in the hardware. 294 - */ 295 - int (*irq_postinstall) (struct drm_device *dev); 296 - 297 - /** 298 - * @irq_uninstall: 299 - * 300 - * Optional callback used by drm_irq_uninstall() which is called before 301 - * the interrupt handler is unregistered. This should be used to disable 302 - * interrupt generation in the hardware. 303 - */ 304 - void (*irq_uninstall) (struct drm_device *dev); 305 273 306 274 /** 307 275 * @master_set: ··· 464 504 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv); 465 505 int (*dma_quiescent) (struct drm_device *); 466 506 int (*context_dtor) (struct drm_device *dev, int context); 507 + irqreturn_t (*irq_handler)(int irq, void *arg); 508 + void (*irq_preinstall)(struct drm_device *dev); 509 + int (*irq_postinstall)(struct drm_device *dev); 510 + void (*irq_uninstall)(struct drm_device *dev); 467 511 u32 (*get_vblank_counter)(struct drm_device *dev, unsigned int pipe); 468 512 int (*enable_vblank)(struct drm_device *dev, unsigned int pipe); 469 513 void (*disable_vblank)(struct drm_device *dev, unsigned int pipe);
-31
include/drm/drm_irq.h
··· 1 - /* 2 - * Copyright 2016 Intel Corp. 3 - * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 14 - * 15 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 - * OTHER DEALINGS IN THE SOFTWARE. 22 - */ 23 - 24 - #ifndef _DRM_IRQ_H_ 25 - #define _DRM_IRQ_H_ 26 - 27 - struct drm_device; 28 - 29 - int drm_irq_install(struct drm_device *dev, int irq); 30 - int drm_irq_uninstall(struct drm_device *dev); 31 - #endif
+3
include/drm/drm_legacy.h
··· 192 192 void drm_legacy_idlelock_take(struct drm_lock_data *lock); 193 193 void drm_legacy_idlelock_release(struct drm_lock_data *lock); 194 194 195 + /* drm_irq.c */ 196 + int drm_legacy_irq_uninstall(struct drm_device *dev); 197 + 195 198 /* drm_pci.c */ 196 199 197 200 #ifdef CONFIG_PCI