From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:23
Currently we build the 47x cputable entries even when CONFIG_PPC_47x is
disabled. That means a kernel built without CONFIG_PPC_47x will claim to
support a 47x CPU and start booting, only to break somewhere later
because it doesn't have 47x support compiled in.
So guard the 47x cputable entries with CONFIG_PPC_47x. Note that this is
inside the #ifdef CONFIG_44x section, because 47x depends on 44x.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/cputable.c | 2 ++
1 file changed, 2 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:23
The entire 44x directory is omitted if CONFIG_44x is not enabled, so
within the 44x/Makefile CONFIG_44x is always y. So convert
obj-$(CONFIG_44x) to the more obvious obj-y.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/44x/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:23
We have several 44x machine check handlers defined in traps.c. It would
be preferable if they were split out with the platforms that use them.
Do that.
In the process, drop get_mc_reason() and instead just open code the
lookup of reason from regs->dsisr. This avoids a pointless layer of
abstraction.
We know to use regs->dsisr because 44x enables BOOKE which enables
PPC_ADV_DEBUG_REGS, and FSL_BOOKE is not enabled on 44x builds.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/traps.c | 74 ------------------------
arch/powerpc/platforms/44x/Makefile | 2 +-
arch/powerpc/platforms/44x/machine_check.c | 90 ++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 75 deletions(-)
create mode 100644 arch/powerpc/platforms/44x/machine_check.c
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:24
We have a lot of code in sysdev for supporting 4xx, ie. either 40x or
44x. Instead it would be cleaner if it was all in platforms/4xx.
This is slightly odd in that we don't actually define any machines in
the 4xx platform, as is usual for a platform directory. But still it
seems like a better result to have all this related code in a directory
by itself.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/4xx/Makefile | 8 ++++++++
arch/powerpc/{sysdev/ppc4xx_cpm.c => platforms/4xx/cpm.c} | 0
arch/powerpc/{sysdev/ppc4xx_gpio.c => platforms/4xx/gpio.c} | 0
.../{sysdev/ppc4xx_hsta_msi.c => platforms/4xx/hsta_msi.c} | 0
arch/powerpc/{sysdev/ppc4xx_msi.c => platforms/4xx/msi.c} | 0
arch/powerpc/{sysdev/ppc4xx_ocm.c => platforms/4xx/ocm.c} | 0
arch/powerpc/{sysdev/ppc4xx_pci.c => platforms/4xx/pci.c} | 2 +-
arch/powerpc/{sysdev/ppc4xx_pci.h => platforms/4xx/pci.h} | 0
arch/powerpc/{sysdev/ppc4xx_soc.c => platforms/4xx/soc.c} | 0
arch/powerpc/{sysdev => platforms/4xx}/uic.c | 0
arch/powerpc/platforms/Makefile | 1 +
arch/powerpc/sysdev/Makefile | 10 ----------
12 files changed, 10 insertions(+), 11 deletions(-)
create mode 100644 arch/powerpc/platforms/4xx/Makefile
rename arch/powerpc/{sysdev/ppc4xx_cpm.c => platforms/4xx/cpm.c} (100%)
rename arch/powerpc/{sysdev/ppc4xx_gpio.c => platforms/4xx/gpio.c} (100%)
rename arch/powerpc/{sysdev/ppc4xx_hsta_msi.c => platforms/4xx/hsta_msi.c} (100%)
rename arch/powerpc/{sysdev/ppc4xx_msi.c => platforms/4xx/msi.c} (100%)
rename arch/powerpc/{sysdev/ppc4xx_ocm.c => platforms/4xx/ocm.c} (100%)
rename arch/powerpc/{sysdev/ppc4xx_pci.c => platforms/4xx/pci.c} (99%)
rename arch/powerpc/{sysdev/ppc4xx_pci.h => platforms/4xx/pci.h} (100%)
rename arch/powerpc/{sysdev/ppc4xx_soc.c => platforms/4xx/soc.c} (100%)
rename arch/powerpc/{sysdev => platforms/4xx}/uic.c (100%)
diff --git a/arch/powerpc/sysdev/ppc4xx_cpm.c b/arch/powerpc/platforms/4xx/cpm.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_cpm.crename to arch/powerpc/platforms/4xx/cpm.cdiff --git a/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/platforms/4xx/gpio.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_gpio.crename to arch/powerpc/platforms/4xx/gpio.cdiff --git a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c b/arch/powerpc/platforms/4xx/hsta_msi.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_hsta_msi.crename to arch/powerpc/platforms/4xx/hsta_msi.cdiff --git a/arch/powerpc/sysdev/ppc4xx_msi.c b/arch/powerpc/platforms/4xx/msi.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_msi.crename to arch/powerpc/platforms/4xx/msi.cdiff --git a/arch/powerpc/sysdev/ppc4xx_ocm.c b/arch/powerpc/platforms/4xx/ocm.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_ocm.crename to arch/powerpc/platforms/4xx/ocm.cdiff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/platforms/4xx/pci.csimilarity index 99%rename from arch/powerpc/sysdev/ppc4xx_pci.crename to arch/powerpc/platforms/4xx/pci.cindex 086aca69ecae..6713edc93a55 100644--- a/arch/powerpc/sysdev/ppc4xx_pci.c+++ b/arch/powerpc/platforms/4xx/pci.c
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.h b/arch/powerpc/platforms/4xx/pci.hsimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_pci.hrename to arch/powerpc/platforms/4xx/pci.hdiff --git a/arch/powerpc/sysdev/ppc4xx_soc.c b/arch/powerpc/platforms/4xx/soc.csimilarity index 100%rename from arch/powerpc/sysdev/ppc4xx_soc.crename to arch/powerpc/platforms/4xx/soc.cdiff --git a/arch/powerpc/sysdev/uic.c b/arch/powerpc/platforms/4xx/uic.csimilarity index 100%rename from arch/powerpc/sysdev/uic.crename to arch/powerpc/platforms/4xx/uic.cdiff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefileindex 469ef170d218..d7a55ecfaee5 100644--- a/arch/powerpc/platforms/Makefile+++ b/arch/powerpc/platforms/Makefile
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:24
Now that we have 4xx platform directory we can move the 4xx machine
check handler in there. Again we drop get_mc_reason() and replace it
with regs->dsisr directly (which is actually SPRN_ESR).
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/traps.c | 18 +-----------------
arch/powerpc/platforms/4xx/Makefile | 2 +-
arch/powerpc/platforms/4xx/machine_check.c | 26 ++++++++++++++++++++++++++
3 files changed, 28 insertions(+), 18 deletions(-)
create mode 100644 arch/powerpc/platforms/4xx/machine_check.c
@@ -380,11 +380,6 @@ static inline int check_io_access(struct pt_regs *regs)/* On 4xx, the reason for the machine check or program exceptionisintheESR.*/#define get_reason(regs) ((regs)->dsisr)-#ifndef CONFIG_FSL_BOOKE-#define get_mc_reason(regs) ((regs)->dsisr)-#else-#define get_mc_reason(regs) (mfspr(SPRN_MCSR))-#endif#define REASON_FP ESR_FP#define REASON_ILLEGAL (ESR_PIL | ESR_PUO)#define REASON_PRIVILEGED ESR_PPR
@@ -398,7 +393,6 @@ static inline int check_io_access(struct pt_regs *regs)/* On non-4xx, the reason for the machine check or programexceptionisintheMSR.*/#define get_reason(regs) ((regs)->msr)-#define get_mc_reason(regs) ((regs)->msr)#define REASON_TM 0x200000#define REASON_FP 0x100000#define REASON_ILLEGAL 0x80000
@@ -511,7 +505,7 @@ int machine_check_e500mc(struct pt_regs *regs)intmachine_check_e500(structpt_regs*regs){-unsignedlongreason=get_mc_reason(regs);+unsignedlongreason=mfspr(SPRN_MCSR);if(reason&MCSR_BUS_RBERR){if(fsl_rio_mcheck_exception(regs))
@@ -558,7 +552,7 @@ int machine_check_generic(struct pt_regs *regs)#elif defined(CONFIG_E200)intmachine_check_e200(structpt_regs*regs){-unsignedlongreason=get_mc_reason(regs);+unsignedlongreason=mfspr(SPRN_MCSR);printk("Machine check in kernel mode.\n");printk("Caused by (from MCSR=%lx): ",reason);
@@ -583,7 +577,7 @@ int machine_check_e200(struct pt_regs *regs)#elif defined(CONFIG_PPC_8xx)intmachine_check_8xx(structpt_regs*regs){-unsignedlongreason=get_mc_reason(regs);+unsignedlongreason=regs->msr;pr_err("Machine check in kernel mode.\n");pr_err("Caused by (from SRR1=%lx): ",reason);
@@ -608,7 +602,7 @@ int machine_check_8xx(struct pt_regs *regs)#elseintmachine_check_generic(structpt_regs*regs){-unsignedlongreason=get_mc_reason(regs);+unsignedlongreason=regs->msr;printk("Machine check in kernel mode.\n");printk("Caused by (from SRR1=%lx): ",reason);
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:25
Make it clear that the fallback version of machine_check_generic() is
only used on 32-bit configs.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/traps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:25
We already have mce.c which is built for 64bit and contains other parts
of the machine check code, so move these bits in there too.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/mce.c | 35 +++++++++++++++++++++++++++++++++++
arch/powerpc/kernel/traps.c | 35 -----------------------------------
2 files changed, 35 insertions(+), 35 deletions(-)
@@ -293,41 +293,6 @@ void system_reset_exception(struct pt_regs *regs)/* What should we do here? We could issue a shutdown or hard reset. */}-#ifdef CONFIG_PPC64-/*-*Thisfunctioniscalledinrealmode.Strictlynoprintk'splease.-*-*regs->nipandregs->msrcontainssrr0andssr1.-*/-longmachine_check_early(structpt_regs*regs)-{-longhandled=0;--__this_cpu_inc(irq_stat.mce_exceptions);--add_taint(TAINT_MACHINE_CHECK,LOCKDEP_NOW_UNRELIABLE);--if(cur_cpu_spec&&cur_cpu_spec->machine_check_early)-handled=cur_cpu_spec->machine_check_early(regs);-returnhandled;-}--longhmi_exception_realmode(structpt_regs*regs)-{-__this_cpu_inc(irq_stat.hmi_exceptions);--wait_for_subcore_guest_exit();--if(ppc_md.hmi_exception_early)-ppc_md.hmi_exception_early(regs);--wait_for_tb_resync();--return0;-}--#endif-/**I/Oaccessescancausemachinechecksonpowermacs.*CheckiftheNIPcorrespondstotheaddressofasync
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-02-17 06:32:26
Currently we open code the reason codes for program checks. Instead use
the existing SRR1 defines.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/reg.h | 1 +
arch/powerpc/kernel/traps.c | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
From: Nicholas Piggin <npiggin@gmail.com> Date: 2017-02-20 02:34:22
On Fri, 17 Feb 2017 17:32:14 +1100
Michael Ellerman [off-list ref] wrote:
We have a lot of code in sysdev for supporting 4xx, ie. either 40x or
44x. Instead it would be cleaner if it was all in platforms/4xx.
This is slightly odd in that we don't actually define any machines in
the 4xx platform, as is usual for a platform directory. But still it
seems like a better result to have all this related code in a directory
by itself.
What about the other things in sysdev that support multiple platforms?
Why not just put the new 4xx subdirectory under sysdev?
The other patches all seem okay to me. Do you have any grand plan for
further breaking up traps.c?
Thanks,
Nick
On Mon, Feb 20, 2017 at 3:34 AM, Nicholas Piggin [off-list ref] wrote:
On Fri, 17 Feb 2017 17:32:14 +1100
Michael Ellerman [off-list ref] wrote:
quoted
We have a lot of code in sysdev for supporting 4xx, ie. either 40x or
44x. Instead it would be cleaner if it was all in platforms/4xx.
This is slightly odd in that we don't actually define any machines in
the 4xx platform, as is usual for a platform directory. But still it
seems like a better result to have all this related code in a directory
by itself.
What about the other things in sysdev that support multiple platforms?
Some of them have subsystem specific directories in drivers these
days, e.g. drivers/pci/host and drivers/irqchip. Some others that are
shared with ARM or ARM64 platforms are already being moved to
drivers/soc/
Why not just put the new 4xx subdirectory under sysdev?
arch/powerpc/platforms/40x/ only has four small C files, you could also
move everything to platforms/4xx/ instead.
Arnd
Now that we have 4xx platform directory we can move the 4xx machine
check handler in there. Again we drop get_mc_reason() and replace it
with regs->dsisr directly (which is actually SPRN_ESR).
The same can also be done for the 8xx.
I can propose a patch once you've commited your patches, to avoid
conflict on traps.c
Or I do it now and you apply your patches over it ?
Christophe