Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 28 | #include <drm/drmP.h> |
| 29 | #include <drm/drm_crtc_helper.h> |
| 30 | #include <drm/radeon_drm.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 31 | #include "radeon_reg.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 32 | #include "radeon.h" |
| 33 | #include "atom.h" |
| 34 | |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 35 | #include <linux/pm_runtime.h> |
| 36 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 37 | #define RADEON_WAIT_IDLE_TIMEOUT 200 |
| 38 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 39 | /** |
| 40 | * radeon_driver_irq_handler_kms - irq handler for KMS |
| 41 | * |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 42 | * @int irq, void *arg: args |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 43 | * |
| 44 | * This is the irq handler for the radeon KMS driver (all asics). |
| 45 | * radeon_irq_process is a macro that points to the per-asic |
| 46 | * irq handler callback. |
| 47 | */ |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 48 | irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 49 | { |
| 50 | struct drm_device *dev = (struct drm_device *) arg; |
| 51 | struct radeon_device *rdev = dev->dev_private; |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 52 | irqreturn_t ret; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 53 | |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 54 | ret = radeon_irq_process(rdev); |
| 55 | if (ret == IRQ_HANDLED) |
| 56 | pm_runtime_mark_last_busy(dev->dev); |
| 57 | return ret; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 60 | /* |
| 61 | * Handle hotplug events outside the interrupt handler proper. |
| 62 | */ |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 63 | /** |
| 64 | * radeon_hotplug_work_func - display hotplug work handler |
| 65 | * |
| 66 | * @work: work struct |
| 67 | * |
| 68 | * This is the hot plug event work handler (all asics). |
| 69 | * The work gets scheduled from the irq handler if there |
| 70 | * was a hot plug interrupt. It walks the connector table |
| 71 | * and calls the hotplug handler for each one, then sends |
| 72 | * a drm hotplug event to alert userspace. |
| 73 | */ |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 74 | static void radeon_hotplug_work_func(struct work_struct *work) |
| 75 | { |
| 76 | struct radeon_device *rdev = container_of(work, struct radeon_device, |
| 77 | hotplug_work); |
| 78 | struct drm_device *dev = rdev->ddev; |
| 79 | struct drm_mode_config *mode_config = &dev->mode_config; |
| 80 | struct drm_connector *connector; |
| 81 | |
| 82 | if (mode_config->num_connector) { |
| 83 | list_for_each_entry(connector, &mode_config->connector_list, head) |
| 84 | radeon_connector_hotplug(connector); |
| 85 | } |
| 86 | /* Just fire off a uevent and let userspace tell us what to do */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 87 | drm_helper_hpd_irq_event(dev); |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 88 | } |
| 89 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 90 | /** |
| 91 | * radeon_driver_irq_preinstall_kms - drm irq preinstall callback |
| 92 | * |
| 93 | * @dev: drm dev pointer |
| 94 | * |
| 95 | * Gets the hw ready to enable irqs (all asics). |
| 96 | * This function disables all interrupt sources on the GPU. |
| 97 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 98 | void radeon_driver_irq_preinstall_kms(struct drm_device *dev) |
| 99 | { |
| 100 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 101 | unsigned long irqflags; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 102 | unsigned i; |
| 103 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 104 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 105 | /* Disable *all* interrupts */ |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 106 | for (i = 0; i < RADEON_NUM_RINGS; i++) |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 107 | atomic_set(&rdev->irq.ring_int[i], 0); |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 108 | rdev->irq.dpm_thermal = false; |
Ilija Hadzic | 54bd520 | 2011-10-26 15:43:58 -0400 | [diff] [blame] | 109 | for (i = 0; i < RADEON_MAX_HPD_PINS; i++) |
Alex Deucher | 9e7b414 | 2010-03-16 17:08:06 -0400 | [diff] [blame] | 110 | rdev->irq.hpd[i] = false; |
Ilija Hadzic | 54bd520 | 2011-10-26 15:43:58 -0400 | [diff] [blame] | 111 | for (i = 0; i < RADEON_MAX_CRTCS; i++) { |
| 112 | rdev->irq.crtc_vblank_int[i] = false; |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 113 | atomic_set(&rdev->irq.pflip[i], 0); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 114 | rdev->irq.afmt[i] = false; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 115 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 116 | radeon_irq_set(rdev); |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 117 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 118 | /* Clear bits */ |
| 119 | radeon_irq_process(rdev); |
| 120 | } |
| 121 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 122 | /** |
| 123 | * radeon_driver_irq_postinstall_kms - drm irq preinstall callback |
| 124 | * |
| 125 | * @dev: drm dev pointer |
| 126 | * |
| 127 | * Handles stuff to be done after enabling irqs (all asics). |
| 128 | * Returns 0 on success. |
| 129 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 130 | int radeon_driver_irq_postinstall_kms(struct drm_device *dev) |
| 131 | { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 132 | dev->max_vblank_count = 0x001fffff; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 133 | return 0; |
| 134 | } |
| 135 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 136 | /** |
| 137 | * radeon_driver_irq_uninstall_kms - drm irq uninstall callback |
| 138 | * |
| 139 | * @dev: drm dev pointer |
| 140 | * |
| 141 | * This function disables all interrupt sources on the GPU (all asics). |
| 142 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 143 | void radeon_driver_irq_uninstall_kms(struct drm_device *dev) |
| 144 | { |
| 145 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 146 | unsigned long irqflags; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 147 | unsigned i; |
| 148 | |
| 149 | if (rdev == NULL) { |
| 150 | return; |
| 151 | } |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 152 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 153 | /* Disable *all* interrupts */ |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 154 | for (i = 0; i < RADEON_NUM_RINGS; i++) |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 155 | atomic_set(&rdev->irq.ring_int[i], 0); |
Alex Deucher | 4a6369e | 2013-04-12 14:04:10 -0400 | [diff] [blame] | 156 | rdev->irq.dpm_thermal = false; |
Ilija Hadzic | 54bd520 | 2011-10-26 15:43:58 -0400 | [diff] [blame] | 157 | for (i = 0; i < RADEON_MAX_HPD_PINS; i++) |
Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 158 | rdev->irq.hpd[i] = false; |
Ilija Hadzic | 54bd520 | 2011-10-26 15:43:58 -0400 | [diff] [blame] | 159 | for (i = 0; i < RADEON_MAX_CRTCS; i++) { |
| 160 | rdev->irq.crtc_vblank_int[i] = false; |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 161 | atomic_set(&rdev->irq.pflip[i], 0); |
Alex Deucher | f122c61 | 2012-03-30 08:59:57 -0400 | [diff] [blame] | 162 | rdev->irq.afmt[i] = false; |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 163 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 164 | radeon_irq_set(rdev); |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 165 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 166 | } |
| 167 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 168 | /** |
| 169 | * radeon_msi_ok - asic specific msi checks |
| 170 | * |
| 171 | * @rdev: radeon device pointer |
| 172 | * |
| 173 | * Handles asic specific MSI checks to determine if |
| 174 | * MSIs should be enabled on a particular chip (all asics). |
| 175 | * Returns true if MSIs should be enabled, false if MSIs |
| 176 | * should not be enabled. |
| 177 | */ |
Alex Deucher | 8f6c25c | 2011-10-25 14:58:49 -0400 | [diff] [blame] | 178 | static bool radeon_msi_ok(struct radeon_device *rdev) |
| 179 | { |
| 180 | /* RV370/RV380 was first asic with MSI support */ |
| 181 | if (rdev->family < CHIP_RV380) |
| 182 | return false; |
| 183 | |
| 184 | /* MSIs don't work on AGP */ |
| 185 | if (rdev->flags & RADEON_IS_AGP) |
| 186 | return false; |
| 187 | |
Benjamin Herrenschmidt | 91ed6fd | 2014-10-03 15:18:59 +1000 | [diff] [blame] | 188 | /* |
| 189 | * Older chips have a HW limitation, they can only generate 40 bits |
| 190 | * of address for "64-bit" MSIs which breaks on some platforms, notably |
| 191 | * IBM POWER servers, so we limit them |
| 192 | */ |
| 193 | if (rdev->family < CHIP_BONAIRE) { |
| 194 | dev_info(rdev->dev, "radeon: MSI limited to 32-bit\n"); |
| 195 | rdev->pdev->no_64bit_msi = 1; |
| 196 | } |
| 197 | |
Alex Deucher | a18cee1 | 2011-11-01 14:20:30 -0400 | [diff] [blame] | 198 | /* force MSI on */ |
| 199 | if (radeon_msi == 1) |
| 200 | return true; |
| 201 | else if (radeon_msi == 0) |
| 202 | return false; |
| 203 | |
Alex Deucher | b362105 | 2011-10-25 15:11:08 -0400 | [diff] [blame] | 204 | /* Quirks */ |
| 205 | /* HP RS690 only seems to work with MSIs. */ |
| 206 | if ((rdev->pdev->device == 0x791f) && |
| 207 | (rdev->pdev->subsystem_vendor == 0x103c) && |
| 208 | (rdev->pdev->subsystem_device == 0x30c2)) |
| 209 | return true; |
| 210 | |
Alex Deucher | 01e718e | 2011-11-01 14:14:18 -0400 | [diff] [blame] | 211 | /* Dell RS690 only seems to work with MSIs. */ |
| 212 | if ((rdev->pdev->device == 0x791f) && |
| 213 | (rdev->pdev->subsystem_vendor == 0x1028) && |
Alex Deucher | 44517c4 | 2012-01-15 08:51:12 -0500 | [diff] [blame] | 214 | (rdev->pdev->subsystem_device == 0x01fc)) |
| 215 | return true; |
| 216 | |
| 217 | /* Dell RS690 only seems to work with MSIs. */ |
| 218 | if ((rdev->pdev->device == 0x791f) && |
| 219 | (rdev->pdev->subsystem_vendor == 0x1028) && |
Alex Deucher | 01e718e | 2011-11-01 14:14:18 -0400 | [diff] [blame] | 220 | (rdev->pdev->subsystem_device == 0x01fd)) |
| 221 | return true; |
| 222 | |
Alex Deucher | 3a6d59d | 2012-09-26 12:31:45 -0400 | [diff] [blame] | 223 | /* Gateway RS690 only seems to work with MSIs. */ |
| 224 | if ((rdev->pdev->device == 0x791f) && |
| 225 | (rdev->pdev->subsystem_vendor == 0x107b) && |
| 226 | (rdev->pdev->subsystem_device == 0x0185)) |
| 227 | return true; |
| 228 | |
Alex Deucher | fb6ca6d | 2012-09-26 12:40:45 -0400 | [diff] [blame] | 229 | /* try and enable MSIs by default on all RS690s */ |
| 230 | if (rdev->family == CHIP_RS690) |
| 231 | return true; |
| 232 | |
Dave Airlie | 16a5e32 | 2012-04-13 11:14:50 +0100 | [diff] [blame] | 233 | /* RV515 seems to have MSI issues where it loses |
| 234 | * MSI rearms occasionally. This leads to lockups and freezes. |
| 235 | * disable it by default. |
| 236 | */ |
| 237 | if (rdev->family == CHIP_RV515) |
| 238 | return false; |
Alex Deucher | 8f6c25c | 2011-10-25 14:58:49 -0400 | [diff] [blame] | 239 | if (rdev->flags & RADEON_IS_IGP) { |
| 240 | /* APUs work fine with MSIs */ |
| 241 | if (rdev->family >= CHIP_PALM) |
| 242 | return true; |
| 243 | /* lots of IGPs have problems with MSIs */ |
| 244 | return false; |
| 245 | } |
| 246 | |
| 247 | return true; |
| 248 | } |
| 249 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 250 | /** |
| 251 | * radeon_irq_kms_init - init driver interrupt info |
| 252 | * |
| 253 | * @rdev: radeon device pointer |
| 254 | * |
| 255 | * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics). |
| 256 | * Returns 0 for success, error for failure. |
| 257 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 258 | int radeon_irq_kms_init(struct radeon_device *rdev) |
| 259 | { |
| 260 | int r = 0; |
| 261 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 262 | spin_lock_init(&rdev->irq.lock); |
Alex Deucher | 9e7b414 | 2010-03-16 17:08:06 -0400 | [diff] [blame] | 263 | r = drm_vblank_init(rdev->ddev, rdev->num_crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 264 | if (r) { |
| 265 | return r; |
| 266 | } |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 267 | /* enable msi */ |
| 268 | rdev->msi_enabled = 0; |
Alex Deucher | 8f6c25c | 2011-10-25 14:58:49 -0400 | [diff] [blame] | 269 | |
| 270 | if (radeon_msi_ok(rdev)) { |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 271 | int ret = pci_enable_msi(rdev->pdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 272 | if (!ret) { |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 273 | rdev->msi_enabled = 1; |
Alex Deucher | da7be68 | 2010-08-12 18:05:34 -0400 | [diff] [blame] | 274 | dev_info(rdev->dev, "radeon: using MSI.\n"); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 275 | } |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 276 | } |
Sergey Senozhatsky | a01c34f | 2013-07-14 14:03:27 +0300 | [diff] [blame] | 277 | |
| 278 | INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); |
| 279 | INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi); |
Sergey Senozhatsky | a01c34f | 2013-07-14 14:03:27 +0300 | [diff] [blame] | 280 | |
Sergey Senozhatsky | 27c505c | 2013-08-29 12:29:35 +0300 | [diff] [blame] | 281 | rdev->irq.installed = true; |
Daniel Vetter | bb0f1b5 | 2013-11-03 21:09:27 +0100 | [diff] [blame] | 282 | r = drm_irq_install(rdev->ddev, rdev->ddev->pdev->irq); |
Sergey Senozhatsky | 27c505c | 2013-08-29 12:29:35 +0300 | [diff] [blame] | 283 | if (r) { |
| 284 | rdev->irq.installed = false; |
| 285 | flush_work(&rdev->hotplug_work); |
| 286 | return r; |
| 287 | } |
| 288 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 289 | DRM_INFO("radeon: irq initialized.\n"); |
| 290 | return 0; |
| 291 | } |
| 292 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 293 | /** |
Masanari Iida | cf2fbdd | 2013-03-16 20:53:05 +0900 | [diff] [blame] | 294 | * radeon_irq_kms_fini - tear down driver interrupt info |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 295 | * |
| 296 | * @rdev: radeon device pointer |
| 297 | * |
| 298 | * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics). |
| 299 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 300 | void radeon_irq_kms_fini(struct radeon_device *rdev) |
| 301 | { |
Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 302 | drm_vblank_cleanup(rdev->ddev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 303 | if (rdev->irq.installed) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 304 | drm_irq_uninstall(rdev->ddev); |
Jerome Glisse | 003e69f | 2010-01-07 15:39:14 +0100 | [diff] [blame] | 305 | rdev->irq.installed = false; |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 306 | if (rdev->msi_enabled) |
| 307 | pci_disable_msi(rdev->pdev); |
Sergey Senozhatsky | a01c34f | 2013-07-14 14:03:27 +0300 | [diff] [blame] | 308 | flush_work(&rdev->hotplug_work); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 309 | } |
| 310 | } |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 311 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 312 | /** |
| 313 | * radeon_irq_kms_sw_irq_get - enable software interrupt |
| 314 | * |
| 315 | * @rdev: radeon device pointer |
| 316 | * @ring: ring whose interrupt you want to enable |
| 317 | * |
| 318 | * Enables the software interrupt for a specific ring (all asics). |
| 319 | * The software interrupt is generally used to signal a fence on |
| 320 | * a particular ring. |
| 321 | */ |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 322 | void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring) |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 323 | { |
| 324 | unsigned long irqflags; |
| 325 | |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 326 | if (!rdev->ddev->irq_enabled) |
| 327 | return; |
| 328 | |
| 329 | if (atomic_inc_return(&rdev->irq.ring_int[ring]) == 1) { |
| 330 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 331 | radeon_irq_set(rdev); |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 332 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 333 | } |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 334 | } |
| 335 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 336 | /** |
Maarten Lankhorst | 954605c | 2014-01-09 11:03:12 +0100 | [diff] [blame] | 337 | * radeon_irq_kms_sw_irq_get_delayed - enable software interrupt |
| 338 | * |
| 339 | * @rdev: radeon device pointer |
| 340 | * @ring: ring whose interrupt you want to enable |
| 341 | * |
| 342 | * Enables the software interrupt for a specific ring (all asics). |
| 343 | * The software interrupt is generally used to signal a fence on |
| 344 | * a particular ring. |
| 345 | */ |
| 346 | bool radeon_irq_kms_sw_irq_get_delayed(struct radeon_device *rdev, int ring) |
| 347 | { |
| 348 | return atomic_inc_return(&rdev->irq.ring_int[ring]) == 1; |
| 349 | } |
| 350 | |
| 351 | /** |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 352 | * radeon_irq_kms_sw_irq_put - disable software interrupt |
| 353 | * |
| 354 | * @rdev: radeon device pointer |
| 355 | * @ring: ring whose interrupt you want to disable |
| 356 | * |
| 357 | * Disables the software interrupt for a specific ring (all asics). |
| 358 | * The software interrupt is generally used to signal a fence on |
| 359 | * a particular ring. |
| 360 | */ |
Alex Deucher | 1b37078 | 2011-11-17 20:13:28 -0500 | [diff] [blame] | 361 | void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring) |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 362 | { |
| 363 | unsigned long irqflags; |
| 364 | |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 365 | if (!rdev->ddev->irq_enabled) |
| 366 | return; |
| 367 | |
| 368 | if (atomic_dec_and_test(&rdev->irq.ring_int[ring])) { |
| 369 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 370 | radeon_irq_set(rdev); |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 371 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 372 | } |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 373 | } |
| 374 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 375 | /** |
| 376 | * radeon_irq_kms_pflip_irq_get - enable pageflip interrupt |
| 377 | * |
| 378 | * @rdev: radeon device pointer |
| 379 | * @crtc: crtc whose interrupt you want to enable |
| 380 | * |
| 381 | * Enables the pageflip interrupt for a specific crtc (all asics). |
| 382 | * For pageflips we use the vblank interrupt source. |
| 383 | */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 384 | void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc) |
| 385 | { |
| 386 | unsigned long irqflags; |
| 387 | |
| 388 | if (crtc < 0 || crtc >= rdev->num_crtc) |
| 389 | return; |
| 390 | |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 391 | if (!rdev->ddev->irq_enabled) |
| 392 | return; |
| 393 | |
| 394 | if (atomic_inc_return(&rdev->irq.pflip[crtc]) == 1) { |
| 395 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 396 | radeon_irq_set(rdev); |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 397 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 398 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 399 | } |
| 400 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 401 | /** |
| 402 | * radeon_irq_kms_pflip_irq_put - disable pageflip interrupt |
| 403 | * |
| 404 | * @rdev: radeon device pointer |
| 405 | * @crtc: crtc whose interrupt you want to disable |
| 406 | * |
| 407 | * Disables the pageflip interrupt for a specific crtc (all asics). |
| 408 | * For pageflips we use the vblank interrupt source. |
| 409 | */ |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 410 | void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc) |
| 411 | { |
| 412 | unsigned long irqflags; |
| 413 | |
| 414 | if (crtc < 0 || crtc >= rdev->num_crtc) |
| 415 | return; |
| 416 | |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 417 | if (!rdev->ddev->irq_enabled) |
| 418 | return; |
| 419 | |
| 420 | if (atomic_dec_and_test(&rdev->irq.pflip[crtc])) { |
| 421 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 422 | radeon_irq_set(rdev); |
Christian Koenig | 736fc37 | 2012-05-17 19:52:00 +0200 | [diff] [blame] | 423 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 424 | } |
Alex Deucher | 6f34be5 | 2010-11-21 10:59:01 -0500 | [diff] [blame] | 425 | } |
| 426 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 427 | /** |
| 428 | * radeon_irq_kms_enable_afmt - enable audio format change interrupt |
| 429 | * |
| 430 | * @rdev: radeon device pointer |
| 431 | * @block: afmt block whose interrupt you want to enable |
| 432 | * |
| 433 | * Enables the afmt change interrupt for a specific afmt block (all asics). |
| 434 | */ |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 435 | void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block) |
| 436 | { |
| 437 | unsigned long irqflags; |
| 438 | |
Alex Deucher | cc9945b | 2013-02-26 16:17:33 -0500 | [diff] [blame] | 439 | if (!rdev->ddev->irq_enabled) |
| 440 | return; |
| 441 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 442 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
| 443 | rdev->irq.afmt[block] = true; |
| 444 | radeon_irq_set(rdev); |
| 445 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 446 | |
| 447 | } |
| 448 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 449 | /** |
| 450 | * radeon_irq_kms_disable_afmt - disable audio format change interrupt |
| 451 | * |
| 452 | * @rdev: radeon device pointer |
| 453 | * @block: afmt block whose interrupt you want to disable |
| 454 | * |
| 455 | * Disables the afmt change interrupt for a specific afmt block (all asics). |
| 456 | */ |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 457 | void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block) |
| 458 | { |
| 459 | unsigned long irqflags; |
| 460 | |
Alex Deucher | cc9945b | 2013-02-26 16:17:33 -0500 | [diff] [blame] | 461 | if (!rdev->ddev->irq_enabled) |
| 462 | return; |
| 463 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 464 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
| 465 | rdev->irq.afmt[block] = false; |
| 466 | radeon_irq_set(rdev); |
| 467 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 468 | } |
| 469 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 470 | /** |
| 471 | * radeon_irq_kms_enable_hpd - enable hotplug detect interrupt |
| 472 | * |
| 473 | * @rdev: radeon device pointer |
| 474 | * @hpd_mask: mask of hpd pins you want to enable. |
| 475 | * |
| 476 | * Enables the hotplug detect interrupt for a specific hpd pin (all asics). |
| 477 | */ |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 478 | void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask) |
| 479 | { |
| 480 | unsigned long irqflags; |
| 481 | int i; |
| 482 | |
Alex Deucher | cc9945b | 2013-02-26 16:17:33 -0500 | [diff] [blame] | 483 | if (!rdev->ddev->irq_enabled) |
| 484 | return; |
| 485 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 486 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
| 487 | for (i = 0; i < RADEON_MAX_HPD_PINS; ++i) |
| 488 | rdev->irq.hpd[i] |= !!(hpd_mask & (1 << i)); |
| 489 | radeon_irq_set(rdev); |
| 490 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 491 | } |
| 492 | |
Alex Deucher | b73ba98 | 2012-07-17 14:02:35 -0400 | [diff] [blame] | 493 | /** |
| 494 | * radeon_irq_kms_disable_hpd - disable hotplug detect interrupt |
| 495 | * |
| 496 | * @rdev: radeon device pointer |
| 497 | * @hpd_mask: mask of hpd pins you want to disable. |
| 498 | * |
| 499 | * Disables the hotplug detect interrupt for a specific hpd pin (all asics). |
| 500 | */ |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 501 | void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask) |
| 502 | { |
| 503 | unsigned long irqflags; |
| 504 | int i; |
| 505 | |
Alex Deucher | cc9945b | 2013-02-26 16:17:33 -0500 | [diff] [blame] | 506 | if (!rdev->ddev->irq_enabled) |
| 507 | return; |
| 508 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 509 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
| 510 | for (i = 0; i < RADEON_MAX_HPD_PINS; ++i) |
| 511 | rdev->irq.hpd[i] &= !(hpd_mask & (1 << i)); |
| 512 | radeon_irq_set(rdev); |
| 513 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 514 | } |
| 515 | |