Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a494df6 authored by Sriharsha Allenki's avatar Sriharsha Allenki
Browse files

usb: gadget: f_mbim: Fix incorrect repsonse available notifications



Two notify requests are being queued for one available modem
response. So for the first GET_ENCAPSULATED_RESPONSE we provide
the host with the available response. Now for the next
GET_ENCAPSULATED_COMMAND we notify the host that the response is
available even before the modem is ready with a response because
of the extra notify request queued on the interrupt endpoint.
This causes a STALL for the next GET_ENCAPSULATED_RESPONSE request.
This is caused because we are queueing a notify request from the
completion handler of the interrupt endpoint request when the
response queue is not empty.

Change-Id: I8a018dc5a95695322fbae096da5943fd3f648f1f
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
parent 79459f1b
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016,2017 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -768,7 +768,6 @@ static void mbim_notify_complete(struct usb_ep *ep, struct usb_request *req)
		break;
	}

	mbim_do_notify(mbim);
	spin_unlock(&mbim->lock);

	pr_debug("dev:%pK Exit\n", mbim);
@@ -878,6 +877,17 @@ fmbim_cmd_complete(struct usb_ep *ep, struct usb_request *req)
	return;
}

static void mbim_response_complete(struct usb_ep *ep, struct usb_request *req)
{
	struct f_mbim *mbim = req->context;

	pr_debug("%s: queue notify request if any new response available\n"
			, __func__);
	spin_lock(&mbim->lock);
	mbim_do_notify(mbim);
	spin_unlock(&mbim->lock);
}

static int
mbim_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
{
@@ -957,6 +967,8 @@ mbim_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
		pr_debug("copied encapsulated_response %d bytes\n",
			value);

		req->complete = mbim_response_complete;
		req->context = mbim;
		break;

	case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)