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

Commit f61dfb6e authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa
Browse files

USB: gadget: u_bam: Fix spinlock lockup issue



Release spinlock before schedueling work when bam channel
is ready after cable is connected. Otherwise it leads
to spinlock lockup issue.

Also release spin lock before usb requests allocation to fix
"BUG: calling sleep function in atomic context".

Change-Id: Ia7f0bb0cf0096e30488e55a93cf62a2d8644a818
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 90f1b5b9
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -902,16 +902,13 @@ static int _gbam_start_io(struct gbam_port *port, bool in)
		queue_size = bam_mux_rx_q_size;
		ep_complete = gbam_epout_complete;
	}
	spin_unlock_irqrestore(spinlock, flags);
	ret = gbam_alloc_requests(ep, idle, queue_size, ep_complete,
			GFP_ATOMIC);
	if (ret) {
			GFP_KERNEL);
	if (ret)
		pr_err("%s: allocation failed\n", __func__);
		spin_unlock_irqrestore(spinlock, flags);
		return ret;
	}
	spin_unlock_irqrestore(spinlock, flags);

	return 0;
	return ret;
}

static void gbam_start_io(struct gbam_port *port)
@@ -1411,6 +1408,7 @@ static int gbam_data_ch_probe(struct platform_device *pdev)
	struct bam_ch_info	*d;
	int			i;
	unsigned long		flags;
	bool			do_work = false;

	pr_debug("%s: name:%s\n", __func__, pdev->name);

@@ -1426,10 +1424,12 @@ static int gbam_data_ch_probe(struct platform_device *pdev)
			spin_lock_irqsave(&port->port_lock_ul, flags);
			spin_lock(&port->port_lock_dl);
			if (port->port_usb)
				queue_work(gbam_wq, &port->connect_w);
				do_work = true;
			spin_unlock(&port->port_lock_dl);
			spin_unlock_irqrestore(&port->port_lock_ul, flags);

			if (do_work)
				queue_work(gbam_wq, &port->connect_w);
			break;
		}
	}