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

Commit 7dca19a9 authored by Sujeev Dias's avatar Sujeev Dias Committed by Gerrit - the friendly Code Review server
Browse files

mhi: core: Protect DB register when handling DB MODE



Possibility exist when handling a DB MODE event another
core to queue a TRE to same channel.  During that time
CC ctxt WP may get updated, however DB MODE event thread
still be using a stale WP.  Add a lock to synchronize
DB MODE event thread and queue TRE thread.

CRs-Fixed: 1005752
Change-Id: I7f285da8751a867a1c3d651466537368799eb657
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent 50239ba4
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1166,6 +1166,7 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
	{
		struct mhi_ring *chan_ctxt = NULL;
		u64 db_value = 0;
		unsigned long flags;

		mhi_dev_ctxt->flags.uldl_enabled = 1;
		chan = MHI_EV_READ_CHID(EV_CHID, event);
@@ -1173,6 +1174,8 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
		chan_ctxt =
			&mhi_dev_ctxt->mhi_local_chan_ctxt[chan];
		mhi_log(MHI_MSG_INFO, "DB_MODE/OOB Detected chan %d.\n", chan);
		spin_lock_irqsave(&mhi_dev_ctxt->db_write_lock[chan],
				  flags);
		if (chan_ctxt->wp != chan_ctxt->rp) {
			db_value = mhi_v2p_addr(mhi_dev_ctxt,
						MHI_RING_TYPE_XFER_RING, chan,
@@ -1184,6 +1187,8 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt,
		client_handle = mhi_dev_ctxt->client_handle_list[chan];
		if (NULL != client_handle)
			result->transaction_status = -ENOTCONN;
		spin_unlock_irqrestore(&mhi_dev_ctxt->db_write_lock[chan],
				       flags);
		break;
	}
	case MHI_EVENT_CC_BAD_TRE: