aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-08-28 16:52:25 -0400
committerH. Peter Anvin <hpa@zytor.com>2008-09-04 11:37:57 -0400
commit58f7c98850a226d3fb05b1095af9f7c4ea3507ba (patch)
tree41bdbb26607a47ff4218aeb68323094a2d619f66 /arch/x86/pci
parent0ccd8c39bc664bf5e9fcc26caad50cc17ff866d1 (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/x86/pci')
-rw-r--r--arch/x86/pci/i386.c79
1 files changed, 79 insertions, 0 deletions
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}
78EXPORT_SYMBOL(pcibios_align_resource); 82EXPORT_SYMBOL(pcibios_align_resource);
79 83
84static 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
134static 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;