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 v10 2/8] gpiolib: regmap: add GPIO_REGMAP_QUIRK_SET_AFTER_DIR
Date: Thu, 15 Oct 2026 11:01:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-172706@kernel.org> (raw)
In-Reply-To: <20261015-cv75-gpio-v10-2-3fe3eb315a55@ambarella.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] gpio: regmap: direction_output bypasses set_with_clear callback
- [Medium] gpio: regmap: silent masking of regmap I/O errors in direction_output
--

commit 3bcfc79235e7b203090c7124352804ddb1bcdde7
Author: Long Zhao <longzhao@ambarella.com>

gpiolib: regmap: add GPIO_REGMAP_QUIRK_SET_AFTER_DIR

This commit introduces a new quirk flag, GPIO_REGMAP_QUIRK_SET_AFTER_DIR,
which allows the output value to be written after the direction change.
This supports legacy controllers that ignore output writes while a line
is still configured as an input.

> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
> --- a/drivers/gpio/gpio-regmap.c
> +++ b/drivers/gpio/gpio-regmap.c

[ ... ]

> @@ -271,9 +272,17 @@ static int gpio_regmap_direction_output(struct gpio_chip *chip,
>  			return ret;
>  	}
>  
> -	gpio_regmap_set(chip, offset, value);
> +	if (!(gpio->quirks & GPIO_REGMAP_QUIRK_SET_AFTER_DIR))
> +		gpio_regmap_set(chip, offset, value);
>  
> -	return gpio_regmap_set_direction(chip, offset, true);
> +	ret = gpio_regmap_set_direction(chip, offset, true);
> +	if (ret)
> +		return ret;
> +
> +	if (gpio->quirks & GPIO_REGMAP_QUIRK_SET_AFTER_DIR)
> +		gpio_regmap_set(chip, offset, value);

[Severity: High]
Does this bypass the chip->set callback for hardware that uses separate set
and clear registers?

When setting the initial value during a direction change to output,
hardcoding a call to gpio_regmap_set() instead of using the properly assigned
callback (such as gpio_regmap_set_with_clear) means that if value == 0, it
writes 0 to the reg_set_base register.

On set/clear hardware, this is typically a no-op instead of properly writing
the mask to reg_clr_base. This could leave the pin incorrectly driven high.

[Severity: Medium]
Is it safe to ignore the return value of gpio_regmap_set() here?

If the underlying bus (like I2C or SPI) encounters a failure or timeout
during the register write, the negative error code is silently dropped.

The gpiolib core would be falsely informed that the direction and value were
successfully configured, leading to state inconsistencies where software
believes a line is driven high or low but the hardware register write failed.

> +
> +	return 0;
>  }
>  
>  void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-cv75-gpio-v10-0-3fe3eb315a55@ambarella.com?part=2

  reply	other threads:[~2026-10-15 11:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 10:53 [PATCH v10 0/8] gpio: add Ambarella CV75 PL061 support Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 1/8] dt-bindings: gpio: pl061: add Ambarella CV75 variant Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 2/8] gpiolib: regmap: add GPIO_REGMAP_QUIRK_SET_AFTER_DIR Long Zhao via B4 Relay
2026-10-15 11:01   ` sashiko-bot [this message]
2026-10-15 10:53 ` [PATCH v10 3/8] gpio: pl061: drop redundant pending check in the IRQ handler Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 4/8] gpio: pl061: convert register access to regmap Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 5/8] gpio: pl061: use IRQ_TYPE_LEVEL_MASK and IRQ_TYPE_EDGE_BOTH Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 6/8] gpio: pl061: use cleanup helpers for locks Long Zhao via B4 Relay
2026-10-15 10:53 ` [PATCH v10 7/8] gpio: pl061: switch data path to gpio-regmap Long Zhao via B4 Relay
2026-10-15 11:04   ` sashiko-bot
2026-10-15 10:53 ` [PATCH v10 8/8] gpio: pl061: add Ambarella register-layout variant 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-172706@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