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

Commit 9c0c0934 authored by Sujeev Dias's avatar Sujeev Dias Committed by Chris Lew
Browse files

mhi: dev: satellite: synchronize subsystem connect and device assert



Subsystem can connect while device removal is in progress. This
can lead to a corner case where a stale work item is pending in
the workqueue after it has either already been flushed or is
never flushed before parent structure gets freed. Synchronize
threads to avoid this scenario and flush workqueues every time.

CRs-Fixed: 2500822b
Change-Id: I9f337e1b00506e70143cbb74f1c75034c56b38be
Acked-by: default avatarBhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 6d6aa1c9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -893,6 +893,8 @@ static int mhi_sat_rpmsg_probe(struct rpmsg_device *rpdev)
	if (!subsys)
		return -EINVAL;

	mutex_lock(&subsys->cntrl_mutex);

	MHI_SUBSYS_LOG("Received RPMSG probe\n");

	dev_set_drvdata(&rpdev->dev, subsys);
@@ -905,6 +907,8 @@ static int mhi_sat_rpmsg_probe(struct rpmsg_device *rpdev)
		schedule_work(&sat_cntrl->connect_work);
	spin_unlock_irq(&subsys->cntrl_lock);

	mutex_unlock(&subsys->cntrl_mutex);

	return 0;
}

@@ -978,6 +982,13 @@ static void mhi_sat_dev_remove(struct mhi_device *mhi_dev)
		return;
	}

	/*
	 * cancel any pending work as it is possible that work gets queued
	 * when rpmsg probe comes in before controller is removed
	 */
	cancel_work_sync(&sat_cntrl->connect_work);
	cancel_work_sync(&sat_cntrl->process_work);

	/* remove address mappings */
	mutex_lock(&sat_cntrl->list_mutex);
	list_for_each_entry_safe(buf, tmp, &sat_cntrl->addr_map_list, node) {