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

Commit b486f958 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss Committed by Gerrit - the friendly Code Review server
Browse files

msm: mhi_dev: Add event lock



There can be multiple MHI channels sending completion event
after processing read/write operations. Add a synchronous
lock when sending event completion to the host to prevent
potential race condition.

Change-Id: Ic927437b7559a50f981e40676889cb33508c497e
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 77813844
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -456,6 +456,7 @@ static int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring,
		}
	}

	mutex_lock(&mhi->mhi_event_lock);
	/* add the ring element */
	mhi_dev_add_element(ring, el);

@@ -470,6 +471,7 @@ static int mhi_dev_send_event(struct mhi_dev *mhi, int evnt_ring,
	 */
	wmb();

	mutex_unlock(&mhi->mhi_event_lock);
	mhi_log(MHI_MSG_VERBOSE, "event sent:\n");
	mhi_log(MHI_MSG_VERBOSE, "evnt ptr : 0x%llx\n", el->evt_tr_comp.ptr);
	mhi_log(MHI_MSG_VERBOSE, "evnt len : 0x%x\n", el->evt_tr_comp.len);
@@ -1836,6 +1838,7 @@ static int mhi_dev_probe(struct platform_device *pdev)
	INIT_LIST_HEAD(&mhi_ctx->event_ring_list);
	INIT_LIST_HEAD(&mhi_ctx->process_ring_list);
	mutex_init(&mhi_ctx->mhi_lock);
	mutex_init(&mhi_ctx->mhi_event_lock);
	mutex_init(&mhi_ctx->mhi_write_test);

	rc = mhi_init(mhi_ctx);
+1 −0
Original line number Diff line number Diff line
@@ -480,6 +480,7 @@ struct mhi_dev {
	/* Scheduler work */
	struct work_struct		chdb_ctrl_work;
	struct mutex			mhi_lock;
	struct mutex			mhi_event_lock;

	/* process a ring element */
	struct workqueue_struct		*pending_ring_wq;