linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Samuel Holland <samuel@sholland.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Guo Ren <guoren@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Wei Xu <xuwei5@hisilicon.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH 5/5] irqchip/sifive-plic: Separate the enable and mask operations
Date: Tue, 10 May 2022 11:27:17 +0100	[thread overview]
Message-ID: <87a6bp7ke2.wl-maz@kernel.org> (raw)
In-Reply-To: <20220509034333.60017-6-samuel@sholland.org>

On Mon, 09 May 2022 04:43:33 +0100,
Samuel Holland <samuel@sholland.org> wrote:
> 
> The PLIC has two per-IRQ checks before sending an IRQ to a hart context.
> First, it checks that the IRQ's priority is nonzero. Then, it checks
> that the enable bit is set for that combination of IRQ and context.
> 
> Currently, the PLIC driver sets both the priority value and the enable
> bit in its (un)mask operations. However, modifying the enable bit is
> problematic for two reasons:
>   1) The enable bits are packed, so changes are not atomic and require
>      taking a spinlock.
>   2) The following requirememnt from the PLIC spec, which explains the
>      racy (un)mask operations in plic_irq_eoi():
> 
>        If the completion ID does not match an interrupt source
>        that is currently enabled for the target, the completion
>        is silently ignored.
> 
> Both of these problems are solved by using the priority value to mask
> IRQs. Each IRQ has a separate priority register, so writing the priority
> value is atomic. And since the enable bit remains set while an IRQ is
> masked, the EOI operation works normally. The enable bits are still used
> to control the IRQ's affinity.

This is pretty neat.

My only concern is around whether implementations do when changing
priority of enabled interrupts. The PLIC architecture is conveniently
silent on the subject, but that's certainly something that can result
in total crap with the ARM GICs, for example, because an
implementation is free to apply this priority change on an already
pending interrupt, or not. But the kernel really wants the interrupt
to be masked once it tells the HW to do so.

Could anyone please check the RTL for some common implementations?

A way to avoid the above trouble (should it exist) would be to
disable the interrupt when changing the priority, and then reenable
it. You'd still get the simpler EOI, which is what you really want.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-05-10 10:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  3:43 [PATCH 0/5] genirq/irqchip: RISC-V PLIC cleanup and optimization Samuel Holland
2022-05-09  3:43 ` [PATCH 1/5] genirq: GENERIC_IRQ_EFFECTIVE_AFF_MASK depends on SMP Samuel Holland
2022-05-09  3:43 ` [PATCH 2/5] genirq: Refactor accessors to use irq_data_get_affinity_mask Samuel Holland
2022-05-09  3:43 ` [PATCH 3/5] genirq: Provide an IRQ affinity mask in non-SMP configs Samuel Holland
2022-05-09  7:52   ` kernel test robot
2022-05-10  4:20     ` Samuel Holland
2022-05-09  3:43 ` [PATCH 4/5] irqchip/sifive-plic: Make better use of the effective affinity mask Samuel Holland
2022-05-09  3:43 ` [PATCH 5/5] irqchip/sifive-plic: Separate the enable and mask operations Samuel Holland
2022-05-10 10:27   ` Marc Zyngier [this message]
2022-05-11 10:00     ` Samuel Holland

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=87a6bp7ke2.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=f.fainelli@gmail.com \
    --cc=guoren@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=samuel@sholland.org \
    --cc=tglx@linutronix.de \
    --cc=xuwei5@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).