All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
Date: Fri, 04 Dec 2026 20:14:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-250607@kernel.org> (raw)
In-Reply-To: <20261204-cs75xx-intc-v7-3-c5e6e23a1a8c@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] irqchip/cs75xx: unlocked read of gc->mask_cache in
  cs75xx_intc_handler()
- [Low] irqchip: stray Link trailer and duplicated paragraph in commit
  message
--

commit dc49f44370a5b75de4ec7c5408183cbf6b8fb780
Author: Fil Dunsky <filipp.dunsky@gmail.com>

> irqchip: Add Cortina Systems CS75xx peripheral interrupt controller
>
> The timers, GPIO banks, I2C, MDIO, SPI and a few other low speed
> peripherals of the Cortina Systems CS75xx SoCs share a single GIC
> interrupt. A status register shows the level of the 15 sources and an
> enable register masks them; there is nothing to acknowledge, each source
> is cleared in its peripheral.
>
> Add a chained driver using a generic chip on a linear domain.
> The driver depends on OF and HAS_IOMEM and can be enabled independently
> of the CS75xx platform support.
>
> Use irq_domain_instantiate() to allocate and initialize the generic chip
> and install the parent handler before the IRQ domain is published.
> A consumer can then only map an IRQ once the chip and handler are ready.
> Use guard_chained_irq() to pair chained entry and exit.
>
> Link: https://lore.kernel.org/all/87mrqpov7z.ffs@fw13/
>
> Pass the transient register base and parent IRQ through init_data.
> Configure the generic chip in its own init callback and install the
> parent handler in the domain init callback before publication.
>
> Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13
> Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>

[Severity: Low]
There is a Link: trailer in the middle of the commit message, followed by a
paragraph repeating the generic chip and parent handler init description.
Should those two paragraphs be merged and both Link: trailers grouped
together before Signed-off-by?

[ ... ]

> diff --git a/drivers/irqchip/irq-cs75xx.c b/drivers/irqchip/irq-cs75xx.c
> new file mode 100644
> index 0000000000000..10fd2fafad7fb
> --- /dev/null
> +++ b/drivers/irqchip/irq-cs75xx.c
> @@ -0,0 +1,133 @@

[ ... ]

> +static void cs75xx_intc_handler(struct irq_desc *desc)
> +{
> +	struct irq_domain *domain = irq_desc_get_handler_data(desc);
> +	struct irq_chip *chip = irq_desc_get_chip(desc);
> +	struct irq_chip_generic *gc;
> +	unsigned long pending;
> +	unsigned int hwirq;
> +
> +	gc = irq_get_domain_generic_chip(domain, 0);
> +	guard_chained_irq(chip, desc);
> +
> +	pending = readl(gc->reg_base + CS75XX_INTC_STATUS) & gc->mask_cache;
> +	for_each_set_bit(hwirq, &pending, CS75XX_INTC_NR_IRQS)
> +		generic_handle_domain_irq(domain, hwirq);
> +}

[Severity: Medium]
Can this unlocked read of gc->mask_cache race with concurrent mask/unmask
updates on another CPU and dispatch spurious child interrupts?

irq_gc_mask_set_bit() and irq_gc_mask_clr_bit() update gc->mask_cache under
gc->lock, while cs75xx_intc_handler() reads it unlocked.  Along with the
data race, unsynchronized reads of CS75XX_INTC_STATUS and gc->mask_cache
allow a split snapshot when another CPU unmasks an IRQF_ONESHOT child IRQ:

CPU0                              CPU1
cs75xx_intc_handler()             <threaded handler for IRQ B>
  readl(CS75XX_INTC_STATUS)
    /* bit A and bit B set */
                                    /* clears peripheral B */
                                  irq_finalize_oneshot()
                                    unmask_threaded_irq()
                                      irq_gc_mask_set_bit()
                                        gc->mask_cache |= BIT(B)
                                    unlock(&desc_B->lock)
  & gc->mask_cache  <-- data race, sees bit B set
  generic_handle_domain_irq(..., B)
    handle_level_irq(desc_B)
      handle_irq_event(desc_B)  <-- spurious IRQ

Because desc_B is already unmasked and desc_B->lock has been released by the
time handle_level_irq() runs, irq_can_handle() returns true and invokes the
handler for an already-cleared interrupt.

Wrapping the status and mask_cache read in scoped_guard(raw_spinlock,
&gc->lock) before the dispatch loop avoids both the data race and the split
snapshot.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-cs75xx-intc-v7-0-c5e6e23a1a8c@gmail.com?part=3

      reply	other threads:[~2026-12-04 20:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 19:59 [PATCH v7 0/3] irqchip: Add Cortina Systems CS75xx peripheral interrupt controller Fil Dunsky
2026-12-04 19:59 ` Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks Fil Dunsky
2026-12-04 19:59   ` Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 2/3] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky
2026-12-04 19:59   ` Fil Dunsky via B4 Relay
2026-12-04 19:59 ` [PATCH v7 3/3] irqchip: Add Cortina Systems CS75xx " Fil Dunsky
2026-12-04 19:59   ` Fil Dunsky via B4 Relay
2026-12-04 20:14   ` sashiko-bot [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=sashiko-outbox-250607@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=filipp.dunsky@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.