Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Long Zhao" <longzhao@ambarella.com>, linux-gpio@vger.kernel.org
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v15 10/14] gpio: pl061: switch data path to gpio-regmap
Date: Wed, 18 Nov 2026 08:35:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-220460@kernel.org> (raw)
In-Reply-To: <20261118-cv75-gpio-v15-10-e3c563673fe1@ambarella.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] gpio: pl061: premature IRQ domain publish breaks
  pl061_irq_domain_map()
- [Low] gpio: pl061: incomplete changelog and inaccurate
  irq_set_parent() description
--

commit 0b93363ac72443e24d6e5779edcb0ca7954b6b53
Author: Long Zhao <longzhao@ambarella.com>

> gpio: pl061: switch data path to gpio-regmap
>
> Move get, set and direction onto gpio-regmap. ARM PL061 sets
> GPIO_REGMAP_QUIRK_SET_AFTER_DIR so the output value is written after
> the direction change.
>
> Keep a custom irqchip and irq domain. Create the domain with the PL061
> private data and let gpio-regmap attach it.
>
> Leave the chained handler's regmap_read() unchecked. mis stays 0 on
> failure, so the pending loop does nothing, and chained_irq_exit()
> still runs. irq_type still ignores MMIO write returns.
>
> The irqchip uses its own child IRQ lockdep class. Split teardown into
> two devm actions: dispose mappings while the domain is still alive,
> and clear the chained handler only after it was installed. Checked
> with lockdep on the CV75 board. irq_set_parent() nests the GPIO
> irq_desc under the AMBA parent for irq_set_wake().
>
> The irqchip is immutable and stores struct pl061 as its chip data,
> so the GPIOCHIP_IRQ_RESOURCE_HELPERS macro does not apply. Look up
> the gpio_chip while mapping the IRQ, then call gpiochip_reqres_irq(),
> gpiochip_relres_irq(), gpiochip_enable_irq() and
> gpiochip_disable_irq() from the irqchip.
>
> Signed-off-by: Long Zhao <longzhao@ambarella.com>

[Severity: Low]
This isn't a bug, but the commit message says irq_set_parent() nests the
GPIO irq_desc under the AMBA parent for irq_set_wake().  irq_set_parent()
only records desc->parent_irq under CONFIG_HARDIRQS_SW_RESEND for software
interrupt resending; irq_set_lockdep_class() is what puts the child
irq_desc in a separate lockdep class so irq_set_irq_wake() on parent_irq
does not trigger a lockdep recursion warning.

The changelog also omits the addition of struct pl061_regs and struct
pl061_drvdata and the rewrite of pl061_suspend() and pl061_resume() to use
regcache syncing instead of struct pl061_context_save_regs.

> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 27ed759486caf..db3d02976383d 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
[ ... ]
> @@ -289,29 +255,64 @@ static void pl061_irq_unmask(struct irq_data *d)
[ ... ]
> +static int pl061_gc_from_domain(struct gpio_chip *gc, const void *data)
> +{
> +	const struct pl061 *pl061 = data;
> +
> +	return gc->irq.domain == pl061->irq_domain;
> +}
> +
> +static struct gpio_chip *pl061_lookup_gc(struct pl061 *pl061)
> +{
> +	struct gpio_device *gdev;
> +
> +	if (pl061->gc)
> +		return pl061->gc;
> +
> +	gdev = gpio_device_find(pl061, pl061_gc_from_domain);
> +	if (!gdev)
> +		return NULL;
> +
> +	pl061->gc = gpio_device_get_chip(gdev);
> +	gpio_device_put(gdev);
> +	return pl061->gc;
> +}
[ ... ]
> @@ -319,68 +320,175 @@ static const struct irq_chip pl061_irq_chip = {
[ ... ]
> +static int pl061_irq_domain_map(struct irq_domain *d, unsigned int virq,
> +				irq_hw_number_t hwirq)
> +{
> +	struct pl061 *pl061 = d->host_data;
> +
> +	if (!pl061_lookup_gc(pl061))
> +		return -ENODEV;

[Severity: Medium]
Can pl061_irq_domain_map() fail with -ENODEV if a consumer maps an IRQ
before devm_gpio_regmap_register() finishes?

devm_irq_domain_instantiate() publishes pl061->irq_domain on
irq_domain_list before devm_gpio_regmap_register() runs, and inside
gpio_regmap_register(), gpiochip_add_data() registers the gpio_device
before gpiochip_irqchip_add_domain() sets gc->irq.domain:

CPU0                                    CPU1
pl061_probe()
  devm_irq_domain_instantiate()
    ...
      __irq_domain_publish()
                                        irq_create_fwspec_mapping()
                                          irq_find_matching_fwspec()
                                          irq_domain_associate_locked()
                                            pl061_irq_domain_map()
                                              pl061_lookup_gc()
                                                --> NULL (-ENODEV)
  devm_gpio_regmap_register()
    gpio_regmap_register()
      gpiochip_add_data()
      gpiochip_irqchip_add_domain()
        gc->irq.domain = irq_domain

Because the domain is already published, a concurrent consumer does not get
-EPROBE_DEFER from irq_find_host(); instead pl061_irq_domain_map() fails
with -ENODEV and irq_create_fwspec_mapping() returns 0, failing the
consumer's probe.

Since pl061_irq_domain_map() does not use pl061->gc itself, could
pl061_lookup_gc() be deferred to pl061_irq_request_resources(), or could
pl061->gc be populated before publishing the IRQ domain?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-cv75-gpio-v15-0-e3c563673fe1@ambarella.com?part=10

  reply	other threads:[~2026-11-18  8:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  7:42 [PATCH v15 00/14] gpio: add Ambarella CV75 PL061 support Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 01/14] dt-bindings: gpio: pl061: add Ambarella CV75 variant Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 02/14] gpio: regmap: add GPIO_REGMAP_QUIRK_SET_AFTER_DIR Long Zhao via B4 Relay
2026-11-18  7:57   ` sashiko-bot
2026-11-18  7:42 ` [PATCH v15 03/14] gpio: regmap: remove gpiochip before tearing down irqchip Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 04/14] gpio: pl061: drop redundant pending check in the IRQ handler Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 05/14] gpio: pl061: convert register access to regmap Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 06/14] gpio: pl061: use IRQ_TYPE_LEVEL_MASK and IRQ_TYPE_EDGE_BOTH Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 07/14] gpio: pl061: use cleanup helpers for locks Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 08/14] gpio: pl061: keep the parent device in a local Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 09/14] gpiolib: request ACPI GPIO events for external IRQ domains Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 10/14] gpio: pl061: switch data path to gpio-regmap Long Zhao via B4 Relay
2026-11-18  8:35   ` sashiko-bot [this message]
2026-11-18  7:42 ` [PATCH v15 11/14] gpio: pl061: add Ambarella register-layout variant Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 12/14] gpio: pl061: tidy up IRQ trigger logging Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 13/14] lib/string_choices: add str_rising_falling() Long Zhao via B4 Relay
2026-11-18  7:42 ` [PATCH v15 14/14] gpio: pl061: use string_choices helpers for IRQ trigger logging 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=sashiko-outbox-220460@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=longzhao@ambarella.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox