* [PATCH v2] Input: psmouse - fix fast_reconnect function for PS/2 mode
@ 2023-10-05 0:20 Jeffery Miller
2023-10-12 22:33 ` Jeffery Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jeffery Miller @ 2023-10-05 0:20 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, linux-input, Andrew Duggan, Andrew Duggan,
loic.poulain, linux, benjamin.tissoires, Jeffery Miller
Make elantech_setup_ps2 and synaptics_init_ps2 set an appropriate
fast_reconnect pointer when the PS/2 mode is used.
When the SMBus connection is attempted psmouse_smbus_init sets
the fast_reconnect pointer to psmouse_smbus_reconnect. When this fails
elantech_setup_ps2 and synaptics_init_ps2 will fallback to PS/2
mode replacing the psmouse private data.
This was causing an issue on resume since psmouse_smbus_reconnect was
being called while in PS/2 mode and attempting to use the invalid
private data.
This issue was uncovered when psmouse_smbus_reconnect started attempting
to use more of the data structure.
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Closes: https://lore.kernel.org/all/ca0109fa-c64b-43c1-a651-75b294d750a1@leemhuis.info/
Fixes: 92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus mode")
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Signed-off-by: Jeffery Miller <jefferymiller@google.com>
---
The other callbacks set in psmouse_smbus_init are already replaced.
Changes in v2:
- Also set fast_reconnect in the synaptics ps2 fallback path from review
comments.
- Add Fixes: tag to the commit that uncovered the problem.
drivers/input/mouse/elantech.c | 1 +
drivers/input/mouse/synaptics.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 2118b2075f43..4e38229404b4 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -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;
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ada299ec5bba..cefc74b3b34b 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -1623,6 +1623,7 @@ static int synaptics_init_ps2(struct psmouse *psmouse,
psmouse->set_rate = synaptics_set_rate;
psmouse->disconnect = synaptics_disconnect;
psmouse->reconnect = synaptics_reconnect;
+ psmouse->fast_reconnect = NULL;
psmouse->cleanup = synaptics_reset;
/* Synaptics can usually stay in sync without extra help */
psmouse->resync_time = 0;
--
2.42.0.582.g8ccd20d70d-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] Input: psmouse - fix fast_reconnect function for PS/2 mode
2023-10-05 0:20 [PATCH v2] Input: psmouse - fix fast_reconnect function for PS/2 mode Jeffery Miller
@ 2023-10-12 22:33 ` Jeffery Miller
0 siblings, 0 replies; 2+ messages in thread
From: Jeffery Miller @ 2023-10-12 22:33 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, linux-input, Andrew Duggan, Andrew Duggan,
loic.poulain, linux, benjamin.tissoires
On Wed, Oct 4, 2023 at 7:23 PM Jeffery Miller <jefferymiller@google.com> wrote:
>
> drivers/input/mouse/elantech.c | 1 +
> drivers/input/mouse/synaptics.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
> index 2118b2075f43..4e38229404b4 100644
> --- a/drivers/input/mouse/elantech.c
> +++ b/drivers/input/mouse/elantech.c
> @@ -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;
> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> index ada299ec5bba..cefc74b3b34b 100644
> --- a/drivers/input/mouse/synaptics.c
> +++ b/drivers/input/mouse/synaptics.c
> @@ -1623,6 +1623,7 @@ static int synaptics_init_ps2(struct psmouse *psmouse,
> psmouse->set_rate = synaptics_set_rate;
> psmouse->disconnect = synaptics_disconnect;
> psmouse->reconnect = synaptics_reconnect;
> + psmouse->fast_reconnect = NULL;
> psmouse->cleanup = synaptics_reset;
> /* Synaptics can usually stay in sync without extra help */
> psmouse->resync_time = 0;
> --
> 2.42.0.582.g8ccd20d70d-goog
>
This fast_reconnect function pointer being left over has been here since commit
8eb92e5c9133 ("Input: psmouse - add support for SMBus companions")
It is only recently noticed due to 92e24e0e57f7 ("Input: psmouse - add
delay when deactivating for SMBus mode") which is in the v6.6 rc
branches.
Shouldn't it be OK to merge regardless of a future refactor of
8eb92e5c9133 ("Input: psmouse - add support for SMBus companions")
as described in https://lore.kernel.org/all/ZR1yUFJ8a9Zt606N@penguin/?
This is a v2 from the previous submission at
https://lore.kernel.org/all/20231004005729.3943515-1-jefferymiller@google.com/
Thanks,
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-12 22:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-05 0:20 [PATCH v2] Input: psmouse - fix fast_reconnect function for PS/2 mode Jeffery Miller
2023-10-12 22:33 ` Jeffery Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox