* [PATCH v3 1/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture
2026-11-25 18:08 [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
@ 2026-11-25 18:08 ` Rong Zhang
2026-11-25 18:08 ` [PATCH v3 2/8] platform/x86: lenovo-ymc: Serialize WMI event handling Rong Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-11-25 18:08 UTC (permalink / raw)
To: Mark Pearson, Derek J. Clark, Hans de Goede, Ilpo Järvinen,
Gergo Koteles, Ike Panhc, Andrew Kallmeyer
Cc: Eduard Aliman, platform-driver-x86, linux-kernel, Mahir Faisal,
Rong Zhang, stable
There are five known Yoga modes: unknown, laptop, tablet, drawing board,
and tent, but lacks symbolic representations for reuse.
Introduce an enumeration called ymc_posture to collect and represent
them. The lenovo_ymc_keymap is also refactored to use the enumeration.
Cc: stable@vger.kernel.org
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Eduard Aliman <edialiman20@gmail.com>
Signed-off-by: Rong Zhang <i@rong.moe>
---
Cc stable as the later fixes depend on this.
---
drivers/platform/x86/lenovo/ideapad-laptop.h | 9 +++++++++
drivers/platform/x86/lenovo/ymc.c | 14 +++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.h b/drivers/platform/x86/lenovo/ideapad-laptop.h
index 1e52f2aa0aac..e29f741ffbf3 100644
--- a/drivers/platform/x86/lenovo/ideapad-laptop.h
+++ b/drivers/platform/x86/lenovo/ideapad-laptop.h
@@ -15,6 +15,15 @@ enum ideapad_laptop_notifier_actions {
IDEAPAD_LAPTOP_YMC_EVENT,
};
+enum ymc_posture {
+ /* Some devices cannot recognize their postures on boot. */
+ YMC_POSTURE_UNKNOWN = 0,
+ YMC_POSTURE_LAPTOP = 1,
+ YMC_POSTURE_TABLET = 2,
+ YMC_POSTURE_DRAWING_BOARD = 3,
+ YMC_POSTURE_TENT = 4,
+};
+
int ideapad_laptop_register_notifier(struct notifier_block *nb);
int ideapad_laptop_unregister_notifier(struct notifier_block *nb);
void ideapad_laptop_call_notifier(unsigned long action, void *data);
diff --git a/drivers/platform/x86/lenovo/ymc.c b/drivers/platform/x86/lenovo/ymc.c
index 91de02d989a0..70f3ae20d3e3 100644
--- a/drivers/platform/x86/lenovo/ymc.c
+++ b/drivers/platform/x86/lenovo/ymc.c
@@ -64,15 +64,11 @@ struct lenovo_ymc_private {
static const struct key_entry lenovo_ymc_keymap[] = {
/* Ignore the uninitialized state */
- { KE_IGNORE, 0x00 },
- /* Laptop */
- { KE_SW, 0x01, { .sw = { SW_TABLET_MODE, 0 } } },
- /* Tablet */
- { KE_SW, 0x02, { .sw = { SW_TABLET_MODE, 1 } } },
- /* Drawing Board */
- { KE_SW, 0x03, { .sw = { SW_TABLET_MODE, 1 } } },
- /* Tent */
- { KE_SW, 0x04, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_IGNORE, YMC_POSTURE_UNKNOWN },
+ { KE_SW, YMC_POSTURE_LAPTOP, { .sw = { SW_TABLET_MODE, 0 } } },
+ { KE_SW, YMC_POSTURE_TABLET, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_SW, YMC_POSTURE_DRAWING_BOARD, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_SW, YMC_POSTURE_TENT, { .sw = { SW_TABLET_MODE, 1 } } },
{ KE_END },
};
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 2/8] platform/x86: lenovo-ymc: Serialize WMI event handling
2026-11-25 18:08 [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
2026-11-25 18:08 ` [PATCH v3 1/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture Rong Zhang
@ 2026-11-25 18:08 ` Rong Zhang
2026-11-25 19:14 ` [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Eduard Aliman
2026-12-01 14:51 ` Ilpo Järvinen
3 siblings, 0 replies; 7+ messages in thread
From: Rong Zhang @ 2026-11-25 18:08 UTC (permalink / raw)
To: Mark Pearson, Derek J. Clark, Hans de Goede, Ilpo Järvinen,
Gergo Koteles, Ike Panhc, Andrew Kallmeyer
Cc: Eduard Aliman, platform-driver-x86, linux-kernel, Mahir Faisal,
Rong Zhang, stable
WMI events may arrive in parallel, causing race conditions, e.g.,
CPU1 CPU2
query: posture A
query: posture B
input report B
input report A
trigger EC with B
trigger EC with A
Fix it by serializing lenovo_ymc_notify() with a mutex.
Fixes: e82882cdd241 ("platform/x86: Add driver for Yoga Tablet Mode switch")
Cc: stable@vger.kernel.org
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Eduard Aliman <edialiman20@gmail.com>
Signed-off-by: Rong Zhang <i@rong.moe>
---
drivers/platform/x86/lenovo/ymc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/platform/x86/lenovo/ymc.c b/drivers/platform/x86/lenovo/ymc.c
index 70f3ae20d3e3..eba22600161e 100644
--- a/drivers/platform/x86/lenovo/ymc.c
+++ b/drivers/platform/x86/lenovo/ymc.c
@@ -10,9 +10,11 @@
#include <linux/acpi.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
+#include <linux/cleanup.h>
#include <linux/dmi.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
+#include <linux/mutex.h>
#include <linux/wmi.h>
#include "ideapad-laptop.h"
@@ -60,6 +62,7 @@ static const struct dmi_system_id allowed_chasis_types_dmi_table[] = {
struct lenovo_ymc_private {
struct input_dev *input_dev;
+ struct mutex mutex; /* Protects event handling. */
};
static const struct key_entry lenovo_ymc_keymap[] = {
@@ -82,6 +85,8 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
acpi_status status;
int code;
+ guard(mutex)(&priv->mutex);
+
status = wmi_evaluate_method(LENOVO_YMC_QUERY_GUID,
LENOVO_YMC_QUERY_INSTANCE,
LENOVO_YMC_QUERY_METHOD,
@@ -137,6 +142,10 @@ static int lenovo_ymc_probe(struct wmi_device *wdev, const void *ctx)
if (!input_dev)
return -ENOMEM;
+ err = devm_mutex_init(&wdev->dev, &priv->mutex);
+ if (err)
+ return err;
+
input_dev->name = "Lenovo Yoga Tablet Mode Control switch";
input_dev->phys = LENOVO_YMC_EVENT_GUID "/input0";
input_dev->id.bustype = BUS_HOST;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
2026-11-25 18:08 [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
2026-11-25 18:08 ` [PATCH v3 1/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture Rong Zhang
2026-11-25 18:08 ` [PATCH v3 2/8] platform/x86: lenovo-ymc: Serialize WMI event handling Rong Zhang
@ 2026-11-25 19:14 ` Eduard Aliman
2026-12-01 14:51 ` Ilpo Järvinen
3 siblings, 0 replies; 7+ messages in thread
From: Eduard Aliman @ 2026-11-25 19:14 UTC (permalink / raw)
To: Rong Zhang, Mark Pearson, Derek J. Clark, Hans de Goede,
Ilpo Järvinen, Gergo Koteles, Ike Panhc, Andrew Kallmeyer,
Eduard Aliman, platform-driver-x86, linux-kernel, Mahir Faisal,
stable
Hi Rong,
I tested this v3 series (patches 1-8/8) on top of Linux 7.3.4 (Fedora 45)
on my Lenovo Yoga 7 14ARP8 (82YM) without setting ymc_ec_trigger=1
manually (relying on the DMI quirk added in patch 8/8).
Folding into tablet mode now automatically turns off the keyboard
backlight, and unfolding restores it as expected.
Tested-by: Eduard Aliman <edialiman20@gmail.com>
Thanks again for adding the quirk for the 14ARP8!
Best regards,
Eduard Aliman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
2026-11-25 18:08 [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Rong Zhang
` (2 preceding siblings ...)
2026-11-25 19:14 ` [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior Eduard Aliman
@ 2026-12-01 14:51 ` Ilpo Järvinen
2026-12-03 12:00 ` Mahir Faisal
3 siblings, 1 reply; 7+ messages in thread
From: Ilpo Järvinen @ 2026-12-01 14:51 UTC (permalink / raw)
To: Mark Pearson, Derek J. Clark, Hans de Goede, Gergo Koteles,
Ike Panhc, Andrew Kallmeyer, Rong Zhang
Cc: Eduard Aliman, platform-driver-x86, linux-kernel, Mahir Faisal,
stable
On Thu, 26 Nov 2026 02:08:18 +0800, Rong Zhang wrote:
> Currently, the ideapad-laptop driver triggers the EC with YMC command
> 0x01, which is necessary for existing devices in the DMI quirk table to
> clear the pending event to allow further events to be emitted.
>
> Newer models do not require command 0x01 anymore (writing it is a
> no-op), but some of them require other commands to properly synchronize
> and set the hardware state.
>
> [...]
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/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture
commit: c1075fdb1fa1d78f7658f753cdcc168acfdd15b7
[2/8] platform/x86: lenovo-ymc: Serialize WMI event handling
commit: 8a09da0490129ca685e2e6098d2c3372bae3bb8d
[3/8] platform/x86: lenovo-wmi-events: Modernize WMI event handling
commit: 65ad5ca4fe497cab6768f2ae3f3b10b6820b1921
[4/8] platform/x86: lenovo-ymc: Modernize WMI driver and factor out events
commit: 421a6666611a4ec778585ec16bc2b00a0ea08acc
[5/8] platform/x86: lenovo-ymc: Refresh posture on resume
commit: c4ae0f20a3f050d5599a5de5ec11ff4caab1b689
[6/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
commit: 538a23992110791865e060ba4dcfc515fc612797
[7/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14IRL8
commit: c221c3b17288b96bed8bf04ddff753acf7d4094a
[8/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14ARP8
commit: 802a116f3ff7ae26b4ce79758e15b9ee7322ddc5
--
i.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
2026-12-01 14:51 ` Ilpo Järvinen
@ 2026-12-03 12:00 ` Mahir Faisal
2026-12-03 12:10 ` Ilpo Järvinen
0 siblings, 1 reply; 7+ messages in thread
From: Mahir Faisal @ 2026-12-03 12:00 UTC (permalink / raw)
To: Rong Zhang, Ilpo Järvinen
Cc: Mark Pearson, Derek J. Clark, Hans de Goede, Gergo Koteles,
Ike Panhc, Andrew Kallmeyer, Eduard Aliman, platform-driver-x86,
linux-kernel, stable
Hi Rong and Ilpo,
I tested the v3 series (patches 1-8/8) on my Lenovo Yoga 7 14IRL8
(82YL, BIOS LHCN30WW), built as modules on top of Fedora 45's 7.3.6
kernel, with my userspace workaround disabled and without
ymc_ec_trigger=1 (relying on the DMI quirk added in patch 7/8).
- Folding into tablet, tent and stand modes turns off the keyboard
backlight and disables the keyboard and touchpad; unfolding to laptop
mode restores all three.
- Changing the posture during suspend is picked up correctly on
resume, in both directions (folded during sleep, and unfolded during
sleep).
Thanks a lot for working on this!
Tested-by: Mahir Faisal <mahirfaisalantiq33@gmail.com>
Best regards,
Mahir
On Tue, Dec 1, 2026 at 8:51 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Thu, 26 Nov 2026 02:08:18 +0800, Rong Zhang wrote:
>
> > Currently, the ideapad-laptop driver triggers the EC with YMC command
> > 0x01, which is necessary for existing devices in the DMI quirk table to
> > clear the pending event to allow further events to be emitted.
> >
> > Newer models do not require command 0x01 anymore (writing it is a
> > no-op), but some of them require other commands to properly synchronize
> > and set the hardware state.
> >
> > [...]
>
> 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/8] platform/x86: lenovo-ymc: Use enumeration to represent device posture
> commit: c1075fdb1fa1d78f7658f753cdcc168acfdd15b7
> [2/8] platform/x86: lenovo-ymc: Serialize WMI event handling
> commit: 8a09da0490129ca685e2e6098d2c3372bae3bb8d
> [3/8] platform/x86: lenovo-wmi-events: Modernize WMI event handling
> commit: 65ad5ca4fe497cab6768f2ae3f3b10b6820b1921
> [4/8] platform/x86: lenovo-ymc: Modernize WMI driver and factor out events
> commit: 421a6666611a4ec778585ec16bc2b00a0ea08acc
> [5/8] platform/x86: lenovo-ymc: Refresh posture on resume
> commit: c4ae0f20a3f050d5599a5de5ec11ff4caab1b689
> [6/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
> commit: 538a23992110791865e060ba4dcfc515fc612797
> [7/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14IRL8
> commit: c221c3b17288b96bed8bf04ddff753acf7d4094a
> [8/8] platform/x86: ideapad-laptop: Enable ymc_ec_trigger for Lenovo Yoga 7 14ARP8
> commit: 802a116f3ff7ae26b4ce79758e15b9ee7322ddc5
>
> --
> i.
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/8] platform/x86: ideapad-laptop: Trigger the EC on YMC events following Windows behavior
2026-12-03 12:00 ` Mahir Faisal
@ 2026-12-03 12:10 ` Ilpo Järvinen
0 siblings, 0 replies; 7+ messages in thread
From: Ilpo Järvinen @ 2026-12-03 12:10 UTC (permalink / raw)
To: Mahir Faisal
Cc: Rong Zhang, Mark Pearson, Derek J. Clark, Hans de Goede,
Gergo Koteles, Ike Panhc, Andrew Kallmeyer, Eduard Aliman,
platform-driver-x86, LKML, stable
On Thu, 3 Dec 2026, Mahir Faisal wrote:
> Hi Rong and Ilpo,
> I tested the v3 series (patches 1-8/8) on my Lenovo Yoga 7 14IRL8
> (82YL, BIOS LHCN30WW), built as modules on top of Fedora 45's 7.3.6
> kernel, with my userspace workaround disabled and without
> ymc_ec_trigger=1 (relying on the DMI quirk added in patch 7/8).
>
> - Folding into tablet, tent and stand modes turns off the keyboard
> backlight and disables the keyboard and touchpad; unfolding to laptop
> mode restores all three.
> - Changing the posture during suspend is picked up correctly on
> resume, in both directions (folded during sleep, and unfolded during
> sleep).
>
> Thanks a lot for working on this!
>
> Tested-by: Mahir Faisal <mahirfaisalantiq33@gmail.com>
Thanks for testing.
I've added you tag to the commits in the review-ilpo-next branch (except
for the last change that relates to a different model).
--
i.
^ permalink raw reply [flat|nested] 7+ messages in thread