From: Ali Tariq <alitariq45892@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
alitariq45892@gmail.com
Subject: [RFC] synchronize_irq() does not wait for chained interrupt handlers
Date: Fri, 17 Jul 2026 16:22:44 +0500 [thread overview]
Message-ID: <20260717112244.231394-1-alitariq45892@gmail.com> (raw)
Hi,
While reviewing drivers/pci/controller/plda/pcie-plda-host.c, I found
that synchronize_irq() does not appear to provide the guarantee I
expected for chained interrupt handlers (registered via
irq_set_chained_handler_and_data()).
Tracing through kernel/irq/manage.c:
- synchronize_irq()'s wait relies on the IRQD_IRQ_INPROGRESS flag
- That flag is set/cleared by handle_irq_event(), part of the normal
(non-chained) dispatch path
- Chained handlers bypass that path entirely and dispatch goes straight
to desc->handle_irq
- The fallback, __irq_get_irqchip_state() via .irq_get_irqchip_state(),
only works if the irq_chip implements that callback
In the PLDA PCIe driver's case, none of its irq_chip structures
implement .irq_get_irqchip_state(), so synchronize_irq() called after
irq_set_chained_handler_and_data(irq, NULL, NULL) returns immediately,
regardless of whether the chained handler is still executing on
another CPU. (I originally submitted a fix using synchronize_irq()
for this driver; withdrawing it once I traced this through [1])
This was originally flagged by an automated review (Sashiko AI) on a
patch I submitted for the StarFive PCIe driver [2]. Tracing through
kernel/irq/manage.c to verify the finding led me to the
IRQD_IRQ_INPROGRESS/chained-handler gap described above. Bjorn Helgaas
then asked whether other drivers using the same pattern would need
similar handling [3], which prompted the wider search below.
I searched the tree for other callers of
irq_set_chained_handler_and_data(irq, NULL, NULL) and found roughly
30 call sites with a similar shape, mostly in driver .remove()/teardown
paths. I haven't individually verified severity for each - it seems to
depend on what runs immediately after teardown in each specific driver
(e.g. whether clocks/power are cut shortly after, as in the PLDA case).
A partial list of files where the same call sequence is present:
arch/arm/common/locomo.c
arch/arm/common/sa1111.c
drivers/gpio/gpio-brcmstb.c
drivers/gpio/gpio-mpc8xxx.c
drivers/gpio/gpio-mt7621.c
drivers/gpio/gpio-mxc.c
drivers/gpio/gpio-rockchip.c
drivers/gpu/drm/imx/dc/dc-ic.c
drivers/gpu/drm/msm/msm_mdss.c
drivers/gpu/ipu-v3/ipu-common.c
drivers/irqchip/irq-imgpdc.c
drivers/irqchip/irq-lan966x-oic.c
drivers/irqchip/irq-ls-scfg-msi.c
drivers/irqchip/irq-ts4800.c
drivers/mfd/fsl-imx25-tsadc.c
drivers/pci/controller/pci-mvebu.c
I'm not sure what the right fix looks like at scale - possibly
implementing .irq_get_irqchip_state() where the hardware supports it,
possibly a driver-local synchronization primitive where it doesn't map
cleanly (which seems to be the case for PLDA, since its status
register is acknowledged partway through handler execution, before
the rest of the dispatch work completes).
Is this a known/expected limitation of synchronize_irq() for chained
handlers, or worth addressing more broadly? Happy to do more digging
or send patches if there's a preferred direction.
Thanks,
Ali
[1] https://lore.kernel.org/linux-pci/20260714174345.1073909-1-alitariq45892@gmail.com/
[2] https://lore.kernel.org/linux-pci/20260713150346.B57F11F000E9@smtp.kernel.org/
[3] https://lore.kernel.org/linux-pci/20260714175852.GA1387886@bhelgaas/
reply other threads:[~2026-07-17 11:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260717112244.231394-1-alitariq45892@gmail.com \
--to=alitariq45892@gmail.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
/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