From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v8 02/14] backlight: add kernel-internal backlight API
Date: Tue, 08 Sep 2026 04:52:32 +0000 [thread overview]
Message-ID: <20260908045232.9F77B1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908044035.62093-3-mario.limonciello@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] backlight_notify_brightness() is called inside backlight_update_status() while bd->ops_lock is held, creating an AB-BA deadlock risk with DRM listeners.
- [Medium] Hardware/hotkey-driven brightness changes reported via backlight_force_update() bypass backlight_notify_brightness(), causing in-kernel listeners to lose sync with the actual state.
--
commit 56d45c464432e9b84ad73dff6ec5f6ddda9af544
Author: Mario Limonciello <mario.limonciello@amd.com>
backlight: add kernel-internal backlight API
This commit adds internal backlight helpers allowing DRM drivers to provide
an interface for user-space to control the backlight via DRM connector
properties. It introduces a brightness-changed notification and a per-device
takeover count to inhibit legacy sysfs writes while a luminance-aware DRM
client is in control.
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 4401f6294ccc8..1c700c1e77c3f 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
[ ... ]
> @@ -548,6 +600,20 @@ int backlight_unregister_notifier(struct notifier_block *nb)
> }
> EXPORT_SYMBOL(backlight_unregister_notifier);
>
> +/**
> + * backlight_notify_brightness - notify brightness change to listeners
> + * @bd: backlight device that changed
> + *
> + * Notify registered listeners that the backlight brightness has changed.
> + * This is called automatically after successful brightness updates.
> + */
> +void backlight_notify_brightness(struct backlight_device *bd)
> +{
> + blocking_notifier_call_chain(&backlight_notifier,
> + BACKLIGHT_BRIGHTNESS_CHANGED, bd);
> +}
> +EXPORT_SYMBOL(backlight_notify_brightness);
[Severity: Medium]
Will in-kernel listeners lose sync with the actual hardware backlight state
when brightness is changed via a hardware hotkey or ACPI event?
When physical hotkey presses trigger platform drivers to invoke
backlight_force_update():
drivers/video/backlight/backlight.c:backlight_force_update() {
...
mutex_unlock(&bd->ops_lock);
backlight_generate_event(bd, reason);
}
It emits a user-space uevent via backlight_generate_event(), but it doesn't
call the newly added backlight_notify_brightness() helper. Should it also
notify in-kernel DRM connector luminance properties here?
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 015183d129f96..fac1acbc698a1 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
[ ... ]
> @@ -325,6 +351,10 @@ static inline int backlight_update_status(struct backlight_device *bd)
> ret = bd->ops->update_status(bd);
> mutex_unlock(&bd->update_lock);
>
> + /* Notify DRM and other listeners that brightness changed */
> + if (ret == 0)
> + backlight_notify_brightness(bd);
[Severity: High]
Does calling backlight_notify_brightness() here create an AB-BA deadlock risk
with DRM listeners?
The caller of backlight_update_status() often holds bd->ops_lock (for example,
in backlight_set_brightness() or legacy sysfs writes). This means the blocking
notifier chain is fired synchronously under ops_lock.
If a DRM listener acquires a DRM lock during the notification callback, it
establishes an ops_lock -> drm_lock dependency.
Conversely, if a DRM driver calls backlight_set_brightness() while holding
DRM locks, it will attempt to acquire ops_lock, resulting in a drm_lock ->
ops_lock dependency.
Should the notification be deferred until after ops_lock is released, just
as backlight_generate_event() is handled?
> +
> return ret;
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908044035.62093-1-mario.limonciello@amd.com?part=2
next prev parent reply other threads:[~2026-09-08 4:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 4:40 [PATCH v8 00/14] Add support for a DRM backlight capability Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 01/14] Revert "backlight: Remove notifier" Mario Limonciello
2026-09-08 4:51 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 02/14] backlight: add kernel-internal backlight API Mario Limonciello
2026-09-08 4:52 ` sashiko-bot [this message]
2026-09-08 15:45 ` Jani Nikula
2026-09-08 16:00 ` Mario Limonciello
2026-09-08 16:33 ` Jani Nikula
2026-09-08 4:40 ` [PATCH v8 03/14] drm/property: add a per-connector luminance flag Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 04/14] drm: add connector backlight (LUMINANCE) infrastructure Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 15:48 ` Jani Nikula
2026-09-08 4:40 ` [PATCH v8 05/14] drm: add DRM_CLIENT_CAP_LUMINANCE Mario Limonciello
2026-09-08 4:55 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 06/14] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 07/14] drm/amd: Indicate driver supports luminance Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 08/14] drm/amd/display: use drm backlight Mario Limonciello
2026-09-08 4:57 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 09/14] drm/amdgpu: Check bios_scratch_reg_offset in backlight level helper Mario Limonciello
2026-09-08 4:51 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 10/14] drm/amd/display: Update KUnit backlight tests for luminance property and fixtures Mario Limonciello
2026-09-08 4:54 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 11/14] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 12/14] drm/xe: Indicate support for luminance on the connector Mario Limonciello
2026-09-08 4:57 ` sashiko-bot
2026-09-08 4:40 ` [PATCH v8 13/14] drm/i915: " Mario Limonciello
2026-09-08 4:40 ` [PATCH v8 14/14] drm/i915/display: use drm backlight Mario Limonciello
2026-09-08 5:03 ` 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=20260908045232.9F77B1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=mario.limonciello@amd.com \
--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;
as well as URLs for NNTP newsgroup(s).