All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andy Chung" <Andy.Chung@amd.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 3/4] hwmon: (kb9002) Add driver for Kandou KB9002 retimer
Date: Tue, 14 Jul 2026 08:33:11 +0000	[thread overview]
Message-ID: <20260714083312.156CB1F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260714-kb9002-upstream-v1-3-8fd2f0b135d8@amd.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] The driver introduces its own mutex for register accesses instead of using the standard hwmon lock, violating subsystem guidelines.
- [Medium] Probe loop retries repeatedly on fatal I2C read failures, causing extreme bus delays on missing devices.
- [Medium] Unconditional requirement for I2C_FUNC_I2C prevents driver from loading on SMBus-only adapters.
- [Medium] Missing suspend/resume handlers will cause devices strapped to raw I2C to fail after system resume.
--

--- Patch [3]: [PATCH 3/4] hwmon: (kb9002) Add driver for Kandou KB9002 retimer ---
commit 929a2de2e63d6d8333f36707bf6da054f63aeab6
Author: Andy Chung <Andy.Chung@amd.com>
Subject: 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. This patch adds 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

[ ... ]

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

[Severity: Medium]
According to the hwmon subsystem guidelines, drivers must use hwmon_lock()
and hwmon_unlock() to serialize attributes registered by other means, such
as the debugfs entries.

Is it appropriate to introduce a custom mutex here instead of saving the
hwmon_dev pointer during kb9002_probe() and utilizing the standard hwmon lock
in functions like kb9002_fw_read()?

[ ... ]

> +static int kb9002_read_revid(struct i2c_client *client, u32 *revid)
> +{
> +	u8 dummy;
> +	int ret;
> +	int i;
> +
> +	for (i = 0; i < KB9002_REVID_READ_RETRIES; i++) {
> +		ret = kb9002_i2c_read(client, KB9002_HW_REG_REVID, revid);
> +		if (!ret && (*revid >> 24) != 0xff)
> +			return 0;
> +		/* Drain one byte from the chip to re-align the I2C FIFO. */
> +		i2c_master_recv(client, &dummy, 1);
> +	}
> +
> +	return ret ? ret : -EIO;
> +}

[Severity: Medium]
If the initial I2C read fails with a hard error, such as when the device is
missing and kb9002_i2c_read() returns a negative error code, this loop does
not short-circuit.

Could this needlessly loop and execute a failing i2c_master_recv() on every
iteration, causing unnecessary bus traffic and probe delays?

[ ... ]

> +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]
This check unconditionally requires I2C_FUNC_I2C.

Could this prevent the driver from loading on SMBus-only adapters even if
the retimer is properly strapped to SMBus mode and does not require the raw
I2C fallback?

Would it be better to defer checking for raw I2C functionality to
kb9002_enable_smbus_target() where it is actually needed?

[ ... ]

> +static struct i2c_driver kb9002_driver = {
> +	.driver = {
> +		.name = KB9002_DEV_NAME,
> +		.of_match_table = kb9002_of_match,
> +	},
> +	.probe = kb9002_probe,
> +	.id_table = kb9002_id,
> +};
> +module_i2c_driver(kb9002_driver);

[Severity: Medium]
If the retimer is strapped to raw I2C mode, the driver switches it to SMBus
mode during probe.

If the device loses power during system suspend and defaults back to raw
I2C mode on wake, will all subsequent SMBus accesses by the driver fail?

Does this driver need pm_ops with a resume handler to restore the device
state after suspend?

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

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

Thread overview: 14+ 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 ` Andy Chung
2026-07-14  8:19 ` [PATCH 1/4] dt-bindings: Add vendor prefix for Kandou Andy Chung via B4 Relay
2026-07-14  8:19   ` Andy Chung
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:19   ` Andy Chung
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:19   ` Andy Chung
2026-07-14  8:33   ` sashiko-bot [this message]
2026-07-14  8:19 ` [PATCH 4/4] hwmon: (kb9002) Add documentation Andy Chung via B4 Relay
2026-07-14  8:19   ` Andy Chung
2026-07-14  8:34   ` 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=20260714083312.156CB1F00A3F@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 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.