irqdomain.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. #define pr_fmt(fmt) "irq: " fmt
  2. #include <linux/debugfs.h>
  3. #include <linux/hardirq.h>
  4. #include <linux/interrupt.h>
  5. #include <linux/irq.h>
  6. #include <linux/irqdesc.h>
  7. #include <linux/irqdomain.h>
  8. #include <linux/module.h>
  9. #include <linux/mutex.h>
  10. #include <linux/of.h>
  11. #include <linux/of_address.h>
  12. #include <linux/of_irq.h>
  13. #include <linux/topology.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/slab.h>
  16. #include <linux/smp.h>
  17. #include <linux/fs.h>
  18. static LIST_HEAD(irq_domain_list);
  19. static DEFINE_MUTEX(irq_domain_mutex);
  20. static DEFINE_MUTEX(revmap_trees_mutex);
  21. static struct irq_domain *irq_default_domain;
  22. static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
  23. irq_hw_number_t hwirq, int node);
  24. static void irq_domain_check_hierarchy(struct irq_domain *domain);
  25. /**
  26. * __irq_domain_add() - Allocate a new irq_domain data structure
  27. * @of_node: optional device-tree node of the interrupt controller
  28. * @size: Size of linear map; 0 for radix mapping only
  29. * @hwirq_max: Maximum number of interrupts supported by controller
  30. * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no
  31. * direct mapping
  32. * @ops: domain callbacks
  33. * @host_data: Controller private data pointer
  34. *
  35. * Allocates and initialize and irq_domain structure.
  36. * Returns pointer to IRQ domain, or NULL on failure.
  37. */
  38. struct irq_domain *__irq_domain_add(struct device_node *of_node, int size,
  39. irq_hw_number_t hwirq_max, int direct_max,
  40. const struct irq_domain_ops *ops,
  41. void *host_data)
  42. {
  43. struct irq_domain *domain;
  44. domain = kzalloc_node(sizeof(*domain) + (sizeof(unsigned int) * size),
  45. GFP_KERNEL, of_node_to_nid(of_node));
  46. if (WARN_ON(!domain))
  47. return NULL;
  48. /* Fill structure */
  49. INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL);
  50. domain->ops = ops;
  51. domain->host_data = host_data;
  52. domain->of_node = of_node_get(of_node);
  53. domain->hwirq_max = hwirq_max;
  54. domain->revmap_size = size;
  55. domain->revmap_direct_max_irq = direct_max;
  56. irq_domain_check_hierarchy(domain);
  57. mutex_lock(&irq_domain_mutex);
  58. list_add(&domain->link, &irq_domain_list);
  59. mutex_unlock(&irq_domain_mutex);
  60. pr_debug("Added domain %s\n", domain->name);
  61. return domain;
  62. }
  63. EXPORT_SYMBOL_GPL(__irq_domain_add);
  64. /**
  65. * irq_domain_remove() - Remove an irq domain.
  66. * @domain: domain to remove
  67. *
  68. * This routine is used to remove an irq domain. The caller must ensure
  69. * that all mappings within the domain have been disposed of prior to
  70. * use, depending on the revmap type.
  71. */
  72. void irq_domain_remove(struct irq_domain *domain)
  73. {
  74. mutex_lock(&irq_domain_mutex);
  75. /*
  76. * radix_tree_delete() takes care of destroying the root
  77. * node when all entries are removed. Shout if there are
  78. * any mappings left.
  79. */
  80. WARN_ON(domain->revmap_tree.height);
  81. list_del(&domain->link);
  82. /*
  83. * If the going away domain is the default one, reset it.
  84. */
  85. if (unlikely(irq_default_domain == domain))
  86. irq_set_default_host(NULL);
  87. mutex_unlock(&irq_domain_mutex);
  88. pr_debug("Removed domain %s\n", domain->name);
  89. of_node_put(domain->of_node);
  90. kfree(domain);
  91. }
  92. EXPORT_SYMBOL_GPL(irq_domain_remove);
  93. /**
  94. * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs
  95. * @of_node: pointer to interrupt controller's device tree node.
  96. * @size: total number of irqs in mapping
  97. * @first_irq: first number of irq block assigned to the domain,
  98. * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then
  99. * pre-map all of the irqs in the domain to virqs starting at first_irq.
  100. * @ops: domain callbacks
  101. * @host_data: Controller private data pointer
  102. *
  103. * Allocates an irq_domain, and optionally if first_irq is positive then also
  104. * allocate irq_descs and map all of the hwirqs to virqs starting at first_irq.
  105. *
  106. * This is intended to implement the expected behaviour for most
  107. * interrupt controllers. If device tree is used, then first_irq will be 0 and
  108. * irqs get mapped dynamically on the fly. However, if the controller requires
  109. * static virq assignments (non-DT boot) then it will set that up correctly.
  110. */
  111. struct irq_domain *irq_domain_add_simple(struct device_node *of_node,
  112. unsigned int size,
  113. unsigned int first_irq,
  114. const struct irq_domain_ops *ops,
  115. void *host_data)
  116. {
  117. struct irq_domain *domain;
  118. domain = __irq_domain_add(of_node, size, size, 0, ops, host_data);
  119. if (!domain)
  120. return NULL;
  121. if (first_irq > 0) {
  122. if (IS_ENABLED(CONFIG_SPARSE_IRQ)) {
  123. /* attempt to allocated irq_descs */
  124. int rc = irq_alloc_descs(first_irq, first_irq, size,
  125. of_node_to_nid(of_node));
  126. if (rc < 0)
  127. pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n",
  128. first_irq);
  129. }
  130. irq_domain_associate_many(domain, first_irq, 0, size);
  131. }
  132. return domain;
  133. }
  134. EXPORT_SYMBOL_GPL(irq_domain_add_simple);
  135. /**
  136. * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.
  137. * @of_node: pointer to interrupt controller's device tree node.
  138. * @size: total number of irqs in legacy mapping
  139. * @first_irq: first number of irq block assigned to the domain
  140. * @first_hwirq: first hwirq number to use for the translation. Should normally
  141. * be '0', but a positive integer can be used if the effective
  142. * hwirqs numbering does not begin at zero.
  143. * @ops: map/unmap domain callbacks
  144. * @host_data: Controller private data pointer
  145. *
  146. * Note: the map() callback will be called before this function returns
  147. * for all legacy interrupts except 0 (which is always the invalid irq for
  148. * a legacy controller).
  149. */
  150. struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
  151. unsigned int size,
  152. unsigned int first_irq,
  153. irq_hw_number_t first_hwirq,
  154. const struct irq_domain_ops *ops,
  155. void *host_data)
  156. {
  157. struct irq_domain *domain;
  158. domain = __irq_domain_add(of_node, first_hwirq + size,
  159. first_hwirq + size, 0, ops, host_data);
  160. if (domain)
  161. irq_domain_associate_many(domain, first_irq, first_hwirq, size);
  162. return domain;
  163. }
  164. EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
  165. /**
  166. * irq_find_host() - Locates a domain for a given device node
  167. * @node: device-tree node of the interrupt controller
  168. */
  169. struct irq_domain *irq_find_host(struct device_node *node)
  170. {
  171. struct irq_domain *h, *found = NULL;
  172. int rc;
  173. /* We might want to match the legacy controller last since
  174. * it might potentially be set to match all interrupts in
  175. * the absence of a device node. This isn't a problem so far
  176. * yet though...
  177. */
  178. mutex_lock(&irq_domain_mutex);
  179. list_for_each_entry(h, &irq_domain_list, link) {
  180. if (h->ops->match)
  181. rc = h->ops->match(h, node);
  182. else
  183. rc = (h->of_node != NULL) && (h->of_node == node);
  184. if (rc) {
  185. found = h;
  186. break;
  187. }
  188. }
  189. mutex_unlock(&irq_domain_mutex);
  190. return found;
  191. }
  192. EXPORT_SYMBOL_GPL(irq_find_host);
  193. /**
  194. * irq_set_default_host() - Set a "default" irq domain
  195. * @domain: default domain pointer
  196. *
  197. * For convenience, it's possible to set a "default" domain that will be used
  198. * whenever NULL is passed to irq_create_mapping(). It makes life easier for
  199. * platforms that want to manipulate a few hard coded interrupt numbers that
  200. * aren't properly represented in the device-tree.
  201. */
  202. void irq_set_default_host(struct irq_domain *domain)
  203. {
  204. pr_debug("Default domain set to @0x%p\n", domain);
  205. irq_default_domain = domain;
  206. }
  207. EXPORT_SYMBOL_GPL(irq_set_default_host);
  208. void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq)
  209. {
  210. struct irq_data *irq_data = irq_get_irq_data(irq);
  211. irq_hw_number_t hwirq;
  212. if (WARN(!irq_data || irq_data->domain != domain,
  213. "virq%i doesn't exist; cannot disassociate\n", irq))
  214. return;
  215. hwirq = irq_data->hwirq;
  216. irq_set_status_flags(irq, IRQ_NOREQUEST);
  217. /* remove chip and handler */
  218. irq_set_chip_and_handler(irq, NULL, NULL);
  219. /* Make sure it's completed */
  220. synchronize_irq(irq);
  221. /* Tell the PIC about it */
  222. if (domain->ops->unmap)
  223. domain->ops->unmap(domain, irq);
  224. smp_mb();
  225. irq_data->domain = NULL;
  226. irq_data->hwirq = 0;
  227. /* Clear reverse map for this hwirq */
  228. if (hwirq < domain->revmap_size) {
  229. domain->linear_revmap[hwirq] = 0;
  230. } else {
  231. mutex_lock(&revmap_trees_mutex);
  232. radix_tree_delete(&domain->revmap_tree, hwirq);
  233. mutex_unlock(&revmap_trees_mutex);
  234. }
  235. }
  236. int irq_domain_associate(struct irq_domain *domain, unsigned int virq,
  237. irq_hw_number_t hwirq)
  238. {
  239. struct irq_data *irq_data = irq_get_irq_data(virq);
  240. int ret;
  241. if (WARN(hwirq >= domain->hwirq_max,
  242. "error: hwirq 0x%x is too large for %s\n", (int)hwirq, domain->name))
  243. return -EINVAL;
  244. if (WARN(!irq_data, "error: virq%i is not allocated", virq))
  245. return -EINVAL;
  246. if (WARN(irq_data->domain, "error: virq%i is already associated", virq))
  247. return -EINVAL;
  248. mutex_lock(&irq_domain_mutex);
  249. irq_data->hwirq = hwirq;
  250. irq_data->domain = domain;
  251. if (domain->ops->map) {
  252. ret = domain->ops->map(domain, virq, hwirq);
  253. if (ret != 0) {
  254. /*
  255. * If map() returns -EPERM, this interrupt is protected
  256. * by the firmware or some other service and shall not
  257. * be mapped. Don't bother telling the user about it.
  258. */
  259. if (ret != -EPERM) {
  260. pr_info("%s didn't like hwirq-0x%lx to VIRQ%i mapping (rc=%d)\n",
  261. domain->name, hwirq, virq, ret);
  262. }
  263. irq_data->domain = NULL;
  264. irq_data->hwirq = 0;
  265. mutex_unlock(&irq_domain_mutex);
  266. return ret;
  267. }
  268. /* If not already assigned, give the domain the chip's name */
  269. if (!domain->name && irq_data->chip)
  270. domain->name = irq_data->chip->name;
  271. }
  272. if (hwirq < domain->revmap_size) {
  273. domain->linear_revmap[hwirq] = virq;
  274. } else {
  275. mutex_lock(&revmap_trees_mutex);
  276. radix_tree_insert(&domain->revmap_tree, hwirq, irq_data);
  277. mutex_unlock(&revmap_trees_mutex);
  278. }
  279. mutex_unlock(&irq_domain_mutex);
  280. irq_clear_status_flags(virq, IRQ_NOREQUEST);
  281. return 0;
  282. }
  283. EXPORT_SYMBOL_GPL(irq_domain_associate);
  284. void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base,
  285. irq_hw_number_t hwirq_base, int count)
  286. {
  287. int i;
  288. pr_debug("%s(%s, irqbase=%i, hwbase=%i, count=%i)\n", __func__,
  289. of_node_full_name(domain->of_node), irq_base, (int)hwirq_base, count);
  290. for (i = 0; i < count; i++) {
  291. irq_domain_associate(domain, irq_base + i, hwirq_base + i);
  292. }
  293. }
  294. EXPORT_SYMBOL_GPL(irq_domain_associate_many);
  295. /**
  296. * irq_create_direct_mapping() - Allocate an irq for direct mapping
  297. * @domain: domain to allocate the irq for or NULL for default domain
  298. *
  299. * This routine is used for irq controllers which can choose the hardware
  300. * interrupt numbers they generate. In such a case it's simplest to use
  301. * the linux irq as the hardware interrupt number. It still uses the linear
  302. * or radix tree to store the mapping, but the irq controller can optimize
  303. * the revmap path by using the hwirq directly.
  304. */
  305. unsigned int irq_create_direct_mapping(struct irq_domain *domain)
  306. {
  307. unsigned int virq;
  308. if (domain == NULL)
  309. domain = irq_default_domain;
  310. virq = irq_alloc_desc_from(1, of_node_to_nid(domain->of_node));
  311. if (!virq) {
  312. pr_debug("create_direct virq allocation failed\n");
  313. return 0;
  314. }
  315. if (virq >= domain->revmap_direct_max_irq) {
  316. pr_err("ERROR: no free irqs available below %i maximum\n",
  317. domain->revmap_direct_max_irq);
  318. irq_free_desc(virq);
  319. return 0;
  320. }
  321. pr_debug("create_direct obtained virq %d\n", virq);
  322. if (irq_domain_associate(domain, virq, virq)) {
  323. irq_free_desc(virq);
  324. return 0;
  325. }
  326. return virq;
  327. }
  328. EXPORT_SYMBOL_GPL(irq_create_direct_mapping);
  329. /**
  330. * irq_create_mapping() - Map a hardware interrupt into linux irq space
  331. * @domain: domain owning this hardware interrupt or NULL for default domain
  332. * @hwirq: hardware irq number in that domain space
  333. *
  334. * Only one mapping per hardware interrupt is permitted. Returns a linux
  335. * irq number.
  336. * If the sense/trigger is to be specified, set_irq_type() should be called
  337. * on the number returned from that call.
  338. */
  339. unsigned int irq_create_mapping(struct irq_domain *domain,
  340. irq_hw_number_t hwirq)
  341. {
  342. int virq;
  343. pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
  344. /* Look for default domain if nececssary */
  345. if (domain == NULL)
  346. domain = irq_default_domain;
  347. if (domain == NULL) {
  348. WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq);
  349. return 0;
  350. }
  351. pr_debug("-> using domain @%p\n", domain);
  352. /* Check if mapping already exists */
  353. virq = irq_find_mapping(domain, hwirq);
  354. if (virq) {
  355. pr_debug("-> existing mapping on virq %d\n", virq);
  356. return virq;
  357. }
  358. /* Allocate a virtual interrupt number */
  359. virq = irq_domain_alloc_descs(-1, 1, hwirq,
  360. of_node_to_nid(domain->of_node));
  361. if (virq <= 0) {
  362. pr_debug("-> virq allocation failed\n");
  363. return 0;
  364. }
  365. if (irq_domain_associate(domain, virq, hwirq)) {
  366. irq_free_desc(virq);
  367. return 0;
  368. }
  369. pr_debug("irq %lu on domain %s mapped to virtual irq %u\n",
  370. hwirq, of_node_full_name(domain->of_node), virq);
  371. return virq;
  372. }
  373. EXPORT_SYMBOL_GPL(irq_create_mapping);
  374. /**
  375. * irq_create_strict_mappings() - Map a range of hw irqs to fixed linux irqs
  376. * @domain: domain owning the interrupt range
  377. * @irq_base: beginning of linux IRQ range
  378. * @hwirq_base: beginning of hardware IRQ range
  379. * @count: Number of interrupts to map
  380. *
  381. * This routine is used for allocating and mapping a range of hardware
  382. * irqs to linux irqs where the linux irq numbers are at pre-defined
  383. * locations. For use by controllers that already have static mappings
  384. * to insert in to the domain.
  385. *
  386. * Non-linear users can use irq_create_identity_mapping() for IRQ-at-a-time
  387. * domain insertion.
  388. *
  389. * 0 is returned upon success, while any failure to establish a static
  390. * mapping is treated as an error.
  391. */
  392. int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base,
  393. irq_hw_number_t hwirq_base, int count)
  394. {
  395. int ret;
  396. ret = irq_alloc_descs(irq_base, irq_base, count,
  397. of_node_to_nid(domain->of_node));
  398. if (unlikely(ret < 0))
  399. return ret;
  400. irq_domain_associate_many(domain, irq_base, hwirq_base, count);
  401. return 0;
  402. }
  403. EXPORT_SYMBOL_GPL(irq_create_strict_mappings);
  404. unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
  405. {
  406. struct irq_domain *domain;
  407. irq_hw_number_t hwirq;
  408. unsigned int type = IRQ_TYPE_NONE;
  409. int virq;
  410. domain = irq_data->np ? irq_find_host(irq_data->np) : irq_default_domain;
  411. if (!domain) {
  412. pr_warn("no irq domain found for %s !\n",
  413. of_node_full_name(irq_data->np));
  414. return 0;
  415. }
  416. /* If domain has no translation, then we assume interrupt line */
  417. if (domain->ops->xlate == NULL)
  418. hwirq = irq_data->args[0];
  419. else {
  420. if (domain->ops->xlate(domain, irq_data->np, irq_data->args,
  421. irq_data->args_count, &hwirq, &type))
  422. return 0;
  423. }
  424. if (irq_domain_is_hierarchy(domain)) {
  425. /*
  426. * If we've already configured this interrupt,
  427. * don't do it again, or hell will break loose.
  428. */
  429. virq = irq_find_mapping(domain, hwirq);
  430. if (virq)
  431. return virq;
  432. virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, irq_data);
  433. if (virq <= 0)
  434. return 0;
  435. } else {
  436. /* Create mapping */
  437. virq = irq_create_mapping(domain, hwirq);
  438. if (!virq)
  439. return virq;
  440. }
  441. /* Set type if specified and different than the current one */
  442. if (type != IRQ_TYPE_NONE &&
  443. type != irq_get_trigger_type(virq))
  444. irq_set_irq_type(virq, type);
  445. return virq;
  446. }
  447. EXPORT_SYMBOL_GPL(irq_create_of_mapping);
  448. /**
  449. * irq_dispose_mapping() - Unmap an interrupt
  450. * @virq: linux irq number of the interrupt to unmap
  451. */
  452. void irq_dispose_mapping(unsigned int virq)
  453. {
  454. struct irq_data *irq_data = irq_get_irq_data(virq);
  455. struct irq_domain *domain;
  456. if (!virq || !irq_data)
  457. return;
  458. domain = irq_data->domain;
  459. if (WARN_ON(domain == NULL))
  460. return;
  461. irq_domain_disassociate(domain, virq);
  462. irq_free_desc(virq);
  463. }
  464. EXPORT_SYMBOL_GPL(irq_dispose_mapping);
  465. /**
  466. * irq_find_mapping() - Find a linux irq from an hw irq number.
  467. * @domain: domain owning this hardware interrupt
  468. * @hwirq: hardware irq number in that domain space
  469. */
  470. unsigned int irq_find_mapping(struct irq_domain *domain,
  471. irq_hw_number_t hwirq)
  472. {
  473. struct irq_data *data;
  474. /* Look for default domain if nececssary */
  475. if (domain == NULL)
  476. domain = irq_default_domain;
  477. if (domain == NULL)
  478. return 0;
  479. if (hwirq < domain->revmap_direct_max_irq) {
  480. data = irq_domain_get_irq_data(domain, hwirq);
  481. if (data && data->hwirq == hwirq)
  482. return hwirq;
  483. }
  484. /* Check if the hwirq is in the linear revmap. */
  485. if (hwirq < domain->revmap_size)
  486. return domain->linear_revmap[hwirq];
  487. rcu_read_lock();
  488. data = radix_tree_lookup(&domain->revmap_tree, hwirq);
  489. rcu_read_unlock();
  490. return data ? data->irq : 0;
  491. }
  492. EXPORT_SYMBOL_GPL(irq_find_mapping);
  493. #ifdef CONFIG_IRQ_DOMAIN_DEBUG
  494. static int virq_debug_show(struct seq_file *m, void *private)
  495. {
  496. unsigned long flags;
  497. struct irq_desc *desc;
  498. struct irq_domain *domain;
  499. struct radix_tree_iter iter;
  500. void *data, **slot;
  501. int i;
  502. seq_printf(m, " %-16s %-6s %-10s %-10s %s\n",
  503. "name", "mapped", "linear-max", "direct-max", "devtree-node");
  504. mutex_lock(&irq_domain_mutex);
  505. list_for_each_entry(domain, &irq_domain_list, link) {
  506. int count = 0;
  507. radix_tree_for_each_slot(slot, &domain->revmap_tree, &iter, 0)
  508. count++;
  509. seq_printf(m, "%c%-16s %6u %10u %10u %s\n",
  510. domain == irq_default_domain ? '*' : ' ', domain->name,
  511. domain->revmap_size + count, domain->revmap_size,
  512. domain->revmap_direct_max_irq,
  513. domain->of_node ? of_node_full_name(domain->of_node) : "");
  514. }
  515. mutex_unlock(&irq_domain_mutex);
  516. seq_printf(m, "%-5s %-7s %-15s %-*s %6s %-14s %s\n", "irq", "hwirq",
  517. "chip name", (int)(2 * sizeof(void *) + 2), "chip data",
  518. "active", "type", "domain");
  519. for (i = 1; i < nr_irqs; i++) {
  520. desc = irq_to_desc(i);
  521. if (!desc)
  522. continue;
  523. raw_spin_lock_irqsave(&desc->lock, flags);
  524. domain = desc->irq_data.domain;
  525. if (domain) {
  526. struct irq_chip *chip;
  527. int hwirq = desc->irq_data.hwirq;
  528. bool direct;
  529. seq_printf(m, "%5d ", i);
  530. seq_printf(m, "0x%05x ", hwirq);
  531. chip = irq_desc_get_chip(desc);
  532. seq_printf(m, "%-15s ", (chip && chip->name) ? chip->name : "none");
  533. data = irq_desc_get_chip_data(desc);
  534. seq_printf(m, data ? "0x%p " : " %p ", data);
  535. seq_printf(m, " %c ", (desc->action && desc->action->handler) ? '*' : ' ');
  536. direct = (i == hwirq) && (i < domain->revmap_direct_max_irq);
  537. seq_printf(m, "%6s%-8s ",
  538. (hwirq < domain->revmap_size) ? "LINEAR" : "RADIX",
  539. direct ? "(DIRECT)" : "");
  540. seq_printf(m, "%s\n", desc->irq_data.domain->name);
  541. }
  542. raw_spin_unlock_irqrestore(&desc->lock, flags);
  543. }
  544. return 0;
  545. }
  546. static int virq_debug_open(struct inode *inode, struct file *file)
  547. {
  548. return single_open(file, virq_debug_show, inode->i_private);
  549. }
  550. static const struct file_operations virq_debug_fops = {
  551. .open = virq_debug_open,
  552. .read = seq_read,
  553. .llseek = seq_lseek,
  554. .release = single_release,
  555. };
  556. static int __init irq_debugfs_init(void)
  557. {
  558. if (debugfs_create_file("irq_domain_mapping", S_IRUGO, NULL,
  559. NULL, &virq_debug_fops) == NULL)
  560. return -ENOMEM;
  561. return 0;
  562. }
  563. __initcall(irq_debugfs_init);
  564. #endif /* CONFIG_IRQ_DOMAIN_DEBUG */
  565. /**
  566. * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings
  567. *
  568. * Device Tree IRQ specifier translation function which works with one cell
  569. * bindings where the cell value maps directly to the hwirq number.
  570. */
  571. int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
  572. const u32 *intspec, unsigned int intsize,
  573. unsigned long *out_hwirq, unsigned int *out_type)
  574. {
  575. if (WARN_ON(intsize < 1))
  576. return -EINVAL;
  577. *out_hwirq = intspec[0];
  578. *out_type = IRQ_TYPE_NONE;
  579. return 0;
  580. }
  581. EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell);
  582. /**
  583. * irq_domain_xlate_twocell() - Generic xlate for direct two cell bindings
  584. *
  585. * Device Tree IRQ specifier translation function which works with two cell
  586. * bindings where the cell values map directly to the hwirq number
  587. * and linux irq flags.
  588. */
  589. int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
  590. const u32 *intspec, unsigned int intsize,
  591. irq_hw_number_t *out_hwirq, unsigned int *out_type)
  592. {
  593. if (WARN_ON(intsize < 2))
  594. return -EINVAL;
  595. *out_hwirq = intspec[0];
  596. *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK;
  597. return 0;
  598. }
  599. EXPORT_SYMBOL_GPL(irq_domain_xlate_twocell);
  600. /**
  601. * irq_domain_xlate_onetwocell() - Generic xlate for one or two cell bindings
  602. *
  603. * Device Tree IRQ specifier translation function which works with either one
  604. * or two cell bindings where the cell values map directly to the hwirq number
  605. * and linux irq flags.
  606. *
  607. * Note: don't use this function unless your interrupt controller explicitly
  608. * supports both one and two cell bindings. For the majority of controllers
  609. * the _onecell() or _twocell() variants above should be used.
  610. */
  611. int irq_domain_xlate_onetwocell(struct irq_domain *d,
  612. struct device_node *ctrlr,
  613. const u32 *intspec, unsigned int intsize,
  614. unsigned long *out_hwirq, unsigned int *out_type)
  615. {
  616. if (WARN_ON(intsize < 1))
  617. return -EINVAL;
  618. *out_hwirq = intspec[0];
  619. *out_type = (intsize > 1) ? intspec[1] : IRQ_TYPE_NONE;
  620. return 0;
  621. }
  622. EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell);
  623. const struct irq_domain_ops irq_domain_simple_ops = {
  624. .xlate = irq_domain_xlate_onetwocell,
  625. };
  626. EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
  627. static int irq_domain_alloc_descs(int virq, unsigned int cnt,
  628. irq_hw_number_t hwirq, int node)
  629. {
  630. unsigned int hint;
  631. if (virq >= 0) {
  632. virq = irq_alloc_descs(virq, virq, cnt, node);
  633. } else {
  634. hint = hwirq % nr_irqs;
  635. if (hint == 0)
  636. hint++;
  637. virq = irq_alloc_descs_from(hint, cnt, node);
  638. if (virq <= 0 && hint > 1)
  639. virq = irq_alloc_descs_from(1, cnt, node);
  640. }
  641. return virq;
  642. }
  643. #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
  644. /**
  645. * irq_domain_add_hierarchy - Add a irqdomain into the hierarchy
  646. * @parent: Parent irq domain to associate with the new domain
  647. * @flags: Irq domain flags associated to the domain
  648. * @size: Size of the domain. See below
  649. * @node: Optional device-tree node of the interrupt controller
  650. * @ops: Pointer to the interrupt domain callbacks
  651. * @host_data: Controller private data pointer
  652. *
  653. * If @size is 0 a tree domain is created, otherwise a linear domain.
  654. *
  655. * If successful the parent is associated to the new domain and the
  656. * domain flags are set.
  657. * Returns pointer to IRQ domain, or NULL on failure.
  658. */
  659. struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
  660. unsigned int flags,
  661. unsigned int size,
  662. struct device_node *node,
  663. const struct irq_domain_ops *ops,
  664. void *host_data)
  665. {
  666. struct irq_domain *domain;
  667. if (size)
  668. domain = irq_domain_add_linear(node, size, ops, host_data);
  669. else
  670. domain = irq_domain_add_tree(node, ops, host_data);
  671. if (domain) {
  672. domain->parent = parent;
  673. domain->flags |= flags;
  674. }
  675. return domain;
  676. }
  677. static void irq_domain_insert_irq(int virq)
  678. {
  679. struct irq_data *data;
  680. for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
  681. struct irq_domain *domain = data->domain;
  682. irq_hw_number_t hwirq = data->hwirq;
  683. if (hwirq < domain->revmap_size) {
  684. domain->linear_revmap[hwirq] = virq;
  685. } else {
  686. mutex_lock(&revmap_trees_mutex);
  687. radix_tree_insert(&domain->revmap_tree, hwirq, data);
  688. mutex_unlock(&revmap_trees_mutex);
  689. }
  690. /* If not already assigned, give the domain the chip's name */
  691. if (!domain->name && data->chip)
  692. domain->name = data->chip->name;
  693. }
  694. irq_clear_status_flags(virq, IRQ_NOREQUEST);
  695. }
  696. static void irq_domain_remove_irq(int virq)
  697. {
  698. struct irq_data *data;
  699. irq_set_status_flags(virq, IRQ_NOREQUEST);
  700. irq_set_chip_and_handler(virq, NULL, NULL);
  701. synchronize_irq(virq);
  702. smp_mb();
  703. for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
  704. struct irq_domain *domain = data->domain;
  705. irq_hw_number_t hwirq = data->hwirq;
  706. if (hwirq < domain->revmap_size) {
  707. domain->linear_revmap[hwirq] = 0;
  708. } else {
  709. mutex_lock(&revmap_trees_mutex);
  710. radix_tree_delete(&domain->revmap_tree, hwirq);
  711. mutex_unlock(&revmap_trees_mutex);
  712. }
  713. }
  714. }
  715. static struct irq_data *irq_domain_insert_irq_data(struct irq_domain *domain,
  716. struct irq_data *child)
  717. {
  718. struct irq_data *irq_data;
  719. irq_data = kzalloc_node(sizeof(*irq_data), GFP_KERNEL,
  720. irq_data_get_node(child));
  721. if (irq_data) {
  722. child->parent_data = irq_data;
  723. irq_data->irq = child->irq;
  724. irq_data->common = child->common;
  725. irq_data->node = child->node;
  726. irq_data->domain = domain;
  727. }
  728. return irq_data;
  729. }
  730. static void irq_domain_free_irq_data(unsigned int virq, unsigned int nr_irqs)
  731. {
  732. struct irq_data *irq_data, *tmp;
  733. int i;
  734. for (i = 0; i < nr_irqs; i++) {
  735. irq_data = irq_get_irq_data(virq + i);
  736. tmp = irq_data->parent_data;
  737. irq_data->parent_data = NULL;
  738. irq_data->domain = NULL;
  739. while (tmp) {
  740. irq_data = tmp;
  741. tmp = tmp->parent_data;
  742. kfree(irq_data);
  743. }
  744. }
  745. }
  746. static int irq_domain_alloc_irq_data(struct irq_domain *domain,
  747. unsigned int virq, unsigned int nr_irqs)
  748. {
  749. struct irq_data *irq_data;
  750. struct irq_domain *parent;
  751. int i;
  752. /* The outermost irq_data is embedded in struct irq_desc */
  753. for (i = 0; i < nr_irqs; i++) {
  754. irq_data = irq_get_irq_data(virq + i);
  755. irq_data->domain = domain;
  756. for (parent = domain->parent; parent; parent = parent->parent) {
  757. irq_data = irq_domain_insert_irq_data(parent, irq_data);
  758. if (!irq_data) {
  759. irq_domain_free_irq_data(virq, i + 1);
  760. return -ENOMEM;
  761. }
  762. }
  763. }
  764. return 0;
  765. }
  766. /**
  767. * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
  768. * @domain: domain to match
  769. * @virq: IRQ number to get irq_data
  770. */
  771. struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
  772. unsigned int virq)
  773. {
  774. struct irq_data *irq_data;
  775. for (irq_data = irq_get_irq_data(virq); irq_data;
  776. irq_data = irq_data->parent_data)
  777. if (irq_data->domain == domain)
  778. return irq_data;
  779. return NULL;
  780. }
  781. /**
  782. * irq_domain_set_hwirq_and_chip - Set hwirq and irqchip of @virq at @domain
  783. * @domain: Interrupt domain to match
  784. * @virq: IRQ number
  785. * @hwirq: The hwirq number
  786. * @chip: The associated interrupt chip
  787. * @chip_data: The associated chip data
  788. */
  789. int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
  790. irq_hw_number_t hwirq, struct irq_chip *chip,
  791. void *chip_data)
  792. {
  793. struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
  794. if (!irq_data)
  795. return -ENOENT;
  796. irq_data->hwirq = hwirq;
  797. irq_data->chip = chip ? chip : &no_irq_chip;
  798. irq_data->chip_data = chip_data;
  799. return 0;
  800. }
  801. /**
  802. * irq_domain_set_info - Set the complete data for a @virq in @domain
  803. * @domain: Interrupt domain to match
  804. * @virq: IRQ number
  805. * @hwirq: The hardware interrupt number
  806. * @chip: The associated interrupt chip
  807. * @chip_data: The associated interrupt chip data
  808. * @handler: The interrupt flow handler
  809. * @handler_data: The interrupt flow handler data
  810. * @handler_name: The interrupt handler name
  811. */
  812. void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
  813. irq_hw_number_t hwirq, struct irq_chip *chip,
  814. void *chip_data, irq_flow_handler_t handler,
  815. void *handler_data, const char *handler_name)
  816. {
  817. irq_domain_set_hwirq_and_chip(domain, virq, hwirq, chip, chip_data);
  818. __irq_set_handler(virq, handler, 0, handler_name);
  819. irq_set_handler_data(virq, handler_data);
  820. }
  821. /**
  822. * irq_domain_reset_irq_data - Clear hwirq, chip and chip_data in @irq_data
  823. * @irq_data: The pointer to irq_data
  824. */
  825. void irq_domain_reset_irq_data(struct irq_data *irq_data)
  826. {
  827. irq_data->hwirq = 0;
  828. irq_data->chip = &no_irq_chip;
  829. irq_data->chip_data = NULL;
  830. }
  831. /**
  832. * irq_domain_free_irqs_common - Clear irq_data and free the parent
  833. * @domain: Interrupt domain to match
  834. * @virq: IRQ number to start with
  835. * @nr_irqs: The number of irqs to free
  836. */
  837. void irq_domain_free_irqs_common(struct irq_domain *domain, unsigned int virq,
  838. unsigned int nr_irqs)
  839. {
  840. struct irq_data *irq_data;
  841. int i;
  842. for (i = 0; i < nr_irqs; i++) {
  843. irq_data = irq_domain_get_irq_data(domain, virq + i);
  844. if (irq_data)
  845. irq_domain_reset_irq_data(irq_data);
  846. }
  847. irq_domain_free_irqs_parent(domain, virq, nr_irqs);
  848. }
  849. /**
  850. * irq_domain_free_irqs_top - Clear handler and handler data, clear irqdata and free parent
  851. * @domain: Interrupt domain to match
  852. * @virq: IRQ number to start with
  853. * @nr_irqs: The number of irqs to free
  854. */
  855. void irq_domain_free_irqs_top(struct irq_domain *domain, unsigned int virq,
  856. unsigned int nr_irqs)
  857. {
  858. int i;
  859. for (i = 0; i < nr_irqs; i++) {
  860. irq_set_handler_data(virq + i, NULL);
  861. irq_set_handler(virq + i, NULL);
  862. }
  863. irq_domain_free_irqs_common(domain, virq, nr_irqs);
  864. }
  865. static bool irq_domain_is_auto_recursive(struct irq_domain *domain)
  866. {
  867. return domain->flags & IRQ_DOMAIN_FLAG_AUTO_RECURSIVE;
  868. }
  869. static void irq_domain_free_irqs_recursive(struct irq_domain *domain,
  870. unsigned int irq_base,
  871. unsigned int nr_irqs)
  872. {
  873. domain->ops->free(domain, irq_base, nr_irqs);
  874. if (irq_domain_is_auto_recursive(domain)) {
  875. BUG_ON(!domain->parent);
  876. irq_domain_free_irqs_recursive(domain->parent, irq_base,
  877. nr_irqs);
  878. }
  879. }
  880. static int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
  881. unsigned int irq_base,
  882. unsigned int nr_irqs, void *arg)
  883. {
  884. int ret = 0;
  885. struct irq_domain *parent = domain->parent;
  886. bool recursive = irq_domain_is_auto_recursive(domain);
  887. BUG_ON(recursive && !parent);
  888. if (recursive)
  889. ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
  890. nr_irqs, arg);
  891. if (ret >= 0)
  892. ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
  893. if (ret < 0 && recursive)
  894. irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
  895. return ret;
  896. }
  897. /**
  898. * __irq_domain_alloc_irqs - Allocate IRQs from domain
  899. * @domain: domain to allocate from
  900. * @irq_base: allocate specified IRQ nubmer if irq_base >= 0
  901. * @nr_irqs: number of IRQs to allocate
  902. * @node: NUMA node id for memory allocation
  903. * @arg: domain specific argument
  904. * @realloc: IRQ descriptors have already been allocated if true
  905. *
  906. * Allocate IRQ numbers and initialized all data structures to support
  907. * hierarchy IRQ domains.
  908. * Parameter @realloc is mainly to support legacy IRQs.
  909. * Returns error code or allocated IRQ number
  910. *
  911. * The whole process to setup an IRQ has been split into two steps.
  912. * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
  913. * descriptor and required hardware resources. The second step,
  914. * irq_domain_activate_irq(), is to program hardwares with preallocated
  915. * resources. In this way, it's easier to rollback when failing to
  916. * allocate resources.
  917. */
  918. int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
  919. unsigned int nr_irqs, int node, void *arg,
  920. bool realloc)
  921. {
  922. int i, ret, virq;
  923. if (domain == NULL) {
  924. domain = irq_default_domain;
  925. if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
  926. return -EINVAL;
  927. }
  928. if (!domain->ops->alloc) {
  929. pr_debug("domain->ops->alloc() is NULL\n");
  930. return -ENOSYS;
  931. }
  932. if (realloc && irq_base >= 0) {
  933. virq = irq_base;
  934. } else {
  935. virq = irq_domain_alloc_descs(irq_base, nr_irqs, 0, node);
  936. if (virq < 0) {
  937. pr_debug("cannot allocate IRQ(base %d, count %d)\n",
  938. irq_base, nr_irqs);
  939. return virq;
  940. }
  941. }
  942. if (irq_domain_alloc_irq_data(domain, virq, nr_irqs)) {
  943. pr_debug("cannot allocate memory for IRQ%d\n", virq);
  944. ret = -ENOMEM;
  945. goto out_free_desc;
  946. }
  947. mutex_lock(&irq_domain_mutex);
  948. ret = irq_domain_alloc_irqs_recursive(domain, virq, nr_irqs, arg);
  949. if (ret < 0) {
  950. mutex_unlock(&irq_domain_mutex);
  951. goto out_free_irq_data;
  952. }
  953. for (i = 0; i < nr_irqs; i++)
  954. irq_domain_insert_irq(virq + i);
  955. mutex_unlock(&irq_domain_mutex);
  956. return virq;
  957. out_free_irq_data:
  958. irq_domain_free_irq_data(virq, nr_irqs);
  959. out_free_desc:
  960. irq_free_descs(virq, nr_irqs);
  961. return ret;
  962. }
  963. /**
  964. * irq_domain_free_irqs - Free IRQ number and associated data structures
  965. * @virq: base IRQ number
  966. * @nr_irqs: number of IRQs to free
  967. */
  968. void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs)
  969. {
  970. struct irq_data *data = irq_get_irq_data(virq);
  971. int i;
  972. if (WARN(!data || !data->domain || !data->domain->ops->free,
  973. "NULL pointer, cannot free irq\n"))
  974. return;
  975. mutex_lock(&irq_domain_mutex);
  976. for (i = 0; i < nr_irqs; i++)
  977. irq_domain_remove_irq(virq + i);
  978. irq_domain_free_irqs_recursive(data->domain, virq, nr_irqs);
  979. mutex_unlock(&irq_domain_mutex);
  980. irq_domain_free_irq_data(virq, nr_irqs);
  981. irq_free_descs(virq, nr_irqs);
  982. }
  983. /**
  984. * irq_domain_alloc_irqs_parent - Allocate interrupts from parent domain
  985. * @irq_base: Base IRQ number
  986. * @nr_irqs: Number of IRQs to allocate
  987. * @arg: Allocation data (arch/domain specific)
  988. *
  989. * Check whether the domain has been setup recursive. If not allocate
  990. * through the parent domain.
  991. */
  992. int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
  993. unsigned int irq_base, unsigned int nr_irqs,
  994. void *arg)
  995. {
  996. /* irq_domain_alloc_irqs_recursive() has called parent's alloc() */
  997. if (irq_domain_is_auto_recursive(domain))
  998. return 0;
  999. domain = domain->parent;
  1000. if (domain)
  1001. return irq_domain_alloc_irqs_recursive(domain, irq_base,
  1002. nr_irqs, arg);
  1003. return -ENOSYS;
  1004. }
  1005. /**
  1006. * irq_domain_free_irqs_parent - Free interrupts from parent domain
  1007. * @irq_base: Base IRQ number
  1008. * @nr_irqs: Number of IRQs to free
  1009. *
  1010. * Check whether the domain has been setup recursive. If not free
  1011. * through the parent domain.
  1012. */
  1013. void irq_domain_free_irqs_parent(struct irq_domain *domain,
  1014. unsigned int irq_base, unsigned int nr_irqs)
  1015. {
  1016. /* irq_domain_free_irqs_recursive() will call parent's free */
  1017. if (!irq_domain_is_auto_recursive(domain) && domain->parent)
  1018. irq_domain_free_irqs_recursive(domain->parent, irq_base,
  1019. nr_irqs);
  1020. }
  1021. /**
  1022. * irq_domain_activate_irq - Call domain_ops->activate recursively to activate
  1023. * interrupt
  1024. * @irq_data: outermost irq_data associated with interrupt
  1025. *
  1026. * This is the second step to call domain_ops->activate to program interrupt
  1027. * controllers, so the interrupt could actually get delivered.
  1028. */
  1029. void irq_domain_activate_irq(struct irq_data *irq_data)
  1030. {
  1031. if (irq_data && irq_data->domain) {
  1032. struct irq_domain *domain = irq_data->domain;
  1033. if (irq_data->parent_data)
  1034. irq_domain_activate_irq(irq_data->parent_data);
  1035. if (domain->ops->activate)
  1036. domain->ops->activate(domain, irq_data);
  1037. }
  1038. }
  1039. /**
  1040. * irq_domain_deactivate_irq - Call domain_ops->deactivate recursively to
  1041. * deactivate interrupt
  1042. * @irq_data: outermost irq_data associated with interrupt
  1043. *
  1044. * It calls domain_ops->deactivate to program interrupt controllers to disable
  1045. * interrupt delivery.
  1046. */
  1047. void irq_domain_deactivate_irq(struct irq_data *irq_data)
  1048. {
  1049. if (irq_data && irq_data->domain) {
  1050. struct irq_domain *domain = irq_data->domain;
  1051. if (domain->ops->deactivate)
  1052. domain->ops->deactivate(domain, irq_data);
  1053. if (irq_data->parent_data)
  1054. irq_domain_deactivate_irq(irq_data->parent_data);
  1055. }
  1056. }
  1057. static void irq_domain_check_hierarchy(struct irq_domain *domain)
  1058. {
  1059. /* Hierarchy irq_domains must implement callback alloc() */
  1060. if (domain->ops->alloc)
  1061. domain->flags |= IRQ_DOMAIN_FLAG_HIERARCHY;
  1062. }
  1063. #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
  1064. /**
  1065. * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
  1066. * @domain: domain to match
  1067. * @virq: IRQ number to get irq_data
  1068. */
  1069. struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
  1070. unsigned int virq)
  1071. {
  1072. struct irq_data *irq_data = irq_get_irq_data(virq);
  1073. return (irq_data && irq_data->domain == domain) ? irq_data : NULL;
  1074. }
  1075. /**
  1076. * irq_domain_set_info - Set the complete data for a @virq in @domain
  1077. * @domain: Interrupt domain to match
  1078. * @virq: IRQ number
  1079. * @hwirq: The hardware interrupt number
  1080. * @chip: The associated interrupt chip
  1081. * @chip_data: The associated interrupt chip data
  1082. * @handler: The interrupt flow handler
  1083. * @handler_data: The interrupt flow handler data
  1084. * @handler_name: The interrupt handler name
  1085. */
  1086. void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
  1087. irq_hw_number_t hwirq, struct irq_chip *chip,
  1088. void *chip_data, irq_flow_handler_t handler,
  1089. void *handler_data, const char *handler_name)
  1090. {
  1091. irq_set_chip_and_handler_name(virq, chip, handler, handler_name);
  1092. irq_set_chip_data(virq, chip_data);
  1093. irq_set_handler_data(virq, handler_data);
  1094. }
  1095. static void irq_domain_check_hierarchy(struct irq_domain *domain)
  1096. {
  1097. }
  1098. #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */