Message ID | 20230505080207.11902-3-ben.dooks@sifive.com |
---|---|
State | Accepted |
Delegated to: | Andes |
Headers | show |
Series | [1/3] riscv: add generic link for <asm/atomic.h> | expand |
Hi Ben, On Fri, May 05, 2023 at 09:02:06AM +0100, Ben Dooks wrote: > Add implementations of the local_irq_{save,restore} macros so that > <asm/atomic.h> can be used with riscv. > > Signed-off-by: Ben Dooks <ben.dooks@sifive.com> > --- > arch/riscv/include/asm/system.h | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/system.h b/arch/riscv/include/asm/system.h > index 9d8e43e394..78093681e5 100644 > --- a/arch/riscv/include/asm/system.h > +++ b/arch/riscv/include/asm/system.h > @@ -7,15 +7,22 @@ > #ifndef __ASM_RISCV_SYSTEM_H > #define __ASM_RISCV_SYSTEM_H > > +#include <asm/csr.h> > + > struct event; > > /* > - * Interrupt configuring macros. > - * > - * TODO > - * > + * Interupt configuration macros > */ > > +#define local_irq_save(__flags) do { \ Can we have this "do" in a new line just like what kernel does? > + __flags = csr_read_clear(CSR_SSTATUS, SR_SIE) & SR_SIE; \ > + } while (0) > + > +#define local_irq_restore(__flags) do { \ > + csr_set(CSR_SSTATUS, __flags & SR_SIE); \ > + } while(0) ^ a space missing > + > /* Hook to set up the CPU (called from SPL too) */ > int riscv_cpu_setup(void *ctx, struct event *event); > If you don't mind, I could make these format modification on my side, so you don't have to spin another patch set. Best regards, Leo > -- > 2.39.2 >
On 2023-06-12 08:47, Leo Liang wrote: > Hi Ben, > > On Fri, May 05, 2023 at 09:02:06AM +0100, Ben Dooks wrote: >> Add implementations of the local_irq_{save,restore} macros so that >> <asm/atomic.h> can be used with riscv. >> >> Signed-off-by: Ben Dooks <ben.dooks@sifive.com> >> --- >> arch/riscv/include/asm/system.h | 15 +++++++++++---- >> 1 file changed, 11 insertions(+), 4 deletions(-) >> >> diff --git a/arch/riscv/include/asm/system.h >> b/arch/riscv/include/asm/system.h >> index 9d8e43e394..78093681e5 100644 >> --- a/arch/riscv/include/asm/system.h >> +++ b/arch/riscv/include/asm/system.h >> @@ -7,15 +7,22 @@ >> #ifndef __ASM_RISCV_SYSTEM_H >> #define __ASM_RISCV_SYSTEM_H >> >> +#include <asm/csr.h> >> + >> struct event; >> >> /* >> - * Interrupt configuring macros. >> - * >> - * TODO >> - * >> + * Interupt configuration macros >> */ >> >> +#define local_irq_save(__flags) do { \ > > Can we have this "do" in a new line just like what kernel does? > >> + __flags = csr_read_clear(CSR_SSTATUS, SR_SIE) & SR_SIE; \ >> + } while (0) >> + >> +#define local_irq_restore(__flags) do { \ >> + csr_set(CSR_SSTATUS, __flags & SR_SIE); \ >> + } while(0) > ^ > a space missing >> + >> /* Hook to set up the CPU (called from SPL too) */ >> int riscv_cpu_setup(void *ctx, struct event *event); >> > > If you don't mind, I could make these format modification on my side, > so you don't have to spin another patch set. > > Best regards, > Leo Yes that's fine, this got buried under a lot of other work. Thank you.
diff --git a/arch/riscv/include/asm/system.h b/arch/riscv/include/asm/system.h index 9d8e43e394..78093681e5 100644 --- a/arch/riscv/include/asm/system.h +++ b/arch/riscv/include/asm/system.h @@ -7,15 +7,22 @@ #ifndef __ASM_RISCV_SYSTEM_H #define __ASM_RISCV_SYSTEM_H +#include <asm/csr.h> + struct event; /* - * Interrupt configuring macros. - * - * TODO - * + * Interupt configuration macros */ +#define local_irq_save(__flags) do { \ + __flags = csr_read_clear(CSR_SSTATUS, SR_SIE) & SR_SIE; \ + } while (0) + +#define local_irq_restore(__flags) do { \ + csr_set(CSR_SSTATUS, __flags & SR_SIE); \ + } while(0) + /* Hook to set up the CPU (called from SPL too) */ int riscv_cpu_setup(void *ctx, struct event *event);
Add implementations of the local_irq_{save,restore} macros so that <asm/atomic.h> can be used with riscv. Signed-off-by: Ben Dooks <ben.dooks@sifive.com> --- arch/riscv/include/asm/system.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)