All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Rong Zhang <i@rong.moe>, linux-leds@vger.kernel.org
Subject: Re: [PATCH v4 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface
Date: Tue, 11 Aug 2026 20:13:38 +0100	[thread overview]
Message-ID: <20260811191338.GC1072730@google.com> (raw)
In-Reply-To: <20260802173152.4F94A1F00A3D@smtp.kernel.org>

On Sun, 02 Aug 2026, sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The `led_trigger_notify_hw_control_changed()` API performs sleepable operations without an internal deferral mechanism, creating a trap for driver authors who might call it directly from hardware interrupt handlers.

Please review, explain or fix the Sashiko review(s).

If this is a set, this request includes the other patches too.

> --
> 
> --- Patch [9]: [PATCH v4 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface ---
> commit 21d51858b3771f2be6da6b9704657f9342549cfc
> Author: Rong Zhang <i@rong.moe>
> 
> leds: trigger: Add led_trigger_notify_hw_control_changed() interface
> 
> This commit introduces a new interface, led_trigger_notify_hw_control_changed(),
> allowing LED drivers to notify the LED core about autonomous hardware
> control transitions. The core will then transition the trigger between
> "none" and the device's private trigger.
> 
> > diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> > index 64bc95d0bfeb7..2db9fcd1350b8 100644
> > --- a/drivers/leds/led-triggers.c
> > +++ b/drivers/leds/led-triggers.c
> [ ... ]
> > @@ -471,6 +492,63 @@ int devm_led_trigger_register(struct device *dev,
> [ ... ]
> > +void led_trigger_notify_hw_control_changed(struct led_classdev *led_cdev, bool activate)
> > +{
> > +	struct led_trigger *trig;
> > +
> > +	/* Restricted to private triggers. */
> > +	if (WARN_ON(!(led_cdev->flags & LED_TRIG_HW_CHANGED) ||
> > +		    !led_cdev->hw_control_trigger || !led_cdev->trigger_type))
> > +		return;
> > +
> > +	scoped_guard(rwsem_read, &triggers_list_lock) {
> 
> [Severity: Medium]
> Will driver authors likely call this API directly from hardware interrupt
> handlers when an autonomous hardware control transition occurs?
> 
> This function acquires a sleepable rw_semaphore (triggers_list_lock) and
> can subsequently call __led_trigger_set() which uses synchronize_rcu().
> Calling this from an atomic context like a hardirq handler would trigger a
> 'sleeping in atomic context' bug or a deadlock.
> 
> Since there is no internal workqueue deferral mechanism (unlike
> led_trigger_event()) and no might_sleep() annotation, could this become a
> trap for driver authors?
> 
> > +		list_for_each_entry(trig, &trigger_list, next_trig) {
> > +			if (trig->trigger_type == led_cdev->trigger_type &&
> > +			    !strcmp(trig->name, led_cdev->hw_control_trigger)) {
> > +				guard(rwsem_write)(&led_cdev->trigger_lock);
> > +
> > +				led_trigger_do_hw_control_transition(led_cdev, activate, trig);
> > +				return;
> > +			}
> > +		}
> > +	}
> > +
> > +	dev_err(led_cdev->dev,
> > +		"%s() is called, but the private trigger (%s) is not properly registered\n",
> > +		__func__, led_cdev->hw_control_trigger);
> > +}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260802-leds-trigger-hw-changed-v4-0-f97e2ca976fe@rong.moe?part=9
> 

-- 
Lee Jones

  reply	other threads:[~2026-08-11 19:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 17:26 [PATCH v4 00/12] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-08-01 17:26 ` [PATCH v4 01/12] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 02/12] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 03/12] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 04/12] leds: cros_ec: Implement offloaded() trigger callback Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 06/12] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 07/12] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 08/12] leds: trigger: Do not attach trigger to a removing LED Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-11 19:13     ` Lee Jones [this message]
2026-08-01 17:26 ` [PATCH v4 10/12] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 11/12] platform/x86: ideapad-laptop: Serialize keyboard backlight notifications Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 12/12] platform/x86: ideapad-laptop: Fully support auto keyboard backlight Rong Zhang
2026-08-02 17:31   ` 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=20260811191338.GC1072730@google.com \
    --to=lee@kernel.org \
    --cc=i@rong.moe \
    --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 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.