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

Commit ad5a0eb3 authored by Bhaumik Bhatt's avatar Bhaumik Bhatt
Browse files

mhi: core: use internal sequence numbers for timesync doorbells



When attempting to latch the remote timer value, host should be
using internal sequence numbers that change every time a client
calls the exposed API and rings the time synchronization
doorbell so that device can identify them as different requests.

Change-Id: I2a38b63c6b942df032f096b17b1fdbc2abdb171b
Signed-off-by: default avatarBhaumik Bhatt <bbhatt@codeaurora.org>
parent 1c275c41
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -714,6 +714,7 @@ struct mhi_chan {
struct tsync_node {
	struct list_head node;
	u32 sequence;
	u32 int_sequence;
	u64 local_time;
	u64 remote_time;
	struct mhi_device *mhi_dev;
@@ -723,6 +724,7 @@ struct tsync_node {

struct mhi_timesync {
	void __iomem *time_reg;
	u32 int_sequence;
	spinlock_t lock; /* list protection */
	struct list_head head;
};
+10 −5
Original line number Diff line number Diff line
@@ -1406,7 +1406,7 @@ int mhi_process_tsync_event_ring(struct mhi_controller *mhi_cntrl,
		&mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index];
	struct mhi_timesync *mhi_tsync = mhi_cntrl->mhi_tsync;
	int count = 0;
	u32 sequence, unit;
	u32 int_sequence, unit;
	u64 remote_time;

	if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) {
@@ -1428,7 +1428,7 @@ int mhi_process_tsync_event_ring(struct mhi_controller *mhi_cntrl,

		MHI_ASSERT(type != MHI_PKT_TYPE_TSYNC_EVENT, "!TSYNC event");

		sequence = MHI_TRE_GET_EV_TSYNC_SEQ(local_rp);
		int_sequence = MHI_TRE_GET_EV_TSYNC_SEQ(local_rp);
		unit = MHI_TRE_GET_EV_TSYNC_UNIT(local_rp);
		remote_time = MHI_TRE_GET_EV_TIME(local_rp);

@@ -1448,9 +1448,9 @@ int mhi_process_tsync_event_ring(struct mhi_controller *mhi_cntrl,
			 * device may not able to process all time sync commands
			 * host issue and only process last command it receive
			 */
			if (tsync_node->sequence == sequence) {
			if (tsync_node->int_sequence == int_sequence) {
				tsync_node->cb_func(tsync_node->mhi_dev,
						    sequence,
						    tsync_node->sequence,
						    tsync_node->local_time,
						    remote_time);
				kfree(tsync_node);
@@ -2569,7 +2569,12 @@ int mhi_get_remote_time(struct mhi_device *mhi_dev,
		goto error_no_mem;
	}

	mhi_tsync->int_sequence++;
	if (mhi_tsync->int_sequence == 0xFFFFFFFF)
		mhi_tsync->int_sequence = 0;

	tsync_node->sequence = sequence;
	tsync_node->int_sequence = mhi_tsync->int_sequence;
	tsync_node->cb_func = cb_func;
	tsync_node->mhi_dev = mhi_dev;

@@ -2594,7 +2599,7 @@ int mhi_get_remote_time(struct mhi_device *mhi_dev,

	tsync_node->local_time =
		mhi_cntrl->time_get(mhi_cntrl, mhi_cntrl->priv_data);
	writel_relaxed_no_log(tsync_node->sequence, mhi_cntrl->tsync_db);
	writel_relaxed_no_log(tsync_node->int_sequence, mhi_cntrl->tsync_db);
	/* write must go thru immediately */
	wmb();