linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Richard Cochran <richardcochran@gmail.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, Sekhar Nori <nsekhar@ti.com>,
	<linux-kernel@vger.kernel.org>,
	Murali Karicheri <m-karicheri2@ti.com>,
	<linux-omap@vger.kernel.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [PATCH net-next v5 03/10] net: ethernet: ti: cpts: move tc mult update in cpts_fifo_read()
Date: Thu, 23 Apr 2020 17:20:15 +0300	[thread overview]
Message-ID: <20200423142022.10538-4-grygorii.strashko@ti.com> (raw)
In-Reply-To: <20200423142022.10538-1-grygorii.strashko@ti.com>

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: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/ti/cpts.c | 8 ++++++--
 drivers/net/ethernet/ti/cpts.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
index f40a864d8c36..a2974b542bed 100644
--- a/drivers/net/ethernet/ti/cpts.c
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -165,6 +165,10 @@ static int cpts_fifo_read(struct cpts *cpts, int match)
 		case CPTS_EV_PUSH:
 			WRITE_ONCE(cpts->cur_timestamp, lo);
 			timecounter_read(&cpts->tc);
+			if (cpts->mult_new) {
+				cpts->cc.mult = cpts->mult_new;
+				cpts->mult_new = 0;
+			}
 			break;
 		case CPTS_EV_TX:
 			if (cpts_match_tx_ts(cpts, event)) {
@@ -228,9 +232,9 @@ static int cpts_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 
 	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);
 
diff --git a/drivers/net/ethernet/ti/cpts.h b/drivers/net/ethernet/ti/cpts.h
index 32ecd1ce4d3b..421630049ee7 100644
--- a/drivers/net/ethernet/ti/cpts.h
+++ b/drivers/net/ethernet/ti/cpts.h
@@ -116,6 +116,7 @@ struct cpts {
 	unsigned long ov_check_period;
 	struct sk_buff_head txq;
 	u64 cur_timestamp;
+	u32 mult_new;
 };
 
 void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
-- 
2.17.1


  parent reply	other threads:[~2020-04-23 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 14:20 [PATCH net-next v5 00/10] net: ethernet: ti: cpts: add irq and HW_TS_PUSH events Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 01/10] net: ethernet: ti: cpts: use dev_yy() api for logs Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 02/10] net: ethernet: ti: cpts: separate hw counter read from timecounter Grygorii Strashko
2020-04-23 14:20 ` Grygorii Strashko [this message]
2020-04-23 14:20 ` [PATCH net-next v5 04/10] net: ethernet: ti: cpts: switch to use new .gettimex64() interface Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 05/10] net: ethernet: ti: cpts: optimize packet to event matching Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 06/10] net: ethernet: ti: cpts: move tx timestamp processing to ptp worker only Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 07/10] net: ethernet: ti: cpts: rework locking Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 08/10] net: ethernet: ti: cpts: add irq support Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 09/10] net: ethernet: ti: cpts: add support for HW_TS_PUSH events Grygorii Strashko
2020-04-23 14:20 ` [PATCH net-next v5 10/10] net: ethernet: ti: cpsw: enable cpts irq Grygorii Strashko
2020-04-23 19:51 ` [PATCH net-next v5 00/10] net: ethernet: ti: cpts: add irq and HW_TS_PUSH events David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200423142022.10538-4-grygorii.strashko@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=m-karicheri2@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=richardcochran@gmail.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).