linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG
@ 2016-06-27  8:03 Amit Pundir
  2016-06-29  8:12 ` Felipe Balbi
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Pundir @ 2016-06-27  8:03 UTC (permalink / raw)
  To: linux-usb, linux-kernel
  Cc: balbi, gregkh, andrzej.p, kernel-team, john.stultz, xerox_lin,
	Rajkumar Raghupathy

From: xerox_lin <xerox_lin@htc.com>

When rndis data transfer is in progress, some Windows7 Host PC is not
sending the GET_ENCAPSULATED_RESPONSE command for receiving the response
for the previous SEND_ENCAPSULATED_COMMAND processed.

The rndis function driver appends each response for the
SEND_ENCAPSULATED_COMMAND in a queue. As the above process got corrupted,
the Host sends a REMOTE_NDIS_RESET_MSG command to do a soft-reset.
As the rndis response queue is not freed, the previous response is sent
as a part of this REMOTE_NDIS_RESET_MSG's reset response and the Host
block any more Rndis transfers.

Hence free the rndis response queue as a part of this soft-reset so that
the correct response for REMOTE_NDIS_RESET_MSG is sent properly during the
response command.

Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
Signed-off-by: Xerox Lin <xerox_lin@htc.com>
[AmitP: Cherry-picked this patch and folded other relevant
        fixes from Android common kernel android-4.4]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry picked this usb tethering fix from AOSP kernel/common/android-4.4
tree and to make sure it doesn't get overlooked, submiting it for review
and comment.

 drivers/usb/gadget/function/rndis.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
index 943c21a..ab6ac1b 100644
--- a/drivers/usb/gadget/function/rndis.c
+++ b/drivers/usb/gadget/function/rndis.c
@@ -680,6 +680,12 @@ static int rndis_reset_response(struct rndis_params *params,
 {
 	rndis_reset_cmplt_type *resp;
 	rndis_resp_t *r;
+	u8 *xbuf;
+	u32 length;
+
+	/* drain the response queue */
+	while ((xbuf = rndis_get_next_response(params, &length)))
+		rndis_free_response(params, xbuf);
 
 	r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type));
 	if (!r)
-- 
2.7.4

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

* Re: [PATCH] usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG
  2016-06-27  8:03 [PATCH] usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG Amit Pundir
@ 2016-06-29  8:12 ` Felipe Balbi
  0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2016-06-29  8:12 UTC (permalink / raw)
  To: Amit Pundir, linux-usb, linux-kernel
  Cc: gregkh, andrzej.p, kernel-team, john.stultz, xerox_lin,
	Rajkumar Raghupathy

[-- Attachment #1: Type: text/plain, Size: 154 bytes --]

Amit Pundir <amit.pundir@linaro.org> writes:

> From: xerox_lin <xerox_lin@htc.com>

Please sanitize name here. Then resend.

thanks

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

end of thread, other threads:[~2016-06-29  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27  8:03 [PATCH] usb: gadget: rndis: free response queue during REMOTE_NDIS_RESET_MSG Amit Pundir
2016-06-29  8:12 ` Felipe Balbi

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).