netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] 1588 support for Zynq Ultrascale+ MPSoC
@ 2015-09-11  7:57 Harini Katakam
  2015-09-11  7:57 ` [RFC PATCH 1/3] net: macb: Add support for extended BD with a config option Harini Katakam
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Harini Katakam @ 2015-09-11  7:57 UTC (permalink / raw)
  To: nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
	galak-sgV2jX0FEOL9JmXXK+q4OQ,
	boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	harinikatakamlinux-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, harinik-gjFFaj9aHVfQT0dZR+AlfA,
	punnaia-gjFFaj9aHVfQT0dZR+AlfA, michals-gjFFaj9aHVfQT0dZR+AlfA,
	anirudh-gjFFaj9aHVfQT0dZR+AlfA

This series adds 1588 support in Cadence MACB driver for Zynq Ultrascale+ MPSoC

This IP supports HW timestamping and this is accesible through extended BD.
The first patch adds support for extended BD through a config option.
Since this required the use two extra u32 variables in the macb_dma_desc
structure, we opted for a static config option.
The second patch adds support to access the timestamp in TX and RX paths,
register to PTP framework and provide time and frequency adjustment.
This was tested in  two step mode using linuxptp.
The TSU clock is expected to be provided through devicetree.

Harini Katakam (3):
  net: macb: Add support for extended BD with a config option
  net: macb: Add support for 1588 for Zynq Ultrascale+ MPSoC
  devicetree: macb: Add optional property tsu-clk

 Documentation/devicetree/bindings/net/macb.txt |    3 +
 drivers/net/ethernet/cadence/Kconfig           |    8 +
 drivers/net/ethernet/cadence/macb.c            |  376 +++++++++++++++++++++++-
 drivers/net/ethernet/cadence/macb.h            |   72 +++++
 4 files changed, 451 insertions(+), 8 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [RFC PATCH 2/3] net: macb: Add support for 1588 for Zynq Ultrascale+ MPSoC
@ 2016-11-18 13:03 Rafal Ozieblo
  0 siblings, 0 replies; 20+ messages in thread
From: Rafal Ozieblo @ 2016-11-18 13:03 UTC (permalink / raw)
  To: harini.katakam@xilinx.com
  Cc: Nicolas Ferre, Andrei Pistirica, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Richard Cochran

>+static inline void macb_handle_txtstamp(struct macb *bp, struct sk_buff *skb,
>+                                       struct macb_dma_desc *desc)
>+{
>+       u32 ts_s, ts_ns;
>+       u8 msg_type;
>+
>+       skb_copy_from_linear_data_offset(skb, GEM_TX_PTPHDR_OFFSET,
>+                                        &msg_type, 1);
>+
>+       /* Bit[32:6] of TS secs from register
>+        * Bit[5:0] of TS secs from BD
>+        * TS nano secs is available in BD
>+        */
>+       if (msg_type & 0x2) {
>+               /* PTP Peer Event Frame packets */
>+               ts_s = (gem_readl(bp, 1588PEERTXSEC) & GEM_SEC_MASK) |
>+                      ((desc->tsl >> GEM_TSL_SEC_RS) |
>+                      (desc->tsh << GEM_TSH_SEC_LS));
>+               ts_ns = desc->tsl & GEM_TSL_NSEC_MASK;
>+       } else {
>+               /* PTP Event Frame packets */
>+               ts_s = (gem_readl(bp, 1588TXSEC) & GEM_SEC_MASK) |
>+                      ((desc->tsl >> GEM_TSL_SEC_RS) |
>+                      (desc->tsh << GEM_TSH_SEC_LS));
>+               ts_ns = desc->tsl & GEM_TSL_NSEC_MASK;
>+       }
>+
>+       struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
>+
>+       memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
>+       shhwtstamps->hwtstamp = ns_to_ktime((ts_s * NS_PER_SEC) + ts_ns);
>+       skb_tstamp_tx(skb, skb_hwtstamps(skb));
>+}
>+
> static void macb_tx_interrupt(struct macb_queue *queue)
> {
>        unsigned int tail;
>@@ -703,6 +745,10 @@ static void macb_tx_interrupt(struct macb_queue *queue)
>                                bp->stats.tx_bytes += skb->len;
>                        }
>
>+#ifdef CONFIG_MACB_EXT_BD
>+                       if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)
>+                               macb_handle_txtstamp(bp, skb, desc);
>+#endif
>                        /* Now we can safely release resources */
>                        macb_tx_unmap(bp, tx_skb);
>
>@@ -796,6 +842,39 @@ static void discard_partial_frame(struct macb *bp,
>unsigned int begin,
>         */
> }

I think, you can not do it in that way. 
It will hold two locks. If you enable appropriate option in kernel (as far as I remember CONFIG_DEBUG_SPINLOCK) you will get a warning here.

Please look at following call-stack:

1. macb_interrupt()   // spin_lock(&bp->lock) is taken
2. macb_tx_interrupt()
3. macb_handle_txtstamp()
4. skb_tstamp_tx()
5. __skb_tstamp_tx()
6. skb_may_tx_timestamp()
7. read_lock_bh() // second lock is taken

I know that those are different locks and different types. But this could lead to deadlocks. This is the reason of warning I could see.
And this is the reason why I get timestamp in interrupt routine but pass it to skb outside interrupt (using circular buffer). 

Best regards,

Rafal Ozieblo   |   Firmware System Engineer, 
phone nbr.: +48 32 5085469 

www.cadence.com

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

end of thread, other threads:[~2016-11-18 13:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-11  7:57 [RFC PATCH 0/3] 1588 support for Zynq Ultrascale+ MPSoC Harini Katakam
2015-09-11  7:57 ` [RFC PATCH 1/3] net: macb: Add support for extended BD with a config option Harini Katakam
     [not found]   ` <1441958258-35441-2-git-send-email-harinik-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2015-09-21 17:48     ` Harini Katakam
2015-09-11  7:57 ` [RFC PATCH 2/3] net: macb: Add support for 1588 for Zynq Ultrascale+ MPSoC Harini Katakam
     [not found]   ` <1441958258-35441-3-git-send-email-harinik-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2015-09-21 17:49     ` Harini Katakam
     [not found]       ` <CAFcVECLfXL-=efbUhNeKhiFQgtfv6Z1+JJckg+js7DM-LfFeSw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-21 18:39         ` Richard Cochran
2015-09-22  4:21           ` Harini Katakam
2016-08-09 16:40       ` Nicolas Ferre
2016-08-09 16:56         ` Punnaiah Choudary Kalluri
2016-08-10  4:56           ` Harini Katakam
     [not found]           ` <03CA77BA8AF6F1469AEDFBDA1322A7B74A1C4205-4lKfpRxZ5ekkx2a1wsGfbYg+Gb3gawCHQz34XiSyOiE@public.gmane.org>
2016-08-10  6:11             ` Michal Simek
2016-08-10 10:12           ` Andrei Pistirica
2016-08-10 10:22             ` Harini Katakam
2015-09-11  7:57 ` [RFC PATCH 3/3] devicetree: macb: Add optional property tsu-clk Harini Katakam
2015-09-11 16:52   ` Sören Brinkmann
2015-09-14  4:09     ` Harini Katakam
2015-09-14  7:58       ` Boris Brezillon
2015-09-14 14:44         ` Sören Brinkmann
2015-09-14 17:34           ` Harini Katakam
  -- strict thread matches above, loose matches on Subject: below --
2016-11-18 13:03 [RFC PATCH 2/3] net: macb: Add support for 1588 for Zynq Ultrascale+ MPSoC Rafal Ozieblo

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