From aa01212fe53d376451366684b3e42e7c8d0b8667 Mon Sep 17 00:00:00 2001 From: Bhaumik Bhatt Date: Wed, 15 Jan 2020 19:30:16 -0800 Subject: [PATCH] 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: Bhaumik Bhatt --- drivers/bus/mhi/core/mhi_internal.h | 2 ++ drivers/bus/mhi/core/mhi_main.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/bus/mhi/core/mhi_internal.h b/drivers/bus/mhi/core/mhi_internal.h index 379c28ed9e8c..cb45bcd3f216 100644 --- a/drivers/bus/mhi/core/mhi_internal.h +++ b/drivers/bus/mhi/core/mhi_internal.h @@ -716,6 +716,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; @@ -725,6 +726,7 @@ struct tsync_node { struct mhi_timesync { void __iomem *time_reg; + u32 int_sequence; spinlock_t lock; /* list protection */ struct list_head head; }; diff --git a/drivers/bus/mhi/core/mhi_main.c b/drivers/bus/mhi/core/mhi_main.c index aadd7c9daec9..eb9d89b4b281 100644 --- a/drivers/bus/mhi/core/mhi_main.c +++ b/drivers/bus/mhi/core/mhi_main.c @@ -1427,7 +1427,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))) { @@ -1448,7 +1448,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); @@ -1468,9 +1468,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); @@ -2631,7 +2631,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; @@ -2656,7 +2661,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();