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

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

Merge "USB: f_mbim: Drop commands until MBIMD opens device on MBIM_OPEN"

parents eb0c6823 0af93af8
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ struct f_mbim {

	atomic_t		error;
	unsigned int		cpkt_drop_cnt;
	bool			remote_wakeup_enabled;
};

struct mbim_ntb_input_size {
@@ -830,6 +831,7 @@ fmbim_cmd_complete(struct usb_ep *ep, struct usb_request *req)
	struct f_mbim		*dev = req->context;
	struct ctrl_pkt		*cpkt = NULL;
	int			len = req->actual;
	static bool		first_command_sent;

	if (!dev) {
		pr_err("mbim dev is null\n");
@@ -841,6 +843,18 @@ fmbim_cmd_complete(struct usb_ep *ep, struct usb_request *req)
		return;
	}

	/*
	 * Wait for user to process prev MBIM_OPEN cmd before handling new one.
	 * However don't drop first command during bootup as file may not be
	 * opened by now. Queue the command in this case.
	 */
	if (!atomic_read(&dev->open_excl) && first_command_sent) {
		pr_err("mbim not opened yet, dropping cmd pkt = %d\n", len);
		return;
	}
	if (!first_command_sent)
		first_command_sent = true;

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

	cpkt = mbim_alloc_ctrl_pkt(len, GFP_ATOMIC);
@@ -1266,6 +1280,7 @@ static void mbim_disable(struct usb_function *f)

	pr_info("SET DEVICE OFFLINE\n");
	atomic_set(&mbim->online, 0);
	mbim->remote_wakeup_enabled = 0;

	 /* Disable Control Path */
	if (mbim->not_port.notify->driver_data) {
@@ -1308,7 +1323,6 @@ static void mbim_disable(struct usb_function *f)

static void mbim_suspend(struct usb_function *f)
{
	bool remote_wakeup_allowed;
	struct f_mbim	*mbim = func_to_mbim(f);

	pr_info("mbim suspended\n");
@@ -1327,9 +1341,9 @@ static void mbim_suspend(struct usb_function *f)
		return;

	if (mbim->cdev->gadget->speed == USB_SPEED_SUPER)
		remote_wakeup_allowed = f->func_wakeup_allowed;
		mbim->remote_wakeup_enabled = f->func_wakeup_allowed;
	else
		remote_wakeup_allowed = mbim->cdev->gadget->remote_wakeup;
		mbim->remote_wakeup_enabled = mbim->cdev->gadget->remote_wakeup;

	/* MBIM data interface is up only when alt setting is set to 1. */
	if (!mbim->data_interface_up) {
@@ -1337,16 +1351,15 @@ static void mbim_suspend(struct usb_function *f)
		return;
	}

	if (!remote_wakeup_allowed)
	if (!mbim->remote_wakeup_enabled)
		atomic_set(&mbim->online, 0);

	bam_data_suspend(&mbim->bam_port, mbim->port_num, USB_FUNC_MBIM,
			remote_wakeup_allowed);
			 mbim->remote_wakeup_enabled);
}

static void mbim_resume(struct usb_function *f)
{
	bool remote_wakeup_allowed;
	struct f_mbim	*mbim = func_to_mbim(f);

	pr_info("mbim resumed\n");
@@ -1367,22 +1380,17 @@ static void mbim_resume(struct usb_function *f)
	mbim_do_notify(mbim);
	spin_unlock(&mbim->lock);

	if (mbim->cdev->gadget->speed == USB_SPEED_SUPER)
		remote_wakeup_allowed = f->func_wakeup_allowed;
	else
		remote_wakeup_allowed = mbim->cdev->gadget->remote_wakeup;

	/* MBIM data interface is up only when alt setting is set to 1. */
	if (!mbim->data_interface_up) {
		pr_debug("MBIM data interface is not opened. Returning\n");
		return;
	}

	if (!remote_wakeup_allowed)
	if (!mbim->remote_wakeup_enabled)
		atomic_set(&mbim->online, 1);

	bam_data_resume(&mbim->bam_port, mbim->port_num, USB_FUNC_MBIM,
			remote_wakeup_allowed);
			mbim->remote_wakeup_enabled);
}

static int mbim_func_suspend(struct usb_function *f, unsigned char options)