From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Javier Carrasco <javier.carrasco.cruz@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v3 00/11] hwmon: chipcap2: various bug fixes
Date: Wed, 14 Oct 2026 19:33:59 +0200 [thread overview]
Message-ID: <20261014-chipcap2_locks-v3-0-27ebfc2c5b9e@gmail.com> (raw)
The original issue (race condition for the alarms) was found by Sashiko[1]
when an unrelated patch affected chipcap2.c. The issue is real as the
access to the variables is not protected by any locking mechanism
although 2 different sources (threaded interrupts and sysfs) could
modify them.
In further iterations Sashiko found new issues[2] that have been added to
the series:
- Fix be16 data handling.
- Defer probe when the IRQs are not available yet.
- IRQ teardown ordering: split the current implementation to provide the
available interrupts before registering the hwmon device, and register
the IRQs after the hwmon device has been registered.
- Disable the device after the hwmon device has been unregistered.
- Enable IRQ processing when the regulator is already enabled.
- Balance regulator counter.
- Do not discard the pending alarms when the device is disabled.
- Reset the completion to account for counter > 1.
- IRQ serialization and synchronization.
The last item required a dedicated mutex because the hwmon_lock was not
suitable to close the gaps where an interrupt might go unnoticed because
there is some dependency between the data read and the interrupt
generation, and also in the completion mechanism. I went through the
different alternatives with a combination of local Sashiko and a second
AI agent, and discarded some complex solutions to close gaps that are
more theoretical than practical e.g. the interrupt was fired, but it did
not reach the controller due to nested GPIO expanders. I added the
Assisted-by: tags to those patches accordingly, although it seems that
this requirement will soon vanish.
Additionally, a harmless off-by-one in a for loop has been fixed to save
~80 ms after the last failed command retry, and the error reporting has
been fixed to show the right issue. These two ones have not been tagged
for stable as they are only meant to improve reaction time and logging
inaccuracies after a command fails. The deferred probe does not have the
stable tag as it is just a reaction if interrupts were provided but
still not available. Of course, I can add the tags to all patches
if required.
The fixes have been validated on real hardware with an Amphenol
ChipCap 2 CC2D23S sensor.
[1] Link: https://lore.kernel.org/linux-hwmon/20260625162114.417EA1F000E9@smtp.kernel.org/
[2] Link: https://lore.kernel.org/linux-hwmon/20260821093706.D1EB11F000E9@smtp.kernel.org/
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Changes in v3:
- Use a dedicated mutex instead of the hwmon subsystem lock to serialize
the access to the alarm indicators, which no longer blocks the alarm
handlers behind a sysfs read.
- New patch: do not discard the pending alarms on disable.
- New patch: synchronize the ready IRQ state.
- Register the data ready IRQ before registering the hwmon device (its
handler does not use hwmon).
- Split the fixes into one patch per issue.
- Drop the patch to fix the channels in the humidity alarm
notifications, which is already applied.
- Link to v2: https://lore.kernel.org/r/20260823-chipcap2_locks-v2-0-6a26c8e9e2fc@gmail.com
Changes in v2:
- Add fixes to the new issues reported by Sashiko.
- Use hwmon subsystem lock.
- Link to v1: https://lore.kernel.org/r/20260821-chipcap2_locks-v1-1-1d8ccabfc1b2@gmail.com
---
Javier Carrasco (11):
hwmon: chipcap2: fix command error diagnostics
hwmon: chipcap2: fix off-by-one in command mode retry loop
hwmon: chipcap2: fix be16 handling
hwmon: chipcap2: defer probe when IRQs are unavailable
hwmon: chipcap2: fix IRQ teardown ordering
hwmon: chipcap2: disable device after hwmon teardown
hwmon: chipcap2: enable IRQ processing when regulator is already enabled
hwmon: chipcap2: balance regulator state
hwmon: chipcap2: do not discard pending alarms on disable
hwmon: chipcap2: serialize access to the alarm indicators
hwmon: chipcap2: synchronize ready IRQ state
drivers/hwmon/chipcap2.c | 192 +++++++++++++++++++++++++++++++----------------
1 file changed, 128 insertions(+), 64 deletions(-)
---
base-commit: 3857c2fe5449541e24afc5efdb0f81a8a8f9a3a0
change-id: 20260820-chipcap2_locks-c01013a24a0c
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
next reply other threads:[~2026-10-14 17:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:33 Javier Carrasco [this message]
2026-10-14 17:34 ` [PATCH v3 01/11] hwmon: chipcap2: fix command error diagnostics Javier Carrasco
2026-10-14 17:50 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 02/11] hwmon: chipcap2: fix off-by-one in command mode retry loop Javier Carrasco
2026-10-14 18:01 ` sashiko-bot
2026-10-14 20:11 ` Javier Carrasco
2026-10-14 17:34 ` [PATCH v3 03/11] hwmon: chipcap2: fix be16 handling Javier Carrasco
2026-10-14 18:08 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 04/11] hwmon: chipcap2: defer probe when IRQs are unavailable Javier Carrasco
2026-10-14 18:14 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 05/11] hwmon: chipcap2: fix IRQ teardown ordering Javier Carrasco
2026-10-14 18:22 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 06/11] hwmon: chipcap2: disable device after hwmon teardown Javier Carrasco
2026-10-14 18:34 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 07/11] hwmon: chipcap2: enable IRQ processing when regulator is already enabled Javier Carrasco
2026-10-14 18:36 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 08/11] hwmon: chipcap2: balance regulator state Javier Carrasco
2026-10-14 18:38 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 09/11] hwmon: chipcap2: do not discard pending alarms on disable Javier Carrasco
2026-10-14 18:38 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 10/11] hwmon: chipcap2: serialize access to the alarm indicators Javier Carrasco
2026-10-14 18:35 ` sashiko-bot
2026-10-14 17:34 ` [PATCH v3 11/11] hwmon: chipcap2: synchronize ready IRQ state Javier Carrasco
2026-10-14 18:41 ` 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=20261014-chipcap2_locks-v3-0-27ebfc2c5b9e@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=stable@vger.kernel.org \
/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.