bcm63xx: fix a race between PCI bus scan and fallback sprom registration
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-3.3 / 307-MIPS-BCM63XX-explicitly-register-the-pci-bus.patch
1 From 45aebb9465e22b236a201deef1b234693d99e174 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sun, 6 May 2012 15:13:48 +0200
4 Subject: [PATCH 2/2] MIPS: BCM63XX: explicitly register the PCI bus
5
6 Instead of setting a global variable toggling the PCI registration,
7 register it in the device_register phase after setting the fallback
8 sprom to ensure there cannot be a race between them.
9
10 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
11 ---
12 arch/mips/bcm63xx/boards/board_bcm963xx.c | 6 +++++-
13 .../include/asm/mach-bcm63xx/bcm63xx_dev_pci.h | 4 +++-
14 arch/mips/pci/pci-bcm63xx.c | 13 +------------
15 3 files changed, 9 insertions(+), 14 deletions(-)
16
17 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
18 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
19 @@ -825,7 +825,6 @@ void __init board_prom_init(void)
20
21 #ifdef CONFIG_PCI
22 if (board.has_pci) {
23 - bcm63xx_pci_enabled = 1;
24 if (BCMCPU_IS_6348())
25 val |= GPIO_MODE_6348_G2_PCI;
26 }
27 @@ -997,5 +996,10 @@ int __init board_register_devices(void)
28 platform_device_register(&bcm63xx_gpio_keys_device);
29 }
30
31 +#ifdef CONFIG_PCI
32 + if (board.has_pci)
33 + bcm63xx_pci_register();
34 +#endif
35 +
36 return 0;
37 }
38 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pci.h
39 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pci.h
40 @@ -1,6 +1,8 @@
41 #ifndef BCM63XX_DEV_PCI_H_
42 #define BCM63XX_DEV_PCI_H_
43
44 -extern int bcm63xx_pci_enabled;
45 +#include <linux/init.h>
46 +
47 +int __init bcm63xx_pci_register(void);
48
49 #endif /* BCM63XX_DEV_PCI_H_ */
50 --- a/arch/mips/pci/pci-bcm63xx.c
51 +++ b/arch/mips/pci/pci-bcm63xx.c
52 @@ -14,12 +14,6 @@
53
54 #include "pci-bcm63xx.h"
55
56 -/*
57 - * Allow PCI to be disabled at runtime depending on board nvram
58 - * configuration
59 - */
60 -int bcm63xx_pci_enabled;
61 -
62 static struct resource bcm_pci_mem_resource = {
63 .name = "bcm63xx PCI memory space",
64 .start = BCM_PCI_MEM_BASE_PA,
65 @@ -94,7 +88,7 @@ static void bcm63xx_int_cfg_writel(u32 v
66
67 void __iomem *pci_iospace_start;
68
69 -static int __init bcm63xx_pci_init(void)
70 +int __init bcm63xx_pci_register(void)
71 {
72 unsigned int mem_size;
73 u32 val;
74 @@ -102,9 +96,6 @@ static int __init bcm63xx_pci_init(void)
75 if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358() && !BCMCPU_IS_6368())
76 return -ENODEV;
77
78 - if (!bcm63xx_pci_enabled)
79 - return -ENODEV;
80 -
81 /*
82 * configuration access are done through IO space, remap 4
83 * first bytes to access it from CPU.
84 @@ -220,5 +211,3 @@ static int __init bcm63xx_pci_init(void)
85 "bcm63xx PCI IO space");
86 return 0;
87 }
88 -
89 -arch_initcall(bcm63xx_pci_init);