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, linux-gpio@vger.kernel.org,
	linux-watchdog@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v3 04/11] gpio: Add Cortina Systems CS75xx GPIO driver
Date: Tue, 13 Oct 2026 06:44:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-169127@kernel.org> (raw)
In-Reply-To: <20261013-b4-cs75xx-s2-v3-4-181bb0d23f4c@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] gpio: hardware direction mutated before acquiring IRQ ownership
- [Medium] gpio: cs75xx_gpio_irq_handler drops latched edges due to early polarity flip
- [Low] kconfig: unmet dependency warning for GPIO_GENERIC without HAS_IOMEM
--

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

gpio: Add Cortina Systems CS75xx GPIO driver

Add a driver for the GPIO banks of the Cortina Systems CS75xx SoCs.
The data and direction registers are handled by gpio-mmio; each bank
has its own interrupt with level and edge triggers.

> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
[ ... ]
> @@ -300,6 +300,18 @@ config GPIO_CLPS711X
>  	help
>  	  Say yes here to support GPIO on CLPS711X SoCs.
>  
> +config GPIO_CS75XX
> +	tristate "Cortina Systems CS75xx GPIO support"
> +	depends on ARCH_CORTINA_ACCESS || COMPILE_TEST
> +	select GPIO_GENERIC

[Severity: Low]
Does this Kconfig setup trigger an unmet dependency warning when HAS_IOMEM is
not set? 

By enabling COMPILE_TEST, this configuration allows the driver to be built on
architectures like User-Mode Linux which lack HAS_IOMEM. However, it uses
select GPIO_GENERIC without inheriting its dependency on HAS_IOMEM. This
could lead to unmet direct dependency warnings and potential build failures.
Consider adding depends on HAS_IOMEM here to safely propagate the requirement.

> diff --git a/drivers/gpio/gpio-cs75xx.c b/drivers/gpio/gpio-cs75xx.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/gpio/gpio-cs75xx.c
[ ... ]
> +static void cs75xx_gpio_irq_ack(struct irq_data *d)
> +{
> +	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> +	struct cs75xx_gpio *g = gpiochip_get_data(gc);
> +
> +	writel(BIT(irqd_to_hwirq(d)), g->base + CS75XX_GPIO_INT);
> +}
[ ... ]
> +static int cs75xx_gpio_irq_reqres(struct irq_data *d)
> +{
> +	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> +	struct cs75xx_gpio *g = gpiochip_get_data(gc);
> +	irq_hw_number_t hwirq = irqd_to_hwirq(d);
> +	int ret;
> +
> +	/* The boot loader may leave the line configured as an output */
> +	ret = gc->direction_input(gc, hwirq);
> +	if (ret)
> +		return ret;
> +
> +	ret = gpiochip_reqres_irq(gc, hwirq);

[Severity: Medium]
Is it safe to mutate the hardware direction before successfully acquiring
the gpiolib IRQ ownership?

If the GPIO line is concurrently requested and actively driven as an output
by another subsystem, changing its hardware direction abruptly could break
the output signal and corrupt the hardware state. While gpiochip_reqres_irq()
checks the in-use state and will ultimately reject the request if it is an
output, the hardware has already been improperly modified here. The core
gpiolib ownership check should likely happen before the hardware state is
changed.

[ ... ]
> +static void cs75xx_gpio_irq_handler(struct irq_desc *desc)
> +{
> +	struct gpio_chip *gc = irq_desc_get_handler_data(desc);
> +	struct cs75xx_gpio *g = gpiochip_get_data(gc);
> +	struct irq_chip *chip = irq_desc_get_chip(desc);
> +	unsigned long pending;
> +	unsigned int offset;
> +
> +	chained_irq_enter(chip, desc);
> +
> +	pending = readl(g->base + CS75XX_GPIO_INT) &
> +		  readl(g->base + CS75XX_GPIO_IE);
> +
> +	for_each_set_bit(offset, &pending, gc->ngpio) {
> +		scoped_guard(gpio_generic_lock, &g->chip) {
> +			if (g->both_edges & BIT(offset))
> +				cs75xx_gpio_set_polarity(g, BIT(offset));
> +		}
> +		generic_handle_domain_irq(gc->irq.domain, offset);

[Severity: Medium]
Could this drop latched edge interrupts due to an early polarity flip?

In this handler, the edge polarity is toggled to arm the hardware for the
opposite edge, followed by generic_handle_domain_irq(), which uses
handle_edge_irq(). The generic edge handler invokes cs75xx_gpio_irq_ack()
which explicitly clears the interrupt status bit unconditionally.

If the pin state flips again in the small window between
cs75xx_gpio_set_polarity() and cs75xx_gpio_irq_ack(), the hardware latches
the new edge, but the subsequent ack clears it. This could result in edge
interrupts being permanently lost, potentially causing peripheral drivers
waiting for GPIO events to hang.

> +	}
> +
> +	chained_irq_exit(chip, desc);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-b4-cs75xx-s2-v3-0-181bb0d23f4c@gmail.com?part=4

  reply	other threads:[~2026-10-13  6:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  6:07 [PATCH v3 00/11] Cortina Systems CS75xx: interrupt controller, GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-13  6:07 ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 01/11] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 02/11] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 03/11] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 04/11] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:44   ` sashiko-bot [this message]
2026-10-13  6:07 ` [PATCH v3 05/11] dt-bindings: i2c: Add Cortina Systems CS7542 I2C controller Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 06/11] i2c: Add Cortina Systems CS75xx I2C controller driver Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 07/11] watchdog: Add ARM TWD (MPCore private) watchdog driver Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  7:03   ` sashiko-bot
2026-10-13  6:07 ` [PATCH v3 08/11] ARM: dts: cortina: cs7542: Add interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 09/11] ARM: dts: cortina: almondplus: Add reset button and enable I2C Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 10/11] ARM: multi_v7_defconfig: Enable Cortina Systems CS75xx GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:07 ` [PATCH v3 11/11] MAINTAINERS: Add Cortina Systems CS75xx interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
2026-10-13  6:07   ` Fil Dunsky
2026-10-13  6:18 ` [PATCH v3 00/11] Cortina Systems CS75xx: interrupt controller, GPIO, I2C and TWD watchdog Krzysztof Kozlowski
2026-10-13  6:19   ` Fil Dunsky

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-169127@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=filipp.dunsky@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --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.