diff mbox series

[v3,09/11] HID: hyperv: Make ringbuffer at least take two pages

Message ID 20200910143455.109293-10-boqun.feng@gmail.com (mailing list archive)
State New, archived
Headers show
Series Hyper-V: Support PAGE_SIZE larger than 4K | expand

Commit Message

Boqun Feng Sept. 10, 2020, 2:34 p.m. UTC
When PAGE_SIZE > HV_HYP_PAGE_SIZE, we need the ringbuffer size to be at
least 2 * PAGE_SIZE: one page for the header and at least one page of
the data part (because of the alignment requirement for double mapping).

So make sure the ringbuffer sizes to be at least 2 * PAGE_SIZE when
using vmbus_open() to establish the vmbus connection.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
---
Hi Jiri,

Thanks for your acked-by. I make a small change in this version (casting
2 * PAGE_SIZE into int to avoid compiler warnings), and it make no
functional change. If the change is inappropriate, please let me know.

 drivers/hid/hid-hyperv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Kelley (LINUX) Sept. 12, 2020, 7:38 p.m. UTC | #1
From: Boqun Feng <boqun.feng@gmail.com> Sent: Thursday, September 10, 2020 7:35 AM
> 
> When PAGE_SIZE > HV_HYP_PAGE_SIZE, we need the ringbuffer size to be at
> least 2 * PAGE_SIZE: one page for the header and at least one page of
> the data part (because of the alignment requirement for double mapping).
> 
> So make sure the ringbuffer sizes to be at least 2 * PAGE_SIZE when
> using vmbus_open() to establish the vmbus connection.
> 
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Acked-by: Jiri Kosina <jkosina@suse.cz>
> ---
> Hi Jiri,
> 
> Thanks for your acked-by. I make a small change in this version (casting
> 2 * PAGE_SIZE into int to avoid compiler warnings), and it make no
> functional change. If the change is inappropriate, please let me know.
> 
>  drivers/hid/hid-hyperv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by:  Michael Kelley <mikelley@microsoft.com>
diff mbox series

Patch

diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index 0b6ee1dee625..8905559b3882 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -104,8 +104,8 @@  struct synthhid_input_report {
 
 #pragma pack(pop)
 
-#define INPUTVSC_SEND_RING_BUFFER_SIZE		(40 * 1024)
-#define INPUTVSC_RECV_RING_BUFFER_SIZE		(40 * 1024)
+#define INPUTVSC_SEND_RING_BUFFER_SIZE	max(40 * 1024, (int)(2 * PAGE_SIZE))
+#define INPUTVSC_RECV_RING_BUFFER_SIZE	max(40 * 1024, (int)(2 * PAGE_SIZE))
 
 
 enum pipe_prot_msg_type {