From: sashiko-bot@kernel.org
To: "Thomas Perrot (Schneider Electric)" <thomas.perrot@bootlin.com>
Cc: conor+dt@kernel.org, Frank.Li@kernel.org, robh@kernel.org,
imx@lists.linux.dev, linux-watchdog@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v8 3/5] mfd: aaeon: Add SRG-IMX8P MCU driver
Date: Fri, 31 Jul 2026 10:07:41 +0000 [thread overview]
Message-ID: <20260731100742.53F641F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260731-dev-b4-aaeon-mcu-driver-v8-3-9ab00e80df2a@bootlin.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The driver unconditionally sets the I2C_M_DMA_SAFE flag on the caller-provided val_buf in aaeon_mcu_regmap_read, bypassing the I2C core's bounce buffering. If a child driver calls regmap_bulk_read() with a stack-allocated buffer for a volatile register (e.g., GPIO inputs), regmap passes the stack buffer directly to aaeon_mcu_regmap_read. This results in the I2C host controller performing DMA directly into a stack memory address, leading to cacheline sharing corruption or a kernel panic (especially on VMAP_STACK configurations).
- [High] The driver implements the MCU's command-response sequence using two separate i2c_transfer() calls without explicitly locking the I2C bus. Since i2c_transfer() internally acquires and releases the I2C adapter lock per call, there is a race window between the command write and the response read. If another device driver on the same I2C bus initiates a transfer during this window, its transaction will be physically interleaved on the bus, disrupting the MCU's state machine.
- [Low] The driver-specific header file aaeon-mcu.h is incorrectly placed in the global include/linux/mfd/ directory, violating MFD subsystem guidelines.
--
--- Patch [3]: [PATCH v8 3/5] mfd: aaeon: Add SRG-IMX8P MCU driver ---
commit 83256074ae86bd1d0d3b7e6e2bf9afe879bd3c73
Author: Thomas Perrot (Schneider Electric) <thomas.perrot@bootlin.com>
mfd: aaeon: Add SRG-IMX8P MCU driver
This patch adds a Multi-Function Device (MFD) driver for the Aaeon
SRG-IMX8P embedded controller. It implements a custom regmap bus over
I2C to match the MCU's command format and registers child devices.
> diff --git a/drivers/mfd/aaeon-mcu.c b/drivers/mfd/aaeon-mcu.c
> new file mode 100644
> index 0000000000000..c06c99d02d648
> --- /dev/null
> +++ b/drivers/mfd/aaeon-mcu.c
[ ... ]
> +static int aaeon_mcu_regmap_write(void *context, const void *data, size_t count)
> +{
[ ... ]
> + ret = i2c_transfer(client->adapter, &write_msg, 1);
> + if (ret < 0)
> + return ret;
> + if (ret != 1)
> + return -EIO;
> +
> + ret = i2c_transfer(client->adapter, &response_msg, 1);
[Severity: High]
Since i2c_transfer() internally acquires and releases the I2C adapter lock
per call, does issuing two separate transfers here leave a race window?
If another device driver on the same I2C bus initiates a transfer during
this window, its transaction could be physically interleaved on the bus.
Would it be safer to use i2c_lock_bus() and __i2c_transfer() to maintain
the lock across both the command write and response read?
> + if (ret < 0)
> + return ret;
[ ... ]
> +static int aaeon_mcu_regmap_read(void *context, const void *reg_buf,
> + size_t reg_size, void *val_buf, size_t val_size)
> +{
[ ... ]
> + read_msg.addr = client->addr;
> + read_msg.flags = I2C_M_RD | I2C_M_DMA_SAFE;
> + read_msg.buf = val_buf;
[Severity: High]
Can val_buf point to a stack-allocated buffer?
When a child driver calls regmap_bulk_read() for a volatile register (like
GPIO inputs), regmap might pass a stack-allocated buffer directly to this
function. By unconditionally setting I2C_M_DMA_SAFE, doesn't this force
the I2C core to bypass bounce buffering?
If the I2C host controller then performs DMA directly into a stack memory
address, this could lead to cacheline sharing corruption or a kernel
panic, especially on VMAP_STACK configurations.
> + read_msg.len = val_size;
> +
> + ret = i2c_transfer(client->adapter, &write_msg, 1);
> + if (ret < 0)
> + return ret;
> + if (ret != 1)
> + return -EIO;
> +
> + ret = i2c_transfer(client->adapter, &read_msg, 1);
[Severity: High]
Similar to the write path above, does releasing the I2C adapter lock
between the write command and the read response risk interleaving transfers
with other devices on the same I2C bus?
> + if (ret < 0)
> + return ret;
[ ... ]
> diff --git a/include/linux/mfd/aaeon-mcu.h b/include/linux/mfd/aaeon-mcu.h
> new file mode 100644
> index 0000000000000..3a1aeec85d60b
> --- /dev/null
> +++ b/include/linux/mfd/aaeon-mcu.h
[Severity: Low]
This isn't a bug, but should this driver-specific header be placed locally
in drivers/mfd/ instead of the global include/linux/mfd/ directory?
The MFD subsystem guidelines state that driver-specific header files used
only by the parent and its immediate children should be kept local to
drivers/mfd/.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-dev-b4-aaeon-mcu-driver-v8-0-9ab00e80df2a@bootlin.com?part=3
next prev parent reply other threads:[~2026-07-31 10:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 9:51 [PATCH v8 0/5] Add support for AAEON SRG-IMX8P MCU Thomas Perrot (Schneider Electric)
2026-07-31 9:51 ` [PATCH v8 1/5] dt-bindings: vendor-prefixes: Add AAEON vendor prefix Thomas Perrot (Schneider Electric)
2026-07-31 9:51 ` [PATCH v8 2/5] dt-bindings: mfd: Add AAEON embedded controller Thomas Perrot (Schneider Electric)
2026-07-31 9:51 ` [PATCH v8 3/5] mfd: aaeon: Add SRG-IMX8P MCU driver Thomas Perrot (Schneider Electric)
2026-07-31 10:07 ` sashiko-bot [this message]
2026-07-31 9:51 ` [PATCH v8 4/5] gpio: aaeon: Add GPIO driver for SRG-IMX8P MCU Thomas Perrot (Schneider Electric)
2026-07-31 10:01 ` sashiko-bot
2026-07-31 9:51 ` [PATCH v8 5/5] watchdog: aaeon: Add watchdog " Thomas Perrot (Schneider Electric)
2026-07-31 10:04 ` 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=20260731100742.53F641F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=linux-watchdog@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=thomas.perrot@bootlin.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.