Skip to content

Commit eee4da2

Browse files
committed
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: powerpc: Fix hcall tracepoint recursion powerpc/numa: Fix bug in unmap_cpu_from_node powerpc/numa: Disable VPHN on dedicated processor partitions powerpc/numa: Add length when creating OF properties via VPHN powerpc/numa: Check for all VPHN changes powerpc/numa: Only use active VPHN count fields powerpc/pseries: Remove unnecessary variable initializations in numa.c powerpc/pseries: Fix brace placement in numa.c powerpc/pseries: Fix typo in VPHN comments powerpc: Fix some 6xx/7xxx CPU setup functions powerpc: Pass the right cpu_spec to ->setup_cpu() on 64-bit powerpc/book3e: Protect complex macro args in mmu-book3e.h powerpc: Fix pfn_valid() when memory starts at a non-zero address
2 parents b8f049a + 57cdfdf commit eee4da2

6 files changed

Lines changed: 94 additions & 52 deletions

File tree

‎arch/powerpc/include/asm/mmu-book3e.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
/* MAS registers bit definitions */
4242

43-
#define MAS0_TLBSEL(x) ((x << 28) & 0x30000000)
44-
#define MAS0_ESEL(x) ((x << 16) & 0x0FFF0000)
43+
#define MAS0_TLBSEL(x) (((x) << 28) & 0x30000000)
44+
#define MAS0_ESEL(x) (((x) << 16) & 0x0FFF0000)
4545
#define MAS0_NV(x) ((x) & 0x00000FFF)
4646
#define MAS0_HES 0x00004000
4747
#define MAS0_WQ_ALLWAYS 0x00000000
@@ -50,12 +50,12 @@
5050

5151
#define MAS1_VALID 0x80000000
5252
#define MAS1_IPROT 0x40000000
53-
#define MAS1_TID(x) ((x << 16) & 0x3FFF0000)
53+
#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000)
5454
#define MAS1_IND 0x00002000
5555
#define MAS1_TS 0x00001000
5656
#define MAS1_TSIZE_MASK 0x00000f80
5757
#define MAS1_TSIZE_SHIFT 7
58-
#define MAS1_TSIZE(x) ((x << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
58+
#define MAS1_TSIZE(x) (((x) << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
5959

6060
#define MAS2_EPN 0xFFFFF000
6161
#define MAS2_X0 0x00000040

‎arch/powerpc/include/asm/page.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extern phys_addr_t kernstart_addr;
101101

102102
#ifdef CONFIG_FLATMEM
103103
#define ARCH_PFN_OFFSET (MEMORY_START >> PAGE_SHIFT)
104-
#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (ARCH_PFN_OFFSET + max_mapnr))
104+
#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr)
105105
#endif
106106

107107
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)

‎arch/powerpc/kernel/cpu_setup_6xx.S‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <asm/mmu.h>
1919

2020
_GLOBAL(__setup_cpu_603)
21-
mflr r4
21+
mflr r5
2222
BEGIN_MMU_FTR_SECTION
2323
li r10,0
2424
mtspr SPRN_SPRG_603_LRU,r10 /* init SW LRU tracking */
@@ -27,60 +27,60 @@ BEGIN_FTR_SECTION
2727
bl __init_fpu_registers
2828
END_FTR_SECTION_IFCLR(CPU_FTR_FPU_UNAVAILABLE)
2929
bl setup_common_caches
30-
mtlr r4
30+
mtlr r5
3131
blr
3232
_GLOBAL(__setup_cpu_604)
33-
mflr r4
33+
mflr r5
3434
bl setup_common_caches
3535
bl setup_604_hid0
36-
mtlr r4
36+
mtlr r5
3737
blr
3838
_GLOBAL(__setup_cpu_750)
39-
mflr r4
39+
mflr r5
4040
bl __init_fpu_registers
4141
bl setup_common_caches
4242
bl setup_750_7400_hid0
43-
mtlr r4
43+
mtlr r5
4444
blr
4545
_GLOBAL(__setup_cpu_750cx)
46-
mflr r4
46+
mflr r5
4747
bl __init_fpu_registers
4848
bl setup_common_caches
4949
bl setup_750_7400_hid0
5050
bl setup_750cx
51-
mtlr r4
51+
mtlr r5
5252
blr
5353
_GLOBAL(__setup_cpu_750fx)
54-
mflr r4
54+
mflr r5
5555
bl __init_fpu_registers
5656
bl setup_common_caches
5757
bl setup_750_7400_hid0
5858
bl setup_750fx
59-
mtlr r4
59+
mtlr r5
6060
blr
6161
_GLOBAL(__setup_cpu_7400)
62-
mflr r4
62+
mflr r5
6363
bl __init_fpu_registers
6464
bl setup_7400_workarounds
6565
bl setup_common_caches
6666
bl setup_750_7400_hid0
67-
mtlr r4
67+
mtlr r5
6868
blr
6969
_GLOBAL(__setup_cpu_7410)
70-
mflr r4
70+
mflr r5
7171
bl __init_fpu_registers
7272
bl setup_7410_workarounds
7373
bl setup_common_caches
7474
bl setup_750_7400_hid0
7575
li r3,0
7676
mtspr SPRN_L2CR2,r3
77-
mtlr r4
77+
mtlr r5
7878
blr
7979
_GLOBAL(__setup_cpu_745x)
80-
mflr r4
80+
mflr r5
8181
bl setup_common_caches
8282
bl setup_745x_specifics
83-
mtlr r4
83+
mtlr r5
8484
blr
8585

8686
/* Enable caches for 603's, 604, 750 & 7400 */
@@ -194,10 +194,10 @@ setup_750cx:
194194
cror 4*cr0+eq,4*cr0+eq,4*cr1+eq
195195
cror 4*cr0+eq,4*cr0+eq,4*cr2+eq
196196
bnelr
197-
lwz r6,CPU_SPEC_FEATURES(r5)
197+
lwz r6,CPU_SPEC_FEATURES(r4)
198198
li r7,CPU_FTR_CAN_NAP
199199
andc r6,r6,r7
200-
stw r6,CPU_SPEC_FEATURES(r5)
200+
stw r6,CPU_SPEC_FEATURES(r4)
201201
blr
202202

203203
/* 750fx specific
@@ -225,12 +225,12 @@ BEGIN_FTR_SECTION
225225
andis. r11,r11,L3CR_L3E@h
226226
beq 1f
227227
END_FTR_SECTION_IFSET(CPU_FTR_L3CR)
228-
lwz r6,CPU_SPEC_FEATURES(r5)
228+
lwz r6,CPU_SPEC_FEATURES(r4)
229229
andi. r0,r6,CPU_FTR_L3_DISABLE_NAP
230230
beq 1f
231231
li r7,CPU_FTR_CAN_NAP
232232
andc r6,r6,r7
233-
stw r6,CPU_SPEC_FEATURES(r5)
233+
stw r6,CPU_SPEC_FEATURES(r4)
234234
1:
235235
mfspr r11,SPRN_HID0
236236

‎arch/powerpc/kernel/cputable.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,8 @@ static void __init setup_cpu_spec(unsigned long offset, struct cpu_spec *s)
20762076
* pointer on ppc64 and booke as we are running at 0 in real mode
20772077
* on ppc64 and reloc_offset is always 0 on booke.
20782078
*/
2079-
if (s->cpu_setup) {
2080-
s->cpu_setup(offset, s);
2079+
if (t->cpu_setup) {
2080+
t->cpu_setup(offset, t);
20812081
}
20822082
#endif /* CONFIG_PPC64 || CONFIG_BOOKE */
20832083
}

‎arch/powerpc/mm/numa.c‎

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
186186
dbg("removing cpu %lu from node %d\n", cpu, node);
187187

188188
if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) {
189-
cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
189+
cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);
190190
} else {
191191
printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
192192
cpu, node);
@@ -1289,10 +1289,9 @@ u64 memory_hotplug_max(void)
12891289
}
12901290
#endif /* CONFIG_MEMORY_HOTPLUG */
12911291

1292-
/* Vrtual Processor Home Node (VPHN) support */
1292+
/* Virtual Processor Home Node (VPHN) support */
12931293
#ifdef CONFIG_PPC_SPLPAR
1294-
#define VPHN_NR_CHANGE_CTRS (8)
1295-
static u8 vphn_cpu_change_counts[NR_CPUS][VPHN_NR_CHANGE_CTRS];
1294+
static u8 vphn_cpu_change_counts[NR_CPUS][MAX_DISTANCE_REF_POINTS];
12961295
static cpumask_t cpu_associativity_changes_mask;
12971296
static int vphn_enabled;
12981297
static void set_topology_timer(void);
@@ -1303,16 +1302,18 @@ static void set_topology_timer(void);
13031302
*/
13041303
static void setup_cpu_associativity_change_counters(void)
13051304
{
1306-
int cpu = 0;
1305+
int cpu;
1306+
1307+
/* The VPHN feature supports a maximum of 8 reference points */
1308+
BUILD_BUG_ON(MAX_DISTANCE_REF_POINTS > 8);
13071309

13081310
for_each_possible_cpu(cpu) {
1309-
int i = 0;
1311+
int i;
13101312
u8 *counts = vphn_cpu_change_counts[cpu];
13111313
volatile u8 *hypervisor_counts = lppaca[cpu].vphn_assoc_counts;
13121314

1313-
for (i = 0; i < VPHN_NR_CHANGE_CTRS; i++) {
1315+
for (i = 0; i < distance_ref_points_depth; i++)
13141316
counts[i] = hypervisor_counts[i];
1315-
}
13161317
}
13171318
}
13181319

@@ -1329,7 +1330,7 @@ static void setup_cpu_associativity_change_counters(void)
13291330
*/
13301331
static int update_cpu_associativity_changes_mask(void)
13311332
{
1332-
int cpu = 0, nr_cpus = 0;
1333+
int cpu, nr_cpus = 0;
13331334
cpumask_t *changes = &cpu_associativity_changes_mask;
13341335

13351336
cpumask_clear(changes);
@@ -1339,8 +1340,8 @@ static int update_cpu_associativity_changes_mask(void)
13391340
u8 *counts = vphn_cpu_change_counts[cpu];
13401341
volatile u8 *hypervisor_counts = lppaca[cpu].vphn_assoc_counts;
13411342

1342-
for (i = 0; i < VPHN_NR_CHANGE_CTRS; i++) {
1343-
if (hypervisor_counts[i] > counts[i]) {
1343+
for (i = 0; i < distance_ref_points_depth; i++) {
1344+
if (hypervisor_counts[i] != counts[i]) {
13441345
counts[i] = hypervisor_counts[i];
13451346
changed = 1;
13461347
}
@@ -1354,39 +1355,39 @@ static int update_cpu_associativity_changes_mask(void)
13541355
return nr_cpus;
13551356
}
13561357

1357-
/* 6 64-bit registers unpacked into 12 32-bit associativity values */
1358-
#define VPHN_ASSOC_BUFSIZE (6*sizeof(u64)/sizeof(u32))
1358+
/*
1359+
* 6 64-bit registers unpacked into 12 32-bit associativity values. To form
1360+
* the complete property we have to add the length in the first cell.
1361+
*/
1362+
#define VPHN_ASSOC_BUFSIZE (6*sizeof(u64)/sizeof(u32) + 1)
13591363

13601364
/*
13611365
* Convert the associativity domain numbers returned from the hypervisor
13621366
* to the sequence they would appear in the ibm,associativity property.
13631367
*/
13641368
static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
13651369
{
1366-
int i = 0;
1367-
int nr_assoc_doms = 0;
1370+
int i, nr_assoc_doms = 0;
13681371
const u16 *field = (const u16*) packed;
13691372

13701373
#define VPHN_FIELD_UNUSED (0xffff)
13711374
#define VPHN_FIELD_MSB (0x8000)
13721375
#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
13731376

1374-
for (i = 0; i < VPHN_ASSOC_BUFSIZE; i++) {
1377+
for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
13751378
if (*field == VPHN_FIELD_UNUSED) {
13761379
/* All significant fields processed, and remaining
13771380
* fields contain the reserved value of all 1's.
13781381
* Just store them.
13791382
*/
13801383
unpacked[i] = *((u32*)field);
13811384
field += 2;
1382-
}
1383-
else if (*field & VPHN_FIELD_MSB) {
1385+
} else if (*field & VPHN_FIELD_MSB) {
13841386
/* Data is in the lower 15 bits of this field */
13851387
unpacked[i] = *field & VPHN_FIELD_MASK;
13861388
field++;
13871389
nr_assoc_doms++;
1388-
}
1389-
else {
1390+
} else {
13901391
/* Data is in the lower 15 bits of this field
13911392
* concatenated with the next 16 bit field
13921393
*/
@@ -1396,6 +1397,9 @@ static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
13961397
}
13971398
}
13981399

1400+
/* The first cell contains the length of the property */
1401+
unpacked[0] = nr_assoc_doms;
1402+
13991403
return nr_assoc_doms;
14001404
}
14011405

@@ -1405,7 +1409,7 @@ static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
14051409
*/
14061410
static long hcall_vphn(unsigned long cpu, unsigned int *associativity)
14071411
{
1408-
long rc = 0;
1412+
long rc;
14091413
long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
14101414
u64 flags = 1;
14111415
int hwcpu = get_hard_smp_processor_id(cpu);
@@ -1419,7 +1423,7 @@ static long hcall_vphn(unsigned long cpu, unsigned int *associativity)
14191423
static long vphn_get_associativity(unsigned long cpu,
14201424
unsigned int *associativity)
14211425
{
1422-
long rc = 0;
1426+
long rc;
14231427

14241428
rc = hcall_vphn(cpu, associativity);
14251429

@@ -1445,9 +1449,9 @@ static long vphn_get_associativity(unsigned long cpu,
14451449
*/
14461450
int arch_update_cpu_topology(void)
14471451
{
1448-
int cpu = 0, nid = 0, old_nid = 0;
1452+
int cpu, nid, old_nid;
14491453
unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0};
1450-
struct sys_device *sysdev = NULL;
1454+
struct sys_device *sysdev;
14511455

14521456
for_each_cpu_mask(cpu, cpu_associativity_changes_mask) {
14531457
vphn_get_associativity(cpu, associativity);
@@ -1512,7 +1516,8 @@ int start_topology_update(void)
15121516
{
15131517
int rc = 0;
15141518

1515-
if (firmware_has_feature(FW_FEATURE_VPHN)) {
1519+
if (firmware_has_feature(FW_FEATURE_VPHN) &&
1520+
get_lppaca()->shared_proc) {
15161521
vphn_enabled = 1;
15171522
setup_cpu_associativity_change_counters();
15181523
init_timer_deferrable(&topology_timer);

‎arch/powerpc/platforms/pseries/lpar.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,13 @@ EXPORT_SYMBOL(arch_free_page);
713713
/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
714714
extern long hcall_tracepoint_refcount;
715715

716+
/*
717+
* Since the tracing code might execute hcalls we need to guard against
718+
* recursion. One example of this are spinlocks calling H_YIELD on
719+
* shared processor partitions.
720+
*/
721+
static DEFINE_PER_CPU(unsigned int, hcall_trace_depth);
722+
716723
void hcall_tracepoint_regfunc(void)
717724
{
718725
hcall_tracepoint_refcount++;
@@ -725,12 +732,42 @@ void hcall_tracepoint_unregfunc(void)
725732

726733
void __trace_hcall_entry(unsigned long opcode, unsigned long *args)
727734
{
735+
unsigned long flags;
736+
unsigned int *depth;
737+
738+
local_irq_save(flags);
739+
740+
depth = &__get_cpu_var(hcall_trace_depth);
741+
742+
if (*depth)
743+
goto out;
744+
745+
(*depth)++;
728746
trace_hcall_entry(opcode, args);
747+
(*depth)--;
748+
749+
out:
750+
local_irq_restore(flags);
729751
}
730752

731753
void __trace_hcall_exit(long opcode, unsigned long retval,
732754
unsigned long *retbuf)
733755
{
756+
unsigned long flags;
757+
unsigned int *depth;
758+
759+
local_irq_save(flags);
760+
761+
depth = &__get_cpu_var(hcall_trace_depth);
762+
763+
if (*depth)
764+
goto out;
765+
766+
(*depth)++;
734767
trace_hcall_exit(opcode, retval, retbuf);
768+
(*depth)--;
769+
770+
out:
771+
local_irq_restore(flags);
735772
}
736773
#endif

0 commit comments

Comments
 (0)