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

Commit a057cc3b authored by Dov Levenglick's avatar Dov Levenglick
Browse files

usb: bam: fix race condition between usb bam and controller



When waking up with the USB cable disconnected, the DWC3 driver
invokes its set_suspend function, which calls
msm_bam_device_lpm_ok. If the usb_bam_probe function hasn't
finished, this results an an attempt to call spin_lock on an
uninitialized lock.
Adding an automatic successful return from msm_bam_device_lpm_ok
if the probe hasn't finished, since this function should return 0
whenever the bam is not a blocking factor to the suspend flow.

Change-Id: Ief52bf12877124281dfd41d5639e72da8055ee5b
Signed-off-by: default avatarDov Levenglick <dovl@codeaurora.org>
parent 4f7295be
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ static struct usb_bam_pipe_connect *usb_bam_connections;
static struct usb_bam_ctx_type ctx;
static struct usb_bam_host_info host_info[MAX_BAMS];
static struct device *usb_device;
static bool probe_finished;

static int __usb_bam_register_wake_cb(int idx, int (*callback)(void *user),
	void *param, bool trigger_cb_per_pipe);
@@ -3184,6 +3185,7 @@ static int usb_bam_probe(struct platform_device *pdev)
	spin_lock_init(&usb_bam_ipa_handshake_info_lock);
	usb_bam_ipa_create_resources();
	spin_lock_init(&usb_bam_lock);
	probe_finished = true;

	return ret;
}
@@ -3271,6 +3273,14 @@ bool msm_bam_device_lpm_ok(enum usb_bam bam_type)
{
	pr_debug("%s: enter bam%s\n", __func__, bam_enable_strings[bam_type]);

	/*
	 * There is the possibility of a race between the usb_bam_probe()
	 * function initializing the relevant spinlocks and structures, vs. the
	 * USB controller's suspend function being invoked by the pm module.
	 */
	if (!probe_finished)
		return 0;

	spin_lock(&usb_bam_ipa_handshake_info_lock);
	if (info[bam_type].lpm_wait_handshake ||
		info[bam_type].lpm_wait_pipes) {