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

Commit 64adbd29 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: mbim: Fix MBIM write to work during USB bus suspend or low-power mode"

parents e351ce21 5b425feb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1774,6 +1774,7 @@ static int dwc_gadget_func_wakeup(struct usb_gadget *g, int interface_id)
		return -ENOTSUPP;

	if (dwc3_gadget_is_suspended(dwc)) {
		pr_debug("USB bus is suspended. Scheduling wakeup and returning -EAGAIN.\n");
		dwc3_gadget_wakeup(&dwc->gadget);
		return -EAGAIN;
	}
+12 −6
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ int usb_func_wakeup(struct usb_function *func)
	gadget = func->config->cdev->gadget;
	if ((gadget->speed != USB_SPEED_SUPER) || !func->func_wakeup_allowed) {
		DBG(func->config->cdev,
			"Function Wakeup is not possible. speed=%u, func_wakeup_allowed=%u",
			"Function Wakeup is not possible. speed=%u, func_wakeup_allowed=%u\n",
			gadget->speed,
			func->func_wakeup_allowed);

@@ -389,7 +389,7 @@ int usb_func_wakeup(struct usb_function *func)
	ret = usb_get_func_interface_id(func);
	if (ret < 0) {
		ERROR(func->config->cdev,
			"Function %s - Unknown interface id. Canceling USB request. ret=%d",
			"Function %s - Unknown interface id. Canceling USB request. ret=%d\n",
			func->name ? func->name : "", ret);
		return ret;
	}
@@ -397,10 +397,16 @@ int usb_func_wakeup(struct usb_function *func)
	interface_id = ret;
	ret = usb_gadget_func_wakeup(gadget, interface_id);
	if (ret) {
		if (ret == -EAGAIN) {
			DBG(func->config->cdev,
				"Function wakeup for %s could not be complete. Retry is needed.\n",
				func->name ? func->name : "");
		} else {
			ERROR(func->config->cdev,
			"Failed to wake function %s from suspend state. interface id: %d, ret=%d. Canceling USB request.",
				"Failed to wake function %s from suspend state. interface id: %d, ret=%d. Canceling USB request.\n",
				func->name ? func->name : "",
				interface_id, ret);
		}
		return ret;
	}

+17 −1
Original line number Diff line number Diff line
@@ -663,10 +663,13 @@ void fmbim_free_req(struct usb_ep *ep, struct usb_request *req)

static void fmbim_ctrl_response_available(struct f_mbim *dev)
{
	const unsigned int		max_ep_queue_trials = 10;

	struct usb_request		*req = dev->not_port.notify_req;
	struct usb_cdc_notification	*event = NULL;
	unsigned long			flags;
	int				ret;
	int                             ep_queue_trials;

	pr_debug("dev:%p portno#%d\n", dev, dev->port_num);

@@ -707,8 +710,21 @@ static void fmbim_ctrl_response_available(struct f_mbim *dev)
	event->wLength = cpu_to_le16(0);
	spin_unlock_irqrestore(&dev->lock, flags);

	ep_queue_trials = 0;
	while (ep_queue_trials <= max_ep_queue_trials) {
		ret = usb_func_ep_queue(&dev->function, dev->not_port.notify,
			   req, GFP_ATOMIC);

		ep_queue_trials++;

		if (ret == -EAGAIN) {
			pr_debug("ep queueing is delayed (-EAGAIN).\n");
			usleep_range(1000, 3000);
		} else {
			break;
		}
	}

	if (ret) {
		atomic_dec(&dev->not_port.notify_count);
		pr_err("ep enqueue error %d\n", ret);
+4 −2
Original line number Diff line number Diff line
@@ -457,8 +457,10 @@ int usb_func_ep_queue(struct usb_function *func, struct usb_ep *ep,
	if ((gadget->speed == USB_SPEED_SUPER) && func->func_is_suspended) {
		ret = usb_func_wakeup(func);
		if (ret) {
			if (ret != -EAGAIN)
				pr_err("Failed to send function wake up notification. func name:%s, ep:%u\n",
				func->name ? func->name : "", ep->address);
					func->name ? func->name : "",
					ep->address);
			return ret;
		}
	}