Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers
Date: Thu, 26 Nov 2026 18:19:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-236012@kernel.org> (raw)
In-Reply-To: <20261126180315.98034-2-gianfranco.mariotti94@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] gpio: fxl6408: raw read of reserved regs in
  regcache_hw_init()
- [Medium] gpio: fxl6408: skipped OUTPUT_HIGH_Z restore in
  fxl6408_resume()
--

commit 1f216d3ac023de920e5ee09cfeb09b23ea1d4d61
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

gpio: fxl6408: Fix reserved register access and disable burst transfers

This commit restricts rd_range and wr_range to valid odd register addresses,
adds FXL6408_REG_OUTPUT_HIGH_Z to rd_range, and enables use_single_read and
use_single_write in regmap_config.

> diff --git a/drivers/gpio/gpio-fxl6408.c b/drivers/gpio/gpio-fxl6408.c
> index 8a7e70180efd9..9f80ea1214e03 100644
> --- a/drivers/gpio/gpio-fxl6408.c
> +++ b/drivers/gpio/gpio-fxl6408.c
> @@ -45,13 +45,16 @@
>  
>  static const struct regmap_range rd_range[] = {
>  	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
> -	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
> +	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
>  	{ FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS },
>  };

[Severity: Medium]
Can adding FXL6408_REG_OUTPUT_HIGH_Z to rd_range while relying on
num_reg_defaults_raw cause fxl6408_resume() to skip restoring
FXL6408_REG_OUTPUT_HIGH_Z?

With FXL6408_REG_OUTPUT_HIGH_Z in rd_range, regcache_hw_init() reads its
live value during devm_regmap_init_i2c() and records that as
map->reg_defaults[] before fxl6408_probe() writes 0 to disable High-Z mode.
If the register was already 0 at probe time (for example from the bootloader
or across a driver rebind or warm reboot), map->reg_defaults[] records 0
instead of the power-on reset default (0xff).  If the chip loses power during
suspend and resets to 0xff, regcache_mark_dirty() and regcache_sync() in
fxl6408_resume() see the cached 0 matching map->reg_defaults[] and skip the
write, leaving all GPIO outputs stuck in High-Z.

>  static const struct regmap_range wr_range[] = {
>  	{ FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID },
> -	{ FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT },
> +	{ FXL6408_REG_IO_DIR, FXL6408_REG_IO_DIR },
> +	{ FXL6408_REG_OUTPUT, FXL6408_REG_OUTPUT },
>  	{ FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z },
>  };
>  
> @@ -78,6 +81,8 @@ static const struct regmap_access_table volatile_table = {
>  static const struct regmap_config regmap = {
>  	.reg_bits = 8,
>  	.val_bits = 8,
> +	.use_single_read = true,
> +	.use_single_write = true,
>  
>  	.max_register = FXL6408_REG_INT_STS,
>  	.wr_table = &wr_table,

[Severity: Medium]
Does setting use_single_read with num_reg_defaults_raw = FXL6408_REG_INT_STS
+ 1 still read every reserved even register during regcache_hw_init()?

When reg_defaults_raw is unset, regcache_hw_init() sets map->cache_bypass =
true and calls regmap_raw_read(map, 0, tmp_buf, map->cache_size_raw) before
falling back to the loop that checks regmap_readable() and
regmap_volatile().  In regmap_raw_read(), cache_bypass and use_single_read
split that 20-byte transfer into 20 single-byte _regmap_raw_read() calls
across 0x00..0x13 without consulting rd_table or volatile_table, reading all
reserved even addresses as well as the clear-on-read status registers 0x01
and 0x13.

Providing explicit reg_defaults for the cacheable registers instead of
num_reg_defaults_raw would avoid both the raw hardware readback in
regcache_hw_init() and the stale default snapshot for
FXL6408_REG_OUTPUT_HIGH_Z.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126180315.98034-1-gianfranco.mariotti94@gmail.com?part=1

  reply	other threads:[~2026-11-26 18:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 18:03 [PATCH 0/5] gpio: fxl6408: Fix regmap ranges/bursts and add PI4IOE5V6408, reset, bias, and IRQ support Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 1/5] gpio: fxl6408: Fix reserved register access and disable burst transfers Gianfranco Mariotti
2026-11-26 18:19   ` sashiko-bot [this message]
2026-11-26 18:03 ` [PATCH 2/5] dt-bindings: gpio: Split fcs,fxl6408 from trivial-gpio and add diodes,pi4ioe5v6408 Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 3/5] gpio: fxl6408: Support optional power supplies and reset GPIO Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 4/5] gpio: fxl6408: Add pull-up and pull-down bias configuration Gianfranco Mariotti
2026-11-26 18:03 ` [PATCH 5/5] gpio: fxl6408: Add interrupt controller support Gianfranco Mariotti
2026-11-26 18:25   ` sashiko-bot

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-236012@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gianfranco.mariotti94@gmail.com \
    --cc=linux-gpio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox