blob: 36483e0d3c9729e555163e9f9a0b1cfe7dc319a8 [file] [log] [blame]
Alex Deucherd38ceaf2015-04-20 16:55:21 -04001/*
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 */
Dave Airliee9c5e742016-01-14 08:07:55 +100028#include <linux/irq.h>
Alex Deucherd38ceaf2015-04-20 16:55:21 -040029#include <drm/drmP.h>
30#include <drm/drm_crtc_helper.h>
31#include <drm/amdgpu_drm.h>
32#include "amdgpu.h"
33#include "amdgpu_ih.h"
34#include "atom.h"
35#include "amdgpu_connectors.h"
Christian Königcef105f2016-12-06 03:41:55 -050036#include "amdgpu_trace.h"
Alex Deucherd38ceaf2015-04-20 16:55:21 -040037
38#include <linux/pm_runtime.h>
39
Harry Wentland45622362017-09-12 15:58:20 -040040#ifdef CONFIG_DRM_AMD_DC
41#include "amdgpu_dm_irq.h"
42#endif
43
Alex Deucherd38ceaf2015-04-20 16:55:21 -040044#define AMDGPU_WAIT_IDLE_TIMEOUT 200
45
46/*
47 * Handle hotplug events outside the interrupt handler proper.
48 */
49/**
50 * amdgpu_hotplug_work_func - display hotplug work handler
51 *
52 * @work: work struct
53 *
54 * This is the hot plug event work handler (all asics).
55 * The work gets scheduled from the irq handler if there
56 * was a hot plug interrupt. It walks the connector table
57 * and calls the hotplug handler for each one, then sends
58 * a drm hotplug event to alert userspace.
59 */
60static void amdgpu_hotplug_work_func(struct work_struct *work)
61{
62 struct amdgpu_device *adev = container_of(work, struct amdgpu_device,
63 hotplug_work);
64 struct drm_device *dev = adev->ddev;
65 struct drm_mode_config *mode_config = &dev->mode_config;
66 struct drm_connector *connector;
67
Alex Deucher9e14c652015-05-15 11:52:18 -040068 mutex_lock(&mode_config->mutex);
Daniel Vetter2babdc82016-12-14 00:08:04 +010069 list_for_each_entry(connector, &mode_config->connector_list, head)
70 amdgpu_connector_hotplug(connector);
Alex Deucher9e14c652015-05-15 11:52:18 -040071 mutex_unlock(&mode_config->mutex);
Alex Deucherd38ceaf2015-04-20 16:55:21 -040072 /* Just fire off a uevent and let userspace tell us what to do */
73 drm_helper_hpd_irq_event(dev);
74}
75
76/**
77 * amdgpu_irq_reset_work_func - execute gpu reset
78 *
79 * @work: work struct
80 *
81 * Execute scheduled gpu reset (cayman+).
82 * This function is called when the irq handler
83 * thinks we need a gpu reset.
84 */
85static void amdgpu_irq_reset_work_func(struct work_struct *work)
86{
87 struct amdgpu_device *adev = container_of(work, struct amdgpu_device,
88 reset_work);
89
Monk Liu4fbf87e22017-05-05 15:09:42 +080090 if (!amdgpu_sriov_vf(adev))
Alex Deucher5f152b52017-12-15 16:40:49 -050091 amdgpu_device_gpu_recover(adev, NULL, false);
Alex Deucherd38ceaf2015-04-20 16:55:21 -040092}
93
94/* Disable *all* interrupts */
95static void amdgpu_irq_disable_all(struct amdgpu_device *adev)
96{
97 unsigned long irqflags;
Alex Deucherd766e6a2016-03-29 18:28:50 -040098 unsigned i, j, k;
Alex Deucherd38ceaf2015-04-20 16:55:21 -040099 int r;
100
101 spin_lock_irqsave(&adev->irq.lock, irqflags);
Alex Deucherd766e6a2016-03-29 18:28:50 -0400102 for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) {
103 if (!adev->irq.client[i].sources)
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400104 continue;
105
Alex Deucherd766e6a2016-03-29 18:28:50 -0400106 for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
107 struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
108
109 if (!src || !src->funcs->set || !src->num_types)
110 continue;
111
112 for (k = 0; k < src->num_types; ++k) {
113 atomic_set(&src->enabled_types[k], 0);
114 r = src->funcs->set(adev, src, k,
115 AMDGPU_IRQ_STATE_DISABLE);
116 if (r)
117 DRM_ERROR("error disabling interrupt (%d)\n",
118 r);
119 }
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400120 }
121 }
122 spin_unlock_irqrestore(&adev->irq.lock, irqflags);
123}
124
125/**
126 * amdgpu_irq_preinstall - drm irq preinstall callback
127 *
128 * @dev: drm dev pointer
129 *
130 * Gets the hw ready to enable irqs (all asics).
131 * This function disables all interrupt sources on the GPU.
132 */
133void amdgpu_irq_preinstall(struct drm_device *dev)
134{
135 struct amdgpu_device *adev = dev->dev_private;
136
137 /* Disable *all* interrupts */
138 amdgpu_irq_disable_all(adev);
139 /* Clear bits */
140 amdgpu_ih_process(adev);
141}
142
143/**
144 * amdgpu_irq_postinstall - drm irq preinstall callback
145 *
146 * @dev: drm dev pointer
147 *
148 * Handles stuff to be done after enabling irqs (all asics).
149 * Returns 0 on success.
150 */
151int amdgpu_irq_postinstall(struct drm_device *dev)
152{
Alex Deucher5a6adfa2015-09-22 10:06:45 -0400153 dev->max_vblank_count = 0x00ffffff;
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400154 return 0;
155}
156
157/**
158 * amdgpu_irq_uninstall - drm irq uninstall callback
159 *
160 * @dev: drm dev pointer
161 *
162 * This function disables all interrupt sources on the GPU (all asics).
163 */
164void amdgpu_irq_uninstall(struct drm_device *dev)
165{
166 struct amdgpu_device *adev = dev->dev_private;
167
168 if (adev == NULL) {
169 return;
170 }
171 amdgpu_irq_disable_all(adev);
172}
173
174/**
175 * amdgpu_irq_handler - irq handler
176 *
177 * @int irq, void *arg: args
178 *
179 * This is the irq handler for the amdgpu driver (all asics).
180 */
181irqreturn_t amdgpu_irq_handler(int irq, void *arg)
182{
183 struct drm_device *dev = (struct drm_device *) arg;
184 struct amdgpu_device *adev = dev->dev_private;
185 irqreturn_t ret;
186
187 ret = amdgpu_ih_process(adev);
188 if (ret == IRQ_HANDLED)
189 pm_runtime_mark_last_busy(dev->dev);
190 return ret;
191}
192
193/**
194 * amdgpu_msi_ok - asic specific msi checks
195 *
196 * @adev: amdgpu device pointer
197 *
198 * Handles asic specific MSI checks to determine if
199 * MSIs should be enabled on a particular chip (all asics).
200 * Returns true if MSIs should be enabled, false if MSIs
201 * should not be enabled.
202 */
203static bool amdgpu_msi_ok(struct amdgpu_device *adev)
204{
205 /* force MSI on */
206 if (amdgpu_msi == 1)
207 return true;
208 else if (amdgpu_msi == 0)
209 return false;
210
211 return true;
212}
213
214/**
215 * amdgpu_irq_init - init driver interrupt info
216 *
217 * @adev: amdgpu device pointer
218 *
219 * Sets up the work irq handlers, vblank init, MSIs, etc. (all asics).
220 * Returns 0 for success, error for failure.
221 */
222int amdgpu_irq_init(struct amdgpu_device *adev)
223{
224 int r = 0;
225
226 spin_lock_init(&adev->irq.lock);
Mario Kleiner8e1b90cc2017-06-21 03:44:56 +0200227
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400228 /* enable msi */
229 adev->irq.msi_enabled = false;
230
231 if (amdgpu_msi_ok(adev)) {
232 int ret = pci_enable_msi(adev->pdev);
233 if (!ret) {
234 adev->irq.msi_enabled = true;
pding9953b722017-10-26 09:30:38 +0800235 dev_dbg(adev->dev, "amdgpu: using MSI.\n");
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400236 }
237 }
238
Harry Wentland45622362017-09-12 15:58:20 -0400239 if (!amdgpu_device_has_dc_support(adev)) {
240 if (!adev->enable_virtual_display)
241 /* Disable vblank irqs aggressively for power-saving */
242 /* XXX: can this be enabled for DC? */
243 adev->ddev->vblank_disable_immediate = true;
244
245 r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc);
246 if (r)
247 return r;
248
249 /* pre DCE11 */
250 INIT_WORK(&adev->hotplug_work,
251 amdgpu_hotplug_work_func);
252 }
253
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400254 INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
255
256 adev->irq.installed = true;
257 r = drm_irq_install(adev->ddev, adev->ddev->pdev->irq);
258 if (r) {
259 adev->irq.installed = false;
Monk Liu9f519432018-01-19 19:02:16 +0800260 if (!amdgpu_device_has_dc_support(adev))
261 flush_work(&adev->hotplug_work);
Alex Deuchere8d75152016-10-21 16:16:07 -0400262 cancel_work_sync(&adev->reset_work);
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400263 return r;
264 }
265
pding9953b722017-10-26 09:30:38 +0800266 DRM_DEBUG("amdgpu: irq initialized.\n");
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400267 return 0;
268}
269
270/**
271 * amdgpu_irq_fini - tear down driver interrupt info
272 *
273 * @adev: amdgpu device pointer
274 *
275 * Tears down the work irq handlers, vblank handlers, MSIs, etc. (all asics).
276 */
277void amdgpu_irq_fini(struct amdgpu_device *adev)
278{
Alex Deucherd766e6a2016-03-29 18:28:50 -0400279 unsigned i, j;
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400280
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400281 if (adev->irq.installed) {
282 drm_irq_uninstall(adev->ddev);
283 adev->irq.installed = false;
284 if (adev->irq.msi_enabled)
285 pci_disable_msi(adev->pdev);
Monk Liu9f519432018-01-19 19:02:16 +0800286 if (!amdgpu_device_has_dc_support(adev))
287 flush_work(&adev->hotplug_work);
Alex Deuchere8d75152016-10-21 16:16:07 -0400288 cancel_work_sync(&adev->reset_work);
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400289 }
290
Alex Deucherd766e6a2016-03-29 18:28:50 -0400291 for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) {
292 if (!adev->irq.client[i].sources)
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400293 continue;
294
Alex Deucherd766e6a2016-03-29 18:28:50 -0400295 for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
296 struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
297
298 if (!src)
299 continue;
300
301 kfree(src->enabled_types);
302 src->enabled_types = NULL;
303 if (src->data) {
304 kfree(src->data);
305 kfree(src);
306 adev->irq.client[i].sources[j] = NULL;
307 }
Alex Deucher0cf3be22015-07-28 14:24:53 -0400308 }
Alex Deucherd766e6a2016-03-29 18:28:50 -0400309 kfree(adev->irq.client[i].sources);
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400310 }
311}
312
313/**
314 * amdgpu_irq_add_id - register irq source
315 *
316 * @adev: amdgpu device pointer
317 * @src_id: source id for this source
318 * @source: irq source
319 *
320 */
Alex Deucherd766e6a2016-03-29 18:28:50 -0400321int amdgpu_irq_add_id(struct amdgpu_device *adev,
322 unsigned client_id, unsigned src_id,
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400323 struct amdgpu_irq_src *source)
324{
Alex Deucherd766e6a2016-03-29 18:28:50 -0400325 if (client_id >= AMDGPU_IH_CLIENTID_MAX)
326 return -EINVAL;
327
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400328 if (src_id >= AMDGPU_MAX_IRQ_SRC_ID)
329 return -EINVAL;
330
Alex Deucherd766e6a2016-03-29 18:28:50 -0400331 if (!source->funcs)
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400332 return -EINVAL;
333
Alex Deucherd766e6a2016-03-29 18:28:50 -0400334 if (!adev->irq.client[client_id].sources) {
Christian König6e3f1872017-04-05 11:46:12 +0200335 adev->irq.client[client_id].sources =
336 kcalloc(AMDGPU_MAX_IRQ_SRC_ID,
337 sizeof(struct amdgpu_irq_src *),
338 GFP_KERNEL);
Alex Deucherd766e6a2016-03-29 18:28:50 -0400339 if (!adev->irq.client[client_id].sources)
340 return -ENOMEM;
341 }
342
343 if (adev->irq.client[client_id].sources[src_id] != NULL)
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400344 return -EINVAL;
345
346 if (source->num_types && !source->enabled_types) {
347 atomic_t *types;
348
349 types = kcalloc(source->num_types, sizeof(atomic_t),
350 GFP_KERNEL);
351 if (!types)
352 return -ENOMEM;
353
354 source->enabled_types = types;
355 }
356
Alex Deucherd766e6a2016-03-29 18:28:50 -0400357 adev->irq.client[client_id].sources[src_id] = source;
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400358 return 0;
359}
360
361/**
362 * amdgpu_irq_dispatch - dispatch irq to IP blocks
363 *
364 * @adev: amdgpu device pointer
365 * @entry: interrupt vector
366 *
367 * Dispatches the irq to the different IP blocks
368 */
369void amdgpu_irq_dispatch(struct amdgpu_device *adev,
370 struct amdgpu_iv_entry *entry)
371{
Alex Deucherd766e6a2016-03-29 18:28:50 -0400372 unsigned client_id = entry->client_id;
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400373 unsigned src_id = entry->src_id;
374 struct amdgpu_irq_src *src;
375 int r;
376
Christian Königcef105f2016-12-06 03:41:55 -0500377 trace_amdgpu_iv(entry);
378
Alex Deucherd766e6a2016-03-29 18:28:50 -0400379 if (client_id >= AMDGPU_IH_CLIENTID_MAX) {
380 DRM_DEBUG("Invalid client_id in IV: %d\n", client_id);
381 return;
382 }
383
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400384 if (src_id >= AMDGPU_MAX_IRQ_SRC_ID) {
385 DRM_DEBUG("Invalid src_id in IV: %d\n", src_id);
386 return;
387 }
388
Alex Deucher5f232362015-11-06 01:29:08 -0500389 if (adev->irq.virq[src_id]) {
390 generic_handle_irq(irq_find_mapping(adev->irq.domain, src_id));
391 } else {
Alex Deucherd766e6a2016-03-29 18:28:50 -0400392 if (!adev->irq.client[client_id].sources) {
393 DRM_DEBUG("Unregistered interrupt client_id: %d src_id: %d\n",
394 client_id, src_id);
395 return;
396 }
397
398 src = adev->irq.client[client_id].sources[src_id];
Alex Deucher5f232362015-11-06 01:29:08 -0500399 if (!src) {
400 DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id);
401 return;
402 }
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400403
Alex Deucher5f232362015-11-06 01:29:08 -0500404 r = src->funcs->process(adev, src, entry);
405 if (r)
406 DRM_ERROR("error processing interrupt (%d)\n", r);
407 }
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400408}
409
410/**
411 * amdgpu_irq_update - update hw interrupt state
412 *
413 * @adev: amdgpu device pointer
414 * @src: interrupt src you want to enable
415 * @type: type of interrupt you want to update
416 *
417 * Updates the interrupt state for a specific src (all asics).
418 */
419int amdgpu_irq_update(struct amdgpu_device *adev,
420 struct amdgpu_irq_src *src, unsigned type)
421{
422 unsigned long irqflags;
423 enum amdgpu_interrupt_state state;
424 int r;
425
426 spin_lock_irqsave(&adev->irq.lock, irqflags);
427
428 /* we need to determine after taking the lock, otherwise
429 we might disable just enabled interrupts again */
430 if (amdgpu_irq_enabled(adev, src, type))
431 state = AMDGPU_IRQ_STATE_ENABLE;
432 else
433 state = AMDGPU_IRQ_STATE_DISABLE;
434
435 r = src->funcs->set(adev, src, type, state);
436 spin_unlock_irqrestore(&adev->irq.lock, irqflags);
437 return r;
438}
439
Chunming Zhou0eaeb072016-06-16 16:54:53 +0800440void amdgpu_irq_gpu_reset_resume_helper(struct amdgpu_device *adev)
441{
Alex Deucherd766e6a2016-03-29 18:28:50 -0400442 int i, j, k;
443
444 for (i = 0; i < AMDGPU_IH_CLIENTID_MAX; ++i) {
445 if (!adev->irq.client[i].sources)
Chunming Zhou0eaeb072016-06-16 16:54:53 +0800446 continue;
Alex Deucherd766e6a2016-03-29 18:28:50 -0400447
448 for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
449 struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
450
451 if (!src)
452 continue;
453 for (k = 0; k < src->num_types; k++)
454 amdgpu_irq_update(adev, src, k);
455 }
Chunming Zhou0eaeb072016-06-16 16:54:53 +0800456 }
457}
458
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400459/**
460 * amdgpu_irq_get - enable interrupt
461 *
462 * @adev: amdgpu device pointer
463 * @src: interrupt src you want to enable
464 * @type: type of interrupt you want to enable
465 *
466 * Enables the interrupt type for a specific src (all asics).
467 */
468int amdgpu_irq_get(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
469 unsigned type)
470{
471 if (!adev->ddev->irq_enabled)
472 return -ENOENT;
473
474 if (type >= src->num_types)
475 return -EINVAL;
476
477 if (!src->enabled_types || !src->funcs->set)
478 return -EINVAL;
479
480 if (atomic_inc_return(&src->enabled_types[type]) == 1)
481 return amdgpu_irq_update(adev, src, type);
482
483 return 0;
484}
485
Alex Deucherd38ceaf2015-04-20 16:55:21 -0400486/**
487 * amdgpu_irq_put - disable interrupt
488 *
489 * @adev: amdgpu device pointer
490 * @src: interrupt src you want to disable
491 * @type: type of interrupt you want to disable
492 *
493 * Disables the interrupt type for a specific src (all asics).
494 */
495int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
496 unsigned type)
497{
498 if (!adev->ddev->irq_enabled)
499 return -ENOENT;
500
501 if (type >= src->num_types)
502 return -EINVAL;
503
504 if (!src->enabled_types || !src->funcs->set)
505 return -EINVAL;
506
507 if (atomic_dec_and_test(&src->enabled_types[type]))
508 return amdgpu_irq_update(adev, src, type);
509
510 return 0;
511}
512
513/**
514 * amdgpu_irq_enabled - test if irq is enabled or not
515 *
516 * @adev: amdgpu device pointer
517 * @idx: interrupt src you want to test
518 *
519 * Tests if the given interrupt source is enabled or not
520 */
521bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
522 unsigned type)
523{
524 if (!adev->ddev->irq_enabled)
525 return false;
526
527 if (type >= src->num_types)
528 return false;
529
530 if (!src->enabled_types || !src->funcs->set)
531 return false;
532
533 return !!atomic_read(&src->enabled_types[type]);
534}
Alex Deucher5f232362015-11-06 01:29:08 -0500535
536/* gen irq */
537static void amdgpu_irq_mask(struct irq_data *irqd)
538{
539 /* XXX */
540}
541
542static void amdgpu_irq_unmask(struct irq_data *irqd)
543{
544 /* XXX */
545}
546
547static struct irq_chip amdgpu_irq_chip = {
548 .name = "amdgpu-ih",
549 .irq_mask = amdgpu_irq_mask,
550 .irq_unmask = amdgpu_irq_unmask,
551};
552
553static int amdgpu_irqdomain_map(struct irq_domain *d,
554 unsigned int irq, irq_hw_number_t hwirq)
555{
556 if (hwirq >= AMDGPU_MAX_IRQ_SRC_ID)
557 return -EPERM;
558
559 irq_set_chip_and_handler(irq,
560 &amdgpu_irq_chip, handle_simple_irq);
561 return 0;
562}
563
Nils Wallméniusf498d9e2016-04-10 16:29:59 +0200564static const struct irq_domain_ops amdgpu_hw_irqdomain_ops = {
Alex Deucher5f232362015-11-06 01:29:08 -0500565 .map = amdgpu_irqdomain_map,
566};
567
568/**
569 * amdgpu_irq_add_domain - create a linear irq domain
570 *
571 * @adev: amdgpu device pointer
572 *
573 * Create an irq domain for GPU interrupt sources
574 * that may be driven by another driver (e.g., ACP).
575 */
576int amdgpu_irq_add_domain(struct amdgpu_device *adev)
577{
578 adev->irq.domain = irq_domain_add_linear(NULL, AMDGPU_MAX_IRQ_SRC_ID,
579 &amdgpu_hw_irqdomain_ops, adev);
580 if (!adev->irq.domain) {
581 DRM_ERROR("GPU irq add domain failed\n");
582 return -ENODEV;
583 }
584
585 return 0;
586}
587
588/**
589 * amdgpu_irq_remove_domain - remove the irq domain
590 *
591 * @adev: amdgpu device pointer
592 *
593 * Remove the irq domain for GPU interrupt sources
594 * that may be driven by another driver (e.g., ACP).
595 */
596void amdgpu_irq_remove_domain(struct amdgpu_device *adev)
597{
598 if (adev->irq.domain) {
599 irq_domain_remove(adev->irq.domain);
600 adev->irq.domain = NULL;
601 }
602}
603
604/**
605 * amdgpu_irq_create_mapping - create a mapping between a domain irq and a
606 * Linux irq
607 *
608 * @adev: amdgpu device pointer
609 * @src_id: IH source id
610 *
611 * Create a mapping between a domain irq (GPU IH src id) and a Linux irq
612 * Use this for components that generate a GPU interrupt, but are driven
613 * by a different driver (e.g., ACP).
614 * Returns the Linux irq.
615 */
616unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id)
617{
618 adev->irq.virq[src_id] = irq_create_mapping(adev->irq.domain, src_id);
619
620 return adev->irq.virq[src_id];
621}