Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anvesh Jain P" <anvesh.p@oss.qualcomm.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 6/8] platform: arm64: qcom-hamoa-ec: Retry I2C transfers on NACK
Date: Tue, 28 Jul 2026 18:26:42 +0000	[thread overview]
Message-ID: <20260728182642.AFF0E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260728-ec_add_more_commands-v1-6-771abd65ee1a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch adds retry logic for EC NACKs to `qcom_ec_write()` and `qcom_ec_read()`, but fails to add equivalent retries for the numerous `i2c_smbus_*` calls made throughout the driver, leaving them vulnerable to the exact same failure.
- [High] Race condition during device removal where cooling device callbacks can execute after debug mode is disabled.
- [Low] Initialized arrays of type `struct i2c_device_id` must use named initializers rather than positional initializers.
--

--- Patch [6]: [PATCH 6/8] platform: arm64: qcom-hamoa-ec: Retry I2C transfers on NACK ---
commit 42a41f4860b9d5a24932df8c69069cb7fd89b4d1
Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>

platform: arm64: qcom-hamoa-ec: Retry I2C transfers on NACK

The patch adds bounded retry logic to qcom_ec_write() and qcom_ec_read()
to handle EC firmware NACKs that occur during busy windows right after
boot or during SCI event bursts.

> The EC firmware NACKs the bus instead of clock-stretching while it is
> busy servicing internal work (e.g. right after boot, when it is also
> emitting a burst of SCI events). A transfer issued in that window fails
> with -ENXIO even though the EC is otherwise healthy.

[Severity: High]
This isn't a bug introduced by this patch, but since the EC NACKs the bus
right after boot and during SCI event bursts, will the un-retried i2c_smbus
calls also fail?

For example, qcom_ec_sci_evt_control() is called directly during probe and
uses i2c_smbus_write_byte_data() without retry logic:

drivers/platform/arm64/qcom-hamoa-ec.c:qcom_ec_sci_evt_control() {
    ...
    ret = i2c_smbus_write_byte_data(client, EC_SCI_EVT_CONTROL_CMD, enable ? 1 : 0);
    ...
}

Similarly, qcom_ec_irq() reads events during an SCI burst using
i2c_smbus_read_byte_data():

drivers/platform/arm64/qcom-hamoa-ec.c:qcom_ec_irq() {
    ...
    val = i2c_smbus_read_byte_data(ec->client, EC_SCI_EVT_READ_CMD);
    ...
}

Should these SMBus calls also be updated to retry on NACK?

> diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
> index a420a180a1948..122ae27c2b483 100644
> --- a/drivers/platform/arm64/qcom-hamoa-ec.c
> +++ b/drivers/platform/arm64/qcom-hamoa-ec.c

[ ... ]

> @@ -281,11 +302,18 @@ static int qcom_ec_read(struct qcom_ec *ec, u8 cmd, const u8 *subcmd,
>  	msgs[1].len   = resp_len;
>  	msgs[1].buf   = read_buf;
>  
> -	ret = i2c_transfer(client->adapter, msgs, 2);
> -	if (ret != 2) {
> -		ret = ret < 0 ? ret : -EIO;
> -		goto out;
> +	for (int i = 0; i < EC_I2C_NACK_MAX_ATTEMPTS; i++) {
> +		ret = i2c_transfer(client->adapter, msgs, 2);
> +		ret = ret == 2 ? 0 : (ret < 0 ? ret : -EIO);
> +		if (ret != -ENXIO || i == EC_I2C_NACK_MAX_ATTEMPTS - 1)
> +			break;
> +
> +		dev_dbg(&client->dev,
> +			"EC busy (NACK), retrying read of cmd 0x%02x\n", cmd);
> +		msleep(EC_I2C_NACK_RETRY_DELAY_MS);
>  	}
> +	if (ret)
> +		goto out;
>  
>  	if (read_buf[0] == 0 || read_buf[0] == 0xff) {
>  		ret = -EOPNOTSUPP;

[Severity: High]
This is a pre-existing issue, but does the cooling device teardown have a
race condition that could leave the fan stuck in debug (manual PWM) mode?

In qcom_ec_remove(), the driver turns off debug mode:

drivers/platform/arm64/qcom-hamoa-ec.c:qcom_ec_remove() {
    ...
    qcom_ec_fan_debug_mode_off(ec_cdev);
    ...
}

However, since the thermal cooling device is managed by devres, it remains
registered until after remove() completes. Can the thermal core invoke
qcom_ec_fan_set_cur_state() during this window, which re-enables debug mode?

drivers/platform/arm64/qcom-hamoa-ec.c:qcom_ec_fan_set_cur_state() {
    ...
    ret = qcom_ec_fan_write_pwm(ec_cdev, state);
    ...
}

[Severity: Low]
This is a pre-existing issue, but does qcom_ec_i2c_id_table violate the I2C
subsystem API guidelines by using positional initializers?

drivers/platform/arm64/qcom-hamoa-ec.c:
static const struct i2c_device_id qcom_ec_i2c_id_table[] = {
	{ "qcom-hamoa-ec", },
	{}
};

The subsystem guidelines state that initialized arrays of type
struct i2c_device_id must use named initializers.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728-ec_add_more_commands-v1-0-771abd65ee1a@oss.qualcomm.com?part=6

  reply	other threads:[~2026-07-28 18:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 17:44 [PATCH 0/8] Extend Qualcomm reference device EC driver with fan LUT, profile and SoC Tj support Anvesh Jain P
2026-07-28 17:44 ` [PATCH 1/8] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add qcom,tsens Anvesh Jain P
2026-07-28 17:54   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 2/8] platform: arm64: qcom-hamoa-ec: Add SoC junction temperature reporting Anvesh Jain P
2026-07-28 18:02   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 3/8] platform: arm64: qcom-hamoa-ec: Switch fan profile based on power supply state Anvesh Jain P
2026-07-28 18:05   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 4/8] platform: arm64: qcom-hamoa-ec: Add fan RPM query and LUT calibration Anvesh Jain P
2026-07-28 18:15   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 5/8] platform: arm64: qcom-hamoa-ec: Verify required I2C adapter functionality Anvesh Jain P
2026-07-28 18:14   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 6/8] platform: arm64: qcom-hamoa-ec: Retry I2C transfers on NACK Anvesh Jain P
2026-07-28 18:26   ` sashiko-bot [this message]
2026-07-28 17:44 ` [PATCH 7/8] arm64: dts: qcom: x1p42100-crd: Add qcom,tsens for EC fan thermal management Anvesh Jain P
2026-07-28 18:26   ` sashiko-bot
2026-07-28 17:44 ` [PATCH 8/8] arm64: dts: qcom: x1e80100-crd: " Anvesh Jain P
2026-07-28 18:36   ` 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=20260728182642.AFF0E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anvesh.p@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@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