| .. | .. |
|---|
| 18 | 18 | #include <linux/export.h> |
|---|
| 19 | 19 | #include <linux/nodemask.h> |
|---|
| 20 | 20 | #include <linux/swap.h> |
|---|
| 21 | | -#include <linux/bootmem.h> |
|---|
| 22 | 21 | #include <linux/pfn.h> |
|---|
| 23 | 22 | #include <linux/highmem.h> |
|---|
| 24 | 23 | #include <asm/page.h> |
|---|
| .. | .. |
|---|
| 26 | 25 | #include <asm/sections.h> |
|---|
| 27 | 26 | |
|---|
| 28 | 27 | #include <asm/sn/arch.h> |
|---|
| 29 | | -#include <asm/sn/hub.h> |
|---|
| 28 | +#include <asm/sn/agent.h> |
|---|
| 30 | 29 | #include <asm/sn/klconfig.h> |
|---|
| 31 | | -#include <asm/sn/sn_private.h> |
|---|
| 32 | 30 | |
|---|
| 31 | +#include "ip27-common.h" |
|---|
| 33 | 32 | |
|---|
| 34 | 33 | #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) |
|---|
| 35 | 34 | #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) |
|---|
| 36 | 35 | |
|---|
| 37 | | -struct node_data *__node_data[MAX_COMPACT_NODES]; |
|---|
| 36 | +struct node_data *__node_data[MAX_NUMNODES]; |
|---|
| 38 | 37 | |
|---|
| 39 | 38 | EXPORT_SYMBOL(__node_data); |
|---|
| 40 | 39 | |
|---|
| 41 | | -static int fine_mode; |
|---|
| 42 | | - |
|---|
| 43 | | -static int is_fine_dirmode(void) |
|---|
| 40 | +static u64 gen_region_mask(void) |
|---|
| 44 | 41 | { |
|---|
| 45 | | - return ((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK) >> NSRI_REGIONSIZE_SHFT) & REGIONSIZE_FINE; |
|---|
| 46 | | -} |
|---|
| 42 | + int region_shift; |
|---|
| 43 | + u64 region_mask; |
|---|
| 44 | + nasid_t nasid; |
|---|
| 47 | 45 | |
|---|
| 48 | | -static hubreg_t get_region(cnodeid_t cnode) |
|---|
| 49 | | -{ |
|---|
| 50 | | - if (fine_mode) |
|---|
| 51 | | - return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_FINEREG_SHFT; |
|---|
| 52 | | - else |
|---|
| 53 | | - return COMPACT_TO_NASID_NODEID(cnode) >> NASID_TO_COARSEREG_SHFT; |
|---|
| 54 | | -} |
|---|
| 46 | + region_shift = get_region_shift(); |
|---|
| 47 | + region_mask = 0; |
|---|
| 48 | + for_each_online_node(nasid) |
|---|
| 49 | + region_mask |= BIT_ULL(nasid >> region_shift); |
|---|
| 55 | 50 | |
|---|
| 56 | | -static hubreg_t region_mask; |
|---|
| 57 | | - |
|---|
| 58 | | -static void gen_region_mask(hubreg_t *region_mask) |
|---|
| 59 | | -{ |
|---|
| 60 | | - cnodeid_t cnode; |
|---|
| 61 | | - |
|---|
| 62 | | - (*region_mask) = 0; |
|---|
| 63 | | - for_each_online_node(cnode) { |
|---|
| 64 | | - (*region_mask) |= 1ULL << get_region(cnode); |
|---|
| 65 | | - } |
|---|
| 51 | + return region_mask; |
|---|
| 66 | 52 | } |
|---|
| 67 | 53 | |
|---|
| 68 | 54 | #define rou_rflag rou_flags |
|---|
| .. | .. |
|---|
| 105 | 91 | router_a->rou_rflag = 0; |
|---|
| 106 | 92 | } |
|---|
| 107 | 93 | |
|---|
| 108 | | -unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES]; |
|---|
| 94 | +unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; |
|---|
| 109 | 95 | EXPORT_SYMBOL(__node_distances); |
|---|
| 110 | 96 | |
|---|
| 111 | 97 | static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b) |
|---|
| 112 | 98 | { |
|---|
| 113 | 99 | klrou_t *router, *router_a = NULL, *router_b = NULL; |
|---|
| 114 | 100 | lboard_t *brd, *dest_brd; |
|---|
| 115 | | - cnodeid_t cnode; |
|---|
| 116 | 101 | nasid_t nasid; |
|---|
| 117 | 102 | int port; |
|---|
| 118 | 103 | |
|---|
| 119 | 104 | /* Figure out which routers nodes in question are connected to */ |
|---|
| 120 | | - for_each_online_node(cnode) { |
|---|
| 121 | | - nasid = COMPACT_TO_NASID_NODEID(cnode); |
|---|
| 122 | | - |
|---|
| 123 | | - if (nasid == -1) continue; |
|---|
| 124 | | - |
|---|
| 105 | + for_each_online_node(nasid) { |
|---|
| 125 | 106 | brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid), |
|---|
| 126 | 107 | KLTYPE_ROUTER); |
|---|
| 127 | 108 | |
|---|
| .. | .. |
|---|
| 154 | 135 | } while ((brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER))); |
|---|
| 155 | 136 | } |
|---|
| 156 | 137 | |
|---|
| 157 | | - if (router_a == NULL) { |
|---|
| 158 | | - printk("node_distance: router_a NULL\n"); |
|---|
| 159 | | - return -1; |
|---|
| 160 | | - } |
|---|
| 161 | | - if (router_b == NULL) { |
|---|
| 162 | | - printk("node_distance: router_b NULL\n"); |
|---|
| 163 | | - return -1; |
|---|
| 164 | | - } |
|---|
| 165 | | - |
|---|
| 166 | 138 | if (nasid_a == nasid_b) |
|---|
| 167 | | - return 0; |
|---|
| 139 | + return LOCAL_DISTANCE; |
|---|
| 168 | 140 | |
|---|
| 169 | 141 | if (router_a == router_b) |
|---|
| 170 | | - return 1; |
|---|
| 142 | + return LOCAL_DISTANCE + 1; |
|---|
| 143 | + |
|---|
| 144 | + if (router_a == NULL) { |
|---|
| 145 | + pr_info("node_distance: router_a NULL\n"); |
|---|
| 146 | + return 255; |
|---|
| 147 | + } |
|---|
| 148 | + if (router_b == NULL) { |
|---|
| 149 | + pr_info("node_distance: router_b NULL\n"); |
|---|
| 150 | + return 255; |
|---|
| 151 | + } |
|---|
| 171 | 152 | |
|---|
| 172 | 153 | router_distance = 100; |
|---|
| 173 | 154 | router_recurse(router_a, router_b, 2); |
|---|
| 174 | 155 | |
|---|
| 175 | | - return router_distance; |
|---|
| 156 | + return LOCAL_DISTANCE + router_distance; |
|---|
| 176 | 157 | } |
|---|
| 177 | 158 | |
|---|
| 178 | 159 | static void __init init_topology_matrix(void) |
|---|
| 179 | 160 | { |
|---|
| 180 | | - nasid_t nasid, nasid2; |
|---|
| 181 | | - cnodeid_t row, col; |
|---|
| 161 | + nasid_t row, col; |
|---|
| 182 | 162 | |
|---|
| 183 | | - for (row = 0; row < MAX_COMPACT_NODES; row++) |
|---|
| 184 | | - for (col = 0; col < MAX_COMPACT_NODES; col++) |
|---|
| 163 | + for (row = 0; row < MAX_NUMNODES; row++) |
|---|
| 164 | + for (col = 0; col < MAX_NUMNODES; col++) |
|---|
| 185 | 165 | __node_distances[row][col] = -1; |
|---|
| 186 | 166 | |
|---|
| 187 | 167 | for_each_online_node(row) { |
|---|
| 188 | | - nasid = COMPACT_TO_NASID_NODEID(row); |
|---|
| 189 | 168 | for_each_online_node(col) { |
|---|
| 190 | | - nasid2 = COMPACT_TO_NASID_NODEID(col); |
|---|
| 191 | 169 | __node_distances[row][col] = |
|---|
| 192 | | - compute_node_distance(nasid, nasid2); |
|---|
| 170 | + compute_node_distance(row, col); |
|---|
| 193 | 171 | } |
|---|
| 194 | 172 | } |
|---|
| 195 | 173 | } |
|---|
| .. | .. |
|---|
| 197 | 175 | static void __init dump_topology(void) |
|---|
| 198 | 176 | { |
|---|
| 199 | 177 | nasid_t nasid; |
|---|
| 200 | | - cnodeid_t cnode; |
|---|
| 201 | 178 | lboard_t *brd, *dest_brd; |
|---|
| 202 | 179 | int port; |
|---|
| 203 | 180 | int router_num = 0; |
|---|
| 204 | 181 | klrou_t *router; |
|---|
| 205 | | - cnodeid_t row, col; |
|---|
| 182 | + nasid_t row, col; |
|---|
| 206 | 183 | |
|---|
| 207 | | - printk("************** Topology ********************\n"); |
|---|
| 184 | + pr_info("************** Topology ********************\n"); |
|---|
| 208 | 185 | |
|---|
| 209 | | - printk(" "); |
|---|
| 186 | + pr_info(" "); |
|---|
| 210 | 187 | for_each_online_node(col) |
|---|
| 211 | | - printk("%02d ", col); |
|---|
| 212 | | - printk("\n"); |
|---|
| 188 | + pr_cont("%02d ", col); |
|---|
| 189 | + pr_cont("\n"); |
|---|
| 213 | 190 | for_each_online_node(row) { |
|---|
| 214 | | - printk("%02d ", row); |
|---|
| 191 | + pr_info("%02d ", row); |
|---|
| 215 | 192 | for_each_online_node(col) |
|---|
| 216 | | - printk("%2d ", node_distance(row, col)); |
|---|
| 217 | | - printk("\n"); |
|---|
| 193 | + pr_cont("%2d ", node_distance(row, col)); |
|---|
| 194 | + pr_cont("\n"); |
|---|
| 218 | 195 | } |
|---|
| 219 | 196 | |
|---|
| 220 | | - for_each_online_node(cnode) { |
|---|
| 221 | | - nasid = COMPACT_TO_NASID_NODEID(cnode); |
|---|
| 222 | | - |
|---|
| 223 | | - if (nasid == -1) continue; |
|---|
| 224 | | - |
|---|
| 197 | + for_each_online_node(nasid) { |
|---|
| 225 | 198 | brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid), |
|---|
| 226 | 199 | KLTYPE_ROUTER); |
|---|
| 227 | 200 | |
|---|
| .. | .. |
|---|
| 231 | 204 | do { |
|---|
| 232 | 205 | if (brd->brd_flags & DUPLICATE_BOARD) |
|---|
| 233 | 206 | continue; |
|---|
| 234 | | - printk("Router %d:", router_num); |
|---|
| 207 | + pr_cont("Router %d:", router_num); |
|---|
| 235 | 208 | router_num++; |
|---|
| 236 | 209 | |
|---|
| 237 | 210 | router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd), brd->brd_compts[0]); |
|---|
| .. | .. |
|---|
| 245 | 218 | router->rou_port[port].port_offset); |
|---|
| 246 | 219 | |
|---|
| 247 | 220 | if (dest_brd->brd_type == KLTYPE_IP27) |
|---|
| 248 | | - printk(" %d", dest_brd->brd_nasid); |
|---|
| 221 | + pr_cont(" %d", dest_brd->brd_nasid); |
|---|
| 249 | 222 | if (dest_brd->brd_type == KLTYPE_ROUTER) |
|---|
| 250 | | - printk(" r"); |
|---|
| 223 | + pr_cont(" r"); |
|---|
| 251 | 224 | } |
|---|
| 252 | | - printk("\n"); |
|---|
| 225 | + pr_cont("\n"); |
|---|
| 253 | 226 | |
|---|
| 254 | 227 | } while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) ); |
|---|
| 255 | 228 | } |
|---|
| 256 | 229 | } |
|---|
| 257 | 230 | |
|---|
| 258 | | -static unsigned long __init slot_getbasepfn(cnodeid_t cnode, int slot) |
|---|
| 231 | +static unsigned long __init slot_getbasepfn(nasid_t nasid, int slot) |
|---|
| 259 | 232 | { |
|---|
| 260 | | - nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); |
|---|
| 261 | | - |
|---|
| 262 | 233 | return ((unsigned long)nasid << PFN_NASIDSHFT) | (slot << SLOT_PFNSHIFT); |
|---|
| 263 | 234 | } |
|---|
| 264 | 235 | |
|---|
| 265 | | -static unsigned long __init slot_psize_compute(cnodeid_t node, int slot) |
|---|
| 236 | +static unsigned long __init slot_psize_compute(nasid_t nasid, int slot) |
|---|
| 266 | 237 | { |
|---|
| 267 | | - nasid_t nasid; |
|---|
| 268 | 238 | lboard_t *brd; |
|---|
| 269 | 239 | klmembnk_t *banks; |
|---|
| 270 | 240 | unsigned long size; |
|---|
| 271 | 241 | |
|---|
| 272 | | - nasid = COMPACT_TO_NASID_NODEID(node); |
|---|
| 273 | 242 | /* Find the node board */ |
|---|
| 274 | 243 | brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27); |
|---|
| 275 | 244 | if (!brd) |
|---|
| .. | .. |
|---|
| 299 | 268 | |
|---|
| 300 | 269 | static void __init mlreset(void) |
|---|
| 301 | 270 | { |
|---|
| 302 | | - int i; |
|---|
| 271 | + u64 region_mask; |
|---|
| 272 | + nasid_t nasid; |
|---|
| 303 | 273 | |
|---|
| 304 | 274 | master_nasid = get_nasid(); |
|---|
| 305 | | - fine_mode = is_fine_dirmode(); |
|---|
| 306 | 275 | |
|---|
| 307 | 276 | /* |
|---|
| 308 | 277 | * Probe for all CPUs - this creates the cpumask and sets up the |
|---|
| .. | .. |
|---|
| 315 | 284 | init_topology_matrix(); |
|---|
| 316 | 285 | dump_topology(); |
|---|
| 317 | 286 | |
|---|
| 318 | | - gen_region_mask(®ion_mask); |
|---|
| 287 | + region_mask = gen_region_mask(); |
|---|
| 319 | 288 | |
|---|
| 320 | 289 | setup_replication_mask(); |
|---|
| 321 | 290 | |
|---|
| 322 | 291 | /* |
|---|
| 323 | 292 | * Set all nodes' calias sizes to 8k |
|---|
| 324 | 293 | */ |
|---|
| 325 | | - for_each_online_node(i) { |
|---|
| 326 | | - nasid_t nasid; |
|---|
| 327 | | - |
|---|
| 328 | | - nasid = COMPACT_TO_NASID_NODEID(i); |
|---|
| 329 | | - |
|---|
| 294 | + for_each_online_node(nasid) { |
|---|
| 330 | 295 | /* |
|---|
| 331 | 296 | * Always have node 0 in the region mask, otherwise |
|---|
| 332 | 297 | * CALIAS accesses get exceptions since the hub |
|---|
| 333 | 298 | * thinks it is a node 0 address. |
|---|
| 334 | 299 | */ |
|---|
| 335 | 300 | REMOTE_HUB_S(nasid, PI_REGION_PRESENT, (region_mask | 1)); |
|---|
| 336 | | -#ifdef CONFIG_REPLICATE_EXHANDLERS |
|---|
| 337 | | - REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K); |
|---|
| 338 | | -#else |
|---|
| 339 | 301 | REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_0); |
|---|
| 340 | | -#endif |
|---|
| 341 | 302 | |
|---|
| 342 | 303 | #ifdef LATER |
|---|
| 343 | 304 | /* |
|---|
| .. | .. |
|---|
| 355 | 316 | { |
|---|
| 356 | 317 | unsigned long slot_psize, slot0sz = 0, nodebytes; /* Hack to detect problem configs */ |
|---|
| 357 | 318 | int slot; |
|---|
| 358 | | - cnodeid_t node; |
|---|
| 319 | + nasid_t node; |
|---|
| 359 | 320 | |
|---|
| 360 | 321 | for_each_online_node(node) { |
|---|
| 361 | 322 | nodebytes = 0; |
|---|
| .. | .. |
|---|
| 374 | 335 | |
|---|
| 375 | 336 | if ((nodebytes >> PAGE_SHIFT) * (sizeof(struct page)) > |
|---|
| 376 | 337 | (slot0sz << PAGE_SHIFT)) { |
|---|
| 377 | | - printk("Ignoring slot %d onwards on node %d\n", |
|---|
| 338 | + pr_info("Ignoring slot %d onwards on node %d\n", |
|---|
| 378 | 339 | slot, node); |
|---|
| 379 | 340 | slot = MAX_MEM_SLOTS; |
|---|
| 380 | 341 | continue; |
|---|
| .. | .. |
|---|
| 385 | 346 | } |
|---|
| 386 | 347 | } |
|---|
| 387 | 348 | |
|---|
| 388 | | -static void __init node_mem_init(cnodeid_t node) |
|---|
| 349 | +static void __init node_mem_init(nasid_t node) |
|---|
| 389 | 350 | { |
|---|
| 390 | 351 | unsigned long slot_firstpfn = slot_getbasepfn(node, 0); |
|---|
| 391 | 352 | unsigned long slot_freepfn = node_getfirstfree(node); |
|---|
| 392 | | - unsigned long bootmap_size; |
|---|
| 393 | 353 | unsigned long start_pfn, end_pfn; |
|---|
| 394 | 354 | |
|---|
| 395 | 355 | get_pfn_range_for_nid(node, &start_pfn, &end_pfn); |
|---|
| .. | .. |
|---|
| 400 | 360 | __node_data[node] = __va(slot_freepfn << PAGE_SHIFT); |
|---|
| 401 | 361 | memset(__node_data[node], 0, PAGE_SIZE); |
|---|
| 402 | 362 | |
|---|
| 403 | | - NODE_DATA(node)->bdata = &bootmem_node_data[node]; |
|---|
| 404 | 363 | NODE_DATA(node)->node_start_pfn = start_pfn; |
|---|
| 405 | 364 | NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; |
|---|
| 406 | 365 | |
|---|
| .. | .. |
|---|
| 409 | 368 | slot_freepfn += PFN_UP(sizeof(struct pglist_data) + |
|---|
| 410 | 369 | sizeof(struct hub_data)); |
|---|
| 411 | 370 | |
|---|
| 412 | | - bootmap_size = init_bootmem_node(NODE_DATA(node), slot_freepfn, |
|---|
| 413 | | - start_pfn, end_pfn); |
|---|
| 414 | | - free_bootmem_with_active_regions(node, end_pfn); |
|---|
| 415 | | - reserve_bootmem_node(NODE_DATA(node), slot_firstpfn << PAGE_SHIFT, |
|---|
| 416 | | - ((slot_freepfn - slot_firstpfn) << PAGE_SHIFT) + bootmap_size, |
|---|
| 417 | | - BOOTMEM_DEFAULT); |
|---|
| 418 | | - sparse_memory_present_with_active_regions(node); |
|---|
| 371 | + memblock_reserve(slot_firstpfn << PAGE_SHIFT, |
|---|
| 372 | + ((slot_freepfn - slot_firstpfn) << PAGE_SHIFT)); |
|---|
| 419 | 373 | } |
|---|
| 420 | 374 | |
|---|
| 421 | 375 | /* |
|---|
| .. | .. |
|---|
| 435 | 389 | */ |
|---|
| 436 | 390 | void __init prom_meminit(void) |
|---|
| 437 | 391 | { |
|---|
| 438 | | - cnodeid_t node; |
|---|
| 392 | + nasid_t node; |
|---|
| 439 | 393 | |
|---|
| 440 | 394 | mlreset(); |
|---|
| 441 | 395 | szmem(); |
|---|
| 396 | + max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); |
|---|
| 442 | 397 | |
|---|
| 443 | | - for (node = 0; node < MAX_COMPACT_NODES; node++) { |
|---|
| 398 | + for (node = 0; node < MAX_NUMNODES; node++) { |
|---|
| 444 | 399 | if (node_online(node)) { |
|---|
| 445 | 400 | node_mem_init(node); |
|---|
| 446 | 401 | continue; |
|---|
| .. | .. |
|---|
| 459 | 414 | void __init paging_init(void) |
|---|
| 460 | 415 | { |
|---|
| 461 | 416 | unsigned long zones_size[MAX_NR_ZONES] = {0, }; |
|---|
| 462 | | - unsigned node; |
|---|
| 463 | 417 | |
|---|
| 464 | 418 | pagetable_init(); |
|---|
| 465 | | - |
|---|
| 466 | | - for_each_online_node(node) { |
|---|
| 467 | | - unsigned long start_pfn, end_pfn; |
|---|
| 468 | | - |
|---|
| 469 | | - get_pfn_range_for_nid(node, &start_pfn, &end_pfn); |
|---|
| 470 | | - |
|---|
| 471 | | - if (end_pfn > max_low_pfn) |
|---|
| 472 | | - max_low_pfn = end_pfn; |
|---|
| 473 | | - } |
|---|
| 474 | 419 | zones_size[ZONE_NORMAL] = max_low_pfn; |
|---|
| 475 | | - free_area_init_nodes(zones_size); |
|---|
| 420 | + free_area_init(zones_size); |
|---|
| 476 | 421 | } |
|---|
| 477 | 422 | |
|---|
| 478 | 423 | void __init mem_init(void) |
|---|
| 479 | 424 | { |
|---|
| 480 | 425 | high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT); |
|---|
| 481 | | - free_all_bootmem(); |
|---|
| 426 | + memblock_free_all(); |
|---|
| 482 | 427 | setup_zero_pages(); /* This comes from node 0 */ |
|---|
| 483 | 428 | mem_init_print_info(NULL); |
|---|
| 484 | 429 | } |
|---|