Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * drm_irq.c IRQ and vblank support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * \author Rickard E. (Rik) Faith <faith@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * \author Gareth Hughes <gareth@valinux.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * The above copyright notice and this permission notice (including the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * paragraph) shall be included in all copies or substantial portions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * The above copyright notice and this permission notice (including the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * paragraph) shall be included in all copies or substantial portions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #include <linux/interrupt.h>	/* For task queue support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #include <linux/vgaarb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #include <drm/drm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #include <drm/drm_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #include <drm/drm_drv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #include <drm/drm_irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #include <drm/drm_print.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #include <drm/drm_vblank.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #include "drm_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * DOC: irq helpers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * The DRM core provides very simple support helpers to enable IRQ handling on a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * device through the drm_irq_install() and drm_irq_uninstall() functions. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * only supports devices with a single interrupt on the main device stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * &drm_device.dev and set as the device paramter in drm_dev_alloc().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * These IRQ helpers are strictly optional. Drivers which roll their own only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * need to set &drm_device.irq_enabled to signal the DRM core that vblank
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * interrupts are working. Since these helpers don't automatically clean up the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * requested interrupt like e.g. devm_request_irq() they're not really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * recommended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * drm_irq_install - install IRQ handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * @irq: IRQ number to install the handler for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * Initializes the IRQ related data. Installs the handler, calling the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * &drm_driver.irq_preinstall and &drm_driver.irq_postinstall functions before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * and after the installation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * This is the simplified helper interface provided for drivers with no special
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * needs. Drivers which need to install interrupt handlers for multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * interrupts must instead set &drm_device.irq_enabled to signal the DRM core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * that vblank interrupts are available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * @irq must match the interrupt number that would be passed to request_irq(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * if called directly instead of using this helper function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * &drm_driver.irq_handler is called to handle the registered interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Zero on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) int drm_irq_install(struct drm_device *dev, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	unsigned long sh_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (irq == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	if (dev->irq_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	dev->irq_enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	DRM_DEBUG("irq=%d\n", irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* Before installing handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (dev->driver->irq_preinstall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		dev->driver->irq_preinstall(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	/* PCI devices require shared interrupts. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (dev->pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		sh_flags = IRQF_SHARED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	ret = request_irq(irq, dev->driver->irq_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			  sh_flags, dev->driver->name, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		dev->irq_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	/* After installing handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (dev->driver->irq_postinstall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		ret = dev->driver->irq_postinstall(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		dev->irq_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		if (drm_core_check_feature(dev, DRIVER_LEGACY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			vga_client_register(dev->pdev, NULL, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		free_irq(irq, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		dev->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) EXPORT_SYMBOL(drm_irq_install);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * drm_irq_uninstall - uninstall the IRQ handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * Calls the driver's &drm_driver.irq_uninstall function and unregisters the IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * handler.  This should only be called by drivers which used drm_irq_install()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * to set up their interrupt handler. Other drivers must only reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * &drm_device.irq_enabled to false.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * Note that for kernel modesetting drivers it is a bug if this function fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * The sanity checks are only to catch buggy user modesetting drivers which call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * the same function through an ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * Zero on success or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int drm_irq_uninstall(struct drm_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	unsigned long irqflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	bool irq_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	irq_enabled = dev->irq_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	dev->irq_enabled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 * Wake up any waiters so they don't hang. This is just to paper over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 * issues for UMS drivers which aren't in full control of their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 * vblank/irq handling. KMS drivers must ensure that vblanks are all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 * disabled when uninstalling the irq handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (drm_dev_has_vblank(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		spin_lock_irqsave(&dev->vbl_lock, irqflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		for (i = 0; i < dev->num_crtcs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			struct drm_vblank_crtc *vblank = &dev->vblank[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			if (!vblank->enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			WARN_ON(drm_core_check_feature(dev, DRIVER_MODESET));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			drm_vblank_disable_and_save(dev, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			wake_up(&vblank->queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (!irq_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	DRM_DEBUG("irq=%d\n", dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (drm_core_check_feature(dev, DRIVER_LEGACY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		vga_client_register(dev->pdev, NULL, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (dev->driver->irq_uninstall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		dev->driver->irq_uninstall(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	free_irq(dev->irq, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) EXPORT_SYMBOL(drm_irq_uninstall);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #if IS_ENABLED(CONFIG_DRM_LEGACY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int drm_legacy_irq_control(struct drm_device *dev, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			   struct drm_file *file_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	struct drm_control *ctl = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	int ret = 0, irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	/* if we haven't irq we fallback for compatibility reasons -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	 * this used to be a separate function in drm_dma.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	/* UMS was only ever supported on pci devices. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (WARN_ON(!dev->pdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	switch (ctl->func) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	case DRM_INST_HANDLER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		irq = dev->pdev->irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		    ctl->irq != irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		mutex_lock(&dev->struct_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		ret = drm_irq_install(dev, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		mutex_unlock(&dev->struct_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	case DRM_UNINST_HANDLER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		mutex_lock(&dev->struct_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		ret = drm_irq_uninstall(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		mutex_unlock(&dev->struct_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #endif