From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: mfd@lists.linux.dev, devicetree@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 4/5] mfd: ocelot: Add support for the LAN9645x switch family
Date: Sat, 05 Dec 2026 12:03:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-251483@kernel.org> (raw)
In-Reply-To: <20261204-mfd-ocelot-add-lan9645x-support-v2-4-d0b811aebfbf@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] mfd: ocelot: duplicate LAN9645x GCB regmap due to resource name
mismatch
- [Low] mfd: ocelot: data race on spi_padding_bytes in
ocelot_spi_probe()
--
commit 3668fbd43fcd3e9655859afe6d486c660c2336eb
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
mfd: ocelot: Add support for the LAN9645x switch family
This commit adds MFD and SPI regmap support for the LAN9645x switch family,
including chip reset handling, SPI padding byte calculation around reset,
and child MFD cell definitions.
> diff --git a/drivers/mfd/ocelot-spi.c b/drivers/mfd/ocelot-spi.c
> index b02f8a5eaab92..eb040be912048 100644
> --- a/drivers/mfd/ocelot-spi.c
> +++ b/drivers/mfd/ocelot-spi.c
[ ... ]
> @@ -50,6 +57,10 @@ static const struct resource vsc7512_gcb_resource =
> VSC7512_CHIP_REGS_RES_SIZE,
> "devcpu_gcb_chip_regs");
>
> +static const struct resource lan9645x_gcb_resource =
> + DEFINE_RES_REG_NAMED(LAN9645X_GCB_RES_START, LAN9645X_GCB_RES_SIZE,
> + "devcpu_gcb");
> +
> static int vsc7512_spi_padding_bytes(u32 max_speed_hz)
> {
> if (max_speed_hz <= 500000)
[Severity: Low]
Does naming lan9645x_gcb_resource "devcpu_gcb" cause a duplicate regmap
for the GCB block?
lan9645x_switch_resources defines the same GCB range under the name "gcb".
Because ocelot_core_try_add_regmap() deduplicates by resource name via
dev_get_regmap(dev, res->name), every LAN9645x probe creates a second
regmap and debugfs entry for the same registers.
Naming lan9645x_gcb_resource "gcb" would let ocelot_core_try_add_regmap()
reuse the regmap created in ocelot_spi_probe().
[ ... ]
> @@ -266,6 +306,8 @@ static int ocelot_spi_probe(struct spi_device *spi)
> * This must be done before calling init, and after a chip reset is
> * performed.
> */
> + ddata->spi_padding_bytes = reset_padding ?: padding;
> +
> err = ocelot_spi_initialize(dev);
> if (err)
> return dev_err_probe(dev, err, "Error initializing SPI bus\n");
> @@ -278,6 +320,8 @@ static int ocelot_spi_probe(struct spi_device *spi)
> * A chip reset will clear the SPI configuration, so it needs to be done
> * again before we can access any registers.
> */
> + ddata->spi_padding_bytes = padding;
> +
> err = ocelot_spi_initialize(dev);
> if (err)
> return dev_err_probe(dev, err, "Error initializing SPI bus after reset\n");
[Severity: Low]
Can updating ddata->spi_padding_bytes here race with concurrent regmap
reads from debugfs?
ocelot_spi_init_regmap() exposes the regmap's debugfs registers file via
devm_regmap_init() before probe finishes. A concurrent root read of that
file calls ocelot_spi_regmap_bus_read() under map->mutex, while probe
writes ddata->spi_padding_bytes without that lock or WRITE_ONCE():
CPU0 CPU1
ocelot_spi_probe()
ocelot_spi_init_regmap()
devm_regmap_init()
regmap_debugfs_init()
regmap_read_debugfs()
regmap_read()
ocelot_spi_regmap_bus_read()
ddata->spi_padding_bytes = ... if (ddata->spi_padding_bytes)
<-- data race
This causes a data race on ddata->spi_padding_bytes and transiently
mismatched SPI padding for the debugfs read, especially while
ocelot_chip_reset() sleeps.
Initializing spi_padding_bytes before ocelot_spi_init_regmap() and using
WRITE_ONCE()/READ_ONCE() or the regmap lock avoids the race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-mfd-ocelot-add-lan9645x-support-v2-0-d0b811aebfbf@microchip.com?part=4
next prev parent reply other threads:[~2026-12-05 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 12:02 [PATCH v2 0/5] mfd: ocelot: Support the LAN9645x switch family Jens Emil Schulz Østergaard
2026-12-04 12:02 ` [PATCH v2 1/5] mfd: ocelot: Define the VSC7512 cells with the MFD_CELL_* macros Jens Emil Schulz Østergaard
2026-12-04 12:02 ` [PATCH v2 2/5] mfd: ocelot: Select the chip through match data Jens Emil Schulz Østergaard
2026-12-04 12:02 ` [PATCH v2 3/5] dt-bindings: mfd: Add the Microchip LAN9645x switch family Jens Emil Schulz Østergaard
2026-12-04 12:02 ` [PATCH v2 4/5] mfd: ocelot: Add support for the " Jens Emil Schulz Østergaard
2026-12-05 12:03 ` sashiko-bot [this message]
2026-12-04 12:02 ` [PATCH v2 5/5] mfd: ocelot: Read LAN9645x registers in a single SPI transfer Jens Emil Schulz Østergaard
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-251483@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=lee@kernel.org \
--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