diff options
author | Will Deacon <will.deacon@arm.com> | 2016-10-28 07:23:57 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-11-29 04:14:48 -0500 |
commit | d44ffa5ae70a15a15190aa9ffa6f6acdeae1d25c (patch) | |
tree | 598f42ebc7e9175f94c6b26c4b0d6073ad93280b | |
parent | 4e201566402c878a225d4425df8a4a664c6f251e (diff) |
irqchip/gic-v3: Convert arm64 GIC accessors to {read,write}_sysreg_s
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.
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | arch/arm64/include/asm/arch_gicv3.h | 45 |
1 files 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 @@ | |||
80 | #include <linux/stringify.h> | 80 | #include <linux/stringify.h> |
81 | #include <asm/barrier.h> | 81 | #include <asm/barrier.h> |
82 | 82 | ||
83 | #define read_gicreg(r) \ | 83 | #define read_gicreg read_sysreg_s |
84 | ({ \ | 84 | #define write_gicreg write_sysreg_s |
85 | u64 reg; \ | ||
86 | asm volatile("mrs_s %0, " __stringify(r) : "=r" (reg)); \ | ||
87 | reg; \ | ||
88 | }) | ||
89 | |||
90 | #define write_gicreg(v,r) \ | ||
91 | do { \ | ||
92 | u64 __val = (v); \ | ||
93 | asm volatile("msr_s " __stringify(r) ", %0" : : "r" (__val));\ | ||
94 | } while (0) | ||
95 | 85 | ||
96 | /* | 86 | /* |
97 | * Low-level accessors | 87 | * Low-level accessors |
@@ -102,13 +92,13 @@ | |||
102 | 92 | ||
103 | static inline void gic_write_eoir(u32 irq) | 93 | static inline void gic_write_eoir(u32 irq) |
104 | { | 94 | { |
105 | asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" ((u64)irq)); | 95 | write_sysreg_s(irq, ICC_EOIR1_EL1); |
106 | isb(); | 96 | isb(); |
107 | } | 97 | } |
108 | 98 | ||
109 | static inline void gic_write_dir(u32 irq) | 99 | static inline void gic_write_dir(u32 irq) |
110 | { | 100 | { |
111 | asm volatile("msr_s " __stringify(ICC_DIR_EL1) ", %0" : : "r" ((u64)irq)); | 101 | write_sysreg_s(irq, ICC_DIR_EL1); |
112 | isb(); | 102 | isb(); |
113 | } | 103 | } |
114 | 104 | ||
@@ -116,7 +106,7 @@ static inline u64 gic_read_iar_common(void) | |||
116 | { | 106 | { |
117 | u64 irqstat; | 107 | u64 irqstat; |
118 | 108 | ||
119 | asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat)); | 109 | irqstat = read_sysreg_s(ICC_IAR1_EL1); |
120 | dsb(sy); | 110 | dsb(sy); |
121 | return irqstat; | 111 | return irqstat; |
122 | } | 112 | } |
@@ -134,10 +124,12 @@ static inline u64 gic_read_iar_cavium_thunderx(void) | |||
134 | 124 | ||
135 | asm volatile( | 125 | asm volatile( |
136 | "nop;nop;nop;nop\n\t" | 126 | "nop;nop;nop;nop\n\t" |
137 | "nop;nop;nop;nop\n\t" | 127 | "nop;nop;nop;nop"); |
138 | "mrs_s %0, " __stringify(ICC_IAR1_EL1) "\n\t" | 128 | |
139 | "nop;nop;nop;nop" | 129 | irqstat = read_sysreg_s(ICC_IAR1_EL1); |
140 | : "=r" (irqstat)); | 130 | |
131 | asm volatile( | ||
132 | "nop;nop;nop;nop"); | ||
141 | mb(); | 133 | mb(); |
142 | 134 | ||
143 | return irqstat; | 135 | return irqstat; |
@@ -145,37 +137,34 @@ static inline u64 gic_read_iar_cavium_thunderx(void) | |||
145 | 137 | ||
146 | static inline void gic_write_pmr(u32 val) | 138 | static inline void gic_write_pmr(u32 val) |
147 | { | 139 | { |
148 | asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" ((u64)val)); | 140 | write_sysreg_s(val, ICC_PMR_EL1); |
149 | } | 141 | } |
150 | 142 | ||
151 | static inline void gic_write_ctlr(u32 val) | 143 | static inline void gic_write_ctlr(u32 val) |
152 | { | 144 | { |
153 | asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" ((u64)val)); | 145 | write_sysreg_s(val, ICC_CTLR_EL1); |
154 | isb(); | 146 | isb(); |
155 | } | 147 | } |
156 | 148 | ||
157 | static inline void gic_write_grpen1(u32 val) | 149 | static inline void gic_write_grpen1(u32 val) |
158 | { | 150 | { |
159 | asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" ((u64)val)); | 151 | write_sysreg_s(val, ICC_GRPEN1_EL1); |
160 | isb(); | 152 | isb(); |
161 | } | 153 | } |
162 | 154 | ||
163 | static inline void gic_write_sgi1r(u64 val) | 155 | static inline void gic_write_sgi1r(u64 val) |
164 | { | 156 | { |
165 | asm volatile("msr_s " __stringify(ICC_SGI1R_EL1) ", %0" : : "r" (val)); | 157 | write_sysreg_s(val, ICC_SGI1R_EL1); |
166 | } | 158 | } |
167 | 159 | ||
168 | static inline u32 gic_read_sre(void) | 160 | static inline u32 gic_read_sre(void) |
169 | { | 161 | { |
170 | u64 val; | 162 | return read_sysreg_s(ICC_SRE_EL1); |
171 | |||
172 | asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val)); | ||
173 | return val; | ||
174 | } | 163 | } |
175 | 164 | ||
176 | static inline void gic_write_sre(u32 val) | 165 | static inline void gic_write_sre(u32 val) |
177 | { | 166 | { |
178 | asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" ((u64)val)); | 167 | write_sysreg_s(val, ICC_SRE_EL1); |
179 | isb(); | 168 | isb(); |
180 | } | 169 | } |
181 | 170 | ||