pci_irq.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * pci_irq.c - ACPI PCI Interrupt Routing ($Revision: 11 $)
  3. *
  4. * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  5. * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  6. * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
  7. *
  8. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or (at
  13. * your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  23. *
  24. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25. */
  26. #include <linux/dmi.h>
  27. #include <linux/kernel.h>
  28. #include <linux/module.h>
  29. #include <linux/init.h>
  30. #include <linux/types.h>
  31. #include <linux/proc_fs.h>
  32. #include <linux/spinlock.h>
  33. #include <linux/pm.h>
  34. #include <linux/pci.h>
  35. #include <linux/acpi.h>
  36. #include <acpi/acpi_bus.h>
  37. #include <acpi/acpi_drivers.h>
  38. #define _COMPONENT ACPI_PCI_COMPONENT
  39. ACPI_MODULE_NAME("pci_irq");
  40. static struct acpi_prt_list acpi_prt;
  41. static DEFINE_SPINLOCK(acpi_prt_lock);
  42. /* --------------------------------------------------------------------------
  43. PCI IRQ Routing Table (PRT) Support
  44. -------------------------------------------------------------------------- */
  45. static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
  46. int bus,
  47. int device, int pin)
  48. {
  49. struct acpi_prt_entry *entry = NULL;
  50. if (!acpi_prt.count)
  51. return NULL;
  52. /*
  53. * Parse through all PRT entries looking for a match on the specified
  54. * PCI device's segment, bus, device, and pin (don't care about func).
  55. *
  56. */
  57. spin_lock(&acpi_prt_lock);
  58. list_for_each_entry(entry, &acpi_prt.entries, node) {
  59. if ((segment == entry->id.segment)
  60. && (bus == entry->id.bus)
  61. && (device == entry->id.device)
  62. && (pin == entry->pin)) {
  63. spin_unlock(&acpi_prt_lock);
  64. return entry;
  65. }
  66. }
  67. spin_unlock(&acpi_prt_lock);
  68. return NULL;
  69. }
  70. /* http://bugzilla.kernel.org/show_bug.cgi?id=4773 */
  71. static struct dmi_system_id medion_md9580[] = {
  72. {
  73. .ident = "Medion MD9580-F laptop",
  74. .matches = {
  75. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  76. DMI_MATCH(DMI_PRODUCT_NAME, "A555"),
  77. },
  78. },
  79. { }
  80. };
  81. /* http://bugzilla.kernel.org/show_bug.cgi?id=5044 */
  82. static struct dmi_system_id dell_optiplex[] = {
  83. {
  84. .ident = "Dell Optiplex GX1",
  85. .matches = {
  86. DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
  87. DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX1 600S+"),
  88. },
  89. },
  90. { }
  91. };
  92. /* http://bugzilla.kernel.org/show_bug.cgi?id=10138 */
  93. static struct dmi_system_id hp_t5710[] = {
  94. {
  95. .ident = "HP t5710",
  96. .matches = {
  97. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  98. DMI_MATCH(DMI_PRODUCT_NAME, "hp t5000 series"),
  99. DMI_MATCH(DMI_BOARD_NAME, "098Ch"),
  100. },
  101. },
  102. { }
  103. };
  104. struct prt_quirk {
  105. struct dmi_system_id *system;
  106. unsigned int segment;
  107. unsigned int bus;
  108. unsigned int device;
  109. unsigned char pin;
  110. char *source; /* according to BIOS */
  111. char *actual_source;
  112. };
  113. /*
  114. * These systems have incorrect _PRT entries. The BIOS claims the PCI
  115. * interrupt at the listed segment/bus/device/pin is connected to the first
  116. * link device, but it is actually connected to the second.
  117. */
  118. static struct prt_quirk prt_quirks[] = {
  119. { medion_md9580, 0, 0, 9, 'A',
  120. "\\_SB_.PCI0.ISA_.LNKA",
  121. "\\_SB_.PCI0.ISA_.LNKB"},
  122. { dell_optiplex, 0, 0, 0xd, 'A',
  123. "\\_SB_.LNKB",
  124. "\\_SB_.LNKA"},
  125. { hp_t5710, 0, 0, 1, 'A',
  126. "\\_SB_.PCI0.LNK1",
  127. "\\_SB_.PCI0.LNK3"},
  128. };
  129. static void
  130. do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt)
  131. {
  132. int i;
  133. struct prt_quirk *quirk;
  134. for (i = 0; i < ARRAY_SIZE(prt_quirks); i++) {
  135. quirk = &prt_quirks[i];
  136. /* All current quirks involve link devices, not GSIs */
  137. if (!prt->source)
  138. continue;
  139. if (dmi_check_system(quirk->system) &&
  140. entry->id.segment == quirk->segment &&
  141. entry->id.bus == quirk->bus &&
  142. entry->id.device == quirk->device &&
  143. entry->pin + 'A' == quirk->pin &&
  144. !strcmp(prt->source, quirk->source) &&
  145. strlen(prt->source) >= strlen(quirk->actual_source)) {
  146. printk(KERN_WARNING PREFIX "firmware reports "
  147. "%04x:%02x:%02x PCI INT %c connected to %s; "
  148. "changing to %s\n",
  149. entry->id.segment, entry->id.bus,
  150. entry->id.device, 'A' + entry->pin,
  151. prt->source, quirk->actual_source);
  152. strcpy(prt->source, quirk->actual_source);
  153. }
  154. }
  155. }
  156. static int
  157. acpi_pci_irq_add_entry(acpi_handle handle,
  158. int segment, int bus, struct acpi_pci_routing_table *prt)
  159. {
  160. struct acpi_prt_entry *entry = NULL;
  161. if (!prt)
  162. return -EINVAL;
  163. entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
  164. if (!entry)
  165. return -ENOMEM;
  166. entry->id.segment = segment;
  167. entry->id.bus = bus;
  168. entry->id.device = (prt->address >> 16) & 0xFFFF;
  169. entry->id.function = prt->address & 0xFFFF;
  170. entry->pin = prt->pin;
  171. do_prt_fixups(entry, prt);
  172. /*
  173. * Type 1: Dynamic
  174. * ---------------
  175. * The 'source' field specifies the PCI interrupt link device used to
  176. * configure the IRQ assigned to this slot|dev|pin. The 'source_index'
  177. * indicates which resource descriptor in the resource template (of
  178. * the link device) this interrupt is allocated from.
  179. *
  180. * NOTE: Don't query the Link Device for IRQ information at this time
  181. * because Link Device enumeration may not have occurred yet
  182. * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
  183. * namespace).
  184. */
  185. if (prt->source[0]) {
  186. acpi_get_handle(handle, prt->source, &entry->link.handle);
  187. entry->link.index = prt->source_index;
  188. }
  189. /*
  190. * Type 2: Static
  191. * --------------
  192. * The 'source' field is NULL, and the 'source_index' field specifies
  193. * the IRQ value, which is hardwired to specific interrupt inputs on
  194. * the interrupt controller.
  195. */
  196. else
  197. entry->link.index = prt->source_index;
  198. ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
  199. " %02X:%02X:%02X[%c] -> %s[%d]\n",
  200. entry->id.segment, entry->id.bus,
  201. entry->id.device, ('A' + entry->pin), prt->source,
  202. entry->link.index));
  203. spin_lock(&acpi_prt_lock);
  204. list_add_tail(&entry->node, &acpi_prt.entries);
  205. acpi_prt.count++;
  206. spin_unlock(&acpi_prt_lock);
  207. return 0;
  208. }
  209. static void
  210. acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
  211. {
  212. if (segment == entry->id.segment && bus == entry->id.bus) {
  213. acpi_prt.count--;
  214. list_del(&entry->node);
  215. kfree(entry);
  216. }
  217. }
  218. int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
  219. {
  220. acpi_status status = AE_OK;
  221. char *pathname = NULL;
  222. struct acpi_buffer buffer = { 0, NULL };
  223. struct acpi_pci_routing_table *prt = NULL;
  224. struct acpi_pci_routing_table *entry = NULL;
  225. static int first_time = 1;
  226. pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
  227. if (!pathname)
  228. return -ENOMEM;
  229. if (first_time) {
  230. acpi_prt.count = 0;
  231. INIT_LIST_HEAD(&acpi_prt.entries);
  232. first_time = 0;
  233. }
  234. /*
  235. * NOTE: We're given a 'handle' to the _PRT object's parent device
  236. * (either a PCI root bridge or PCI-PCI bridge).
  237. */
  238. buffer.length = ACPI_PATHNAME_MAX;
  239. buffer.pointer = pathname;
  240. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  241. printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
  242. pathname);
  243. /*
  244. * Evaluate this _PRT and add its entries to our global list (acpi_prt).
  245. */
  246. buffer.length = 0;
  247. buffer.pointer = NULL;
  248. kfree(pathname);
  249. status = acpi_get_irq_routing_table(handle, &buffer);
  250. if (status != AE_BUFFER_OVERFLOW) {
  251. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
  252. acpi_format_exception(status)));
  253. return -ENODEV;
  254. }
  255. prt = kzalloc(buffer.length, GFP_KERNEL);
  256. if (!prt) {
  257. return -ENOMEM;
  258. }
  259. buffer.pointer = prt;
  260. status = acpi_get_irq_routing_table(handle, &buffer);
  261. if (ACPI_FAILURE(status)) {
  262. ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
  263. acpi_format_exception(status)));
  264. kfree(buffer.pointer);
  265. return -ENODEV;
  266. }
  267. entry = prt;
  268. while (entry && (entry->length > 0)) {
  269. acpi_pci_irq_add_entry(handle, segment, bus, entry);
  270. entry = (struct acpi_pci_routing_table *)
  271. ((unsigned long)entry + entry->length);
  272. }
  273. kfree(prt);
  274. return 0;
  275. }
  276. void acpi_pci_irq_del_prt(int segment, int bus)
  277. {
  278. struct list_head *node = NULL, *n = NULL;
  279. struct acpi_prt_entry *entry = NULL;
  280. if (!acpi_prt.count) {
  281. return;
  282. }
  283. printk(KERN_DEBUG
  284. "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment,
  285. bus);
  286. spin_lock(&acpi_prt_lock);
  287. list_for_each_safe(node, n, &acpi_prt.entries) {
  288. entry = list_entry(node, struct acpi_prt_entry, node);
  289. acpi_pci_irq_del_entry(segment, bus, entry);
  290. }
  291. spin_unlock(&acpi_prt_lock);
  292. }
  293. /* --------------------------------------------------------------------------
  294. PCI Interrupt Routing Support
  295. -------------------------------------------------------------------------- */
  296. typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **);
  297. static int
  298. acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
  299. int *triggering, int *polarity, char **link)
  300. {
  301. int irq;
  302. if (entry->link.handle) {
  303. irq = acpi_pci_link_allocate_irq(entry->link.handle,
  304. entry->link.index, triggering,
  305. polarity, link);
  306. if (irq < 0) {
  307. printk(KERN_WARNING PREFIX
  308. "Invalid IRQ link routing entry\n");
  309. return -1;
  310. }
  311. } else {
  312. irq = entry->link.index;
  313. *triggering = ACPI_LEVEL_SENSITIVE;
  314. *polarity = ACPI_ACTIVE_LOW;
  315. }
  316. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
  317. return irq;
  318. }
  319. static int
  320. acpi_pci_free_irq(struct acpi_prt_entry *entry,
  321. int *triggering, int *polarity, char **link)
  322. {
  323. int irq;
  324. if (entry->link.handle) {
  325. irq = acpi_pci_link_free_irq(entry->link.handle);
  326. } else {
  327. irq = entry->link.index;
  328. }
  329. return irq;
  330. }
  331. #ifdef CONFIG_X86_IO_APIC
  332. extern int noioapicquirk;
  333. static int bridge_has_boot_interrupt_variant(struct pci_bus *bus)
  334. {
  335. struct pci_bus *bus_it;
  336. for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) {
  337. if (!bus_it->self)
  338. return 0;
  339. printk(KERN_INFO "vendor=%04x device=%04x\n", bus_it->self->vendor,
  340. bus_it->self->device);
  341. if (bus_it->self->irq_reroute_variant)
  342. return bus_it->self->irq_reroute_variant;
  343. }
  344. return 0;
  345. }
  346. #endif /* CONFIG_X86_IO_APIC */
  347. /*
  348. * acpi_pci_irq_lookup
  349. * success: return IRQ >= 0
  350. * failure: return -1
  351. */
  352. static int
  353. acpi_pci_irq_lookup(struct pci_bus *bus,
  354. int device,
  355. int pin,
  356. int *triggering,
  357. int *polarity, char **link, irq_lookup_func func)
  358. {
  359. struct acpi_prt_entry *entry = NULL;
  360. int segment = pci_domain_nr(bus);
  361. int bus_nr = bus->number;
  362. int ret;
  363. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  364. "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
  365. segment, bus_nr, device, ('A' + pin)));
  366. entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
  367. if (!entry) {
  368. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
  369. return -1;
  370. }
  371. ret = func(entry, triggering, polarity, link);
  372. #ifdef CONFIG_X86_IO_APIC
  373. /*
  374. * Some chipsets (e.g. intel 6700PXH) generate a legacy INTx when the
  375. * IRQ entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel
  376. * does during interrupt handling). When this INTx generation cannot be
  377. * disabled, we reroute these interrupts to their legacy equivalent to
  378. * get rid of spurious interrupts.
  379. */
  380. if (!noioapicquirk) {
  381. switch (bridge_has_boot_interrupt_variant(bus)) {
  382. case 0:
  383. /* no rerouting necessary */
  384. break;
  385. case INTEL_IRQ_REROUTE_VARIANT:
  386. /*
  387. * Remap according to INTx routing table in 6700PXH
  388. * specs, intel order number 302628-002, section
  389. * 2.15.2. Other chipsets (80332, ...) have the same
  390. * mapping and are handled here as well.
  391. */
  392. printk(KERN_INFO "pci irq %d -> rerouted to legacy "
  393. "irq %d\n", ret, (ret % 4) + 16);
  394. ret = (ret % 4) + 16;
  395. break;
  396. default:
  397. printk(KERN_INFO "not rerouting irq %d to legacy irq: "
  398. "unknown mapping\n", ret);
  399. break;
  400. }
  401. }
  402. #endif /* CONFIG_X86_IO_APIC */
  403. return ret;
  404. }
  405. /*
  406. * acpi_pci_irq_derive
  407. * success: return IRQ >= 0
  408. * failure: return < 0
  409. */
  410. static int
  411. acpi_pci_irq_derive(struct pci_dev *dev,
  412. int pin,
  413. int *triggering,
  414. int *polarity, char **link, irq_lookup_func func)
  415. {
  416. struct pci_dev *bridge = dev;
  417. int irq = -1;
  418. u8 bridge_pin = 0, orig_pin = pin;
  419. if (!dev)
  420. return -EINVAL;
  421. /*
  422. * Attempt to derive an IRQ for this device from a parent bridge's
  423. * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
  424. */
  425. while (irq < 0 && bridge->bus->self) {
  426. pin = (pin + PCI_SLOT(bridge->devfn)) % 4;
  427. bridge = bridge->bus->self;
  428. if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
  429. /* PC card has the same IRQ as its cardbridge */
  430. bridge_pin = bridge->pin;
  431. if (!bridge_pin) {
  432. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  433. "No interrupt pin configured for device %s\n",
  434. pci_name(bridge)));
  435. return -1;
  436. }
  437. /* Pin is from 0 to 3 */
  438. bridge_pin--;
  439. pin = bridge_pin;
  440. }
  441. irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
  442. pin, triggering, polarity,
  443. link, func);
  444. }
  445. if (irq < 0) {
  446. dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n",
  447. 'A' + orig_pin);
  448. return -1;
  449. }
  450. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
  451. irq, pci_name(dev), pci_name(bridge)));
  452. return irq;
  453. }
  454. /*
  455. * acpi_pci_irq_enable
  456. * success: return 0
  457. * failure: return < 0
  458. */
  459. int acpi_pci_irq_enable(struct pci_dev *dev)
  460. {
  461. int irq = 0;
  462. u8 pin = 0;
  463. int triggering = ACPI_LEVEL_SENSITIVE;
  464. int polarity = ACPI_ACTIVE_LOW;
  465. char *link = NULL;
  466. char link_desc[16];
  467. int rc;
  468. if (!dev)
  469. return -EINVAL;
  470. pin = dev->pin;
  471. if (!pin) {
  472. ACPI_DEBUG_PRINT((ACPI_DB_INFO,
  473. "No interrupt pin configured for device %s\n",
  474. pci_name(dev)));
  475. return 0;
  476. }
  477. pin--;
  478. if (!dev->bus) {
  479. dev_err(&dev->dev, "invalid (NULL) 'bus' field\n");
  480. return -ENODEV;
  481. }
  482. /*
  483. * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT
  484. * values override any BIOS-assigned IRQs set during boot.
  485. */
  486. irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
  487. &triggering, &polarity, &link,
  488. acpi_pci_allocate_irq);
  489. /*
  490. * If no PRT entry was found, we'll try to derive an IRQ from the
  491. * device's parent bridge.
  492. */
  493. if (irq < 0)
  494. irq = acpi_pci_irq_derive(dev, pin, &triggering,
  495. &polarity, &link,
  496. acpi_pci_allocate_irq);
  497. if (irq < 0) {
  498. /*
  499. * IDE legacy mode controller IRQs are magic. Why do compat
  500. * extensions always make such a nasty mess.
  501. */
  502. if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE &&
  503. (dev->class & 0x05) == 0)
  504. return 0;
  505. }
  506. /*
  507. * No IRQ known to the ACPI subsystem - maybe the BIOS /
  508. * driver reported one, then use it. Exit in any case.
  509. */
  510. if (irq < 0) {
  511. dev_warn(&dev->dev, "PCI INT %c: no GSI", 'A' + pin);
  512. /* Interrupt Line values above 0xF are forbidden */
  513. if (dev->irq > 0 && (dev->irq <= 0xF)) {
  514. printk(" - using IRQ %d\n", dev->irq);
  515. acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
  516. ACPI_ACTIVE_LOW);
  517. return 0;
  518. } else {
  519. printk("\n");
  520. return 0;
  521. }
  522. }
  523. rc = acpi_register_gsi(irq, triggering, polarity);
  524. if (rc < 0) {
  525. dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
  526. 'A' + pin);
  527. return rc;
  528. }
  529. dev->irq = rc;
  530. if (link)
  531. snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
  532. else
  533. link_desc[0] = '\0';
  534. dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
  535. 'A' + pin, link_desc, irq,
  536. (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
  537. (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
  538. return 0;
  539. }
  540. /* FIXME: implement x86/x86_64 version */
  541. void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
  542. {
  543. }
  544. void acpi_pci_irq_disable(struct pci_dev *dev)
  545. {
  546. int gsi = 0;
  547. u8 pin = 0;
  548. int triggering = ACPI_LEVEL_SENSITIVE;
  549. int polarity = ACPI_ACTIVE_LOW;
  550. if (!dev || !dev->bus)
  551. return;
  552. pin = dev->pin;
  553. if (!pin)
  554. return;
  555. pin--;
  556. /*
  557. * First we check the PCI IRQ routing table (PRT) for an IRQ.
  558. */
  559. gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
  560. &triggering, &polarity, NULL,
  561. acpi_pci_free_irq);
  562. /*
  563. * If no PRT entry was found, we'll try to derive an IRQ from the
  564. * device's parent bridge.
  565. */
  566. if (gsi < 0)
  567. gsi = acpi_pci_irq_derive(dev, pin,
  568. &triggering, &polarity, NULL,
  569. acpi_pci_free_irq);
  570. if (gsi < 0)
  571. return;
  572. /*
  573. * TBD: It might be worth clearing dev->irq by magic constant
  574. * (e.g. PCI_UNDEFINED_IRQ).
  575. */
  576. dev_info(&dev->dev, "PCI INT %c disabled\n", 'A' + pin);
  577. acpi_unregister_gsi(gsi);
  578. }