Merge branch 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86, UV, BAU: Extend for more than 16 cpus per socket
x86, UV: Fix the effect of extra bits in the hub nodeid register
x86, UV: Add common uv_early_read_mmr() function for reading MMRs

+57 -35
+5 -4
arch/x86/include/asm/uv/uv_bau.h
··· 26 26 * BAU_SB_DESCRIPTOR_BASE register, set 1 is located at BASE + 512, 27 27 * set 2 is at BASE + 2*512, set 3 at BASE + 3*512, and so on. 28 28 * 29 - * We will use 31 sets, one for sending BAU messages from each of the 32 29 + * We will use one set for sending BAU messages from each of the 30 30 * cpu's on the uvhub. 31 31 * 32 32 * TLB shootdown will use the first of the 8 descriptors of each set. 33 33 * Each of the descriptors is 64 bytes in size (8*64 = 512 bytes in a set). 34 34 */ 35 35 36 + #define MAX_CPUS_PER_UVHUB 64 37 + #define MAX_CPUS_PER_SOCKET 32 38 + #define UV_ADP_SIZE 64 /* hardware-provided max. */ 39 + #define UV_CPUS_PER_ACT_STATUS 32 /* hardware-provided max. */ 36 40 #define UV_ITEMS_PER_DESCRIPTOR 8 37 41 /* the 'throttle' to prevent the hardware stay-busy bug */ 38 42 #define MAX_BAU_CONCURRENT 3 39 - #define UV_CPUS_PER_ACT_STATUS 32 40 43 #define UV_ACT_STATUS_MASK 0x3 41 44 #define UV_ACT_STATUS_SIZE 2 42 - #define UV_ADP_SIZE 32 43 45 #define UV_DISTRIBUTION_SIZE 256 44 46 #define UV_SW_ACK_NPENDING 8 45 47 #define UV_NET_ENDPOINT_INTD 0x38 ··· 102 100 * number of destination side software ack resources 103 101 */ 104 102 #define DEST_NUM_RESOURCES 8 105 - #define MAX_CPUS_PER_NODE 32 106 103 /* 107 104 * completion statuses for sending a TLB flush message 108 105 */
+34 -27
arch/x86/kernel/apic/x2apic_uv_x.c
··· 48 48 EXPORT_SYMBOL_GPL(uv_apicid_hibits); 49 49 static DEFINE_SPINLOCK(uv_nmi_lock); 50 50 51 + static unsigned long __init uv_early_read_mmr(unsigned long addr) 52 + { 53 + unsigned long val, *mmr; 54 + 55 + mmr = early_ioremap(UV_LOCAL_MMR_BASE | addr, sizeof(*mmr)); 56 + val = *mmr; 57 + early_iounmap(mmr, sizeof(*mmr)); 58 + return val; 59 + } 60 + 51 61 static inline bool is_GRU_range(u64 start, u64 end) 52 62 { 53 63 return start >= gru_start_paddr && end <= gru_end_paddr; ··· 68 58 return is_ISA_range(start, end) || is_GRU_range(start, end); 69 59 } 70 60 71 - static int early_get_nodeid(void) 61 + static int __init early_get_pnodeid(void) 72 62 { 73 63 union uvh_node_id_u node_id; 74 - unsigned long *mmr; 75 - 76 - mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_NODE_ID, sizeof(*mmr)); 77 - node_id.v = *mmr; 78 - early_iounmap(mmr, sizeof(*mmr)); 64 + union uvh_rh_gam_config_mmr_u m_n_config; 65 + int pnode; 79 66 80 67 /* Currently, all blades have same revision number */ 68 + node_id.v = uv_early_read_mmr(UVH_NODE_ID); 69 + m_n_config.v = uv_early_read_mmr(UVH_RH_GAM_CONFIG_MMR); 81 70 uv_min_hub_revision_id = node_id.s.revision; 82 71 83 - return node_id.s.node_id; 72 + pnode = (node_id.s.node_id >> 1) & ((1 << m_n_config.s.n_skt) - 1); 73 + return pnode; 84 74 } 85 75 86 76 static void __init early_get_apic_pnode_shift(void) 87 77 { 88 - unsigned long *mmr; 89 - 90 - mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_APICID, sizeof(*mmr)); 91 - uvh_apicid.v = *mmr; 92 - early_iounmap(mmr, sizeof(*mmr)); 78 + uvh_apicid.v = uv_early_read_mmr(UVH_APICID); 93 79 if (!uvh_apicid.v) 94 80 /* 95 81 * Old bios, use default value ··· 101 95 static void __init uv_set_apicid_hibit(void) 102 96 { 103 97 union uvh_lb_target_physical_apic_id_mask_u apicid_mask; 104 - unsigned long *mmr; 105 98 106 - mmr = early_ioremap(UV_LOCAL_MMR_BASE | 107 - UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK, sizeof(*mmr)); 108 - apicid_mask.v = *mmr; 109 - early_iounmap(mmr, sizeof(*mmr)); 99 + apicid_mask.v = uv_early_read_mmr(UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK); 110 100 uv_apicid_hibits = apicid_mask.s.bit_enables & UV_APICID_HIBIT_MASK; 111 101 } 112 102 113 103 static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 114 104 { 115 - int nodeid; 105 + int pnodeid; 116 106 117 107 if (!strcmp(oem_id, "SGI")) { 118 - nodeid = early_get_nodeid(); 108 + pnodeid = early_get_pnodeid(); 119 109 early_get_apic_pnode_shift(); 120 110 x86_platform.is_untracked_pat_range = uv_is_untracked_pat_range; 121 111 x86_platform.nmi_init = uv_nmi_init; ··· 121 119 uv_system_type = UV_X2APIC; 122 120 else if (!strcmp(oem_table_id, "UVH")) { 123 121 __get_cpu_var(x2apic_extra_bits) = 124 - nodeid << (uvh_apicid.s.pnode_shift - 1); 122 + pnodeid << uvh_apicid.s.pnode_shift; 125 123 uv_system_type = UV_NON_UNIQUE_APIC; 126 124 uv_set_apicid_hibit(); 127 125 return 1; ··· 684 682 void __init uv_system_init(void) 685 683 { 686 684 union uvh_rh_gam_config_mmr_u m_n_config; 685 + union uvh_rh_gam_mmioh_overlay_config_mmr_u mmioh; 687 686 union uvh_node_id_u node_id; 688 687 unsigned long gnode_upper, lowmem_redir_base, lowmem_redir_size; 689 - int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val; 688 + int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val, n_io; 690 689 int gnode_extra, max_pnode = 0; 691 690 unsigned long mmr_base, present, paddr; 692 - unsigned short pnode_mask; 691 + unsigned short pnode_mask, pnode_io_mask; 693 692 694 693 map_low_mmrs(); 695 694 696 695 m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR ); 697 696 m_val = m_n_config.s.m_skt; 698 697 n_val = m_n_config.s.n_skt; 698 + mmioh.v = uv_read_local_mmr(UVH_RH_GAM_MMIOH_OVERLAY_CONFIG_MMR); 699 + n_io = mmioh.s.n_io; 699 700 mmr_base = 700 701 uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR) & 701 702 ~UV_MMR_ENABLE; 702 703 pnode_mask = (1 << n_val) - 1; 704 + pnode_io_mask = (1 << n_io) - 1; 705 + 703 706 node_id.v = uv_read_local_mmr(UVH_NODE_ID); 704 707 gnode_extra = (node_id.s.node_id & ~((1 << n_val) - 1)) >> 1; 705 708 gnode_upper = ((unsigned long)gnode_extra << m_val); 706 - printk(KERN_DEBUG "UV: N %d, M %d, gnode_upper 0x%lx, gnode_extra 0x%x\n", 707 - n_val, m_val, gnode_upper, gnode_extra); 709 + printk(KERN_INFO "UV: N %d, M %d, N_IO: %d, gnode_upper 0x%lx, gnode_extra 0x%x, pnode_mask 0x%x, pnode_io_mask 0x%x\n", 710 + n_val, m_val, n_io, gnode_upper, gnode_extra, pnode_mask, pnode_io_mask); 708 711 709 712 printk(KERN_DEBUG "UV: global MMR base 0x%lx\n", mmr_base); 710 713 ··· 742 735 for (j = 0; j < 64; j++) { 743 736 if (!test_bit(j, &present)) 744 737 continue; 745 - pnode = (i * 64 + j); 738 + pnode = (i * 64 + j) & pnode_mask; 746 739 uv_blade_info[blade].pnode = pnode; 747 740 uv_blade_info[blade].nr_possible_cpus = 0; 748 741 uv_blade_info[blade].nr_online_cpus = 0; ··· 763 756 /* 764 757 * apic_pnode_shift must be set before calling uv_apicid_to_pnode(); 765 758 */ 759 + uv_cpu_hub_info(cpu)->pnode_mask = pnode_mask; 766 760 uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift; 767 761 pnode = uv_apicid_to_pnode(apicid); 768 762 blade = boot_pnode_to_blade(pnode); ··· 780 772 uv_cpu_hub_info(cpu)->numa_blade_id = blade; 781 773 uv_cpu_hub_info(cpu)->blade_processor_id = lcpu; 782 774 uv_cpu_hub_info(cpu)->pnode = pnode; 783 - uv_cpu_hub_info(cpu)->pnode_mask = pnode_mask; 784 775 uv_cpu_hub_info(cpu)->gpa_mask = (1UL << (m_val + n_val)) - 1; 785 776 uv_cpu_hub_info(cpu)->gnode_upper = gnode_upper; 786 777 uv_cpu_hub_info(cpu)->gnode_extra = gnode_extra; ··· 803 796 804 797 map_gru_high(max_pnode); 805 798 map_mmr_high(max_pnode); 806 - map_mmioh_high(max_pnode); 799 + map_mmioh_high(max_pnode & pnode_io_mask); 807 800 808 801 uv_cpu_init(); 809 802 uv_scir_register_cpu_notifier();
+18 -4
arch/x86/platform/uv/tlb_uv.c
··· 1341 1341 1342 1342 /* 1343 1343 * each bau_desc is 64 bytes; there are 8 (UV_ITEMS_PER_DESCRIPTOR) 1344 - * per cpu; and up to 32 (UV_ADP_SIZE) cpu's per uvhub 1344 + * per cpu; and one per cpu on the uvhub (UV_ADP_SIZE) 1345 1345 */ 1346 1346 bau_desc = kmalloc_node(sizeof(struct bau_desc) * UV_ADP_SIZE 1347 1347 * UV_ITEMS_PER_DESCRIPTOR, GFP_KERNEL, node); ··· 1490 1490 /* 1491 1491 * initialize the bau_control structure for each cpu 1492 1492 */ 1493 - static void __init uv_init_per_cpu(int nuvhubs) 1493 + static int __init uv_init_per_cpu(int nuvhubs) 1494 1494 { 1495 1495 int i; 1496 1496 int cpu; ··· 1507 1507 struct bau_control *smaster = NULL; 1508 1508 struct socket_desc { 1509 1509 short num_cpus; 1510 - short cpu_number[16]; 1510 + short cpu_number[MAX_CPUS_PER_SOCKET]; 1511 1511 }; 1512 1512 struct uvhub_desc { 1513 1513 unsigned short socket_mask; ··· 1540 1540 sdp = &bdp->socket[socket]; 1541 1541 sdp->cpu_number[sdp->num_cpus] = cpu; 1542 1542 sdp->num_cpus++; 1543 + if (sdp->num_cpus > MAX_CPUS_PER_SOCKET) { 1544 + printk(KERN_EMERG "%d cpus per socket invalid\n", sdp->num_cpus); 1545 + return 1; 1546 + } 1543 1547 } 1544 1548 for (uvhub = 0; uvhub < nuvhubs; uvhub++) { 1545 1549 if (!(*(uvhub_mask + (uvhub/8)) & (1 << (uvhub%8)))) ··· 1574 1570 bcp->uvhub_master = hmaster; 1575 1571 bcp->uvhub_cpu = uv_cpu_hub_info(cpu)-> 1576 1572 blade_processor_id; 1573 + if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) { 1574 + printk(KERN_EMERG 1575 + "%d cpus per uvhub invalid\n", 1576 + bcp->uvhub_cpu); 1577 + return 1; 1578 + } 1577 1579 } 1578 1580 nextsocket: 1579 1581 socket++; ··· 1605 1595 bcp->congested_reps = congested_reps; 1606 1596 bcp->congested_period = congested_period; 1607 1597 } 1598 + return 0; 1608 1599 } 1609 1600 1610 1601 /* ··· 1636 1625 spin_lock_init(&disable_lock); 1637 1626 congested_cycles = microsec_2_cycles(congested_response_us); 1638 1627 1639 - uv_init_per_cpu(nuvhubs); 1628 + if (uv_init_per_cpu(nuvhubs)) { 1629 + nobau = 1; 1630 + return 0; 1631 + } 1640 1632 1641 1633 uv_partition_base_pnode = 0x7fffffff; 1642 1634 for (uvhub = 0; uvhub < nuvhubs; uvhub++)