From: sashiko-bot@kernel.org
To: "Long Zhao" <longzhao@ambarella.com>
Cc: conor+dt@kernel.org, linux-clk@vger.kernel.org,
mfd@lists.linux.dev, linux-serial@vger.kernel.org,
robh@kernel.org, devicetree@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v9 12/15] gpio: pl061: add Ambarella register-layout variant
Date: Thu, 01 Oct 2026 12:55:34 +0000 [thread overview]
Message-ID: <20261001125534.D01BA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001-cv75-v5-v9-12-486cc289a4b8@ambarella.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] gpio: pl061: output state corruption via RMW on Ambarella data register
--
commit b4f961be1d109a1753acf06716b7c68488ad35bd
Author: Long Zhao <longzhao@ambarella.com>
gpio: pl061: add Ambarella register-layout variant
Add a 32-bit, 32-line layout with DAT/DIR/IS/IBE/IEV/IE/MIS/IC plus
MASK and ENABLE. Probe unmasks the bank and enables the controller.
IRQ type changes also clear the pending bit. This derivative does not
need write-after-direction or system suspend save/restore.
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 08d45f8923c2a..bbb9eeeb074aa 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
[ ... ]
> @@ -318,6 +330,18 @@ static bool pl061_arm_volatile_reg(struct device *dev, unsigned int reg)
> }
> }
>
> +static bool pl061_ambarella_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + switch (reg) {
> + case AMBARELLA_DAT:
> + case AMBARELLA_MIS:
> + case AMBARELLA_IC:
> + return true;
[Severity: High]
Does marking AMBARELLA_DAT as volatile expose the driver to data corruption
during read-modify-write operations?
Because AMBARELLA_DAT is marked volatile and .cache_type is omitted below
in pl061_ambarella_regmap_config (defaulting to REGCACHE_NONE), RMW
operations on AMBARELLA_DAT (like via gpio_set_value) will bypass the cache.
Since this is a full 32-bit width register, a RMW operation reads the
physical state of all 32 pins and writes it back. This could overwrite the
output flip-flops of all other pins with their current physical state
instead of their driven values.
Unlike the ARM variant which leverages address-based masking to safely set
individual bits, it looks like Ambarella relies on a single 32-bit register
and would strictly require regmap caching (e.g., REGCACHE_FLAT) to perform
safe RMW operations.
> + default:
> + return false;
> + }
> +}
> +
> static const struct regmap_config pl061_arm_regmap_config = {
> .reg_bits = 16,
> .val_bits = 8,
[ ... ]
This is a pre-existing issue, but I noticed a potential interrupt storm due
to the incorrect hardware initialization order in pl061_probe():
drivers/gpio/gpio-pl061.c:pl061_probe() {
...
if (regs->enable) {
ret = regmap_write(pl061->regmap, regs->enable, ~0U);
if (ret)
return ret;
}
if (regs->mask) {
ret = regmap_write(pl061->regmap, regs->mask, ~0U);
if (ret)
return ret;
}
/*
* irq_chip support
*/
regmap_write(pl061->regmap, regs->ie, 0); /* disable irqs */
...
}
[Severity: Medium]
Can this sequence trigger an interrupt storm that permanently disables the
parent IRQ line?
The hardware controller is unmasked and enabled globally (via regs->enable
and regs->mask) before its local interrupts are masked (regs->ie = 0). If
the bootloader or kexec leaves the device with pending interrupts and IE
set, enabling the controller immediately asserts the IRQ line before the
driver has registered the chained handler.
This is also a pre-existing issue, but I noticed a potential use-after-free
of the irq_domain on driver teardown in pl061_probe():
drivers/gpio/gpio-pl061.c:pl061_probe() {
...
gpio_regmap = devm_gpio_regmap_register(dev, &config);
if (IS_ERR(gpio_regmap)) {
...
if (irq) {
ret = devm_add_action_or_reset(dev, pl061_remove_irq, pl061);
if (ret)
return ret;
irq_set_chained_handler_and_data(irq, pl061_irq_handler, pl061);
}
...
}
[Severity: High]
Does registering the IRQ teardown action after registering the gpio_regmap
cause a use-after-free?
During driver unbind or probe failure, devm actions execute in LIFO order.
Because devm_add_action_or_reset(dev, pl061_remove_irq) is called after
devm_gpio_regmap_register(), the pl061_remove_irq action executes first and
frees pl061->irq_domain.
Subsequently, devm_gpio_regmap_unregister calls gpiochip_remove(), which
iterates over active IRQs and calls gpiod_to_irq(), dereferencing the
already-freed domain. This could be reached by holding a GPIO line event FD
open from userspace while unbinding the driver via sysfs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001-cv75-v5-v9-0-486cc289a4b8@ambarella.com?part=12
next prev parent reply other threads:[~2026-10-01 12:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 12:40 [PATCH v9 00/15] Ambarella CV75 SoC minimal bring-up Long Zhao via B4 Relay
2026-10-01 12:40 ` [PATCH v9 01/15] dt-bindings: arm: add Ambarella CV75 platforms Long Zhao via B4 Relay
2026-10-01 12:43 ` sashiko-bot
2026-10-01 12:40 ` [PATCH v9 02/15] dt-bindings: mfd: syscon: add Ambarella CV75 secure scratchpad Long Zhao via B4 Relay
2026-10-01 12:43 ` sashiko-bot
2026-10-01 12:40 ` [PATCH v9 03/15] dt-bindings: clock: add Ambarella CV75 RCT Long Zhao via B4 Relay
2026-10-01 12:45 ` sashiko-bot
2026-10-01 12:40 ` [PATCH v9 04/15] dt-bindings: gpio: pl061: add Ambarella CV75 variant Long Zhao via B4 Relay
2026-10-01 12:50 ` sashiko-bot
2026-10-01 19:23 ` Conor Dooley
2026-10-01 19:36 ` Linus Walleij
2026-10-01 21:16 ` Conor Dooley
2026-10-01 12:40 ` [PATCH v9 05/15] dt-bindings: serial: snps-dw-apb-uart: add ambarella,cv75-uart Long Zhao via B4 Relay
2026-10-01 12:43 ` sashiko-bot
2026-10-01 12:40 ` [PATCH v9 06/15] clk: ambarella: add CV75 RCT clock controller Long Zhao via B4 Relay
2026-10-01 12:47 ` sashiko-bot
2026-10-02 8:10 ` Andy Shevchenko
2026-10-01 12:40 ` [PATCH v9 07/15] gpiolib: regmap: add GPIO_REGMAP_QUIRK_SET_AFTER_DIR Long Zhao via B4 Relay
2026-10-01 12:45 ` sashiko-bot
2026-10-02 7:41 ` Andy Shevchenko
2026-10-01 12:40 ` [PATCH v9 08/15] gpio: pl061: convert register access to regmap Long Zhao via B4 Relay
2026-10-01 12:47 ` sashiko-bot
2026-10-02 8:26 ` Andy Shevchenko
2026-10-01 12:40 ` [PATCH v9 09/15] gpio: pl061: use IRQ_TYPE_LEVEL_MASK and IRQ_TYPE_EDGE_BOTH Long Zhao via B4 Relay
2026-10-01 12:45 ` sashiko-bot
2026-10-02 9:22 ` Andy Shevchenko
2026-10-01 12:40 ` [PATCH v9 10/15] gpio: pl061: use cleanup helpers for locks Long Zhao via B4 Relay
2026-10-01 12:46 ` sashiko-bot
2026-10-01 12:41 ` [PATCH v9 11/15] gpio: pl061: switch data path to gpio-regmap Long Zhao via B4 Relay
2026-10-01 12:56 ` sashiko-bot
2026-10-01 12:41 ` [PATCH v9 12/15] gpio: pl061: add Ambarella register-layout variant Long Zhao via B4 Relay
2026-10-01 12:55 ` sashiko-bot [this message]
2026-10-01 12:41 ` [PATCH v9 13/15] serial: 8250_dw: add Ambarella CV75 quirks Long Zhao via B4 Relay
2026-10-01 12:49 ` sashiko-bot
2026-10-01 12:52 ` Greg Kroah-Hartman
2026-10-01 19:20 ` Linus Walleij
2026-10-02 2:17 ` zl020895
2026-10-02 8:09 ` Jerome Brunet
2026-10-01 12:41 ` [PATCH v9 14/15] arm64: ambarella: add ARCH_AMBARELLA and CV75 EVK DT Long Zhao via B4 Relay
2026-10-01 12:54 ` sashiko-bot
2026-10-01 12:41 ` [PATCH v9 15/15] MAINTAINERS: add ARM/AMBARELLA SoC support Long Zhao via B4 Relay
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=20261001125534.D01BA1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=longzhao@ambarella.com \
--cc=mfd@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox