From: Ben Dooks <ben.dooks@codethink.co.uk>
To: "luxu.kernel" <luxujoy@gmail.com>,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
luxu.kernel@bytedance.com
Subject: Re: [PATCH] riscv: Fix local irq restore when flags indicates irq disabled
Date: Mon, 24 Jul 2023 14:42:50 +0100 [thread overview]
Message-ID: <e75d0e92-1e6e-43c2-1935-00f22df5579d@codethink.co.uk> (raw)
In-Reply-To: <20230724132736.124106-1-luxu.kernel@bytedance.com>
On 24/07/2023 14:27, luxu.kernel wrote:
> When arch_local_irq_restore() is called with flags indicating irqs
> disabled, we need to clear SR_IE bit in CSR_STATUS, whereas current
> implementation based on csr_set() function only sets SR_IE bit of
> CSR_STATUS when SR_IE bit of flags is high and does nothing when
> SR_IE bit of flags is low.
>
> This commit supplies csr clear operation when calling irq restore
> function with flags indicating irq disabled.
>
> Signed-off-by: luxu.kernel <luxu.kernel@bytedance.com>
real-names are required for signoff
> ---
> arch/riscv/include/asm/irqflags.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h
> index 08d4d6a5b7e9..7c31fc3c3559 100644
> --- a/arch/riscv/include/asm/irqflags.h
> +++ b/arch/riscv/include/asm/irqflags.h
> @@ -49,7 +49,10 @@ static inline int arch_irqs_disabled(void)
> /* set interrupt enabled status */
> static inline void arch_local_irq_restore(unsigned long flags)
> {
> - csr_set(CSR_STATUS, flags & SR_IE);
> + if (flags & SR_IE)
> + csr_set(CSR_STATUS, SR_IE);
> + else
> + csr_clear(CSR_STATUS, SR_IE);
> }
>
> #endif /* _ASM_RISCV_IRQFLAGS_H */
I think this is correct, I wonder how long this has been going on
without anyone noticing?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: "luxu.kernel" <luxujoy@gmail.com>,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
luxu.kernel@bytedance.com
Subject: Re: [PATCH] riscv: Fix local irq restore when flags indicates irq disabled
Date: Mon, 24 Jul 2023 14:42:50 +0100 [thread overview]
Message-ID: <e75d0e92-1e6e-43c2-1935-00f22df5579d@codethink.co.uk> (raw)
In-Reply-To: <20230724132736.124106-1-luxu.kernel@bytedance.com>
On 24/07/2023 14:27, luxu.kernel wrote:
> When arch_local_irq_restore() is called with flags indicating irqs
> disabled, we need to clear SR_IE bit in CSR_STATUS, whereas current
> implementation based on csr_set() function only sets SR_IE bit of
> CSR_STATUS when SR_IE bit of flags is high and does nothing when
> SR_IE bit of flags is low.
>
> This commit supplies csr clear operation when calling irq restore
> function with flags indicating irq disabled.
>
> Signed-off-by: luxu.kernel <luxu.kernel@bytedance.com>
real-names are required for signoff
> ---
> arch/riscv/include/asm/irqflags.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h
> index 08d4d6a5b7e9..7c31fc3c3559 100644
> --- a/arch/riscv/include/asm/irqflags.h
> +++ b/arch/riscv/include/asm/irqflags.h
> @@ -49,7 +49,10 @@ static inline int arch_irqs_disabled(void)
> /* set interrupt enabled status */
> static inline void arch_local_irq_restore(unsigned long flags)
> {
> - csr_set(CSR_STATUS, flags & SR_IE);
> + if (flags & SR_IE)
> + csr_set(CSR_STATUS, SR_IE);
> + else
> + csr_clear(CSR_STATUS, SR_IE);
> }
>
> #endif /* _ASM_RISCV_IRQFLAGS_H */
I think this is correct, I wonder how long this has been going on
without anyone noticing?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
next prev parent reply other threads:[~2023-07-24 13:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 13:27 [PATCH] riscv: Fix local irq restore when flags indicates irq disabled luxu.kernel
2023-07-24 13:27 ` luxu.kernel
2023-07-24 13:42 ` Ben Dooks [this message]
2023-07-24 13:42 ` Ben Dooks
2023-07-24 14:03 ` Conor Dooley
2023-07-25 6:25 ` Xu Lu
2023-07-25 6:25 ` Xu Lu
-- strict thread matches above, loose matches on Subject: below --
2023-07-25 7:05 Xu Lu
2023-07-25 7:05 ` Xu Lu
2023-08-09 6:05 ` Palmer Dabbelt
2023-08-09 6:05 ` Palmer Dabbelt
2024-06-18 10:36 Xu Lu
2024-06-18 10:38 Xu Lu
2024-06-18 10:38 ` Xu Lu
2024-06-18 12:06 ` Mark Rutland
2024-06-18 12:06 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e75d0e92-1e6e-43c2-1935-00f22df5579d@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luxu.kernel@bytedance.com \
--cc=luxujoy@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.