Skip to content

Commit 77a0dd5

Browse files
committed
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
2 parents d7a5a18 + cfa6091 commit 77a0dd5

File tree

3 files changed

+57
-35
lines changed

3 files changed

+57
-35
lines changed

arch/x86/include/asm/uv/uv_bau.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@
2626
* BAU_SB_DESCRIPTOR_BASE register, set 1 is located at BASE + 512,
2727
* set 2 is at BASE + 2*512, set 3 at BASE + 3*512, and so on.
2828
*
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
3030
* cpu's on the uvhub.
3131
*
3232
* TLB shootdown will use the first of the 8 descriptors of each set.
3333
* Each of the descriptors is 64 bytes in size (8*64 = 512 bytes in a set).
3434
*/
3535

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. */
3640
#define UV_ITEMS_PER_DESCRIPTOR 8
3741
/* the 'throttle' to prevent the hardware stay-busy bug */
3842
#define MAX_BAU_CONCURRENT 3
39-
#define UV_CPUS_PER_ACT_STATUS 32
4043
#define UV_ACT_STATUS_MASK 0x3
4144
#define UV_ACT_STATUS_SIZE 2
42-
#define UV_ADP_SIZE 32
4345
#define UV_DISTRIBUTION_SIZE 256
4446
#define UV_SW_ACK_NPENDING 8
4547
#define UV_NET_ENDPOINT_INTD 0x38
@@ -100,7 +102,6 @@
100102
* number of destination side software ack resources
101103
*/
102104
#define DEST_NUM_RESOURCES 8
103-
#define MAX_CPUS_PER_NODE 32
104105
/*
105106
* completion statuses for sending a TLB flush message
106107
*/

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ unsigned int uv_apicid_hibits;
4848
EXPORT_SYMBOL_GPL(uv_apicid_hibits);
4949
static DEFINE_SPINLOCK(uv_nmi_lock);
5050

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+
5161
static inline bool is_GRU_range(u64 start, u64 end)
5262
{
5363
return start >= gru_start_paddr && end <= gru_end_paddr;
@@ -58,28 +68,24 @@ static bool uv_is_untracked_pat_range(u64 start, u64 end)
5868
return is_ISA_range(start, end) || is_GRU_range(start, end);
5969
}
6070

61-
static int early_get_nodeid(void)
71+
static int __init early_get_pnodeid(void)
6272
{
6373
union uvh_node_id_u node_id;
64-
unsigned long *mmr;
65-
66-
mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_NODE_ID, sizeof(*mmr));
67-
node_id.v = *mmr;
68-
early_iounmap(mmr, sizeof(*mmr));
74+
union uvh_rh_gam_config_mmr_u m_n_config;
75+
int pnode;
6976

7077
/* Currently, all blades have same revision number */
78+
node_id.v = uv_early_read_mmr(UVH_NODE_ID);
79+
m_n_config.v = uv_early_read_mmr(UVH_RH_GAM_CONFIG_MMR);
7180
uv_min_hub_revision_id = node_id.s.revision;
7281

73-
return node_id.s.node_id;
82+
pnode = (node_id.s.node_id >> 1) & ((1 << m_n_config.s.n_skt) - 1);
83+
return pnode;
7484
}
7585

7686
static void __init early_get_apic_pnode_shift(void)
7787
{
78-
unsigned long *mmr;
79-
80-
mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_APICID, sizeof(*mmr));
81-
uvh_apicid.v = *mmr;
82-
early_iounmap(mmr, sizeof(*mmr));
88+
uvh_apicid.v = uv_early_read_mmr(UVH_APICID);
8389
if (!uvh_apicid.v)
8490
/*
8591
* Old bios, use default value
@@ -95,21 +101,17 @@ static void __init early_get_apic_pnode_shift(void)
95101
static void __init uv_set_apicid_hibit(void)
96102
{
97103
union uvh_lb_target_physical_apic_id_mask_u apicid_mask;
98-
unsigned long *mmr;
99104

100-
mmr = early_ioremap(UV_LOCAL_MMR_BASE |
101-
UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK, sizeof(*mmr));
102-
apicid_mask.v = *mmr;
103-
early_iounmap(mmr, sizeof(*mmr));
105+
apicid_mask.v = uv_early_read_mmr(UVH_LB_TARGET_PHYSICAL_APIC_ID_MASK);
104106
uv_apicid_hibits = apicid_mask.s.bit_enables & UV_APICID_HIBIT_MASK;
105107
}
106108

107109
static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
108110
{
109-
int nodeid;
111+
int pnodeid;
110112

111113
if (!strcmp(oem_id, "SGI")) {
112-
nodeid = early_get_nodeid();
114+
pnodeid = early_get_pnodeid();
113115
early_get_apic_pnode_shift();
114116
x86_platform.is_untracked_pat_range = uv_is_untracked_pat_range;
115117
x86_platform.nmi_init = uv_nmi_init;
@@ -119,7 +121,7 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
119121
uv_system_type = UV_X2APIC;
120122
else if (!strcmp(oem_table_id, "UVH")) {
121123
__get_cpu_var(x2apic_extra_bits) =
122-
nodeid << (uvh_apicid.s.pnode_shift - 1);
124+
pnodeid << uvh_apicid.s.pnode_shift;
123125
uv_system_type = UV_NON_UNIQUE_APIC;
124126
uv_set_apicid_hibit();
125127
return 1;
@@ -682,27 +684,32 @@ void uv_nmi_init(void)
682684
void __init uv_system_init(void)
683685
{
684686
union uvh_rh_gam_config_mmr_u m_n_config;
687+
union uvh_rh_gam_mmioh_overlay_config_mmr_u mmioh;
685688
union uvh_node_id_u node_id;
686689
unsigned long gnode_upper, lowmem_redir_base, lowmem_redir_size;
687-
int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val;
690+
int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val, n_io;
688691
int gnode_extra, max_pnode = 0;
689692
unsigned long mmr_base, present, paddr;
690-
unsigned short pnode_mask;
693+
unsigned short pnode_mask, pnode_io_mask;
691694

692695
map_low_mmrs();
693696

694697
m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR );
695698
m_val = m_n_config.s.m_skt;
696699
n_val = m_n_config.s.n_skt;
700+
mmioh.v = uv_read_local_mmr(UVH_RH_GAM_MMIOH_OVERLAY_CONFIG_MMR);
701+
n_io = mmioh.s.n_io;
697702
mmr_base =
698703
uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR) &
699704
~UV_MMR_ENABLE;
700705
pnode_mask = (1 << n_val) - 1;
706+
pnode_io_mask = (1 << n_io) - 1;
707+
701708
node_id.v = uv_read_local_mmr(UVH_NODE_ID);
702709
gnode_extra = (node_id.s.node_id & ~((1 << n_val) - 1)) >> 1;
703710
gnode_upper = ((unsigned long)gnode_extra << m_val);
704-
printk(KERN_DEBUG "UV: N %d, M %d, gnode_upper 0x%lx, gnode_extra 0x%x\n",
705-
n_val, m_val, gnode_upper, gnode_extra);
711+
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",
712+
n_val, m_val, n_io, gnode_upper, gnode_extra, pnode_mask, pnode_io_mask);
706713

707714
printk(KERN_DEBUG "UV: global MMR base 0x%lx\n", mmr_base);
708715

@@ -735,7 +742,7 @@ void __init uv_system_init(void)
735742
for (j = 0; j < 64; j++) {
736743
if (!test_bit(j, &present))
737744
continue;
738-
pnode = (i * 64 + j);
745+
pnode = (i * 64 + j) & pnode_mask;
739746
uv_blade_info[blade].pnode = pnode;
740747
uv_blade_info[blade].nr_possible_cpus = 0;
741748
uv_blade_info[blade].nr_online_cpus = 0;
@@ -756,6 +763,7 @@ void __init uv_system_init(void)
756763
/*
757764
* apic_pnode_shift must be set before calling uv_apicid_to_pnode();
758765
*/
766+
uv_cpu_hub_info(cpu)->pnode_mask = pnode_mask;
759767
uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift;
760768
pnode = uv_apicid_to_pnode(apicid);
761769
blade = boot_pnode_to_blade(pnode);
@@ -772,7 +780,6 @@ void __init uv_system_init(void)
772780
uv_cpu_hub_info(cpu)->numa_blade_id = blade;
773781
uv_cpu_hub_info(cpu)->blade_processor_id = lcpu;
774782
uv_cpu_hub_info(cpu)->pnode = pnode;
775-
uv_cpu_hub_info(cpu)->pnode_mask = pnode_mask;
776783
uv_cpu_hub_info(cpu)->gpa_mask = (1UL << (m_val + n_val)) - 1;
777784
uv_cpu_hub_info(cpu)->gnode_upper = gnode_upper;
778785
uv_cpu_hub_info(cpu)->gnode_extra = gnode_extra;
@@ -796,7 +803,7 @@ void __init uv_system_init(void)
796803

797804
map_gru_high(max_pnode);
798805
map_mmr_high(max_pnode);
799-
map_mmioh_high(max_pnode);
806+
map_mmioh_high(max_pnode & pnode_io_mask);
800807

801808
uv_cpu_init();
802809
uv_scir_register_cpu_notifier();

arch/x86/platform/uv/tlb_uv.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ uv_activation_descriptor_init(int node, int pnode)
13411341

13421342
/*
13431343
* 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)
13451345
*/
13461346
bau_desc = kmalloc_node(sizeof(struct bau_desc) * UV_ADP_SIZE
13471347
* UV_ITEMS_PER_DESCRIPTOR, GFP_KERNEL, node);
@@ -1490,7 +1490,7 @@ calculate_destination_timeout(void)
14901490
/*
14911491
* initialize the bau_control structure for each cpu
14921492
*/
1493-
static void __init uv_init_per_cpu(int nuvhubs)
1493+
static int __init uv_init_per_cpu(int nuvhubs)
14941494
{
14951495
int i;
14961496
int cpu;
@@ -1507,7 +1507,7 @@ static void __init uv_init_per_cpu(int nuvhubs)
15071507
struct bau_control *smaster = NULL;
15081508
struct socket_desc {
15091509
short num_cpus;
1510-
short cpu_number[16];
1510+
short cpu_number[MAX_CPUS_PER_SOCKET];
15111511
};
15121512
struct uvhub_desc {
15131513
unsigned short socket_mask;
@@ -1540,6 +1540,10 @@ static void __init uv_init_per_cpu(int nuvhubs)
15401540
sdp = &bdp->socket[socket];
15411541
sdp->cpu_number[sdp->num_cpus] = cpu;
15421542
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+
}
15431547
}
15441548
for (uvhub = 0; uvhub < nuvhubs; uvhub++) {
15451549
if (!(*(uvhub_mask + (uvhub/8)) & (1 << (uvhub%8))))
@@ -1570,6 +1574,12 @@ static void __init uv_init_per_cpu(int nuvhubs)
15701574
bcp->uvhub_master = hmaster;
15711575
bcp->uvhub_cpu = uv_cpu_hub_info(cpu)->
15721576
blade_processor_id;
1577+
if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) {
1578+
printk(KERN_EMERG
1579+
"%d cpus per uvhub invalid\n",
1580+
bcp->uvhub_cpu);
1581+
return 1;
1582+
}
15731583
}
15741584
nextsocket:
15751585
socket++;
@@ -1595,6 +1605,7 @@ static void __init uv_init_per_cpu(int nuvhubs)
15951605
bcp->congested_reps = congested_reps;
15961606
bcp->congested_period = congested_period;
15971607
}
1608+
return 0;
15981609
}
15991610

16001611
/*
@@ -1625,7 +1636,10 @@ static int __init uv_bau_init(void)
16251636
spin_lock_init(&disable_lock);
16261637
congested_cycles = microsec_2_cycles(congested_response_us);
16271638

1628-
uv_init_per_cpu(nuvhubs);
1639+
if (uv_init_per_cpu(nuvhubs)) {
1640+
nobau = 1;
1641+
return 0;
1642+
}
16291643

16301644
uv_partition_base_pnode = 0x7fffffff;
16311645
for (uvhub = 0; uvhub < nuvhubs; uvhub++)

0 commit comments

Comments
 (0)