From: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 4/8] platform: arm64: qcom-hamoa-ec: Add fan RPM query and LUT calibration
Date: Wed, 5 Aug 2026 18:45:56 +0530 [thread overview]
Message-ID: <6b59bf0d-c98c-4004-a117-7f5dde20d625@oss.qualcomm.com> (raw)
In-Reply-To: <20260728181543.AB3131F000E9@smtp.kernel.org>
On 7/28/2026 11:45 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Race condition between suspend/remove paths and `fan_calib_work_fn` can cause a 10 to 20-second hang.
> - [High] `psy_work` can be queued and executed while the device is in suspend, leading to I2C transfer failures.
> --
>
> --- Patch [4]: [PATCH 4/8] platform: arm64: qcom-hamoa-ec: Add fan RPM query and LUT calibration ---
> commit e49733d2c63b28585a159eb3f465f9613c0aec7d
> Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
>
> platform: arm64: qcom-hamoa-ec: Add fan RPM query and LUT calibration
>
> This commit adds EC command definitions and handler functions for querying
> fan RPM and programming per-fan LUTs mapping SoC temperature to target RPM.
> It implements a runtime calibration work item to determine the maximum RPM,
> and programs the LUT once calibration finishes and upon power-supply changes.
>
>> diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
>> index f6ff77d4e8f69..d0c45d9970eee 100644
>> --- a/drivers/platform/arm64/qcom-hamoa-ec.c
>> +++ b/drivers/platform/arm64/qcom-hamoa-ec.c
> [ ... ]
>> @@ -665,6 +1097,49 @@ static void qcom_ec_soc_tj_work_fn(struct work_struct *work)
>> queue_delayed_work(system_percpu_wq, &ec->soc_tj_work, EC_SOC_TJ_TEMP_POLL_JIFFIES);
>> }
>>
>> +static void qcom_ec_fan_calib_work_fn(struct work_struct *work)
>> +{
>> + struct qcom_ec *ec = container_of(work, struct qcom_ec, fan_calib_work);
>> + struct device *dev = &ec->client->dev;
>> + int i, ret;
>> +
>> + reinit_completion(&ec->calib_abort);
>
> [Severity: High]
> Can this race with the suspend or remove paths and cause a long delay?
>
> If qcom_ec_fan_calib_work_fn() begins executing concurrently with
> qcom_ec_suspend() or qcom_ec_remove(), the suspend/remove thread calls
> complete_all(&ec->calib_abort) to signal the worker to abort.
>
> However, if the worker executes reinit_completion() immediately after the
> suspend thread's complete_all(), the abort signal is erased. The suspend
> thread then blocks in cancel_work_sync(), waiting for the worker to finish,
> and the worker will block in wait_for_completion_interruptible_timeout()
> for the full timeout per fan (up to 10-20 seconds total).
>
I'll guard against this, probably by checking completion state before
reinit or using a separate abort flag instead of relying on
reinit_completion() alone.
>> +
>> + mutex_lock(&ec->io_lock);
>> + ec->calibrating = true;
>> + mutex_unlock(&ec->io_lock);
>> +
> [ ... ]
>> @@ -690,7 +1169,16 @@ static int qcom_ec_suspend(struct device *dev)
>> struct qcom_ec *ec = i2c_get_clientdata(client);
>> int ret;
>>
>> - disable_delayed_work_sync(&ec->soc_tj_work);
>> + if (ec->lut_cfg && ec->thermal_cap.fan_cnt) {
>> + complete_all(&ec->calib_abort);
>> + cancel_work_sync(&ec->fan_calib_work);
>> + }
>> +
>> + if (ec->lut_cfg)
>> + cancel_work_sync(&ec->psy_work);
>
> [Severity: High]
> Does this allow psy_work to be re-queued and executed during suspend?
>
> While cancel_work_sync() stops currently pending work, the system-wide
> power supply notifier qcom_ec_psy_notifier() is not unregistered during
> suspend.
>
> If a power supply event occurs during the suspend process after
> cancel_work_sync() has run, the notifier can immediately queue psy_work
> back to the non-freezable system_long_wq.
>
> This could cause the work to run and attempt I2C transfers while the
> I2C controller is suspended or the EC is in Modern Standby, potentially
> leading to bus lockups or suspend failures.
>
I'll switch that to disable_work_sync() so the notifier can't requeue it
mid-suspend.
>> +
>> + if (ec->lut_cfg && ec->lut_cfg->send_soc_tj)
>> + disable_delayed_work_sync(&ec->soc_tj_work);
>>
>> mutex_lock(&ec->io_lock);
>> ret = i2c_smbus_write_byte_data(client, EC_MODERN_STANDBY_CMD,
>
--
Best Regards,
Anvesh
next prev parent reply other threads:[~2026-08-05 13:16 UTC|newest]
Thread overview: 47+ 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-08-05 9:54 ` Anvesh Jain P
2026-07-29 11:08 ` Krzysztof Kozlowski
2026-07-29 11:54 ` Anvesh Jain P
2026-07-29 12:32 ` Krzysztof Kozlowski
2026-07-29 13:00 ` Anvesh Jain P
2026-07-29 11:13 ` Konrad Dybcio
2026-07-29 12:13 ` Anvesh Jain P
2026-07-30 17:11 ` Konrad Dybcio
2026-07-31 5:55 ` Anvesh Jain P
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-08-05 10:40 ` Anvesh Jain P
2026-07-29 10:59 ` Konrad Dybcio
2026-07-29 13:03 ` Anvesh Jain P
2026-07-30 17:04 ` Konrad Dybcio
2026-07-31 5:47 ` Anvesh Jain P
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-08-05 13:12 ` Anvesh Jain P
2026-07-29 11:02 ` Konrad Dybcio
2026-07-30 6:21 ` Anvesh Jain P
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-08-05 13:15 ` Anvesh Jain P [this message]
2026-07-29 11:07 ` Konrad Dybcio
2026-07-30 6:35 ` Anvesh Jain P
2026-07-30 17:08 ` Konrad Dybcio
2026-07-31 6:25 ` Anvesh Jain P
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-08-05 14:20 ` Anvesh Jain P
2026-07-29 11:08 ` Konrad Dybcio
2026-07-30 6:37 ` Anvesh Jain P
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
2026-08-05 15:10 ` Anvesh Jain P
2026-07-29 11:11 ` Konrad Dybcio
2026-07-30 6:40 ` Anvesh Jain P
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-08-06 4:29 ` Anvesh Jain P
2026-07-28 17:44 ` [PATCH 8/8] arm64: dts: qcom: x1e80100-crd: " Anvesh Jain P
2026-07-28 18:36 ` sashiko-bot
2026-08-06 4:37 ` Anvesh Jain P
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=6b59bf0d-c98c-4004-a117-7f5dde20d625@oss.qualcomm.com \
--to=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