linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Sub ns increment fixes in Macb PTP
@ 2019-06-27  6:20 Harini Katakam
  2019-06-27  6:20 ` [PATCH 1/2] net: macb: Add separate definition for PPM fraction Harini Katakam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Harini Katakam @ 2019-06-27  6:20 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea, rafalo,
	andrei.pistirica
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

The subns increment register fields are not captured correctly in the
driver. Fix the same and also increase the subns incr resolution.

Sub ns resolution was increased to 24 bits in r1p06f2 version. To my
knowledge, this PTP driver, with its current BD time stamp
implementation, is only useful to that version or above. So, I have
increased the resolution unconditionally. Please let me know if there
is any IP versions incompatible with this - there is no register to
obtain this information from.

Changes from RFC:
None

Harini Katakam (2):
  net: macb: Add separate definition for PPM fraction
  net: macb: Fix SUBNS increment and increase resolution

 drivers/net/ethernet/cadence/macb.h     | 9 ++++++++-
 drivers/net/ethernet/cadence/macb_ptp.c | 7 +++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] net: macb: Add separate definition for PPM fraction
  2019-06-27  6:20 [PATCH 0/2] Sub ns increment fixes in Macb PTP Harini Katakam
@ 2019-06-27  6:20 ` Harini Katakam
  2019-06-27  6:21 ` [PATCH 2/2] net: macb: Fix SUBNS increment and increase resolution Harini Katakam
  2019-06-29 18:09 ` [PATCH 0/2] Sub ns increment fixes in Macb PTP David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Harini Katakam @ 2019-06-27  6:20 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea, rafalo,
	andrei.pistirica
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

The scaled ppm parameter passed to _adjfine() contains a 16 bit
fraction. This just happens to be the same as SUBNSINCR_SIZE now.
Hence define this separately.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
---
 drivers/net/ethernet/cadence/macb.h     | 3 +++
 drivers/net/ethernet/cadence/macb_ptp.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 515bfd2..90bc70b 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -834,6 +834,9 @@ struct gem_tx_ts {
 /* limit RX checksum offload to TCP and UDP packets */
 #define GEM_RX_CSUM_CHECKED_MASK		2
 
+/* Scaled PPM fraction */
+#define PPM_FRACTION	16
+
 /* struct macb_tx_skb - data about an skb which is being transmitted
  * @skb: skb currently being transmitted, only set for the last buffer
  *       of the frame
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 0a8aca8..6276eac 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -135,7 +135,7 @@ static int gem_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 	 * (temp / USEC_PER_SEC) + 0.5
 	 */
 	adj += (USEC_PER_SEC >> 1);
-	adj >>= GEM_SUBNSINCR_SIZE; /* remove fractions */
+	adj >>= PPM_FRACTION; /* remove fractions */
 	adj = div_u64(adj, USEC_PER_SEC);
 	adj = neg_adj ? (word - adj) : (word + adj);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: macb: Fix SUBNS increment and increase resolution
  2019-06-27  6:20 [PATCH 0/2] Sub ns increment fixes in Macb PTP Harini Katakam
  2019-06-27  6:20 ` [PATCH 1/2] net: macb: Add separate definition for PPM fraction Harini Katakam
@ 2019-06-27  6:21 ` Harini Katakam
  2019-06-29 18:09 ` [PATCH 0/2] Sub ns increment fixes in Macb PTP David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Harini Katakam @ 2019-06-27  6:21 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea, rafalo,
	andrei.pistirica
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

The subns increment register has 24 bits as follows:
RegBit[15:0] = Subns[23:8]; RegBit[31:24] = Subns[7:0]

Fix the same in the driver and increase sub ns resolution to the
best capable, 24 bits. This should be the case on all GEM versions
that this PTP driver supports.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
---
 drivers/net/ethernet/cadence/macb.h     | 6 +++++-
 drivers/net/ethernet/cadence/macb_ptp.c | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 90bc70b..03983bd 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -496,7 +496,11 @@
 
 /* Bitfields in TISUBN */
 #define GEM_SUBNSINCR_OFFSET			0
-#define GEM_SUBNSINCR_SIZE			16
+#define GEM_SUBNSINCRL_OFFSET			24
+#define GEM_SUBNSINCRL_SIZE			8
+#define GEM_SUBNSINCRH_OFFSET			0
+#define GEM_SUBNSINCRH_SIZE			16
+#define GEM_SUBNSINCR_SIZE			24
 
 /* Bitfields in TI */
 #define GEM_NSINCR_OFFSET			0
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 6276eac..43a3f0d 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -104,7 +104,10 @@ static int gem_tsu_incr_set(struct macb *bp, struct tsu_incr *incr_spec)
 	 * to take effect.
 	 */
 	spin_lock_irqsave(&bp->tsu_clk_lock, flags);
-	gem_writel(bp, TISUBN, GEM_BF(SUBNSINCR, incr_spec->sub_ns));
+	/* RegBit[15:0] = Subns[23:8]; RegBit[31:24] = Subns[7:0] */
+	gem_writel(bp, TISUBN, GEM_BF(SUBNSINCRL, incr_spec->sub_ns) |
+		   GEM_BF(SUBNSINCRH, (incr_spec->sub_ns >>
+			  GEM_SUBNSINCRL_SIZE)));
 	gem_writel(bp, TI, GEM_BF(NSINCR, incr_spec->ns));
 	spin_unlock_irqrestore(&bp->tsu_clk_lock, flags);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Sub ns increment fixes in Macb PTP
  2019-06-27  6:20 [PATCH 0/2] Sub ns increment fixes in Macb PTP Harini Katakam
  2019-06-27  6:20 ` [PATCH 1/2] net: macb: Add separate definition for PPM fraction Harini Katakam
  2019-06-27  6:21 ` [PATCH 2/2] net: macb: Fix SUBNS increment and increase resolution Harini Katakam
@ 2019-06-29 18:09 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-29 18:09 UTC (permalink / raw)
  To: harini.katakam
  Cc: nicolas.ferre, richardcochran, claudiu.beznea, rafalo,
	andrei.pistirica, netdev, linux-kernel, michal.simek,
	harinikatakamlinux

From: Harini Katakam <harini.katakam@xilinx.com>
Date: Thu, 27 Jun 2019 11:50:58 +0530

> The subns increment register fields are not captured correctly in the
> driver. Fix the same and also increase the subns incr resolution.
> 
> Sub ns resolution was increased to 24 bits in r1p06f2 version. To my
> knowledge, this PTP driver, with its current BD time stamp
> implementation, is only useful to that version or above. So, I have
> increased the resolution unconditionally. Please let me know if there
> is any IP versions incompatible with this - there is no register to
> obtain this information from.
> 
> Changes from RFC:
> None

Series applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-29 18:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27  6:20 [PATCH 0/2] Sub ns increment fixes in Macb PTP Harini Katakam
2019-06-27  6:20 ` [PATCH 1/2] net: macb: Add separate definition for PPM fraction Harini Katakam
2019-06-27  6:21 ` [PATCH 2/2] net: macb: Fix SUBNS increment and increase resolution Harini Katakam
2019-06-29 18:09 ` [PATCH 0/2] Sub ns increment fixes in Macb PTP David Miller

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).