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 <bbhatt@codeaurora.org>
This commit is contained in:
Bhaumik Bhatt 2020-01-15 19:30:16 -08:00 • committed by Gerrit - the friendly Code Review server
commit aa01212fe5
2 changed files with 12 additions and 5 deletions

View file

@ -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;
};

View file

@ -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();