Skip to contentSkip to conversation

Input: elantech - fix fast_reconnect callback in ps2 mode

PATCH In review Jeffery Miller 4 participants 9 messages Oct 4, 2023 – Oct 12, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: elantech - fix fast_reconnect callback in ps2 mode

Make elantech_setup_ps2 set a compatible fast_reconnect pointer when its ps2 mode is used.

When an SMBus connection is attempted and fails psmouse_smbus_init sets fast_reconnect to psmouse_smbus_reconnect. psmouse_smbus_reconnect expects psmouse->private to be struct psmouse_smbus_dev but elantech_setup_ps2 replaces it with its private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in ps2, not SMBus mode.

This was uncovered by commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")

Closes:

---

The other callbacks set in psmouse_smbus_init are already replaced. Should fast_reconnect be set to elantech_reconnect instead?

 drivers/input/mouse/elantech.c | 1 +
 1 file changed, 1 insertion(+)
drivers/input/mouse/elantech.c +1 -0
index 2118b2075f43..4e38229404b4 100644
@@ -2114,6 +2114,7 @@ static int elantech_setup_ps2(struct psmouse *psmouse,
 	psmouse->protocol_handler = elantech_process_byte;
 	psmouse->disconnect = elantech_disconnect;
 	psmouse->reconnect = elantech_reconnect;
+	psmouse->fast_reconnect = NULL;
 	psmouse->pktsize = info->hw_version > 1 ? 6 : 4;
 
 	return 0;
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
maintainer Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jeffery Miller

Make elantech_setup_ps2 set a compatible fast_reconnect pointer when its ps2 mode is used.

When an SMBus connection is attempted and fails psmouse_smbus_init sets fast_reconnect to psmouse_smbus_reconnect. psmouse_smbus_reconnect expects psmouse->private to be struct psmouse_smbus_dev but elantech_setup_ps2 replaces it with its private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in ps2, not SMBus mode.

Quoted 2 lines

This was uncovered by commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")

Ahh, thx for investigating. This fixes things for me. Feel free to add:

Quoted 3 lines

Closes:

Side note: something went sideways here, it afaics should look something like this:

"""

Quoted 2 lines

Closes:

https://lore.kernel.org/all/[email protected]/
"""

Thx again. Ciao, Thorsten

#2 lore raw
In reply to Jeffery Miller
Quoted 15 lines · Jeffery Miller

Make elantech_setup_ps2 set a compatible fast_reconnect pointer when its ps2 mode is used.

When an SMBus connection is attempted and fails psmouse_smbus_init sets fast_reconnect to psmouse_smbus_reconnect. psmouse_smbus_reconnect expects psmouse->private to be struct psmouse_smbus_dev but elantech_setup_ps2 replaces it with its private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in ps2, not SMBus mode.

This was uncovered by commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")

Closes:

Quoted 8 lines

---

The other callbacks set in psmouse_smbus_init are already replaced. Should fast_reconnect be set to elantech_reconnect instead?

What commit id does this fix? Should it also have a cc: stable tag?

thanks,

greg k-h

#3 lore raw
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Jeffery Miller

Make elantech_setup_ps2 set a compatible fast_reconnect pointer when its ps2 mode is used.

When an SMBus connection is attempted and fails psmouse_smbus_init sets fast_reconnect to psmouse_smbus_reconnect. psmouse_smbus_reconnect expects psmouse->private to be struct psmouse_smbus_dev but elantech_setup_ps2 replaces it with its private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in ps2, not SMBus mode.

This was uncovered by commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")

Closes:

Quoted 7 lines
Quoted 5 lines

---

The other callbacks set in psmouse_smbus_init are already replaced. Should fast_reconnect be set to elantech_reconnect instead?

What commit id does this fix?

Good point, yes, it also needs this:

Fixes 92e24e0e57f72e ("Input: psmouse - add delay when deactivating for

SMBus mode")

Quoted 1 line

Should it also have a cc: stable tag?

Not that I can see, as that commit was merged for 6.6 and not backported (no idea why Jeffery CCed the stable list, maybe I'm missing something)

Ciao, Thorsten

#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 3 lines · Greg Kroah-Hartman

What commit id does this fix? Should it also have a cc: stable tag?

A crash was observed after commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode") which
is not in stable.
I don't think so. The underlying issue was introduced in commit 8eb92e5c9133 ("Input: psmouse - add support for SMBus companions") but wasn't causing a noticed problem.

maintainer
#5 lore raw
In reply to Jeffery Miller

Hi Jeffery,

Quoted 11 lines · Jeffery Miller

Make elantech_setup_ps2 set a compatible fast_reconnect pointer when its ps2 mode is used.

When an SMBus connection is attempted and fails psmouse_smbus_init sets fast_reconnect to psmouse_smbus_reconnect. psmouse_smbus_reconnect expects psmouse->private to be struct psmouse_smbus_dev but elantech_setup_ps2 replaces it with its private data. This was causing an issue on resume since psmouse_smbus_reconnect was being called while in ps2, not SMBus mode.

Quoted 2 lines

This was uncovered by commit 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")

Nice find, thank you.

Quoted 10 lines

Closes:

---

The other callbacks set in psmouse_smbus_init are already replaced. Should fast_reconnect be set to elantech_reconnect instead?

No, doing PS/2 Elantech reinitialization is not a "fast" operation, as it takes a while to communicate with/query the device, so we should not be using elantech_reconnect() as a "fast" reconnect handler.

In fact, now that I think about it more, we should rework the original patch that added the delay, so that we do not wait these 30 msec in the "fast" reconnect handler. It turns out your original approach was better, but we should not be using retries, but rather the existing reset_delay_ms already defined in rmi platform data. I would appreciate if you try the draft patch at the end of this email (to be applied after reverting your original one adding the delay in psmouse-smbus.c).

Quoted 10 lines

 drivers/input/mouse/elantech.c | 1 +
 1 file changed, 1 insertion(+)
drivers/input/mouse/elantech.c +0 -0
index 2118b2075f43..4e38229404b4 100644

drivers/input/mouse/elantech.c static int elantech_setup_ps2(struct psmouse *psmouse, · line 2117

Quoted 4 lines
drivers/input/mouse/elantech.c +1 -0
@@ -2114,6 +2114,7 @@ static int elantech_setup_ps2(struct psmouse *psmouse,
 	psmouse->protocol_handler = elantech_process_byte;
 	psmouse->disconnect = elantech_disconnect;
 	psmouse->reconnect = elantech_reconnect;
+	psmouse->fast_reconnect = NULL;

I think we need a similar change in synaptics.c as that one also can fall back to PS/2 mode.

Thanks!

---

drivers/input/mouse/synaptics.c +1 -0
index ada299ec5bba..6ccc4a099b51 100644
@@ -1752,6 +1752,7 @@ static int synaptics_create_intertouch(struct psmouse *psmouse,
 		psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) &&
 		!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10);
 	const struct rmi_device_platform_data pdata = {
+		.reset_delay_ms = 30,
 		.sensor_pdata = {
 			.sensor_type = rmi_sensor_touchpad,
 			.axis_align.flip_y = true,
drivers/input/rmi4/rmi_smbus.c +28 -22

76 lines not on this page · raw message

Signature · 1 line
Dmitry
#6 lore raw

Dmitry,

Quoted 8 lines · Dmitry Torokhov

In fact, now that I think about it more, we should rework the original patch that added the delay, so that we do not wait these 30 msec in the "fast" reconnect handler. It turns out your original approach was better, but we should not be using retries, but rather the existing reset_delay_ms already defined in rmi platform data. I would appreciate if you try the draft patch at the end of this email (to be applied after reverting your original one adding the delay in psmouse-smbus.c).

I tested the draft patch and it works. I did revert the previous delay patch while testing it.

Quoted 4 lines

I think we need a similar change in synaptics.c as that one also can fall back to PS/2 mode.

Ah, good point, yes it does appear this needs to be done as well. I have tested and will post an new version of the patch to include the fix in synaptics.c as well.

Thanks,
Jeff

#7 lore raw
Quoted 14 lines · Jeffery Miller
Quoted 8 lines · Dmitry Torokhov

In fact, now that I think about it more, we should rework the original patch that added the delay, so that we do not wait these 30 msec in the "fast" reconnect handler. It turns out your original approach was better, but we should not be using retries, but rather the existing reset_delay_ms already defined in rmi platform data. I would appreciate if you try the draft patch at the end of this email (to be applied after reverting your original one adding the delay in psmouse-smbus.c).

I tested the draft patch and it works. I did revert the previous delay patch while testing it.

Quoted 6 lines
Quoted 3 lines

I think we need a similar change in synaptics.c as that one also can fall back to PS/2 mode.

Ah, good point, yes it does appear this needs to be done as well. I have tested and will post an new version of the patch to include the fix in synaptics.c as well.

As I'm affected by this problem (and somebody else reported to me in private to be affected as well) and nothing afaics happened in the past few days a quick question:

What's the way forward here now that -rc6 slowly comes into sight? Apply Jeff's patch to fix my problem? Revert the culprit and fix this properly up with Dmitry's and Jeff's patches in the next cycle? Something else?

Ciao, Thorsten

maintainer
#8 lore raw

Hi Thorsten,

Quoted 22 lines · Thorsten Leemhuis
Quoted 14 lines · Jeffery Miller
Quoted 8 lines · Dmitry Torokhov

In fact, now that I think about it more, we should rework the original patch that added the delay, so that we do not wait these 30 msec in the "fast" reconnect handler. It turns out your original approach was better, but we should not be using retries, but rather the existing reset_delay_ms already defined in rmi platform data. I would appreciate if you try the draft patch at the end of this email (to be applied after reverting your original one adding the delay in psmouse-smbus.c).

I tested the draft patch and it works. I did revert the previous delay patch while testing it.

Quoted 6 lines
Quoted 3 lines

I think we need a similar change in synaptics.c as that one also can fall back to PS/2 mode.

Ah, good point, yes it does appear this needs to be done as well. I have tested and will post an new version of the patch to include the fix in synaptics.c as well.

Quoted 7 lines

As I'm affected by this problem (and somebody else reported to me in private to be affected as well) and nothing afaics happened in the past few days a quick question:

What's the way forward here now that -rc6 slowly comes into sight? Apply Jeff's patch to fix my problem? Revert the culprit and fix this properly up with Dmitry's and Jeff's patches in the next cycle? Something else?

I will revert the original patch introducing the delay now that we argee there is a better way. In the mean time I will merge Jeff's patch to reset fast_reconnect handlers, as it is right thing to do anyway, and will get into shape the patch setting reset-delay in RMI code.

Thanks.

Signature · 1 line
Dmitry