* [PATCH] HID: hyperv: Use in-place iterator API in the channel callback
@ 2019-08-20 2:56 Dexuan Cui
2019-09-03 0:43 ` Dexuan Cui
0 siblings, 1 reply; 4+ messages in thread
From: Dexuan Cui @ 2019-08-20 2:56 UTC (permalink / raw)
To: jikos, benjamin.tissoires, linux-input, linux-hyperv,
Stephen Hemminger, Sasha Levin, sashal, Haiyang Zhang,
KY Srinivasan, Michael Kelley
Cc: gregkh, linux-kernel, Dexuan Cui
Simplify the ring buffer handling with the in-place API.
Also avoid the dynamic allocation and the memory leak in the channel
callback function.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
Hi Jiri, Benjamin, can this patch go through Sasha's hyperv tree:
https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
This is a purely Hyper-V specific change.
drivers/hid/hid-hyperv.c | 56 +++++++++---------------------------------------
1 file changed, 10 insertions(+), 46 deletions(-)
diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index 7795831..f363163 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -314,60 +314,24 @@ static void mousevsc_on_receive(struct hv_device *device,
static void mousevsc_on_channel_callback(void *context)
{
- const int packet_size = 0x100;
- int ret;
struct hv_device *device = context;
- u32 bytes_recvd;
- u64 req_id;
struct vmpacket_descriptor *desc;
- unsigned char *buffer;
- int bufferlen = packet_size;
-
- buffer = kmalloc(bufferlen, GFP_ATOMIC);
- if (!buffer)
- return;
-
- do {
- ret = vmbus_recvpacket_raw(device->channel, buffer,
- bufferlen, &bytes_recvd, &req_id);
-
- switch (ret) {
- case 0:
- if (bytes_recvd <= 0) {
- kfree(buffer);
- return;
- }
- desc = (struct vmpacket_descriptor *)buffer;
-
- switch (desc->type) {
- case VM_PKT_COMP:
- break;
-
- case VM_PKT_DATA_INBAND:
- mousevsc_on_receive(device, desc);
- break;
-
- default:
- pr_err("unhandled packet type %d, tid %llx len %d\n",
- desc->type, req_id, bytes_recvd);
- break;
- }
+ foreach_vmbus_pkt(desc, device->channel) {
+ switch (desc->type) {
+ case VM_PKT_COMP:
break;
- case -ENOBUFS:
- kfree(buffer);
- /* Handle large packet */
- bufferlen = bytes_recvd;
- buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
-
- if (!buffer)
- return;
+ case VM_PKT_DATA_INBAND:
+ mousevsc_on_receive(device, desc);
+ break;
+ default:
+ pr_err("Unhandled packet type %d, tid %llx len %d\n",
+ desc->type, desc->trans_id, desc->len8 * 8);
break;
}
- } while (1);
-
+ }
}
static int mousevsc_connect_to_vsp(struct hv_device *device)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] HID: hyperv: Use in-place iterator API in the channel callback
2019-08-20 2:56 [PATCH] HID: hyperv: Use in-place iterator API in the channel callback Dexuan Cui
@ 2019-09-03 0:43 ` Dexuan Cui
2019-09-04 14:23 ` Jiri Kosina
0 siblings, 1 reply; 4+ messages in thread
From: Dexuan Cui @ 2019-09-03 0:43 UTC (permalink / raw)
To: jikos, benjamin.tissoires, linux-input, linux-hyperv,
Stephen Hemminger, Sasha Levin, sashal, Haiyang Zhang,
KY Srinivasan, Michael Kelley
Cc: gregkh, linux-kernel
> -----Original Message-----
> From: Dexuan Cui <decui@microsoft.com>
> Sent: Monday, August 19, 2019 7:57 PM
> To: jikos@kernel.org; benjamin.tissoires@redhat.com;
> linux-input@vger.kernel.org; linux-hyperv@vger.kernel.org; Stephen
> Hemminger <sthemmin@microsoft.com>; Sasha Levin
> <Alexander.Levin@microsoft.com>; sashal@kernel.org; Haiyang Zhang
> <haiyangz@microsoft.com>; KY Srinivasan <kys@microsoft.com>; Michael
> Kelley <mikelley@microsoft.com>
> Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; Dexuan Cui
> <decui@microsoft.com>
> Subject: [PATCH] HID: hyperv: Use in-place iterator API in the channel callback
>
> Simplify the ring buffer handling with the in-place API.
>
> Also avoid the dynamic allocation and the memory leak in the channel
> callback function.
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> ---
>
> Hi Jiri, Benjamin, can this patch go through Sasha's hyperv tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
>
> This is a purely Hyper-V specific change.
Hi Jiri, Benjamin,
Are you OK if this patch for the Hyper-V HID driver goes through the Hyper-V
tree maintained by Sasha Levin? It's a purely Hyper-V change, and I have
been using the patch for several months and there is no regression.
Thanks,
-- Dexuan
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] HID: hyperv: Use in-place iterator API in the channel callback
2019-09-03 0:43 ` Dexuan Cui
@ 2019-09-04 14:23 ` Jiri Kosina
2019-09-05 15:11 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2019-09-04 14:23 UTC (permalink / raw)
To: Dexuan Cui
Cc: benjamin.tissoires, linux-input, linux-hyperv, Stephen Hemminger,
Sasha Levin, sashal, Haiyang Zhang, KY Srinivasan,
Michael Kelley, gregkh, linux-kernel
On Tue, 3 Sep 2019, Dexuan Cui wrote:
> > Hi Jiri, Benjamin, can this patch go through Sasha's hyperv tree:
> > https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
> >
> > This is a purely Hyper-V specific change.
>
> Hi Jiri, Benjamin,
> Are you OK if this patch for the Hyper-V HID driver goes through the Hyper-V
> tree maintained by Sasha Levin? It's a purely Hyper-V change, and I have
> been using the patch for several months and there is no regression.
No problem with that. Feel free to add
Acked-by: Jiri Kosina <jkosina@suse.cz>
in that case.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] HID: hyperv: Use in-place iterator API in the channel callback
2019-09-04 14:23 ` Jiri Kosina
@ 2019-09-05 15:11 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-09-05 15:11 UTC (permalink / raw)
To: Jiri Kosina
Cc: Dexuan Cui, benjamin.tissoires, linux-input, linux-hyperv,
Stephen Hemminger, Sasha Levin, Haiyang Zhang, KY Srinivasan,
Michael Kelley, gregkh, linux-kernel
On Wed, Sep 04, 2019 at 04:23:27PM +0200, Jiri Kosina wrote:
>On Tue, 3 Sep 2019, Dexuan Cui wrote:
>
>> > Hi Jiri, Benjamin, can this patch go through Sasha's hyperv tree:
>> > https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
>> >
>> > This is a purely Hyper-V specific change.
>>
>> Hi Jiri, Benjamin,
>> Are you OK if this patch for the Hyper-V HID driver goes through the Hyper-V
>> tree maintained by Sasha Levin? It's a purely Hyper-V change, and I have
>> been using the patch for several months and there is no regression.
>
>No problem with that. Feel free to add
>
> Acked-by: Jiri Kosina <jkosina@suse.cz>
>
>in that case.
I've queued it up for hyperv-fixes, thank you!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-05 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 2:56 [PATCH] HID: hyperv: Use in-place iterator API in the channel callback Dexuan Cui
2019-09-03 0:43 ` Dexuan Cui
2019-09-04 14:23 ` Jiri Kosina
2019-09-05 15:11 ` Sasha Levin
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).