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

Commit 3b8635c8 authored by Manu Gautam's avatar Manu Gautam
Browse files

USB: gadget: u_bam_data: Bail out from disconnect_w if connect pending



By the time disconnect_work started running if USB state changed
to connect then bail out to avoid following scenario:

1. bam_data_connect
	->ep_enable
2. 				connect_work started
					..
3. bam_data_disconnect			..
	->ep_disable			..
					..
4. bam_data_connect			..
	->ep_enable			..
					..
			  	 	->start_rx/tx (ep_queue) SUCCESS

5.				disconnect_work started/ended

6.				connect_work started
					->ep_queue 		 FAILS!!

This change avoids going through step-5 and 6 as USB<->IPA
connection is already setup and no need to tear it down and
only to realize late that ep_queue fails eventually on connect
as request was never dequeued. Also, data stall happens
as driver reconnects BAM pipes and IPA while usb-request
remains queued without restarting data transfers with controller/DBM.

Change-Id: I84a1b4833f3c0283d441766dba86f75c7ac93194
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent e701f80b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 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
@@ -775,6 +775,13 @@ static void bam2bam_data_disconnect_work(struct work_struct *w)
		return;
	}

	if (port->last_event == U_BAM_DATA_CONNECT_E) {
		pr_debug("%s: Port is about to connect. Bail out.\n",
			__func__);
		spin_unlock_irqrestore(&port->port_lock, flags);
		return;
	}

	d = &port->data_ch;

	/*