Skip to content

Commit d630ba5

Browse files
committed
Merge branch 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'x86-uv-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: uv2: Workaround for UV2 Hub bug (system global address format)
2 parents 5fd862f + 6a469e4 commit d630ba5

4 files changed

Lines changed: 46 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define UV_BAU_TUNABLES_DIR "sgi_uv"
5656
#define UV_BAU_TUNABLES_FILE "bau_tunables"
5757
#define WHITESPACE " \t\n"
58+
#define uv_mmask ((1UL << uv_hub_info->m_val) - 1)
5859
#define uv_physnodeaddr(x) ((__pa((unsigned long)(x)) & uv_mmask))
5960
#define cpubit_isset(cpu, bau_local_cpumask) \
6061
test_bit((cpu), (bau_local_cpumask).bits)

‎arch/x86/include/asm/uv/uv_hub.h‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
* PNODE - the low N bits of the GNODE. The PNODE is the most useful variant
4747
* of the nasid for socket usage.
4848
*
49+
* GPA - (global physical address) a socket physical address converted
50+
* so that it can be used by the GRU as a global address. Socket
51+
* physical addresses 1) need additional NASID (node) bits added
52+
* to the high end of the address, and 2) unaliased if the
53+
* partition does not have a physical address 0. In addition, on
54+
* UV2 rev 1, GPAs need the gnode left shifted to bits 39 or 40.
55+
*
4956
*
5057
* NumaLink Global Physical Address Format:
5158
* +--------------------------------+---------------------+
@@ -141,6 +148,8 @@ struct uv_hub_info_s {
141148
unsigned int gnode_extra;
142149
unsigned char hub_revision;
143150
unsigned char apic_pnode_shift;
151+
unsigned char m_shift;
152+
unsigned char n_lshift;
144153
unsigned long gnode_upper;
145154
unsigned long lowmem_remap_top;
146155
unsigned long lowmem_remap_base;
@@ -177,6 +186,16 @@ static inline int is_uv2_hub(void)
177186
return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE;
178187
}
179188

189+
static inline int is_uv2_1_hub(void)
190+
{
191+
return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE;
192+
}
193+
194+
static inline int is_uv2_2_hub(void)
195+
{
196+
return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1;
197+
}
198+
180199
union uvh_apicid {
181200
unsigned long v;
182201
struct uvh_apicid_s {
@@ -276,7 +295,10 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr)
276295
{
277296
if (paddr < uv_hub_info->lowmem_remap_top)
278297
paddr |= uv_hub_info->lowmem_remap_base;
279-
return paddr | uv_hub_info->gnode_upper;
298+
paddr |= uv_hub_info->gnode_upper;
299+
paddr = ((paddr << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
300+
((paddr >> uv_hub_info->m_val) << uv_hub_info->n_lshift);
301+
return paddr;
280302
}
281303

282304

@@ -300,16 +322,19 @@ static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
300322
unsigned long remap_base = uv_hub_info->lowmem_remap_base;
301323
unsigned long remap_top = uv_hub_info->lowmem_remap_top;
302324

325+
gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
326+
((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);
327+
gpa = gpa & uv_hub_info->gpa_mask;
303328
if (paddr >= remap_base && paddr < remap_base + remap_top)
304329
paddr -= remap_base;
305330
return paddr;
306331
}
307332

308333

309-
/* gnode -> pnode */
334+
/* gpa -> pnode */
310335
static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
311336
{
312-
return gpa >> uv_hub_info->m_val;
337+
return gpa >> uv_hub_info->n_lshift;
313338
}
314339

315340
/* gpa -> pnode */
@@ -320,6 +345,12 @@ static inline int uv_gpa_to_pnode(unsigned long gpa)
320345
return uv_gpa_to_gnode(gpa) & n_mask;
321346
}
322347

348+
/* gpa -> node offset*/
349+
static inline unsigned long uv_gpa_to_offset(unsigned long gpa)
350+
{
351+
return (gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift;
352+
}
353+
323354
/* pnode, offset --> socket virtual */
324355
static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
325356
{

‎arch/x86/kernel/apic/x2apic_uv_x.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,10 @@ void __init uv_system_init(void)
820820
uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift;
821821
uv_cpu_hub_info(cpu)->hub_revision = uv_hub_info->hub_revision;
822822

823+
uv_cpu_hub_info(cpu)->m_shift = 64 - m_val;
824+
uv_cpu_hub_info(cpu)->n_lshift = is_uv2_1_hub() ?
825+
(m_val == 40 ? 40 : 39) : m_val;
826+
823827
pnode = uv_apicid_to_pnode(apicid);
824828
blade = boot_pnode_to_blade(pnode);
825829
lcpu = uv_blade_info[blade].nr_possible_cpus;
@@ -850,8 +854,7 @@ void __init uv_system_init(void)
850854
if (uv_node_to_blade[nid] >= 0)
851855
continue;
852856
paddr = node_start_pfn(nid) << PAGE_SHIFT;
853-
paddr = uv_soc_phys_ram_to_gpa(paddr);
854-
pnode = (paddr >> m_val) & pnode_mask;
857+
pnode = uv_gpa_to_pnode(uv_soc_phys_ram_to_gpa(paddr));
855858
blade = boot_pnode_to_blade(pnode);
856859
uv_node_to_blade[nid] = blade;
857860
}

‎arch/x86/platform/uv/tlb_uv.c‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ early_param("nobau", setup_nobau);
115115

116116
/* base pnode in this partition */
117117
static int uv_base_pnode __read_mostly;
118-
/* position of pnode (which is nasid>>1): */
119-
static int uv_nshift __read_mostly;
120-
static unsigned long uv_mmask __read_mostly;
121118

122119
static DEFINE_PER_CPU(struct ptc_stats, ptcstats);
123120
static DEFINE_PER_CPU(struct bau_control, bau_control);
@@ -1435,7 +1432,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
14351432
{
14361433
int i;
14371434
int cpu;
1438-
unsigned long pa;
1435+
unsigned long gpa;
14391436
unsigned long m;
14401437
unsigned long n;
14411438
size_t dsize;
@@ -1451,9 +1448,9 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
14511448
bau_desc = kmalloc_node(dsize, GFP_KERNEL, node);
14521449
BUG_ON(!bau_desc);
14531450

1454-
pa = uv_gpa(bau_desc); /* need the real nasid*/
1455-
n = pa >> uv_nshift;
1456-
m = pa & uv_mmask;
1451+
gpa = uv_gpa(bau_desc);
1452+
n = uv_gpa_to_gnode(gpa);
1453+
m = uv_gpa_to_offset(gpa);
14571454

14581455
/* the 14-bit pnode */
14591456
write_mmr_descriptor_base(pnode, (n << UV_DESC_PSHIFT | m));
@@ -1525,9 +1522,9 @@ static void pq_init(int node, int pnode)
15251522
bcp->queue_last = pqp + (DEST_Q_SIZE - 1);
15261523
}
15271524
/*
1528-
* need the pnode of where the memory was really allocated
1525+
* need the gnode of where the memory was really allocated
15291526
*/
1530-
pn = uv_gpa(pqp) >> uv_nshift;
1527+
pn = uv_gpa_to_gnode(uv_gpa(pqp));
15311528
first = uv_physnodeaddr(pqp);
15321529
pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
15331530
last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
@@ -1837,8 +1834,6 @@ static int __init uv_bau_init(void)
18371834
zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
18381835
}
18391836

1840-
uv_nshift = uv_hub_info->m_val;
1841-
uv_mmask = (1UL << uv_hub_info->m_val) - 1;
18421837
nuvhubs = uv_num_possible_blades();
18431838
spin_lock_init(&disable_lock);
18441839
congested_cycles = usec_2_cycles(congested_respns_us);

0 commit comments

Comments
 (0)