aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-11-12 01:27:40 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-11-24 18:25:59 -0500
commit67f241f4579651ea4335b58967c8880c0a378249 (patch)
tree595afbde4b48bcd33425fb96ee2f4e09e45b6979 /arch
parent7b7a78594292d540720485544ad1043b71de14e0 (diff)
x86/pci: seperate x86_pci_rootbus_res_quirks from amd_bus.c
Those functions are used by intel_bus.c so seperate them to another file. and make amd_bus a bit smaller. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/pci/Makefile2
-rw-r--r--arch/x86/pci/amd_bus.c99
-rw-r--r--arch/x86/pci/bus_numa.c101
-rw-r--r--arch/x86/pci/bus_numa.h1
4 files changed, 103 insertions, 100 deletions
diff --git a/arch/x86/pci/Makefile b/arch/x86/pci/Makefile
index d8a0a6279a4d..564b008a51c7 100644
--- a/arch/x86/pci/Makefile
+++ b/arch/x86/pci/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
15 15
16obj-y += common.o early.o 16obj-y += common.o early.o
17obj-y += amd_bus.o 17obj-y += amd_bus.o
18obj-$(CONFIG_X86_64) += intel_bus.o 18obj-$(CONFIG_X86_64) += bus_numa.o intel_bus.o
19 19
20ifeq ($(CONFIG_PCI_DEBUG),y) 20ifeq ($(CONFIG_PCI_DEBUG),y)
21EXTRA_CFLAGS += -DDEBUG 21EXTRA_CFLAGS += -DDEBUG
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index 995f36096a42..95ecbd495955 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -6,8 +6,6 @@
6 6
7#ifdef CONFIG_X86_64 7#ifdef CONFIG_X86_64
8#include <asm/pci-direct.h> 8#include <asm/pci-direct.h>
9#include <asm/mpspec.h>
10#include <linux/cpumask.h>
11#endif 9#endif
12 10
13#include "bus_numa.h" 11#include "bus_numa.h"
@@ -19,54 +17,6 @@
19 17
20#ifdef CONFIG_X86_64 18#ifdef CONFIG_X86_64
21 19
22int pci_root_num;
23struct pci_root_info pci_root_info[PCI_ROOT_NR];
24static int found_all_numa_early;
25
26void x86_pci_root_bus_res_quirks(struct pci_bus *b)
27{
28 int i;
29 int j;
30 struct pci_root_info *info;
31
32 /* don't go for it if _CRS is used already */
33 if (b->resource[0] != &ioport_resource ||
34 b->resource[1] != &iomem_resource)
35 return;
36
37 if (!pci_root_num)
38 return;
39
40 /* for amd, if only one root bus, don't need to do anything */
41 if (pci_root_num < 2 && found_all_numa_early)
42 return;
43
44 for (i = 0; i < pci_root_num; i++) {
45 if (pci_root_info[i].bus_min == b->number)
46 break;
47 }
48
49 if (i == pci_root_num)
50 return;
51
52 printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
53 b->number);
54
55 info = &pci_root_info[i];
56 for (j = 0; j < info->res_num; j++) {
57 struct resource *res;
58 struct resource *root;
59
60 res = &info->res[j];
61 b->resource[j] = res;
62 if (res->flags & IORESOURCE_IO)
63 root = &ioport_resource;
64 else
65 root = &iomem_resource;
66 insert_resource(root, res);
67 }
68}
69
70#define RANGE_NUM 16 20#define RANGE_NUM 16
71 21
72struct res_range { 22struct res_range {
@@ -119,55 +69,6 @@ static void __init update_range(struct res_range *range, size_t start,
119 } 69 }
120} 70}
121 71
122void __init update_res(struct pci_root_info *info, size_t start,
123 size_t end, unsigned long flags, int merge)
124{
125 int i;
126 struct resource *res;
127
128 if (start > end)
129 return;
130
131 if (!merge)
132 goto addit;
133
134 /* try to merge it with old one */
135 for (i = 0; i < info->res_num; i++) {
136 size_t final_start, final_end;
137 size_t common_start, common_end;
138
139 res = &info->res[i];
140 if (res->flags != flags)
141 continue;
142
143 common_start = max((size_t)res->start, start);
144 common_end = min((size_t)res->end, end);
145 if (common_start > common_end + 1)
146 continue;
147
148 final_start = min((size_t)res->start, start);
149 final_end = max((size_t)res->end, end);
150
151 res->start = final_start;
152 res->end = final_end;
153 return;
154 }
155
156addit:
157
158 /* need to add that */
159 if (info->res_num >= RES_NUM)
160 return;
161
162 res = &info->res[info->res_num];
163 res->name = info->name;
164 res->flags = flags;
165 res->start = start;
166 res->end = end;
167 res->child = NULL;
168 info->res_num++;
169}
170
171struct pci_hostbridge_probe { 72struct pci_hostbridge_probe {
172 u32 bus; 73 u32 bus;
173 u32 slot; 74 u32 slot;
diff --git a/arch/x86/pci/bus_numa.c b/arch/x86/pci/bus_numa.c
new file mode 100644
index 000000000000..145df00e0387
--- /dev/null
+++ b/arch/x86/pci/bus_numa.c
@@ -0,0 +1,101 @@
1#include <linux/init.h>
2#include <linux/pci.h>
3
4#include "bus_numa.h"
5
6int pci_root_num;
7struct pci_root_info pci_root_info[PCI_ROOT_NR];
8int found_all_numa_early;
9
10void x86_pci_root_bus_res_quirks(struct pci_bus *b)
11{
12 int i;
13 int j;
14 struct pci_root_info *info;
15
16 /* don't go for it if _CRS is used already */
17 if (b->resource[0] != &ioport_resource ||
18 b->resource[1] != &iomem_resource)
19 return;
20
21 if (!pci_root_num)
22 return;
23
24 /* for amd, if only one root bus, don't need to do anything */
25 if (pci_root_num < 2 && found_all_numa_early)
26 return;
27
28 for (i = 0; i < pci_root_num; i++) {
29 if (pci_root_info[i].bus_min == b->number)
30 break;
31 }
32
33 if (i == pci_root_num)
34 return;
35
36 printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
37 b->number);
38
39 info = &pci_root_info[i];
40 for (j = 0; j < info->res_num; j++) {
41 struct resource *res;
42 struct resource *root;
43
44 res = &info->res[j];
45 b->resource[j] = res;
46 if (res->flags & IORESOURCE_IO)
47 root = &ioport_resource;
48 else
49 root = &iomem_resource;
50 insert_resource(root, res);
51 }
52}
53
54void __init update_res(struct pci_root_info *info, size_t start,
55 size_t end, unsigned long flags, int merge)
56{
57 int i;
58 struct resource *res;
59
60 if (start > end)
61 return;
62
63 if (!merge)
64 goto addit;
65
66 /* try to merge it with old one */
67 for (i = 0; i < info->res_num; i++) {
68 size_t final_start, final_end;
69 size_t common_start, common_end;
70
71 res = &info->res[i];
72 if (res->flags != flags)
73 continue;
74
75 common_start = max((size_t)res->start, start);
76 common_end = min((size_t)res->end, end);
77 if (common_start > common_end + 1)
78 continue;
79
80 final_start = min((size_t)res->start, start);
81 final_end = max((size_t)res->end, end);
82
83 res->start = final_start;
84 res->end = final_end;
85 return;
86 }
87
88addit:
89
90 /* need to add that */
91 if (info->res_num >= RES_NUM)
92 return;
93
94 res = &info->res[info->res_num];
95 res->name = info->name;
96 res->flags = flags;
97 res->start = start;
98 res->end = end;
99 res->child = NULL;
100 info->res_num++;
101}
diff --git a/arch/x86/pci/bus_numa.h b/arch/x86/pci/bus_numa.h
index 730369f392a3..adbc23fe82ac 100644
--- a/arch/x86/pci/bus_numa.h
+++ b/arch/x86/pci/bus_numa.h
@@ -20,6 +20,7 @@ struct pci_root_info {
20#define PCI_ROOT_NR 4 20#define PCI_ROOT_NR 4
21extern int pci_root_num; 21extern int pci_root_num;
22extern struct pci_root_info pci_root_info[PCI_ROOT_NR]; 22extern struct pci_root_info pci_root_info[PCI_ROOT_NR];
23extern int found_all_numa_early;
23 24
24extern void update_res(struct pci_root_info *info, size_t start, 25extern void update_res(struct pci_root_info *info, size_t start,
25 size_t end, unsigned long flags, int merge); 26 size_t end, unsigned long flags, int merge);