Skip to content

Commit 34b85e3

Browse files
committed
Merge tag 'powerpc-3.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux
Pull second batch of powerpc updates from Michael Ellerman: "The highlight is the series that reworks the idle management on powernv, which allows us to use deeper idle states on those machines. There's the fix from Anton for the "BUG at kernel/smpboot.c:134!" problem. An i2c driver for powernv. This is acked by Wolfram Sang, and he asked that we take it through the powerpc tree. A fix for audit from rgb at Red Hat, acked by Paul Moore who is one of the audit maintainers. A patch from Ben to export the symbol map of our OPAL firmware as a sysfs file, so that tools can use it. Also some CXL fixes, a couple of powerpc perf fixes, a fix for smt-enabled, and the patch to add __force to get_user() so we can use bitwise types" * tag 'powerpc-3.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux: powerpc/powernv: Ignore smt-enabled on Power8 and later powerpc/uaccess: Allow get_user() with bitwise types powerpc/powernv: Expose OPAL firmware symbol map powernv/powerpc: Add winkle support for offline cpus powernv/cpuidle: Redesign idle states management powerpc/powernv: Enable Offline CPUs to enter deep idle states powerpc/powernv: Switch off MMU before entering nap/sleep/rvwinkle mode i2c: Driver to expose PowerNV platform i2c busses powerpc: add little endian flag to syscall_get_arch() power/perf/hv-24x7: Use kmem_cache_free() instead of kfree powerpc/perf/hv-24x7: Use per-cpu page buffer cxl: Unmap MMIO regions when detaching a context cxl: Add timeout to process element commands cxl: Change contexts_lock to a mutex to fix sleep while atomic bug powerpc: Secondary CPUs must set cpu_callin_map after setting active and online
2 parents d5e80b4 + d70a54e commit 34b85e3

32 files changed

Lines changed: 1156 additions & 108 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Device-tree bindings for I2C OPAL driver
2+
----------------------------------------
3+
4+
Most of the device node and properties layout is specific to the firmware and
5+
used by the firmware itself for configuring the port. From the linux
6+
perspective, the properties of use are "ibm,port-name" and "ibm,opal-id".
7+
8+
Required properties:
9+
10+
- reg: Port-id within a given master
11+
- compatible: must be "ibm,opal-i2c"
12+
- ibm,opal-id: Refers to a specific bus and used to identify it when calling
13+
the relevant OPAL functions.
14+
- bus-frequency: Operating frequency of the i2c bus (in HZ). Informational for
15+
linux, used by the FW though.
16+
17+
Optional properties:
18+
- ibm,port-name: Firmware provides this name that uniquely identifies the i2c
19+
port.
20+
21+
The node contains a number of other properties that are used by the FW itself
22+
and depend on the specific hardware implementation. The example below depicts
23+
a P8 on-chip bus.
24+
25+
Example:
26+
27+
i2c-bus@0 {
28+
reg = <0x0>;
29+
bus-frequency = <0x61a80>;
30+
compatible = "ibm,power8-i2c-port", "ibm,opal-i2c";
31+
ibm,opal-id = <0x1>;
32+
ibm,port-name = "p8_00000000_e1p0";
33+
#address-cells = <0x1>;
34+
phandle = <0x10000006>;
35+
#size-cells = <0x0>;
36+
linux,phandle = <0x10000006>;
37+
};

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef _ASM_POWERPC_CPUIDLE_H
2+
#define _ASM_POWERPC_CPUIDLE_H
3+
4+
#ifdef CONFIG_PPC_POWERNV
5+
/* Used in powernv idle state management */
6+
#define PNV_THREAD_RUNNING 0
7+
#define PNV_THREAD_NAP 1
8+
#define PNV_THREAD_SLEEP 2
9+
#define PNV_THREAD_WINKLE 3
10+
#define PNV_CORE_IDLE_LOCK_BIT 0x100
11+
#define PNV_CORE_IDLE_THREAD_BITS 0x0FF
12+
13+
#ifndef __ASSEMBLY__
14+
extern u32 pnv_fastsleep_workaround_at_entry[];
15+
extern u32 pnv_fastsleep_workaround_at_exit[];
16+
#endif
17+
18+
#endif
19+
20+
#endif

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ struct opal_sg_list {
5656
#define OPAL_HARDWARE_FROZEN -13
5757
#define OPAL_WRONG_STATE -14
5858
#define OPAL_ASYNC_COMPLETION -15
59+
#define OPAL_I2C_TIMEOUT -17
60+
#define OPAL_I2C_INVALID_CMD -18
61+
#define OPAL_I2C_LBUS_PARITY -19
62+
#define OPAL_I2C_BKEND_OVERRUN -20
63+
#define OPAL_I2C_BKEND_ACCESS -21
64+
#define OPAL_I2C_ARBT_LOST -22
65+
#define OPAL_I2C_NACK_RCVD -23
66+
#define OPAL_I2C_STOP_ERR -24
5967

6068
/* API Tokens (in r0) */
6169
#define OPAL_INVALID_CALL -1
@@ -152,12 +160,25 @@ struct opal_sg_list {
152160
#define OPAL_PCI_ERR_INJECT 96
153161
#define OPAL_PCI_EEH_FREEZE_SET 97
154162
#define OPAL_HANDLE_HMI 98
163+
#define OPAL_CONFIG_CPU_IDLE_STATE 99
164+
#define OPAL_SLW_SET_REG 100
155165
#define OPAL_REGISTER_DUMP_REGION 101
156166
#define OPAL_UNREGISTER_DUMP_REGION 102
157167
#define OPAL_WRITE_TPO 103
158168
#define OPAL_READ_TPO 104
159169
#define OPAL_IPMI_SEND 107
160170
#define OPAL_IPMI_RECV 108
171+
#define OPAL_I2C_REQUEST 109
172+
173+
/* Device tree flags */
174+
175+
/* Flags set in power-mgmt nodes in device tree if
176+
* respective idle states are supported in the platform.
177+
*/
178+
#define OPAL_PM_NAP_ENABLED 0x00010000
179+
#define OPAL_PM_SLEEP_ENABLED 0x00020000
180+
#define OPAL_PM_WINKLE_ENABLED 0x00040000
181+
#define OPAL_PM_SLEEP_ENABLED_ER1 0x00080000
161182

162183
#ifndef __ASSEMBLY__
163184

@@ -712,6 +733,24 @@ typedef struct oppanel_line {
712733
uint64_t line_len;
713734
} oppanel_line_t;
714735

736+
/* OPAL I2C request */
737+
struct opal_i2c_request {
738+
uint8_t type;
739+
#define OPAL_I2C_RAW_READ 0
740+
#define OPAL_I2C_RAW_WRITE 1
741+
#define OPAL_I2C_SM_READ 2
742+
#define OPAL_I2C_SM_WRITE 3
743+
uint8_t flags;
744+
#define OPAL_I2C_ADDR_10 0x01 /* Not supported yet */
745+
uint8_t subaddr_sz; /* Max 4 */
746+
uint8_t reserved;
747+
__be16 addr; /* 7 or 10 bit address */
748+
__be16 reserved2;
749+
__be32 subaddr; /* Sub-address if any */
750+
__be32 size; /* Data size */
751+
__be64 buffer_ra; /* Buffer real address */
752+
};
753+
715754
/* /sys/firmware/opal */
716755
extern struct kobject *opal_kobj;
717756

@@ -876,11 +915,14 @@ int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);
876915
int64_t opal_handle_hmi(void);
877916
int64_t opal_register_dump_region(uint32_t id, uint64_t start, uint64_t end);
878917
int64_t opal_unregister_dump_region(uint32_t id);
918+
int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val);
879919
int64_t opal_pci_set_phb_cxl_mode(uint64_t phb_id, uint64_t mode, uint64_t pe_number);
880920
int64_t opal_ipmi_send(uint64_t interface, struct opal_ipmi_msg *msg,
881921
uint64_t msg_len);
882922
int64_t opal_ipmi_recv(uint64_t interface, struct opal_ipmi_msg *msg,
883923
uint64_t *msg_len);
924+
int64_t opal_i2c_request(uint64_t async_token, uint32_t bus_id,
925+
struct opal_i2c_request *oreq);
884926

885927
/* Internal functions */
886928
extern int early_init_dt_scan_opal(unsigned long node, const char *uname,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ struct paca_struct {
152152
u64 tm_scratch; /* TM scratch area for reclaim */
153153
#endif
154154

155+
#ifdef CONFIG_PPC_POWERNV
156+
/* Per-core mask tracking idle threads and a lock bit-[L][TTTTTTTT] */
157+
u32 *core_idle_state_ptr;
158+
u8 thread_idle_state; /* PNV_THREAD_RUNNING/NAP/SLEEP */
159+
/* Mask to indicate thread id in core */
160+
u8 thread_mask;
161+
/* Mask to denote subcore sibling threads */
162+
u8 subcore_sibling_mask;
163+
#endif
164+
155165
#ifdef CONFIG_PPC_BOOK3S_64
156166
/* Exclusive emergency stack pointer for machine check exception. */
157167
void *mc_emergency_sp;

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

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

195195
#define PPC_INST_NAP 0x4c000364
196196
#define PPC_INST_SLEEP 0x4c0003a4
197+
#define PPC_INST_WINKLE 0x4c0003e4
197198

198199
/* A2 specific instructions */
199200
#define PPC_INST_ERATWE 0x7c0001a6
@@ -375,6 +376,7 @@
375376

376377
#define PPC_NAP stringify_in_c(.long PPC_INST_NAP)
377378
#define PPC_SLEEP stringify_in_c(.long PPC_INST_SLEEP)
379+
#define PPC_WINKLE stringify_in_c(.long PPC_INST_WINKLE)
378380

379381
/* BHRB instructions */
380382
#define PPC_CLRBHRB stringify_in_c(.long PPC_INST_CLRBHRB)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
452452

453453
extern int powersave_nap; /* set if nap mode can be used in idle loop */
454454
extern unsigned long power7_nap(int check_irq);
455-
extern void power7_sleep(void);
455+
extern unsigned long power7_sleep(void);
456+
extern unsigned long power7_winkle(void);
456457
extern void flush_instruction_cache(void);
457458
extern void hard_reset_now(void);
458459
extern void poweroff_now(void);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@
118118
#define __MSR (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV)
119119
#ifdef __BIG_ENDIAN__
120120
#define MSR_ __MSR
121+
#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV)
121122
#else
122123
#define MSR_ (__MSR | MSR_LE)
124+
#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV | MSR_LE)
123125
#endif
124126
#define MSR_KERNEL (MSR_ | MSR_64BIT)
125127
#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
@@ -371,6 +373,7 @@
371373
#define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */
372374
#define SPRN_DBAT7U 0x23E /* Data BAT 7 Upper Register */
373375
#define SPRN_PPR 0x380 /* SMT Thread status Register */
376+
#define SPRN_TSCR 0x399 /* Thread Switch Control Register */
374377

375378
#define SPRN_DEC 0x016 /* Decrement Register */
376379
#define SPRN_DER 0x095 /* Debug Enable Regsiter */
@@ -728,6 +731,7 @@
728731
#define SPRN_BESCR 806 /* Branch event status and control register */
729732
#define BESCR_GE 0x8000000000000000ULL /* Global Enable */
730733
#define SPRN_WORT 895 /* Workload optimization register - thread */
734+
#define SPRN_WORC 863 /* Workload optimization register - core */
731735

732736
#define SPRN_PMC1 787
733737
#define SPRN_PMC2 788

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
9090

9191
static inline int syscall_get_arch(void)
9292
{
93-
return is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
93+
int arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
94+
#ifdef __LITTLE_ENDIAN__
95+
arch |= __AUDIT_ARCH_LE;
96+
#endif
97+
return arch;
9498
}
9599
#endif /* _ASM_SYSCALL_H */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ do { \
284284
if (!is_kernel_addr((unsigned long)__gu_addr)) \
285285
might_fault(); \
286286
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
287-
(x) = (__typeof__(*(ptr)))__gu_val; \
287+
(x) = (__force __typeof__(*(ptr)))__gu_val; \
288288
__gu_err; \
289289
})
290290
#endif /* __powerpc64__ */
@@ -297,7 +297,7 @@ do { \
297297
might_fault(); \
298298
if (access_ok(VERIFY_READ, __gu_addr, (size))) \
299299
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
300-
(x) = (__typeof__(*(ptr)))__gu_val; \
300+
(x) = (__force __typeof__(*(ptr)))__gu_val; \
301301
__gu_err; \
302302
})
303303

@@ -308,7 +308,7 @@ do { \
308308
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
309309
__chk_user_ptr(ptr); \
310310
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
311-
(x) = (__typeof__(*(ptr)))__gu_val; \
311+
(x) = (__force __typeof__(*(ptr)))__gu_val; \
312312
__gu_err; \
313313
})
314314

‎arch/powerpc/kernel/asm-offsets.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,5 +726,16 @@ int main(void)
726726
arch.timing_last_enter.tv32.tbl));
727727
#endif
728728

729+
#ifdef CONFIG_PPC_POWERNV
730+
DEFINE(PACA_CORE_IDLE_STATE_PTR,
731+
offsetof(struct paca_struct, core_idle_state_ptr));
732+
DEFINE(PACA_THREAD_IDLE_STATE,
733+
offsetof(struct paca_struct, thread_idle_state));
734+
DEFINE(PACA_THREAD_MASK,
735+
offsetof(struct paca_struct, thread_mask));
736+
DEFINE(PACA_SUBCORE_SIBLING_MASK,
737+
offsetof(struct paca_struct, subcore_sibling_mask));
738+
#endif
739+
729740
return 0;
730741
}

0 commit comments

Comments
 (0)