From: sashiko-bot@kernel.org
To: "Jie Gu" <jie.gu@leica-geosystems.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 1/2] leds: tps6131x: Cancel torch refresh on flash mode switch
Date: Fri, 20 Nov 2026 08:09:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-224685@kernel.org> (raw)
In-Reply-To: <20261120075859.731257-2-jie.gu@leica-geosystems.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] leds: tps6131x: torch_refresh_work race with
tps6131x_brightness_set()
--
commit 7abce202322d69429cb0363b0f5444e8321b3409
Author: Jie Gu <jie.gu@leica-geosystems.com.cn>
leds: tps6131x: Cancel torch refresh on flash mode switch
This commit cancels pending torch_refresh_work before switching the
TPS6131X mode in tps6131x_strobe_set() and
tps6131x_flash_external_strobe_set().
> diff --git a/drivers/leds/flash/leds-tps6131x.c b/drivers/leds/flash/leds-tps6131x.c
> index 7f2c3895e6e98..704c3e7dfcda0 100644
> --- a/drivers/leds/flash/leds-tps6131x.c
> +++ b/drivers/leds/flash/leds-tps6131x.c
> @@ -378,6 +378,7 @@ static int tps6131x_strobe_set(struct led_classdev_flash *fled_cdev, bool state)
> struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
> int ret;
>
> + cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
> guard(mutex)(&tps6131x->lock);
>
> ret = tps6131x_set_mode(tps6131x, state ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
> @@ -697,6 +698,7 @@ static int tps6131x_flash_external_strobe_set(struct v4l2_flash *v4l2_flash, boo
> struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
> struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
>
> + cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
> guard(mutex)(&tps6131x->lock);
>
> return tps6131x_set_mode(tps6131x, enable ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
[Severity: Medium]
Can an in-flight tps6131x_brightness_set() still re-arm
torch_refresh_work after cancel_delayed_work_sync() returns in
tps6131x_strobe_set() or tps6131x_flash_external_strobe_set()?
tps6131x_brightness_set() runs asynchronously on leds_wq via
led_cdev->set_brightness_work without holding led_cdev->led_access, and
neither flash_strobe_store() nor v4l2_flash_open() flushes
set_brightness_work:
kworker (leds_wq) CPU1
set_brightness_delayed()
tps6131x_brightness_set()
cancel_delayed_work_sync(...)
guard(mutex)(&tps6131x->lock)
regmap_update_bits(...)
tps6131x_strobe_set()
cancel_delayed_work_sync(...)
guard(mutex)(&tps6131x->lock)
schedule_delayed_work(...)
/* unlock tps6131x->lock */
tps6131x_set_mode(...,
TPS6131X_MODE_FLASH, ...)
/* unlock tps6131x->lock */
tps6131x_torch_refresh_handler()
tps6131x_set_mode(...,
TPS6131X_MODE_TORCH, true) <-- forces device back into torch mode
When torch_refresh_work fires later, tps6131x_torch_refresh_handler()
unconditionally writes TPS6131X_MODE_TORCH and re-arms itself.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120075859.731257-1-jie.gu@leica-geosystems.com?part=1
next prev parent reply other threads:[~2026-11-20 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:58 [PATCH v2 0/2] leds: tps6131x: Fix torch-to-flash transitions Jie Gu
2026-11-20 7:58 ` [PATCH v2 1/2] leds: tps6131x: Cancel torch refresh on flash mode switch Jie Gu
2026-11-20 8:09 ` sashiko-bot [this message]
2026-11-20 7:58 ` [PATCH v2 2/2] leds: tps6131x: Clear torch brightness cache on flash takeover Jie Gu
2026-11-20 8:09 ` 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=sashiko-outbox-224685@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jie.gu@leica-geosystems.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.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