hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hid/hid-hyperv.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2009, Citrix Systems, Inc.
34 * Copyright (c) 2010, Microsoft Corporation.
45 * Copyright (c) 2011, Novell Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
146 */
157 #include <linux/init.h>
168 #include <linux/module.h>
....@@ -112,8 +104,8 @@
112104
113105 #pragma pack(pop)
114106
115
-#define INPUTVSC_SEND_RING_BUFFER_SIZE (10*PAGE_SIZE)
116
-#define INPUTVSC_RECV_RING_BUFFER_SIZE (10*PAGE_SIZE)
107
+#define INPUTVSC_SEND_RING_BUFFER_SIZE VMBUS_RING_SIZE(36 * 1024)
108
+#define INPUTVSC_RECV_RING_BUFFER_SIZE VMBUS_RING_SIZE(36 * 1024)
117109
118110
119111 enum pipe_prot_msg_type {
....@@ -200,6 +192,8 @@
200192 if (desc->bLength == 0)
201193 goto cleanup;
202194
195
+ /* The pointer is not NULL when we resume from hibernation */
196
+ kfree(input_device->hid_desc);
203197 input_device->hid_desc = kmemdup(desc, desc->bLength, GFP_ATOMIC);
204198
205199 if (!input_device->hid_desc)
....@@ -211,6 +205,8 @@
211205 goto cleanup;
212206 }
213207
208
+ /* The pointer is not NULL when we resume from hibernation */
209
+ kfree(input_device->report_desc);
214210 input_device->report_desc = kzalloc(input_device->report_desc_size,
215211 GFP_ATOMIC);
216212
....@@ -349,6 +345,8 @@
349345 struct mousevsc_dev *input_dev = hv_get_drvdata(device);
350346 struct mousevsc_prt_msg *request;
351347 struct mousevsc_prt_msg *response;
348
+
349
+ reinit_completion(&input_dev->wait_event);
352350
353351 request = &input_dev->protocol_req;
354352 memset(request, 0, sizeof(struct mousevsc_prt_msg));
....@@ -500,7 +498,7 @@
500498
501499 ret = hid_add_device(hid_dev);
502500 if (ret)
503
- goto probe_err1;
501
+ goto probe_err2;
504502
505503
506504 ret = hid_parse(hid_dev);
....@@ -549,6 +547,30 @@
549547 return 0;
550548 }
551549
550
+static int mousevsc_suspend(struct hv_device *dev)
551
+{
552
+ vmbus_close(dev->channel);
553
+
554
+ return 0;
555
+}
556
+
557
+static int mousevsc_resume(struct hv_device *dev)
558
+{
559
+ int ret;
560
+
561
+ ret = vmbus_open(dev->channel,
562
+ INPUTVSC_SEND_RING_BUFFER_SIZE,
563
+ INPUTVSC_RECV_RING_BUFFER_SIZE,
564
+ NULL, 0,
565
+ mousevsc_on_channel_callback,
566
+ dev);
567
+ if (ret)
568
+ return ret;
569
+
570
+ ret = mousevsc_connect_to_vsp(dev);
571
+ return ret;
572
+}
573
+
552574 static const struct hv_vmbus_device_id id_table[] = {
553575 /* Mouse guid */
554576 { HV_MOUSE_GUID, },
....@@ -562,6 +584,8 @@
562584 .id_table = id_table,
563585 .probe = mousevsc_probe,
564586 .remove = mousevsc_remove,
587
+ .suspend = mousevsc_suspend,
588
+ .resume = mousevsc_resume,
565589 .driver = {
566590 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
567591 },
....@@ -578,5 +602,7 @@
578602 }
579603
580604 MODULE_LICENSE("GPL");
605
+MODULE_DESCRIPTION("Microsoft Hyper-V Synthetic HID Driver");
606
+
581607 module_init(mousevsc_init);
582608 module_exit(mousevsc_exit);