* [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s
@ 2016-10-28 11:23 Will Deacon
2016-10-28 11:23 ` [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154 Will Deacon
2016-10-28 14:54 ` [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Mark Rutland
0 siblings, 2 replies; 5+ messages in thread
From: Will Deacon @ 2016-10-28 11:23 UTC (permalink / raw)
To: linux-arm-kernel
The GIC system registers are accessed using open-coded wrappers around
the mrs_s/msr_s asm macros.
This patch moves the code over to the {read,wrote}_sysreg_s accessors
instead, reducing the amount of explicit asm blocks in the arch headers.
Cc: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/arch_gicv3.h | 45 ++++++++++++++-----------------------
1 file changed, 17 insertions(+), 28 deletions(-)
diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index f8ae6d6e4767..fdf34f8b4ee0 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -80,18 +80,8 @@
#include <linux/stringify.h>
#include <asm/barrier.h>
-#define read_gicreg(r) \
- ({ \
- u64 reg; \
- asm volatile("mrs_s %0, " __stringify(r) : "=r" (reg)); \
- reg; \
- })
-
-#define write_gicreg(v,r) \
- do { \
- u64 __val = (v); \
- asm volatile("msr_s " __stringify(r) ", %0" : : "r" (__val));\
- } while (0)
+#define read_gicreg read_sysreg_s
+#define write_gicreg write_sysreg_s
/*
* Low-level accessors
@@ -102,13 +92,13 @@
static inline void gic_write_eoir(u32 irq)
{
- asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" ((u64)irq));
+ write_sysreg_s(irq, ICC_EOIR1_EL1);
isb();
}
static inline void gic_write_dir(u32 irq)
{
- asm volatile("msr_s " __stringify(ICC_DIR_EL1) ", %0" : : "r" ((u64)irq));
+ write_sysreg_s(irq, ICC_DIR_EL1);
isb();
}
@@ -116,7 +106,7 @@ static inline u64 gic_read_iar_common(void)
{
u64 irqstat;
- asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat));
+ irqstat = read_sysreg_s(ICC_IAR1_EL1);
dsb(sy);
return irqstat;
}
@@ -134,10 +124,12 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
asm volatile(
"nop;nop;nop;nop\n\t"
- "nop;nop;nop;nop\n\t"
- "mrs_s %0, " __stringify(ICC_IAR1_EL1) "\n\t"
- "nop;nop;nop;nop"
- : "=r" (irqstat));
+ "nop;nop;nop;nop");
+
+ irqstat = read_sysreg_s(ICC_IAR1_EL1);
+
+ asm volatile(
+ "nop;nop;nop;nop");
mb();
return irqstat;
@@ -145,37 +137,34 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
static inline void gic_write_pmr(u32 val)
{
- asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" ((u64)val));
+ write_sysreg_s(val, ICC_PMR_EL1);
}
static inline void gic_write_ctlr(u32 val)
{
- asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" ((u64)val));
+ write_sysreg_s(val, ICC_CTLR_EL1);
isb();
}
static inline void gic_write_grpen1(u32 val)
{
- asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" ((u64)val));
+ write_sysreg_s(val, ICC_GRPEN1_EL1);
isb();
}
static inline void gic_write_sgi1r(u64 val)
{
- asm volatile("msr_s " __stringify(ICC_SGI1R_EL1) ", %0" : : "r" (val));
+ write_sysreg_s(val, ICC_SGI1R_EL1);
}
static inline u32 gic_read_sre(void)
{
- u64 val;
-
- asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
- return val;
+ return read_sysreg_s(ICC_SRE_EL1);
}
static inline void gic_write_sre(u32 val)
{
- asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" ((u64)val));
+ write_sysreg_s(val, ICC_SRE_EL1);
isb();
}
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154
2016-10-28 11:23 [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Will Deacon
@ 2016-10-28 11:23 ` Will Deacon
2016-10-28 15:10 ` Mark Rutland
2016-10-28 15:16 ` Marc Zyngier
2016-10-28 14:54 ` [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Mark Rutland
1 sibling, 2 replies; 5+ messages in thread
From: Will Deacon @ 2016-10-28 11:23 UTC (permalink / raw)
To: linux-arm-kernel
The workaround for Cavium ThunderX erratum 23154 has a homebrew
pipeflush built out of NOP sequences around the read of the IAR.
This patch converts the code to use the new nops macro, which makes it
a little easier to read.
Cc: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/include/asm/arch_gicv3.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index fdf34f8b4ee0..0313670a3e3f 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -122,14 +122,9 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
{
u64 irqstat;
- asm volatile(
- "nop;nop;nop;nop\n\t"
- "nop;nop;nop;nop");
-
+ nops(8);
irqstat = read_sysreg_s(ICC_IAR1_EL1);
-
- asm volatile(
- "nop;nop;nop;nop");
+ nops(4);
mb();
return irqstat;
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s
2016-10-28 11:23 [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Will Deacon
2016-10-28 11:23 ` [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154 Will Deacon
@ 2016-10-28 14:54 ` Mark Rutland
1 sibling, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2016-10-28 14:54 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Oct 28, 2016 at 12:23:57PM +0100, Will Deacon wrote:
> The GIC system registers are accessed using open-coded wrappers around
> the mrs_s/msr_s asm macros.
>
> This patch moves the code over to the {read,wrote}_sysreg_s accessors
> instead, reducing the amount of explicit asm blocks in the arch headers.
It's nice to see more of this going away!
[...]
> @@ -134,10 +124,12 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
>
> asm volatile(
> "nop;nop;nop;nop\n\t"
> - "nop;nop;nop;nop\n\t"
> - "mrs_s %0, " __stringify(ICC_IAR1_EL1) "\n\t"
> - "nop;nop;nop;nop"
> - : "=r" (irqstat));
> + "nop;nop;nop;nop");
> +
> + irqstat = read_sysreg_s(ICC_IAR1_EL1);
> +
> + asm volatile(
> + "nop;nop;nop;nop");
This looks odd, but I see that it disappears in the next patch anyway,
and mirrors the above.
Otherwise, all the transformations look correct to me. FWIW:
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Thanks,
Mark.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154
2016-10-28 11:23 ` [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154 Will Deacon
@ 2016-10-28 15:10 ` Mark Rutland
2016-10-28 15:16 ` Marc Zyngier
1 sibling, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2016-10-28 15:10 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Oct 28, 2016 at 12:23:58PM +0100, Will Deacon wrote:
> The workaround for Cavium ThunderX erratum 23154 has a homebrew
> pipeflush built out of NOP sequences around the read of the IAR.
>
> This patch converts the code to use the new nops macro, which makes it
> a little easier to read.
>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
(yes, I counted them)
Thanks,
Mark.
> ---
> arch/arm64/include/asm/arch_gicv3.h | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
> index fdf34f8b4ee0..0313670a3e3f 100644
> --- a/arch/arm64/include/asm/arch_gicv3.h
> +++ b/arch/arm64/include/asm/arch_gicv3.h
> @@ -122,14 +122,9 @@ static inline u64 gic_read_iar_cavium_thunderx(void)
> {
> u64 irqstat;
>
> - asm volatile(
> - "nop;nop;nop;nop\n\t"
> - "nop;nop;nop;nop");
> -
> + nops(8);
> irqstat = read_sysreg_s(ICC_IAR1_EL1);
> -
> - asm volatile(
> - "nop;nop;nop;nop");
> + nops(4);
> mb();
>
> return irqstat;
> --
> 2.1.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154
2016-10-28 11:23 ` [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154 Will Deacon
2016-10-28 15:10 ` Mark Rutland
@ 2016-10-28 15:16 ` Marc Zyngier
1 sibling, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2016-10-28 15:16 UTC (permalink / raw)
To: linux-arm-kernel
Hi Will,
On 28/10/16 12:23, Will Deacon wrote:
> The workaround for Cavium ThunderX erratum 23154 has a homebrew
> pipeflush built out of NOP sequences around the read of the IAR.
>
> This patch converts the code to use the new nops macro, which makes it
> a little easier to read.
>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Both patches queued for 4.10.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-28 15:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-28 11:23 [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Will Deacon
2016-10-28 11:23 ` [PATCH 2/2] irqchip/gic-v3: Use nops macro for Cavium ThunderX erratum 23154 Will Deacon
2016-10-28 15:10 ` Mark Rutland
2016-10-28 15:16 ` Marc Zyngier
2016-10-28 14:54 ` [PATCH 1/2] irqchip/gic-v3: Convert arm64 GIC accessors to {read, write}_sysreg_s Mark Rutland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).