Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Anup Patel <anup@brainfault.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <maz@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>
Subject: Re: [PATCH 2/2] irqchip/sifive-plic: Disable S-mode IRQs if running in M-mode
Date: Tue, 1 Mar 2022 08:30:06 +0000	[thread overview]
Message-ID: <Yh3ZjqTbdDK0dQSt@x1-carbon> (raw)
In-Reply-To: <CAAhSdy0c4Sn=44mwpghpj54jmdHPePXynWQqQDtGM4p0XLj19w@mail.gmail.com>

On Tue, Mar 01, 2022 at 09:48:20AM +0530, Anup Patel wrote:
> On Tue, Mar 1, 2022 at 6:22 AM Niklas Cassel <Niklas.Cassel@wdc.com> wrote:
> >
> > From: Niklas Cassel <niklas.cassel@wdc.com>
> >
> > When detecting a hart context for a privilege mode different from the
> > current running privilege mode, we simply skip to the next hart context
> > register.
> >
> > This means that we never clear the S-mode enable bits when running in
> > M-mode.
> >
> > On canaan k210, a bunch of S-mode interrupts are enabled by the bootrom.
> > These S-mode specific interrupts should never trigger, since we never set
> > the mie.SEIE bit in the parent interrupt controller (riscv-intc).
> >
> > However, we will be able to see the mip.SEIE bit set as pending.
> >
> > This doesn't seem like a good default when CONFIG_RISCV_M_MODE is set,
> > since in that case we will never enter lower privilege mode (e.g. S-mode).
> >
> > Let's clear the S-mode enable bits when running the kernel in M-mode, such
> > that we won't have a interrupt pending bit set, which we will never clear.
> >
> > Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> > ---
> >  drivers/irqchip/irq-sifive-plic.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> > index 211bcb10aa93..46caeb11a114 100644
> > --- a/drivers/irqchip/irq-sifive-plic.c
> > +++ b/drivers/irqchip/irq-sifive-plic.c
> > @@ -326,8 +326,19 @@ static int __init plic_init(struct device_node *node,
> >                  * Skip contexts other than external interrupts for our
> >                  * privilege level.
> >                  */
> > -               if (parent.args[0] != RV_IRQ_EXT)
> > +               if (parent.args[0] != RV_IRQ_EXT) {
> > +                       /* Disable S-mode enable bits if running in M-mode. */
> > +                       if (IS_ENABLED(CONFIG_RISCV_M_MODE)) {
> > +                               struct plic_handler tmp_handler = {};
> > +
> > +                               raw_spin_lock_init(&tmp_handler.enable_lock);
> 
> Creating a dummy plic_handler over here is a strange work-around.
> 
> Please define and use
> "void __plic_toggle(void __iomem *enable_base, int hwirq, int enable)"
> over here and in the plic_toggle() function.

Hello Anup,

Your suggestion sounds like a cleaner solution, will fix in V2.


Kind regards,
Niklas
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2022-03-01  8:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  0:51 [PATCH 0/2] sifive-plic minor improvements Niklas Cassel
2022-03-01  0:51 ` [PATCH 1/2] irqchip/sifive-plic: Improve naming scheme for per context offsets Niklas Cassel
2022-03-01  4:12   ` Anup Patel
2022-03-01  9:05     ` Niklas Cassel
2022-03-01 11:10       ` Anup Patel
2022-03-01  0:51 ` [PATCH 2/2] irqchip/sifive-plic: Disable S-mode IRQs if running in M-mode Niklas Cassel
2022-03-01  4:18   ` Anup Patel
2022-03-01  8:30     ` Niklas Cassel [this message]

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=Yh3ZjqTbdDK0dQSt@x1-carbon \
    --to=niklas.cassel@wdc.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-riscv@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox