Skip to content

Commit a55feeb

Browse files
committed
Merge tag 'powerpc-4.0-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux
Pull powerpc fixes from Michael Ellerman: - Fix the MCE code to use CONFIG_KVM_BOOK3S_64_HANDLER - Little endian fixes for post mobility device tree update - Add PVR for POWER8NVL processor - Fixes for hypervisor doorbell handling * tag 'powerpc-4.0-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux: powerpc/book3s: Fix the MCE code to use CONFIG_KVM_BOOK3S_64_HANDLER powerpc/pseries: Little endian fixes for post mobility device tree update powerpc: Add PVR for POWER8NVL processor powerpc/powernv: Fixes for hypervisor doorbell handling
2 parents 0d33cd0 + 44d5f6f commit a55feeb

File tree

7 files changed

+64
-24
lines changed

7 files changed

+64
-24
lines changed

arch/powerpc/include/asm/ppc-opcode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
#define PPC_INST_MFSPR_PVR_MASK 0xfc1fffff
154154
#define PPC_INST_MFTMR 0x7c0002dc
155155
#define PPC_INST_MSGSND 0x7c00019c
156+
#define PPC_INST_MSGCLR 0x7c0001dc
156157
#define PPC_INST_MSGSNDP 0x7c00011c
157158
#define PPC_INST_MTTMR 0x7c0003dc
158159
#define PPC_INST_NOP 0x60000000
@@ -309,6 +310,8 @@
309310
___PPC_RB(b) | __PPC_EH(eh))
310311
#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \
311312
___PPC_RB(b))
313+
#define PPC_MSGCLR(b) stringify_in_c(.long PPC_INST_MSGCLR | \
314+
___PPC_RB(b))
312315
#define PPC_MSGSNDP(b) stringify_in_c(.long PPC_INST_MSGSNDP | \
313316
___PPC_RB(b))
314317
#define PPC_POPCNTB(a, s) stringify_in_c(.long PPC_INST_POPCNTB | \

arch/powerpc/include/asm/reg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,16 @@
608608
#define SRR1_ISI_N_OR_G 0x10000000 /* ISI: Access is no-exec or G */
609609
#define SRR1_ISI_PROT 0x08000000 /* ISI: Other protection fault */
610610
#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */
611+
#define SRR1_WAKEMASK_P8 0x003c0000 /* reason for wakeup on POWER8 */
611612
#define SRR1_WAKESYSERR 0x00300000 /* System error */
612613
#define SRR1_WAKEEE 0x00200000 /* External interrupt */
613614
#define SRR1_WAKEMT 0x00280000 /* mtctrl */
614615
#define SRR1_WAKEHMI 0x00280000 /* Hypervisor maintenance */
615616
#define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */
617+
#define SRR1_WAKEDBELL 0x00140000 /* Privileged doorbell on P8 */
616618
#define SRR1_WAKETHERM 0x00100000 /* Thermal management interrupt */
617619
#define SRR1_WAKERESET 0x00100000 /* System reset */
620+
#define SRR1_WAKEHDBELL 0x000c0000 /* Hypervisor doorbell on P8 */
618621
#define SRR1_WAKESTATE 0x00030000 /* Powersave exit mask [46:47] */
619622
#define SRR1_WS_DEEPEST 0x00030000 /* Some resources not maintained,
620623
* may not be recoverable */

arch/powerpc/kernel/cputable.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,26 @@ static struct cpu_spec __initdata cpu_specs[] = {
437437
.machine_check_early = __machine_check_early_realmode_p8,
438438
.platform = "power8",
439439
},
440+
{ /* Power8NVL */
441+
.pvr_mask = 0xffff0000,
442+
.pvr_value = 0x004c0000,
443+
.cpu_name = "POWER8NVL (raw)",
444+
.cpu_features = CPU_FTRS_POWER8,
445+
.cpu_user_features = COMMON_USER_POWER8,
446+
.cpu_user_features2 = COMMON_USER2_POWER8,
447+
.mmu_features = MMU_FTRS_POWER8,
448+
.icache_bsize = 128,
449+
.dcache_bsize = 128,
450+
.num_pmcs = 6,
451+
.pmc_type = PPC_PMC_IBM,
452+
.oprofile_cpu_type = "ppc64/power8",
453+
.oprofile_type = PPC_OPROFILE_INVALID,
454+
.cpu_setup = __setup_cpu_power8,
455+
.cpu_restore = __restore_cpu_power8,
456+
.flush_tlb = __flush_tlb_power8,
457+
.machine_check_early = __machine_check_early_realmode_p8,
458+
.platform = "power8",
459+
},
440460
{ /* Power8 DD1: Does not support doorbell IPIs */
441461
.pvr_mask = 0xffffff00,
442462
.pvr_value = 0x004d0100,

arch/powerpc/kernel/dbell.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <asm/dbell.h>
1919
#include <asm/irq_regs.h>
20+
#include <asm/kvm_ppc.h>
2021

2122
#ifdef CONFIG_SMP
2223
void doorbell_setup_this_cpu(void)
@@ -41,6 +42,7 @@ void doorbell_exception(struct pt_regs *regs)
4142

4243
may_hard_irq_enable();
4344

45+
kvmppc_set_host_ipi(smp_processor_id(), 0);
4446
__this_cpu_inc(irq_stat.doorbell_irqs);
4547

4648
smp_ipi_demux();

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ machine_check_handle_early:
14081408
bne 9f /* continue in V mode if we are. */
14091409

14101410
5:
1411-
#ifdef CONFIG_KVM_BOOK3S_64_HV
1411+
#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
14121412
/*
14131413
* We are coming from kernel context. Check if we are coming from
14141414
* guest. if yes, then we can continue. We will fall through

arch/powerpc/platforms/powernv/smp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <asm/runlatch.h>
3434
#include <asm/code-patching.h>
3535
#include <asm/dbell.h>
36+
#include <asm/kvm_ppc.h>
37+
#include <asm/ppc-opcode.h>
3638

3739
#include "powernv.h"
3840

@@ -149,7 +151,7 @@ static int pnv_smp_cpu_disable(void)
149151
static void pnv_smp_cpu_kill_self(void)
150152
{
151153
unsigned int cpu;
152-
unsigned long srr1;
154+
unsigned long srr1, wmask;
153155
u32 idle_states;
154156

155157
/* Standard hot unplug procedure */
@@ -161,6 +163,10 @@ static void pnv_smp_cpu_kill_self(void)
161163
generic_set_cpu_dead(cpu);
162164
smp_wmb();
163165

166+
wmask = SRR1_WAKEMASK;
167+
if (cpu_has_feature(CPU_FTR_ARCH_207S))
168+
wmask = SRR1_WAKEMASK_P8;
169+
164170
idle_states = pnv_get_supported_cpuidle_states();
165171
/* We don't want to take decrementer interrupts while we are offline,
166172
* so clear LPCR:PECE1. We keep PECE2 enabled.
@@ -191,10 +197,14 @@ static void pnv_smp_cpu_kill_self(void)
191197
* having finished executing in a KVM guest, then srr1
192198
* contains 0.
193199
*/
194-
if ((srr1 & SRR1_WAKEMASK) == SRR1_WAKEEE) {
200+
if ((srr1 & wmask) == SRR1_WAKEEE) {
195201
icp_native_flush_interrupt();
196202
local_paca->irq_happened &= PACA_IRQ_HARD_DIS;
197203
smp_mb();
204+
} else if ((srr1 & wmask) == SRR1_WAKEHDBELL) {
205+
unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER);
206+
asm volatile(PPC_MSGCLR(%0) : : "r" (msg));
207+
kvmppc_set_host_ipi(cpu, 0);
198208
}
199209

200210
if (cpu_core_split_required())

arch/powerpc/platforms/pseries/mobility.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
static struct kobject *mobility_kobj;
2626

2727
struct update_props_workarea {
28-
u32 phandle;
29-
u32 state;
30-
u64 reserved;
31-
u32 nprops;
28+
__be32 phandle;
29+
__be32 state;
30+
__be64 reserved;
31+
__be32 nprops;
3232
} __packed;
3333

3434
#define NODE_ACTION_MASK 0xff000000
@@ -54,11 +54,11 @@ static int mobility_rtas_call(int token, char *buf, s32 scope)
5454
return rc;
5555
}
5656

57-
static int delete_dt_node(u32 phandle)
57+
static int delete_dt_node(__be32 phandle)
5858
{
5959
struct device_node *dn;
6060

61-
dn = of_find_node_by_phandle(phandle);
61+
dn = of_find_node_by_phandle(be32_to_cpu(phandle));
6262
if (!dn)
6363
return -ENOENT;
6464

@@ -127,7 +127,7 @@ static int update_dt_property(struct device_node *dn, struct property **prop,
127127
return 0;
128128
}
129129

130-
static int update_dt_node(u32 phandle, s32 scope)
130+
static int update_dt_node(__be32 phandle, s32 scope)
131131
{
132132
struct update_props_workarea *upwa;
133133
struct device_node *dn;
@@ -136,6 +136,7 @@ static int update_dt_node(u32 phandle, s32 scope)
136136
char *prop_data;
137137
char *rtas_buf;
138138
int update_properties_token;
139+
u32 nprops;
139140
u32 vd;
140141

141142
update_properties_token = rtas_token("ibm,update-properties");
@@ -146,7 +147,7 @@ static int update_dt_node(u32 phandle, s32 scope)
146147
if (!rtas_buf)
147148
return -ENOMEM;
148149

149-
dn = of_find_node_by_phandle(phandle);
150+
dn = of_find_node_by_phandle(be32_to_cpu(phandle));
150151
if (!dn) {
151152
kfree(rtas_buf);
152153
return -ENOENT;
@@ -162,6 +163,7 @@ static int update_dt_node(u32 phandle, s32 scope)
162163
break;
163164

164165
prop_data = rtas_buf + sizeof(*upwa);
166+
nprops = be32_to_cpu(upwa->nprops);
165167

166168
/* On the first call to ibm,update-properties for a node the
167169
* the first property value descriptor contains an empty
@@ -170,17 +172,17 @@ static int update_dt_node(u32 phandle, s32 scope)
170172
*/
171173
if (*prop_data == 0) {
172174
prop_data++;
173-
vd = *(u32 *)prop_data;
175+
vd = be32_to_cpu(*(__be32 *)prop_data);
174176
prop_data += vd + sizeof(vd);
175-
upwa->nprops--;
177+
nprops--;
176178
}
177179

178-
for (i = 0; i < upwa->nprops; i++) {
180+
for (i = 0; i < nprops; i++) {
179181
char *prop_name;
180182

181183
prop_name = prop_data;
182184
prop_data += strlen(prop_name) + 1;
183-
vd = *(u32 *)prop_data;
185+
vd = be32_to_cpu(*(__be32 *)prop_data);
184186
prop_data += sizeof(vd);
185187

186188
switch (vd) {
@@ -212,13 +214,13 @@ static int update_dt_node(u32 phandle, s32 scope)
212214
return 0;
213215
}
214216

215-
static int add_dt_node(u32 parent_phandle, u32 drc_index)
217+
static int add_dt_node(__be32 parent_phandle, __be32 drc_index)
216218
{
217219
struct device_node *dn;
218220
struct device_node *parent_dn;
219221
int rc;
220222

221-
parent_dn = of_find_node_by_phandle(parent_phandle);
223+
parent_dn = of_find_node_by_phandle(be32_to_cpu(parent_phandle));
222224
if (!parent_dn)
223225
return -ENOENT;
224226

@@ -237,7 +239,7 @@ static int add_dt_node(u32 parent_phandle, u32 drc_index)
237239
int pseries_devicetree_update(s32 scope)
238240
{
239241
char *rtas_buf;
240-
u32 *data;
242+
__be32 *data;
241243
int update_nodes_token;
242244
int rc;
243245

@@ -254,17 +256,17 @@ int pseries_devicetree_update(s32 scope)
254256
if (rc && rc != 1)
255257
break;
256258

257-
data = (u32 *)rtas_buf + 4;
258-
while (*data & NODE_ACTION_MASK) {
259+
data = (__be32 *)rtas_buf + 4;
260+
while (be32_to_cpu(*data) & NODE_ACTION_MASK) {
259261
int i;
260-
u32 action = *data & NODE_ACTION_MASK;
261-
int node_count = *data & NODE_COUNT_MASK;
262+
u32 action = be32_to_cpu(*data) & NODE_ACTION_MASK;
263+
u32 node_count = be32_to_cpu(*data) & NODE_COUNT_MASK;
262264

263265
data++;
264266

265267
for (i = 0; i < node_count; i++) {
266-
u32 phandle = *data++;
267-
u32 drc_index;
268+
__be32 phandle = *data++;
269+
__be32 drc_index;
268270

269271
switch (action) {
270272
case DELETE_DT_NODE:

0 commit comments

Comments
 (0)