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

Commit da880e97 authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa Committed by Manu Gautam
Browse files

usb_bam: Acquire usb_bam_lock spinlock before lpm handshake spinlock



Currently driver is acquiring lpm handshake spinlock first before taking
usb_bam_lock spinlock in consumer request callback provided to IPA driver.
But releasing in reverse order. This could cause deadlock in corner case,
where as part of connect, notify_usb_connected() will be called with
usb_bam_lock acquired. If consumer request resource called from IPA driver,
first it takes lpm handshake spinlock and waits for other spinlock.
Hence fix the issue by acquiring usb_bam_lock first before taking lpm
handshake spinlock in consumer request resource callback provided to IPA
driver.

CRs-Fixed: 842842
Change-Id: I597a31720d25f4822869452213f99bb742d8e610
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 1a49109d
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -1529,11 +1529,10 @@ static int cons_request_resource(enum usb_ctrl cur_bam)
	log_event(1, "%s: Request %s_CONS resource\n",
	log_event(1, "%s: Request %s_CONS resource\n",
			__func__, bam_enable_strings[cur_bam]);
			__func__, bam_enable_strings[cur_bam]);


	spin_lock(&usb_bam_lock);
	spin_lock(&usb_bam_ipa_handshake_info_lock);
	spin_lock(&usb_bam_ipa_handshake_info_lock);
	info[cur_bam].cur_cons_state = IPA_RM_RESOURCE_GRANTED;
	info[cur_bam].cur_cons_state = IPA_RM_RESOURCE_GRANTED;


	spin_lock(&usb_bam_lock);

	switch (info[cur_bam].cur_bam_mode) {
	switch (info[cur_bam].cur_bam_mode) {
	case USB_BAM_DEVICE:
	case USB_BAM_DEVICE:
		if (ctx.pipes_enabled_per_bam[cur_bam] &&
		if (ctx.pipes_enabled_per_bam[cur_bam] &&