aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci/amd_bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/pci/amd_bus.c')
-rw-r--r--arch/x86/pci/amd_bus.c91
1 files changed, 37 insertions, 54 deletions
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index 0567df3890e1..5aed49bff058 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -32,6 +32,27 @@ static struct pci_hostbridge_probe pci_probes[] __initdata = {
32 32
33#define RANGE_NUM 16 33#define RANGE_NUM 16
34 34
35static struct pci_root_info __init *find_pci_root_info(int node, int link)
36{
37 struct pci_root_info *info;
38
39 /* find the position */
40 list_for_each_entry(info, &pci_root_infos, list)
41 if (info->node == node && info->link == link)
42 return info;
43
44 return NULL;
45}
46
47static void __init set_mp_bus_range_to_node(int min_bus, int max_bus, int node)
48{
49#ifdef CONFIG_NUMA
50 int j;
51
52 for (j = min_bus; j <= max_bus; j++)
53 set_mp_bus_to_node(j, node);
54#endif
55}
35/** 56/**
36 * early_fill_mp_bus_to_node() 57 * early_fill_mp_bus_to_node()
37 * called before pcibios_scan_root and pci_scan_bus 58 * called before pcibios_scan_root and pci_scan_bus
@@ -41,7 +62,6 @@ static struct pci_hostbridge_probe pci_probes[] __initdata = {
41static int __init early_fill_mp_bus_info(void) 62static int __init early_fill_mp_bus_info(void)
42{ 63{
43 int i; 64 int i;
44 int j;
45 unsigned bus; 65 unsigned bus;
46 unsigned slot; 66 unsigned slot;
47 int node; 67 int node;
@@ -50,7 +70,6 @@ static int __init early_fill_mp_bus_info(void)
50 int def_link; 70 int def_link;
51 struct pci_root_info *info; 71 struct pci_root_info *info;
52 u32 reg; 72 u32 reg;
53 struct resource *res;
54 u64 start; 73 u64 start;
55 u64 end; 74 u64 end;
56 struct range range[RANGE_NUM]; 75 struct range range[RANGE_NUM];
@@ -86,7 +105,6 @@ static int __init early_fill_mp_bus_info(void)
86 if (!found) 105 if (!found)
87 return 0; 106 return 0;
88 107
89 pci_root_num = 0;
90 for (i = 0; i < 4; i++) { 108 for (i = 0; i < 4; i++) {
91 int min_bus; 109 int min_bus;
92 int max_bus; 110 int max_bus;
@@ -99,19 +117,11 @@ static int __init early_fill_mp_bus_info(void)
99 min_bus = (reg >> 16) & 0xff; 117 min_bus = (reg >> 16) & 0xff;
100 max_bus = (reg >> 24) & 0xff; 118 max_bus = (reg >> 24) & 0xff;
101 node = (reg >> 4) & 0x07; 119 node = (reg >> 4) & 0x07;
102#ifdef CONFIG_NUMA 120 set_mp_bus_range_to_node(min_bus, max_bus, node);
103 for (j = min_bus; j <= max_bus; j++)
104 set_mp_bus_to_node(j, node);
105#endif
106 link = (reg >> 8) & 0x03; 121 link = (reg >> 8) & 0x03;
107 122
108 info = &pci_root_info[pci_root_num]; 123 info = alloc_pci_root_info(min_bus, max_bus, node, link);
109 info->bus_min = min_bus;
110 info->bus_max = max_bus;
111 info->node = node;
112 info->link = link;
113 sprintf(info->name, "PCI Bus #%02x", min_bus); 124 sprintf(info->name, "PCI Bus #%02x", min_bus);
114 pci_root_num++;
115 } 125 }
116 126
117 /* get the default node and link for left over res */ 127 /* get the default node and link for left over res */
@@ -134,16 +144,10 @@ static int __init early_fill_mp_bus_info(void)
134 link = (reg >> 4) & 0x03; 144 link = (reg >> 4) & 0x03;
135 end = (reg & 0xfff000) | 0xfff; 145 end = (reg & 0xfff000) | 0xfff;
136 146
137 /* find the position */ 147 info = find_pci_root_info(node, link);
138 for (j = 0; j < pci_root_num; j++) { 148 if (!info)
139 info = &pci_root_info[j];
140 if (info->node == node && info->link == link)
141 break;
142 }
143 if (j == pci_root_num)
144 continue; /* not found */ 149 continue; /* not found */
145 150
146 info = &pci_root_info[j];
147 printk(KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n", 151 printk(KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n",
148 node, link, start, end); 152 node, link, start, end);
149 153
@@ -155,13 +159,8 @@ static int __init early_fill_mp_bus_info(void)
155 } 159 }
156 /* add left over io port range to def node/link, [0, 0xffff] */ 160 /* add left over io port range to def node/link, [0, 0xffff] */
157 /* find the position */ 161 /* find the position */
158 for (j = 0; j < pci_root_num; j++) { 162 info = find_pci_root_info(def_node, def_link);
159 info = &pci_root_info[j]; 163 if (info) {
160 if (info->node == def_node && info->link == def_link)
161 break;
162 }
163 if (j < pci_root_num) {
164 info = &pci_root_info[j];
165 for (i = 0; i < RANGE_NUM; i++) { 164 for (i = 0; i < RANGE_NUM; i++) {
166 if (!range[i].end) 165 if (!range[i].end)
167 continue; 166 continue;
@@ -214,16 +213,10 @@ static int __init early_fill_mp_bus_info(void)
214 end <<= 8; 213 end <<= 8;
215 end |= 0xffff; 214 end |= 0xffff;
216 215
217 /* find the position */ 216 info = find_pci_root_info(node, link);
218 for (j = 0; j < pci_root_num; j++) {
219 info = &pci_root_info[j];
220 if (info->node == node && info->link == link)
221 break;
222 }
223 if (j == pci_root_num)
224 continue; /* not found */
225 217
226 info = &pci_root_info[j]; 218 if (!info)
219 continue;
227 220
228 printk(KERN_DEBUG "node %d link %d: mmio [%llx, %llx]", 221 printk(KERN_DEBUG "node %d link %d: mmio [%llx, %llx]",
229 node, link, start, end); 222 node, link, start, end);
@@ -291,14 +284,8 @@ static int __init early_fill_mp_bus_info(void)
291 * add left over mmio range to def node/link ? 284 * add left over mmio range to def node/link ?
292 * that is tricky, just record range in from start_min to 4G 285 * that is tricky, just record range in from start_min to 4G
293 */ 286 */
294 for (j = 0; j < pci_root_num; j++) { 287 info = find_pci_root_info(def_node, def_link);
295 info = &pci_root_info[j]; 288 if (info) {
296 if (info->node == def_node && info->link == def_link)
297 break;
298 }
299 if (j < pci_root_num) {
300 info = &pci_root_info[j];
301
302 for (i = 0; i < RANGE_NUM; i++) { 289 for (i = 0; i < RANGE_NUM; i++) {
303 if (!range[i].end) 290 if (!range[i].end)
304 continue; 291 continue;
@@ -309,20 +296,16 @@ static int __init early_fill_mp_bus_info(void)
309 } 296 }
310 } 297 }
311 298
312 for (i = 0; i < pci_root_num; i++) { 299 list_for_each_entry(info, &pci_root_infos, list) {
313 int res_num;
314 int busnum; 300 int busnum;
301 struct pci_root_res *root_res;
315 302
316 info = &pci_root_info[i];
317 res_num = info->res_num;
318 busnum = info->bus_min; 303 busnum = info->bus_min;
319 printk(KERN_DEBUG "bus: [%02x, %02x] on node %x link %x\n", 304 printk(KERN_DEBUG "bus: [%02x, %02x] on node %x link %x\n",
320 info->bus_min, info->bus_max, info->node, info->link); 305 info->bus_min, info->bus_max, info->node, info->link);
321 for (j = 0; j < res_num; j++) { 306 list_for_each_entry(root_res, &info->resources, list)
322 res = &info->res[j]; 307 printk(KERN_DEBUG "bus: %02x %pR\n",
323 printk(KERN_DEBUG "bus: %02x index %x %pR\n", 308 busnum, &root_res->res);
324 busnum, j, res);
325 }
326 } 309 }
327 310
328 return 0; 311 return 0;