Input: synaptics - support the touchpad LED on RMI function $30
Subsystems (2)
PATCH 1/1 Input: synaptics - support the touchpad LED on RMI function $30
Some HP laptops have an LED in the top left corner of the Synaptics touchpad that HP's Windows driver lights while the touchpad is disabled (double tap on that corner). On the HP ZBook 17 G3 (SYN3040, TM2706-002) the LED is not driven through the PS/2 deluxe LED command: the Windows driver (SynTP.sys 19.0.19.68) switches the touchpad to RMI register access over PS/2 with mode byte 0x7f, looks up function $30 (GPIO/LED) in the page description table and sets the LED bit in its control register:
register write: SetScale 2:1, SetRate <reg>, SetRate <value>
register read: SetScale 2:1, SetRate <reg>, GetInfo (first byte)
For touchpads in a new rmi_led_pnp_ids list, look up the F30 LED this way when the touchpad is set up and register a synaptics::touchpad_disabled LED class device. Setting it deactivates the touchpad, writes the F30 registers and restores the mode byte, which leaves RMI access. The LED is restored after reconnect.
On this touchpad F30 is on page 1 with control base 0x55 and four GPIO/LED pins; the LED is bit 3 of control register 0x59 and its brightness register is 0x5f.
Tested on an HP ZBook 17 G3 with Ubuntu's 7.0.0 kernel: the LED follows writes to its brightness file, the touchpad and the pointing stick keep working, and a userspace helper that turns the touchpad off on a double tap in the corner keeps the LED in step with GNOME's touchpad setting.
Reading HP's Windows driver (Ghidra) and writing this patch were done with the help of an AI coding assistant (Claude); I tested the LED and the touchpad on the machine.
--- drivers/input/mouse/synaptics.c | 241 ++++++++++++++++++++++++++++++++ drivers/input/mouse/synaptics.h | 13 ++ 2 files changed, 254 insertions(+)
drivers/input/mouse/synaptics.c +241 -0
@@ -589,6 +589,236 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)return 0 ; } +/* +* Some HP touchpads have an LED in the top left corner that HP's Windows +* driver lights while the touchpad is disabled. It is wired to RMI function +* $30 (GPIO/LED), which these touchpads also expose over PS/2: mode byte 0x7f +* switches them to RMI register access, where SetScale 2:1 followed by two +* SetRate commands writes a register, and SetScale 2:1, SetRate and GetInfo +* read one. Setting the normal mode byte again leaves RMI access. +*/ +static const char *const rmi_led_pnp_ids[] = { +"SYN3040" ,/* HP ZBook 17 G3 */ +NULL +}; + +#define SYN_RMI_MODE 0x7f +#define SYN_RMI_PAGE_SELECT 0xff +#define SYN_RMI_PDT_START 0xee +#define SYN_RMI_PDT_END 0x0b +#define SYN_RMI_PDT_ENTRY_SIZE 6 +#define SYN_RMI_NUM_PAGES 4 +#define SYN_RMI_F30 0x30 +#define SYN_RMI_F30_HAS_LED BIT(2) +#define SYN_RMI_F30_HAS_GPIO BIT(3) +#define SYN_RMI_LED_BRIGHTNESS 0x0b/* as set by HP's Windows driver */ + +static int synaptics_rmi_write (struct psmouse *psmouse,u8 reg,u8 val) +{ +struct ps2dev *ps2dev = &psmouse->ps2dev; +int error; + + error =ps2_command (ps2dev,NULL ,PSMOUSE_CMD_SETSCALE21 ); +if (error) +return error; + + error =ps2_command (ps2dev, ®,PSMOUSE_CMD_SETRATE ); +if (error) +return error; + +return ps2_command (ps2dev, &val,PSMOUSE_CMD_SETRATE ); +} + +static int synaptics_rmi_read (struct psmouse *psmouse,u8 reg,u8 *val) +{ +struct ps2dev *ps2dev = &psmouse->ps2dev; +u8 param[3 ]; +int error; + + error =ps2_command (ps2dev,NULL ,PSMOUSE_CMD_SETSCALE21 ); +if (error) +return error; + + error =ps2_command (ps2dev, ®,PSMOUSE_CMD_SETRATE ); +if (error) +return error; + + error =ps2_command (ps2dev, param,PSMOUSE_CMD_GETINFO ); +if (error) +return error; + + *val = param[0 ]; +return 0 ; +} + +/* Finds the LED of RMI function $30. Leaves the touchpad in RMI mode. */ +static int synaptics_rmi_led_probe (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; +u8 fn, query, ctrl, caps, count, gpios; +unsigned int page, zeros, i; +int addr, error; + + error =synaptics_mode_cmd (psmouse,SYN_RMI_MODE ); +if (error) +return error; + +for (page =0 ; page <SYN_RMI_NUM_PAGES ; page++) { + error =synaptics_rmi_write (psmouse,SYN_RMI_PAGE_SELECT , page); +if (error) +return error; + +for (addr =SYN_RMI_PDT_START ; addr >=SYN_RMI_PDT_END ; + addr -=SYN_RMI_PDT_ENTRY_SIZE ) { + error =synaptics_rmi_read (psmouse, addr, &fn); +if (error) +return error; +if (!fn) +break ; +if (fn !=SYN_RMI_F30 ) +continue ; + + error =synaptics_rmi_read (psmouse, addr -5 , &query); +if (!error) + error =synaptics_rmi_read (psmouse, addr -3 , &ctrl); +if (!error) + error =synaptics_rmi_read (psmouse, query, &caps); +if (!error) + error =synaptics_rmi_read (psmouse, query +1 , &count); +if (error) +return error; + +if (!(caps &SYN_RMI_F30_HAS_LED )) +return -ENODEV ; + + priv->rmi_led_page = page; +if (!(caps &SYN_RMI_F30_HAS_GPIO )) { + priv->rmi_led_mask =BIT (0 ); + priv->rmi_led_ctrl = ctrl +1 ; + priv->rmi_led_brightness = ctrl +4 ; +return 0 ; + } + +/* GPIO/LED select: the LED is the first set bit */ + error =synaptics_rmi_read (psmouse, ctrl, &gpios); +if (error) +return error; + + priv->rmi_led_mask =0 ; +for (i =0 , zeros =0 ; i <min (count,8 ); i++) { +if (!(gpios &BIT (i))) + zeros++; +else if (!priv->rmi_led_mask) + priv->rmi_led_mask =BIT (i); + } +if (!priv->rmi_led_mask) +return -ENODEV ; + + priv->rmi_led_ctrl = ctrl +4 ; + priv->rmi_led_brightness = ctrl +7 + zeros; +return 0 ; + } + } + +return -ENODEV ; +} + +/* Sets the LED. Leaves the touchpad in RMI mode. */ +static int __synaptics_rmi_led_set (struct psmouse *psmouse,bool on) +{ +struct synaptics_data *priv = psmouse->private; +u8 val; +int error; + + error =synaptics_mode_cmd (psmouse,SYN_RMI_MODE ); +if (error) +return error; + + error =synaptics_rmi_write (psmouse,SYN_RMI_PAGE_SELECT , priv->rmi_led_page); +if (error) +return error; + +if (on) { + error =synaptics_rmi_write (psmouse, priv->rmi_led_brightness, +SYN_RMI_LED_BRIGHTNESS ); +if (error) +return error; + } + + error =synaptics_rmi_read (psmouse, priv->rmi_led_ctrl, &val); +if (error) +return error; + + val = on ? val | priv->rmi_led_mask : val & ~priv->rmi_led_mask; +return synaptics_rmi_write (psmouse, priv->rmi_led_ctrl, val); +} + +static int synaptics_set_mode (struct psmouse *psmouse); + +static int synaptics_rmi_led_set (struct led_classdev *led, +enum led_brightness value) +{ + struct synaptics_data *priv = container_of(led, struct synaptics_data, rmi_led); +struct psmouse *psmouse = priv->psmouse; +int error, ret; + +guard (mutex)(&priv->rmi_led_lock); + +if (psmouse->state !=PSMOUSE_ACTIVATED ) +return -EBUSY ; + + error =psmouse_deactivate (psmouse); +if (error) +return error; + + ret =__synaptics_rmi_led_set (psmouse, value !=LED_OFF ); + +/* Setting the mode byte again leaves RMI access */ + error =synaptics_set_mode (psmouse); +if (!ret) + ret = error; + + error =psmouse_activate (psmouse); +return ret ?: error; +} + +static void synaptics_rmi_led_init (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; + +if (!IS_REACHABLE (CONFIG_LEDS_CLASS ) || + !psmouse_matches_pnp_id (psmouse, rmi_led_pnp_ids)) +return ; + +if (synaptics_rmi_led_probe (psmouse)) +return ; + +psmouse_info (psmouse,"touchpad LED on RMI F30 (page %u, ctrl %#x, mask %#x)\n" , + priv->rmi_led_page, priv->rmi_led_ctrl, priv->rmi_led_mask); +__synaptics_rmi_led_set (psmouse, false); + priv->has_rmi_led = true; +} + +static void synaptics_rmi_led_register (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; +int error; + +if (!priv->has_rmi_led) +return ; + +mutex_init (&priv->rmi_led_lock); + priv->psmouse = psmouse; + priv->rmi_led.name ="synaptics::touchpad_disabled" ; + priv->rmi_led.max_brightness =1 ; + priv->rmi_led.brightness_set_blocking = synaptics_rmi_led_set; + error =led_classdev_register (&psmouse->ps2dev.serio->dev, &priv->rmi_led); +if (error) { +psmouse_warn (psmouse,"failed to register touchpad LED: %d\n" , error); + priv->has_rmi_led = false; + } +} +static int synaptics_set_mode (struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private;
@@ -1444,6 +1674,9 @@ static void synaptics_disconnect(struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private; +if (priv->has_rmi_led) +led_classdev_unregister (&priv->rmi_led); +/* * We might have left a breadcrumb when trying to * set up SMbus companion.
@@ -1496,6 +1729,10 @@ static int synaptics_reconnect(struct psmouse *psmouse)return error; } +/* The reset turned the LED off; the mode byte below leaves RMI access. */ +if (priv->has_rmi_led && priv->rmi_led.brightness) +__synaptics_rmi_led_set (psmouse, true); + error =synaptics_set_mode (psmouse);if (error) {psmouse_err (psmouse,"Unable to initialize device.\n" );
@@ -1616,6 +1853,8 @@ static int synaptics_init_ps2(struct psmouse *psmouse,*/ priv->is_forcepad =psmouse_matches_pnp_id (psmouse, forcepad_pnp_ids); +synaptics_rmi_led_init (psmouse); + err =synaptics_set_mode (psmouse);if (err) {psmouse_err (psmouse,"Unable to initialize device.\n" );
@@ -1693,6 +1932,8 @@ static int synaptics_init_ps2(struct psmouse *psmouse, } } +synaptics_rmi_led_register (psmouse); +return 0 ; init_fail:
drivers/input/mouse/synaptics.h +13 -0
@@ -6,6 +6,9 @@#ifndef _SYNAPTICS_H#define _SYNAPTICS_H +#include <linux/leds.h> +#include <linux/mutex.h> +/* synaptics queries */ #define SYN_QUE_IDENTIFY 0x00#define SYN_QUE_MODES 0x01
@@ -202,6 +205,16 @@ struct synaptics_data {bool press;bool report_press;bool is_forcepad; + +/* Touchpad LED on RMI function $30, reached over PS/2 */ +struct psmouse *psmouse; +struct led_classdev rmi_led; +struct mutex rmi_led_lock; +bool has_rmi_led; +u8 rmi_led_page; +u8 rmi_led_ctrl; +u8 rmi_led_mask; +u8 rmi_led_brightness; };void synaptics_module_init (void );
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] Input: synaptics: LED unregister in synaptics_disconnect() fails with -EBUSY - [Medium] Input…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Input: synaptics: LED unregister in synaptics_disconnect() fails with -EBUSY
- [Medium] Input: synaptics: missing psmouse_mutex locking in synaptics_rmi_led_set()
- [Medium] Input: synaptics: synaptics_rmi_led_set() clears SYN_BIT_FOUR_BYTE_CLIENT
- [Low] Input: synaptics: link failure when CONFIG_LEDS_CLASS is not reachable --
commit 2ccb85e9eccb48086da73fe8acd02267ab779ff1
Author: ahmad baghereslami <[email protected]>
Input: synaptics - support the touchpad LED on RMI function $30
This commit adds support for the touchpad disabled LED wired to RMI function $30 on certain HP laptops (such as the HP ZBook 17 G3) by accessing RMI registers over PS/2 using mode byte 0x7f. It probes F30 during PS/2 initialization, registers an LED class device, and restores the LED state on reconnect.
Quoted 4 lines
drivers/input/mouse/synaptics.c +0
-0
[ ... ]
Quoted 7 lines
drivers/input/mouse/synaptics.c +7
-0+static int synaptics_rmi_led_set (struct led_classdev *led, +enum led_brightness value) +{ + struct synaptics_data *priv = container_of(led, struct synaptics_data, rmi_led); +struct psmouse *psmouse = priv->psmouse; +int error, ret; +
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 774
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+guard (mutex)(&priv->rmi_led_lock); + +if (psmouse->state !=PSMOUSE_ACTIVATED ) +return -EBUSY ; + + error =psmouse_deactivate (psmouse); +if (error) +return error; + + ret =__synaptics_rmi_led_set (psmouse, value !=LED_OFF );
[Severity: Medium]
Should synaptics_rmi_led_set() synchronize with psmouse_mutex rather than a private rmi_led_lock?
In drivers/input/mouse/psmouse-base.c, psmouse_mutex serializes all paths that inspect or transition psmouse->state, activate or deactivate a device or pass-through parent port, or run multi-command PS/2 sequences (such as psmouse_reconnect(), psmouse_resync(), psmouse_cleanup(), psmouse_disconnect(), and psmouse_attr_set_helper()). Meanwhile, ps2_command() only holds ps2dev->cmd_mutex for one PS/2 command at a time, and nothing else in synaptics.c (including synaptics_reconnect()) or psmouse-base.c takes priv->rmi_led_lock.
When synaptics_rmi_led_set() runs asynchronously from set_brightness_work without holding psmouse_mutex:
1. While __synaptics_rmi_led_set() has the touchpad in mode 0x7f across multiple SetScale 2:1, SetRate, and GetInfo commands, concurrent PS/2 commands from reconnect, resync, sysfs attribute writes (such as synaptics_set_rate() or synaptics_set_disable_gesture()), or pass-through port operations can interleave and corrupt both the RMI register sequence and the concurrent operation.
2. At the end of synaptics_rmi_led_set(), psmouse_activate(psmouse) unconditionally sends the enable command and sets psmouse->state to activated, even if a concurrent thread holding psmouse_mutex (such as pass-through child probing, reconnect, cleanup, or disconnect) has deactivated the touchpad and expects it to stay in command or initializing mode.
3. If set_brightness_work runs while a sysfs write or pass-through operation temporarily places psmouse->state into command mode, or right after synaptics_rmi_led_register() before psmouse_connect() activates the device, synaptics_rmi_led_set() immediately returns -EBUSY instead of waiting for the state transition to finish.
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 783
Quoted 9 lines
drivers/input/mouse/synaptics.c +9
-0+ +/* Setting the mode byte again leaves RMI access */ + error =synaptics_set_mode (psmouse); +if (!ret) + ret = error; + + error =psmouse_activate (psmouse); +return ret ?: error; +}
[Severity: Medium]
Will calling synaptics_set_mode() here clobber the 4-byte client bit in priv->mode when a pass-through guest device is attached?
When a 4-byte protocol child is activated on the pass-through port, synaptics_pt_activate() updates priv->mode:
drivers/input/mouse/synaptics.c:synaptics_pt_activate() {
...
if (child) {
if (child->pktsize == 4)
priv->mode |= SYN_BIT_FOUR_BYTE_CLIENT;
else
priv->mode &= ~SYN_BIT_FOUR_BYTE_CLIENT;
if (synaptics_mode_cmd(psmouse, priv->mode))
psmouse_warn(psmouse,
"failed to switch guest protocol\n");
}
}Other runtime mode updates such as synaptics_set_rate() and synaptics_set_disable_gesture() modify priv->mode in place and call synaptics_mode_cmd(psmouse, priv->mode). By contrast, synaptics_set_mode() resets priv->mode = 0 and rebuilds it without SYN_BIT_FOUR_BYTE_CLIENT, which will clear that bit in hardware whenever the LED brightness is changed.
Quoted 27 lines
drivers/input/mouse/synaptics.c +27
-0+ +static void synaptics_rmi_led_init (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; + +if (!IS_REACHABLE (CONFIG_LEDS_CLASS ) || + !psmouse_matches_pnp_id (psmouse, rmi_led_pnp_ids)) +return ; + +if (synaptics_rmi_led_probe (psmouse)) +return ; + +psmouse_info (psmouse,"touchpad LED on RMI F30 (page %u, ctrl %#x, mask %#x)\n" , + priv->rmi_led_page, priv->rmi_led_ctrl, priv->rmi_led_mask); +__synaptics_rmi_led_set (psmouse, false); + priv->has_rmi_led = true; +} + +static void synaptics_rmi_led_register (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; +int error; + +if (!priv->has_rmi_led) +return ; + +mutex_init (&priv->rmi_led_lock);
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 820
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+ priv->psmouse = psmouse; + priv->rmi_led.name ="synaptics::touchpad_disabled" ; + priv->rmi_led.max_brightness =1 ; + priv->rmi_led.brightness_set_blocking = synaptics_rmi_led_set; + error =led_classdev_register (&psmouse->ps2dev.serio->dev, &priv->rmi_led); +if (error) { +psmouse_warn (psmouse,"failed to register touchpad LED: %d\n" , error); + priv->has_rmi_led = false; + } +}
[Severity: Low]
Can this cause a link failure when CONFIG_LEDS_CLASS is disabled, or when psmouse is built-in and CONFIG_LEDS_CLASS=m?
In drivers/input/mouse/Kconfig, MOUSE_PS2_SYNAPTICS does not depend on or select LEDS_CLASS, and include/linux/leds.h declares led_classdev_register_ext() and led_classdev_unregister() unconditionally without inline stubs when CONFIG_LEDS_CLASS is not enabled.
Because synaptics_rmi_led_init() checks IS_REACHABLE(CONFIG_LEDS_CLASS), whereas synaptics_rmi_led_register() and synaptics_disconnect() only check the runtime struct field priv->has_rmi_led after priv is loaded from psmouse->private across function calls, the compiler cannot fold priv->has_rmi_led to a compile-time constant false and eliminate the calls to led_classdev_register() and led_classdev_unregister().
drivers/input/mouse/synaptics.c static void synaptics_disconnect(struct psmouse *psmouse) · line 1678
Quoted 10 lines
drivers/input/mouse/synaptics.c +3
-0+static int synaptics_set_mode (struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private;@@ -1444,6 +1674,9 @@ static void synaptics_disconnect(struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private; +if (priv->has_rmi_led) +led_classdev_unregister (&priv->rmi_led);
[Severity: Medium]
When synaptics_disconnect() calls led_classdev_unregister(&priv->rmi_led), will the shutdown brightness update always fail with -EBUSY?
Every caller of psmouse->disconnect(psmouse) in drivers/input/mouse/psmouse-base.c transitions psmouse->state to command mode before invoking the disconnect callback:
drivers/input/mouse/psmouse-base.c:psmouse_disconnect() {
...
psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
...
if (psmouse->disconnect)
psmouse->disconnect(psmouse);
}Because LED_RETAIN_AT_SHUTDOWN is not set on priv->rmi_led.flags, led_classdev_unregister() calls led_set_brightness(&priv->rmi_led, LED_OFF) and flushes set_brightness_work:
led_classdev_unregister()
-> led_set_brightness(&priv->rmi_led, LED_OFF) -> flush_work(&priv->rmi_led.set_brightness_work)
-> set_brightness_delayed()
-> synaptics_rmi_led_set()Inside synaptics_rmi_led_set(), the check:
if (psmouse->state != PSMOUSE_ACTIVATED) return -EBUSY;
sees PSMOUSE_CMD_MODE and returns -EBUSY, causing set_brightness_delayed_set_brightness() to log a kernel error and leaving the hardware LED lit if it was on before disconnect.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
kernel test robot
build botkernel test robot noticed the following build errors:
Hi ahmad,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus hid/for-next linus/master v7.3 next-20261029] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/ahmad-baghereslami/Input-synaptics-support-the-touchpad-LED-on-RMI-function-30/20261030-103821 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next patch link: https://lore.kernel.org/r/20261030070821.1716595-1-ahmad.b1995%40gmail.com patch subject: [PATCH] Input: synaptics - support the touchpad LED on RMI function $30 config: um-randconfig-1000-20261031 (https://download.01.org/0day-ci/archive/20261031/[email protected]/config) compiler: gcc-12 (Debian 12.4.0-5) 12.4.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
/usr/bin/ld: drivers/input/mouse/synaptics.o: in function `synaptics_disconnect':
>> synaptics.c:(.text+0x22dc): undefined reference to `led_classdev_unregister' /usr/bin/ld: drivers/input/mouse/synaptics.o: in function `synaptics_init_ps2': >> synaptics.c:(.text+0x406d): undefined reference to `led_classdev_register_ext'
collect2: error: ld returned 1 exit status
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi ahmad,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus hid/for-next linus/master v7.3 next-20261030] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/ahmad-baghereslami/Input-synaptics-support-the-touchpad-LED-on-RMI-function-30/20261030-103821 base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next patch link: https://lore.kernel.org/r/20261030070821.1716595-1-ahmad.b1995%40gmail.com patch subject: [PATCH] Input: synaptics - support the touchpad LED on RMI function $30 config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20261031/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
/usr/bin/ld: drivers/input/mouse/synaptics.o: in function `synaptics_disconnect':
>> drivers/input/mouse/synaptics.c:1678:(.text+0x3ec): undefined reference to `led_classdev_unregister' /usr/bin/ld: drivers/input/mouse/synaptics.o: in function `led_classdev_register': >> include/linux/leds.h:274:(.text+0x12c9): undefined reference to `led_classdev_register_ext'
collect2: error: ld returned 1 exit status
vim +1678 drivers/input/mouse/synaptics.c
1668
1669 PSMOUSE_DEFINE_ATTR(disable_gesture, S_IWUSR | S_IRUGO, NULL,
1670 synaptics_show_disable_gesture,
1671 synaptics_set_disable_gesture);
1672
1673 static void synaptics_disconnect(struct psmouse *psmouse)
1674 {
1675 struct synaptics_data *priv = psmouse->private;
1676
1677 if (priv->has_rmi_led)
> 1678 led_classdev_unregister(&priv->rmi_led);
1679
1680 /*
1681 * We might have left a breadcrumb when trying to
1682 * set up SMbus companion.
1683 */
1684 psmouse_smbus_cleanup(psmouse);
1685
1686 if (!priv->absolute_mode &&
1687 SYN_ID_DISGEST_SUPPORTED(priv->info.identity))
1688 device_remove_file(&psmouse->ps2dev.serio->dev,
1689 &psmouse_attr_disable_gesture.dattr);
1690
1691 synaptics_reset(psmouse);
1692 kfree(priv);
1693 psmouse->private = NULL;
1694 }
1695
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH v2 1/1 Input: synaptics - support the touchpad LED on RMI function $30
In reply to ahmad baghereslamiSome HP laptops have an LED in the top left corner of the Synaptics touchpad that HP's Windows driver lights while the touchpad is disabled (double tap on that corner). On the HP ZBook 17 G3 (SYN3040, TM2706-002) the LED is not driven through the PS/2 deluxe LED command: the Windows driver (SynTP.sys 19.0.19.68) switches the touchpad to RMI register access over PS/2 with mode byte 0x7f, looks up function $30 (GPIO/LED) in the page description table and sets the LED bit in its control register:
register write: SetScale 2:1, SetRate <reg>, SetRate <value>
register read: SetScale 2:1, SetRate <reg>, GetInfo (first byte)
For touchpads in a new rmi_led_pnp_ids list, look up the F30 LED this way when the touchpad is set up and register a synaptics::touchpad_disabled LED class device. Setting it queues a work item that, with psmouse_mutex held like the protected psmouse attributes, deactivates the touchpad, writes the F30 registers and restores the mode byte, which leaves RMI access. synaptics_disconnect() cancels the work with psmouse_mutex held, so the work only tries to take the mutex and retries later when it is busy. psmouse_mutex is no longer static so that synaptics.c can take it. The LED is restored after reconnect.
On this touchpad F30 is on page 1 with control base 0x55 and four GPIO/LED pins; the LED is bit 3 of control register 0x59 and its brightness register is 0x5f.
Tested on an HP ZBook 17 G3 with Ubuntu's 7.0.0 kernel: the LED follows writes to its brightness file, the touchpad and the pointing stick keep working, and a userspace helper that turns the touchpad off on a double tap in the corner keeps the LED in step with GNOME's touchpad setting.
Reading HP's Windows driver (Ghidra) and writing this patch were done with the help of an AI coding assistant (Claude); I tested the LED and the touchpad on the machine.
---
Notes:
v2:
- Fix the link failure reported by the kernel test robot when CONFIG_LEDS_CLASS is not reachable: the register and unregister calls are now behind IS_REACHABLE(CONFIG_LEDS_CLASS).
- Set the LED from a work item that holds psmouse_mutex instead of a private mutex, so it cannot interleave with reconnect, resync or attribute writes (sashiko review). The work uses mutex_trylock() and retries, because synaptics_disconnect() cancels it with psmouse_mutex held. If you would rather have this done another way, for example a helper in psmouse-base.c instead of exporting psmouse_mutex to the protocol code, I am happy to change it.
- Restore the mode with synaptics_mode_cmd(psmouse, priv->mode) instead of synaptics_set_mode(), so SYN_BIT_FOUR_BYTE_CLIENT survives (sashiko).
- Set LED_RETAIN_AT_SHUTDOWN: synaptics_disconnect() resets the touchpad, which turns the LED off, so unregistering no longer calls into the driver with the touchpad in command mode (sashiko).
- Mask the F30 GPIO/LED count with 0x1f and give up on more than eight pins (sashiko). The brightness register offset still counts every GPIO pin, not only those below the LED: the brightness registers come after one register per GPIO pin, which is how HP's driver computes it and what this touchpad needs (three GPIO pins, brightness at 0x5f).
v1: https://lore.kernel.org/all/[email protected]/
drivers/input/mouse/psmouse-base.c | 2 +- drivers/input/mouse/psmouse.h | 3 + drivers/input/mouse/synaptics.c | 282 +++++++++++++++++++++++++++++ drivers/input/mouse/synaptics.h | 13 ++ 4 files changed, 299 insertions(+), 1 deletion(-)
drivers/input/mouse/psmouse-base.c +1 -1
@@ -111,7 +111,7 @@ ATTRIBUTE_GROUPS(psmouse_dev);* rarely more than one PS/2 mouse connected and since semaphore * is taken in "slow" paths it is not worth it. */ -static DEFINE_MUTEX (psmouse_mutex); +DEFINE_MUTEX (psmouse_mutex);struct psmouse *psmouse_from_serio (struct serio *serio) {
drivers/input/mouse/psmouse.h +3 -0
@@ -136,6 +136,9 @@ int psmouse_reset(struct psmouse *psmouse);void psmouse_set_state (struct psmouse *psmouse,enum psmouse_state new_state);void psmouse_set_resolution (struct psmouse *psmouse,unsigned int resolution);psmouse_ret_t psmouse_process_byte (struct psmouse *psmouse); +/* Serializes connecting, reconnecting and reconfiguring PS/2 mice */ +extern struct mutex psmouse_mutex; +int psmouse_activate (struct psmouse *psmouse);int psmouse_deactivate (struct psmouse *psmouse);bool psmouse_matches_pnp_id (struct psmouse *psmouse,const char *const ids[]);
drivers/input/mouse/synaptics.c +282 -0
312 lines not on this page · raw message
drivers/input/mouse/synaptics.h +13 -0
@@ -6,6 +6,9 @@#ifndef _SYNAPTICS_H#define _SYNAPTICS_H +#include <linux/leds.h> +#include <linux/workqueue.h> +/* synaptics queries */ #define SYN_QUE_IDENTIFY 0x00#define SYN_QUE_MODES 0x01
@@ -202,6 +205,16 @@ struct synaptics_data {bool press;bool report_press;bool is_forcepad; + +/* Touchpad LED on RMI function $30, reached over PS/2 */ +struct psmouse *psmouse; +struct led_classdev rmi_led; +struct delayed_work rmi_led_work; +bool has_rmi_led; +u8 rmi_led_page; +u8 rmi_led_ctrl; +u8 rmi_led_mask; +u8 rmi_led_brightness; };void synaptics_module_init (void );
base-commit: 97a889cad5dd8ff83f40514f2d67c565c0dc54b1
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] Input: synaptics - touchpad LED left on after synaptics_disconnect() - [Medium] Input: synaptics…
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [Medium] Input: synaptics - touchpad LED left on after synaptics_disconnect()
- [Medium] Input: synaptics - synaptics_rmi_led_set() ignores brightness value
- [Low] Input: synaptics - deprecated system_wq used in synaptics_rmi_led_set()
- [Low] Input: synaptics - non-standard error return style in RMI LED helpers
--
commit 8709ca284d49e5eecf9c3bb3b076159f75f00824
Author: ahmad baghereslami <[email protected]>
Input: synaptics - support the touchpad LED on RMI function $30
This commit adds support for the touchpad LED wired to RMI function $30 over PS/2 on HP laptops such as the HP ZBook 17 G3.
Quoted 5 lines
drivers/input/mouse/synaptics.c +0
-0@@ -589,6 +589,278 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
[ ... ]
Quoted 15 lines
drivers/input/mouse/synaptics.c +15
-0+static int synaptics_rmi_write (struct psmouse *psmouse,u8 reg,u8 val) +{ +struct ps2dev *ps2dev = &psmouse->ps2dev; +int error; + + error =ps2_command (ps2dev,NULL ,PSMOUSE_CMD_SETSCALE21 ); +if (error) +return error; + + error =ps2_command (ps2dev, ®,PSMOUSE_CMD_SETRATE ); +if (error) +return error; + +return ps2_command (ps2dev, &val,PSMOUSE_CMD_SETRATE ); +}
[ ... ]
Quoted 19 lines
drivers/input/mouse/synaptics.c +19
-0+/* Sets the LED. Leaves the touchpad in RMI mode. */ +static int __synaptics_rmi_led_set (struct psmouse *psmouse,bool on) +{ +struct synaptics_data *priv = psmouse->private; +u8 val; +int error; + + error =synaptics_mode_cmd (psmouse,SYN_RMI_MODE ); +if (error) +return error; + + error =synaptics_rmi_write (psmouse,SYN_RMI_PAGE_SELECT , priv->rmi_led_page); +if (error) +return error; + +if (on) { + error =synaptics_rmi_write (psmouse, priv->rmi_led_brightness, +SYN_RMI_LED_BRIGHTNESS ); +if (error)
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 761
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+return error; + } + + error =synaptics_rmi_read (psmouse, priv->rmi_led_ctrl, &val); +if (error) +return error; + + val = on ? val | priv->rmi_led_mask : val & ~priv->rmi_led_mask; +return synaptics_rmi_write (psmouse, priv->rmi_led_ctrl, val); +}
[Severity: Low]
This isn't a bug, but in input subsystem functions that have multiple failure points using an error variable, the preferred style for the final call is to assign to error, check if (error) return error, and explicitly return 0 on the success path in both synaptics_rmi_write() and __synaptics_rmi_led_set().
Quoted 41 lines
drivers/input/mouse/synaptics.c +41
-0+ +/* +* Runs with psmouse_mutex held, like the protected psmouse attributes, so +* that it does not race with reconnect, resync or attribute changes. +* synaptics_disconnect() cancels it with psmouse_mutex held, so it must not +* wait for the mutex: when it is busy, try again a little later. +*/ +static void synaptics_rmi_led_work (struct work_struct *work) +{ +struct synaptics_data *priv =container_of (to_delayed_work (work), + struct synaptics_data, + rmi_led_work); +struct psmouse *psmouse = priv->psmouse; +int error; + +if (!mutex_trylock (&psmouse_mutex)) { +schedule_delayed_work (&priv->rmi_led_work, +msecs_to_jiffies (SYN_RMI_LED_RETRY_MS )); +return ; + } + +if (psmouse->state ==PSMOUSE_RESYNCING ) { +schedule_delayed_work (&priv->rmi_led_work, +msecs_to_jiffies (SYN_RMI_LED_RETRY_MS )); + }else if (psmouse->state ==PSMOUSE_ACTIVATED ) { +/* Otherwise the LED is restored on reconnect */ +psmouse_deactivate (psmouse); + + error =__synaptics_rmi_led_set (psmouse, + priv->rmi_led.brightness !=LED_OFF ); +if (error) +psmouse_warn (psmouse, +"failed to set touchpad LED: %d\n" , error); + +/* Setting the mode byte again leaves RMI access */ +if (synaptics_mode_cmd (psmouse, priv->mode)) +psmouse_warn (psmouse,"failed to restore mode\n" ); + +psmouse_activate (psmouse); + } +
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 812
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+mutex_unlock (&psmouse_mutex); +} + +static void synaptics_rmi_led_set (struct led_classdev *led, +enum led_brightness value) +{ + struct synaptics_data *priv = container_of(led, struct synaptics_data, rmi_led); + +mod_delayed_work (system_wq, &priv->rmi_led_work,0 ); +}
[Severity: Medium]
Can ignoring the value argument in synaptics_rmi_led_set() leave the LED stuck on when software blinking is disabled?
When led_set_brightness(led_cdev, LED_OFF) is called while software blinking (LED_BLINK_SW) is active, set_brightness_delayed() stops blinking and invokes brightness_set(led_cdev, LED_OFF) without updating led_cdev->brightness:
drivers/leds/led-core.c:set_brightness_delayed() {
if (test_and_clear_bit(LED_BLINK_DISABLE, &led_cdev->work_flags)) {
led_stop_software_blink(led_cdev);
set_bit(LED_SET_BRIGHTNESS_OFF, &led_cdev->work_flags);
}
...
if (test_and_clear_bit(LED_SET_BRIGHTNESS_OFF, &led_cdev->work_flags))
set_brightness_delayed_set_brightness(led_cdev, LED_OFF);
}If the blink timer last left priv->rmi_led.brightness at 1, synaptics_rmi_led_work() (and synaptics_reconnect()) will read that stale value instead of LED_OFF and keep the LED lit.
[Severity: Low]
Also in synaptics_rmi_led_set(), system_wq is deprecated and scheduled for removal; please use system_percpu_wq in mod_delayed_work() instead.
[ ... ]
Quoted 37 lines
drivers/input/mouse/synaptics.c +33
-0+static void synaptics_rmi_led_register (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; +int error; + +if (!IS_REACHABLE (CONFIG_LEDS_CLASS ) || !priv->has_rmi_led) +return ; + + priv->psmouse = psmouse; +INIT_DELAYED_WORK (&priv->rmi_led_work, synaptics_rmi_led_work); + priv->rmi_led.name ="synaptics::touchpad_disabled" ; + priv->rmi_led.max_brightness =1 ; + priv->rmi_led.brightness_set = synaptics_rmi_led_set; +/* synaptics_disconnect() resets the touchpad, which turns the LED off */ + priv->rmi_led.flags =LED_RETAIN_AT_SHUTDOWN ; + error =led_classdev_register (&psmouse->ps2dev.serio->dev, &priv->rmi_led); +if (error) { +psmouse_warn (psmouse,"failed to register touchpad LED: %d\n" , error); + priv->has_rmi_led = false; + } +} + +static void synaptics_rmi_led_unregister (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; + +if (!IS_REACHABLE (CONFIG_LEDS_CLASS ) || !priv->has_rmi_led) +return ; + +led_classdev_unregister (&priv->rmi_led); +cancel_delayed_work_sync (&priv->rmi_led_work); +} +static int synaptics_set_mode (struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private;
drivers/input/mouse/synaptics.c static void synaptics_disconnect(struct psmouse *psmouse) · line 1723
Quoted 8 lines
drivers/input/mouse/synaptics.c +2
-0@@ -1444,6 +1716,8 @@ static void synaptics_disconnect(struct psmouse *psmouse) {struct synaptics_data *priv = psmouse->private; +synaptics_rmi_led_unregister (psmouse); +/* * We might have left a breadcrumb when trying to * set up SMbus companion.
[Severity: Medium]
Does synaptics_disconnect() leave the touchpad LED lit in hardware if it was on when the driver disconnects?
Because LED_RETAIN_AT_SHUTDOWN is set, led_classdev_unregister() does not turn the LED off, and any pending rmi_led_work is canceled before it can acquire psmouse_mutex. Unlike synaptics_reconnect(), which calls psmouse_reset(), synaptics_disconnect() only calls synaptics_reset():
drivers/input/mouse/synaptics.c:synaptics_reset() {
/* reset touchpad back to relative mode, gestures enabled */
synaptics_mode_cmd(psmouse, 0);
}Writing mode byte 0 only leaves RMI register access mode without clearing the F30 LED control register, so the LED stays on after driver unbind, module unload, or a protocol switch. Calling __synaptics_rmi_led_set(psmouse, false) in synaptics_rmi_led_unregister() after cancel_delayed_work_sync() (before synaptics_reset() writes mode byte 0) would turn it off.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v3 1/1 Input: synaptics - support the touchpad LED on RMI function $30
In reply to ahmad baghereslamiSome HP laptops have an LED in the top left corner of the Synaptics touchpad that HP's Windows driver lights while the touchpad is disabled (double tap on that corner). On the HP ZBook 17 G3 (SYN3040, TM2706-002) the LED is not driven through the PS/2 deluxe LED command: the Windows driver (SynTP.sys 19.0.19.68) switches the touchpad to RMI register access over PS/2 with mode byte 0x7f, looks up function $30 (GPIO/LED) in the page description table and sets the LED bit in its control register:
register write: SetScale 2:1, SetRate <reg>, SetRate <value>
register read: SetScale 2:1, SetRate <reg>, GetInfo (first byte)
For touchpads in a new rmi_led_pnp_ids list, look up the F30 LED this way when the touchpad is set up and register a synaptics::touchpad_disabled LED class device. Setting it queues a work item that, with psmouse_mutex held like the protected psmouse attributes, deactivates the touchpad, writes the F30 registers and restores the mode byte, which leaves RMI access. synaptics_disconnect() cancels the work with psmouse_mutex held, so the work only tries to take the mutex and retries later when it is busy. psmouse_mutex is no longer static so that synaptics.c can take it. The LED is restored after reconnect and turned off when the driver disconnects.
On this touchpad F30 is on page 1 with control base 0x55 and four GPIO/LED pins; the LED is bit 3 of control register 0x59 and its brightness register is 0x5f.
Tested on an HP ZBook 17 G3 with Ubuntu's 7.0.0 kernel: the LED follows writes to its brightness file, the touchpad and the pointing stick keep working, and a userspace helper that turns the touchpad off on a double tap in the corner keeps the LED in step with GNOME's touchpad setting.
Reading HP's Windows driver (Ghidra) and writing this patch were done with the help of an AI coding assistant (Claude); I tested the LED and the touchpad on the machine.
---
Notes:
v3:
- Turn the LED off in synaptics_disconnect(): mode byte 0 from synaptics_reset() leaves RMI access but does not clear the F30 LED register, so v2 left the LED lit after unbind or a protocol switch (sashiko).
- Keep the requested state in its own field, set from the brightness_set callback, instead of reading led_cdev->brightness, which the LED core does not update when it stops software blinking (sashiko).
- Use system_percpu_wq instead of system_wq (sashiko).
- Return 0 explicitly at the end of the RMI helpers (sashiko).
v2: https://lore.kernel.org/all/[email protected]/
v2:
- Fix the link failure reported by the kernel test robot when CONFIG_LEDS_CLASS is not reachable: the register and unregister calls are now behind IS_REACHABLE(CONFIG_LEDS_CLASS).
- Set the LED from a work item that holds psmouse_mutex instead of a private mutex, so it cannot interleave with reconnect, resync or attribute writes (sashiko review). The work uses mutex_trylock() and retries, because synaptics_disconnect() cancels it with psmouse_mutex held. If you would rather have this done another way, for example a helper in psmouse-base.c instead of exporting psmouse_mutex to the protocol code, I am happy to change it.
- Restore the mode with synaptics_mode_cmd(psmouse, priv->mode) instead of synaptics_set_mode(), so SYN_BIT_FOUR_BYTE_CLIENT survives (sashiko).
- Set LED_RETAIN_AT_SHUTDOWN: synaptics_disconnect() resets the touchpad, which turns the LED off, so unregistering no longer calls into the driver with the touchpad in command mode (sashiko).
- Mask the F30 GPIO/LED count with 0x1f and give up on more than eight pins (sashiko). The brightness register offset still counts every GPIO pin, not only those below the LED: the brightness registers come after one register per GPIO pin, which is how HP's driver computes it and what this touchpad needs (three GPIO pins, brightness at 0x5f).
v1: https://lore.kernel.org/all/[email protected]/
drivers/input/mouse/psmouse-base.c | 2 +- drivers/input/mouse/psmouse.h | 3 + drivers/input/mouse/synaptics.c | 298 +++++++++++++++++++++++++++++ drivers/input/mouse/synaptics.h | 14 ++ 4 files changed, 316 insertions(+), 1 deletion(-)
drivers/input/mouse/psmouse-base.c +1 -1
@@ -111,7 +111,7 @@ ATTRIBUTE_GROUPS(psmouse_dev);* rarely more than one PS/2 mouse connected and since semaphore * is taken in "slow" paths it is not worth it. */ -static DEFINE_MUTEX (psmouse_mutex); +DEFINE_MUTEX (psmouse_mutex);struct psmouse *psmouse_from_serio (struct serio *serio) {
drivers/input/mouse/psmouse.h +3 -0
@@ -136,6 +136,9 @@ int psmouse_reset(struct psmouse *psmouse);void psmouse_set_state (struct psmouse *psmouse,enum psmouse_state new_state);void psmouse_set_resolution (struct psmouse *psmouse,unsigned int resolution);psmouse_ret_t psmouse_process_byte (struct psmouse *psmouse); +/* Serializes connecting, reconnecting and reconfiguring PS/2 mice */ +extern struct mutex psmouse_mutex; +int psmouse_activate (struct psmouse *psmouse);int psmouse_deactivate (struct psmouse *psmouse);bool psmouse_matches_pnp_id (struct psmouse *psmouse,const char *const ids[]);
drivers/input/mouse/synaptics.c +298 -0
328 lines not on this page · raw message
drivers/input/mouse/synaptics.h +14 -0
@@ -6,6 +6,9 @@#ifndef _SYNAPTICS_H#define _SYNAPTICS_H +#include <linux/leds.h> +#include <linux/workqueue.h> +/* synaptics queries */ #define SYN_QUE_IDENTIFY 0x00#define SYN_QUE_MODES 0x01
@@ -202,6 +205,17 @@ struct synaptics_data {bool press;bool report_press;bool is_forcepad; + +/* Touchpad LED on RMI function $30, reached over PS/2 */ +struct psmouse *psmouse; +struct led_classdev rmi_led; +struct delayed_work rmi_led_work; +bool has_rmi_led; +bool rmi_led_on; +u8 rmi_led_page; +u8 rmi_led_ctrl; +u8 rmi_led_mask; +u8 rmi_led_brightness; };void synaptics_module_init (void );
base-commit: 97a889cad5dd8ff83f40514f2d67c565c0dc54b1
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] Input: synaptics - LED left on in synaptics_rmi_led_unregister() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] Input: synaptics - LED left on in synaptics_rmi_led_unregister()
--
commit 8aa89954a3d89d6d5994f705dc23ae6d58848db8
Author: ahmad baghereslami <[email protected]>
Input: synaptics - support the touchpad LED on RMI function $30
This commit adds support for the touchpad-disabled LED on Synaptics touchpads that expose RMI function $30 over PS/2, registering an LED class device and updating the hardware registers via a delayed work item under psmouse_mutex.
Quoted 5 lines
drivers/input/mouse/synaptics.c +0
-0@@ -589,6 +589,294 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
[ ... ]
Quoted 8 lines
drivers/input/mouse/synaptics.c +8
-0+static void synaptics_rmi_led_set (struct led_classdev *led, +enum led_brightness value) +{ + struct synaptics_data *priv = container_of(led, struct synaptics_data, rmi_led); + +WRITE_ONCE (priv->rmi_led_on, value !=LED_OFF ); +mod_delayed_work (system_percpu_wq, &priv->rmi_led_work,0 ); +}
[ ... ]
Quoted 7 lines
drivers/input/mouse/synaptics.c +7
-0+static void synaptics_rmi_led_unregister (struct psmouse *psmouse) +{ +struct synaptics_data *priv = psmouse->private; + +if (!IS_REACHABLE (CONFIG_LEDS_CLASS ) || !priv->has_rmi_led) +return ; +
drivers/input/mouse/synaptics.c static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) · line 878
Quoted 10 lines
drivers/input/mouse/synaptics.c +10
-0+led_classdev_unregister (&priv->rmi_led); +cancel_delayed_work_sync (&priv->rmi_led_work); + +/* +* The touchpad is in command mode here. Mode byte 0, which +* synaptics_reset() sets next, leaves RMI access but keeps the LED lit. +*/ +if (priv->rmi_led_on) +__synaptics_rmi_led_set (psmouse, false); +}
[Severity: Medium]
Can synaptics_rmi_led_unregister() leave the physical touchpad LED lit on disconnect?
synaptics_rmi_led_set() clears priv->rmi_led_on before synaptics_rmi_led_work() takes psmouse_mutex and updates the hardware register. Because synaptics_disconnect() runs with psmouse_mutex held, any LED_OFF request queued while the LED is lit cannot run its work item. For example, if a trigger is attached to the LED, led_classdev_unregister() detaches it before checking LED_RETAIN_AT_SHUTDOWN:
drivers/leds/led-class.c:led_classdev_unregister() {
...
#ifdef CONFIG_LEDS_TRIGGERS
down_write(&led_cdev->trigger_lock);
if (led_cdev->trigger)
led_trigger_set(led_cdev, NULL);
up_write(&led_cdev->trigger_lock);
#endif
...
}led_trigger_set(led_cdev, NULL) calls led_set_brightness(led_cdev, LED_OFF), which invokes synaptics_rmi_led_set() and sets priv->rmi_led_on to false. cancel_delayed_work_sync() then cancels the pending work before it can write to the touchpad, and the check on priv->rmi_led_on is false, so __synaptics_rmi_led_set(psmouse, false) is skipped and the hardware LED stays on.
Calling __synaptics_rmi_led_set(psmouse, false) unconditionally in synaptics_rmi_led_unregister() (as synaptics_rmi_led_init() does), or tracking the committed hardware state separately from the requested state, would avoid this.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 6 lines · On Sat, 14 Nov 2026 09:24:32 +0000, [email protected] wrote:
led_trigger_set(led_cdev, NULL)callsled_set_brightness(led_cdev, LED_OFF), which invokessynaptics_rmi_led_set()and setspriv->rmi_led_onto false.cancel_delayed_work_sync()then cancels the pending work before it can write to the touchpad, and the check onpriv->rmi_led_onis false, so__synaptics_rmi_led_set(psmouse, false)is skipped and the hardware LED stays on.
Right. The same happens without a trigger when the brightness is set to 0 just before an unbind: the work cannot take psmouse_mutex, so it is cancelled before it reaches the touchpad.
v4 will turn the LED off in synaptics_rmi_led_unregister() whatever rmi_led_on says, as synaptics_rmi_led_init() does. I will wait a few days for other comments on v3 before sending it.
Thanks,
Ahmad
Dmitry Torokhov
maintainerHi Ahmad,
Quoted 9 lines · ahmad baghereslami
Some HP laptops have an LED in the top left corner of the Synaptics touchpad that HP's Windows driver lights while the touchpad is disabled (double tap on that corner). On the HP ZBook 17 G3 (SYN3040, TM2706-002) the LED is not driven through the PS/2 deluxe LED command: the Windows driver (SynTP.sys 19.0.19.68) switches the touchpad to RMI register access over PS/2 with mode byte
0x7f, looks up function $30 (GPIO/LED) in the page description table and sets the LED bit in its control register:
Quoted 6 lines
register write: SetScale 2:1, SetRate <reg>, SetRate <value>
register read: SetScale 2:1, SetRate <reg>, GetInfo (first byte)For touchpads in a new
rmi_led_pnp_idslist, look up the F30 LED this way when the touchpad is set up and register asynaptics::touchpad_disabledLED class device.
Why is this touchpad running in legacy PS/2 mode instead of native RMI4 mode over SMBus (InterTouch / rmi4_smbus)?
Could you please check if booting with psmouse.synaptics_intertouch=1 switches the touchpad (and the pointing stick via F03) to RMI4 over SMBus on the HP ZBook 17 G3?
If InterTouch works on this machine, we should add "SYN3040" to smbus_pnp_ids[] in drivers/input/mouse/synaptics.c and implement LED class support in drivers/input/rmi4/rmi_f30.c (which already parses f30->has_led and the F30 control register layout), rather than adding RMI4 PDT scanning and F30 register manipulation over the PS/2 command backdoor in the legacy PS/2 driver.
Thanks.
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 3 lines · Dmitry Torokhov
Could you please check if booting with psmouse.synaptics_intertouch=1 switches the touchpad (and the pointing stick via F03) to RMI4 over SMBus on the HP ZBook 17 G3?
Yes, it does. With psmouse.synaptics_intertouch=1 the touchpad binds as "Synaptics TM2706-002" through rmi4_smbus, and motion, taps, buttons, scrolling and the pointing stick (F03) all work.
The reason I kept it on PS/2 is a side effect on this laptop: the embedded controller turns the keyboard backlight back on when it sees PS/2 input after the backlight has timed out. Over SMBus the touchpad's traffic no longer passes through the EC, so touching the touchpad no longer wakes the keyboard backlight; only typing does. Nothing else differed in daily use.
If you still prefer the RMI4 route, I can send a series that adds "SYN3040" to smbus_pnp_ids[] and implements LED class support in rmi_f30.c, and drop the PS/2 backdoor. Or, if the backlight behaviour is a reason to keep this touchpad on PS/2, I would keep the current approach. Which would you prefer?
(Separately, sashiko found that v3 can leave the LED lit when a trigger is removed at unbind; I have a fix ready for whichever version comes next.)
Thanks,
Ahmad
Dmitry Torokhov
maintainerHi Ahmad,
On Mon, Nov 16, 2026 at 10:49:06AM +0330, ahmad baghereslami wrote:
...
Quoted 7 lines
The reason I kept it on PS/2 is a side effect on this laptop: the embedded controller turns the keyboard backlight back on when it sees PS/2 input after the backlight has timed out. Over SMBus the touchpad's traffic no longer passes through the EC, so touching the touchpad no longer wakes the keyboard backlight; only typing does. Nothing else differed in daily use.
Quoted 5 lines
If you still prefer the RMI4 route, I can send a series that adds "SYN3040" to smbus_pnp_ids[] and implements LED class support in
rmi_f30.c, and drop the PS/2 backdoor. Or, if the backlight behaviour is a reason to keep this touchpad on PS/2, I would keep the current approach. Which would you prefer?
I would definitely prefer the RMI4 route: adding "SYN3040" to smbus_pnp_ids[] and implementing LED class support in rmi_f30.c.
We already enable InterTouch on several other HP laptops in smbus_pnp_ids[], and implementing F30 LED support in rmi_f30.c benefits all RMI4 touchpads (over SMBus, I2C, SPI, or HID) without duplicating RMI4 PDT scanning and register access over the PS/2 command backdoor or having to deactivate the PS/2 stream and export psmouse_mutex on every LED update.
Keyboard backlight management should be handled separately from the touchpad transport: relying on the EC snooping legacy PS/2 traffic is just an incidental side effect (an external USB/Bluetooth mouse or an I2C-HID touchpad already bypasses the EC in the same way). Ideally the keyboard backlight is exposed as a standard LED class device by the HP platform driver (hp-wmi) and managed by userspace policy monitoring input activity, or (if an in-kernel mechanism is desired) driven by ledtrig-input-events (the "input-events" LED trigger) or an input observer in the platform driver.
Thanks.
Signature · 1 line
Dmitry