amdgpu_irq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. */
  28. /**
  29. * DOC: Interrupt Handling
  30. *
  31. * Interrupts generated within GPU hardware raise interrupt requests that are
  32. * passed to amdgpu IRQ handler which is responsible for detecting source and
  33. * type of the interrupt and dispatching matching handlers. If handling an
  34. * interrupt requires calling kernel functions that may sleep processing is
  35. * dispatched to work handlers.
  36. *
  37. * If MSI functionality is not disabled by module parameter then MSI
  38. * support will be enabled.
  39. *
  40. * For GPU interrupt sources that may be driven by another driver, IRQ domain
  41. * support is used (with mapping between virtual and hardware IRQs).
  42. */
  43. #include <linux/irq.h>
  44. #include <drm/drmP.h>
  45. #include <drm/drm_crtc_helper.h>
  46. #include <drm/amdgpu_drm.h>
  47. #include "amdgpu.h"
  48. #include "amdgpu_ih.h"
  49. #include "atom.h"
  50. #include "amdgpu_connectors.h"
  51. #include "amdgpu_trace.h"
  52. #include "amdgpu_amdkfd.h"
  53. #include <linux/pm_runtime.h>
  54. #ifdef CONFIG_DRM_AMD_DC
  55. #include "amdgpu_dm_irq.h"
  56. #endif
  57. #define AMDGPU_WAIT_IDLE_TIMEOUT 200
  58. /**
  59. * amdgpu_hotplug_work_func - work handler for display hotplug event
  60. *
  61. * @work: work struct pointer
  62. *
  63. * This is the hotplug event work handler (all ASICs).
  64. * The work gets scheduled from the IRQ handler if there
  65. * was a hotplug interrupt. It walks through the connector table
  66. * and calls hotplug handler for each connector. After this, it sends
  67. * a DRM hotplug event to alert userspace.
  68. *
  69. * This design approach is required in order to defer hotplug event handling
  70. * from the IRQ handler to a work handler because hotplug handler has to use
  71. * mutexes which cannot be locked in an IRQ handler (since &mutex_lock may
  72. * sleep).
  73. */
  74. static void amdgpu_hotplug_work_func(struct work_struct *work)
  75. {
  76. struct amdgpu_device *adev = container_of(work, struct amdgpu_device,
  77. hotplug_work);
  78. struct drm_device *dev = adev->ddev;
  79. struct drm_mode_config *mode_config = &dev->mode_config;
  80. struct drm_connector *connector;
  81. mutex_lock(&mode_config->mutex);
  82. list_for_each_entry(connector, &mode_config->connector_list, head)
  83. amdgpu_connector_hotplug(connector);
  84. mutex_unlock(&mode_config->mutex);
  85. /* Just fire off a uevent and let userspace tell us what to do */
  86. drm_helper_hpd_irq_event(dev);
  87. }
  88. /**
  89. * amdgpu_irq_reset_work_func - execute GPU reset
  90. *
  91. * @work: work struct pointer
  92. *
  93. * Execute scheduled GPU reset (Cayman+).
  94. * This function is called when the IRQ handler thinks we need a GPU reset.
  95. */
  96. static void amdgpu_irq_reset_work_func(struct work_struct *work)
  97. {
  98. struct amdgpu_device *adev = container_of(work, struct amdgpu_device,
  99. reset_work);
  100. if (!amdgpu_sriov_vf(adev) && amdgpu_device_should_recover_gpu(adev))
  101. amdgpu_device_gpu_recover(adev, NULL);
  102. }
  103. /**
  104. * amdgpu_irq_disable_all - disable *all* interrupts
  105. *
  106. * @adev: amdgpu device pointer
  107. *
  108. * Disable all types of interrupts from all sources.
  109. */
  110. void amdgpu_irq_disable_all(struct amdgpu_device *adev)
  111. {
  112. unsigned long irqflags;
  113. unsigned i, j, k;
  114. int r;
  115. spin_lock_irqsave(&adev->irq.lock, irqflags);
  116. for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
  117. if (!adev->irq.client[i].sources)
  118. continue;
  119. for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
  120. struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
  121. if (!src || !src->funcs->set || !src->num_types)
  122. continue;
  123. for (k = 0; k < src->num_types; ++k) {
  124. atomic_set(&src->enabled_types[k], 0);
  125. r = src->funcs->set(adev, src, k,
  126. AMDGPU_IRQ_STATE_DISABLE);
  127. if (r)
  128. DRM_ERROR("error disabling interrupt (%d)\n",
  129. r);
  130. }
  131. }
  132. }
  133. spin_unlock_irqrestore(&adev->irq.lock, irqflags);
  134. }
  135. /**
  136. * amdgpu_irq_callback - callback from the IH ring
  137. *
  138. * @adev: amdgpu device pointer
  139. * @ih: amdgpu ih ring
  140. *
  141. * Callback from IH ring processing to handle the entry at the current position
  142. * and advance the read pointer.
  143. */
  144. static void amdgpu_irq_callback(struct amdgpu_device *adev,
  145. struct amdgpu_ih_ring *ih)
  146. {
  147. u32 ring_index = ih->rptr >> 2;
  148. struct amdgpu_iv_entry entry;
  149. /* Prescreening of high-frequency interrupts */
  150. if (!amdgpu_ih_prescreen_iv(adev))
  151. return;
  152. /* Before dispatching irq to IP blocks, send it to amdkfd */
  153. amdgpu_amdkfd_interrupt(adev, (const void *) &ih->ring[ring_index]);
  154. entry.iv_entry = (const uint32_t *)&ih->ring[ring_index];
  155. amdgpu_ih_decode_iv(adev, &entry);
  156. amdgpu_irq_dispatch(adev, &entry);
  157. }
  158. /**
  159. * amdgpu_irq_handler - IRQ handler
  160. *
  161. * @irq: IRQ number (unused)
  162. * @arg: pointer to DRM device
  163. *
  164. * IRQ handler for amdgpu driver (all ASICs).
  165. *
  166. * Returns:
  167. * result of handling the IRQ, as defined by &irqreturn_t
  168. */
  169. irqreturn_t amdgpu_irq_handler(int irq, void *arg)
  170. {
  171. struct drm_device *dev = (struct drm_device *) arg;
  172. struct amdgpu_device *adev = dev->dev_private;
  173. irqreturn_t ret;
  174. ret = amdgpu_ih_process(adev, &adev->irq.ih, amdgpu_irq_callback);
  175. if (ret == IRQ_HANDLED)
  176. pm_runtime_mark_last_busy(dev->dev);
  177. return ret;
  178. }
  179. /**
  180. * amdgpu_msi_ok - check whether MSI functionality is enabled
  181. *
  182. * @adev: amdgpu device pointer (unused)
  183. *
  184. * Checks whether MSI functionality has been disabled via module parameter
  185. * (all ASICs).
  186. *
  187. * Returns:
  188. * *true* if MSIs are allowed to be enabled or *false* otherwise
  189. */
  190. static bool amdgpu_msi_ok(struct amdgpu_device *adev)
  191. {
  192. if (amdgpu_msi == 1)
  193. return true;
  194. else if (amdgpu_msi == 0)
  195. return false;
  196. return true;
  197. }
  198. /**
  199. * amdgpu_irq_init - initialize interrupt handling
  200. *
  201. * @adev: amdgpu device pointer
  202. *
  203. * Sets up work functions for hotplug and reset interrupts, enables MSI
  204. * functionality, initializes vblank, hotplug and reset interrupt handling.
  205. *
  206. * Returns:
  207. * 0 on success or error code on failure
  208. */
  209. int amdgpu_irq_init(struct amdgpu_device *adev)
  210. {
  211. int r = 0;
  212. spin_lock_init(&adev->irq.lock);
  213. /* Enable MSI if not disabled by module parameter */
  214. adev->irq.msi_enabled = false;
  215. if (amdgpu_msi_ok(adev)) {
  216. int ret = pci_enable_msi(adev->pdev);
  217. if (!ret) {
  218. adev->irq.msi_enabled = true;
  219. dev_dbg(adev->dev, "amdgpu: using MSI.\n");
  220. }
  221. }
  222. if (!amdgpu_device_has_dc_support(adev)) {
  223. if (!adev->enable_virtual_display)
  224. /* Disable vblank IRQs aggressively for power-saving */
  225. /* XXX: can this be enabled for DC? */
  226. adev->ddev->vblank_disable_immediate = true;
  227. r = drm_vblank_init(adev->ddev, adev->mode_info.num_crtc);
  228. if (r)
  229. return r;
  230. /* Pre-DCE11 */
  231. INIT_WORK(&adev->hotplug_work,
  232. amdgpu_hotplug_work_func);
  233. }
  234. INIT_WORK(&adev->reset_work, amdgpu_irq_reset_work_func);
  235. adev->irq.installed = true;
  236. r = drm_irq_install(adev->ddev, adev->ddev->pdev->irq);
  237. if (r) {
  238. adev->irq.installed = false;
  239. if (!amdgpu_device_has_dc_support(adev))
  240. flush_work(&adev->hotplug_work);
  241. cancel_work_sync(&adev->reset_work);
  242. return r;
  243. }
  244. adev->ddev->max_vblank_count = 0x00ffffff;
  245. DRM_DEBUG("amdgpu: irq initialized.\n");
  246. return 0;
  247. }
  248. /**
  249. * amdgpu_irq_fini - shut down interrupt handling
  250. *
  251. * @adev: amdgpu device pointer
  252. *
  253. * Tears down work functions for hotplug and reset interrupts, disables MSI
  254. * functionality, shuts down vblank, hotplug and reset interrupt handling,
  255. * turns off interrupts from all sources (all ASICs).
  256. */
  257. void amdgpu_irq_fini(struct amdgpu_device *adev)
  258. {
  259. unsigned i, j;
  260. if (adev->irq.installed) {
  261. drm_irq_uninstall(adev->ddev);
  262. adev->irq.installed = false;
  263. if (adev->irq.msi_enabled)
  264. pci_disable_msi(adev->pdev);
  265. if (!amdgpu_device_has_dc_support(adev))
  266. flush_work(&adev->hotplug_work);
  267. cancel_work_sync(&adev->reset_work);
  268. }
  269. for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
  270. if (!adev->irq.client[i].sources)
  271. continue;
  272. for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
  273. struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
  274. if (!src)
  275. continue;
  276. kfree(src->enabled_types);
  277. src->enabled_types = NULL;
  278. if (src->data) {
  279. kfree(src->data);
  280. kfree(src);
  281. adev->irq.client[i].sources[j] = NULL;
  282. }
  283. }
  284. kfree(adev->irq.client[i].sources);
  285. adev->irq.client[i].sources = NULL;
  286. }
  287. }
  288. /**
  289. * amdgpu_irq_add_id - register IRQ source
  290. *
  291. * @adev: amdgpu device pointer
  292. * @client_id: client id
  293. * @src_id: source id
  294. * @source: IRQ source pointer
  295. *
  296. * Registers IRQ source on a client.
  297. *
  298. * Returns:
  299. * 0 on success or error code otherwise
  300. */
  301. int amdgpu_irq_add_id(struct amdgpu_device *adev,
  302. unsigned client_id, unsigned src_id,
  303. struct amdgpu_irq_src *source)
  304. {
  305. if (client_id >= AMDGPU_IRQ_CLIENTID_MAX)
  306. return -EINVAL;
  307. if (src_id >= AMDGPU_MAX_IRQ_SRC_ID)
  308. return -EINVAL;
  309. if (!source->funcs)
  310. return -EINVAL;
  311. if (!adev->irq.client[client_id].sources) {
  312. adev->irq.client[client_id].sources =
  313. kcalloc(AMDGPU_MAX_IRQ_SRC_ID,
  314. sizeof(struct amdgpu_irq_src *),
  315. GFP_KERNEL);
  316. if (!adev->irq.client[client_id].sources)
  317. return -ENOMEM;
  318. }
  319. if (adev->irq.client[client_id].sources[src_id] != NULL)
  320. return -EINVAL;
  321. if (source->num_types && !source->enabled_types) {
  322. atomic_t *types;
  323. types = kcalloc(source->num_types, sizeof(atomic_t),
  324. GFP_KERNEL);
  325. if (!types)
  326. return -ENOMEM;
  327. source->enabled_types = types;
  328. }
  329. adev->irq.client[client_id].sources[src_id] = source;
  330. return 0;
  331. }
  332. /**
  333. * amdgpu_irq_dispatch - dispatch IRQ to IP blocks
  334. *
  335. * @adev: amdgpu device pointer
  336. * @entry: interrupt vector pointer
  337. *
  338. * Dispatches IRQ to IP blocks.
  339. */
  340. void amdgpu_irq_dispatch(struct amdgpu_device *adev,
  341. struct amdgpu_iv_entry *entry)
  342. {
  343. unsigned client_id = entry->client_id;
  344. unsigned src_id = entry->src_id;
  345. struct amdgpu_irq_src *src;
  346. int r;
  347. trace_amdgpu_iv(entry);
  348. if (client_id >= AMDGPU_IRQ_CLIENTID_MAX) {
  349. DRM_DEBUG("Invalid client_id in IV: %d\n", client_id);
  350. return;
  351. }
  352. if (src_id >= AMDGPU_MAX_IRQ_SRC_ID) {
  353. DRM_DEBUG("Invalid src_id in IV: %d\n", src_id);
  354. return;
  355. }
  356. if (adev->irq.virq[src_id]) {
  357. generic_handle_irq(irq_find_mapping(adev->irq.domain, src_id));
  358. } else {
  359. if (!adev->irq.client[client_id].sources) {
  360. DRM_DEBUG("Unregistered interrupt client_id: %d src_id: %d\n",
  361. client_id, src_id);
  362. return;
  363. }
  364. src = adev->irq.client[client_id].sources[src_id];
  365. if (!src) {
  366. DRM_DEBUG("Unhandled interrupt src_id: %d\n", src_id);
  367. return;
  368. }
  369. r = src->funcs->process(adev, src, entry);
  370. if (r)
  371. DRM_ERROR("error processing interrupt (%d)\n", r);
  372. }
  373. }
  374. /**
  375. * amdgpu_irq_update - update hardware interrupt state
  376. *
  377. * @adev: amdgpu device pointer
  378. * @src: interrupt source pointer
  379. * @type: type of interrupt
  380. *
  381. * Updates interrupt state for the specific source (all ASICs).
  382. */
  383. int amdgpu_irq_update(struct amdgpu_device *adev,
  384. struct amdgpu_irq_src *src, unsigned type)
  385. {
  386. unsigned long irqflags;
  387. enum amdgpu_interrupt_state state;
  388. int r;
  389. spin_lock_irqsave(&adev->irq.lock, irqflags);
  390. /* We need to determine after taking the lock, otherwise
  391. we might disable just enabled interrupts again */
  392. if (amdgpu_irq_enabled(adev, src, type))
  393. state = AMDGPU_IRQ_STATE_ENABLE;
  394. else
  395. state = AMDGPU_IRQ_STATE_DISABLE;
  396. r = src->funcs->set(adev, src, type, state);
  397. spin_unlock_irqrestore(&adev->irq.lock, irqflags);
  398. return r;
  399. }
  400. /**
  401. * amdgpu_irq_gpu_reset_resume_helper - update interrupt states on all sources
  402. *
  403. * @adev: amdgpu device pointer
  404. *
  405. * Updates state of all types of interrupts on all sources on resume after
  406. * reset.
  407. */
  408. void amdgpu_irq_gpu_reset_resume_helper(struct amdgpu_device *adev)
  409. {
  410. int i, j, k;
  411. for (i = 0; i < AMDGPU_IRQ_CLIENTID_MAX; ++i) {
  412. if (!adev->irq.client[i].sources)
  413. continue;
  414. for (j = 0; j < AMDGPU_MAX_IRQ_SRC_ID; ++j) {
  415. struct amdgpu_irq_src *src = adev->irq.client[i].sources[j];
  416. if (!src)
  417. continue;
  418. for (k = 0; k < src->num_types; k++)
  419. amdgpu_irq_update(adev, src, k);
  420. }
  421. }
  422. }
  423. /**
  424. * amdgpu_irq_get - enable interrupt
  425. *
  426. * @adev: amdgpu device pointer
  427. * @src: interrupt source pointer
  428. * @type: type of interrupt
  429. *
  430. * Enables specified type of interrupt on the specified source (all ASICs).
  431. *
  432. * Returns:
  433. * 0 on success or error code otherwise
  434. */
  435. int amdgpu_irq_get(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  436. unsigned type)
  437. {
  438. if (!adev->ddev->irq_enabled)
  439. return -ENOENT;
  440. if (type >= src->num_types)
  441. return -EINVAL;
  442. if (!src->enabled_types || !src->funcs->set)
  443. return -EINVAL;
  444. if (atomic_inc_return(&src->enabled_types[type]) == 1)
  445. return amdgpu_irq_update(adev, src, type);
  446. return 0;
  447. }
  448. /**
  449. * amdgpu_irq_put - disable interrupt
  450. *
  451. * @adev: amdgpu device pointer
  452. * @src: interrupt source pointer
  453. * @type: type of interrupt
  454. *
  455. * Enables specified type of interrupt on the specified source (all ASICs).
  456. *
  457. * Returns:
  458. * 0 on success or error code otherwise
  459. */
  460. int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  461. unsigned type)
  462. {
  463. if (!adev->ddev->irq_enabled)
  464. return -ENOENT;
  465. if (type >= src->num_types)
  466. return -EINVAL;
  467. if (!src->enabled_types || !src->funcs->set)
  468. return -EINVAL;
  469. if (atomic_dec_and_test(&src->enabled_types[type]))
  470. return amdgpu_irq_update(adev, src, type);
  471. return 0;
  472. }
  473. /**
  474. * amdgpu_irq_enabled - check whether interrupt is enabled or not
  475. *
  476. * @adev: amdgpu device pointer
  477. * @src: interrupt source pointer
  478. * @type: type of interrupt
  479. *
  480. * Checks whether the given type of interrupt is enabled on the given source.
  481. *
  482. * Returns:
  483. * *true* if interrupt is enabled, *false* if interrupt is disabled or on
  484. * invalid parameters
  485. */
  486. bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  487. unsigned type)
  488. {
  489. if (!adev->ddev->irq_enabled)
  490. return false;
  491. if (type >= src->num_types)
  492. return false;
  493. if (!src->enabled_types || !src->funcs->set)
  494. return false;
  495. return !!atomic_read(&src->enabled_types[type]);
  496. }
  497. /* XXX: Generic IRQ handling */
  498. static void amdgpu_irq_mask(struct irq_data *irqd)
  499. {
  500. /* XXX */
  501. }
  502. static void amdgpu_irq_unmask(struct irq_data *irqd)
  503. {
  504. /* XXX */
  505. }
  506. /* amdgpu hardware interrupt chip descriptor */
  507. static struct irq_chip amdgpu_irq_chip = {
  508. .name = "amdgpu-ih",
  509. .irq_mask = amdgpu_irq_mask,
  510. .irq_unmask = amdgpu_irq_unmask,
  511. };
  512. /**
  513. * amdgpu_irqdomain_map - create mapping between virtual and hardware IRQ numbers
  514. *
  515. * @d: amdgpu IRQ domain pointer (unused)
  516. * @irq: virtual IRQ number
  517. * @hwirq: hardware irq number
  518. *
  519. * Current implementation assigns simple interrupt handler to the given virtual
  520. * IRQ.
  521. *
  522. * Returns:
  523. * 0 on success or error code otherwise
  524. */
  525. static int amdgpu_irqdomain_map(struct irq_domain *d,
  526. unsigned int irq, irq_hw_number_t hwirq)
  527. {
  528. if (hwirq >= AMDGPU_MAX_IRQ_SRC_ID)
  529. return -EPERM;
  530. irq_set_chip_and_handler(irq,
  531. &amdgpu_irq_chip, handle_simple_irq);
  532. return 0;
  533. }
  534. /* Implementation of methods for amdgpu IRQ domain */
  535. static const struct irq_domain_ops amdgpu_hw_irqdomain_ops = {
  536. .map = amdgpu_irqdomain_map,
  537. };
  538. /**
  539. * amdgpu_irq_add_domain - create a linear IRQ domain
  540. *
  541. * @adev: amdgpu device pointer
  542. *
  543. * Creates an IRQ domain for GPU interrupt sources
  544. * that may be driven by another driver (e.g., ACP).
  545. *
  546. * Returns:
  547. * 0 on success or error code otherwise
  548. */
  549. int amdgpu_irq_add_domain(struct amdgpu_device *adev)
  550. {
  551. adev->irq.domain = irq_domain_add_linear(NULL, AMDGPU_MAX_IRQ_SRC_ID,
  552. &amdgpu_hw_irqdomain_ops, adev);
  553. if (!adev->irq.domain) {
  554. DRM_ERROR("GPU irq add domain failed\n");
  555. return -ENODEV;
  556. }
  557. return 0;
  558. }
  559. /**
  560. * amdgpu_irq_remove_domain - remove the IRQ domain
  561. *
  562. * @adev: amdgpu device pointer
  563. *
  564. * Removes the IRQ domain for GPU interrupt sources
  565. * that may be driven by another driver (e.g., ACP).
  566. */
  567. void amdgpu_irq_remove_domain(struct amdgpu_device *adev)
  568. {
  569. if (adev->irq.domain) {
  570. irq_domain_remove(adev->irq.domain);
  571. adev->irq.domain = NULL;
  572. }
  573. }
  574. /**
  575. * amdgpu_irq_create_mapping - create mapping between domain Linux IRQs
  576. *
  577. * @adev: amdgpu device pointer
  578. * @src_id: IH source id
  579. *
  580. * Creates mapping between a domain IRQ (GPU IH src id) and a Linux IRQ
  581. * Use this for components that generate a GPU interrupt, but are driven
  582. * by a different driver (e.g., ACP).
  583. *
  584. * Returns:
  585. * Linux IRQ
  586. */
  587. unsigned amdgpu_irq_create_mapping(struct amdgpu_device *adev, unsigned src_id)
  588. {
  589. adev->irq.virq[src_id] = irq_create_mapping(adev->irq.domain, src_id);
  590. return adev->irq.virq[src_id];
  591. }