Commit 0d6df3e6 authored by Grygorii Strashko's avatar Grygorii Strashko Committed by David S. Miller

net: ethernet: ti: cpts: move tc mult update in cpts_fifo_read()

Now CPTS driver .adjfreq() generates request to read CPTS current time
(CPTS_EV_PUSH) with intention to process all pending event using previous
frequency adjustment values before switching to the new ones. So
CPTS_EV_PUSH works as a marker to switch to the new frequency adjustment
values. Current code assumes that all job is done in .adjfreq(), but after
enabling IRQ this will not be true any more.

Hence save new frequency adjustment values (mult) and perform actual freq
adjustment in cpts_fifo_read() immediately after CPTS_EV_PUSH is received.
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e66dccce
...@@ -165,6 +165,10 @@ static int cpts_fifo_read(struct cpts *cpts, int match) ...@@ -165,6 +165,10 @@ static int cpts_fifo_read(struct cpts *cpts, int match)
case CPTS_EV_PUSH: case CPTS_EV_PUSH:
WRITE_ONCE(cpts->cur_timestamp, lo); WRITE_ONCE(cpts->cur_timestamp, lo);
timecounter_read(&cpts->tc); timecounter_read(&cpts->tc);
if (cpts->mult_new) {
cpts->cc.mult = cpts->mult_new;
cpts->mult_new = 0;
}
break; break;
case CPTS_EV_TX: case CPTS_EV_TX:
if (cpts_match_tx_ts(cpts, event)) { if (cpts_match_tx_ts(cpts, event)) {
...@@ -228,9 +232,9 @@ static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) ...@@ -228,9 +232,9 @@ static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
spin_lock_irqsave(&cpts->lock, flags); spin_lock_irqsave(&cpts->lock, flags);
cpts_update_cur_time(cpts, CPTS_EV_PUSH); cpts->mult_new = neg_adj ? mult - diff : mult + diff;
cpts->cc.mult = neg_adj ? mult - diff : mult + diff; cpts_update_cur_time(cpts, CPTS_EV_PUSH);
spin_unlock_irqrestore(&cpts->lock, flags); spin_unlock_irqrestore(&cpts->lock, flags);
......
...@@ -116,6 +116,7 @@ struct cpts { ...@@ -116,6 +116,7 @@ struct cpts {
unsigned long ov_check_period; unsigned long ov_check_period;
struct sk_buff_head txq; struct sk_buff_head txq;
u64 cur_timestamp; u64 cur_timestamp;
u32 mult_new;
}; };
void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb); void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment