hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/input/serio/hyperv-keyboard.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2013, Microsoft Corporation.
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
124 */
135
146 #include <linux/init.h>
....@@ -83,8 +75,8 @@
8375
8476 #define HK_MAXIMUM_MESSAGE_SIZE 256
8577
86
-#define KBD_VSC_SEND_RING_BUFFER_SIZE (10 * PAGE_SIZE)
87
-#define KBD_VSC_RECV_RING_BUFFER_SIZE (10 * PAGE_SIZE)
78
+#define KBD_VSC_SEND_RING_BUFFER_SIZE VMBUS_RING_SIZE(36 * 1024)
79
+#define KBD_VSC_RECV_RING_BUFFER_SIZE VMBUS_RING_SIZE(36 * 1024)
8880
8981 #define XTKBD_EMUL0 0xe0
9082 #define XTKBD_EMUL1 0xe1
....@@ -267,6 +259,8 @@
267259 u32 proto_status;
268260 int error;
269261
262
+ reinit_completion(&kbd_dev->wait_event);
263
+
270264 request = &kbd_dev->protocol_req;
271265 memset(request, 0, sizeof(struct synth_kbd_protocol_request));
272266 request->header.type = __cpu_to_le32(SYNTH_KBD_PROTOCOL_REQUEST);
....@@ -388,6 +382,29 @@
388382 return 0;
389383 }
390384
385
+static int hv_kbd_suspend(struct hv_device *hv_dev)
386
+{
387
+ vmbus_close(hv_dev->channel);
388
+
389
+ return 0;
390
+}
391
+
392
+static int hv_kbd_resume(struct hv_device *hv_dev)
393
+{
394
+ int ret;
395
+
396
+ ret = vmbus_open(hv_dev->channel,
397
+ KBD_VSC_SEND_RING_BUFFER_SIZE,
398
+ KBD_VSC_RECV_RING_BUFFER_SIZE,
399
+ NULL, 0,
400
+ hv_kbd_on_channel_callback,
401
+ hv_dev);
402
+ if (ret == 0)
403
+ ret = hv_kbd_connect_to_vsp(hv_dev);
404
+
405
+ return ret;
406
+}
407
+
391408 static const struct hv_vmbus_device_id id_table[] = {
392409 /* Keyboard guid */
393410 { HV_KBD_GUID, },
....@@ -401,6 +418,8 @@
401418 .id_table = id_table,
402419 .probe = hv_kbd_probe,
403420 .remove = hv_kbd_remove,
421
+ .suspend = hv_kbd_suspend,
422
+ .resume = hv_kbd_resume,
404423 .driver = {
405424 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
406425 },
....@@ -417,5 +436,7 @@
417436 }
418437
419438 MODULE_LICENSE("GPL");
439
+MODULE_DESCRIPTION("Microsoft Hyper-V Synthetic Keyboard Driver");
440
+
420441 module_init(hv_kbd_init);
421442 module_exit(hv_kbd_exit);