Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andy Chung" <Andy.Chung@amd.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	linux-hwmon@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 4/4] hwmon: (kb9002) Add documentation
Date: Tue, 14 Jul 2026 08:34:44 +0000	[thread overview]
Message-ID: <20260714083445.212131F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-kb9002-upstream-v1-4-8fd2f0b135d8@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The driver uses a private mutex instead of `hwmon_lock()`, violating hwmon core guidelines.
- [Medium] The driver unconditionally requires `I2C_FUNC_I2C`, permanently breaking support for SMBus-only controllers.
--

--- Patch [4]: [PATCH 4/4] hwmon: (kb9002) Add documentation ---
commit 929a2de2e63d6d8333f36707bf6da054f63aeab6
Author: Andy Chung <Andy.Chung@amd.com>

hwmon: (kb9002) Add driver for Kandou KB9002 retimer

The Kandou KB9002 is an 8-lane PCIe 5.0 retimer that exposes an SMBus
target with mandatory PEC. Add a hwmon driver reporting the firmware
aggregated maximum die temperature as temp1_input, with the firmware
version and boot status under debugfs.

> diff --git a/drivers/hwmon/kb9002.c b/drivers/hwmon/kb9002.c
> new file mode 100644
> index 0000000000000..2a3dffe52a62f
> --- /dev/null
> +++ b/drivers/hwmon/kb9002.c
> @@ -0,0 +1,473 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later

[ ... ]

> +struct kb9002_data {
> +	struct i2c_client *client;
> +	struct mutex lock;	/* serialises register accesses */
> +};

[Severity: Medium]
Does using a private mutex instead of hwmon_lock() violate the hwmon
subsystem guidelines? The guidelines mandate using hwmon_lock() and
hwmon_unlock() to serialize attributes registered outside the core,
such as debugfs, with sysfs and thermal operations. By discarding the
hwmon_dev pointer returned during registration, the driver cannot
correctly call hwmon_lock().

[ ... ]

> +static int kb9002_fw_read(struct kb9002_data *data, u16 reg, u32 *val)
> +{
> +	struct i2c_client *client = data->client;
> +	u8 addr[2];
> +	u8 rbuf[I2C_SMBUS_BLOCK_MAX];
> +	int ret;
> +
> +	put_unaligned_le16(reg, addr);
> +
> +	mutex_lock(&data->lock);

[Severity: Medium]
This isn't a bug in the locking logic itself, but shouldn't this code use
hwmon_lock() instead of the private lock to serialize I2C/SMBus accesses?

[ ... ]

> +static int kb9002_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct kb9002_data *data;
> +	struct device *hwmon_dev;
> +	u32 vid;
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter,
> +				     I2C_FUNC_SMBUS_BLOCK_DATA |
> +				     I2C_FUNC_SMBUS_PEC | I2C_FUNC_I2C))
> +		return -ENODEV;

[Severity: Medium]
Does unconditionally requiring I2C_FUNC_I2C prevent the driver from binding
on SMBus-only controllers?

Raw I2C functionality appears to be used only in a fallback path
(kb9002_enable_smbus_target()) to switch the device out of raw-I2C mode.
By mandating it upfront, the driver unnecessarily denies service on
legitimate SMBus-only systems where the hardware is already configured
for SMBus mode.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-kb9002-upstream-v1-0-8fd2f0b135d8@amd.com?part=4

      reply	other threads:[~2026-07-14  8:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  8:19 [PATCH 0/4] hwmon: Add Kandou KB9002 PCIe retimer driver Andy Chung via B4 Relay
2026-07-14  8:19 ` [PATCH 1/4] dt-bindings: Add vendor prefix for Kandou Andy Chung via B4 Relay
2026-07-14  8:23   ` sashiko-bot
2026-07-14  8:19 ` [PATCH 2/4] dt-bindings: hwmon: Add Kandou KB9002 Andy Chung via B4 Relay
2026-07-14  8:32   ` sashiko-bot
2026-07-14  8:19 ` [PATCH 3/4] hwmon: (kb9002) Add driver for Kandou KB9002 retimer Andy Chung via B4 Relay
2026-07-14  8:33   ` sashiko-bot
2026-07-14  8:19 ` [PATCH 4/4] hwmon: (kb9002) Add documentation Andy Chung via B4 Relay
2026-07-14  8:34   ` sashiko-bot [this message]

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=20260714083445.212131F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Andy.Chung@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@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