Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/init.h> |
| 2 | #include <linux/pci.h> |
Robert Richter | d199a04 | 2008-07-02 22:50:26 +0200 | [diff] [blame] | 3 | #include <linux/topology.h> |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 4 | #include <linux/cpu.h> |
Yinghai Lu | 27811d8 | 2010-02-10 01:20:07 -0800 | [diff] [blame] | 5 | #include <linux/range.h> |
| 6 | |
Jaswinder Singh Rajput | 8248771 | 2008-12-27 18:32:28 +0530 | [diff] [blame] | 7 | #include <asm/pci_x86.h> |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 8 | |
Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 9 | #include <asm/pci-direct.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Yinghai Lu | 99935a7 | 2009-10-04 21:54:24 -0700 | [diff] [blame] | 11 | #include "bus_numa.h" |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | /* |
| 14 | * This discovers the pcibus <-> node mapping on AMD K8. |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 15 | * also get peer root bus resource for io,mmio |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 18 | struct pci_hostbridge_probe { |
| 19 | u32 bus; |
| 20 | u32 slot; |
| 21 | u32 vendor; |
| 22 | u32 device; |
| 23 | }; |
| 24 | |
| 25 | static struct pci_hostbridge_probe pci_probes[] __initdata = { |
| 26 | { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1100 }, |
| 27 | { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, |
| 28 | { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, |
| 29 | { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1300 }, |
| 30 | }; |
| 31 | |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 32 | static u64 __initdata fam10h_mmconf_start; |
| 33 | static u64 __initdata fam10h_mmconf_end; |
| 34 | static void __init get_pci_mmcfg_amd_fam10h_range(void) |
| 35 | { |
| 36 | u32 address; |
| 37 | u64 base, msr; |
| 38 | unsigned segn_busn_bits; |
| 39 | |
| 40 | /* assume all cpus from fam10h have mmconf */ |
| 41 | if (boot_cpu_data.x86 < 0x10) |
| 42 | return; |
| 43 | |
| 44 | address = MSR_FAM10H_MMIO_CONF_BASE; |
| 45 | rdmsrl(address, msr); |
| 46 | |
| 47 | /* mmconfig is not enable */ |
| 48 | if (!(msr & FAM10H_MMIO_CONF_ENABLE)) |
| 49 | return; |
| 50 | |
| 51 | base = msr & (FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT); |
| 52 | |
| 53 | segn_busn_bits = (msr >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) & |
| 54 | FAM10H_MMIO_CONF_BUSRANGE_MASK; |
| 55 | |
| 56 | fam10h_mmconf_start = base; |
| 57 | fam10h_mmconf_end = base + (1ULL<<(segn_busn_bits + 20)) - 1; |
| 58 | } |
| 59 | |
Yinghai Lu | 27811d8 | 2010-02-10 01:20:07 -0800 | [diff] [blame] | 60 | #define RANGE_NUM 16 |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | /** |
Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 63 | * early_fill_mp_bus_to_node() |
| 64 | * called before pcibios_scan_root and pci_scan_bus |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | * fills the mp_bus_to_cpumask array based according to the LDT Bus Number |
| 66 | * Registers found in the K8 northbridge |
| 67 | */ |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 68 | static int __init early_fill_mp_bus_info(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 70 | int i; |
| 71 | int j; |
| 72 | unsigned bus; |
Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 73 | unsigned slot; |
Yinghai Lu | 35ddd06 | 2008-02-19 03:15:08 -0800 | [diff] [blame] | 74 | int node; |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 75 | int link; |
| 76 | int def_node; |
| 77 | int def_link; |
| 78 | struct pci_root_info *info; |
| 79 | u32 reg; |
| 80 | struct resource *res; |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 81 | u64 start; |
| 82 | u64 end; |
Yinghai Lu | 27811d8 | 2010-02-10 01:20:07 -0800 | [diff] [blame] | 83 | struct range range[RANGE_NUM]; |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 84 | u64 val; |
| 85 | u32 address; |
Yinghai Lu | 3e3da00 | 2010-02-10 01:20:09 -0800 | [diff] [blame] | 86 | bool found; |
Yinghai Lu | 35ddd06 | 2008-02-19 03:15:08 -0800 | [diff] [blame] | 87 | |
Yinghai Lu | 871d5f8 | 2008-02-19 03:20:09 -0800 | [diff] [blame] | 88 | if (!early_pci_allowed()) |
| 89 | return -1; |
| 90 | |
Yinghai Lu | 3e3da00 | 2010-02-10 01:20:09 -0800 | [diff] [blame] | 91 | found = false; |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 92 | for (i = 0; i < ARRAY_SIZE(pci_probes); i++) { |
| 93 | u32 id; |
| 94 | u16 device; |
| 95 | u16 vendor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 97 | bus = pci_probes[i].bus; |
| 98 | slot = pci_probes[i].slot; |
| 99 | id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID); |
Yinghai Lu | 35ddd06 | 2008-02-19 03:15:08 -0800 | [diff] [blame] | 100 | |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 101 | vendor = id & 0xffff; |
| 102 | device = (id>>16) & 0xffff; |
| 103 | if (pci_probes[i].vendor == vendor && |
| 104 | pci_probes[i].device == device) { |
Yinghai Lu | 3e3da00 | 2010-02-10 01:20:09 -0800 | [diff] [blame] | 105 | found = true; |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 106 | break; |
| 107 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Yinghai Lu | 3e3da00 | 2010-02-10 01:20:09 -0800 | [diff] [blame] | 110 | if (!found) |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 111 | return 0; |
| 112 | |
| 113 | pci_root_num = 0; |
| 114 | for (i = 0; i < 4; i++) { |
| 115 | int min_bus; |
| 116 | int max_bus; |
| 117 | reg = read_pci_config(bus, slot, 1, 0xe0 + (i << 2)); |
| 118 | |
| 119 | /* Check if that register is enabled for bus range */ |
| 120 | if ((reg & 7) != 3) |
| 121 | continue; |
| 122 | |
| 123 | min_bus = (reg >> 16) & 0xff; |
| 124 | max_bus = (reg >> 24) & 0xff; |
| 125 | node = (reg >> 4) & 0x07; |
| 126 | #ifdef CONFIG_NUMA |
| 127 | for (j = min_bus; j <= max_bus; j++) |
Jesse Barnes | 2547089 | 2009-07-10 14:04:30 -0700 | [diff] [blame] | 128 | set_mp_bus_to_node(j, node); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 129 | #endif |
| 130 | link = (reg >> 8) & 0x03; |
| 131 | |
| 132 | info = &pci_root_info[pci_root_num]; |
| 133 | info->bus_min = min_bus; |
| 134 | info->bus_max = max_bus; |
| 135 | info->node = node; |
| 136 | info->link = link; |
| 137 | sprintf(info->name, "PCI Bus #%02x", min_bus); |
| 138 | pci_root_num++; |
| 139 | } |
| 140 | |
| 141 | /* get the default node and link for left over res */ |
| 142 | reg = read_pci_config(bus, slot, 0, 0x60); |
| 143 | def_node = (reg >> 8) & 0x07; |
| 144 | reg = read_pci_config(bus, slot, 0, 0x64); |
| 145 | def_link = (reg >> 8) & 0x03; |
| 146 | |
| 147 | memset(range, 0, sizeof(range)); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 148 | add_range(range, RANGE_NUM, 0, 0, 0xffff + 1); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 149 | /* io port resource */ |
| 150 | for (i = 0; i < 4; i++) { |
| 151 | reg = read_pci_config(bus, slot, 1, 0xc0 + (i << 3)); |
| 152 | if (!(reg & 3)) |
| 153 | continue; |
| 154 | |
| 155 | start = reg & 0xfff000; |
| 156 | reg = read_pci_config(bus, slot, 1, 0xc4 + (i << 3)); |
| 157 | node = reg & 0x07; |
| 158 | link = (reg >> 4) & 0x03; |
| 159 | end = (reg & 0xfff000) | 0xfff; |
| 160 | |
| 161 | /* find the position */ |
| 162 | for (j = 0; j < pci_root_num; j++) { |
| 163 | info = &pci_root_info[j]; |
| 164 | if (info->node == node && info->link == link) |
| 165 | break; |
| 166 | } |
| 167 | if (j == pci_root_num) |
| 168 | continue; /* not found */ |
| 169 | |
| 170 | info = &pci_root_info[j]; |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 171 | printk(KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n", |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 172 | node, link, start, end); |
Yinghai Lu | e8ee6f0 | 2008-04-13 01:41:58 -0700 | [diff] [blame] | 173 | |
| 174 | /* kernel only handle 16 bit only */ |
| 175 | if (end > 0xffff) |
| 176 | end = 0xffff; |
| 177 | update_res(info, start, end, IORESOURCE_IO, 1); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 178 | subtract_range(range, RANGE_NUM, start, end + 1); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 179 | } |
| 180 | /* add left over io port range to def node/link, [0, 0xffff] */ |
| 181 | /* find the position */ |
| 182 | for (j = 0; j < pci_root_num; j++) { |
| 183 | info = &pci_root_info[j]; |
| 184 | if (info->node == def_node && info->link == def_link) |
| 185 | break; |
| 186 | } |
| 187 | if (j < pci_root_num) { |
| 188 | info = &pci_root_info[j]; |
| 189 | for (i = 0; i < RANGE_NUM; i++) { |
| 190 | if (!range[i].end) |
| 191 | continue; |
| 192 | |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 193 | update_res(info, range[i].start, range[i].end - 1, |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 194 | IORESOURCE_IO, 1); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | memset(range, 0, sizeof(range)); |
| 199 | /* 0xfd00000000-0xffffffffff for HT */ |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 200 | end = cap_resource((0xfdULL<<32) - 1); |
| 201 | end++; |
| 202 | add_range(range, RANGE_NUM, 0, 0, end); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 203 | |
| 204 | /* need to take out [0, TOM) for RAM*/ |
| 205 | address = MSR_K8_TOP_MEM1; |
| 206 | rdmsrl(address, val); |
Yinghai Lu | 8004dd9 | 2008-05-12 17:40:39 -0700 | [diff] [blame] | 207 | end = (val & 0xffffff800000ULL); |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 208 | printk(KERN_INFO "TOM: %016llx aka %lldM\n", end, end>>20); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 209 | if (end < (1ULL<<32)) |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 210 | subtract_range(range, RANGE_NUM, 0, end); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 211 | |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 212 | /* get mmconfig */ |
| 213 | get_pci_mmcfg_amd_fam10h_range(); |
| 214 | /* need to take out mmconf range */ |
| 215 | if (fam10h_mmconf_end) { |
| 216 | printk(KERN_DEBUG "Fam 10h mmconf [%llx, %llx]\n", fam10h_mmconf_start, fam10h_mmconf_end); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 217 | subtract_range(range, RANGE_NUM, fam10h_mmconf_start, |
| 218 | fam10h_mmconf_end + 1); |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 221 | /* mmio resource */ |
| 222 | for (i = 0; i < 8; i++) { |
| 223 | reg = read_pci_config(bus, slot, 1, 0x80 + (i << 3)); |
| 224 | if (!(reg & 3)) |
| 225 | continue; |
| 226 | |
| 227 | start = reg & 0xffffff00; /* 39:16 on 31:8*/ |
| 228 | start <<= 8; |
| 229 | reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3)); |
| 230 | node = reg & 0x07; |
| 231 | link = (reg >> 4) & 0x03; |
| 232 | end = (reg & 0xffffff00); |
| 233 | end <<= 8; |
| 234 | end |= 0xffff; |
| 235 | |
| 236 | /* find the position */ |
| 237 | for (j = 0; j < pci_root_num; j++) { |
| 238 | info = &pci_root_info[j]; |
| 239 | if (info->node == node && info->link == link) |
| 240 | break; |
| 241 | } |
| 242 | if (j == pci_root_num) |
| 243 | continue; /* not found */ |
| 244 | |
| 245 | info = &pci_root_info[j]; |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 246 | |
| 247 | printk(KERN_DEBUG "node %d link %d: mmio [%llx, %llx]", |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 248 | node, link, start, end); |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 249 | /* |
| 250 | * some sick allocation would have range overlap with fam10h |
| 251 | * mmconf range, so need to update start and end. |
| 252 | */ |
| 253 | if (fam10h_mmconf_end) { |
| 254 | int changed = 0; |
| 255 | u64 endx = 0; |
| 256 | if (start >= fam10h_mmconf_start && |
| 257 | start <= fam10h_mmconf_end) { |
| 258 | start = fam10h_mmconf_end + 1; |
| 259 | changed = 1; |
| 260 | } |
| 261 | |
| 262 | if (end >= fam10h_mmconf_start && |
| 263 | end <= fam10h_mmconf_end) { |
| 264 | end = fam10h_mmconf_start - 1; |
| 265 | changed = 1; |
| 266 | } |
| 267 | |
| 268 | if (start < fam10h_mmconf_start && |
| 269 | end > fam10h_mmconf_end) { |
| 270 | /* we got a hole */ |
| 271 | endx = fam10h_mmconf_start - 1; |
| 272 | update_res(info, start, endx, IORESOURCE_MEM, 0); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 273 | subtract_range(range, RANGE_NUM, start, |
| 274 | endx + 1); |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 275 | printk(KERN_CONT " ==> [%llx, %llx]", start, endx); |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 276 | start = fam10h_mmconf_end + 1; |
| 277 | changed = 1; |
| 278 | } |
| 279 | if (changed) { |
| 280 | if (start <= end) { |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 281 | printk(KERN_CONT " %s [%llx, %llx]", endx ? "and" : "==>", start, end); |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 282 | } else { |
| 283 | printk(KERN_CONT "%s\n", endx?"":" ==> none"); |
| 284 | continue; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
Yinghai Lu | 9ad3f2c | 2010-02-10 01:20:11 -0800 | [diff] [blame] | 289 | update_res(info, cap_resource(start), cap_resource(end), |
| 290 | IORESOURCE_MEM, 1); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 291 | subtract_range(range, RANGE_NUM, start, end + 1); |
Yinghai Lu | 6e184f2 | 2008-03-06 01:15:31 -0800 | [diff] [blame] | 292 | printk(KERN_CONT "\n"); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | /* need to take out [4G, TOM2) for RAM*/ |
| 296 | /* SYS_CFG */ |
| 297 | address = MSR_K8_SYSCFG; |
| 298 | rdmsrl(address, val); |
| 299 | /* TOP_MEM2 is enabled? */ |
| 300 | if (val & (1<<21)) { |
| 301 | /* TOP_MEM2 */ |
| 302 | address = MSR_K8_TOP_MEM2; |
| 303 | rdmsrl(address, val); |
Yinghai Lu | 8004dd9 | 2008-05-12 17:40:39 -0700 | [diff] [blame] | 304 | end = (val & 0xffffff800000ULL); |
Yinghai Lu | 97445c3 | 2010-02-10 01:20:10 -0800 | [diff] [blame] | 305 | printk(KERN_INFO "TOM2: %016llx aka %lldM\n", end, end>>20); |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 306 | subtract_range(range, RANGE_NUM, 1ULL<<32, end); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | /* |
| 310 | * add left over mmio range to def node/link ? |
| 311 | * that is tricky, just record range in from start_min to 4G |
| 312 | */ |
| 313 | for (j = 0; j < pci_root_num; j++) { |
| 314 | info = &pci_root_info[j]; |
| 315 | if (info->node == def_node && info->link == def_link) |
| 316 | break; |
| 317 | } |
| 318 | if (j < pci_root_num) { |
| 319 | info = &pci_root_info[j]; |
| 320 | |
| 321 | for (i = 0; i < RANGE_NUM; i++) { |
| 322 | if (!range[i].end) |
| 323 | continue; |
| 324 | |
Yinghai Lu | 9ad3f2c | 2010-02-10 01:20:11 -0800 | [diff] [blame] | 325 | update_res(info, cap_resource(range[i].start), |
Yinghai Lu | e9a0064 | 2010-02-10 01:20:13 -0800 | [diff] [blame] | 326 | cap_resource(range[i].end - 1), |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 327 | IORESOURCE_MEM, 1); |
| 328 | } |
| 329 | } |
| 330 | |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 331 | for (i = 0; i < pci_root_num; i++) { |
| 332 | int res_num; |
| 333 | int busnum; |
| 334 | |
| 335 | info = &pci_root_info[i]; |
| 336 | res_num = info->res_num; |
| 337 | busnum = info->bus_min; |
Yinghai Lu | 99935a7 | 2009-10-04 21:54:24 -0700 | [diff] [blame] | 338 | printk(KERN_DEBUG "bus: [%02x, %02x] on node %x link %x\n", |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 339 | info->bus_min, info->bus_max, info->node, info->link); |
| 340 | for (j = 0; j < res_num; j++) { |
| 341 | res = &info->res[j]; |
Yinghai Lu | 284f933 | 2010-02-10 01:20:12 -0800 | [diff] [blame] | 342 | printk(KERN_DEBUG "bus: %02x index %x %pR\n", |
| 343 | busnum, j, res); |
Yinghai Lu | 30a18d6 | 2008-02-19 03:21:20 -0800 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | return 0; |
| 348 | } |
| 349 | |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 350 | #define ENABLE_CF8_EXT_CFG (1ULL << 46) |
| 351 | |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 352 | static void enable_pci_io_ecs(void *unused) |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 353 | { |
| 354 | u64 reg; |
| 355 | rdmsrl(MSR_AMD64_NB_CFG, reg); |
| 356 | if (!(reg & ENABLE_CF8_EXT_CFG)) { |
| 357 | reg |= ENABLE_CF8_EXT_CFG; |
| 358 | wrmsrl(MSR_AMD64_NB_CFG, reg); |
| 359 | } |
| 360 | } |
| 361 | |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 362 | static int __cpuinit amd_cpu_notify(struct notifier_block *self, |
| 363 | unsigned long action, void *hcpu) |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 364 | { |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 365 | int cpu = (long)hcpu; |
Robert Richter | ed21763 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 366 | switch (action) { |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 367 | case CPU_ONLINE: |
| 368 | case CPU_ONLINE_FROZEN: |
| 369 | smp_call_function_single(cpu, enable_pci_io_ecs, NULL, 0); |
| 370 | break; |
| 371 | default: |
| 372 | break; |
| 373 | } |
| 374 | return NOTIFY_OK; |
| 375 | } |
| 376 | |
| 377 | static struct notifier_block __cpuinitdata amd_cpu_notifier = { |
| 378 | .notifier_call = amd_cpu_notify, |
| 379 | }; |
| 380 | |
| 381 | static int __init pci_io_ecs_init(void) |
| 382 | { |
| 383 | int cpu; |
| 384 | |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 385 | /* assume all cpus from fam10h have IO ECS */ |
| 386 | if (boot_cpu_data.x86 < 0x10) |
| 387 | return 0; |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 388 | |
| 389 | register_cpu_notifier(&amd_cpu_notifier); |
| 390 | for_each_online_cpu(cpu) |
| 391 | amd_cpu_notify(&amd_cpu_notifier, (unsigned long)CPU_ONLINE, |
| 392 | (void *)(long)cpu); |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 393 | pci_probe |= PCI_HAS_IO_ECS; |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 394 | |
Robert Richter | 3a27dd1 | 2008-06-12 20:19:23 +0200 | [diff] [blame] | 395 | return 0; |
| 396 | } |
| 397 | |
Robert Richter | 9b4e27b | 2008-08-22 20:23:37 +0200 | [diff] [blame] | 398 | static int __init amd_postcore_init(void) |
| 399 | { |
| 400 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
| 401 | return 0; |
| 402 | |
| 403 | early_fill_mp_bus_info(); |
Robert Richter | 91ede00 | 2008-08-22 20:23:38 +0200 | [diff] [blame] | 404 | pci_io_ecs_init(); |
Robert Richter | 9b4e27b | 2008-08-22 20:23:37 +0200 | [diff] [blame] | 405 | |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | postcore_initcall(amd_postcore_init); |