irqdomain.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  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, child->node);
  720. if (irq_data) {
  721. child->parent_data = irq_data;
  722. irq_data->irq = child->irq;
  723. irq_data->node = child->node;
  724. irq_data->domain = domain;
  725. }
  726. return irq_data;
  727. }
  728. static void irq_domain_free_irq_data(unsigned int virq, unsigned int nr_irqs)
  729. {
  730. struct irq_data *irq_data, *tmp;
  731. int i;
  732. for (i = 0; i < nr_irqs; i++) {
  733. irq_data = irq_get_irq_data(virq + i);
  734. tmp = irq_data->parent_data;
  735. irq_data->parent_data = NULL;
  736. irq_data->domain = NULL;
  737. while (tmp) {
  738. irq_data = tmp;
  739. tmp = tmp->parent_data;
  740. kfree(irq_data);
  741. }
  742. }
  743. }
  744. static int irq_domain_alloc_irq_data(struct irq_domain *domain,
  745. unsigned int virq, unsigned int nr_irqs)
  746. {
  747. struct irq_data *irq_data;
  748. struct irq_domain *parent;
  749. int i;
  750. /* The outermost irq_data is embedded in struct irq_desc */
  751. for (i = 0; i < nr_irqs; i++) {
  752. irq_data = irq_get_irq_data(virq + i);
  753. irq_data->domain = domain;
  754. for (parent = domain->parent; parent; parent = parent->parent) {
  755. irq_data = irq_domain_insert_irq_data(parent, irq_data);
  756. if (!irq_data) {
  757. irq_domain_free_irq_data(virq, i + 1);
  758. return -ENOMEM;
  759. }
  760. }
  761. }
  762. return 0;
  763. }
  764. /**
  765. * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
  766. * @domain: domain to match
  767. * @virq: IRQ number to get irq_data
  768. */
  769. struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
  770. unsigned int virq)
  771. {
  772. struct irq_data *irq_data;
  773. for (irq_data = irq_get_irq_data(virq); irq_data;
  774. irq_data = irq_data->parent_data)
  775. if (irq_data->domain == domain)
  776. return irq_data;
  777. return NULL;
  778. }
  779. /**
  780. * irq_domain_set_hwirq_and_chip - Set hwirq and irqchip of @virq at @domain
  781. * @domain: Interrupt domain to match
  782. * @virq: IRQ number
  783. * @hwirq: The hwirq number
  784. * @chip: The associated interrupt chip
  785. * @chip_data: The associated chip data
  786. */
  787. int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
  788. irq_hw_number_t hwirq, struct irq_chip *chip,
  789. void *chip_data)
  790. {
  791. struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
  792. if (!irq_data)
  793. return -ENOENT;
  794. irq_data->hwirq = hwirq;
  795. irq_data->chip = chip ? chip : &no_irq_chip;
  796. irq_data->chip_data = chip_data;
  797. return 0;
  798. }
  799. /**
  800. * irq_domain_set_info - Set the complete data for a @virq in @domain
  801. * @domain: Interrupt domain to match
  802. * @virq: IRQ number
  803. * @hwirq: The hardware interrupt number
  804. * @chip: The associated interrupt chip
  805. * @chip_data: The associated interrupt chip data
  806. * @handler: The interrupt flow handler
  807. * @handler_data: The interrupt flow handler data
  808. * @handler_name: The interrupt handler name
  809. */
  810. void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
  811. irq_hw_number_t hwirq, struct irq_chip *chip,
  812. void *chip_data, irq_flow_handler_t handler,
  813. void *handler_data, const char *handler_name)
  814. {
  815. irq_domain_set_hwirq_and_chip(domain, virq, hwirq, chip, chip_data);
  816. __irq_set_handler(virq, handler, 0, handler_name);
  817. irq_set_handler_data(virq, handler_data);
  818. }
  819. /**
  820. * irq_domain_reset_irq_data - Clear hwirq, chip and chip_data in @irq_data
  821. * @irq_data: The pointer to irq_data
  822. */
  823. void irq_domain_reset_irq_data(struct irq_data *irq_data)
  824. {
  825. irq_data->hwirq = 0;
  826. irq_data->chip = &no_irq_chip;
  827. irq_data->chip_data = NULL;
  828. }
  829. /**
  830. * irq_domain_free_irqs_common - Clear irq_data and free the parent
  831. * @domain: Interrupt domain to match
  832. * @virq: IRQ number to start with
  833. * @nr_irqs: The number of irqs to free
  834. */
  835. void irq_domain_free_irqs_common(struct irq_domain *domain, unsigned int virq,
  836. unsigned int nr_irqs)
  837. {
  838. struct irq_data *irq_data;
  839. int i;
  840. for (i = 0; i < nr_irqs; i++) {
  841. irq_data = irq_domain_get_irq_data(domain, virq + i);
  842. if (irq_data)
  843. irq_domain_reset_irq_data(irq_data);
  844. }
  845. irq_domain_free_irqs_parent(domain, virq, nr_irqs);
  846. }
  847. /**
  848. * irq_domain_free_irqs_top - Clear handler and handler data, clear irqdata and free parent
  849. * @domain: Interrupt domain to match
  850. * @virq: IRQ number to start with
  851. * @nr_irqs: The number of irqs to free
  852. */
  853. void irq_domain_free_irqs_top(struct irq_domain *domain, unsigned int virq,
  854. unsigned int nr_irqs)
  855. {
  856. int i;
  857. for (i = 0; i < nr_irqs; i++) {
  858. irq_set_handler_data(virq + i, NULL);
  859. irq_set_handler(virq + i, NULL);
  860. }
  861. irq_domain_free_irqs_common(domain, virq, nr_irqs);
  862. }
  863. static bool irq_domain_is_auto_recursive(struct irq_domain *domain)
  864. {
  865. return domain->flags & IRQ_DOMAIN_FLAG_AUTO_RECURSIVE;
  866. }
  867. static void irq_domain_free_irqs_recursive(struct irq_domain *domain,
  868. unsigned int irq_base,
  869. unsigned int nr_irqs)
  870. {
  871. domain->ops->free(domain, irq_base, nr_irqs);
  872. if (irq_domain_is_auto_recursive(domain)) {
  873. BUG_ON(!domain->parent);
  874. irq_domain_free_irqs_recursive(domain->parent, irq_base,
  875. nr_irqs);
  876. }
  877. }
  878. static int irq_domain_alloc_irqs_recursive(struct irq_domain *domain,
  879. unsigned int irq_base,
  880. unsigned int nr_irqs, void *arg)
  881. {
  882. int ret = 0;
  883. struct irq_domain *parent = domain->parent;
  884. bool recursive = irq_domain_is_auto_recursive(domain);
  885. BUG_ON(recursive && !parent);
  886. if (recursive)
  887. ret = irq_domain_alloc_irqs_recursive(parent, irq_base,
  888. nr_irqs, arg);
  889. if (ret >= 0)
  890. ret = domain->ops->alloc(domain, irq_base, nr_irqs, arg);
  891. if (ret < 0 && recursive)
  892. irq_domain_free_irqs_recursive(parent, irq_base, nr_irqs);
  893. return ret;
  894. }
  895. /**
  896. * __irq_domain_alloc_irqs - Allocate IRQs from domain
  897. * @domain: domain to allocate from
  898. * @irq_base: allocate specified IRQ nubmer if irq_base >= 0
  899. * @nr_irqs: number of IRQs to allocate
  900. * @node: NUMA node id for memory allocation
  901. * @arg: domain specific argument
  902. * @realloc: IRQ descriptors have already been allocated if true
  903. *
  904. * Allocate IRQ numbers and initialized all data structures to support
  905. * hierarchy IRQ domains.
  906. * Parameter @realloc is mainly to support legacy IRQs.
  907. * Returns error code or allocated IRQ number
  908. *
  909. * The whole process to setup an IRQ has been split into two steps.
  910. * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
  911. * descriptor and required hardware resources. The second step,
  912. * irq_domain_activate_irq(), is to program hardwares with preallocated
  913. * resources. In this way, it's easier to rollback when failing to
  914. * allocate resources.
  915. */
  916. int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
  917. unsigned int nr_irqs, int node, void *arg,
  918. bool realloc)
  919. {
  920. int i, ret, virq;
  921. if (domain == NULL) {
  922. domain = irq_default_domain;
  923. if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
  924. return -EINVAL;
  925. }
  926. if (!domain->ops->alloc) {
  927. pr_debug("domain->ops->alloc() is NULL\n");
  928. return -ENOSYS;
  929. }
  930. if (realloc && irq_base >= 0) {
  931. virq = irq_base;
  932. } else {
  933. virq = irq_domain_alloc_descs(irq_base, nr_irqs, 0, node);
  934. if (virq < 0) {
  935. pr_debug("cannot allocate IRQ(base %d, count %d)\n",
  936. irq_base, nr_irqs);
  937. return virq;
  938. }
  939. }
  940. if (irq_domain_alloc_irq_data(domain, virq, nr_irqs)) {
  941. pr_debug("cannot allocate memory for IRQ%d\n", virq);
  942. ret = -ENOMEM;
  943. goto out_free_desc;
  944. }
  945. mutex_lock(&irq_domain_mutex);
  946. ret = irq_domain_alloc_irqs_recursive(domain, virq, nr_irqs, arg);
  947. if (ret < 0) {
  948. mutex_unlock(&irq_domain_mutex);
  949. goto out_free_irq_data;
  950. }
  951. for (i = 0; i < nr_irqs; i++)
  952. irq_domain_insert_irq(virq + i);
  953. mutex_unlock(&irq_domain_mutex);
  954. return virq;
  955. out_free_irq_data:
  956. irq_domain_free_irq_data(virq, nr_irqs);
  957. out_free_desc:
  958. irq_free_descs(virq, nr_irqs);
  959. return ret;
  960. }
  961. /**
  962. * irq_domain_free_irqs - Free IRQ number and associated data structures
  963. * @virq: base IRQ number
  964. * @nr_irqs: number of IRQs to free
  965. */
  966. void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs)
  967. {
  968. struct irq_data *data = irq_get_irq_data(virq);
  969. int i;
  970. if (WARN(!data || !data->domain || !data->domain->ops->free,
  971. "NULL pointer, cannot free irq\n"))
  972. return;
  973. mutex_lock(&irq_domain_mutex);
  974. for (i = 0; i < nr_irqs; i++)
  975. irq_domain_remove_irq(virq + i);
  976. irq_domain_free_irqs_recursive(data->domain, virq, nr_irqs);
  977. mutex_unlock(&irq_domain_mutex);
  978. irq_domain_free_irq_data(virq, nr_irqs);
  979. irq_free_descs(virq, nr_irqs);
  980. }
  981. /**
  982. * irq_domain_alloc_irqs_parent - Allocate interrupts from parent domain
  983. * @irq_base: Base IRQ number
  984. * @nr_irqs: Number of IRQs to allocate
  985. * @arg: Allocation data (arch/domain specific)
  986. *
  987. * Check whether the domain has been setup recursive. If not allocate
  988. * through the parent domain.
  989. */
  990. int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
  991. unsigned int irq_base, unsigned int nr_irqs,
  992. void *arg)
  993. {
  994. /* irq_domain_alloc_irqs_recursive() has called parent's alloc() */
  995. if (irq_domain_is_auto_recursive(domain))
  996. return 0;
  997. domain = domain->parent;
  998. if (domain)
  999. return irq_domain_alloc_irqs_recursive(domain, irq_base,
  1000. nr_irqs, arg);
  1001. return -ENOSYS;
  1002. }
  1003. /**
  1004. * irq_domain_free_irqs_parent - Free interrupts from parent domain
  1005. * @irq_base: Base IRQ number
  1006. * @nr_irqs: Number of IRQs to free
  1007. *
  1008. * Check whether the domain has been setup recursive. If not free
  1009. * through the parent domain.
  1010. */
  1011. void irq_domain_free_irqs_parent(struct irq_domain *domain,
  1012. unsigned int irq_base, unsigned int nr_irqs)
  1013. {
  1014. /* irq_domain_free_irqs_recursive() will call parent's free */
  1015. if (!irq_domain_is_auto_recursive(domain) && domain->parent)
  1016. irq_domain_free_irqs_recursive(domain->parent, irq_base,
  1017. nr_irqs);
  1018. }
  1019. /**
  1020. * irq_domain_activate_irq - Call domain_ops->activate recursively to activate
  1021. * interrupt
  1022. * @irq_data: outermost irq_data associated with interrupt
  1023. *
  1024. * This is the second step to call domain_ops->activate to program interrupt
  1025. * controllers, so the interrupt could actually get delivered.
  1026. */
  1027. void irq_domain_activate_irq(struct irq_data *irq_data)
  1028. {
  1029. if (irq_data && irq_data->domain) {
  1030. struct irq_domain *domain = irq_data->domain;
  1031. if (irq_data->parent_data)
  1032. irq_domain_activate_irq(irq_data->parent_data);
  1033. if (domain->ops->activate)
  1034. domain->ops->activate(domain, irq_data);
  1035. }
  1036. }
  1037. /**
  1038. * irq_domain_deactivate_irq - Call domain_ops->deactivate recursively to
  1039. * deactivate interrupt
  1040. * @irq_data: outermost irq_data associated with interrupt
  1041. *
  1042. * It calls domain_ops->deactivate to program interrupt controllers to disable
  1043. * interrupt delivery.
  1044. */
  1045. void irq_domain_deactivate_irq(struct irq_data *irq_data)
  1046. {
  1047. if (irq_data && irq_data->domain) {
  1048. struct irq_domain *domain = irq_data->domain;
  1049. if (domain->ops->deactivate)
  1050. domain->ops->deactivate(domain, irq_data);
  1051. if (irq_data->parent_data)
  1052. irq_domain_deactivate_irq(irq_data->parent_data);
  1053. }
  1054. }
  1055. static void irq_domain_check_hierarchy(struct irq_domain *domain)
  1056. {
  1057. /* Hierarchy irq_domains must implement callback alloc() */
  1058. if (domain->ops->alloc)
  1059. domain->flags |= IRQ_DOMAIN_FLAG_HIERARCHY;
  1060. }
  1061. #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
  1062. /**
  1063. * irq_domain_get_irq_data - Get irq_data associated with @virq and @domain
  1064. * @domain: domain to match
  1065. * @virq: IRQ number to get irq_data
  1066. */
  1067. struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
  1068. unsigned int virq)
  1069. {
  1070. struct irq_data *irq_data = irq_get_irq_data(virq);
  1071. return (irq_data && irq_data->domain == domain) ? irq_data : NULL;
  1072. }
  1073. static void irq_domain_check_hierarchy(struct irq_domain *domain)
  1074. {
  1075. }
  1076. #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */