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

Commit d4b68e76 authored by Sujeev Dias's avatar Sujeev Dias
Browse files

mhi: core: release pm_lock before removing MHI devices



During MHI shutdown deadlock could occur between device remove
and device probe. During remove, MHI host acquires pm_lock and
attempts to grab device lock while in probe, base driver acquires
device lock and attempts to grab pm lock. To avoid this deadlock,
release pm lock before removing devices.

CRs-Fixed: 2359701
Change-Id: I1fa28e3bc6104fd5de95d7ee82dd4a2bc1b9905f
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 94da5973
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -564,13 +564,13 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl,
		tasklet_kill(&mhi_event->task);
		tasklet_kill(&mhi_event->task);
	}
	}


	mutex_unlock(&mhi_cntrl->pm_mutex);

	MHI_LOG("Reset all active channels and remove mhi devices\n");
	MHI_LOG("Reset all active channels and remove mhi devices\n");
	device_for_each_child(mhi_cntrl->dev, NULL, mhi_destroy_device);
	device_for_each_child(mhi_cntrl->dev, NULL, mhi_destroy_device);


	MHI_LOG("Finish resetting channels\n");
	MHI_LOG("Finish resetting channels\n");


	/* release lock and wait for all pending thread to complete */
	mutex_unlock(&mhi_cntrl->pm_mutex);
	MHI_LOG("Waiting for all pending threads to complete\n");
	MHI_LOG("Waiting for all pending threads to complete\n");
	wake_up_all(&mhi_cntrl->state_event);
	wake_up_all(&mhi_cntrl->state_event);
	flush_work(&mhi_cntrl->st_worker);
	flush_work(&mhi_cntrl->st_worker);