linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode
@ 2022-03-22  2:10 Zongmin Zhou
  2022-03-31  1:59 ` [RESEND PATCH] " Zongmin Zhou
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zongmin Zhou @ 2022-03-22  2:10 UTC (permalink / raw)
  To: linux-graphics-maintainer, pv-drivers, dmitry.torokhov
  Cc: linux-input, linux-kernel, zhouzongmin

Details:
When I use VirtualPS/2 VMMouse on virtual machine,There will be an error message after resume from suspend mode.
like below:
psmouse serio1: vmmouse: Unable to re-enable mouse when reconnecting, err: -6
And vmmouse will be unusable,so have to do full rescan to find a another driver to use for the port.

This error is due to QEMU still generate PS2 events to notify kernel driver to read from queue,
but kernel can't process the data in suspend mode, resulting a surge of s->nb_queue value,
which ultimately led to an error getting VMMOUSE_VERSION_ID after resume.

Test scenario:
1)virtual machine started with qemu command "vmport=on",it will use VirtualPS/2 VMMouse
2)click suspend botton to enter suspend mode
3)resume and will get the error message from dmesg

Fixed by:
Disabling the vmmouse in its reset handler,It will notify qemu to stop vmmouse and remove handler.

Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
---
 drivers/input/mouse/vmmouse.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index 42443ffba7c4..ea9eff7c8099 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -365,6 +365,19 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 	return 0;
 }
 
+/**
+ * vmmouse_reset - Disable vmmouse and reset
+ *
+ * @psmouse: Pointer to the psmouse struct
+ *
+ * Tries to disable vmmouse mode before enter suspend.
+ */
+static void vmmouse_reset(struct psmouse *psmouse)
+{
+	vmmouse_disable(psmouse);
+	psmouse_reset(psmouse);
+}
+
 /**
  * vmmouse_disconnect - Take down vmmouse driver
  *
@@ -472,6 +485,7 @@ int vmmouse_init(struct psmouse *psmouse)
 	psmouse->protocol_handler = vmmouse_process_byte;
 	psmouse->disconnect = vmmouse_disconnect;
 	psmouse->reconnect = vmmouse_reconnect;
+	psmouse->cleanup = vmmouse_reset;
 
 	return 0;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode
  2022-03-22  2:10 [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode Zongmin Zhou
@ 2022-03-31  1:59 ` Zongmin Zhou
  2022-04-06 10:08 ` Zongmin Zhou
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Zongmin Zhou @ 2022-03-31  1:59 UTC (permalink / raw)
  To: linux-graphics-maintainer, pv-drivers, dmitry.torokhov
  Cc: linux-input, linux-kernel, zhouzongmin

Details:
When I use VirtualPS/2 VMMouse on virtual machine,
There will be an error message after resume from suspend mode.
like below:
vmmouse: Unable to re-enable mouse when reconnecting, err: -6

And vmmouse will be unusable,so have to do full rescan
to find a another driver to use for the port.

This error is due to QEMU still generate PS2 events
to notify kernel driver to read from queue,
but kernel can't process the data in suspend mode,
resulting a surge of s->nb_queue value,
which ultimately led to an error getting VMMOUSE_VERSION_ID after resume.

Test scenario:
1)virtual machine started with qemu command "vmport=on",
  it will use VirtualPS/2 VMMouse.
2)click suspend botton to enter suspend mode.
3)resume and will get the error message from dmesg.

Fixed by:
Disabling the vmmouse in its reset handler,
It will notify qemu to stop vmmouse and remove handler.

Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
---
 drivers/input/mouse/vmmouse.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index 42443ffba7c4..ea9eff7c8099 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -365,6 +365,19 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 	return 0;
 }
 
+/**
+ * vmmouse_reset - Disable vmmouse and reset
+ *
+ * @psmouse: Pointer to the psmouse struct
+ *
+ * Tries to disable vmmouse mode before enter suspend.
+ */
+static void vmmouse_reset(struct psmouse *psmouse)
+{
+	vmmouse_disable(psmouse);
+	psmouse_reset(psmouse);
+}
+
 /**
  * vmmouse_disconnect - Take down vmmouse driver
  *
@@ -472,6 +485,7 @@ int vmmouse_init(struct psmouse *psmouse)
 	psmouse->protocol_handler = vmmouse_process_byte;
 	psmouse->disconnect = vmmouse_disconnect;
 	psmouse->reconnect = vmmouse_reconnect;
+	psmouse->cleanup = vmmouse_reset;
 
 	return 0;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode
  2022-03-22  2:10 [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode Zongmin Zhou
  2022-03-31  1:59 ` [RESEND PATCH] " Zongmin Zhou
@ 2022-04-06 10:08 ` Zongmin Zhou
  2022-04-26  2:40 ` [PATCH] " Zack Rusin
  2022-05-18  4:56 ` Dmitry Torokhov
  3 siblings, 0 replies; 5+ messages in thread
From: Zongmin Zhou @ 2022-04-06 10:08 UTC (permalink / raw)
  To: zackr, linux-graphics-maintainer, pv-drivers, dmitry.torokhov
  Cc: linux-input, linux-kernel, zhouzongmin

Details:
When I use VirtualPS/2 VMMouse on virtual machine,
There will be an error message after resume from suspend mode.
like below:
vmmouse: Unable to re-enable mouse when reconnecting, err: -6

And vmmouse will be unusable,so have to do full rescan
to find a another driver to use for the port.

This error is due to QEMU still generate PS2 events
to notify kernel driver to read from queue,
but kernel can't process the data in suspend mode,
resulting a surge of s->nb_queue value,
which ultimately led to an error getting VMMOUSE_VERSION_ID after resume.

Test scenario:
1)virtual machine started with qemu command "vmport=on",
  it will use VirtualPS/2 VMMouse.
2)click suspend botton to enter suspend mode.
3)resume and will get the error message from dmesg.

Fixed by:
Disabling the vmmouse in its reset handler,
It will notify qemu to stop vmmouse and remove handler.

Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
---
 drivers/input/mouse/vmmouse.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index 42443ffba7c4..ea9eff7c8099 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -365,6 +365,19 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties)
 	return 0;
 }
 
+/**
+ * vmmouse_reset - Disable vmmouse and reset
+ *
+ * @psmouse: Pointer to the psmouse struct
+ *
+ * Tries to disable vmmouse mode before enter suspend.
+ */
+static void vmmouse_reset(struct psmouse *psmouse)
+{
+	vmmouse_disable(psmouse);
+	psmouse_reset(psmouse);
+}
+
 /**
  * vmmouse_disconnect - Take down vmmouse driver
  *
@@ -472,6 +485,7 @@ int vmmouse_init(struct psmouse *psmouse)
 	psmouse->protocol_handler = vmmouse_process_byte;
 	psmouse->disconnect = vmmouse_disconnect;
 	psmouse->reconnect = vmmouse_reconnect;
+	psmouse->cleanup = vmmouse_reset;
 
 	return 0;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode
  2022-03-22  2:10 [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode Zongmin Zhou
  2022-03-31  1:59 ` [RESEND PATCH] " Zongmin Zhou
  2022-04-06 10:08 ` Zongmin Zhou
@ 2022-04-26  2:40 ` Zack Rusin
  2022-05-18  4:56 ` Dmitry Torokhov
  3 siblings, 0 replies; 5+ messages in thread
From: Zack Rusin @ 2022-04-26  2:40 UTC (permalink / raw)
  To: dmitry.torokhov, Pv-drivers, zhouzongmin, Linux-graphics-maintainer
  Cc: linux-input, linux-kernel

On Tue, 2022-03-22 at 10:10 +0800, Zongmin Zhou wrote:
> ⚠ External Email: This email originated from outside of the
> organization. Do not click links or open attachments unless you
> recognize the sender.
> 
> Details:
> When I use VirtualPS/2 VMMouse on virtual machine,There will be an
> error message after resume from suspend mode.
> like below:
> psmouse serio1: vmmouse: Unable to re-enable mouse when reconnecting,
> err: -6
> And vmmouse will be unusable,so have to do full rescan to find a
> another driver to use for the port.
> 
> This error is due to QEMU still generate PS2 events to notify kernel
> driver to read from queue,
> but kernel can't process the data in suspend mode, resulting a surge
> of s->nb_queue value,
> which ultimately led to an error getting VMMOUSE_VERSION_ID after
> resume.
> 
> Test scenario:
> 1)virtual machine started with qemu command "vmport=on",it will use
> VirtualPS/2 VMMouse
> 2)click suspend botton to enter suspend mode
> 3)resume and will get the error message from dmesg
> 
> Fixed by:
> Disabling the vmmouse in its reset handler,It will notify qemu to
> stop vmmouse and remove handler.

Thank you for the clarification. Looks good.

Reviewed-by: Zack Rusin <zackr@vmware.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode
  2022-03-22  2:10 [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode Zongmin Zhou
                   ` (2 preceding siblings ...)
  2022-04-26  2:40 ` [PATCH] " Zack Rusin
@ 2022-05-18  4:56 ` Dmitry Torokhov
  3 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2022-05-18  4:56 UTC (permalink / raw)
  To: Zongmin Zhou
  Cc: linux-graphics-maintainer, pv-drivers, linux-input, linux-kernel

On Tue, Mar 22, 2022 at 10:10:46AM +0800, Zongmin Zhou wrote:
> Details:
> When I use VirtualPS/2 VMMouse on virtual machine,There will be an error message after resume from suspend mode.
> like below:
> psmouse serio1: vmmouse: Unable to re-enable mouse when reconnecting, err: -6
> And vmmouse will be unusable,so have to do full rescan to find a another driver to use for the port.
> 
> This error is due to QEMU still generate PS2 events to notify kernel driver to read from queue,
> but kernel can't process the data in suspend mode, resulting a surge of s->nb_queue value,
> which ultimately led to an error getting VMMOUSE_VERSION_ID after resume.
> 
> Test scenario:
> 1)virtual machine started with qemu command "vmport=on",it will use VirtualPS/2 VMMouse
> 2)click suspend botton to enter suspend mode
> 3)resume and will get the error message from dmesg
> 
> Fixed by:
> Disabling the vmmouse in its reset handler,It will notify qemu to stop vmmouse and remove handler.
> 
> Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-18  4:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22  2:10 [PATCH] input/vmmouse: Add vmmouse_reset() function to disable vmmouse before entering suspend mode Zongmin Zhou
2022-03-31  1:59 ` [RESEND PATCH] " Zongmin Zhou
2022-04-06 10:08 ` Zongmin Zhou
2022-04-26  2:40 ` [PATCH] " Zack Rusin
2022-05-18  4:56 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).