Skip to content

Commit ef5b570

Browse files
chleroympe
authored andcommitted
powerpc/irq: Don't open code irq_soft_mask helpers
Use READ_ONCE() and WRITE_ONCE() instead of open coding read and write of local PACA irq_soft_mask. For the write, add a barrier to keep the memory clobber that was there previously. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/e2454434992cc932a5a34b695ae981c0b2f4c28e.1652862729.git.christophe.leroy@csgroup.eu
1 parent 9855230 commit ef5b570

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

arch/powerpc/include/asm/hw_irq.h

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ static inline void __hard_RI_enable(void)
113113

114114
static inline notrace unsigned long irq_soft_mask_return(void)
115115
{
116-
unsigned long flags;
117-
118-
asm volatile(
119-
"lbz %0,%1(13)"
120-
: "=r" (flags)
121-
: "i" (offsetof(struct paca_struct, irq_soft_mask)));
122-
123-
return flags;
116+
return READ_ONCE(local_paca->irq_soft_mask);
124117
}
125118

126119
/*
@@ -148,46 +141,24 @@ static inline notrace void irq_soft_mask_set(unsigned long mask)
148141
WARN_ON(mask && !(mask & IRQS_DISABLED));
149142
#endif
150143

151-
asm volatile(
152-
"stb %0,%1(13)"
153-
:
154-
: "r" (mask),
155-
"i" (offsetof(struct paca_struct, irq_soft_mask))
156-
: "memory");
144+
WRITE_ONCE(local_paca->irq_soft_mask, mask);
145+
barrier();
157146
}
158147

159148
static inline notrace unsigned long irq_soft_mask_set_return(unsigned long mask)
160149
{
161-
unsigned long flags;
162-
163-
#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
164-
WARN_ON(mask && !(mask & IRQS_DISABLED));
165-
#endif
150+
unsigned long flags = irq_soft_mask_return();
166151

167-
asm volatile(
168-
"lbz %0,%1(13); stb %2,%1(13)"
169-
: "=&r" (flags)
170-
: "i" (offsetof(struct paca_struct, irq_soft_mask)),
171-
"r" (mask)
172-
: "memory");
152+
irq_soft_mask_set(mask);
173153

174154
return flags;
175155
}
176156

177157
static inline notrace unsigned long irq_soft_mask_or_return(unsigned long mask)
178158
{
179-
unsigned long flags, tmp;
180-
181-
asm volatile(
182-
"lbz %0,%2(13); or %1,%0,%3; stb %1,%2(13)"
183-
: "=&r" (flags), "=r" (tmp)
184-
: "i" (offsetof(struct paca_struct, irq_soft_mask)),
185-
"r" (mask)
186-
: "memory");
159+
unsigned long flags = irq_soft_mask_return();
187160

188-
#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
189-
WARN_ON((mask | flags) && !((mask | flags) & IRQS_DISABLED));
190-
#endif
161+
irq_soft_mask_set(flags | mask);
191162

192163
return flags;
193164
}

0 commit comments

Comments
 (0)