aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-versatile
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2013-08-22 12:47:48 -0400
committerKevin Hilman <khilman@linaro.org>2013-09-04 17:52:52 -0400
commitf9b71fef12f0d6ac5c7051cfd87f7700f78c56b6 (patch)
treeff62572892958142714fc3e37a9de800bfaca984 /arch/arm/mach-versatile
parentd4e4ab86bcba5a72779c43dc1459f71fea3d89c8 (diff)
ARM: PCI: versatile: Fix map_irq function to match hardware
The PCI controller code for the Versatile board has never had the correct IRQ mapping for hardware. For many years it had an odd mapping ("all interrupts are int 27") which aligned with the equivalent bug in QEMU. However as of commit 1bc39ac5dab265 the mapping changed and no longer matched either hardware or QEMU, with the result that any PCI card beyond the first in QEMU would not have functioning interrupts; for example a boot with a SCSI controller would time out as follows: ------------ sym0: <895a> rev 0x0 at pci 0000:00:0d.0 irq 92 sym0: SCSI BUS has been reset. scsi0 : sym-2.2.3 [...] scsi 0:0:0:0: ABORT operation started scsi 0:0:0:0: ABORT operation timed-out. scsi 0:0:0:0: DEVICE RESET operation started scsi 0:0:0:0: DEVICE RESET operation timed-out. scsi 0:0:0:0: BUS RESET operation started scsi 0:0:0:0: BUS RESET operation timed-out. scsi 0:0:0:0: HOST RESET operation started sym0: SCSI BUS has been reset ------------ Fix the mapping so that it matches real hardware (checked against the schematics for PB926 and backplane, and tested against the hardware). This allows PCI cards using interrupts to work on hardware for the first time; this change will also work with QEMU 1.5 or later, where the equivalent bugs in the modelling of the hardware have been fixed. Although QEMU will attempt to autodetect whether the kernel is expecting the long-standing "everything is int 27" mapping or the one hardware has, for certainty we force it into "definitely behave like hardware mode"; this will avoid unexpected surprises later if we implement sparse irqs. This is harmless on hardware. Thanks to Paul Gortmaker for bisecting the problem and finding an initial solution, to Russell King for providing the correct interrupt mapping, and to Guenter Roeck for providing an initial version of this patch and prodding me into relocating the hardware and retesting everything. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Cc: stable@vger.kernel.org Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Kevin Hilman <khilman@linaro.org>
Diffstat (limited to 'arch/arm/mach-versatile')
-rw-r--r--arch/arm/mach-versatile/pci.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index e92e5e0705bc..234740d90385 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -295,6 +295,19 @@ int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
295 __raw_writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2); 295 __raw_writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);
296 296
297 /* 297 /*
298 * For many years the kernel and QEMU were symbiotically buggy
299 * in that they both assumed the same broken IRQ mapping.
300 * QEMU therefore attempts to auto-detect old broken kernels
301 * so that they still work on newer QEMU as they did on old
302 * QEMU. Since we now use the correct (ie matching-hardware)
303 * IRQ mapping we write a definitely different value to a
304 * PCI_INTERRUPT_LINE register to tell QEMU that we expect
305 * real hardware behaviour and it need not be backwards
306 * compatible for us. This write is harmless on real hardware.
307 */
308 __raw_writel(0, VERSATILE_PCI_VIRT_BASE+PCI_INTERRUPT_LINE);
309
310 /*
298 * Do not to map Versatile FPGA PCI device into memory space 311 * Do not to map Versatile FPGA PCI device into memory space
299 */ 312 */
300 pci_slot_ignore |= (1 << myslot); 313 pci_slot_ignore |= (1 << myslot);
@@ -327,13 +340,13 @@ static int __init versatile_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
327{ 340{
328 int irq; 341 int irq;
329 342
330 /* slot, pin, irq 343 /*
331 * 24 1 IRQ_SIC_PCI0 344 * Slot INTA INTB INTC INTD
332 * 25 1 IRQ_SIC_PCI1 345 * 31 PCI1 PCI2 PCI3 PCI0
333 * 26 1 IRQ_SIC_PCI2 346 * 30 PCI0 PCI1 PCI2 PCI3
334 * 27 1 IRQ_SIC_PCI3 347 * 29 PCI3 PCI0 PCI1 PCI2
335 */ 348 */
336 irq = IRQ_SIC_PCI0 + ((slot - 24 + pin - 1) & 3); 349 irq = IRQ_SIC_PCI0 + ((slot + 2 + pin - 1) & 3);
337 350
338 return irq; 351 return irq;
339} 352}