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