diff options
author | Yinghai Lu <yhlu.kernel@gmail.com> | 2008-08-28 16:52:25 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-09-04 11:37:57 -0400 |
commit | 58f7c98850a226d3fb05b1095af9f7c4ea3507ba (patch) | |
tree | 41bdbb26607a47ff4218aeb68323094a2d619f66 /arch | |
parent | 0ccd8c39bc664bf5e9fcc26caad50cc17ff866d1 (diff) |
x86: split e820 reserved entries record to late v2
so could let BAR res register at first, or even pnp.
v2: insert e820 reserve resources before pnp_system_init
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/e820.c | 20 | ||||
-rw-r--r-- | arch/x86/pci/i386.c | 79 |
2 files changed, 97 insertions, 2 deletions
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 291e6cd9f9c0..523d6c5605d1 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
@@ -1271,13 +1271,15 @@ static inline const char *e820_type_to_string(int e820_type) | |||
1271 | /* | 1271 | /* |
1272 | * Mark e820 reserved areas as busy for the resource manager. | 1272 | * Mark e820 reserved areas as busy for the resource manager. |
1273 | */ | 1273 | */ |
1274 | struct resource __initdata *e820_res; | ||
1274 | void __init e820_reserve_resources(void) | 1275 | void __init e820_reserve_resources(void) |
1275 | { | 1276 | { |
1276 | int i; | 1277 | int i; |
1277 | struct resource *res; | ||
1278 | u64 end; | 1278 | u64 end; |
1279 | struct resource *res; | ||
1279 | 1280 | ||
1280 | res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); | 1281 | res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); |
1282 | e820_res = res; | ||
1281 | for (i = 0; i < e820.nr_map; i++) { | 1283 | for (i = 0; i < e820.nr_map; i++) { |
1282 | end = e820.map[i].addr + e820.map[i].size - 1; | 1284 | end = e820.map[i].addr + e820.map[i].size - 1; |
1283 | #ifndef CONFIG_RESOURCES_64BIT | 1285 | #ifndef CONFIG_RESOURCES_64BIT |
@@ -1291,7 +1293,8 @@ void __init e820_reserve_resources(void) | |||
1291 | res->end = end; | 1293 | res->end = end; |
1292 | 1294 | ||
1293 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; | 1295 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; |
1294 | insert_resource(&iomem_resource, res); | 1296 | if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) |
1297 | insert_resource(&iomem_resource, res); | ||
1295 | res++; | 1298 | res++; |
1296 | } | 1299 | } |
1297 | 1300 | ||
@@ -1303,6 +1306,19 @@ void __init e820_reserve_resources(void) | |||
1303 | } | 1306 | } |
1304 | } | 1307 | } |
1305 | 1308 | ||
1309 | void __init e820_reserve_resources_late(void) | ||
1310 | { | ||
1311 | int i; | ||
1312 | struct resource *res; | ||
1313 | |||
1314 | res = e820_res; | ||
1315 | for (i = 0; i < e820.nr_map; i++) { | ||
1316 | if (e820.map[i].type == E820_RESERVED && res->start >= (1ULL<<20)) | ||
1317 | insert_resource(&iomem_resource, res); | ||
1318 | res++; | ||
1319 | } | ||
1320 | } | ||
1321 | |||
1306 | char *__init default_machine_specific_memory_setup(void) | 1322 | char *__init default_machine_specific_memory_setup(void) |
1307 | { | 1323 | { |
1308 | char *who = "BIOS-e820"; | 1324 | char *who = "BIOS-e820"; |
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 8791fc55e715..40811efaa25a 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -31,8 +31,12 @@ | |||
31 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
34 | #include <linux/acpi.h> | ||
34 | 35 | ||
35 | #include <asm/pat.h> | 36 | #include <asm/pat.h> |
37 | #include <asm/hpet.h> | ||
38 | #include <asm/io_apic.h> | ||
39 | #include <asm/e820.h> | ||
36 | 40 | ||
37 | #include "pci.h" | 41 | #include "pci.h" |
38 | 42 | ||
@@ -77,6 +81,77 @@ pcibios_align_resource(void *data, struct resource *res, | |||
77 | } | 81 | } |
78 | EXPORT_SYMBOL(pcibios_align_resource); | 82 | EXPORT_SYMBOL(pcibios_align_resource); |
79 | 83 | ||
84 | static int check_res_with_valid(struct pci_dev *dev, struct resource *res) | ||
85 | { | ||
86 | unsigned long base; | ||
87 | unsigned long size; | ||
88 | int i; | ||
89 | |||
90 | base = res->start; | ||
91 | size = (res->start == 0 && res->end == res->start) ? 0 : | ||
92 | (res->end - res->start + 1); | ||
93 | |||
94 | if (!base || !size) | ||
95 | return 0; | ||
96 | |||
97 | #ifdef CONFIG_HPET_TIMER | ||
98 | /* for hpet */ | ||
99 | if (base == hpet_address && (res->flags & IORESOURCE_MEM)) { | ||
100 | dev_info(&dev->dev, "BAR has HPET at %08lx-%08lx\n", | ||
101 | base, base + size - 1); | ||
102 | return 1; | ||
103 | } | ||
104 | #endif | ||
105 | |||
106 | #ifdef CONFIG_X86_IO_APIC | ||
107 | for (i = 0; i < nr_ioapics; i++) { | ||
108 | unsigned long ioapic_phys = mp_ioapics[i].mp_apicaddr; | ||
109 | |||
110 | if (base == ioapic_phys && (res->flags & IORESOURCE_MEM)) { | ||
111 | dev_info(&dev->dev, "BAR has ioapic at %08lx-%08lx\n", | ||
112 | base, base + size - 1); | ||
113 | return 1; | ||
114 | } | ||
115 | } | ||
116 | #endif | ||
117 | |||
118 | #ifdef CONFIG_PCI_MMCONFIG | ||
119 | for (i = 0; i < pci_mmcfg_config_num; i++) { | ||
120 | unsigned long addr; | ||
121 | |||
122 | addr = pci_mmcfg_config[i].address; | ||
123 | if (base == addr && (res->flags & IORESOURCE_MEM)) { | ||
124 | dev_info(&dev->dev, "BAR has MMCONFIG at %08lx-%08lx\n", | ||
125 | base, base + size - 1); | ||
126 | return 1; | ||
127 | } | ||
128 | } | ||
129 | #endif | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | static int check_platform(struct pci_dev *dev, struct resource *res) | ||
135 | { | ||
136 | struct resource *root = NULL; | ||
137 | |||
138 | /* | ||
139 | * forcibly insert it into the | ||
140 | * resource tree | ||
141 | */ | ||
142 | if (res->flags & IORESOURCE_MEM) | ||
143 | root = &iomem_resource; | ||
144 | else if (res->flags & IORESOURCE_IO) | ||
145 | root = &ioport_resource; | ||
146 | |||
147 | if (root && check_res_with_valid(dev, res)) { | ||
148 | insert_resource(root, res); | ||
149 | |||
150 | return 1; | ||
151 | } | ||
152 | |||
153 | return 0; | ||
154 | } | ||
80 | /* | 155 | /* |
81 | * Handle resources of PCI devices. If the world were perfect, we could | 156 | * Handle resources of PCI devices. If the world were perfect, we could |
82 | * just allocate all the resource regions and do nothing more. It isn't. | 157 | * just allocate all the resource regions and do nothing more. It isn't. |
@@ -128,6 +203,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) | |||
128 | pr = pci_find_parent_resource(dev, r); | 203 | pr = pci_find_parent_resource(dev, r); |
129 | if (!r->start || !pr || | 204 | if (!r->start || !pr || |
130 | request_resource(pr, r) < 0) { | 205 | request_resource(pr, r) < 0) { |
206 | if (check_platform(dev, r)) | ||
207 | continue; | ||
131 | dev_err(&dev->dev, "BAR %d: can't allocate resource\n", idx); | 208 | dev_err(&dev->dev, "BAR %d: can't allocate resource\n", idx); |
132 | /* | 209 | /* |
133 | * Something is wrong with the region. | 210 | * Something is wrong with the region. |
@@ -169,6 +246,8 @@ static void __init pcibios_allocate_resources(int pass) | |||
169 | r->flags, disabled, pass); | 246 | r->flags, disabled, pass); |
170 | pr = pci_find_parent_resource(dev, r); | 247 | pr = pci_find_parent_resource(dev, r); |
171 | if (!pr || request_resource(pr, r) < 0) { | 248 | if (!pr || request_resource(pr, r) < 0) { |
249 | if (check_platform(dev, r)) | ||
250 | continue; | ||
172 | dev_err(&dev->dev, "BAR %d: can't allocate resource\n", idx); | 251 | dev_err(&dev->dev, "BAR %d: can't allocate resource\n", idx); |
173 | /* We'll assign a new address later */ | 252 | /* We'll assign a new address later */ |
174 | r->end -= r->start; | 253 | r->end -= r->start; |