From: Thomas Gleixner <tglx@kernel.org>
To: Rosen Penev <rosenp@gmail.com>, linux-kernel@vger.kernel.org
Cc: Radu Rendec <radu@rendec.net>
Subject: Re: [PATCH] irqchip/ath79-cpu: Flush every write buffer of a shared interrupt
Date: Sun, 08 Nov 2026 21:41:47 +0100 [thread overview]
Message-ID: <874idrvywk.ffs@fw13> (raw)
In-Reply-To: <20261106221201.15054-1-rosenp@gmail.com>
On Fri, Nov 06 2026 at 14:12, Rosen Penev wrote:
>
> -static unsigned irq_wb_chan[8] = {
> - -1, -1, -1, -1, -1, -1, -1, -1,
> -};
> +static u32 irq_wb_chans[8];
>
> asmlinkage void plat_irq_dispatch(void)
> {
> - unsigned long pending;
> - int irq;
> + unsigned long pending, chans;
> + int irq, chan;
>
> pending = read_c0_status() & read_c0_cause() & ST0_IM;
>
> @@ -46,8 +47,11 @@ asmlinkage void plat_irq_dispatch(void)
> pending >>= CAUSEB_IP;
> while (pending) {
> irq = fls(pending) - 1;
> - if (irq < ARRAY_SIZE(irq_wb_chan) && irq_wb_chan[irq] != -1)
> - ath79_ddr_wb_flush(irq_wb_chan[irq]);
> + if (irq < ARRAY_SIZE(irq_wb_chans)) {
> + chans = irq_wb_chans[irq];
> + for_each_set_bit(chan, &chans, 32)
> + ath79_ddr_wb_flush(chan);
So the CPU provides 8 interrupts and 32 sources, where each source has
its own specific flush register. There is some distribution mechanism
(firmware configured or fixed in hardware) which maps a interrupt source
to a CPU interrupt. When two sources are mapped to the same CPU
interrupt then they share the interrupt line, i.e. the handlers are
requested with IRQF_SHARED, _and_ both flush registers have to be
written to so that the interrupt handler can observe the data and figure
out whether it should handle it or not. Correct?
I kinda decoded this from your change log and tried to map it to the
code. It looks correct, but for heavens sake this needs a bit fat
comment explaining the magic behind all of this. Even for your own sake
as you will have forgotten the gory details three month down the road.
Btw, as this is the interrupt hotpath, this for_each_set_bit() loop is
pretty inefficient when there is more than one interrupt source
associated with a CPU interrupt.
What you want (as a patch on top) is:
ath79_ddr_wb_flush_many(unsigned long sources)
{
__ath79_ddr_wb_flush_many(sources);
// Document WHY this needs to be done twice
// The existing comment is useless...
__ath79_ddr_wb_flush_many(sources);
}
static __ath79_ddr_wb_flush_many(unsigned long sources)
{
u32 __iomem *base = ath79_ddr_wb_flush_base;
for_each_set_bit(idx, &sources, 32)
__raw_writel(0x1, base + idx)
for_each_set_bit(idx, &sources, 32) {
while (__raw_readl(base + idx) & 0x1)
;
}
}
or something like that. For a single interrupt it's exactly the same
outcome, but for multiple interrupts mapped to one CPU interrupt there
is an obvious speedup potential, no?
Thanks,
tglx
prev parent reply other threads:[~2026-11-08 20:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 22:12 Rosen Penev
2026-11-08 20:41 ` Thomas Gleixner [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=874idrvywk.ffs@fw13 \
--to=tglx@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=radu@rendec.net \
--cc=rosenp@gmail.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
all inboxes | Powered by JetHome®