* [PATCH 1/8] platform/x86: thinkpad_acpi: remove early exit in hotkey_kthread()
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 2/8] platform/x86: thinkpad_acpi: drop dead -ENXIO check in hotkey_init() Dmitry Torokhov
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
hotkey_kthread() starts with an early return when tpacpi_lifecycle is
TPACPI_LIFE_EXITING. A kthread started with kthread_run() and stopped
via kthread_stop() must not exit before kthread_should_stop() returns
true, otherwise its task_struct can be freed before
hotkey_poll_stop_sync() calls kthread_stop().
Remove the early return so hotkey_kthread() always waits for
kthread_stop().
Fixes: 01e88f25985d ("ACPI: thinkpad-acpi: add CMOS NVRAM polling for hot keys (v9)")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 1bccc21ee29b..a586113ab1a7 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -2451,9 +2451,6 @@ static int hotkey_kthread(void *data)
unsigned int poll_freq;
bool was_frozen;
- if (tpacpi_lifecycle == TPACPI_LIFE_EXITING)
- return 0;
-
set_freezable();
so = 0;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 2/8] platform/x86: thinkpad_acpi: drop dead -ENXIO check in hotkey_init()
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 1/8] platform/x86: thinkpad_acpi: remove early exit in hotkey_kthread() Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 3/8] platform/x86: thinkpad_acpi: simplify hotkey open/close and poll setup Dmitry Torokhov
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
hotkey_mask_set() only ever returns 0 or -EIO, never -ENXIO. Simplify
the error check on its return value in hotkey_init() accordingly.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index a586113ab1a7..659a2c5d1982 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -3572,7 +3572,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
| hotkey_driver_mask)
& ~hotkey_source_mask);
}
- if (res < 0 && res != -ENXIO) {
+ if (res) {
hotkey_exit();
return res;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 3/8] platform/x86: thinkpad_acpi: simplify hotkey open/close and poll setup
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 1/8] platform/x86: thinkpad_acpi: remove early exit in hotkey_kthread() Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 2/8] platform/x86: thinkpad_acpi: drop dead -ENXIO check in hotkey_init() Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 4/8] platform/x86: thinkpad_acpi: update polling state in hotkey_user_mask_set() Dmitry Torokhov
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
Since commit 38b9ab80db31 ("platform/x86: thinkpad_acpi: Move subdriver
initialization to tpacpi_pdriver's probe."), tpacpi_subdrivers_release()
is registered via devm_add_action_or_reset() before tpacpi_inputdev is
registered. Because devres resources are unwound in reverse order,
tpacpi_inputdev is always unregistered (closing any open handles and
preventing new opens) before hotkey_exit() is called. Combined with
hotkey_kthread() no longer exiting early on TPACPI_LIFE_EXITING, the
lifecycle guards in the input callbacks are unnecessary.
Drop the obsolete tpacpi_lifecycle checks and BUG() from
hotkey_inputdev_open() and hotkey_inputdev_close(), as well as the
redundant driver mask check in hotkey_inputdev_close() (which
hotkey_poll_setup() already evaluates).
Also call hotkey_poll_setup() directly inside the existing hotkey_mutex
critical sections in hotkey_init() and hotkey_resume(), and remove the
now-unused hotkey_poll_setup_safe() wrapper.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 52 +++++++++--------------------
1 file changed, 15 insertions(+), 37 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 659a2c5d1982..e5f78107bd1a 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -2546,12 +2546,6 @@ static void hotkey_poll_setup(const bool may_warn)
}
}
-static void hotkey_poll_setup_safe(const bool may_warn)
-{
- guard(mutex)(&hotkey_mutex);
- hotkey_poll_setup(may_warn);
-}
-
static void hotkey_poll_set_freq(unsigned int freq)
{
lockdep_assert_held(&hotkey_mutex);
@@ -2568,10 +2562,6 @@ static void hotkey_poll_setup(const bool __unused)
{
}
-static void hotkey_poll_setup_safe(const bool __unused)
-{
-}
-
static void hotkey_poll_stop_sync(void)
{
}
@@ -2579,21 +2569,12 @@ static void hotkey_poll_stop_sync(void)
static int hotkey_inputdev_open(struct input_dev *dev)
{
- switch (tpacpi_lifecycle) {
- case TPACPI_LIFE_INIT:
- case TPACPI_LIFE_RUNNING:
- scoped_guard(mutex, &hotkey_mutex) {
- hotkey_input_enabled = true;
- hotkey_poll_setup(false);
- }
- return 0;
- case TPACPI_LIFE_EXITING:
- return -EBUSY;
- }
+ guard(mutex)(&hotkey_mutex);
+
+ hotkey_input_enabled = true;
+ hotkey_poll_setup(false);
- /* Should only happen if tpacpi_lifecycle is corrupt */
- BUG();
- return -EBUSY;
+ return 0;
}
static void hotkey_inputdev_close(struct input_dev *dev)
@@ -2601,11 +2582,7 @@ static void hotkey_inputdev_close(struct input_dev *dev)
guard(mutex)(&hotkey_mutex);
hotkey_input_enabled = false;
-
- /* disable hotkey polling when possible */
- if (tpacpi_lifecycle != TPACPI_LIFE_EXITING &&
- !(hotkey_source_mask & hotkey_driver_mask))
- hotkey_poll_setup(false);
+ hotkey_poll_setup(false);
}
/* sysfs hotkey enable ------------------------------------------------- */
@@ -3571,22 +3548,23 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
res = hotkey_mask_set(((hotkey_all_mask & ~hotkey_reserved_mask)
| hotkey_driver_mask)
& ~hotkey_source_mask);
+ if (!res) {
+ hotkey_user_mask = (hotkey_acpi_mask | hotkey_source_mask)
+ & ~hotkey_reserved_mask;
+ vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
+ "initial masks: user=0x%08x, fw=0x%08x, poll=0x%08x\n",
+ hotkey_user_mask, hotkey_acpi_mask, hotkey_source_mask);
+ hotkey_poll_setup(true);
+ }
}
if (res) {
hotkey_exit();
return res;
}
- hotkey_user_mask = (hotkey_acpi_mask | hotkey_source_mask)
- & ~hotkey_reserved_mask;
- vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
- "initial masks: user=0x%08x, fw=0x%08x, poll=0x%08x\n",
- hotkey_user_mask, hotkey_acpi_mask, hotkey_source_mask);
tpacpi_inputdev->open = &hotkey_inputdev_open;
tpacpi_inputdev->close = &hotkey_inputdev_close;
- hotkey_poll_setup_safe(true);
-
/* Enable TrackPoint doubletap event reporting by default. */
tp_features.trackpoint_doubletap_enable = 1;
@@ -4024,6 +4002,7 @@ static void hotkey_resume(void)
if (hotkey_status_set(true) < 0 ||
hotkey_mask_set(hotkey_acpi_mask) < 0)
pr_err("error while attempting to reset the event firmware interface\n");
+ hotkey_poll_setup(false);
}
tpacpi_send_radiosw_update();
@@ -4033,7 +4012,6 @@ static void hotkey_resume(void)
keyboard_attached_on_screen_notify_change();
hotkey_wakeup_reason_notify_change();
hotkey_wakeup_hotunplug_complete_notify_change();
- hotkey_poll_setup_safe(false);
/* restore previous mode of adaptive keyboard of X1 Carbon */
if (tp_features.has_adaptive_kbd) {
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 4/8] platform/x86: thinkpad_acpi: update polling state in hotkey_user_mask_set()
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
` (2 preceding siblings ...)
2026-11-25 23:11 ` [PATCH 3/8] platform/x86: thinkpad_acpi: simplify hotkey open/close and poll setup Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 5/8] platform/x86: thinkpad_acpi: use scoped_guard() for hotkey config locking Dmitry Torokhov
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
hotkey_user_mask_set() is called from both hotkey_mask_store() (sysfs)
and hotkey_write() (/proc/acpi/ibm/hotkey), but only hotkey_mask_store()
called hotkey_poll_setup(true) afterwards. As a result, updating the
hotkey mask through /proc/acpi/ibm/hotkey did not start or stop the
NVRAM polling thread to match the new mask.
Move the hotkey_poll_setup(true) call into hotkey_user_mask_set(),
matching tpacpi_hotkey_driver_mask_set(), and drop the redundant #ifdef
guard from hotkey_mask_store().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index e5f78107bd1a..7a82a9014a3e 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -2137,6 +2137,8 @@ static int hotkey_user_mask_set(const u32 mask)
/* Enable the available bits in hotkey_user_mask */
hotkey_user_mask = mask & (hotkey_acpi_mask | hotkey_source_mask);
+ hotkey_poll_setup(true);
+
return rc;
}
@@ -2647,10 +2649,6 @@ static ssize_t hotkey_mask_store(struct device *dev,
res = hotkey_user_mask_set(t);
-#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
- hotkey_poll_setup(true);
-#endif
-
tpacpi_disclose_usertask("hotkey_mask", "set to 0x%08lx\n", t);
return (res) ? res : count;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 5/8] platform/x86: thinkpad_acpi: use scoped_guard() for hotkey config locking
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
` (3 preceding siblings ...)
2026-11-25 23:11 ` [PATCH 4/8] platform/x86: thinkpad_acpi: update polling state in hotkey_user_mask_set() Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 6/8] platform/x86: thinkpad_acpi: convert hotkey_thread_data_mutex to a spinlock Dmitry Torokhov
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
Replace the HOTKEY_CONFIG_CRITICAL_START and HOTKEY_CONFIG_CRITICAL_END
macros and manual hotkey_thread_data_mutex lock/unlock calls with
scoped_guard(mutex, &hotkey_thread_data_mutex).
Keep the hotkey_driver_mask assignment inside the guard in
tpacpi_hotkey_driver_mask_set() when polling is enabled so updates to
hotkey_driver_mask, hotkey_source_mask, and hotkey_config_change remain
atomic with respect to hotkey_kthread().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 74 ++++++++++++-----------------
1 file changed, 31 insertions(+), 43 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 7a82a9014a3e..58500b72d9d2 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -1819,8 +1819,6 @@ static struct task_struct *tpacpi_hotkey_task;
*
* Increment hotkey_config_change when changing them if you
* want the kthread to forget old state.
- *
- * See HOTKEY_CONFIG_CRITICAL_START/HOTKEY_CONFIG_CRITICAL_END
*/
static struct mutex hotkey_thread_data_mutex;
static unsigned int hotkey_config_change;
@@ -1828,29 +1826,14 @@ static unsigned int hotkey_config_change;
/*
* hotkey poller control variables
*
- * Must be atomic or readers will also need to acquire mutex
- *
- * HOTKEY_CONFIG_CRITICAL_START/HOTKEY_CONFIG_CRITICAL_END
- * should be used only when the changes need to be taken as
- * a block, OR when one needs to force the kthread to forget
- * old state.
+ * Must be atomic or readers will also need to acquire mutex.
*/
static u32 hotkey_source_mask; /* bit mask 0=ACPI,1=NVRAM */
static unsigned int hotkey_poll_freq = 10; /* Hz */
-#define HOTKEY_CONFIG_CRITICAL_START \
- do { \
- mutex_lock(&hotkey_thread_data_mutex); \
- hotkey_config_change++; \
- } while (0);
-#define HOTKEY_CONFIG_CRITICAL_END \
- mutex_unlock(&hotkey_thread_data_mutex);
-
#else /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
#define hotkey_source_mask 0U
-#define HOTKEY_CONFIG_CRITICAL_START
-#define HOTKEY_CONFIG_CRITICAL_END
#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
@@ -2159,12 +2142,15 @@ static int tpacpi_hotkey_driver_mask_set(const u32 mask)
guard(mutex)(&hotkey_mutex);
- HOTKEY_CONFIG_CRITICAL_START
- hotkey_driver_mask = mask;
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
- hotkey_source_mask |= (mask & ~hotkey_all_mask);
+ scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ hotkey_driver_mask = mask;
+ hotkey_source_mask |= (mask & ~hotkey_all_mask);
+ hotkey_config_change++;
+ }
+#else
+ hotkey_driver_mask = mask;
#endif
- HOTKEY_CONFIG_CRITICAL_END
rc = hotkey_mask_set((hotkey_acpi_mask | hotkey_driver_mask) &
~hotkey_source_mask);
@@ -2460,13 +2446,13 @@ static int hotkey_kthread(void *data)
t = 0;
/* Initial state for compares */
- mutex_lock(&hotkey_thread_data_mutex);
- change_detector = hotkey_config_change;
- poll_mask = hotkey_source_mask;
- event_mask = hotkey_source_mask &
- (hotkey_driver_mask | hotkey_user_mask);
- poll_freq = hotkey_poll_freq;
- mutex_unlock(&hotkey_thread_data_mutex);
+ scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ change_detector = hotkey_config_change;
+ poll_mask = hotkey_source_mask;
+ event_mask = hotkey_source_mask &
+ (hotkey_driver_mask | hotkey_user_mask);
+ poll_freq = hotkey_poll_freq;
+ }
hotkey_read_nvram(&s[so], poll_mask);
while (!kthread_should_stop()) {
@@ -2483,18 +2469,19 @@ static int hotkey_kthread(void *data)
if (t > 0 && !was_frozen)
continue;
- mutex_lock(&hotkey_thread_data_mutex);
- if (was_frozen || hotkey_config_change != change_detector) {
- /* forget old state on thaw or config change */
- si = so;
- t = 0;
- change_detector = hotkey_config_change;
+ scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ if (was_frozen ||
+ hotkey_config_change != change_detector) {
+ /* forget old state on thaw or config change */
+ si = so;
+ t = 0;
+ change_detector = hotkey_config_change;
+ }
+ poll_mask = hotkey_source_mask;
+ event_mask = hotkey_source_mask &
+ (hotkey_driver_mask | hotkey_user_mask);
+ poll_freq = hotkey_poll_freq;
}
- poll_mask = hotkey_source_mask;
- event_mask = hotkey_source_mask &
- (hotkey_driver_mask | hotkey_user_mask);
- poll_freq = hotkey_poll_freq;
- mutex_unlock(&hotkey_thread_data_mutex);
if (likely(poll_mask)) {
hotkey_read_nvram(&s[si], poll_mask);
@@ -2739,9 +2726,10 @@ static ssize_t hotkey_source_mask_store(struct device *dev,
if (rc)
return rc;
- HOTKEY_CONFIG_CRITICAL_START
- hotkey_source_mask = t;
- HOTKEY_CONFIG_CRITICAL_END
+ scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ hotkey_source_mask = t;
+ hotkey_config_change++;
+ }
rc = hotkey_mask_set((hotkey_user_mask | hotkey_driver_mask) &
~hotkey_source_mask);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 6/8] platform/x86: thinkpad_acpi: convert hotkey_thread_data_mutex to a spinlock
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
` (4 preceding siblings ...)
2026-11-25 23:11 ` [PATCH 5/8] platform/x86: thinkpad_acpi: use scoped_guard() for hotkey config locking Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 7/8] platform/x86: thinkpad_acpi: remove unused hotkey_poll_active flag Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 8/8] platform/x86: thinkpad_acpi: drop redundant input device parent assignment Dmitry Torokhov
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
hotkey_thread_data_mutex only protects a few in-memory integer reads
and updates across hotkey_kthread(), tpacpi_hotkey_driver_mask_set(),
and hotkey_source_mask_store(), with no sleeping calls inside any of
its critical sections.
Convert it to a statically initialized spinlock_t
(hotkey_thread_data_lock), which also allows dropping the conditional
mutex_init() call from hotkey_init().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 58500b72d9d2..0ebaea0ab96b 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -67,6 +67,7 @@
#include <linux/sched/signal.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
+#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/string_helpers.h>
@@ -1814,19 +1815,19 @@ struct tp_nvram_state {
static struct task_struct *tpacpi_hotkey_task;
/*
- * Acquire mutex to write poller control variables as an
+ * Acquire spinlock to write poller control variables as an
* atomic block.
*
* Increment hotkey_config_change when changing them if you
* want the kthread to forget old state.
*/
-static struct mutex hotkey_thread_data_mutex;
+static DEFINE_SPINLOCK(hotkey_thread_data_lock);
static unsigned int hotkey_config_change;
/*
* hotkey poller control variables
*
- * Must be atomic or readers will also need to acquire mutex.
+ * Must be atomic or readers will also need to acquire spinlock.
*/
static u32 hotkey_source_mask; /* bit mask 0=ACPI,1=NVRAM */
static unsigned int hotkey_poll_freq = 10; /* Hz */
@@ -2143,7 +2144,7 @@ static int tpacpi_hotkey_driver_mask_set(const u32 mask)
guard(mutex)(&hotkey_mutex);
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
- scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ scoped_guard(spinlock, &hotkey_thread_data_lock) {
hotkey_driver_mask = mask;
hotkey_source_mask |= (mask & ~hotkey_all_mask);
hotkey_config_change++;
@@ -2446,7 +2447,7 @@ static int hotkey_kthread(void *data)
t = 0;
/* Initial state for compares */
- scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ scoped_guard(spinlock, &hotkey_thread_data_lock) {
change_detector = hotkey_config_change;
poll_mask = hotkey_source_mask;
event_mask = hotkey_source_mask &
@@ -2469,7 +2470,7 @@ static int hotkey_kthread(void *data)
if (t > 0 && !was_frozen)
continue;
- scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ scoped_guard(spinlock, &hotkey_thread_data_lock) {
if (was_frozen ||
hotkey_config_change != change_detector) {
/* forget old state on thaw or config change */
@@ -2726,7 +2727,7 @@ static ssize_t hotkey_source_mask_store(struct device *dev,
if (rc)
return rc;
- scoped_guard(mutex, &hotkey_thread_data_mutex) {
+ scoped_guard(spinlock, &hotkey_thread_data_lock) {
hotkey_source_mask = t;
hotkey_config_change++;
}
@@ -3329,10 +3330,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
TPACPI_ACPIHANDLE_INIT(hkey);
mutex_init(&hotkey_mutex);
-#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
- mutex_init(&hotkey_thread_data_mutex);
-#endif
-
/* hotkey not supported on 570 */
tp_features.hotkey = hkey_handle != NULL;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 7/8] platform/x86: thinkpad_acpi: remove unused hotkey_poll_active flag
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
` (5 preceding siblings ...)
2026-11-25 23:11 ` [PATCH 6/8] platform/x86: thinkpad_acpi: convert hotkey_thread_data_mutex to a spinlock Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
2026-11-25 23:11 ` [PATCH 8/8] platform/x86: thinkpad_acpi: drop redundant input device parent assignment Dmitry Torokhov
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
Drop the unused hotkey_poll_active bitfield from tp_features, which has
never been referenced since it was introduced.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 0ebaea0ab96b..898d919d697a 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -377,7 +377,6 @@ static struct {
u32 mixer_no_level_control:1;
u32 battery_force_primary:1;
u32 platform_drv_registered:1;
- u32 hotkey_poll_active:1;
u32 has_adaptive_kbd:1;
u32 kbd_lang:1;
u32 trackpoint_doubletap_enable:1;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 8/8] platform/x86: thinkpad_acpi: drop redundant input device parent assignment
2026-11-25 23:11 [PATCH 0/8] platform/x86: thinkpad_acpi: clean up hotkey polling and locking Dmitry Torokhov
` (6 preceding siblings ...)
2026-11-25 23:11 ` [PATCH 7/8] platform/x86: thinkpad_acpi: remove unused hotkey_poll_active flag Dmitry Torokhov
@ 2026-11-25 23:11 ` Dmitry Torokhov
7 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2026-11-25 23:11 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Mark Pearson, Derek J. Clark,
Rong Zhang, Hans de Goede, Ilpo Järvinen
Cc: platform-driver-x86, ibm-acpi-devel, linux-kernel
Drop the manual tpacpi_inputdev->dev.parent assignment in
tpacpi_pdriver_probe(), as devm_input_allocate_device(&pdev->dev)
already sets the parent device.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 898d919d697a..e809ed417e0c 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -12245,7 +12245,6 @@ static int __init tpacpi_pdriver_probe(struct platform_device *pdev)
tpacpi_inputdev->id.vendor = thinkpad_id.vendor;
tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
- tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev;
/* Init subdriver dependencies */
tpacpi_detect_brightness_capabilities();
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 9+ messages in thread