* [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock
@ 2026-11-26 15:15 Armin Wolf
2026-11-26 15:15 ` [PATCH v3 2/2] platform/x86: lg-laptop: Improve keyboard backlight detection Armin Wolf
2026-12-01 14:50 ` [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Ilpo Järvinen
0 siblings, 2 replies; 4+ messages in thread
From: Armin Wolf @ 2026-11-26 15:15 UTC (permalink / raw)
To: matan; +Cc: hansg, ilpo.jarvinen, platform-driver-x86, linux-kernel, daxter1992
Calling ACPI control methods inside the .brightness_set callback
of a LED class device can cause deadlocks because this callback
must not sleep. Use .brightness_set_blocking instead.
Fixes: dbf0c5a6b1f8 ("platform/x86: Add LG Gram laptop special features driver")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Change since v2:
- none
Changes since v1:
- none
---
drivers/platform/x86/lg-laptop.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
index 36ad1e269443..a784071de8b3 100644
--- a/drivers/platform/x86/lg-laptop.c
+++ b/drivers/platform/x86/lg-laptop.c
@@ -32,7 +32,7 @@
#define LED_DEVICE(_name, max, flag) struct led_classdev _name = { \
.name = __stringify(_name), \
.max_brightness = max, \
- .brightness_set = _name##_set, \
+ .brightness_set_blocking = _name##_set, \
.brightness_get = _name##_get, \
.flags = flag, \
}
@@ -599,10 +599,9 @@ static const struct attribute_group dev_attribute_group = {
.attrs = dev_attributes,
};
-static void tpad_led_set(struct led_classdev *cdev,
- enum led_brightness brightness)
+static int tpad_led_set(struct led_classdev *cdev, enum led_brightness brightness)
{
- lg_wmab_set(cdev->dev->parent, WM_TLED, brightness > LED_OFF);
+ return lg_wmab_set(cdev->dev->parent, WM_TLED, brightness > LED_OFF);
}
static enum led_brightness tpad_led_get(struct led_classdev *cdev)
@@ -612,8 +611,7 @@ static enum led_brightness tpad_led_get(struct led_classdev *cdev)
static LED_DEVICE(tpad_led, 1, 0);
-static void kbd_backlight_set(struct led_classdev *cdev,
- enum led_brightness brightness)
+static int kbd_backlight_set(struct led_classdev *cdev, enum led_brightness brightness)
{
/* Must always be written */
u32 value = KBD_LED_STATUS;
@@ -633,7 +631,7 @@ static void kbd_backlight_set(struct led_classdev *cdev,
value |= FIELD_PREP(KBD_LED_BRIGHTNESS_MASK, bright);
value |= FIELD_PREP(KBD_LED_MODE_MASK, mode);
- lg_wmab_set(cdev->dev->parent, WM_KEY_LIGHT, value);
+ return lg_wmab_set(cdev->dev->parent, WM_KEY_LIGHT, value);
}
static enum led_brightness get_kbd_backlight_level(struct device *dev)
--
2.56.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v3 2/2] platform/x86: lg-laptop: Improve keyboard backlight detection
2026-11-26 15:15 [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Armin Wolf
@ 2026-11-26 15:15 ` Armin Wolf
2026-12-01 14:50 ` [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Ilpo Järvinen
1 sibling, 0 replies; 4+ messages in thread
From: Armin Wolf @ 2026-11-26 15:15 UTC (permalink / raw)
To: matan; +Cc: hansg, ilpo.jarvinen, platform-driver-x86, linux-kernel, daxter1992
Not all devices support the keyboard backlight feature, instead they
will return an error when trying to read/write the backlight level.
Avoid registering the associated LED class device on such devices
by first verifying that reading of the backlight level works. For
this the get_kbd_backlight_level() function has to be modified to
stop hiding any errors coming from the WMAB call.
Reported-by: Carlos Javier Alvarez <daxter1992@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222275
Tested-by: Carlos Javier Alvarez <daxter1992@gmail.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Changes since v2:
- make kbd_brightness signed
Changes since v1:
- fix error handling in lg_laptop_handle_input_event()
---
drivers/platform/x86/lg-laptop.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
index a784071de8b3..d6d452a1dbe5 100644
--- a/drivers/platform/x86/lg-laptop.c
+++ b/drivers/platform/x86/lg-laptop.c
@@ -641,10 +641,10 @@ static enum led_brightness get_kbd_backlight_level(struct device *dev)
ret = lg_wmab_get(dev, WM_KEY_LIGHT, &value);
if (ret < 0)
- return LED_OFF;
+ return ret;
if (FIELD_GET(KBD_LED_MAGIC_MASK, value) != KBD_LED_MAGIC)
- return LED_OFF;
+ return -EIO;
if (FIELD_GET(KBD_LED_MODE_MASK, value) == KBD_LED_MODE_OFF)
return LED_OFF;
@@ -703,7 +703,7 @@ static int lg_laptop_get_event_data(acpi_handle handle, u32 value, u32 *data)
static void lg_laptop_handle_input_event(struct input_dev *input_dev, u32 value, u32 data)
{
- unsigned int kbd_brightness;
+ int kbd_brightness;
switch (value) {
case LG_NOTIFY_HOTKEY:
@@ -719,6 +719,9 @@ static void lg_laptop_handle_input_event(struct input_dev *input_dev, u32 value,
break;
kbd_brightness = get_kbd_backlight_level(kbd_backlight.dev->parent);
+ if (kbd_brightness < 0)
+ kbd_brightness = LED_OFF;
+
led_classdev_notify_brightness_hw_changed(&kbd_backlight, kbd_brightness);
break;
default:
@@ -823,6 +826,21 @@ static int lg_laptop_input_init(struct device *dev, acpi_handle handle)
return 0;
}
+static int lg_laptop_kbd_backlight_init(struct device *dev)
+{
+ int ret;
+
+ /*
+ * Devices that do not support the keyboard backlight feature
+ * usually return a error when trying to read the backlight level.
+ */
+ ret = get_kbd_backlight_level(dev);
+ if (ret < 0)
+ return ret;
+
+ return devm_led_classdev_register(dev, &kbd_backlight);
+}
+
static acpi_status lg_laptop_address_space_write(struct device *dev, acpi_physical_address address,
size_t size, u64 value)
{
@@ -1035,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
battery_limit_use_wmbb = 1;
/* LEDs are optional */
- ret = devm_led_classdev_register(&pdev->dev, &kbd_backlight);
+ ret = lg_laptop_kbd_backlight_init(&pdev->dev);
if (ret < 0)
kbd_backlight_available = false;
else
--
2.56.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock
2026-11-26 15:15 [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Armin Wolf
2026-11-26 15:15 ` [PATCH v3 2/2] platform/x86: lg-laptop: Improve keyboard backlight detection Armin Wolf
@ 2026-12-01 14:50 ` Ilpo Järvinen
2026-12-01 21:19 ` Armin Wolf
1 sibling, 1 reply; 4+ messages in thread
From: Ilpo Järvinen @ 2026-12-01 14:50 UTC (permalink / raw)
To: matan, Armin Wolf; +Cc: hansg, platform-driver-x86, linux-kernel, daxter1992
On Thu, 26 Nov 2026 16:15:56 +0100, Armin Wolf wrote:
> Calling ACPI control methods inside the .brightness_set callback
> of a LED class device can cause deadlocks because this callback
> must not sleep. Use .brightness_set_blocking instead.
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also
fixes are mostly routed through for-next unless the fix is for a
commit introduced in the most recent cycle or is clearly a regression
fix.
The list of commits applied:
[1/2] platform/x86: lg-laptop: Fix possible LED deadlock
commit: 37d8b26727ba0ae78c44814ba5a1f423e5ba3764
[2/2] platform/x86: lg-laptop: Improve keyboard backlight detection
commit: b354a3c972b6cef862da3ac525b16b04c461017c
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock
2026-12-01 14:50 ` [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Ilpo Järvinen
@ 2026-12-01 21:19 ` Armin Wolf
0 siblings, 0 replies; 4+ messages in thread
From: Armin Wolf @ 2026-12-01 21:19 UTC (permalink / raw)
To: Ilpo Järvinen, matan
Cc: hansg, platform-driver-x86, linux-kernel, daxter1992
Am 01.12.26 um 15:50 schrieb Ilpo Järvinen:
> On Thu, 26 Nov 2026 16:15:56 +0100, Armin Wolf wrote:
>
>> Calling ACPI control methods inside the .brightness_set callback
>> of a LED class device can cause deadlocks because this callback
>> must not sleep. Use .brightness_set_blocking instead.
>
> Thank you for your contribution, it has been applied to my local
> review-ilpo-next branch. Note it will show up in the public
> platform-drivers-x86/review-ilpo-next branch only once I've pushed my
> local branch there, which might take a while.
Thank you :)
Armin Wolf
> FYI [if applicable to your patch], as per Linus' policy change, also
> fixes are mostly routed through for-next unless the fix is for a
> commit introduced in the most recent cycle or is clearly a regression
> fix.
>
> The list of commits applied:
> [1/2] platform/x86: lg-laptop: Fix possible LED deadlock
> commit: 37d8b26727ba0ae78c44814ba5a1f423e5ba3764
> [2/2] platform/x86: lg-laptop: Improve keyboard backlight detection
> commit: b354a3c972b6cef862da3ac525b16b04c461017c
>
> --
> i.
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-01 21:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 15:15 [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Armin Wolf
2026-11-26 15:15 ` [PATCH v3 2/2] platform/x86: lg-laptop: Improve keyboard backlight detection Armin Wolf
2026-12-01 14:50 ` [PATCH v3 1/2] platform/x86: lg-laptop: Fix possible LED deadlock Ilpo Järvinen
2026-12-01 21:19 ` Armin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®