* [PATCH v3 10/16] powerpc: fix includes in asm/processor.h
From: Christophe Leroy @ 2018-07-05 16:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
Remove superflous includes and add missing ones
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/hw_breakpoint.h | 1 +
arch/powerpc/include/asm/processor.h | 5 ++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index 8e7b09703ca4..3637588d3f6d 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -55,6 +55,7 @@ struct arch_hw_breakpoint {
struct perf_event;
struct pmu;
struct perf_sample_data;
+struct task_struct;
#define HW_BREAKPOINT_ALIGN 0x7
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 5debe337ea9d..52fadded5c1e 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -39,10 +39,9 @@
#endif /* CONFIG_PPC64 */
#ifndef __ASSEMBLY__
-#include <linux/compiler.h>
-#include <linux/cache.h>
+#include <linux/types.h>
+#include <asm/thread_info.h>
#include <asm/ptrace.h>
-#include <asm/types.h>
#include <asm/hw_breakpoint.h>
/* We do _not_ want to define new machine types at all, those must die
--
2.13.3
^ permalink raw reply related
* [PATCH v3 09/16] powerpc/book3s: Remove PPC_PIN_SIZE
From: Christophe Leroy @ 2018-07-05 16:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
PPC_PIN_SIZE is specific to the 44x and is defined in mmu.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/book3s/32/pgtable.h | 5 -----
arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 3c3e34240628..751cf931bb3f 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -84,17 +84,12 @@
* of RAM. -- Cort
*/
#define VMALLOC_OFFSET (0x1000000) /* 16M */
-#ifdef PPC_PIN_SIZE
-#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
-#else
#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
-#endif
#define VMALLOC_END ioremap_bot
#ifndef __ASSEMBLY__
#include <linux/sched.h>
#include <linux/threads.h>
-#include <asm/io.h> /* For sub-arch specific PPC_PIN_SIZE */
extern unsigned long ioremap_bot;
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 7df2f3a66cc5..79805e0dad27 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
@@ -8,7 +8,7 @@
#ifndef __ASSEMBLY__
#include <linux/sched.h>
#include <linux/threads.h>
-#include <asm/io.h> /* For sub-arch specific PPC_PIN_SIZE */
+#include <asm/mmu.h> /* For sub-arch specific PPC_PIN_SIZE */
#include <asm/asm-405.h>
extern unsigned long ioremap_bot;
--
2.13.3
^ permalink raw reply related
* [PATCH v3 08/16] powerpc: declare set_breakpoint() static
From: Christophe Leroy @ 2018-07-05 16:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
set_breakpoint() is only used in process.c so make it static
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/debug.h | 1 -
arch/powerpc/kernel/process.c | 14 +++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/debug.h b/arch/powerpc/include/asm/debug.h
index ce5da214ffe5..7756026b95ca 100644
--- a/arch/powerpc/include/asm/debug.h
+++ b/arch/powerpc/include/asm/debug.h
@@ -45,7 +45,6 @@ static inline int debugger_break_match(struct pt_regs *regs) { return 0; }
static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
#endif
-void set_breakpoint(struct arch_hw_breakpoint *brk);
void __set_breakpoint(struct arch_hw_breakpoint *brk);
bool ppc_breakpoint_available(void);
#ifdef CONFIG_PPC_ADV_DEBUG_REGS
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9ef4aea9fffe..6061efb369e8 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -716,6 +716,13 @@ void switch_booke_debug_regs(struct debug_reg *new_debug)
EXPORT_SYMBOL_GPL(switch_booke_debug_regs);
#else /* !CONFIG_PPC_ADV_DEBUG_REGS */
#ifndef CONFIG_HAVE_HW_BREAKPOINT
+static void set_breakpoint(struct arch_hw_breakpoint *brk)
+{
+ preempt_disable();
+ __set_breakpoint(brk);
+ preempt_enable();
+}
+
static void set_debug_reg_defaults(struct thread_struct *thread)
{
thread->hw_brk.address = 0;
@@ -828,13 +835,6 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
WARN_ON_ONCE(1);
}
-void set_breakpoint(struct arch_hw_breakpoint *brk)
-{
- preempt_disable();
- __set_breakpoint(brk);
- preempt_enable();
-}
-
/* Check if we have DAWR or DABR hardware */
bool ppc_breakpoint_available(void)
{
--
2.13.3
^ permalink raw reply related
* [PATCH v3 07/16] powerpc: remove superflous inclusions of asm/fixmap.h
From: Christophe Leroy @ 2018-07-05 16:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
Files not using fixmap consts or functions don't need asm/fixmap.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/fixmap.h | 2 --
arch/powerpc/kernel/head_8xx.S | 1 -
arch/powerpc/mm/dump_hashpagetable.c | 1 -
arch/powerpc/sysdev/cpm_common.c | 1 -
4 files changed, 5 deletions(-)
diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index 6c40dfda5912..40efdf1d2d6e 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -15,9 +15,7 @@
#define _ASM_FIXMAP_H
#ifndef __ASSEMBLY__
-#include <linux/kernel.h>
#include <asm/page.h>
-#include <asm/pgtable.h>
#ifdef CONFIG_HIGHMEM
#include <linux/threads.h>
#include <asm/kmap_types.h>
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 6cab07e76732..95f6bdc0718f 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -30,7 +30,6 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/ptrace.h>
-#include <asm/fixmap.h>
#include <asm/export.h>
#if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
diff --git a/arch/powerpc/mm/dump_hashpagetable.c b/arch/powerpc/mm/dump_hashpagetable.c
index 14cfb11b09d0..ddffb1513ddc 100644
--- a/arch/powerpc/mm/dump_hashpagetable.c
+++ b/arch/powerpc/mm/dump_hashpagetable.c
@@ -19,7 +19,6 @@
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
-#include <asm/fixmap.h>
#include <asm/pgtable.h>
#include <linux/const.h>
#include <asm/page.h>
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index b74508175b67..010975c3422f 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -28,7 +28,6 @@
#include <asm/udbg.h>
#include <asm/io.h>
#include <asm/cpm.h>
-#include <asm/fixmap.h>
#include <soc/fsl/qe/qe.h>
#include <mm/mmu_decl.h>
--
2.13.3
^ permalink raw reply related
* [PATCH v3 06/16] powerpc: clean inclusions of asm/feature-fixups.h
From: Christophe Leroy @ 2018-07-05 16:25 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
files not using feature fixup don't need asm/feature-fixups.h
files using feature fixup need asm/feature-fixups.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/cputable.h | 1 -
arch/powerpc/include/asm/dbell.h | 1 +
arch/powerpc/include/asm/dt_cpu_ftrs.h | 1 -
arch/powerpc/include/asm/exception-64s.h | 1 +
arch/powerpc/include/asm/firmware.h | 1 -
arch/powerpc/include/asm/kvm_booke_hv_asm.h | 2 ++
arch/powerpc/include/asm/mmu.h | 1 -
arch/powerpc/include/asm/ppc_asm.h | 1 +
arch/powerpc/include/asm/reg.h | 1 +
arch/powerpc/kernel/cpu_setup_6xx.S | 1 +
arch/powerpc/kernel/entry_32.S | 1 +
arch/powerpc/kernel/entry_64.S | 1 +
arch/powerpc/kernel/exceptions-64e.S | 1 +
arch/powerpc/kernel/exceptions-64s.S | 1 +
arch/powerpc/kernel/fpu.S | 1 +
arch/powerpc/kernel/head_32.S | 1 +
arch/powerpc/kernel/head_64.S | 1 +
arch/powerpc/kernel/head_fsl_booke.S | 1 +
arch/powerpc/kernel/idle_6xx.S | 1 +
arch/powerpc/kernel/idle_book3s.S | 1 +
arch/powerpc/kernel/idle_e500.S | 1 +
arch/powerpc/kernel/idle_power4.S | 1 +
arch/powerpc/kernel/l2cr_6xx.S | 1 +
arch/powerpc/kernel/misc_32.S | 1 +
arch/powerpc/kernel/misc_64.S | 1 +
arch/powerpc/kernel/setup_32.c | 1 +
arch/powerpc/kernel/setup_64.c | 1 +
arch/powerpc/kernel/swsusp_32.S | 1 +
arch/powerpc/kernel/swsusp_asm64.S | 1 +
arch/powerpc/kernel/tm.S | 1 +
arch/powerpc/kvm/book3s_64_slb.S | 1 +
arch/powerpc/kvm/book3s_hv_interrupts.S | 1 +
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 1 +
arch/powerpc/kvm/book3s_segment.S | 1 +
arch/powerpc/lib/copypage_64.S | 1 +
arch/powerpc/lib/copyuser_64.S | 1 +
arch/powerpc/lib/hweight_64.S | 1 +
arch/powerpc/lib/memcpy_64.S | 1 +
arch/powerpc/mm/hash_low_32.S | 1 +
arch/powerpc/mm/hash_native_64.c | 1 +
arch/powerpc/mm/slb_low.S | 1 +
arch/powerpc/mm/tlb_low_64e.S | 1 +
arch/powerpc/mm/tlb_nohash_low.S | 1 +
arch/powerpc/platforms/powermac/cache.S | 1 +
arch/powerpc/platforms/powermac/sleep.S | 1 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
arch/powerpc/platforms/pseries/hvCall.S | 1 +
47 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index badcb36cb253..5f9f477d39d3 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -4,7 +4,6 @@
#include <linux/types.h>
-#include <asm/feature-fixups.h>
#include <uapi/asm/cputable.h>
#include <asm/asm-const.h>
diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h
index 998c42ff1caa..99b84db23e8c 100644
--- a/arch/powerpc/include/asm/dbell.h
+++ b/arch/powerpc/include/asm/dbell.h
@@ -16,6 +16,7 @@
#include <linux/threads.h>
#include <asm/ppc-opcode.h>
+#include <asm/feature-fixups.h>
#define PPC_DBELL_MSG_BRDCAST (0x04000000)
#define PPC_DBELL_TYPE(x) (((x) & 0xf) << (63-36))
diff --git a/arch/powerpc/include/asm/dt_cpu_ftrs.h b/arch/powerpc/include/asm/dt_cpu_ftrs.h
index 55113432fc91..0c729e2d0e8a 100644
--- a/arch/powerpc/include/asm/dt_cpu_ftrs.h
+++ b/arch/powerpc/include/asm/dt_cpu_ftrs.h
@@ -10,7 +10,6 @@
*/
#include <linux/types.h>
-#include <asm/feature-fixups.h>
#include <uapi/asm/cputable.h>
#ifdef CONFIG_PPC_DT_CPU_FTRS
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index c40b4380951c..1f2efc1a9769 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -35,6 +35,7 @@
* implementations as possible.
*/
#include <asm/head-64.h>
+#include <asm/feature-fixups.h>
/* PACA save area offsets (exgen, exmc, etc) */
#define EX_R9 0
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index ce8aab72c21b..7a051bd21f87 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -14,7 +14,6 @@
#ifdef __KERNEL__
-#include <asm/feature-fixups.h>
#include <asm/asm-const.h>
/* firmware feature bitmask values */
diff --git a/arch/powerpc/include/asm/kvm_booke_hv_asm.h b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
index e5f048bbcb7c..931260b59ac6 100644
--- a/arch/powerpc/include/asm/kvm_booke_hv_asm.h
+++ b/arch/powerpc/include/asm/kvm_booke_hv_asm.h
@@ -9,6 +9,8 @@
#ifndef ASM_KVM_BOOKE_HV_ASM_H
#define ASM_KVM_BOOKE_HV_ASM_H
+#include <asm/feature-fixups.h>
+
#ifdef __ASSEMBLY__
/*
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 8418d83b5eb0..13ea441ac531 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -5,7 +5,6 @@
#include <linux/types.h>
-#include <asm/feature-fixups.h>
#include <asm/asm-const.h>
/*
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 75ece56dcd62..b5d023680801 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -9,6 +9,7 @@
#include <asm/processor.h>
#include <asm/ppc-opcode.h>
#include <asm/firmware.h>
+#include <asm/feature-fixups.h>
#ifdef __ASSEMBLY__
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index d4a8dc71a057..486b7c83b8c5 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -14,6 +14,7 @@
#include <linux/stringify.h>
#include <asm/cputable.h>
#include <asm/asm-const.h>
+#include <asm/feature-fixups.h>
/* Pickup Book E specific registers. */
#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S
index a9f3970693e1..fa3c2c91290c 100644
--- a/arch/powerpc/kernel/cpu_setup_6xx.S
+++ b/arch/powerpc/kernel/cpu_setup_6xx.S
@@ -16,6 +16,7 @@
#include <asm/asm-offsets.h>
#include <asm/cache.h>
#include <asm/mmu.h>
+#include <asm/feature-fixups.h>
_GLOBAL(__setup_cpu_603)
mflr r5
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 7642cb984d3a..3bd097be90d9 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -34,6 +34,7 @@
#include <asm/ptrace.h>
#include <asm/export.h>
#include <asm/asm-405.h>
+#include <asm/feature-fixups.h>
/*
* MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE.
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index fc4b4c69ce40..31068be6be59 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -44,6 +44,7 @@
#else
#include <asm/exception-64e.h>
#endif
+#include <asm/feature-fixups.h>
/*
* System calls.
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 9b6e653e501a..419efdd567be 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -27,6 +27,7 @@
#include <asm/hw_irq.h>
#include <asm/kvm_asm.h>
#include <asm/kvm_booke_hv_asm.h>
+#include <asm/feature-fixups.h>
/* XXX This will ultimately add space for a special exception save
* structure used to save things like SRR0/SRR1, SPRGs, MAS, etc...
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 285c6465324a..a3c79aed2f61 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -18,6 +18,7 @@
#include <asm/ptrace.h>
#include <asm/cpuidle.h>
#include <asm/head-64.h>
+#include <asm/feature-fixups.h>
/*
* There are a few constraints to be concerned with.
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index 07c913fd5aba..529dcc21c3f9 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -26,6 +26,7 @@
#include <asm/ptrace.h>
#include <asm/export.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#ifdef CONFIG_VSX
#define __REST_32FPVSRS(n,c,base) \
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 29b2fed93289..61ca27929355 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -35,6 +35,7 @@
#include <asm/bug.h>
#include <asm/kvm_book3s_asm.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
/* 601 only have IBAT; cr0.eq is set on 601 when using this macro */
#define LOAD_BAT(n, reg, RA, RB) \
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 6eca15f25c73..4898e9491a1c 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -44,6 +44,7 @@
#include <asm/cputhreads.h>
#include <asm/ppc-opcode.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
/* The physical memory is laid out such that the secondary processor
* spin code sits at 0x0000...0x00ff. On server, the vectors follow
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index bf4c6021515f..e2750b856c8f 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -43,6 +43,7 @@
#include <asm/cache.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
#include "head_booke.h"
/* As with the other PowerPC ports, it is expected that when code
diff --git a/arch/powerpc/kernel/idle_6xx.S b/arch/powerpc/kernel/idle_6xx.S
index 1686916cc7f0..ff026c9d3cab 100644
--- a/arch/powerpc/kernel/idle_6xx.S
+++ b/arch/powerpc/kernel/idle_6xx.S
@@ -20,6 +20,7 @@
#include <asm/thread_info.h>
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
+#include <asm/feature-fixups.h>
.text
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index 3db0513d8442..0cb6ffe992c2 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -24,6 +24,7 @@
#include <asm/book3s/64/mmu-hash.h>
#include <asm/mmu.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#undef DEBUG
diff --git a/arch/powerpc/kernel/idle_e500.S b/arch/powerpc/kernel/idle_e500.S
index b9b6ef510be1..583e55ac7d26 100644
--- a/arch/powerpc/kernel/idle_e500.S
+++ b/arch/powerpc/kernel/idle_e500.S
@@ -17,6 +17,7 @@
#include <asm/thread_info.h>
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
+#include <asm/feature-fixups.h>
.text
diff --git a/arch/powerpc/kernel/idle_power4.S b/arch/powerpc/kernel/idle_power4.S
index 08faa93755f9..dd7471fe20bd 100644
--- a/arch/powerpc/kernel/idle_power4.S
+++ b/arch/powerpc/kernel/idle_power4.S
@@ -16,6 +16,7 @@
#include <asm/asm-offsets.h>
#include <asm/irqflags.h>
#include <asm/hw_irq.h>
+#include <asm/feature-fixups.h>
#undef DEBUG
diff --git a/arch/powerpc/kernel/l2cr_6xx.S b/arch/powerpc/kernel/l2cr_6xx.S
index 6408f09dbbd9..6e7dbb7d527c 100644
--- a/arch/powerpc/kernel/l2cr_6xx.S
+++ b/arch/powerpc/kernel/l2cr_6xx.S
@@ -45,6 +45,7 @@
#include <asm/ppc_asm.h>
#include <asm/cache.h>
#include <asm/page.h>
+#include <asm/feature-fixups.h>
/* Usage:
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 3f7a9a2d2435..695b24a2d954 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -34,6 +34,7 @@
#include <asm/bug.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
.text
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index fa267e94090a..262ba9481781 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -28,6 +28,7 @@
#include <asm/ptrace.h>
#include <asm/mmu.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
.text
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index ef747a5a30b9..0e3743343280 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -41,6 +41,7 @@
#include <asm/cpu_has_feature.h>
#include <asm/asm-prototypes.h>
#include <asm/kdump.h>
+#include <asm/feature-fixups.h>
#define DBG(fmt...)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 225bc5f91049..6a501b25dd85 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -68,6 +68,7 @@
#include <asm/opal.h>
#include <asm/cputhreads.h>
#include <asm/hw_irq.h>
+#include <asm/feature-fixups.h>
#include "setup.h"
diff --git a/arch/powerpc/kernel/swsusp_32.S b/arch/powerpc/kernel/swsusp_32.S
index 34b73a262709..7a919e9a3400 100644
--- a/arch/powerpc/kernel/swsusp_32.S
+++ b/arch/powerpc/kernel/swsusp_32.S
@@ -7,6 +7,7 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/mmu.h>
+#include <asm/feature-fixups.h>
/*
* Structure for storing CPU registers on the save area.
diff --git a/arch/powerpc/kernel/swsusp_asm64.S b/arch/powerpc/kernel/swsusp_asm64.S
index 82d8aae81c6a..f83bf6f72cb0 100644
--- a/arch/powerpc/kernel/swsusp_asm64.S
+++ b/arch/powerpc/kernel/swsusp_asm64.S
@@ -13,6 +13,7 @@
#include <asm/thread_info.h>
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
+#include <asm/feature-fixups.h>
/*
* Structure for storing CPU registers on the save area.
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index ff12f47a96b6..c0dcdd57cd7f 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -13,6 +13,7 @@
#include <asm/reg.h>
#include <asm/bug.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
#ifdef CONFIG_VSX
/* See fpu.S, this is borrowed from there */
diff --git a/arch/powerpc/kvm/book3s_64_slb.S b/arch/powerpc/kvm/book3s_64_slb.S
index d293485c1a60..066c665dc86f 100644
--- a/arch/powerpc/kvm/book3s_64_slb.S
+++ b/arch/powerpc/kvm/book3s_64_slb.S
@@ -18,6 +18,7 @@
*/
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#define SHADOW_SLB_ENTRY_LEN 0x10
#define OFFSET_ESID(x) (SHADOW_SLB_ENTRY_LEN * x)
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 4218073eea1f..666b91c79eb4 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -28,6 +28,7 @@
#include <asm/exception-64s.h>
#include <asm/ppc-opcode.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
/*****************************************************************************
* *
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index e24a1e7279fd..ac53be00039a 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -33,6 +33,7 @@
#include <asm/xive-regs.h>
#include <asm/thread_info.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
/* Sign-extend HDEC if not on POWER9 */
#define EXTEND_HDEC(reg) \
diff --git a/arch/powerpc/kvm/book3s_segment.S b/arch/powerpc/kvm/book3s_segment.S
index 7fec258bb072..e5c542a7c5ac 100644
--- a/arch/powerpc/kvm/book3s_segment.S
+++ b/arch/powerpc/kvm/book3s_segment.S
@@ -20,6 +20,7 @@
/* Real mode helpers */
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#if defined(CONFIG_PPC_BOOK3S_64)
diff --git a/arch/powerpc/lib/copypage_64.S b/arch/powerpc/lib/copypage_64.S
index 8d5034f645f3..694390357667 100644
--- a/arch/powerpc/lib/copypage_64.S
+++ b/arch/powerpc/lib/copypage_64.S
@@ -11,6 +11,7 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
.section ".toc","aw"
PPC64_CACHES:
diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S
index 65244263b6a3..2d6f128d3ebe 100644
--- a/arch/powerpc/lib/copyuser_64.S
+++ b/arch/powerpc/lib/copyuser_64.S
@@ -10,6 +10,7 @@
#include <asm/ppc_asm.h>
#include <asm/export.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#ifdef __BIG_ENDIAN__
#define sLd sld /* Shift towards low-numbered address. */
diff --git a/arch/powerpc/lib/hweight_64.S b/arch/powerpc/lib/hweight_64.S
index 3de7ac154f24..0526b2225260 100644
--- a/arch/powerpc/lib/hweight_64.S
+++ b/arch/powerpc/lib/hweight_64.S
@@ -20,6 +20,7 @@
#include <asm/processor.h>
#include <asm/ppc_asm.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
/* Note: This code relies on -mminimal-toc */
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 26ea02b7311f..94650d6eae9c 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -10,6 +10,7 @@
#include <asm/ppc_asm.h>
#include <asm/export.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
.align 7
_GLOBAL_TOC(memcpy)
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index ffbd7c0bda96..26acf6c8c20c 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -27,6 +27,7 @@
#include <asm/thread_info.h>
#include <asm/asm-offsets.h>
#include <asm/export.h>
+#include <asm/feature-fixups.h>
#ifdef CONFIG_SMP
.section .bss
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 1d049c78c82a..1baabc74c4ae 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -30,6 +30,7 @@
#include <asm/udbg.h>
#include <asm/kexec.h>
#include <asm/ppc-opcode.h>
+#include <asm/feature-fixups.h>
#include <misc/cxl-base.h>
diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
index a83fbd2a4a24..4ac5057ad439 100644
--- a/arch/powerpc/mm/slb_low.S
+++ b/arch/powerpc/mm/slb_low.S
@@ -22,6 +22,7 @@
#include <asm/mmu.h>
#include <asm/pgtable.h>
#include <asm/firmware.h>
+#include <asm/feature-fixups.h>
/*
* This macro generates asm code to compute the VSID scramble
diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S
index eb82d787d99a..7fd20c52a8ec 100644
--- a/arch/powerpc/mm/tlb_low_64e.S
+++ b/arch/powerpc/mm/tlb_low_64e.S
@@ -22,6 +22,7 @@
#include <asm/ppc-opcode.h>
#include <asm/kvm_asm.h>
#include <asm/kvm_booke_hv_asm.h>
+#include <asm/feature-fixups.h>
#ifdef CONFIG_PPC_64K_PAGES
#define VPTE_PMD_SHIFT (PTE_INDEX_SIZE+1)
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index 505a3d010c47..e066a658acac 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -35,6 +35,7 @@
#include <asm/processor.h>
#include <asm/bug.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
#if defined(CONFIG_40x)
diff --git a/arch/powerpc/platforms/powermac/cache.S b/arch/powerpc/platforms/powermac/cache.S
index cc5347eb1662..27862feee4a5 100644
--- a/arch/powerpc/platforms/powermac/cache.S
+++ b/arch/powerpc/platforms/powermac/cache.S
@@ -17,6 +17,7 @@
#include <asm/processor.h>
#include <asm/ppc_asm.h>
#include <asm/cputable.h>
+#include <asm/feature-fixups.h>
/*
* Flush and disable all data caches (dL1, L2, L3). This is used
diff --git a/arch/powerpc/platforms/powermac/sleep.S b/arch/powerpc/platforms/powermac/sleep.S
index 1c2802fabd57..f89808b9713d 100644
--- a/arch/powerpc/platforms/powermac/sleep.S
+++ b/arch/powerpc/platforms/powermac/sleep.S
@@ -18,6 +18,7 @@
#include <asm/thread_info.h>
#include <asm/asm-offsets.h>
#include <asm/mmu.h>
+#include <asm/feature-fixups.h>
#define MAGIC 0x4c617273 /* 'Lars' */
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 4016e3c3d18b..3508be7d758a 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -15,6 +15,7 @@
#include <asm/asm-offsets.h>
#include <asm/opal.h>
#include <asm/asm-compat.h>
+#include <asm/feature-fixups.h>
.section ".text"
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index c511a1743a44..d91412c591ef 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -13,6 +13,7 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/ptrace.h>
+#include <asm/feature-fixups.h>
.section ".text"
--
2.13.3
^ permalink raw reply related
* [PATCH v3 05/16] powerpc: clean the inclusion of stringify.h
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
Only include linux/stringify.h is files using __stringify()
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/dcr-native.h | 1 +
arch/powerpc/include/asm/ppc-opcode.h | 1 -
arch/powerpc/include/asm/reg_fsl_emb.h | 2 ++
arch/powerpc/include/asm/synch.h | 1 -
arch/powerpc/include/asm/thread_info.h | 1 -
arch/powerpc/kernel/prom.c | 1 -
arch/powerpc/kernel/prom_init.c | 1 -
arch/powerpc/kvm/book3s_64_vio_hv.c | 1 +
arch/powerpc/lib/locks.c | 1 -
arch/powerpc/perf/req-gen/_begin.h | 2 ++
arch/powerpc/perf/req-gen/perf.h | 1 +
arch/powerpc/platforms/cell/cbe_thermal.c | 1 +
arch/powerpc/platforms/cell/spufs/sputrace.h | 1 +
arch/powerpc/platforms/powernv/vas.h | 1 +
arch/powerpc/platforms/pseries/mobility.c | 1 +
15 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/include/asm/dcr-native.h b/arch/powerpc/include/asm/dcr-native.h
index 4a2beef74277..151dff555f50 100644
--- a/arch/powerpc/include/asm/dcr-native.h
+++ b/arch/powerpc/include/asm/dcr-native.h
@@ -25,6 +25,7 @@
#include <linux/spinlock.h>
#include <asm/cputable.h>
#include <asm/cpu_has_feature.h>
+#include <linux/stringify.h>
typedef struct {
unsigned int base;
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 68d916ae1986..04a03da18602 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -12,7 +12,6 @@
#ifndef _ASM_POWERPC_PPC_OPCODE_H
#define _ASM_POWERPC_PPC_OPCODE_H
-#include <linux/stringify.h>
#include <asm/asm-const.h>
#define __REG_R0 0
diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h b/arch/powerpc/include/asm/reg_fsl_emb.h
index d7ccf93e6279..a21f529c43d9 100644
--- a/arch/powerpc/include/asm/reg_fsl_emb.h
+++ b/arch/powerpc/include/asm/reg_fsl_emb.h
@@ -7,6 +7,8 @@
#ifndef __ASM_POWERPC_REG_FSL_EMB_H__
#define __ASM_POWERPC_REG_FSL_EMB_H__
+#include <linux/stringify.h>
+
#ifndef __ASSEMBLY__
/* Performance Monitor Registers */
#define mfpmr(rn) ({unsigned int rval; \
diff --git a/arch/powerpc/include/asm/synch.h b/arch/powerpc/include/asm/synch.h
index f6f8c75bbb24..aca70fb43147 100644
--- a/arch/powerpc/include/asm/synch.h
+++ b/arch/powerpc/include/asm/synch.h
@@ -3,7 +3,6 @@
#define _ASM_POWERPC_SYNCH_H
#ifdef __KERNEL__
-#include <linux/stringify.h>
#include <asm/feature-fixups.h>
#include <asm/asm-const.h>
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index ae554b6fe6b9..3c0002044bc9 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -27,7 +27,6 @@
#include <linux/cache.h>
#include <asm/processor.h>
#include <asm/page.h>
-#include <linux/stringify.h>
#include <asm/accounting.h>
/*
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 05e7fb47a7a4..60ccf08d3a08 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -23,7 +23,6 @@
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/pci.h>
-#include <linux/stringify.h>
#include <linux/delay.h>
#include <linux/initrd.h>
#include <linux/bitops.h>
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 5425dd3d6a9f..8e516336df33 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -27,7 +27,6 @@
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/proc_fs.h>
-#include <linux/stringify.h>
#include <linux/delay.h>
#include <linux/initrd.h>
#include <linux/bitops.h>
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 925fc316a104..80d50d67b8c5 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/hugetlb.h>
#include <linux/list.h>
+#include <linux/stringify.h>
#include <asm/tlbflush.h>
#include <asm/kvm_ppc.h>
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index b7b1237d4aa6..35a0ef932e1a 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -15,7 +15,6 @@
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/export.h>
-#include <linux/stringify.h>
#include <linux/smp.h>
/* waiting for a spinlock... */
diff --git a/arch/powerpc/perf/req-gen/_begin.h b/arch/powerpc/perf/req-gen/_begin.h
index 549f8782c52d..a200b86eba3b 100644
--- a/arch/powerpc/perf/req-gen/_begin.h
+++ b/arch/powerpc/perf/req-gen/_begin.h
@@ -3,6 +3,8 @@
#ifndef POWERPC_PERF_REQ_GEN_H_
#define POWERPC_PERF_REQ_GEN_H_
+#include <linux/stringify.h>
+
#define CAT2_STR_(t, s) __stringify(t/s)
#define CAT2_STR(t, s) CAT2_STR_(t, s)
#define I(...) __VA_ARGS__
diff --git a/arch/powerpc/perf/req-gen/perf.h b/arch/powerpc/perf/req-gen/perf.h
index 871a9a1766c2..fa9bc804e67a 100644
--- a/arch/powerpc/perf/req-gen/perf.h
+++ b/arch/powerpc/perf/req-gen/perf.h
@@ -3,6 +3,7 @@
#define LINUX_POWERPC_PERF_REQ_GEN_PERF_H_
#include <linux/perf_event.h>
+#include <linux/stringify.h>
#ifndef REQUEST_FILE
#error "REQUEST_FILE must be defined before including"
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
index 2c15ff094483..55aac74e1cb9 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -49,6 +49,7 @@
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/cpu.h>
+#include <linux/stringify.h>
#include <asm/spu.h>
#include <asm/io.h>
#include <asm/prom.h>
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.h b/arch/powerpc/platforms/cell/spufs/sputrace.h
index d557e999b662..1def11e911ac 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.h
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.h
@@ -3,6 +3,7 @@
#define _TRACE_SPUFS_H
#include <linux/tracepoint.h>
+#include <linux/stringify.h>
#undef TRACE_SYSTEM
#define TRACE_SYSTEM spufs
diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h
index ae0100fd35bb..f5493dbdd7ff 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -15,6 +15,7 @@
#include <linux/io.h>
#include <linux/dcache.h>
#include <linux/mutex.h>
+#include <linux/stringify.h>
/*
* Overview of Virtual Accelerator Switchboard (VAS).
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 8a8033a249c7..f0e30dc94988 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -17,6 +17,7 @@
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/stringify.h>
#include <asm/machdep.h>
#include <asm/rtas.h>
--
2.13.3
^ permalink raw reply related
* [PATCH v3 04/16] powerpc: move ASM_CONST and stringify_in_c() into asm-const.h
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
This patch moves ASM_CONST() and stringify_in_c() into
dedicated asm-const.h, then cleans all related inclusions.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/crypto/md5-asm.S | 1 +
arch/powerpc/crypto/sha1-powerpc-asm.S | 1 +
arch/powerpc/include/asm/asm-compat.h | 13 +------------
arch/powerpc/include/asm/asm-const.h | 14 ++++++++++++++
arch/powerpc/include/asm/barrier.h | 2 ++
arch/powerpc/include/asm/book3s/64/hash.h | 2 ++
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 2 +-
arch/powerpc/include/asm/book3s/64/radix.h | 2 ++
arch/powerpc/include/asm/cmpxchg.h | 1 -
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/cputable.h | 2 +-
arch/powerpc/include/asm/dt_cpu_ftrs.h | 1 -
arch/powerpc/include/asm/feature-fixups.h | 2 ++
arch/powerpc/include/asm/firmware.h | 2 +-
arch/powerpc/include/asm/futex.h | 1 -
arch/powerpc/include/asm/iommu.h | 1 +
arch/powerpc/include/asm/jump_label.h | 2 +-
arch/powerpc/include/asm/mmu-44x.h | 1 +
arch/powerpc/include/asm/mmu.h | 2 +-
arch/powerpc/include/asm/nohash/64/pgtable.h | 1 +
arch/powerpc/include/asm/page.h | 2 +-
arch/powerpc/include/asm/page_64.h | 2 ++
arch/powerpc/include/asm/ppc-opcode.h | 2 +-
arch/powerpc/include/asm/ptrace.h | 1 +
arch/powerpc/include/asm/reg.h | 1 +
arch/powerpc/include/asm/reg_a2.h | 2 ++
arch/powerpc/include/asm/spinlock.h | 1 -
arch/powerpc/include/asm/synch.h | 1 +
arch/powerpc/include/asm/thread_info.h | 2 ++
arch/powerpc/include/asm/uaccess.h | 1 -
arch/powerpc/kernel/entry_64.S | 1 +
arch/powerpc/kernel/fpu.S | 1 +
arch/powerpc/kernel/idle_book3s.S | 1 +
arch/powerpc/kernel/kvm_emul.S | 1 +
arch/powerpc/kernel/ppc_save_regs.S | 1 +
arch/powerpc/kernel/vector.S | 1 +
arch/powerpc/kvm/book3s_64_slb.S | 2 ++
arch/powerpc/kvm/book3s_hv_interrupts.S | 1 +
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 1 +
arch/powerpc/kvm/book3s_interrupts.S | 1 +
arch/powerpc/kvm/book3s_rmhandlers.S | 1 +
arch/powerpc/kvm/book3s_segment.S | 2 ++
arch/powerpc/lib/copyuser_64.S | 1 +
arch/powerpc/lib/feature-fixups-test.S | 1 +
arch/powerpc/lib/ldstfp.S | 1 +
arch/powerpc/lib/memcpy_64.S | 1 +
arch/powerpc/mm/tlb_nohash_low.S | 1 +
arch/powerpc/net/bpf_jit32.h | 1 +
arch/powerpc/net/bpf_jit_asm.S | 1 +
arch/powerpc/net/bpf_jit_comp.c | 1 +
arch/powerpc/net/bpf_jit_comp64.c | 1 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
arch/powerpc/platforms/pseries/setup.c | 1 +
arch/powerpc/purgatory/trampoline.S | 10 +---------
arch/powerpc/xmon/spr_access.S | 1 +
55 files changed, 72 insertions(+), 33 deletions(-)
create mode 100644 arch/powerpc/include/asm/asm-const.h
diff --git a/arch/powerpc/crypto/md5-asm.S b/arch/powerpc/crypto/md5-asm.S
index 10cdf5bceebb..1834065362c7 100644
--- a/arch/powerpc/crypto/md5-asm.S
+++ b/arch/powerpc/crypto/md5-asm.S
@@ -11,6 +11,7 @@
*/
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
+#include <asm/asm-compat.h>
#define rHP r3
#define rWP r4
diff --git a/arch/powerpc/crypto/sha1-powerpc-asm.S b/arch/powerpc/crypto/sha1-powerpc-asm.S
index c8951ce0dcc4..23e248beff71 100644
--- a/arch/powerpc/crypto/sha1-powerpc-asm.S
+++ b/arch/powerpc/crypto/sha1-powerpc-asm.S
@@ -7,6 +7,7 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
+#include <asm/asm-compat.h>
#ifdef __BIG_ENDIAN__
#define LWZ(rt, d, ra) \
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index d2cf3593e987..09f8dd4da883 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -1,21 +1,10 @@
#ifndef _ASM_POWERPC_ASM_COMPAT_H
#define _ASM_POWERPC_ASM_COMPAT_H
+#include <asm/asm-compat.h>
#include <asm/types.h>
#include <asm/ppc-opcode.h>
-#ifdef __ASSEMBLY__
-# define stringify_in_c(...) __VA_ARGS__
-# define ASM_CONST(x) x
-#else
-/* This version of stringify will deal with commas... */
-# define __stringify_in_c(...) #__VA_ARGS__
-# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
-# define __ASM_CONST(x) x##UL
-# define ASM_CONST(x) __ASM_CONST(x)
-#endif
-
-
#ifdef __powerpc64__
/* operations for longs and pointers */
diff --git a/arch/powerpc/include/asm/asm-const.h b/arch/powerpc/include/asm/asm-const.h
new file mode 100644
index 000000000000..082c1538c562
--- /dev/null
+++ b/arch/powerpc/include/asm/asm-const.h
@@ -0,0 +1,14 @@
+#ifndef _ASM_POWERPC_ASM_CONST_H
+#define _ASM_POWERPC_ASM_CONST_H
+
+#ifdef __ASSEMBLY__
+# define stringify_in_c(...) __VA_ARGS__
+# define ASM_CONST(x) x
+#else
+/* This version of stringify will deal with commas... */
+# define __stringify_in_c(...) #__VA_ARGS__
+# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
+# define __ASM_CONST(x) x##UL
+# define ASM_CONST(x) __ASM_CONST(x)
+#endif
+#endif /* _ASM_POWERPC_ASM_CONST_H */
diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
index f67b3f6e36be..de1316874e45 100644
--- a/arch/powerpc/include/asm/barrier.h
+++ b/arch/powerpc/include/asm/barrier.h
@@ -5,6 +5,8 @@
#ifndef _ASM_POWERPC_BARRIER_H
#define _ASM_POWERPC_BARRIER_H
+#include <asm/asm-const.h>
+
/*
* Memory barrier.
* The sync instruction guarantees that all memory accesses initiated
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h
index 0387b155f13d..d52a51b2ce7b 100644
--- a/arch/powerpc/include/asm/book3s/64/hash.h
+++ b/arch/powerpc/include/asm/book3s/64/hash.h
@@ -3,6 +3,8 @@
#define _ASM_POWERPC_BOOK3S_64_HASH_H
#ifdef __KERNEL__
+#include <asm/asm-const.h>
+
/*
* Common bits between 4K and 64K pages in a linux-style PTE.
* Additional bits may be defined in pgtable-hash64-*.h
diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index 50ed64fba4ae..a2b384545bce 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -12,9 +12,9 @@
* 2 of the License, or (at your option) any later version.
*/
-#include <asm/asm-compat.h>
#include <asm/page.h>
#include <asm/bug.h>
+#include <asm/asm-const.h>
/*
* This is necessary to get the definition of PGTABLE_RANGE which we
diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h
index ef9f96742ce1..e2bc11a35216 100644
--- a/arch/powerpc/include/asm/book3s/64/radix.h
+++ b/arch/powerpc/include/asm/book3s/64/radix.h
@@ -2,6 +2,8 @@
#ifndef _ASM_POWERPC_PGTABLE_RADIX_H
#define _ASM_POWERPC_PGTABLE_RADIX_H
+#include <asm/asm-const.h>
+
#ifndef __ASSEMBLY__
#include <asm/cmpxchg.h>
#endif
diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h
index 67ec1073ac97..27183871eb3b 100644
--- a/arch/powerpc/include/asm/cmpxchg.h
+++ b/arch/powerpc/include/asm/cmpxchg.h
@@ -5,7 +5,6 @@
#ifdef __KERNEL__
#include <linux/compiler.h>
#include <asm/synch.h>
-#include <asm/asm-compat.h>
#include <linux/bug.h>
#include <asm/asm-405.h>
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
index 812535f40124..9ecc7bfc8ae7 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -14,6 +14,7 @@
#include <asm/ppc-opcode.h>
#include <linux/string.h>
#include <linux/kallsyms.h>
+#include <asm/asm-compat.h>
/* Flags for create_branch:
* "b" == create_branch(addr, target, 0);
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 9c0a3083571b..badcb36cb253 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -4,9 +4,9 @@
#include <linux/types.h>
-#include <asm/asm-compat.h>
#include <asm/feature-fixups.h>
#include <uapi/asm/cputable.h>
+#include <asm/asm-const.h>
#ifndef __ASSEMBLY__
diff --git a/arch/powerpc/include/asm/dt_cpu_ftrs.h b/arch/powerpc/include/asm/dt_cpu_ftrs.h
index 71515d909ed1..55113432fc91 100644
--- a/arch/powerpc/include/asm/dt_cpu_ftrs.h
+++ b/arch/powerpc/include/asm/dt_cpu_ftrs.h
@@ -10,7 +10,6 @@
*/
#include <linux/types.h>
-#include <asm/asm-compat.h>
#include <asm/feature-fixups.h>
#include <uapi/asm/cputable.h>
diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h
index fcfd05672b1b..33b6f9c892c8 100644
--- a/arch/powerpc/include/asm/feature-fixups.h
+++ b/arch/powerpc/include/asm/feature-fixups.h
@@ -1,6 +1,8 @@
#ifndef __ASM_POWERPC_FEATURE_FIXUPS_H
#define __ASM_POWERPC_FEATURE_FIXUPS_H
+#include <asm/asm-const.h>
+
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 535add3f7791..ce8aab72c21b 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -14,8 +14,8 @@
#ifdef __KERNEL__
-#include <asm/asm-compat.h>
#include <asm/feature-fixups.h>
+#include <asm/asm-const.h>
/* firmware feature bitmask values */
diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h
index 76c8648d0fa8..94542776a62d 100644
--- a/arch/powerpc/include/asm/futex.h
+++ b/arch/powerpc/include/asm/futex.h
@@ -8,7 +8,6 @@
#include <linux/uaccess.h>
#include <asm/errno.h>
#include <asm/synch.h>
-#include <asm/asm-compat.h>
#include <asm/asm-405.h>
#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 20febe0b7f32..880a8a19d20d 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -30,6 +30,7 @@
#include <asm/machdep.h>
#include <asm/types.h>
#include <asm/pci-bridge.h>
+#include <asm/asm-const.h>
#define IOMMU_PAGE_SHIFT_4K 12
#define IOMMU_PAGE_SIZE_4K (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K)
diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h
index 9a287e0ac8b1..a3b2cf940b4e 100644
--- a/arch/powerpc/include/asm/jump_label.h
+++ b/arch/powerpc/include/asm/jump_label.h
@@ -14,7 +14,7 @@
#include <linux/types.h>
#include <asm/feature-fixups.h>
-#include <asm/asm-compat.h>
+#include <asm/asm-const.h>
#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
#define JUMP_LABEL_NOP_SIZE 4
diff --git a/arch/powerpc/include/asm/mmu-44x.h b/arch/powerpc/include/asm/mmu-44x.h
index cb57f29f531d..9bdbe1d1c9b9 100644
--- a/arch/powerpc/include/asm/mmu-44x.h
+++ b/arch/powerpc/include/asm/mmu-44x.h
@@ -6,6 +6,7 @@
*/
#include <asm/page.h>
+#include <asm/asm-const.h>
#define PPC44x_MMUCR_TID 0x000000ff
#define PPC44x_MMUCR_STS 0x00010000
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 61d15ce92278..8418d83b5eb0 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -5,8 +5,8 @@
#include <linux/types.h>
-#include <asm/asm-compat.h>
#include <asm/feature-fixups.h>
+#include <asm/asm-const.h>
/*
* MMU features bit definitions
diff --git a/arch/powerpc/include/asm/nohash/64/pgtable.h b/arch/powerpc/include/asm/nohash/64/pgtable.h
index dd0c7236208f..fe05b3e03cf1 100644
--- a/arch/powerpc/include/asm/nohash/64/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/64/pgtable.h
@@ -8,6 +8,7 @@
#include <asm/nohash/64/pgtable-4k.h>
#include <asm/barrier.h>
+#include <asm/asm-const.h>
#ifdef CONFIG_PPC_64K_PAGES
#error "Page size not supported"
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index a9fbefaacf10..f6a1265face2 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -16,7 +16,7 @@
#else
#include <asm/types.h>
#endif
-#include <asm/asm-compat.h>
+#include <asm/asm-const.h>
/*
* On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index af04acdb873f..c0ce17e909ef 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -10,6 +10,8 @@
* 2 of the License, or (at your option) any later version.
*/
+#include <asm/asm-const.h>
+
/*
* We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
* specific, every notion of page number shared with the firmware, TCEs,
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 4436887bc415..68d916ae1986 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -13,7 +13,7 @@
#define _ASM_POWERPC_PPC_OPCODE_H
#include <linux/stringify.h>
-#include <asm/asm-compat.h>
+#include <asm/asm-const.h>
#define __REG_R0 0
#define __REG_R1 1
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index e4923686e43a..447cbd1bee99 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -24,6 +24,7 @@
#define _ASM_POWERPC_PTRACE_H
#include <uapi/asm/ptrace.h>
+#include <asm/asm-const.h>
#ifdef __powerpc64__
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 562568414cf4..d4a8dc71a057 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -13,6 +13,7 @@
#include <linux/stringify.h>
#include <asm/cputable.h>
+#include <asm/asm-const.h>
/* Pickup Book E specific registers. */
#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
diff --git a/arch/powerpc/include/asm/reg_a2.h b/arch/powerpc/include/asm/reg_a2.h
index 3ba9c6f096fc..74c2c57c492a 100644
--- a/arch/powerpc/include/asm/reg_a2.h
+++ b/arch/powerpc/include/asm/reg_a2.h
@@ -12,6 +12,8 @@
#ifndef __ASM_POWERPC_REG_A2_H__
#define __ASM_POWERPC_REG_A2_H__
+#include <asm/asm-const.h>
+
#define SPRN_TENSR 0x1b5
#define SPRN_TENS 0x1b6 /* Thread ENable Set */
#define SPRN_TENC 0x1b7 /* Thread ENable Clear */
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index 7ec38f4ee927..685c72310f5d 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -24,7 +24,6 @@
#include <asm/paca.h>
#include <asm/hvcall.h>
#endif
-#include <asm/asm-compat.h>
#include <asm/synch.h>
#include <asm/ppc-opcode.h>
#include <asm/asm-405.h>
diff --git a/arch/powerpc/include/asm/synch.h b/arch/powerpc/include/asm/synch.h
index 6ec546090ba1..f6f8c75bbb24 100644
--- a/arch/powerpc/include/asm/synch.h
+++ b/arch/powerpc/include/asm/synch.h
@@ -5,6 +5,7 @@
#include <linux/stringify.h>
#include <asm/feature-fixups.h>
+#include <asm/asm-const.h>
#ifndef __ASSEMBLY__
extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index f308dfeb2746..ae554b6fe6b9 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -9,6 +9,8 @@
#ifndef _ASM_POWERPC_THREAD_INFO_H
#define _ASM_POWERPC_THREAD_INFO_H
+#include <asm/asm-const.h>
+
#ifdef __KERNEL__
#define THREAD_SHIFT CONFIG_THREAD_SHIFT
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 468653ce844c..643cfbd5bcb5 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -2,7 +2,6 @@
#ifndef _ARCH_POWERPC_UACCESS_H
#define _ARCH_POWERPC_UACCESS_H
-#include <asm/asm-compat.h>
#include <asm/ppc_asm.h>
#include <asm/processor.h>
#include <asm/page.h>
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 729e9ef4d3bb..fc4b4c69ce40 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -38,6 +38,7 @@
#include <asm/ppc-opcode.h>
#include <asm/barrier.h>
#include <asm/export.h>
+#include <asm/asm-compat.h>
#ifdef CONFIG_PPC_BOOK3S
#include <asm/exception-64s.h>
#else
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index 6c509f39bbde..07c913fd5aba 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -25,6 +25,7 @@
#include <asm/asm-offsets.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/asm-compat.h>
#ifdef CONFIG_VSX
#define __REST_32FPVSRS(n,c,base) \
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index e734f6e45abc..3db0513d8442 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -23,6 +23,7 @@
#include <asm/exception-64s.h>
#include <asm/book3s/64/mmu-hash.h>
#include <asm/mmu.h>
+#include <asm/asm-compat.h>
#undef DEBUG
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index e100ff324a85..c005088f6c9c 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -23,6 +23,7 @@
#include <asm/reg.h>
#include <asm/page.h>
#include <asm/asm-offsets.h>
+#include <asm/asm-compat.h>
#define KVM_MAGIC_PAGE (-4096)
diff --git a/arch/powerpc/kernel/ppc_save_regs.S b/arch/powerpc/kernel/ppc_save_regs.S
index 8afbe213d729..6d1b42ee797c 100644
--- a/arch/powerpc/kernel/ppc_save_regs.S
+++ b/arch/powerpc/kernel/ppc_save_regs.S
@@ -12,6 +12,7 @@
#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/ptrace.h>
+#include <asm/asm-compat.h>
/*
* Grab the register values as they are now.
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index f314fd475491..21165da0052d 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -8,6 +8,7 @@
#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/asm-compat.h>
/*
* Load state from memory into VMX registers including VSCR.
diff --git a/arch/powerpc/kvm/book3s_64_slb.S b/arch/powerpc/kvm/book3s_64_slb.S
index 688722acd692..d293485c1a60 100644
--- a/arch/powerpc/kvm/book3s_64_slb.S
+++ b/arch/powerpc/kvm/book3s_64_slb.S
@@ -17,6 +17,8 @@
* Authors: Alexander Graf <agraf@suse.de>
*/
+#include <asm/asm-compat.h>
+
#define SHADOW_SLB_ENTRY_LEN 0x10
#define OFFSET_ESID(x) (SHADOW_SLB_ENTRY_LEN * x)
#define OFFSET_VSID(x) ((SHADOW_SLB_ENTRY_LEN * x) + 8)
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 82f2ff9410b6..4218073eea1f 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -27,6 +27,7 @@
#include <asm/asm-offsets.h>
#include <asm/exception-64s.h>
#include <asm/ppc-opcode.h>
+#include <asm/asm-compat.h>
/*****************************************************************************
* *
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 153988d878e8..e24a1e7279fd 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -32,6 +32,7 @@
#include <asm/opal.h>
#include <asm/xive-regs.h>
#include <asm/thread_info.h>
+#include <asm/asm-compat.h>
/* Sign-extend HDEC if not on POWER9 */
#define EXTEND_HDEC(reg) \
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S
index c18e845019ec..d71dab16dc6f 100644
--- a/arch/powerpc/kvm/book3s_interrupts.S
+++ b/arch/powerpc/kvm/book3s_interrupts.S
@@ -23,6 +23,7 @@
#include <asm/page.h>
#include <asm/asm-offsets.h>
#include <asm/exception-64s.h>
+#include <asm/asm-compat.h>
#if defined(CONFIG_PPC_BOOK3S_64)
#ifdef PPC64_ELF_ABI_v2
diff --git a/arch/powerpc/kvm/book3s_rmhandlers.S b/arch/powerpc/kvm/book3s_rmhandlers.S
index 34a5adeff084..b0089e04c8c8 100644
--- a/arch/powerpc/kvm/book3s_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_rmhandlers.S
@@ -23,6 +23,7 @@
#include <asm/mmu.h>
#include <asm/page.h>
#include <asm/asm-offsets.h>
+#include <asm/asm-compat.h>
#ifdef CONFIG_PPC_BOOK3S_64
#include <asm/exception-64s.h>
diff --git a/arch/powerpc/kvm/book3s_segment.S b/arch/powerpc/kvm/book3s_segment.S
index 98ccc7ec5d48..7fec258bb072 100644
--- a/arch/powerpc/kvm/book3s_segment.S
+++ b/arch/powerpc/kvm/book3s_segment.S
@@ -19,6 +19,8 @@
/* Real mode helpers */
+#include <asm/asm-compat.h>
+
#if defined(CONFIG_PPC_BOOK3S_64)
#define GET_SHADOW_VCPU(reg) \
diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S
index 506677395681..65244263b6a3 100644
--- a/arch/powerpc/lib/copyuser_64.S
+++ b/arch/powerpc/lib/copyuser_64.S
@@ -9,6 +9,7 @@
#include <asm/processor.h>
#include <asm/ppc_asm.h>
#include <asm/export.h>
+#include <asm/asm-compat.h>
#ifdef __BIG_ENDIAN__
#define sLd sld /* Shift towards low-numbered address. */
diff --git a/arch/powerpc/lib/feature-fixups-test.S b/arch/powerpc/lib/feature-fixups-test.S
index f16cec989506..ee7c5fd5fc64 100644
--- a/arch/powerpc/lib/feature-fixups-test.S
+++ b/arch/powerpc/lib/feature-fixups-test.S
@@ -11,6 +11,7 @@
#include <asm/feature-fixups.h>
#include <asm/ppc_asm.h>
#include <asm/synch.h>
+#include <asm/asm-compat.h>
.text
diff --git a/arch/powerpc/lib/ldstfp.S b/arch/powerpc/lib/ldstfp.S
index ae15eba49c1f..32e91994b6b2 100644
--- a/arch/powerpc/lib/ldstfp.S
+++ b/arch/powerpc/lib/ldstfp.S
@@ -15,6 +15,7 @@
#include <asm/ppc-opcode.h>
#include <asm/reg.h>
#include <asm/asm-offsets.h>
+#include <asm/asm-compat.h>
#include <linux/errno.h>
#ifdef CONFIG_PPC_FPU
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 8d8265be1a59..26ea02b7311f 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -9,6 +9,7 @@
#include <asm/processor.h>
#include <asm/ppc_asm.h>
#include <asm/export.h>
+#include <asm/asm-compat.h>
.align 7
_GLOBAL_TOC(memcpy)
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index 048b8e9f4492..505a3d010c47 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -34,6 +34,7 @@
#include <asm/asm-offsets.h>
#include <asm/processor.h>
#include <asm/bug.h>
+#include <asm/asm-compat.h>
#if defined(CONFIG_40x)
diff --git a/arch/powerpc/net/bpf_jit32.h b/arch/powerpc/net/bpf_jit32.h
index a8cd7e289ecd..6f4daacad296 100644
--- a/arch/powerpc/net/bpf_jit32.h
+++ b/arch/powerpc/net/bpf_jit32.h
@@ -13,6 +13,7 @@
#ifndef _BPF_JIT32_H
#define _BPF_JIT32_H
+#include <asm/asm-compat.h>
#include "bpf_jit.h"
#ifdef CONFIG_PPC64
diff --git a/arch/powerpc/net/bpf_jit_asm.S b/arch/powerpc/net/bpf_jit_asm.S
index 3dd9c43d40c9..c80280dc2e04 100644
--- a/arch/powerpc/net/bpf_jit_asm.S
+++ b/arch/powerpc/net/bpf_jit_asm.S
@@ -10,6 +10,7 @@
*/
#include <asm/ppc_asm.h>
+#include <asm/asm-compat.h>
#include "bpf_jit32.h"
/*
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 5b061fc81df3..d5bfe24bb3b5 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -12,6 +12,7 @@
*/
#include <linux/moduleloader.h>
#include <asm/cacheflush.h>
+#include <asm/asm-compat.h>
#include <linux/netdevice.h>
#include <linux/filter.h>
#include <linux/if_vlan.h>
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 380cbf9a40d9..b8de5244a58c 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -13,6 +13,7 @@
*/
#include <linux/moduleloader.h>
#include <asm/cacheflush.h>
+#include <asm/asm-compat.h>
#include <linux/netdevice.h>
#include <linux/filter.h>
#include <linux/if_vlan.h>
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index a8d9b4089c31..4016e3c3d18b 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -14,6 +14,7 @@
#include <asm/hvcall.h>
#include <asm/asm-offsets.h>
#include <asm/opal.h>
+#include <asm/asm-compat.h>
.section ".text"
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 139f0af6c3d9..e14ccf32a97d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -69,6 +69,7 @@
#include <asm/kexec.h>
#include <asm/isa-bridge.h>
#include <asm/security_features.h>
+#include <asm/asm-const.h>
#include "pseries.h"
diff --git a/arch/powerpc/purgatory/trampoline.S b/arch/powerpc/purgatory/trampoline.S
index 4aad9dd10ace..1e1129553fd7 100644
--- a/arch/powerpc/purgatory/trampoline.S
+++ b/arch/powerpc/purgatory/trampoline.S
@@ -12,15 +12,7 @@
* Software Foundation (version 2 of the License).
*/
-#if defined(__LITTLE_ENDIAN__)
-#define STWX_BE stwbrx
-#define LWZX_BE lwbrx
-#elif defined(__BIG_ENDIAN__)
-#define STWX_BE stwx
-#define LWZX_BE lwzx
-#else
-#error no endianness defined!
-#endif
+#include <asm/asm-compat.h>
.machine ppc64
.balign 256
diff --git a/arch/powerpc/xmon/spr_access.S b/arch/powerpc/xmon/spr_access.S
index 4099cbcddaaa..720a52afdd58 100644
--- a/arch/powerpc/xmon/spr_access.S
+++ b/arch/powerpc/xmon/spr_access.S
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <asm/ppc_asm.h>
+#include <asm/asm-compat.h>
/* unsigned long xmon_mfspr(sprn, default_value) */
_GLOBAL(xmon_mfspr)
--
2.13.3
^ permalink raw reply related
* [PATCH v3 03/16] powerpc/405: move PPC405_ERR77 in asm-405.h
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/asm-405.h | 19 +++++++++++++++++++
arch/powerpc/include/asm/asm-compat.h | 13 -------------
arch/powerpc/include/asm/atomic.h | 1 +
arch/powerpc/include/asm/bitops.h | 1 +
arch/powerpc/include/asm/book3s/32/pgtable.h | 2 --
arch/powerpc/include/asm/cmpxchg.h | 1 +
arch/powerpc/include/asm/futex.h | 1 +
arch/powerpc/include/asm/nohash/32/pgtable.h | 1 +
arch/powerpc/include/asm/spinlock.h | 1 +
arch/powerpc/kernel/entry_32.S | 1 +
arch/powerpc/kernel/head_40x.S | 1 +
11 files changed, 27 insertions(+), 15 deletions(-)
create mode 100644 arch/powerpc/include/asm/asm-405.h
diff --git a/arch/powerpc/include/asm/asm-405.h b/arch/powerpc/include/asm/asm-405.h
new file mode 100644
index 000000000000..7270d3ae7c8e
--- /dev/null
+++ b/arch/powerpc/include/asm/asm-405.h
@@ -0,0 +1,19 @@
+#ifndef _ASM_POWERPC_ASM_405_H
+#define _ASM_POWERPC_ASM_405_H
+
+#include <asm/asm-const.h>
+
+#ifdef __KERNEL__
+#ifdef CONFIG_IBM405_ERR77
+/* Erratum #77 on the 405 means we need a sync or dcbt before every
+ * stwcx. The old ATOMIC_SYNC_FIX covered some but not all of this.
+ */
+#define PPC405_ERR77(ra,rb) stringify_in_c(dcbt ra, rb;)
+#define PPC405_ERR77_SYNC stringify_in_c(sync;)
+#else
+#define PPC405_ERR77(ra,rb)
+#define PPC405_ERR77_SYNC
+#endif
+#endif
+
+#endif /* _ASM_POWERPC_ASM_405_H */
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 7f2a7702596c..d2cf3593e987 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -70,17 +70,4 @@
#endif
-#ifdef __KERNEL__
-#ifdef CONFIG_IBM405_ERR77
-/* Erratum #77 on the 405 means we need a sync or dcbt before every
- * stwcx. The old ATOMIC_SYNC_FIX covered some but not all of this.
- */
-#define PPC405_ERR77(ra,rb) stringify_in_c(dcbt ra, rb;)
-#define PPC405_ERR77_SYNC stringify_in_c(sync;)
-#else
-#define PPC405_ERR77(ra,rb)
-#define PPC405_ERR77_SYNC
-#endif
-#endif
-
#endif /* _ASM_POWERPC_ASM_COMPAT_H */
diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
index 682b3e6a1e21..cbdb0b7e60a3 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -10,6 +10,7 @@
#include <linux/types.h>
#include <asm/cmpxchg.h>
#include <asm/barrier.h>
+#include <asm/asm-405.h>
#define ATOMIC_INIT(i) { (i) }
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index b750ffef83c7..ff71566dadee 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -45,6 +45,7 @@
#include <linux/compiler.h>
#include <asm/asm-compat.h>
#include <asm/synch.h>
+#include <asm/asm-405.h>
/* PPC bit number conversion */
#define PPC_BITLSHIFT(be) (BITS_PER_LONG - 1 - (be))
diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index 02f5acd7ccc4..3c3e34240628 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -164,7 +164,6 @@ static inline unsigned long pte_update(pte_t *p,
1: lwarx %0,0,%3\n\
andc %1,%0,%4\n\
or %1,%1,%5\n"
- PPC405_ERR77(0,%3)
" stwcx. %1,0,%3\n\
bne- 1b"
: "=&r" (old), "=&r" (tmp), "=m" (*p)
@@ -186,7 +185,6 @@ static inline unsigned long long pte_update(pte_t *p,
lwzx %0,0,%3\n\
andc %1,%L0,%5\n\
or %1,%1,%6\n"
- PPC405_ERR77(0,%3)
" stwcx. %1,0,%4\n\
bne- 1b"
: "=&r" (old), "=&r" (tmp), "=m" (*p)
diff --git a/arch/powerpc/include/asm/cmpxchg.h b/arch/powerpc/include/asm/cmpxchg.h
index 9b001f1f6b32..67ec1073ac97 100644
--- a/arch/powerpc/include/asm/cmpxchg.h
+++ b/arch/powerpc/include/asm/cmpxchg.h
@@ -7,6 +7,7 @@
#include <asm/synch.h>
#include <asm/asm-compat.h>
#include <linux/bug.h>
+#include <asm/asm-405.h>
#ifdef __BIG_ENDIAN
#define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h
index 1a944c18c539..76c8648d0fa8 100644
--- a/arch/powerpc/include/asm/futex.h
+++ b/arch/powerpc/include/asm/futex.h
@@ -9,6 +9,7 @@
#include <asm/errno.h>
#include <asm/synch.h>
#include <asm/asm-compat.h>
+#include <asm/asm-405.h>
#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
__asm__ __volatile ( \
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 7c46a98cc7f4..7df2f3a66cc5 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
@@ -9,6 +9,7 @@
#include <linux/sched.h>
#include <linux/threads.h>
#include <asm/io.h> /* For sub-arch specific PPC_PIN_SIZE */
+#include <asm/asm-405.h>
extern unsigned long ioremap_bot;
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index 72dc4ddc2972..7ec38f4ee927 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -27,6 +27,7 @@
#include <asm/asm-compat.h>
#include <asm/synch.h>
#include <asm/ppc-opcode.h>
+#include <asm/asm-405.h>
#ifdef CONFIG_PPC64
/* use 0x800000yy when locked, where yy == CPU number */
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 973577f2141c..7642cb984d3a 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -33,6 +33,7 @@
#include <asm/unistd.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/asm-405.h>
/*
* MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE.
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 41374a468d1c..b19d78410511 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -42,6 +42,7 @@
#include <asm/asm-offsets.h>
#include <asm/ptrace.h>
#include <asm/export.h>
+#include <asm/asm-405.h>
/* As with the other PowerPC ports, it is expected that when code
* execution begins here, the following registers contain valid, yet
--
2.13.3
^ permalink raw reply related
* [PATCH v3 02/16] powerpc: remove unneeded inclusions of cpu_has_feature.h
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
Files not using cpu_has_feature() don't need cpu_has_feature.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/cacheflush.h | 1 -
arch/powerpc/include/asm/cputime.h | 1 -
arch/powerpc/include/asm/dbell.h | 1 -
arch/powerpc/kernel/vdso.c | 1 -
4 files changed, 4 deletions(-)
diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h
index 0d72ec75da63..d5a8d7bf0759 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -11,7 +11,6 @@
#include <linux/mm.h>
#include <asm/cputable.h>
-#include <asm/cpu_has_feature.h>
/*
* No cache flushing is required when address mappings are changed,
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index bc4903badb3f..133672744b2e 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -23,7 +23,6 @@
#include <asm/div64.h>
#include <asm/time.h>
#include <asm/param.h>
-#include <asm/cpu_has_feature.h>
typedef u64 __nocast cputime_t;
typedef u64 __nocast cputime64_t;
diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h
index 9f2ae0d25e15..998c42ff1caa 100644
--- a/arch/powerpc/include/asm/dbell.h
+++ b/arch/powerpc/include/asm/dbell.h
@@ -16,7 +16,6 @@
#include <linux/threads.h>
#include <asm/ppc-opcode.h>
-#include <asm/cpu_has_feature.h>
#define PPC_DBELL_MSG_BRDCAST (0x04000000)
#define PPC_DBELL_TYPE(x) (((x) & 0xf) << (63-36))
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index d2205b97628c..65b3bdb99f0b 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -22,7 +22,6 @@
#include <linux/security.h>
#include <linux/memblock.h>
-#include <asm/cpu_has_feature.h>
#include <asm/pgtable.h>
#include <asm/processor.h>
#include <asm/mmu.h>
--
2.13.3
^ permalink raw reply related
* [PATCH v3 01/16] powerpc: remove kdump.h from page.h
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1530807556.git.christophe.leroy@c-s.fr>
page.h doesn't need kdump.h
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/page.h | 1 -
arch/powerpc/kernel/crash.c | 1 -
arch/powerpc/kernel/machine_kexec.c | 1 +
arch/powerpc/kernel/setup_32.c | 1 +
4 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index db7be0779d55..a9fbefaacf10 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -17,7 +17,6 @@
#include <asm/types.h>
#endif
#include <asm/asm-compat.h>
-#include <asm/kdump.h>
/*
* On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 17c8b99680f2..43a3ce2301e8 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -23,7 +23,6 @@
#include <asm/processor.h>
#include <asm/machdep.h>
#include <asm/kexec.h>
-#include <asm/kdump.h>
#include <asm/prom.h>
#include <asm/smp.h>
#include <asm/setjmp.h>
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 936c7e2d421e..e530cbd48995 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -17,6 +17,7 @@
#include <linux/irq.h>
#include <linux/ftrace.h>
+#include <asm/kdump.h>
#include <asm/machdep.h>
#include <asm/pgalloc.h>
#include <asm/prom.h>
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 74457485574b..ef747a5a30b9 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -40,6 +40,7 @@
#include <asm/code-patching.h>
#include <asm/cpu_has_feature.h>
#include <asm/asm-prototypes.h>
+#include <asm/kdump.h>
#define DBG(fmt...)
--
2.13.3
^ permalink raw reply related
* [PATCH v3 00/16] Remove unneccessary included headers
From: Christophe Leroy @ 2018-07-05 16:24 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
The purpose of this serie is to limit the number of includes to
only the necessary ones in order to reduce the number of files
recompiled everytime a header file is modified.
Compilation test: see http://kisskb.ellerman.id.au/kisskb/head/14261/
Among the 4 failures, one is compiler bug that I don't have with GCC 8,
the 3 others are pre-existing failures
Christophe Leroy (16):
powerpc: remove kdump.h from page.h
powerpc: remove unneeded inclusions of cpu_has_feature.h
powerpc/405: move PPC405_ERR77 in asm-405.h
powerpc: move ASM_CONST and stringify_in_c() into asm-const.h
powerpc: clean the inclusion of stringify.h
powerpc: clean inclusions of asm/feature-fixups.h
powerpc: remove superflous inclusions of asm/fixmap.h
powerpc: declare set_breakpoint() static
powerpc/book3s: Remove PPC_PIN_SIZE
powerpc: fix includes in asm/processor.h
powerpc/nohash: fix hash related comments in pgtable.h
powerpc/44x: remove page.h from mmu-44x.h
powerpc: split reg.h in two parts
powerpc: Split synch.h in two parts
powerpc: remove unnecessary inclusion of asm/tlbflush.h
powerpc: split asm/tlbflush.h
arch/powerpc/crypto/md5-asm.S | 1 +
arch/powerpc/crypto/sha1-powerpc-asm.S | 1 +
arch/powerpc/include/asm/asm-405.h | 19 +++++
arch/powerpc/include/asm/asm-compat.h | 26 +------
arch/powerpc/include/asm/asm-const.h | 14 ++++
arch/powerpc/include/asm/atomic.h | 2 +
arch/powerpc/include/asm/barrier.h | 3 +
arch/powerpc/include/asm/bitops.h | 2 +
arch/powerpc/include/asm/book3s/32/pgtable.h | 7 --
arch/powerpc/include/asm/book3s/32/tlbflush.h | 25 +++++++
arch/powerpc/include/asm/book3s/64/hash.h | 2 +
arch/powerpc/include/asm/book3s/64/mmu-hash.h | 2 +-
arch/powerpc/include/asm/book3s/64/radix.h | 2 +
arch/powerpc/include/asm/book3s/tlbflush.h | 11 +++
arch/powerpc/include/asm/cacheflush.h | 1 -
arch/powerpc/include/asm/cmpxchg.h | 3 +-
arch/powerpc/include/asm/code-patching.h | 1 +
arch/powerpc/include/asm/cputable.h | 3 +-
arch/powerpc/include/asm/cputime.h | 1 -
arch/powerpc/include/asm/dbell.h | 2 +-
arch/powerpc/include/asm/dcr-native.h | 1 +
arch/powerpc/include/asm/debug.h | 1 -
arch/powerpc/include/asm/dt_cpu_ftrs.h | 2 -
arch/powerpc/include/asm/exception-64s.h | 2 +
arch/powerpc/include/asm/feature-fixups.h | 2 +
arch/powerpc/include/asm/firmware.h | 3 +-
arch/powerpc/include/asm/fixmap.h | 2 -
arch/powerpc/include/asm/futex.h | 2 +-
arch/powerpc/include/asm/highmem.h | 2 +-
arch/powerpc/include/asm/hw_breakpoint.h | 1 +
arch/powerpc/include/asm/iommu.h | 1 +
arch/powerpc/include/asm/jump_label.h | 2 +-
arch/powerpc/include/asm/kvm_booke_hv_asm.h | 2 +
arch/powerpc/include/asm/mmu-44x.h | 10 +--
arch/powerpc/include/asm/mmu.h | 3 +-
arch/powerpc/include/asm/nohash/32/pgtable.h | 7 +-
arch/powerpc/include/asm/nohash/64/pgtable.h | 19 ++---
arch/powerpc/include/asm/{ => nohash}/tlbflush.h | 42 ++---------
arch/powerpc/include/asm/page.h | 3 +-
arch/powerpc/include/asm/page_64.h | 2 +
arch/powerpc/include/asm/ppc-opcode.h | 3 +-
arch/powerpc/include/asm/ppc_asm.h | 1 +
arch/powerpc/include/asm/processor.h | 5 +-
arch/powerpc/include/asm/ptrace.h | 1 +
arch/powerpc/include/asm/reg-ftr.h | 71 +++++++++++++++++++
arch/powerpc/include/asm/reg.h | 42 +----------
arch/powerpc/include/asm/reg_a2.h | 2 +
arch/powerpc/include/asm/reg_fsl_emb.h | 2 +
arch/powerpc/include/asm/spinlock.h | 3 +-
arch/powerpc/include/asm/{synch.h => synch-ftr.h} | 24 ++-----
arch/powerpc/include/asm/synch.h | 30 --------
arch/powerpc/include/asm/thread_info.h | 3 +-
arch/powerpc/include/asm/tlb.h | 1 -
arch/powerpc/include/asm/tlbflush.h | 86 ++---------------------
arch/powerpc/include/asm/uaccess.h | 1 -
arch/powerpc/kernel/cpu_setup_6xx.S | 1 +
arch/powerpc/kernel/crash.c | 1 -
arch/powerpc/kernel/entry_32.S | 2 +
arch/powerpc/kernel/entry_64.S | 3 +
arch/powerpc/kernel/exceptions-64e.S | 1 +
arch/powerpc/kernel/exceptions-64s.S | 2 +
arch/powerpc/kernel/fpu.S | 2 +
arch/powerpc/kernel/head_32.S | 1 +
arch/powerpc/kernel/head_40x.S | 1 +
arch/powerpc/kernel/head_64.S | 2 +
arch/powerpc/kernel/head_8xx.S | 1 -
arch/powerpc/kernel/head_fsl_booke.S | 1 +
arch/powerpc/kernel/idle_6xx.S | 1 +
arch/powerpc/kernel/idle_book3s.S | 3 +
arch/powerpc/kernel/idle_e500.S | 1 +
arch/powerpc/kernel/idle_power4.S | 1 +
arch/powerpc/kernel/kvm_emul.S | 1 +
arch/powerpc/kernel/l2cr_6xx.S | 1 +
arch/powerpc/kernel/machine_kexec.c | 1 +
arch/powerpc/kernel/misc_32.S | 1 +
arch/powerpc/kernel/misc_64.S | 1 +
arch/powerpc/kernel/paca.c | 1 +
arch/powerpc/kernel/ppc_save_regs.S | 1 +
arch/powerpc/kernel/process.c | 15 ++--
arch/powerpc/kernel/prom.c | 1 -
arch/powerpc/kernel/prom_init.c | 1 -
arch/powerpc/kernel/setup_32.c | 2 +
arch/powerpc/kernel/setup_64.c | 1 +
arch/powerpc/kernel/swsusp_32.S | 1 +
arch/powerpc/kernel/swsusp_asm64.S | 1 +
arch/powerpc/kernel/tm.S | 2 +
arch/powerpc/kernel/vdso.c | 1 -
arch/powerpc/kernel/vector.S | 1 +
arch/powerpc/kvm/book3s.c | 1 -
arch/powerpc/kvm/book3s_32_mmu.c | 1 -
arch/powerpc/kvm/book3s_64_mmu.c | 1 -
arch/powerpc/kvm/book3s_64_mmu_hv.c | 1 -
arch/powerpc/kvm/book3s_64_slb.S | 3 +
arch/powerpc/kvm/book3s_64_vio.c | 1 -
arch/powerpc/kvm/book3s_64_vio_hv.c | 2 +-
arch/powerpc/kvm/book3s_hv.c | 1 -
arch/powerpc/kvm/book3s_hv_interrupts.S | 2 +
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 1 -
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +
arch/powerpc/kvm/book3s_interrupts.S | 1 +
arch/powerpc/kvm/book3s_pr.c | 1 -
arch/powerpc/kvm/book3s_rmhandlers.S | 2 +
arch/powerpc/kvm/book3s_segment.S | 4 ++
arch/powerpc/kvm/e500.c | 1 -
arch/powerpc/kvm/e500mc.c | 1 -
arch/powerpc/kvm/powerpc.c | 1 -
arch/powerpc/kvm/tm.S | 1 +
arch/powerpc/lib/copypage_64.S | 1 +
arch/powerpc/lib/copyuser_64.S | 2 +
arch/powerpc/lib/feature-fixups-test.S | 2 +
arch/powerpc/lib/hweight_64.S | 1 +
arch/powerpc/lib/ldstfp.S | 1 +
arch/powerpc/lib/locks.c | 1 -
arch/powerpc/lib/memcpy_64.S | 2 +
arch/powerpc/mm/dump_hashpagetable.c | 1 -
arch/powerpc/mm/fault.c | 1 -
arch/powerpc/mm/hash_low_32.S | 1 +
arch/powerpc/mm/hash_native_64.c | 2 +-
arch/powerpc/mm/hash_utils_64.c | 1 -
arch/powerpc/mm/mmu_context_hash32.c | 1 -
arch/powerpc/mm/mmu_decl.h | 1 -
arch/powerpc/mm/slb_low.S | 1 +
arch/powerpc/mm/subpage-prot.c | 1 -
arch/powerpc/mm/tlb_low_64e.S | 1 +
arch/powerpc/mm/tlb_nohash_low.S | 2 +
arch/powerpc/net/bpf_jit32.h | 1 +
arch/powerpc/net/bpf_jit_asm.S | 1 +
arch/powerpc/net/bpf_jit_comp.c | 1 +
arch/powerpc/net/bpf_jit_comp64.c | 1 +
arch/powerpc/perf/req-gen/_begin.h | 2 +
arch/powerpc/perf/req-gen/perf.h | 1 +
arch/powerpc/platforms/cell/cbe_thermal.c | 1 +
arch/powerpc/platforms/cell/spufs/sputrace.h | 1 +
arch/powerpc/platforms/powermac/cache.S | 1 +
arch/powerpc/platforms/powermac/sleep.S | 1 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 2 +
arch/powerpc/platforms/powernv/vas.h | 1 +
arch/powerpc/platforms/pseries/hvCall.S | 1 +
arch/powerpc/platforms/pseries/lpar.c | 1 -
arch/powerpc/platforms/pseries/mobility.c | 1 +
arch/powerpc/platforms/pseries/setup.c | 1 +
arch/powerpc/purgatory/trampoline.S | 10 +--
arch/powerpc/sysdev/cpm1.c | 1 -
arch/powerpc/sysdev/cpm_common.c | 1 -
arch/powerpc/xmon/spr_access.S | 1 +
145 files changed, 312 insertions(+), 340 deletions(-)
create mode 100644 arch/powerpc/include/asm/asm-405.h
create mode 100644 arch/powerpc/include/asm/asm-const.h
create mode 100644 arch/powerpc/include/asm/book3s/32/tlbflush.h
create mode 100644 arch/powerpc/include/asm/book3s/tlbflush.h
copy arch/powerpc/include/asm/{ => nohash}/tlbflush.h (57%)
create mode 100644 arch/powerpc/include/asm/reg-ftr.h
copy arch/powerpc/include/asm/{synch.h => synch-ftr.h} (63%)
--
2.13.3
^ permalink raw reply
* Re: [PATCHv5 2/4] x86: Add build salt to the vDSO
From: Andy Lutomirski @ 2018-07-05 15:58 UTC (permalink / raw)
To: Laura Abbott
Cc: Andy Lutomirski, Mark Wielaard, H . J . Lu, Masahiro Yamada,
Linus Torvalds, X86 ML, LKML, Nick Clifton, Cary Coutant,
Linux Kbuild mailing list, linuxppc-dev, Michael Ellerman,
Catalin Marinas, Will Deacon, linux-arm-kernel
In-Reply-To: <20180703233430.14416-3-labbott@redhat.com>
On Tue, Jul 3, 2018 at 4:34 PM, Laura Abbott <labbott@redhat.com> wrote:
>
> The vDSO needs to have a unique build id in a similar manner
> to the kernel and modules. Use the build salt macro.
>
Looks good to me. I have no idea whose tree these would go through.
> Signed-off-by: Laura Abbott <labbott@redhat.com>
> ---
> v5: Switched to using the single line BUILD_SALT macro
> ---
> arch/x86/entry/vdso/vdso-note.S | 3 +++
> arch/x86/entry/vdso/vdso32/note.S | 3 +++
> 2 files changed, 6 insertions(+)
>
> diff --git a/arch/x86/entry/vdso/vdso-note.S b/arch/x86/entry/vdso/vdso-note.S
> index 79a071e4357e..79423170118f 100644
> --- a/arch/x86/entry/vdso/vdso-note.S
> +++ b/arch/x86/entry/vdso/vdso-note.S
> @@ -3,6 +3,7 @@
> * Here we can supply some information useful to userland.
> */
>
> +#include <linux/build-salt.h>
> #include <linux/uts.h>
> #include <linux/version.h>
> #include <linux/elfnote.h>
> @@ -10,3 +11,5 @@
> ELFNOTE_START(Linux, 0, "a")
> .long LINUX_VERSION_CODE
> ELFNOTE_END
> +
> +BUILD_SALT
> diff --git a/arch/x86/entry/vdso/vdso32/note.S b/arch/x86/entry/vdso/vdso32/note.S
> index 9fd51f206314..e78047d119f6 100644
> --- a/arch/x86/entry/vdso/vdso32/note.S
> +++ b/arch/x86/entry/vdso/vdso32/note.S
> @@ -4,6 +4,7 @@
> * Here we can supply some information useful to userland.
> */
>
> +#include <linux/build-salt.h>
> #include <linux/version.h>
> #include <linux/elfnote.h>
>
> @@ -14,6 +15,8 @@ ELFNOTE_START(Linux, 0, "a")
> .long LINUX_VERSION_CODE
> ELFNOTE_END
>
> +BUILD_SALT
> +
> #ifdef CONFIG_XEN
> /*
> * Add a special note telling glibc's dynamic linker a fake hardware
> --
> 2.17.1
>
^ permalink raw reply
* RE: [PATCH] powerpc/mpic: Cleanup irq vector accounting
From: Bharat Bhushan @ 2018-07-05 15:42 UTC (permalink / raw)
To: Michael Ellerman, benh@kernel.crashing.org, paulus@samba.org,
robh@kernel.org, geoff@infradead.org, tyreld@linux.vnet.ibm.com,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
In-Reply-To: <87efgjku6k.fsf@concordia.ellerman.id.au>
> -----Original Message-----
> From: Michael Ellerman [mailto:mpe@ellerman.id.au]
> Sent: Wednesday, July 4, 2018 6:57 PM
> To: Bharat Bhushan <bharat.bhushan@nxp.com>;
> benh@kernel.crashing.org; paulus@samba.org; robh@kernel.org;
> geoff@infradead.org; tyreld@linux.vnet.ibm.com; linuxppc-
> dev@lists.ozlabs.org; linux-kernel@vger.kernel.org
> Cc: Bharat Bhushan <bharat.bhushan@nxp.com>
> Subject: Re: [PATCH] powerpc/mpic: Cleanup irq vector accounting
>=20
> Bharat Bhushan <Bharat.Bhushan@nxp.com> writes:
>=20
> > Available vector space accounts ipis and timer interrupts while
> > spurious vector was not accounted.
>=20
> OK. What is the symptom of that? Nothing? Total system crash?
>=20
> Looks like this can be tagged:
>=20
> Fixes: 0a4081641d72 ("powerpc/mpic: FSL MPIC error interrupt support.")
>=20
> Which added the code that uses "12".
>=20
> > Also later
> > mpic_setup_error_int() escape one more vector, seemingly it assumes
> > one spurious vector.
>=20
> Ah right, I get it now.
>=20
> So there is no bug. It's just a disagreement about whether the "intvec"
> argument to mpic_setup_error_int() indicates the first number that's free=
to
> use or the last number that has been allocated.
>=20
> Right?
Yes, it is not any bug fix. This is minor cleanup where passing rather than=
passing "last intvec used" to "intvec to be used" in mpic_setup_error_int(=
).
Thanks
-Bharat
>=20
> cheers
>=20
> > Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> > ---
> > arch/powerpc/sysdev/fsl_mpic_err.c | 2 +-
> > arch/powerpc/sysdev/mpic.c | 6 +++---
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/powerpc/sysdev/fsl_mpic_err.c
> > b/arch/powerpc/sysdev/fsl_mpic_err.c
> > index 488ec45..2a98837 100644
> > --- a/arch/powerpc/sysdev/fsl_mpic_err.c
> > +++ b/arch/powerpc/sysdev/fsl_mpic_err.c
> > @@ -76,7 +76,7 @@ int mpic_setup_error_int(struct mpic *mpic, int
> intvec)
> > mpic->flags |=3D MPIC_FSL_HAS_EIMR;
> > /* allocate interrupt vectors for error interrupts */
> > for (i =3D MPIC_MAX_ERR - 1; i >=3D 0; i--)
> > - mpic->err_int_vecs[i] =3D --intvec;
> > + mpic->err_int_vecs[i] =3D intvec--;
> >
> > return 0;
> > }
> > diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> > index 1d4e0ef6..e098d1e 100644
> > --- a/arch/powerpc/sysdev/mpic.c
> > +++ b/arch/powerpc/sysdev/mpic.c
> > @@ -1380,12 +1380,12 @@ struct mpic * __init mpic_alloc(struct
> device_node *node,
> > * global vector number space, as in case of ipis
> > * and timer interrupts.
> > *
> > - * Available vector space =3D intvec_top - 12, where 12
> > + * Available vector space =3D intvec_top - 13, where 13
> > * is the number of vectors which have been consumed by
> > - * ipis and timer interrupts.
> > + * ipis, timer interrupts and spurious.
> > */
> > if (fsl_version >=3D 0x401) {
> > - ret =3D mpic_setup_error_int(mpic, intvec_top - 12);
> > + ret =3D mpic_setup_error_int(mpic, intvec_top - 13);
> > if (ret)
> > return NULL;
> > }
> > --
> > 1.9.3
^ permalink raw reply
* Re: [PATCH v3 2/3] hwmon: ibmpowernv: Add attributes to enable/disable sensor groups
From: Guenter Roeck @ 2018-07-05 15:37 UTC (permalink / raw)
To: Shilpasri G Bhat, mpe, linuxppc-dev, linux-hwmon, linux-kernel,
ego
In-Reply-To: <1530798689-27742-3-git-send-email-shilpa.bhat@linux.vnet.ibm.com>
On 07/05/2018 06:51 AM, Shilpasri G Bhat wrote:
> On-Chip-Controller(OCC) is an embedded micro-processor in POWER9 chip
> which measures various system and chip level sensors. These sensors
> comprises of environmental sensors (like power, temperature, current
> and voltage) and performance sensors (like utilization, frequency).
> All these sensors are copied to main memory at a regular interval of
> 100ms. OCC provides a way to select a group of sensors that is copied
> to the main memory to increase the update frequency of selected sensor
> groups. When a sensor-group is disabled, OCC will not copy it to main
> memory and those sensors read 0 values.
>
> This patch provides support for enabling/disabling the sensor groups
> like power, temperature, current and voltage. This patch adds new
> per-senor sysfs attribute to disable and enable them.
>
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> ---
> Changes from v2:
> - Writes to first 'enable' attribute of the sensor group will affect all the
> sensors in the group
> - Removed global mutex and made it per sensor-group
>
> drivers/hwmon/ibmpowernv.c | 184 ++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 155 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
> index f829dad..9c6adee 100644
> --- a/drivers/hwmon/ibmpowernv.c
> +++ b/drivers/hwmon/ibmpowernv.c
> @@ -73,6 +73,10 @@ enum sensors {
> struct attribute_group group;
> u32 attr_count;
> u32 hwmon_index;
> + struct mutex mutex;
> + u32 *gid;
> + u32 nr_gid;
> + bool enable;
> } sensor_groups[] = {
> { "fan" },
> { "temp" },
> @@ -105,6 +109,9 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
> ssize_t ret;
> u64 x;
>
> + if (!sensor_groups[sdata->type].enable)
> + return -ENODATA;
> +
> ret = opal_get_sensor_data_u64(sdata->id, &x);
>
> if (ret)
> @@ -120,6 +127,46 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
> return sprintf(buf, "%llu\n", x);
> }
>
> +static ssize_t show_enable(struct device *dev,
> + struct device_attribute *devattr, char *buf)
> +{
> + struct sensor_data *sdata = container_of(devattr, struct sensor_data,
> + dev_attr);
> +
> + return sprintf(buf, "%u\n", sensor_groups[sdata->type].enable);
> +}
> +
> +static ssize_t store_enable(struct device *dev,
> + struct device_attribute *devattr,
> + const char *buf, size_t count)
> +{
> + struct sensor_data *sdata = container_of(devattr, struct sensor_data,
> + dev_attr);
> + struct sensor_group *sg = &sensor_groups[sdata->type];
> + int ret, i;
> + bool data;
> +
> + ret = kstrtobool(buf, &data);
> + if (ret)
> + return ret;
> +
> + ret = mutex_lock_interruptible(&sg->mutex);
> + if (ret)
> + return ret;
> +
> + if (data != sg->enable)
> + for (i = 0; i < sg->nr_gid && !ret; i++)
> + ret = sensor_group_enable(sg->gid[i], data);
> +
Wouldn't it be better to have a separate attribute for each of the
affected groups if there can be more than one ? Just wondering.
The idea was to widen the scope to a point where there is a 1:1 match
between the hardware capabilities and attributes. Clearly having
a separate attribute for all sensors was inappropriate, but the code
above now suggests that a single attribute for all sensors may have
widened the scope too much (because the hardware can do better than
this).
Thanks,
Guenter
> + if (!ret) {
> + sg->enable = data;
> + ret = count;
> + }
> +
> + mutex_unlock(&sg->mutex);
> + return ret;
> +}
> +
> static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
> char *buf)
> {
> @@ -292,13 +339,68 @@ static u32 get_sensor_hwmon_index(struct sensor_data *sdata,
> return ++sensor_groups[sdata->type].hwmon_index;
> }
>
> +static int init_sensor_group_data(struct platform_device *pdev)
> +{
> + struct device_node *groups, *sg;
> + enum sensors type;
> + int ret = 0, i;
> +
> + for (i = 0; i < MAX_SENSOR_TYPE; i++) {
> + sensor_groups[i].nr_gid = 0;
> + sensor_groups[i].enable = true;
> + }
> +
> + groups = of_find_node_by_path("/ibm,opal/sensor-groups");
> + if (!groups)
> + return ret;
> +
> + for (i = 0; i < MAX_SENSOR_TYPE; i++) {
> + u32 gid[256];
> + u32 id, size;
> +
> + for_each_child_of_node(groups, sg) {
> + type = get_sensor_type(sg);
> + if (type != i)
> + continue;
> +
> + if (of_property_read_u32(sg, "sensor-group-id", &id))
> + continue;
> +
> + gid[sensor_groups[i].nr_gid++] = id;
> + }
> +
> + if (!sensor_groups[i].nr_gid)
> + continue;
> +
> + size = sensor_groups[i].nr_gid * sizeof(u32);
> + sensor_groups[i].gid = devm_kzalloc(&pdev->dev, size,
> + GFP_KERNEL);
> + if (!sensor_groups[i].gid) {
> + ret = -ENOMEM;
> + break;
> + }
> +
> + memcpy(sensor_groups[i].gid, gid, size);
> + sensor_groups[i].enable = false;
> + mutex_init(&sensor_groups[i].mutex);
> + }
> +
> + of_node_put(groups);
> + return ret;
> +}
> +
> static int populate_attr_groups(struct platform_device *pdev)
> {
> struct platform_data *pdata = platform_get_drvdata(pdev);
> const struct attribute_group **pgroups = pdata->attr_groups;
> struct device_node *opal, *np;
> + int ret;
> enum sensors type;
>
> + ret = init_sensor_group_data(pdev);
> + if (ret)
> + return ret;
> +
> opal = of_find_node_by_path("/ibm,opal/sensors");
> for_each_child_of_node(opal, np) {
> const char *label;
> @@ -313,7 +415,7 @@ static int populate_attr_groups(struct platform_device *pdev)
> sensor_groups[type].attr_count++;
>
> /*
> - * add attributes for labels, min and max
> + * add attributes for labels, min, max and enable
> */
> if (!of_property_read_string(np, "label", &label))
> sensor_groups[type].attr_count++;
> @@ -321,6 +423,8 @@ static int populate_attr_groups(struct platform_device *pdev)
> sensor_groups[type].attr_count++;
> if (of_find_property(np, "sensor-data-max", NULL))
> sensor_groups[type].attr_count++;
> + if (sensor_groups[type].nr_gid)
> + sensor_groups[type].attr_count++;
> }
>
> of_node_put(opal);
> @@ -344,7 +448,10 @@ static int populate_attr_groups(struct platform_device *pdev)
> static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
> ssize_t (*show)(struct device *dev,
> struct device_attribute *attr,
> - char *buf))
> + char *buf),
> + ssize_t (*store)(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count))
> {
> snprintf(sdata->name, MAX_ATTR_LEN, "%s%d_%s",
> sensor_groups[sdata->type].name, sdata->hwmon_index,
> @@ -352,8 +459,13 @@ static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
>
> sysfs_attr_init(&sdata->dev_attr.attr);
> sdata->dev_attr.attr.name = sdata->name;
> - sdata->dev_attr.attr.mode = S_IRUGO;
> sdata->dev_attr.show = show;
> + if (store) {
> + sdata->dev_attr.store = store;
> + sdata->dev_attr.attr.mode = 0664;
> + } else {
> + sdata->dev_attr.attr.mode = 0444;
> + }
> }
>
> static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
> @@ -361,13 +473,16 @@ static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
> const struct attribute_group *pgroup,
> ssize_t (*show)(struct device *dev,
> struct device_attribute *attr,
> - char *buf))
> + char *buf),
> + ssize_t (*store)(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count))
> {
> sdata->id = sid;
> sdata->type = type;
> sdata->opal_index = od;
> sdata->hwmon_index = hd;
> - create_hwmon_attr(sdata, attr_name, show);
> + create_hwmon_attr(sdata, attr_name, show, store);
> pgroup->attrs[sensor_groups[type].attr_count++] = &sdata->dev_attr.attr;
> }
>
> @@ -408,18 +523,16 @@ static int create_device_attrs(struct platform_device *pdev)
> u32 count = 0;
> int err = 0;
>
> - opal = of_find_node_by_path("/ibm,opal/sensors");
> sdata = devm_kcalloc(&pdev->dev,
> pdata->sensors_count, sizeof(*sdata),
> GFP_KERNEL);
> - if (!sdata) {
> - err = -ENOMEM;
> - goto exit_put_node;
> - }
> + if (!sdata)
> + return -ENOMEM;
>
> + opal = of_find_node_by_path("/ibm,opal/sensors");
> for_each_child_of_node(opal, np) {
> const char *attr_name;
> - u32 opal_index;
> + u32 opal_index, hw_id;
> const char *label;
>
> if (np->name == NULL)
> @@ -456,14 +569,11 @@ static int create_device_attrs(struct platform_device *pdev)
> opal_index = INVALID_INDEX;
> }
>
> - sdata[count].opal_index = opal_index;
> - sdata[count].hwmon_index =
> - get_sensor_hwmon_index(&sdata[count], sdata, count);
> -
> - create_hwmon_attr(&sdata[count], attr_name, show_sensor);
> -
> - pgroups[type]->attrs[sensor_groups[type].attr_count++] =
> - &sdata[count++].dev_attr.attr;
> + hw_id = get_sensor_hwmon_index(&sdata[count], sdata, count);
> + populate_sensor(&sdata[count], opal_index, hw_id, sensor_id,
> + attr_name, type, pgroups[type], show_sensor,
> + NULL);
> + count++;
>
> if (!of_property_read_string(np, "label", &label)) {
> /*
> @@ -474,33 +584,49 @@ static int create_device_attrs(struct platform_device *pdev)
> */
>
> make_sensor_label(np, &sdata[count], label);
> - populate_sensor(&sdata[count], opal_index,
> - sdata[count - 1].hwmon_index,
> + populate_sensor(&sdata[count], opal_index, hw_id,
> sensor_id, "label", type, pgroups[type],
> - show_label);
> + show_label, NULL);
> count++;
> }
>
> if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) {
> attr_name = get_max_attr(type);
> - populate_sensor(&sdata[count], opal_index,
> - sdata[count - 1].hwmon_index,
> + populate_sensor(&sdata[count], opal_index, hw_id,
> sensor_id, attr_name, type,
> - pgroups[type], show_sensor);
> + pgroups[type], show_sensor, NULL);
> count++;
> }
>
> if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) {
> attr_name = get_min_attr(type);
> - populate_sensor(&sdata[count], opal_index,
> - sdata[count - 1].hwmon_index,
> + populate_sensor(&sdata[count], opal_index, hw_id,
> sensor_id, attr_name, type,
> - pgroups[type], show_sensor);
> + pgroups[type], show_sensor, NULL);
> count++;
> }
> +
> + if (sensor_groups[type].nr_gid) {
> + ssize_t (*store)(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count);
> +
> + if (!sensor_groups[type].enable) {
> + sensor_groups[type].enable = true;
> + store = store_enable;
> + } else {
> + store = NULL;
> + }
> +
> + sensor_groups[type].enable = true;
> + populate_sensor(&sdata[count], opal_index, hw_id,
> + sensor_id, "enable", type,
> + pgroups[type], show_enable, store);
> + count++;
> + }
> +
> }
>
> -exit_put_node:
> of_node_put(opal);
> return err;
> }
>
^ permalink raw reply
* Re: [PATCH v3 3/3] hwmon: Document the sensor enable attribute and update ibmpowernv
From: Guenter Roeck @ 2018-07-05 15:31 UTC (permalink / raw)
To: Shilpasri G Bhat, mpe, linuxppc-dev, linux-hwmon, linux-kernel,
ego
In-Reply-To: <1530798689-27742-4-git-send-email-shilpa.bhat@linux.vnet.ibm.com>
On 07/05/2018 06:51 AM, Shilpasri G Bhat wrote:
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> ---
> Documentation/hwmon/ibmpowernv | 35 +++++++++++++++-
> Documentation/hwmon/sysfs-interface | 82 +++++++++++++++++++++++++++++++++++++
I guess I wasn't specific enough. The sysfs ABI change must be a separate patch,
independent of the driver (and driver documentation) changes. If you want to document
the driver changes with the same patch as the driver or in a separate patch is up
to you, but I'll want the ABI changes in a separate patch.
Guenter
> 2 files changed, 115 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/hwmon/ibmpowernv b/Documentation/hwmon/ibmpowernv
> index 8826ba2..77ddba7 100644
> --- a/Documentation/hwmon/ibmpowernv
> +++ b/Documentation/hwmon/ibmpowernv
> @@ -33,9 +33,40 @@ fanX_input Measured RPM value.
> fanX_min Threshold RPM for alert generation.
> fanX_fault 0: No fail condition
> 1: Failing fan
> +
> tempX_input Measured ambient temperature.
> tempX_max Threshold ambient temperature for alert generation.
> -inX_input Measured power supply voltage
> +tempX_highest Historical maximum temperature
> +tempX_lowest Historical minimum temperature
> +temp1_enable Enable/disable all temperature sensors
> + 1: Enable
> + 0: Disable
> +temp[2-N]_enable State of the sensor (enabled/disabled)
> +
> +inX_input Measured power supply voltage (millivolt)
> inX_fault 0: No fail condition.
> 1: Failing power supply.
> -power1_input System power consumption (microWatt)
> +inX_highest Historical maximum voltage
> +inX_lowest Historical minimum voltage
> +in1_enable Enable/disable all voltage sensors
> + 1: Enable
> + 0: Disable
> +in[2-N]_enable State of the sensor (enabled/disabled)
> +
> +powerX_input Power consumption (microWatt)
> +powerX_input_highest Historical maximum power
> +powerX_input_lowest Historical minimum power
> +power1_enable Enable/disable all power sensors
> + 1: Enable
> + 0: Disable
> +power[2-N]_enable State of the sensor (enabled/disabled)
> +
> +currX_input Measured current (milliampere)
> +currX_highest Historical maximum current
> +currX_lowest Historical minimum current
> +curr1_enable Enable/disable all current sensors
> + 1: Enable
> + 0: Disable
> +curr[2-N]_enable State of the sensor (enabled/disabled)
> +
> +energyX_input Cumulative energy (microJoule)
> diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
> index fc337c3..d81109c 100644
> --- a/Documentation/hwmon/sysfs-interface
> +++ b/Documentation/hwmon/sysfs-interface
> @@ -171,6 +171,17 @@ in[0-*]_label Suggested voltage channel label.
> user-space.
> RO
>
> +in[0-*]_enable
> + Enable or disable the sensor.
> + When disabled the sensor read will return -ENODATA. For chips
> + which do not have the capability to disable/enable single sensor
> + but have support for sensor-group disable/enable, will only have
> + the first attribute with write permission. In such cases write
> + to the first attribute will affect all the sensors of this type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> cpu[0-*]_vid CPU core reference voltage.
> Unit: millivolt
> RO
> @@ -236,6 +247,17 @@ fan[1-*]_label Suggested fan channel label.
> In all other cases, the label is provided by user-space.
> RO
>
> +fan[1-*]_enable
> + Enable or disable the sensor.
> + When disabled the sensor read will return -ENODATA. For chips
> + which do not have the capability to disable/enable single sensor
> + but have support for sensor-group disable/enable, will only have
> + the first attribute with write permission. In such cases write
> + to the first attribute will affect all the sensors of this type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> Also see the Alarms section for status flags associated with fans.
>
>
> @@ -409,6 +431,17 @@ temp_reset_history
> Reset temp_lowest and temp_highest for all sensors
> WO
>
> +temp[1-*]_enable
> + Enable or disable the sensor.
> + When disabled the sensor read will return -ENODATA. For chips
> + which do not have the capability to disable/enable single sensor
> + but have support for sensor-group disable/enable, will only have
> + the first attribute with write permission. In such cases write
> + to the first attribute will affect all the sensors of this type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> Some chips measure temperature using external thermistors and an ADC, and
> report the temperature measurement as a voltage. Converting this voltage
> back to a temperature (or the other way around for limits) requires
> @@ -468,6 +501,17 @@ curr_reset_history
> Reset currX_lowest and currX_highest for all sensors
> WO
>
> +curr[1-*]_enable
> + Enable or disable the sensor.
> + When disabled the sensor read will return -ENODATA. For chips
> + which do not have the capability to disable/enable single sensor
> + but have support for sensor-group disable/enable, will only have
> + the first attribute with write permission. In such cases write
> + to the first attribute will affect all the sensors of this type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> Also see the Alarms section for status flags associated with currents.
>
> *********
> @@ -566,6 +610,19 @@ power[1-*]_crit Critical maximum power.
> Unit: microWatt
> RW
>
> +power[1-*]_enable Enable or disable the sensor.
> + When disabled the sensor read will return
> + -ENODATA. For chips which do not have the
> + capability to disable/enable single sensor but
> + have support for sensor-group disable/enable,
> + will only have the first attribute with write
> + permission. In such cases write to the first
> + attribute will affect all the sensors of this
> + type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> Also see the Alarms section for status flags associated with power readings.
>
> **********
> @@ -576,6 +633,18 @@ energy[1-*]_input Cumulative energy use
> Unit: microJoule
> RO
>
> +energy[1-*]_enable Enable or disable the sensor.
> + When disabled the sensor read will return
> + -ENODATA. For chips which do not have the
> + capability to disable/enable single sensor but
> + have support for sensor-group disable/enable,
> + will only have the first attribute with write
> + permission. In such cases write to the first
> + attribute will affect all the sensors of this
> + type.
> + 1: Enable
> + 0: Disable
> + RW/RO
>
> ************
> * Humidity *
> @@ -586,6 +655,19 @@ humidity[1-*]_input Humidity
> RO
>
>
> +humidity[1-*]_enable Enable or disable the sensor.
> + When disabled the sensor read will return
> + -ENODATA. For chips which do not have the
> + capability to disable/enable single sensor but
> + have support for sensor-group disable/enable,
> + will only have the first attribute with write
> + permission. In such cases write to the first
> + attribute will affect all the sensors of this
> + type.
> + 1: Enable
> + 0: Disable
> + RW/RO
> +
> **********
> * Alarms *
> **********
>
^ permalink raw reply
* [PATCH v3 3/3] hwmon: Document the sensor enable attribute and update ibmpowernv
From: Shilpasri G Bhat @ 2018-07-05 13:51 UTC (permalink / raw)
To: linux, mpe, linuxppc-dev, linux-hwmon, linux-kernel, ego; +Cc: Shilpasri G Bhat
In-Reply-To: <1530798689-27742-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
Documentation/hwmon/ibmpowernv | 35 +++++++++++++++-
Documentation/hwmon/sysfs-interface | 82 +++++++++++++++++++++++++++++++++++++
2 files changed, 115 insertions(+), 2 deletions(-)
diff --git a/Documentation/hwmon/ibmpowernv b/Documentation/hwmon/ibmpowernv
index 8826ba2..77ddba7 100644
--- a/Documentation/hwmon/ibmpowernv
+++ b/Documentation/hwmon/ibmpowernv
@@ -33,9 +33,40 @@ fanX_input Measured RPM value.
fanX_min Threshold RPM for alert generation.
fanX_fault 0: No fail condition
1: Failing fan
+
tempX_input Measured ambient temperature.
tempX_max Threshold ambient temperature for alert generation.
-inX_input Measured power supply voltage
+tempX_highest Historical maximum temperature
+tempX_lowest Historical minimum temperature
+temp1_enable Enable/disable all temperature sensors
+ 1: Enable
+ 0: Disable
+temp[2-N]_enable State of the sensor (enabled/disabled)
+
+inX_input Measured power supply voltage (millivolt)
inX_fault 0: No fail condition.
1: Failing power supply.
-power1_input System power consumption (microWatt)
+inX_highest Historical maximum voltage
+inX_lowest Historical minimum voltage
+in1_enable Enable/disable all voltage sensors
+ 1: Enable
+ 0: Disable
+in[2-N]_enable State of the sensor (enabled/disabled)
+
+powerX_input Power consumption (microWatt)
+powerX_input_highest Historical maximum power
+powerX_input_lowest Historical minimum power
+power1_enable Enable/disable all power sensors
+ 1: Enable
+ 0: Disable
+power[2-N]_enable State of the sensor (enabled/disabled)
+
+currX_input Measured current (milliampere)
+currX_highest Historical maximum current
+currX_lowest Historical minimum current
+curr1_enable Enable/disable all current sensors
+ 1: Enable
+ 0: Disable
+curr[2-N]_enable State of the sensor (enabled/disabled)
+
+energyX_input Cumulative energy (microJoule)
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index fc337c3..d81109c 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -171,6 +171,17 @@ in[0-*]_label Suggested voltage channel label.
user-space.
RO
+in[0-*]_enable
+ Enable or disable the sensor.
+ When disabled the sensor read will return -ENODATA. For chips
+ which do not have the capability to disable/enable single sensor
+ but have support for sensor-group disable/enable, will only have
+ the first attribute with write permission. In such cases write
+ to the first attribute will affect all the sensors of this type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
cpu[0-*]_vid CPU core reference voltage.
Unit: millivolt
RO
@@ -236,6 +247,17 @@ fan[1-*]_label Suggested fan channel label.
In all other cases, the label is provided by user-space.
RO
+fan[1-*]_enable
+ Enable or disable the sensor.
+ When disabled the sensor read will return -ENODATA. For chips
+ which do not have the capability to disable/enable single sensor
+ but have support for sensor-group disable/enable, will only have
+ the first attribute with write permission. In such cases write
+ to the first attribute will affect all the sensors of this type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
Also see the Alarms section for status flags associated with fans.
@@ -409,6 +431,17 @@ temp_reset_history
Reset temp_lowest and temp_highest for all sensors
WO
+temp[1-*]_enable
+ Enable or disable the sensor.
+ When disabled the sensor read will return -ENODATA. For chips
+ which do not have the capability to disable/enable single sensor
+ but have support for sensor-group disable/enable, will only have
+ the first attribute with write permission. In such cases write
+ to the first attribute will affect all the sensors of this type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
Some chips measure temperature using external thermistors and an ADC, and
report the temperature measurement as a voltage. Converting this voltage
back to a temperature (or the other way around for limits) requires
@@ -468,6 +501,17 @@ curr_reset_history
Reset currX_lowest and currX_highest for all sensors
WO
+curr[1-*]_enable
+ Enable or disable the sensor.
+ When disabled the sensor read will return -ENODATA. For chips
+ which do not have the capability to disable/enable single sensor
+ but have support for sensor-group disable/enable, will only have
+ the first attribute with write permission. In such cases write
+ to the first attribute will affect all the sensors of this type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
Also see the Alarms section for status flags associated with currents.
*********
@@ -566,6 +610,19 @@ power[1-*]_crit Critical maximum power.
Unit: microWatt
RW
+power[1-*]_enable Enable or disable the sensor.
+ When disabled the sensor read will return
+ -ENODATA. For chips which do not have the
+ capability to disable/enable single sensor but
+ have support for sensor-group disable/enable,
+ will only have the first attribute with write
+ permission. In such cases write to the first
+ attribute will affect all the sensors of this
+ type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
Also see the Alarms section for status flags associated with power readings.
**********
@@ -576,6 +633,18 @@ energy[1-*]_input Cumulative energy use
Unit: microJoule
RO
+energy[1-*]_enable Enable or disable the sensor.
+ When disabled the sensor read will return
+ -ENODATA. For chips which do not have the
+ capability to disable/enable single sensor but
+ have support for sensor-group disable/enable,
+ will only have the first attribute with write
+ permission. In such cases write to the first
+ attribute will affect all the sensors of this
+ type.
+ 1: Enable
+ 0: Disable
+ RW/RO
************
* Humidity *
@@ -586,6 +655,19 @@ humidity[1-*]_input Humidity
RO
+humidity[1-*]_enable Enable or disable the sensor.
+ When disabled the sensor read will return
+ -ENODATA. For chips which do not have the
+ capability to disable/enable single sensor but
+ have support for sensor-group disable/enable,
+ will only have the first attribute with write
+ permission. In such cases write to the first
+ attribute will affect all the sensors of this
+ type.
+ 1: Enable
+ 0: Disable
+ RW/RO
+
**********
* Alarms *
**********
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 2/3] hwmon: ibmpowernv: Add attributes to enable/disable sensor groups
From: Shilpasri G Bhat @ 2018-07-05 13:51 UTC (permalink / raw)
To: linux, mpe, linuxppc-dev, linux-hwmon, linux-kernel, ego; +Cc: Shilpasri G Bhat
In-Reply-To: <1530798689-27742-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com>
On-Chip-Controller(OCC) is an embedded micro-processor in POWER9 chip
which measures various system and chip level sensors. These sensors
comprises of environmental sensors (like power, temperature, current
and voltage) and performance sensors (like utilization, frequency).
All these sensors are copied to main memory at a regular interval of
100ms. OCC provides a way to select a group of sensors that is copied
to the main memory to increase the update frequency of selected sensor
groups. When a sensor-group is disabled, OCC will not copy it to main
memory and those sensors read 0 values.
This patch provides support for enabling/disabling the sensor groups
like power, temperature, current and voltage. This patch adds new
per-senor sysfs attribute to disable and enable them.
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
Changes from v2:
- Writes to first 'enable' attribute of the sensor group will affect all the
sensors in the group
- Removed global mutex and made it per sensor-group
drivers/hwmon/ibmpowernv.c | 184 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 155 insertions(+), 29 deletions(-)
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index f829dad..9c6adee 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -73,6 +73,10 @@ enum sensors {
struct attribute_group group;
u32 attr_count;
u32 hwmon_index;
+ struct mutex mutex;
+ u32 *gid;
+ u32 nr_gid;
+ bool enable;
} sensor_groups[] = {
{ "fan" },
{ "temp" },
@@ -105,6 +109,9 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
ssize_t ret;
u64 x;
+ if (!sensor_groups[sdata->type].enable)
+ return -ENODATA;
+
ret = opal_get_sensor_data_u64(sdata->id, &x);
if (ret)
@@ -120,6 +127,46 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
return sprintf(buf, "%llu\n", x);
}
+static ssize_t show_enable(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ struct sensor_data *sdata = container_of(devattr, struct sensor_data,
+ dev_attr);
+
+ return sprintf(buf, "%u\n", sensor_groups[sdata->type].enable);
+}
+
+static ssize_t store_enable(struct device *dev,
+ struct device_attribute *devattr,
+ const char *buf, size_t count)
+{
+ struct sensor_data *sdata = container_of(devattr, struct sensor_data,
+ dev_attr);
+ struct sensor_group *sg = &sensor_groups[sdata->type];
+ int ret, i;
+ bool data;
+
+ ret = kstrtobool(buf, &data);
+ if (ret)
+ return ret;
+
+ ret = mutex_lock_interruptible(&sg->mutex);
+ if (ret)
+ return ret;
+
+ if (data != sg->enable)
+ for (i = 0; i < sg->nr_gid && !ret; i++)
+ ret = sensor_group_enable(sg->gid[i], data);
+
+ if (!ret) {
+ sg->enable = data;
+ ret = count;
+ }
+
+ mutex_unlock(&sg->mutex);
+ return ret;
+}
+
static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
char *buf)
{
@@ -292,13 +339,68 @@ static u32 get_sensor_hwmon_index(struct sensor_data *sdata,
return ++sensor_groups[sdata->type].hwmon_index;
}
+static int init_sensor_group_data(struct platform_device *pdev)
+{
+ struct device_node *groups, *sg;
+ enum sensors type;
+ int ret = 0, i;
+
+ for (i = 0; i < MAX_SENSOR_TYPE; i++) {
+ sensor_groups[i].nr_gid = 0;
+ sensor_groups[i].enable = true;
+ }
+
+ groups = of_find_node_by_path("/ibm,opal/sensor-groups");
+ if (!groups)
+ return ret;
+
+ for (i = 0; i < MAX_SENSOR_TYPE; i++) {
+ u32 gid[256];
+ u32 id, size;
+
+ for_each_child_of_node(groups, sg) {
+ type = get_sensor_type(sg);
+ if (type != i)
+ continue;
+
+ if (of_property_read_u32(sg, "sensor-group-id", &id))
+ continue;
+
+ gid[sensor_groups[i].nr_gid++] = id;
+ }
+
+ if (!sensor_groups[i].nr_gid)
+ continue;
+
+ size = sensor_groups[i].nr_gid * sizeof(u32);
+ sensor_groups[i].gid = devm_kzalloc(&pdev->dev, size,
+ GFP_KERNEL);
+ if (!sensor_groups[i].gid) {
+ ret = -ENOMEM;
+ break;
+ }
+
+ memcpy(sensor_groups[i].gid, gid, size);
+ sensor_groups[i].enable = false;
+ mutex_init(&sensor_groups[i].mutex);
+ }
+
+ of_node_put(groups);
+ return ret;
+}
+
static int populate_attr_groups(struct platform_device *pdev)
{
struct platform_data *pdata = platform_get_drvdata(pdev);
const struct attribute_group **pgroups = pdata->attr_groups;
struct device_node *opal, *np;
+ int ret;
enum sensors type;
+ ret = init_sensor_group_data(pdev);
+ if (ret)
+ return ret;
+
opal = of_find_node_by_path("/ibm,opal/sensors");
for_each_child_of_node(opal, np) {
const char *label;
@@ -313,7 +415,7 @@ static int populate_attr_groups(struct platform_device *pdev)
sensor_groups[type].attr_count++;
/*
- * add attributes for labels, min and max
+ * add attributes for labels, min, max and enable
*/
if (!of_property_read_string(np, "label", &label))
sensor_groups[type].attr_count++;
@@ -321,6 +423,8 @@ static int populate_attr_groups(struct platform_device *pdev)
sensor_groups[type].attr_count++;
if (of_find_property(np, "sensor-data-max", NULL))
sensor_groups[type].attr_count++;
+ if (sensor_groups[type].nr_gid)
+ sensor_groups[type].attr_count++;
}
of_node_put(opal);
@@ -344,7 +448,10 @@ static int populate_attr_groups(struct platform_device *pdev)
static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
ssize_t (*show)(struct device *dev,
struct device_attribute *attr,
- char *buf))
+ char *buf),
+ ssize_t (*store)(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count))
{
snprintf(sdata->name, MAX_ATTR_LEN, "%s%d_%s",
sensor_groups[sdata->type].name, sdata->hwmon_index,
@@ -352,8 +459,13 @@ static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
sysfs_attr_init(&sdata->dev_attr.attr);
sdata->dev_attr.attr.name = sdata->name;
- sdata->dev_attr.attr.mode = S_IRUGO;
sdata->dev_attr.show = show;
+ if (store) {
+ sdata->dev_attr.store = store;
+ sdata->dev_attr.attr.mode = 0664;
+ } else {
+ sdata->dev_attr.attr.mode = 0444;
+ }
}
static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
@@ -361,13 +473,16 @@ static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
const struct attribute_group *pgroup,
ssize_t (*show)(struct device *dev,
struct device_attribute *attr,
- char *buf))
+ char *buf),
+ ssize_t (*store)(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count))
{
sdata->id = sid;
sdata->type = type;
sdata->opal_index = od;
sdata->hwmon_index = hd;
- create_hwmon_attr(sdata, attr_name, show);
+ create_hwmon_attr(sdata, attr_name, show, store);
pgroup->attrs[sensor_groups[type].attr_count++] = &sdata->dev_attr.attr;
}
@@ -408,18 +523,16 @@ static int create_device_attrs(struct platform_device *pdev)
u32 count = 0;
int err = 0;
- opal = of_find_node_by_path("/ibm,opal/sensors");
sdata = devm_kcalloc(&pdev->dev,
pdata->sensors_count, sizeof(*sdata),
GFP_KERNEL);
- if (!sdata) {
- err = -ENOMEM;
- goto exit_put_node;
- }
+ if (!sdata)
+ return -ENOMEM;
+ opal = of_find_node_by_path("/ibm,opal/sensors");
for_each_child_of_node(opal, np) {
const char *attr_name;
- u32 opal_index;
+ u32 opal_index, hw_id;
const char *label;
if (np->name == NULL)
@@ -456,14 +569,11 @@ static int create_device_attrs(struct platform_device *pdev)
opal_index = INVALID_INDEX;
}
- sdata[count].opal_index = opal_index;
- sdata[count].hwmon_index =
- get_sensor_hwmon_index(&sdata[count], sdata, count);
-
- create_hwmon_attr(&sdata[count], attr_name, show_sensor);
-
- pgroups[type]->attrs[sensor_groups[type].attr_count++] =
- &sdata[count++].dev_attr.attr;
+ hw_id = get_sensor_hwmon_index(&sdata[count], sdata, count);
+ populate_sensor(&sdata[count], opal_index, hw_id, sensor_id,
+ attr_name, type, pgroups[type], show_sensor,
+ NULL);
+ count++;
if (!of_property_read_string(np, "label", &label)) {
/*
@@ -474,33 +584,49 @@ static int create_device_attrs(struct platform_device *pdev)
*/
make_sensor_label(np, &sdata[count], label);
- populate_sensor(&sdata[count], opal_index,
- sdata[count - 1].hwmon_index,
+ populate_sensor(&sdata[count], opal_index, hw_id,
sensor_id, "label", type, pgroups[type],
- show_label);
+ show_label, NULL);
count++;
}
if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) {
attr_name = get_max_attr(type);
- populate_sensor(&sdata[count], opal_index,
- sdata[count - 1].hwmon_index,
+ populate_sensor(&sdata[count], opal_index, hw_id,
sensor_id, attr_name, type,
- pgroups[type], show_sensor);
+ pgroups[type], show_sensor, NULL);
count++;
}
if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) {
attr_name = get_min_attr(type);
- populate_sensor(&sdata[count], opal_index,
- sdata[count - 1].hwmon_index,
+ populate_sensor(&sdata[count], opal_index, hw_id,
sensor_id, attr_name, type,
- pgroups[type], show_sensor);
+ pgroups[type], show_sensor, NULL);
count++;
}
+
+ if (sensor_groups[type].nr_gid) {
+ ssize_t (*store)(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+
+ if (!sensor_groups[type].enable) {
+ sensor_groups[type].enable = true;
+ store = store_enable;
+ } else {
+ store = NULL;
+ }
+
+ sensor_groups[type].enable = true;
+ populate_sensor(&sdata[count], opal_index, hw_id,
+ sensor_id, "enable", type,
+ pgroups[type], show_enable, store);
+ count++;
+ }
+
}
-exit_put_node:
of_node_put(opal);
return err;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 1/3] powernv:opal-sensor-groups: Add support to enable sensor groups
From: Shilpasri G Bhat @ 2018-07-05 13:51 UTC (permalink / raw)
To: linux, mpe, linuxppc-dev, linux-hwmon, linux-kernel, ego; +Cc: Shilpasri G Bhat
In-Reply-To: <1530798689-27742-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com>
Adds support to enable/disable a sensor group at runtime. This
can be used to select the sensor groups that needs to be copied to
main memory by OCC. Sensor groups like power, temperature, current,
voltage, frequency, utilization can be enabled/disabled at runtime.
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
No changes from v2.
arch/powerpc/include/asm/opal-api.h | 1 +
arch/powerpc/include/asm/opal.h | 2 ++
.../powerpc/platforms/powernv/opal-sensor-groups.c | 28 ++++++++++++++++++++++
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
4 files changed, 32 insertions(+)
diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index 3bab299..56a94a1 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -206,6 +206,7 @@
#define OPAL_NPU_SPA_CLEAR_CACHE 160
#define OPAL_NPU_TL_SET 161
#define OPAL_SENSOR_READ_U64 162
+#define OPAL_SENSOR_GROUP_ENABLE 163
#define OPAL_PCI_GET_PBCQ_TUNNEL_BAR 164
#define OPAL_PCI_SET_PBCQ_TUNNEL_BAR 165
#define OPAL_LAST 165
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index e1b2910..fc0550e 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -292,6 +292,7 @@ int64_t opal_imc_counters_init(uint32_t type, uint64_t address,
int opal_get_power_shift_ratio(u32 handle, int token, u32 *psr);
int opal_set_power_shift_ratio(u32 handle, int token, u32 psr);
int opal_sensor_group_clear(u32 group_hndl, int token);
+int opal_sensor_group_enable(u32 group_hndl, int token, bool enable);
s64 opal_signal_system_reset(s32 cpu);
s64 opal_quiesce(u64 shutdown_type, s32 cpu);
@@ -326,6 +327,7 @@ extern int opal_async_wait_response_interruptible(uint64_t token,
struct opal_msg *msg);
extern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data);
extern int opal_get_sensor_data_u64(u32 sensor_hndl, u64 *sensor_data);
+extern int sensor_group_enable(u32 grp_hndl, bool enable);
struct rtc_time;
extern time64_t opal_get_boot_time(void);
diff --git a/arch/powerpc/platforms/powernv/opal-sensor-groups.c b/arch/powerpc/platforms/powernv/opal-sensor-groups.c
index 541c9ea..f7d04b6 100644
--- a/arch/powerpc/platforms/powernv/opal-sensor-groups.c
+++ b/arch/powerpc/platforms/powernv/opal-sensor-groups.c
@@ -32,6 +32,34 @@ struct sg_attr {
struct sg_attr *sgattrs;
} *sgs;
+int sensor_group_enable(u32 handle, bool enable)
+{
+ struct opal_msg msg;
+ int token, ret;
+
+ token = opal_async_get_token_interruptible();
+ if (token < 0)
+ return token;
+
+ ret = opal_sensor_group_enable(handle, token, enable);
+ if (ret == OPAL_ASYNC_COMPLETION) {
+ ret = opal_async_wait_response(token, &msg);
+ if (ret) {
+ pr_devel("Failed to wait for the async response\n");
+ ret = -EIO;
+ goto out;
+ }
+ ret = opal_error_code(opal_get_async_rc(msg));
+ } else {
+ ret = opal_error_code(ret);
+ }
+
+out:
+ opal_async_release_token(token);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(sensor_group_enable);
+
static ssize_t sg_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count)
{
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index a8d9b40..8268a1e 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -327,3 +327,4 @@ OPAL_CALL(opal_npu_tl_set, OPAL_NPU_TL_SET);
OPAL_CALL(opal_pci_get_pbcq_tunnel_bar, OPAL_PCI_GET_PBCQ_TUNNEL_BAR);
OPAL_CALL(opal_pci_set_pbcq_tunnel_bar, OPAL_PCI_SET_PBCQ_TUNNEL_BAR);
OPAL_CALL(opal_sensor_read_u64, OPAL_SENSOR_READ_U64);
+OPAL_CALL(opal_sensor_group_enable, OPAL_SENSOR_GROUP_ENABLE);
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 0/3] hwmon: Add attributes to enable/disable sensors
From: Shilpasri G Bhat @ 2018-07-05 13:51 UTC (permalink / raw)
To: linux, mpe, linuxppc-dev, linux-hwmon, linux-kernel, ego; +Cc: Shilpasri G Bhat
This patch series adds new attribute to enable or disable a sensor in
runtime.
v2 : https://lkml.org/lkml/2018/7/4/263
v1 : https://lkml.org/lkml/2018/3/22/214
Shilpasri G Bhat (3):
powernv:opal-sensor-groups: Add support to enable sensor groups
hwmon: ibmpowernv: Add attributes to enable/disable sensor groups
hwmon: Document the sensor enable attribute and update ibmpowernv
Documentation/hwmon/ibmpowernv | 35 +++-
Documentation/hwmon/sysfs-interface | 82 +++++++++
arch/powerpc/include/asm/opal-api.h | 1 +
arch/powerpc/include/asm/opal.h | 2 +
.../powerpc/platforms/powernv/opal-sensor-groups.c | 28 ++++
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
drivers/hwmon/ibmpowernv.c | 184 +++++++++++++++++----
7 files changed, 302 insertions(+), 31 deletions(-)
--
1.8.3.1
^ permalink raw reply
* Re: [PATCH v2 3/3] powerpc/fsl: Implement cpu_show_spectre_v1/v2 for NXP PowerPC Book3E
From: Diana Madalina Craciun @ 2018-07-05 13:26 UTC (permalink / raw)
To: Michael Ellerman, Michal Suchánek, Bharat Bhushan
Cc: oss@buserror.net, linuxppc-dev@lists.ozlabs.org, Leo Li
In-Reply-To: <87va9wg4qe.fsf@concordia.ellerman.id.au>
On 07/03/2018 10:26 AM, Michael Ellerman wrote:=0A=
> Michal Such=E1nek <msuchanek@suse.de> writes:=0A=
>> On Tue, 12 Jun 2018 02:59:11 +0000=0A=
>> Bharat Bhushan <bharat.bhushan@nxp.com> wrote:=0A=
>>=0A=
>>> Hi Diana,=0A=
>>>=0A=
>>>> -----Original Message-----=0A=
>>>> From: Diana Craciun [mailto:diana.craciun@nxp.com]=0A=
>>>> Sent: Monday, June 11, 2018 6:23 PM=0A=
>>>> To: linuxppc-dev@lists.ozlabs.org=0A=
>>>> Cc: mpe@ellerman.id.au; oss@buserror.net; Leo Li=0A=
>>>> <leoyang.li@nxp.com>; Bharat Bhushan <bharat.bhushan@nxp.com>;=0A=
>>>> Diana Madalina Craciun <diana.craciun@nxp.com>=0A=
>>>> Subject: [PATCH v2 3/3] powerpc/fsl: Implement=0A=
>>>> cpu_show_spectre_v1/v2 for NXP PowerPC Book3E =0A=
>>> Please add some description=0A=
>> To me the subject is self-explanatory. It implements a kernel interface=
=0A=
>> that was already described elsewhere.=0A=
>>=0A=
>> What are you missing here?=0A=
> It should at least explain why it's reimplementing a function that=0A=
> already exists for powerpc. ie. Why can't the existing version be used?=
=0A=
>=0A=
> cheers=0A=
>=0A=
OK. I think I can use the cpu_show_spectre_v1 and for now I can use=0A=
cpu_show_spectre_v2 as well (the patches are under development for=0A=
mitigating Spectre v2). But I cannot use cpu_show_meltdown because it=0A=
uses references to variables that are specific to BOOK3S_64. But I do=0A=
not need a special implementation for cpu_show_meltdown because our=0A=
platform is not vulnerable to Meltdown. So, I will just ifdef the=0A=
cpu_show_meltdown and leave the default implementation.=0A=
=0A=
Diana=0A=
=0A=
=0A=
=0A=
=0A=
^ permalink raw reply
* Re: [PATCH v2 2/3] powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book3E
From: Diana Madalina Craciun @ 2018-07-05 13:21 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev@lists.ozlabs.org
Cc: oss@buserror.net, Leo Li, Bharat Bhushan
In-Reply-To: <87tvpgg4qa.fsf@concordia.ellerman.id.au>
Hi Michael,=0A=
=0A=
Thank you for the review.=0A=
=0A=
On 07/03/2018 10:26 AM, Michael Ellerman wrote:=0A=
> Hi Diana,=0A=
>=0A=
> A few comments below ...=0A=
>=0A=
> Diana Craciun <diana.craciun@nxp.com> writes:=0A=
>> Implement the barrier_nospec as a isync;sync instruction sequence.=0A=
>> The implementation uses the infrastructure built for BOOK3S 64.=0A=
> Do you have any details on why that sequence functions as an effective=0A=
> barrier on your chips?=0A=
=0A=
It was recommended by the hardware team, I do not have details.=0A=
=0A=
>=0A=
> In a lot of places we have eg:=0A=
>=0A=
> +#if defined(CONFIG_PPC_BOOK3S_64) || defined(CONFIG_PPC_FSL_BOOK3E)=0A=
>=0A=
> Can you please add a Kconfig symbol to capture that. eg.=0A=
>=0A=
> config PPC_NOSPEC=0A=
> bool=0A=
> default y=0A=
> depends on PPC_BOOK3S_64 || PPC_FSL_BOOK3E=0A=
>=0A=
>=0A=
> And then use that everywhere.=0A=
=0A=
OK.=0A=
=0A=
>=0A=
>> diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/a=
sm/barrier.h=0A=
>> index f67b3f6..405d572 100644=0A=
>> --- a/arch/powerpc/include/asm/barrier.h=0A=
>> +++ b/arch/powerpc/include/asm/barrier.h=0A=
>> @@ -86,6 +86,16 @@ do { \=0A=
>> // This also acts as a compiler barrier due to the memory clobber.=0A=
>> #define barrier_nospec() asm (stringify_in_c(barrier_nospec_asm) ::: "m=
emory")=0A=
>> =0A=
>> +#elif defined(CONFIG_PPC_FSL_BOOK3E)=0A=
>> +/*=0A=
>> + * Prevent the execution of subsequent instructions speculatively using=
a=0A=
>> + * isync;sync instruction sequence.=0A=
>> + */=0A=
>> +#define barrier_nospec_asm NOSPEC_BARRIER_FIXUP_SECTION; nop; nop=0A=
>> +=0A=
>> +// This also acts as a compiler barrier due to the memory clobber.=0A=
>> +#define barrier_nospec() asm (stringify_in_c(barrier_nospec_asm) ::: "m=
emory")=0A=
>> +=0A=
>> #else /* !CONFIG_PPC_BOOK3S_64 */=0A=
>> #define barrier_nospec_asm=0A=
>> #define barrier_nospec()=0A=
> If we have CONFIG_PPC_NOSPEC this can be done something like:=0A=
>=0A=
> #ifdef CONFIG_PPC_BOOK3S_64=0A=
> #define NOSPEC_BARRIER_SLOT nop=0A=
> #elif defined(CONFIG_PPC_FSL_BOOK3E)=0A=
> #define NOSPEC_BARRIER_SLOT nop; nop=0A=
> #endif /* CONFIG_PPC_BOOK3S_64 */=0A=
>=0A=
> #ifdef CONFIG_PPC_NOSPEC=0A=
> /*=0A=
> * Prevent execution of subsequent instructions until preceding branches =
have=0A=
> * been fully resolved and are no longer executing speculatively.=0A=
> */=0A=
> #define barrier_nospec_asm NOSPEC_BARRIER_FIXUP_SECTION; NOSPEC_BARRIER_S=
LOT=0A=
>=0A=
> // This also acts as a compiler barrier due to the memory clobber.=0A=
> #define barrier_nospec() asm (stringify_in_c(barrier_nospec_asm) ::: "mem=
ory")=0A=
> #else=0A=
> #define barrier_nospec_asm=0A=
> #define barrier_nospec()=0A=
> #endif /* CONFIG_PPC_NOSPEC */=0A=
=0A=
OK.=0A=
=0A=
>=0A=
>=0A=
>> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile=
=0A=
>> index 2b4c40b2..d9dee43 100644=0A=
>> --- a/arch/powerpc/kernel/Makefile=0A=
>> +++ b/arch/powerpc/kernel/Makefile=0A=
>> @@ -76,7 +76,7 @@ endif=0A=
>> obj64-$(CONFIG_HIBERNATION) +=3D swsusp_asm64.o=0A=
>> obj-$(CONFIG_MODULES) +=3D module.o module_$(BITS).o=0A=
>> obj-$(CONFIG_44x) +=3D cpu_setup_44x.o=0A=
>> -obj-$(CONFIG_PPC_FSL_BOOK3E) +=3D cpu_setup_fsl_booke.o=0A=
>> +obj-$(CONFIG_PPC_FSL_BOOK3E) +=3D cpu_setup_fsl_booke.o security.o=0A=
>> obj-$(CONFIG_PPC_DOORBELL) +=3D dbell.o=0A=
>> obj-$(CONFIG_JUMP_LABEL) +=3D jump_label.o=0A=
> Can we instead do:=0A=
>=0A=
> obj-$(CONFIG_PPC_NOSPEC) +=3D security.o=0A=
=0A=
OK=0A=
=0A=
>=0A=
>> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/securi=
ty.c=0A=
>> index c55e102..797c975 100644=0A=
>> --- a/arch/powerpc/kernel/security.c=0A=
>> +++ b/arch/powerpc/kernel/security.c=0A=
>> @@ -13,7 +13,9 @@=0A=
>> #include <asm/setup.h>=0A=
>> =0A=
>> =0A=
>> +#ifdef CONFIG_PPC_BOOK3S_64=0A=
>> unsigned long powerpc_security_features __read_mostly =3D SEC_FTR_DEFAU=
LT;=0A=
>> +#endif /* CONFIG_PPC_BOOK3S_64 */=0A=
> Why are you making that book3s specific?=0A=
>=0A=
> By doing that you then can't use the existing versions of=0A=
> setup_barrier_nospec() and cpu_show_spectre_v1/v2().=0A=
>=0A=
>> @@ -24,6 +26,7 @@ static void enable_barrier_nospec(bool enable)=0A=
>> do_barrier_nospec_fixups(enable);=0A=
>> }=0A=
>> =0A=
>> +#ifdef CONFIG_PPC_BOOK3S_64=0A=
>> void setup_barrier_nospec(void)=0A=
>> {=0A=
>> bool enable;=0A=
>> @@ -46,6 +49,15 @@ void setup_barrier_nospec(void)=0A=
>> if (!no_nospec)=0A=
>> enable_barrier_nospec(enable);=0A=
>> }=0A=
>> +#endif /* CONFIG_PPC_BOOK3S_64 */=0A=
>> +=0A=
>> +#ifdef CONFIG_PPC_FSL_BOOK3E=0A=
>> +void setup_barrier_nospec(void)=0A=
>> +{=0A=
>> + if (!no_nospec)=0A=
>> + enable_barrier_nospec(true);=0A=
>> +}=0A=
>> +#endif /* CONFIG_PPC_FSL_BOOK3E */=0A=
> eg. that is identical to the existing version except for the feature chec=
k:=0A=
>=0A=
> enable =3D security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) &&=0A=
> security_ftr_enabled(SEC_FTR_BNDS_CHK_SPEC_BAR);=0A=
>=0A=
>=0A=
> Both those bits are enabled by default, so you shouldn't need to elide=0A=
> that check.=0A=
>=0A=
> So basically you should be able to use the existing=0A=
> setup_barrier_nospec() if you just remove the ifdef around=0A=
> powerpc_security_features. Or am I missing something?=0A=
=0A=
OK. I was under the impression that those bits are not enabled by=0A=
default. But obviously I was wrong. In this case I will use the existing=0A=
function.=0A=
=0A=
>=0A=
>=0A=
>> diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_=
32.c=0A=
>> index 7445748..80c1e6e 100644=0A=
>> --- a/arch/powerpc/kernel/setup_32.c=0A=
>> +++ b/arch/powerpc/kernel/setup_32.c=0A=
>> @@ -116,6 +116,11 @@ notrace void __init machine_init(u64 dt_ptr)=0A=
>> /* Do some early initialization based on the flat device tree */=0A=
>> early_init_devtree(__va(dt_ptr));=0A=
>> =0A=
>> + /* Apply the speculation barrier fixup */=0A=
>> +#ifdef CONFIG_PPC_FSL_BOOK3E=0A=
>> + setup_barrier_nospec();=0A=
>> +#endif=0A=
> This ifdef should be handled in a header with an empty version for the=0A=
> #else case.=0A=
=0A=
OK=0A=
=0A=
>=0A=
>> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_=
64.c=0A=
>> index 7a7ce8a..b2a644a 100644=0A=
>> --- a/arch/powerpc/kernel/setup_64.c=0A=
>> +++ b/arch/powerpc/kernel/setup_64.c=0A=
>> @@ -327,6 +327,12 @@ void __init early_setup(unsigned long dt_ptr)=0A=
>> =0A=
>> /* Apply all the dynamic patching */=0A=
>> apply_feature_fixups();=0A=
>> +=0A=
>> + /* Apply the speculation barrier fixup */=0A=
>> +#ifdef CONFIG_PPC_FSL_BOOK3E=0A=
>> + setup_barrier_nospec();=0A=
>> +#endif /* CONFIG_PPC_FSL_BOOK3E */=0A=
> Can you call it from ppc_md->setup_arch() like the other platforms?=0A=
>=0A=
> Failing that we could put it in setup_arch() after the call to=0A=
> ppc_md->setup_arch(), so we can share it with powernv/pseries.=0A=
=0A=
The reason for which I did not call it from the ppc_md->setup_arch() was=0A=
that from my point of view the mitigation is not specific to the=0A=
platform code, but rather to the CPU.=0A=
=0A=
>=0A=
>> diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/featur=
e-fixups.c=0A=
>> index 2b9173d..bea2b87 100644=0A=
>> --- a/arch/powerpc/lib/feature-fixups.c=0A=
>> +++ b/arch/powerpc/lib/feature-fixups.c=0A=
>> @@ -188,7 +188,40 @@ void do_barrier_nospec_fixups_range(bool enable, vo=
id *fixup_start, void *fixup_=0A=
>> =0A=
>> printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i);=0A=
>> }=0A=
>> +#endif /* CONFIG_PPC_BOOK3S_64 */=0A=
>> +=0A=
>> +#ifdef CONFIG_PPC_FSL_BOOK3E=0A=
>> +void do_barrier_nospec_fixups_range(bool enable, void *fixup_start, voi=
d *fixup_end)=0A=
>> +{=0A=
>> + unsigned int instr[2], *dest;=0A=
>> + long *start, *end;=0A=
>> + int i;=0A=
>> +=0A=
>> + start =3D fixup_start;=0A=
>> + end =3D fixup_end;=0A=
>> +=0A=
>> + instr[0] =3D PPC_INST_NOP;=0A=
>> + instr[1] =3D PPC_INST_NOP;=0A=
>> +=0A=
>> + if (enable) {=0A=
>> + pr_info("barrier_nospec; using isync; sync as a speculation barrier\n=
");=0A=
>> + instr[0] =3D PPC_INST_ISYNC;=0A=
>> + instr[1] =3D PPC_INST_SYNC;=0A=
>> + }=0A=
>> +=0A=
>> + for (i =3D 0; start < end; start++, i++) {=0A=
>> + dest =3D (void *)start + *start;=0A=
>> + pr_devel("patching dest %lx\n", (unsigned long)dest);=0A=
>> =0A=
>> + patch_instruction(dest, instr[0]);=0A=
>> + patch_instruction(dest + 1, instr[1]);=0A=
>> + }=0A=
>> +=0A=
>> + pr_debug("barrier-nospec: patched %d locations\n", i);=0A=
>> +}=0A=
>> +#endif /* CONFIG_PPC_FSL_BOOK3E */=0A=
> It's a bit unfortunate that we end up with two versions of that, which=0A=
> are 80% the same. But merging them without ugly ifdefs would require a=0A=
> bit more refactoring. So I guess it's OK for now.=0A=
>=0A=
> cheers=0A=
>=0A=
Regards,=0A=
=0A=
Diana=0A=
=0A=
^ permalink raw reply
* Re: [PATCH 15/26] ppc: Convert vas ID allocation to new IDA API
From: Matthew Wilcox @ 2018-07-05 12:17 UTC (permalink / raw)
To: linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Sukadev Bhattiprolu, linuxppc-dev
In-Reply-To: <20180621212835.5636-16-willy@infradead.org>
On Thu, Jun 21, 2018 at 02:28:24PM -0700, Matthew Wilcox wrote:
> Removes a custom spinlock and simplifies the code.
I took a closer look at this patch as part of fixing the typo *ahem*.
The original code is buggy at the limit:
- if (winid > VAS_WINDOWS_PER_CHIP) {
- pr_err("Too many (%d) open windows\n", winid);
- vas_release_window_id(ida, winid);
That permits winid to be == VAS_WINDOWS_PER_CHIP, which is 64 << 10.
Since you then go on to store:
int id = window->winid;
vinst->windows[id] = window;
and windows is defined as:
struct vas_window *windows[VAS_WINDOWS_PER_CHIP];
that's a buffer overflow.
Here's the current version of my patch which will be in linux-next tomorrow.
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index ff9f48812331..e59e0e60e5b5 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -515,35 +515,17 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
return 0;
}
-static DEFINE_SPINLOCK(vas_ida_lock);
-
static void vas_release_window_id(struct ida *ida, int winid)
{
- spin_lock(&vas_ida_lock);
- ida_remove(ida, winid);
- spin_unlock(&vas_ida_lock);
+ ida_free(ida, winid);
}
static int vas_assign_window_id(struct ida *ida)
{
- int rc, winid;
-
- do {
- rc = ida_pre_get(ida, GFP_KERNEL);
- if (!rc)
- return -EAGAIN;
-
- spin_lock(&vas_ida_lock);
- rc = ida_get_new(ida, &winid);
- spin_unlock(&vas_ida_lock);
- } while (rc == -EAGAIN);
-
- if (rc)
- return rc;
+ int winid = ida_alloc_max(ida, VAS_WINDOWS_PER_CHIP - 1, GFP_KERNEL);
- if (winid > VAS_WINDOWS_PER_CHIP) {
- pr_err("Too many (%d) open windows\n", winid);
- vas_release_window_id(ida, winid);
+ if (winid == -ENOSPC) {
+ pr_err("Too many (%d) open windows\n", VAS_WINDOWS_PER_CHIP);
return -EAGAIN;
}
^ permalink raw reply related
* [PATCH v4 2/2] powernv/cpuidle: Use parsed device tree values for cpuidle_init
From: Akshay Adiga @ 2018-07-05 11:40 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, linux-pm
Cc: rjw, stewart, benh, svaidy, ego, npiggin, mpe, Akshay Adiga
In-Reply-To: <20180705114022.19285-1-akshay.adiga@linux.vnet.ibm.com>
Export pnv_idle_states and nr_pnv_idle_states so that its accessible to
cpuidle driver. Use properties from pnv_idle_states structure for powernv
cpuidle_init.
Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/cpuidle.h | 2 +
drivers/cpuidle/cpuidle-powernv.c | 158 +++++------------------------
2 files changed, 28 insertions(+), 132 deletions(-)
diff --git a/arch/powerpc/include/asm/cpuidle.h b/arch/powerpc/include/asm/cpuidle.h
index 574b0ce1d671..43e5f31fe64d 100644
--- a/arch/powerpc/include/asm/cpuidle.h
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -90,6 +90,8 @@ struct pnv_idle_states_t {
bool valid;
};
+extern struct pnv_idle_states_t *pnv_idle_states;
+extern int nr_pnv_idle_states;
extern u32 pnv_fastsleep_workaround_at_entry[];
extern u32 pnv_fastsleep_workaround_at_exit[];
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index d29e4f041efe..84b1ebe212b3 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -242,6 +242,7 @@ static inline void add_powernv_state(int index, const char *name,
powernv_states[index].target_residency = target_residency;
powernv_states[index].exit_latency = exit_latency;
powernv_states[index].enter = idle_fn;
+ /* For power8 and below psscr_* will be 0 */
stop_psscr_table[index].val = psscr_val;
stop_psscr_table[index].mask = psscr_mask;
}
@@ -263,186 +264,80 @@ static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len,
extern u32 pnv_get_supported_cpuidle_states(void);
static int powernv_add_idle_states(void)
{
- struct device_node *power_mgt;
int nr_idle_states = 1; /* Snooze */
- int dt_idle_states, count;
- u32 latency_ns[CPUIDLE_STATE_MAX];
- u32 residency_ns[CPUIDLE_STATE_MAX];
- u32 flags[CPUIDLE_STATE_MAX];
- u64 psscr_val[CPUIDLE_STATE_MAX];
- u64 psscr_mask[CPUIDLE_STATE_MAX];
- const char *names[CPUIDLE_STATE_MAX];
+ int dt_idle_states;
u32 has_stop_states = 0;
- int i, rc;
+ int i;
u32 supported_flags = pnv_get_supported_cpuidle_states();
/* Currently we have snooze statically defined */
-
- power_mgt = of_find_node_by_path("/ibm,opal/power-mgt");
- if (!power_mgt) {
- pr_warn("opal: PowerMgmt Node not found\n");
- goto out;
- }
-
- /* Read values of any property to determine the num of idle states */
- dt_idle_states = of_property_count_u32_elems(power_mgt, "ibm,cpu-idle-state-flags");
- if (dt_idle_states < 0) {
- pr_warn("cpuidle-powernv: no idle states found in the DT\n");
+ if (nr_pnv_idle_states <= 0) {
+ pr_warn("cpuidle-powernv : Only Snooze is available\n");
goto out;
}
- count = of_property_count_u32_elems(power_mgt,
- "ibm,cpu-idle-state-latencies-ns");
-
- if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags", dt_idle_states,
- "ibm,cpu-idle-state-latencies-ns",
- count) != 0)
- goto out;
-
- count = of_property_count_strings(power_mgt,
- "ibm,cpu-idle-state-names");
- if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags", dt_idle_states,
- "ibm,cpu-idle-state-names",
- count) != 0)
- goto out;
+ /* TODO: Count only states which are eligible for cpuidle */
+ dt_idle_states = nr_pnv_idle_states;
/*
* Since snooze is used as first idle state, max idle states allowed is
* CPUIDLE_STATE_MAX -1
*/
- if (dt_idle_states > CPUIDLE_STATE_MAX - 1) {
+ if (nr_pnv_idle_states > CPUIDLE_STATE_MAX - 1) {
pr_warn("cpuidle-powernv: discovered idle states more than allowed");
dt_idle_states = CPUIDLE_STATE_MAX - 1;
}
- if (of_property_read_u32_array(power_mgt,
- "ibm,cpu-idle-state-flags", flags, dt_idle_states)) {
- pr_warn("cpuidle-powernv : missing ibm,cpu-idle-state-flags in DT\n");
- goto out;
- }
-
- if (of_property_read_u32_array(power_mgt,
- "ibm,cpu-idle-state-latencies-ns", latency_ns,
- dt_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
- goto out;
- }
- if (of_property_read_string_array(power_mgt,
- "ibm,cpu-idle-state-names", names, dt_idle_states) < 0) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n");
- goto out;
- }
-
/*
* If the idle states use stop instruction, probe for psscr values
* and psscr mask which are necessary to specify required stop level.
*/
- has_stop_states = (flags[0] &
+ has_stop_states = (pnv_idle_states[0].flags &
(OPAL_PM_STOP_INST_FAST | OPAL_PM_STOP_INST_DEEP));
- if (has_stop_states) {
- count = of_property_count_u64_elems(power_mgt,
- "ibm,cpu-idle-state-psscr");
- if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags",
- dt_idle_states,
- "ibm,cpu-idle-state-psscr",
- count) != 0)
- goto out;
-
- count = of_property_count_u64_elems(power_mgt,
- "ibm,cpu-idle-state-psscr-mask");
- if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags",
- dt_idle_states,
- "ibm,cpu-idle-state-psscr-mask",
- count) != 0)
- goto out;
-
- if (of_property_read_u64_array(power_mgt,
- "ibm,cpu-idle-state-psscr", psscr_val, dt_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in DT\n");
- goto out;
- }
-
- if (of_property_read_u64_array(power_mgt,
- "ibm,cpu-idle-state-psscr-mask",
- psscr_mask, dt_idle_states)) {
- pr_warn("cpuidle-powernv:Missing ibm,cpu-idle-state-psscr-mask in DT\n");
- goto out;
- }
- }
-
- count = of_property_count_u32_elems(power_mgt,
- "ibm,cpu-idle-state-residency-ns");
-
- if (count < 0) {
- rc = count;
- } else if (validate_dt_prop_sizes("ibm,cpu-idle-state-flags",
- dt_idle_states,
- "ibm,cpu-idle-state-residency-ns",
- count) != 0) {
- goto out;
- } else {
- rc = of_property_read_u32_array(power_mgt,
- "ibm,cpu-idle-state-residency-ns",
- residency_ns, dt_idle_states);
- }
for (i = 0; i < dt_idle_states; i++) {
unsigned int exit_latency, target_residency;
bool stops_timebase = false;
+ struct pnv_idle_states_t *state = &pnv_idle_states[i];
/*
* Skip the platform idle state whose flag isn't in
* the supported_cpuidle_states flag mask.
*/
- if ((flags[i] & supported_flags) != flags[i])
+ if ((state->flags & supported_flags) != state->flags)
continue;
/*
* If an idle state has exit latency beyond
* POWERNV_THRESHOLD_LATENCY_NS then don't use it
* in cpu-idle.
*/
- if (latency_ns[i] > POWERNV_THRESHOLD_LATENCY_NS)
+ if (state->latency_ns > POWERNV_THRESHOLD_LATENCY_NS)
continue;
/*
* Firmware passes residency and latency values in ns.
* cpuidle expects it in us.
*/
- exit_latency = DIV_ROUND_UP(latency_ns[i], 1000);
- if (!rc)
- target_residency = DIV_ROUND_UP(residency_ns[i], 1000);
- else
- target_residency = 0;
-
- if (has_stop_states) {
- int err = validate_psscr_val_mask(&psscr_val[i],
- &psscr_mask[i],
- flags[i]);
- if (err) {
- report_invalid_psscr_val(psscr_val[i], err);
+ exit_latency = DIV_ROUND_UP(state->latency_ns, 1000);
+ target_residency = DIV_ROUND_UP(state->residency_ns, 1000);
+
+ if (has_stop_states && !(state->valid))
continue;
- }
- }
- if (flags[i] & OPAL_PM_TIMEBASE_STOP)
+ if (state->flags & OPAL_PM_TIMEBASE_STOP)
stops_timebase = true;
- /*
- * For nap and fastsleep, use default target_residency
- * values if f/w does not expose it.
- */
- if (flags[i] & OPAL_PM_NAP_ENABLED) {
- if (!rc)
- target_residency = 100;
+ if (state->flags & OPAL_PM_NAP_ENABLED) {
/* Add NAP state */
add_powernv_state(nr_idle_states, "Nap",
CPUIDLE_FLAG_NONE, nap_loop,
target_residency, exit_latency, 0, 0);
} else if (has_stop_states && !stops_timebase) {
- add_powernv_state(nr_idle_states, names[i],
+ add_powernv_state(nr_idle_states, state->name,
CPUIDLE_FLAG_NONE, stop_loop,
target_residency, exit_latency,
- psscr_val[i], psscr_mask[i]);
+ state->psscr_val,
+ state->psscr_mask);
}
/*
@@ -450,20 +345,19 @@ static int powernv_add_idle_states(void)
* within this config dependency check.
*/
#ifdef CONFIG_TICK_ONESHOT
- else if (flags[i] & OPAL_PM_SLEEP_ENABLED ||
- flags[i] & OPAL_PM_SLEEP_ENABLED_ER1) {
- if (!rc)
- target_residency = 300000;
+ else if (state->flags & OPAL_PM_SLEEP_ENABLED ||
+ state->flags & OPAL_PM_SLEEP_ENABLED_ER1) {
/* Add FASTSLEEP state */
add_powernv_state(nr_idle_states, "FastSleep",
CPUIDLE_FLAG_TIMER_STOP,
fastsleep_loop,
target_residency, exit_latency, 0, 0);
} else if (has_stop_states && stops_timebase) {
- add_powernv_state(nr_idle_states, names[i],
+ add_powernv_state(nr_idle_states, state->name,
CPUIDLE_FLAG_TIMER_STOP, stop_loop,
target_residency, exit_latency,
- psscr_val[i], psscr_mask[i]);
+ state->psscr_val,
+ state->psscr_mask);
}
#endif
else
--
2.18.0.rc2.85.g1fb9df7
^ permalink raw reply related
* [PATCH v4 1/2] powernv/cpuidle: Parse dt idle properties into global structure
From: Akshay Adiga @ 2018-07-05 11:40 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, linux-pm
Cc: rjw, stewart, benh, svaidy, ego, npiggin, mpe, Akshay Adiga
In-Reply-To: <20180705114022.19285-1-akshay.adiga@linux.vnet.ibm.com>
Device-tree parsing happens twice, once while deciding idle state to be
used for hotplug and once during cpuidle init. Hence, parsing the device
tree and caching it will reduce code duplication. Parsing code has been
moved to pnv_parse_cpuidle_dt() from pnv_probe_idle_states(). In addition
to the properties in the device tree the number of available states is
also required.
Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/cpuidle.h | 11 ++
arch/powerpc/platforms/powernv/idle.c | 216 ++++++++++++++++----------
2 files changed, 149 insertions(+), 78 deletions(-)
diff --git a/arch/powerpc/include/asm/cpuidle.h b/arch/powerpc/include/asm/cpuidle.h
index e210a83eb196..574b0ce1d671 100644
--- a/arch/powerpc/include/asm/cpuidle.h
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -79,6 +79,17 @@ struct stop_sprs {
u64 mmcra;
};
+#define PNV_IDLE_NAME_LEN 16
+struct pnv_idle_states_t {
+ char name[PNV_IDLE_NAME_LEN];
+ u32 latency_ns;
+ u32 residency_ns;
+ u64 psscr_val;
+ u64 psscr_mask;
+ u32 flags;
+ bool valid;
+};
+
extern u32 pnv_fastsleep_workaround_at_entry[];
extern u32 pnv_fastsleep_workaround_at_exit[];
diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 1c5d0675b43c..7cf71b3e03a1 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -36,6 +36,8 @@
#define P9_STOP_SPR_PSSCR 855
static u32 supported_cpuidle_states;
+struct pnv_idle_states_t *pnv_idle_states;
+int nr_pnv_idle_states;
/*
* The default stop state that will be used by ppc_md.power_save
@@ -622,48 +624,10 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags)
* @dt_idle_states: Number of idle state entries
* Returns 0 on success
*/
-static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
- int dt_idle_states)
+static int __init pnv_power9_idle_init(void)
{
- u64 *psscr_val = NULL;
- u64 *psscr_mask = NULL;
- u32 *residency_ns = NULL;
u64 max_residency_ns = 0;
- int rc = 0, i;
-
- psscr_val = kcalloc(dt_idle_states, sizeof(*psscr_val), GFP_KERNEL);
- psscr_mask = kcalloc(dt_idle_states, sizeof(*psscr_mask), GFP_KERNEL);
- residency_ns = kcalloc(dt_idle_states, sizeof(*residency_ns),
- GFP_KERNEL);
-
- if (!psscr_val || !psscr_mask || !residency_ns) {
- rc = -1;
- goto out;
- }
-
- if (of_property_read_u64_array(np,
- "ibm,cpu-idle-state-psscr",
- psscr_val, dt_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in DT\n");
- rc = -1;
- goto out;
- }
-
- if (of_property_read_u64_array(np,
- "ibm,cpu-idle-state-psscr-mask",
- psscr_mask, dt_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask in DT\n");
- rc = -1;
- goto out;
- }
-
- if (of_property_read_u32_array(np,
- "ibm,cpu-idle-state-residency-ns",
- residency_ns, dt_idle_states)) {
- pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-residency-ns in DT\n");
- rc = -1;
- goto out;
- }
+ int i;
/*
* Set pnv_first_deep_stop_state, pnv_deepest_stop_psscr_{val,mask},
@@ -679,33 +643,36 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
* the shallowest (OPAL_PM_STOP_INST_FAST) loss-less stop state.
*/
pnv_first_deep_stop_state = MAX_STOP_STATE;
- for (i = 0; i < dt_idle_states; i++) {
+ for (i = 0; i < nr_pnv_idle_states; i++) {
int err;
- u64 psscr_rl = psscr_val[i] & PSSCR_RL_MASK;
+ struct pnv_idle_states_t *state = &pnv_idle_states[i];
+ u64 psscr_rl = state->psscr_val & PSSCR_RL_MASK;
- if ((flags[i] & OPAL_PM_LOSE_FULL_CONTEXT) &&
- (pnv_first_deep_stop_state > psscr_rl))
+ if ((state->flags & OPAL_PM_LOSE_FULL_CONTEXT) &&
+ pnv_first_deep_stop_state > psscr_rl)
pnv_first_deep_stop_state = psscr_rl;
- err = validate_psscr_val_mask(&psscr_val[i], &psscr_mask[i],
- flags[i]);
+ err = validate_psscr_val_mask(&state->psscr_val,
+ &state->psscr_mask,
+ state->flags);
if (err) {
- report_invalid_psscr_val(psscr_val[i], err);
+ state->valid = false;
+ report_invalid_psscr_val(state->psscr_val, err);
continue;
}
- if (max_residency_ns < residency_ns[i]) {
- max_residency_ns = residency_ns[i];
- pnv_deepest_stop_psscr_val = psscr_val[i];
- pnv_deepest_stop_psscr_mask = psscr_mask[i];
- pnv_deepest_stop_flag = flags[i];
+ if (max_residency_ns < state->residency_ns) {
+ max_residency_ns = state->residency_ns;
+ pnv_deepest_stop_psscr_val = state->psscr_val;
+ pnv_deepest_stop_psscr_mask = state->psscr_mask;
+ pnv_deepest_stop_flag = state->flags;
deepest_stop_found = true;
}
if (!default_stop_found &&
- (flags[i] & OPAL_PM_STOP_INST_FAST)) {
- pnv_default_stop_val = psscr_val[i];
- pnv_default_stop_mask = psscr_mask[i];
+ (state->flags & OPAL_PM_STOP_INST_FAST)) {
+ pnv_default_stop_val = state->psscr_val;
+ pnv_default_stop_mask = state->psscr_mask;
default_stop_found = true;
}
}
@@ -728,11 +695,8 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
pr_info("cpuidle-powernv: Requested Level (RL) value of first deep stop = 0x%llx\n",
pnv_first_deep_stop_state);
-out:
- kfree(psscr_val);
- kfree(psscr_mask);
- kfree(residency_ns);
- return rc;
+
+ return 0;
}
/*
@@ -740,50 +704,146 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
*/
static void __init pnv_probe_idle_states(void)
{
- struct device_node *np;
- int dt_idle_states;
- u32 *flags = NULL;
int i;
+ if (nr_pnv_idle_states < 0) {
+ pr_warn("cpuidle-powernv: no idle states found in the DT\n");
+ return;
+ }
+
+ if (cpu_has_feature(CPU_FTR_ARCH_300)) {
+ if (pnv_power9_idle_init())
+ return;
+ }
+
+ for (i = 0; i < nr_pnv_idle_states; i++)
+ supported_cpuidle_states |= pnv_idle_states[i].flags;
+}
+
+/*
+ * This function parses device-tree and populates all the information
+ * into pnv_idle_states structure. It also sets up nr_pnv_idle_states
+ * which is the number of cpuidle states discovered through device-tree.
+ */
+
+static int pnv_parse_cpuidle_dt(void)
+{
+ struct device_node *np;
+ int nr_idle_states, i;
+ int rc = 0;
+ u32 *temp_u32;
+ u64 *temp_u64;
+ const char **temp_string;
+
np = of_find_node_by_path("/ibm,opal/power-mgt");
if (!np) {
pr_warn("opal: PowerMgmt Node not found\n");
- goto out;
+ return -ENODEV;
}
- dt_idle_states = of_property_count_u32_elems(np,
- "ibm,cpu-idle-state-flags");
- if (dt_idle_states < 0) {
- pr_warn("cpuidle-powernv: no idle states found in the DT\n");
+ nr_idle_states = of_property_count_u32_elems(np,
+ "ibm,cpu-idle-state-flags");
+
+ pnv_idle_states = kcalloc(nr_idle_states, sizeof(*pnv_idle_states),
+ GFP_KERNEL);
+ temp_u32 = kcalloc(nr_idle_states, sizeof(u32), GFP_KERNEL);
+ temp_u64 = kcalloc(nr_idle_states, sizeof(u64), GFP_KERNEL);
+ temp_string = kcalloc(nr_idle_states, sizeof(char *), GFP_KERNEL);
+
+ if (!(pnv_idle_states && temp_u32 && temp_u64 && temp_string)) {
+ pr_err("Could not allocate memory for dt parsing\n");
+ rc = -ENOMEM;
goto out;
}
- flags = kcalloc(dt_idle_states, sizeof(*flags), GFP_KERNEL);
-
- if (of_property_read_u32_array(np,
- "ibm,cpu-idle-state-flags", flags, dt_idle_states)) {
+ /* Read flags */
+ if (of_property_read_u32_array(np, "ibm,cpu-idle-state-flags",
+ temp_u32, nr_idle_states)) {
pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-flags in DT\n");
+ rc = -EINVAL;
goto out;
}
+ for (i = 0; i < nr_idle_states; i++)
+ pnv_idle_states[i].flags = temp_u32[i];
+
+ /* Read latencies */
+ if (of_property_read_u32_array(np, "ibm,cpu-idle-state-latencies-ns",
+ temp_u32, nr_idle_states)) {
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
+ rc = -EINVAL;
+ goto out;
+ }
+ for (i = 0; i < nr_idle_states; i++)
+ pnv_idle_states[i].latency_ns = temp_u32[i];
+
+ /* Read residencies */
+ if (of_property_read_u32_array(np, "ibm,cpu-idle-state-residency-ns",
+ temp_u32, nr_idle_states)) {
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
+ rc = -EINVAL;
+ goto out;
+ }
+ for (i = 0; i < nr_idle_states; i++)
+ pnv_idle_states[i].residency_ns = temp_u32[i];
+ /* For power9 */
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
- if (pnv_power9_idle_init(np, flags, dt_idle_states))
+ /* Read pm_crtl_val */
+ if (of_property_read_u64_array(np, "ibm,cpu-idle-state-psscr",
+ temp_u64, nr_idle_states)) {
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in DT\n");
+ rc = -EINVAL;
+ goto out;
+ }
+ for (i = 0; i < nr_idle_states; i++)
+ pnv_idle_states[i].psscr_val = temp_u64[i];
+
+ /* Read pm_crtl_mask */
+ if (of_property_read_u64_array(np, "ibm,cpu-idle-state-psscr-mask",
+ temp_u64, nr_idle_states)) {
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask in DT\n");
+ rc = -EINVAL;
goto out;
+ }
+ for (i = 0; i < nr_idle_states; i++)
+ pnv_idle_states[i].psscr_mask = temp_u64[i];
}
- for (i = 0; i < dt_idle_states; i++)
- supported_cpuidle_states |= flags[i];
+ /*
+ * power8 specific properties ibm,cpu-idle-state-pmicr-mask and
+ * ibm,cpu-idle-state-pmicr-val were never used and there is no
+ * plan to use it in near future. Hence, not parsing these properties
+ */
+ if (of_property_read_string_array(np, "ibm,cpu-idle-state-names",
+ temp_string, nr_idle_states) < 0) {
+ pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n");
+ rc = -EINVAL;
+ goto out;
+ }
+ for (i = 0; i < nr_idle_states; i++)
+ strncpy(pnv_idle_states[i].name, temp_string[i],
+ PNV_IDLE_NAME_LEN);
+ nr_pnv_idle_states = nr_idle_states;
+ rc = 0;
out:
- kfree(flags);
+ kfree(temp_u32);
+ kfree(temp_u64);
+ kfree(temp_string);
+ return rc;
}
+
static int __init pnv_init_idle_states(void)
{
-
+ int rc = 0;
supported_cpuidle_states = 0;
+ /* In case we error out nr_pnv_idle_states will be zero */
+ nr_pnv_idle_states = 0;
if (cpuidle_disable != IDLE_NO_OVERRIDE)
goto out;
-
+ rc = pnv_parse_cpuidle_dt();
+ if (rc)
+ return rc;
pnv_probe_idle_states();
if (!(supported_cpuidle_states & OPAL_PM_SLEEP_ENABLED_ER1)) {
--
2.18.0.rc2.85.g1fb9df7
^ permalink raw reply related
* [PATCH v4 0/2] powernv/cpuidle Device-tree parsing cleanup
From: Akshay Adiga @ 2018-07-05 11:40 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev, linux-pm
Cc: rjw, stewart, benh, svaidy, ego, npiggin, mpe, Akshay Adiga
Device-tree parsed multiple time in powernv cpuidle and powernv
hotplug code.
First to identify supported flags. Second time, to identify deepest_state
and first deep state. Third time, during cpuidle init to find the available
idle states. Any change in device-tree format will lead to make changes in
these 3 places. Errors in device-tree can be handled in a better manner.
This series adds code to parse device tree once and save in global structure.
Changes from v3 :
- Removed a stale comment
Changes from v2 :
- Fix build error (moved a hunk from patch 1 to patch 2)
Changes from v1 :
- fold first 2 patches into 1
- rename pm_ctrl_reg_* as psscr_*
- added comment stating removal of pmicr parsing code
- removed parsing code for pmicr
- add member valid in pnv_idle_states_t to indicate if the psscr-mask/val
are valid combination,
- Change function description of pnv_parse_cpuidle_dt
- Added error handling code.
Akshay Adiga (2):
powernv/cpuidle: Parse dt idle properties into global structure
powernv/cpuidle: Use parsed device tree values for cpuidle_init
arch/powerpc/include/asm/cpuidle.h | 13 ++
arch/powerpc/platforms/powernv/idle.c | 216 ++++++++++++++++----------
drivers/cpuidle/cpuidle-powernv.c | 158 ++++---------------
3 files changed, 177 insertions(+), 210 deletions(-)
--
2.18.0.rc2.85.g1fb9df7
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox