From: sashiko-bot@kernel.org
To: "Akshay Gupta" <Akshay.Gupta@amd.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3 5/8] misc: amd-sbi: Add support for SB-TSI over I3C
Date: Mon, 22 Jun 2026 14:19:17 +0000 [thread overview]
Message-ID: <20260622141918.086C11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260622135821.2190260-6-Akshay.Gupta@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The I3C transfer buffer shares a CPU cacheline with the device structure and other DMA mappings, causing unsafe DMA operations and potential memory corruption.
- [Low] Unmet Kconfig dependency warning triggered because `SENSORS_SBTSI` unconditionally selects `AMD_SBTSI` without inheriting its dependencies.
--
commit 6d735915bcef7f51c2d83398a0f1592836ede997
Author: Prathima <Prathima.Lk@amd.com>
misc: amd-sbi: Add support for SB-TSI over I3C
This patch extends the SB-TSI driver to support both I2C and I3C bus
interfaces. It registers both I2C and I3C drivers using
module_i3c_i2c_driver() and updates the Kconfig dependency from I2C to
I3C_OR_I2C.
> diff --git a/drivers/misc/amd-sbi/Kconfig b/drivers/misc/amd-sbi/Kconfig
> index 512251690e0e9..1a96b71f85069 100644
> --- a/drivers/misc/amd-sbi/Kconfig
> +++ b/drivers/misc/amd-sbi/Kconfig
> @@ -23,13 +23,13 @@ config AMD_SBRMI_HWMON
>
> config AMD_SBTSI
> tristate "AMD side band TSI support"
> - depends on I2C
> + depends on I3C_OR_I2C
[Severity: Low]
Could this change cause unmet direct dependencies warnings if another Kconfig
symbol selects AMD_SBTSI without inheriting this new dependency?
For example, if SENSORS_SBTSI selects AMD_SBTSI, it would need to have
compatible dependencies to prevent build failures on unsupported
architectures or when I3C/I2C is disabled.
> depends on ARM || ARM64 || COMPILE_TEST
> select AUXILIARY_BUS
[ ... ]
> diff --git a/drivers/misc/amd-sbi/tsi-core.c b/drivers/misc/amd-sbi/tsi-core.c
> index 6ef1831515bbb..9278d06d8e5f6 100644
> --- a/drivers/misc/amd-sbi/tsi-core.c
> +++ b/drivers/misc/amd-sbi/tsi-core.c
[ ... ]
> @@ -23,8 +33,54 @@ static int sbtsi_i2c_xfer(struct sbtsi_data *data, u8 reg, u8 *val, bool is_read
> return i2c_smbus_write_byte_data(data->client, reg, *val);
> }
>
> +/* I3C read transfer function */
> +static int sbtsi_i3c_read(struct sbtsi_data *data, u8 reg, u8 *val)
> +{
> + struct i3c_xfer xfers[2] = { };
> + u8 *buf = sbtsi_i3c_buf(data);
> + int ret;
> +
> + buf[0] = reg;
> + /* Add Register data to read/write */
> + xfers[0].rnw = false;
> + xfers[0].len = 1;
> + xfers[0].data.out = &buf[0];
> +
> + xfers[1].rnw = true;
> + xfers[1].len = 1;
> + xfers[1].data.in = &buf[1];
[Severity: High]
Does this code risk memory corruption or unsafe DMA operations?
If the underlying I3C host controller processes these transfers using DMA,
mapping &buf[1] as DMA_FROM_DEVICE requires a cache invalidation upon
unmap.
This invalidation could silently destroy concurrent CPU writes to
variables sharing the same cacheline, such as the kref in struct
sbtsi_data.
Additionally, passing adjacent 1-byte buffers for overlapping
DMA_TO_DEVICE and DMA_FROM_DEVICE mappings in a single transaction
violates the Linux DMA API.
> +
> + ret = i3c_device_do_xfers(data->i3cdev, xfers, 2, I3C_SDR);
[ ... ]
> diff --git a/drivers/misc/amd-sbi/tsi-core.h b/drivers/misc/amd-sbi/tsi-core.h
> new file mode 100644
> index 0000000000000..7dde040caf308
> --- /dev/null
> +++ b/drivers/misc/amd-sbi/tsi-core.h
> @@ -0,0 +1,23 @@
[ ... ]
> +struct sbtsi_i3c_priv {
> + struct sbtsi_data data;
> + u8 buf[2];
[Severity: High]
Is it safe to define this buffer without explicit cacheline alignment?
Without ____cacheline_aligned, buf shares a CPU cacheline with adjacent
fields in struct sbtsi_data. As this buffer is used in I3C transfers in
sbtsi_i3c_read() and sbtsi_i3c_write(), this could lead to cacheline
sharing issues during DMA.
> +};
> +
> +#endif /* _LINUX_TSI_CORE_H_ */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260622135821.2190260-1-Akshay.Gupta@amd.com?part=5
next prev parent reply other threads:[~2026-06-22 14:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 13:58 [PATCH v3 0/8] misc: amd-sbi: Refactor SBTSI driver with I3C support and ioctl interface Akshay Gupta
2026-06-22 13:58 ` [PATCH v3 1/8] hwmon/misc: amd-sbi: Move core sbtsi support from hwmon to misc Akshay Gupta
2026-06-22 14:12 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 2/8] hwmon: sbtsi_temp: Refactor temperature register access into helpers Akshay Gupta
2026-06-22 14:11 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 3/8] hwmon/misc: amd-sbi: Move sbtsi register transfer to core abstraction Akshay Gupta
2026-06-22 14:18 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 4/8] misc: amd-sbi: Consolidate Common SBTSI Probe Path for I2C and I3C Akshay Gupta
2026-06-22 14:11 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 5/8] misc: amd-sbi: Add support for SB-TSI over I3C Akshay Gupta
2026-06-22 14:19 ` sashiko-bot [this message]
2026-06-22 13:58 ` [PATCH v3 6/8] misc: amd-sbi: Add SBTSI ioctl register transfer interface Akshay Gupta
2026-06-22 14:15 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 7/8] hwmon: Add mutex protecting for sbtsi read/write through hwmon Akshay Gupta
2026-06-22 14:17 ` sashiko-bot
2026-06-22 13:58 ` [PATCH v3 8/8] docs: misc: amd-sbi: Document SBTSI userspace interface Akshay Gupta
2026-06-22 14:12 ` sashiko-bot
2026-06-22 16:57 ` Randy Dunlap
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=20260622141918.086C11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Akshay.Gupta@amd.com \
--cc=linux-hwmon@vger.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