Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Make pci_read_irq_line the default

This patch reworks the way IRQs are fixed up on PCI for arch powerpc.

It makes pci_read_irq_line() called by default in the PCI code for
devices that are probed, and add an optional per-device fixup in
ppc_md for platforms that really need to correct what they obtain
from pci_read_irq_line().

It also removes ppc_md.irq_bus_setup which was only used by pSeries
and should not be needed anymore.

I've also removed the pSeries s7a workaround as it can't work with
the current interrupt code anyway. I'm trying to get one of these
machines working so I can test a proper fix for that problem.

I also haven't updated the old-style fixup code from 85xx_cds.c
because it's actually buggy :) It assigns pci_dev->irq hard coded
numbers which is no good with the new IRQ mapping code. It should
at least use irq_create_mapping(NULL, hard_coded_number); and possibly
also set_irq_type() to set them as level low.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Benjamin Herrenschmidt and committed by
Paul Mackerras
f90bb153 34ba8a5c

+59 -184
+10
arch/powerpc/kernel/pci_32.c
··· 12 12 #include <linux/errno.h> 13 13 #include <linux/bootmem.h> 14 14 #include <linux/irq.h> 15 + #include <linux/list.h> 15 16 16 17 #include <asm/processor.h> 17 18 #include <asm/io.h> ··· 1339 1338 struct pci_controller *hose = (struct pci_controller *) bus->sysdata; 1340 1339 unsigned long io_offset; 1341 1340 struct resource *res; 1341 + struct pci_dev *dev; 1342 1342 int i; 1343 1343 1344 1344 io_offset = (unsigned long)hose->io_base_virt - isa_io_base; ··· 1392 1390 } 1393 1391 } 1394 1392 1393 + /* Platform specific bus fixups */ 1395 1394 if (ppc_md.pcibios_fixup_bus) 1396 1395 ppc_md.pcibios_fixup_bus(bus); 1396 + 1397 + /* Read default IRQs and fixup if necessary */ 1398 + list_for_each_entry(dev, &bus->devices, bus_list) { 1399 + pci_read_irq_line(dev); 1400 + if (ppc_md.pci_irq_fixup) 1401 + ppc_md.pci_irq_fixup(dev); 1402 + } 1397 1403 } 1398 1404 1399 1405 char __init *pcibios_setup(char *str)
+6 -2
arch/powerpc/kernel/pci_64.c
··· 1215 1215 list_for_each_entry(dev, &bus->devices, bus_list) 1216 1216 ppc_md.iommu_dev_setup(dev); 1217 1217 1218 - if (ppc_md.irq_bus_setup) 1219 - ppc_md.irq_bus_setup(bus); 1218 + /* Read default IRQs and fixup if necessary */ 1219 + list_for_each_entry(dev, &bus->devices, bus_list) { 1220 + pci_read_irq_line(dev); 1221 + if (ppc_md.pci_irq_fixup) 1222 + ppc_md.pci_irq_fixup(dev); 1223 + } 1220 1224 } 1221 1225 1222 1226 void __devinit pcibios_fixup_bus(struct pci_bus *bus)
-13
arch/powerpc/platforms/82xx/mpc82xx_ads.c
··· 515 515 return PCIBIOS_SUCCESSFUL; 516 516 } 517 517 518 - static void 519 - __init mpc82xx_pcibios_fixup(void) 520 - { 521 - struct pci_dev *dev = NULL; 522 - 523 - for_each_pci_dev(dev) { 524 - pci_read_irq_line(dev); 525 - } 526 - } 527 - 528 518 void __init add_bridge(struct device_node *np) 529 519 { 530 520 int len; ··· 587 597 add_bridge(np); 588 598 589 599 of_node_put(np); 590 - ppc_md.pci_map_irq = NULL; 591 - ppc_md.pcibios_fixup = mpc82xx_pcibios_fixup; 592 - ppc_md.pcibios_fixup_bus = NULL; 593 600 #endif 594 601 595 602 #ifdef CONFIG_ROOT_NFS
-3
arch/powerpc/platforms/83xx/mpc834x_itx.c
··· 118 118 .time_init = mpc83xx_time_init, 119 119 .calibrate_decr = generic_calibrate_decr, 120 120 .progress = udbg_progress, 121 - #ifdef CONFIG_PCI 122 - .pcibios_fixup = mpc83xx_pcibios_fixup, 123 - #endif 124 121 };
-3
arch/powerpc/platforms/83xx/mpc834x_sys.c
··· 137 137 .time_init = mpc83xx_time_init, 138 138 .calibrate_decr = generic_calibrate_decr, 139 139 .progress = udbg_progress, 140 - #ifdef CONFIG_PCI 141 - .pcibios_fixup = mpc83xx_pcibios_fixup, 142 - #endif 143 140 };
-1
arch/powerpc/platforms/83xx/mpc83xx.h
··· 11 11 12 12 extern int add_bridge(struct device_node *dev); 13 13 extern int mpc83xx_exclude_device(u_char bus, u_char devfn); 14 - extern void mpc83xx_pcibios_fixup(void); 15 14 extern void mpc83xx_restart(char *cmd); 16 15 extern long mpc83xx_time_init(void); 17 16
-9
arch/powerpc/platforms/83xx/pci.c
··· 45 45 return PCIBIOS_SUCCESSFUL; 46 46 } 47 47 48 - void __init mpc83xx_pcibios_fixup(void) 49 - { 50 - struct pci_dev *dev = NULL; 51 - 52 - /* map all the PCI irqs */ 53 - for_each_pci_dev(dev) 54 - pci_read_irq_line(dev); 55 - } 56 - 57 48 int __init add_bridge(struct device_node *dev) 58 49 { 59 50 int len;
-11
arch/powerpc/platforms/85xx/mpc85xx_ads.c
··· 53 53 else 54 54 return PCIBIOS_SUCCESSFUL; 55 55 } 56 - 57 - void __init 58 - mpc85xx_pcibios_fixup(void) 59 - { 60 - struct pci_dev *dev = NULL; 61 - 62 - for_each_pci_dev(dev) 63 - pci_read_irq_line(dev); 64 - } 65 56 #endif /* CONFIG_PCI */ 66 57 67 58 #ifdef CONFIG_CPM2 ··· 244 253 #ifdef CONFIG_PCI 245 254 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 246 255 add_bridge(np); 247 - 248 - ppc_md.pcibios_fixup = mpc85xx_pcibios_fixup; 249 256 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 250 257 #endif 251 258
-10
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
··· 398 398 } 399 399 400 400 401 - void __init mpc86xx_hpcn_pcibios_fixup(void) 402 - { 403 - struct pci_dev *dev = NULL; 404 - 405 - for_each_pci_dev(dev) 406 - pci_read_irq_line(dev); 407 - } 408 - 409 - 410 401 /* 411 402 * Called very early, device-tree isn't unflattened 412 403 */ ··· 452 461 .setup_arch = mpc86xx_hpcn_setup_arch, 453 462 .init_IRQ = mpc86xx_hpcn_init_irq, 454 463 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo, 455 - .pcibios_fixup = mpc86xx_hpcn_pcibios_fixup, 456 464 .get_irq = mpic_get_irq, 457 465 .restart = mpc86xx_restart, 458 466 .time_init = mpc86xx_time_init,
-9
arch/powerpc/platforms/cell/setup.c
··· 80 80 printk("*** %04x : %s\n", hex, s ? s : ""); 81 81 } 82 82 83 - static void __init cell_pcibios_fixup(void) 84 - { 85 - struct pci_dev *dev = NULL; 86 - 87 - for_each_pci_dev(dev) 88 - pci_read_irq_line(dev); 89 - } 90 - 91 83 static void __init cell_init_irq(void) 92 84 { 93 85 iic_init_IRQ(); ··· 172 180 .check_legacy_ioport = cell_check_legacy_ioport, 173 181 .progress = cell_progress, 174 182 .init_IRQ = cell_init_irq, 175 - .pcibios_fixup = cell_pcibios_fixup, 176 183 #ifdef CONFIG_KEXEC 177 184 .machine_kexec = default_machine_kexec, 178 185 .machine_kexec_prepare = default_machine_kexec_prepare,
-1
arch/powerpc/platforms/chrp/chrp.h
··· 9 9 10 10 extern void chrp_find_bridges(void); 11 11 extern void chrp_event_scan(unsigned long); 12 - extern void chrp_pcibios_fixup(void);
-9
arch/powerpc/platforms/chrp/pci.c
··· 156 156 return 1; 157 157 } 158 158 159 - void __init 160 - chrp_pcibios_fixup(void) 161 - { 162 - struct pci_dev *dev = NULL; 163 - 164 - for_each_pci_dev(dev) 165 - pci_read_irq_line(dev); 166 - } 167 - 168 159 #define PRG_CL_RESET_VALID 0x00010000 169 160 170 161 static void __init
-1
arch/powerpc/platforms/chrp/setup.c
··· 600 600 .init = chrp_init2, 601 601 .show_cpuinfo = chrp_show_cpuinfo, 602 602 .init_IRQ = chrp_init_IRQ, 603 - .pcibios_fixup = chrp_pcibios_fixup, 604 603 .restart = rtas_restart, 605 604 .power_off = rtas_power_off, 606 605 .halt = rtas_halt,
+5 -11
arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
··· 89 89 /* 90 90 * Scans the interrupt map for pci device 91 91 */ 92 - void mpc7448_hpc2_fixup_irq(struct pci_dev *dev) 92 + void __devinit mpc7448_hpc2_fixup_irq(struct pci_dev *dev) 93 93 { 94 94 struct pci_controller *hose; 95 95 struct device_node *node; ··· 117 117 pin = 1; 118 118 pin--; 119 119 dev->irq = interrupt[slot*4*7 + pin*7 + 5]; 120 + 121 + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 122 + 120 123 DBG("TSI_PCI: dev->irq = 0x%x\n", dev->irq); 121 124 } 122 125 /* temporary pci irq map fixup*/ 123 - 124 - void __init mpc7448_hpc2_pcibios_fixup(void) 125 - { 126 - struct pci_dev *dev = NULL; 127 - for_each_pci_dev(dev) { 128 - mpc7448_hpc2_fixup_irq(dev); 129 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 130 - } 131 - } 132 126 133 127 static void __init mpc7448_hpc2_setup_arch(void) 134 128 { ··· 294 300 .init_IRQ = mpc7448_hpc2_init_IRQ, 295 301 .show_cpuinfo = mpc7448_hpc2_show_cpuinfo, 296 302 .get_irq = mpic_get_irq, 297 - .pcibios_fixup = mpc7448_hpc2_pcibios_fixup, 303 + .pci_irq_fixup = mpc7448_hpc2_fixup_irq, 298 304 .restart = mpc7448_hpc2_restart, 299 305 .calibrate_decr = generic_calibrate_decr, 300 306 .machine_check_exception= mpc7448_machine_check_exception,
+1 -1
arch/powerpc/platforms/maple/maple.h
··· 8 8 extern unsigned long maple_get_boot_time(void); 9 9 extern void maple_calibrate_decr(void); 10 10 extern void maple_pci_init(void); 11 - extern void maple_pcibios_fixup(void); 11 + extern void maple_pci_irq_fixup(struct pci_dev *dev); 12 12 extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel);
+19 -28
arch/powerpc/platforms/maple/pci.c
··· 502 502 } 503 503 504 504 505 - void __init maple_pcibios_fixup(void) 505 + void __devinit maple_pci_irq_fixup(struct pci_dev *dev) 506 506 { 507 - struct pci_dev *dev = NULL; 507 + DBG(" -> maple_pci_irq_fixup\n"); 508 508 509 - DBG(" -> maple_pcibios_fixup\n"); 510 - 511 - for_each_pci_dev(dev) { 512 - /* Fixup IRQ for PCIe host */ 513 - if (u4_pcie != NULL && dev->bus->number == 0 && 514 - pci_bus_to_host(dev->bus) == u4_pcie) { 515 - printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n"); 516 - dev->irq = irq_create_mapping(NULL, 1); 517 - if (dev->irq != NO_IRQ) 518 - set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 519 - continue; 520 - } 521 - 522 - /* Hide AMD8111 IDE interrupt when in legacy mode so 523 - * the driver calls pci_get_legacy_ide_irq() 524 - */ 525 - if (dev->vendor == PCI_VENDOR_ID_AMD && 526 - dev->device == PCI_DEVICE_ID_AMD_8111_IDE && 527 - (dev->class & 5) != 5) { 528 - dev->irq = NO_IRQ; 529 - continue; 530 - } 531 - 532 - /* For all others, map the interrupt from the device-tree */ 533 - pci_read_irq_line(dev); 509 + /* Fixup IRQ for PCIe host */ 510 + if (u4_pcie != NULL && dev->bus->number == 0 && 511 + pci_bus_to_host(dev->bus) == u4_pcie) { 512 + printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n"); 513 + dev->irq = irq_create_mapping(NULL, 1); 514 + if (dev->irq != NO_IRQ) 515 + set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 534 516 } 535 517 536 - DBG(" <- maple_pcibios_fixup\n"); 518 + /* Hide AMD8111 IDE interrupt when in legacy mode so 519 + * the driver calls pci_get_legacy_ide_irq() 520 + */ 521 + if (dev->vendor == PCI_VENDOR_ID_AMD && 522 + dev->device == PCI_DEVICE_ID_AMD_8111_IDE && 523 + (dev->class & 5) != 5) { 524 + dev->irq = NO_IRQ; 525 + } 526 + 527 + DBG(" <- maple_pci_irq_fixup\n"); 537 528 } 538 529 539 530 static void __init maple_fixup_phb_resources(void)
+1 -1
arch/powerpc/platforms/maple/setup.c
··· 312 312 .setup_arch = maple_setup_arch, 313 313 .init_early = maple_init_early, 314 314 .init_IRQ = maple_init_IRQ, 315 - .pcibios_fixup = maple_pcibios_fixup, 315 + .pci_irq_fixup = maple_pci_irq_fixup, 316 316 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq, 317 317 .restart = maple_restart, 318 318 .power_off = maple_power_off,
-1
arch/powerpc/platforms/pasemi/pasemi.h
··· 3 3 4 4 extern unsigned long pas_get_boot_time(void); 5 5 extern void pas_pci_init(void); 6 - extern void pas_pcibios_fixup(void); 7 6 8 7 #endif /* _PASEMI_PASEMI_H */
-8
arch/powerpc/platforms/pasemi/pci.c
··· 148 148 } 149 149 150 150 151 - void __init pas_pcibios_fixup(void) 152 - { 153 - struct pci_dev *dev = NULL; 154 - 155 - for_each_pci_dev(dev) 156 - pci_read_irq_line(dev); 157 - } 158 - 159 151 static void __init pas_fixup_phb_resources(void) 160 152 { 161 153 struct pci_controller *hose, *tmp;
-1
arch/powerpc/platforms/pasemi/setup.c
··· 176 176 .init_early = pas_init_early, 177 177 .init_IRQ = pas_init_IRQ, 178 178 .get_irq = mpic_get_irq, 179 - .pcibios_fixup = pas_pcibios_fixup, 180 179 .restart = pas_restart, 181 180 .power_off = pas_power_off, 182 181 .halt = pas_halt,
+14 -21
arch/powerpc/platforms/powermac/pci.c
··· 984 984 return 0; 985 985 } 986 986 987 - void __init pmac_pcibios_fixup(void) 987 + void __devinit pmac_pci_irq_fixup(struct pci_dev *dev) 988 988 { 989 - struct pci_dev* dev = NULL; 990 - 991 - for_each_pci_dev(dev) { 992 - /* Read interrupt from the device-tree */ 993 - pci_read_irq_line(dev); 994 - 995 989 #ifdef CONFIG_PPC32 996 - /* Fixup interrupt for the modem/ethernet combo controller. 997 - * on machines with a second ohare chip. 998 - * The number in the device tree (27) is bogus (correct for 999 - * the ethernet-only board but not the combo ethernet/modem 1000 - * board). The real interrupt is 28 on the second controller 1001 - * -> 28+32 = 60. 1002 - */ 1003 - if (has_second_ohare && 1004 - dev->vendor == PCI_VENDOR_ID_DEC && 1005 - dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) { 1006 - dev->irq = irq_create_mapping(NULL, 60); 1007 - set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 1008 - } 1009 - #endif /* CONFIG_PPC32 */ 990 + /* Fixup interrupt for the modem/ethernet combo controller. 991 + * on machines with a second ohare chip. 992 + * The number in the device tree (27) is bogus (correct for 993 + * the ethernet-only board but not the combo ethernet/modem 994 + * board). The real interrupt is 28 on the second controller 995 + * -> 28+32 = 60. 996 + */ 997 + if (has_second_ohare && 998 + dev->vendor == PCI_VENDOR_ID_DEC && 999 + dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) { 1000 + dev->irq = irq_create_mapping(NULL, 60); 1001 + set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 1010 1002 } 1003 + #endif /* CONFIG_PPC32 */ 1011 1004 } 1012 1005 1013 1006 #ifdef CONFIG_PPC64
+1 -1
arch/powerpc/platforms/powermac/pmac.h
··· 20 20 extern int pmac_set_rtc_time(struct rtc_time *); 21 21 extern void pmac_read_rtc_time(void); 22 22 extern void pmac_calibrate_decr(void); 23 - extern void pmac_pcibios_fixup(void); 23 + extern void pmac_pci_irq_fixup(struct pci_dev *); 24 24 extern void pmac_pci_init(void); 25 25 extern unsigned long pmac_ide_get_base(int index); 26 26 extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,
+1 -1
arch/powerpc/platforms/powermac/setup.c
··· 727 727 .show_cpuinfo = pmac_show_cpuinfo, 728 728 .init_IRQ = pmac_pic_init, 729 729 .get_irq = NULL, /* changed later */ 730 - .pcibios_fixup = pmac_pcibios_fixup, 730 + .pci_irq_fixup = pmac_pci_irq_fixup, 731 731 .restart = pmac_restart, 732 732 .power_off = pmac_power_off, 733 733 .halt = pmac_halt,
-35
arch/powerpc/platforms/pseries/pci.c
··· 29 29 #include <asm/prom.h> 30 30 #include <asm/ppc-pci.h> 31 31 32 - static int __devinitdata s7a_workaround = -1; 33 - 34 32 #if 0 35 33 void pcibios_name_device(struct pci_dev *dev) 36 34 { ··· 54 56 } 55 57 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device); 56 58 #endif 57 - 58 - static void __devinit check_s7a(void) 59 - { 60 - struct device_node *root; 61 - const char *model; 62 - 63 - s7a_workaround = 0; 64 - root = of_find_node_by_path("/"); 65 - if (root) { 66 - model = get_property(root, "model", NULL); 67 - if (model && !strcmp(model, "IBM,7013-S7A")) 68 - s7a_workaround = 1; 69 - of_node_put(root); 70 - } 71 - } 72 - 73 - void __devinit pSeries_irq_bus_setup(struct pci_bus *bus) 74 - { 75 - struct pci_dev *dev; 76 - 77 - if (s7a_workaround < 0) 78 - check_s7a(); 79 - list_for_each_entry(dev, &bus->devices, bus_list) { 80 - pci_read_irq_line(dev); 81 - if (s7a_workaround) { 82 - if (dev->irq > 16) { 83 - dev->irq -= 3; 84 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 85 - dev->irq); 86 - } 87 - } 88 - } 89 - } 90 59 91 60 static void __init pSeries_request_regions(void) 92 61 {
-1
arch/powerpc/platforms/pseries/setup.c
··· 553 553 .log_error = pSeries_log_error, 554 554 .pcibios_fixup = pSeries_final_fixup, 555 555 .pci_probe_mode = pSeries_pci_probe_mode, 556 - .irq_bus_setup = pSeries_irq_bus_setup, 557 556 .restart = rtas_restart, 558 557 .power_off = rtas_power_off, 559 558 .halt = rtas_halt,
+1 -1
include/asm-powerpc/machdep.h
··· 86 86 void (*tce_flush)(struct iommu_table *tbl); 87 87 void (*iommu_dev_setup)(struct pci_dev *dev); 88 88 void (*iommu_bus_setup)(struct pci_bus *bus); 89 - void (*irq_bus_setup)(struct pci_bus *bus); 90 89 #endif /* CONFIG_PPC64 */ 91 90 92 91 int (*probe)(void); ··· 105 106 /* Called after scanning the bus, before allocating resources */ 106 107 void (*pcibios_fixup)(void); 107 108 int (*pci_probe_mode)(struct pci_bus *); 109 + void (*pci_irq_fixup)(struct pci_dev *dev); 108 110 109 111 void (*restart)(char *cmd); 110 112 void (*power_off)(void);
-1
include/asm-powerpc/ppc-pci.h
··· 47 47 48 48 /* From pSeries_pci.h */ 49 49 extern void pSeries_final_fixup(void); 50 - extern void pSeries_irq_bus_setup(struct pci_bus *bus); 51 50 52 51 extern unsigned long pci_probe_only; 53 52