acpi.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include <linux/pci.h>
  2. #include <linux/acpi.h>
  3. #include <linux/init.h>
  4. #include <linux/irq.h>
  5. #include <asm/numa.h>
  6. #include "pci.h"
  7. struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
  8. {
  9. struct pci_bus *bus;
  10. struct pci_sysdata *sd;
  11. int pxm;
  12. /* Allocate per-root-bus (not per bus) arch-specific data.
  13. * TODO: leak; this memory is never freed.
  14. * It's arguable whether it's worth the trouble to care.
  15. */
  16. sd = kzalloc(sizeof(*sd), GFP_KERNEL);
  17. if (!sd) {
  18. printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
  19. return NULL;
  20. }
  21. if (domain != 0) {
  22. printk(KERN_WARNING "PCI: Multiple domains not supported\n");
  23. kfree(sd);
  24. return NULL;
  25. }
  26. sd->node = -1;
  27. pxm = acpi_get_pxm(device->handle);
  28. #ifdef CONFIG_ACPI_NUMA
  29. if (pxm >= 0)
  30. sd->node = pxm_to_node(pxm);
  31. #endif
  32. bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
  33. if (!bus)
  34. kfree(sd);
  35. #ifdef CONFIG_ACPI_NUMA
  36. if (bus != NULL) {
  37. if (pxm >= 0) {
  38. printk("bus %d -> pxm %d -> node %d\n",
  39. busnum, pxm, sd->node);
  40. }
  41. }
  42. #endif
  43. return bus;
  44. }
  45. extern int pci_routeirq;
  46. static int __init pci_acpi_init(void)
  47. {
  48. struct pci_dev *dev = NULL;
  49. if (pcibios_scanned)
  50. return 0;
  51. if (acpi_noirq)
  52. return 0;
  53. printk(KERN_INFO "PCI: Using ACPI for IRQ routing\n");
  54. acpi_irq_penalty_init();
  55. pcibios_scanned++;
  56. pcibios_enable_irq = acpi_pci_irq_enable;
  57. pcibios_disable_irq = acpi_pci_irq_disable;
  58. if (pci_routeirq) {
  59. /*
  60. * PCI IRQ routing is set up by pci_enable_device(), but we
  61. * also do it here in case there are still broken drivers that
  62. * don't use pci_enable_device().
  63. */
  64. printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n");
  65. for_each_pci_dev(dev)
  66. acpi_pci_irq_enable(dev);
  67. } else
  68. printk(KERN_INFO "PCI: If a device doesn't work, try \"pci=routeirq\". If it helps, post a report\n");
  69. #ifdef CONFIG_X86_IO_APIC
  70. if (acpi_ioapic)
  71. print_IO_APIC();
  72. #endif
  73. return 0;
  74. }
  75. subsys_initcall(pci_acpi_init);