linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: stmmac: Fix HW timestamping
@ 2017-10-20 13:37 Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 1/3] net: stmmac: Add missing call to dev_kfree_skb() Jose Abreu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jose Abreu @ 2017-10-20 13:37 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Jose Abreu, David S. Miller, Joao Pinto, Giuseppe Cavallaro,
	Alexandre Torgue

Hi,

Three fixes for HW timestamping feature, all of them for RX side.

Best regards,
Jose Miguel Abreu

David,

I'm targeting this for -next but teel free to apply this in
your -fixes tree if you think its needed. Though, I don't
think anyone is using HW timestamping because these bugs would
appear immediatly.

Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>

Jose Abreu (3):
  net: stmmac: Add missing call to dev_kfree_skb()
  net: stmmac: Fix stmmac_get_rx_hwtstamp()
  net: stmmac: Prevent infinite loop in get_rx_timestamp_status()

 drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c |  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

-- 
1.9.1

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

* [PATCH net-next 1/3] net: stmmac: Add missing call to dev_kfree_skb()
  2017-10-20 13:37 [PATCH net-next 0/3] net: stmmac: Fix HW timestamping Jose Abreu
@ 2017-10-20 13:37 ` Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 2/3] net: stmmac: Fix stmmac_get_rx_hwtstamp() Jose Abreu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jose Abreu @ 2017-10-20 13:37 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Jose Abreu, David S. Miller, Joao Pinto, Giuseppe Cavallaro,
	Alexandre Torgue

When RX HW timestamp is enabled and a frame is discarded we are
not freeing the skb but instead only setting to NULL the entry.

Add a call to dev_kfree_skb_any() so that skb entry is correctly
freed.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0e1b0a3..f7b7906 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3358,6 +3358,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 				 * them in stmmac_rx_refill() function so that
 				 * device can reuse it.
 				 */
+				dev_kfree_skb_any(rx_q->rx_skbuff[entry]);
 				rx_q->rx_skbuff[entry] = NULL;
 				dma_unmap_single(priv->device,
 						 rx_q->rx_skbuff_dma[entry],
-- 
1.9.1

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

* [PATCH net-next 2/3] net: stmmac: Fix stmmac_get_rx_hwtstamp()
  2017-10-20 13:37 [PATCH net-next 0/3] net: stmmac: Fix HW timestamping Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 1/3] net: stmmac: Add missing call to dev_kfree_skb() Jose Abreu
@ 2017-10-20 13:37 ` Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 3/3] net: stmmac: Prevent infinite loop in get_rx_timestamp_status() Jose Abreu
  2017-10-22  2:06 ` [PATCH net-next 0/3] net: stmmac: Fix HW timestamping David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Jose Abreu @ 2017-10-20 13:37 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Jose Abreu, David S. Miller, Joao Pinto, Giuseppe Cavallaro,
	Alexandre Torgue

When using GMAC4 the valid timestamp is from CTX next desc but
we are passing the previous desc to get_rx_timestamp_status()
callback.

Fix this and while at it rework a little bit the function logic.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f7b7906..0d3fd3b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -473,19 +473,18 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
 				   struct dma_desc *np, struct sk_buff *skb)
 {
 	struct skb_shared_hwtstamps *shhwtstamp = NULL;
+	struct dma_desc *desc = p;
 	u64 ns;
 
 	if (!priv->hwts_rx_en)
 		return;
+	/* For GMAC4, the valid timestamp is from CTX next desc. */
+	if (priv->plat->has_gmac4)
+		desc = np;
 
 	/* Check if timestamp is available */
-	if (priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) {
-		/* For GMAC4, the valid timestamp is from CTX next desc. */
-		if (priv->plat->has_gmac4)
-			ns = priv->hw->desc->get_timestamp(np, priv->adv_ts);
-		else
-			ns = priv->hw->desc->get_timestamp(p, priv->adv_ts);
-
+	if (priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) {
+		ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
 		netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
 		shhwtstamp = skb_hwtstamps(skb);
 		memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps));
-- 
1.9.1

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

* [PATCH net-next 3/3] net: stmmac: Prevent infinite loop in get_rx_timestamp_status()
  2017-10-20 13:37 [PATCH net-next 0/3] net: stmmac: Fix HW timestamping Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 1/3] net: stmmac: Add missing call to dev_kfree_skb() Jose Abreu
  2017-10-20 13:37 ` [PATCH net-next 2/3] net: stmmac: Fix stmmac_get_rx_hwtstamp() Jose Abreu
@ 2017-10-20 13:37 ` Jose Abreu
  2017-10-22  2:06 ` [PATCH net-next 0/3] net: stmmac: Fix HW timestamping David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Jose Abreu @ 2017-10-20 13:37 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Jose Abreu, David S. Miller, Joao Pinto, Giuseppe Cavallaro,
	Alexandre Torgue

Prevent infinite loop by correctly setting the loop condition to
break when i == 10.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index e0ef02f..4b286e2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -275,7 +275,7 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats)
 					goto exit;
 				i++;
 
-			} while ((ret == 1) || (i < 10));
+			} while ((ret == 1) && (i < 10));
 
 			if (i == 10)
 				ret = -EBUSY;
-- 
1.9.1

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

* Re: [PATCH net-next 0/3] net: stmmac: Fix HW timestamping
  2017-10-20 13:37 [PATCH net-next 0/3] net: stmmac: Fix HW timestamping Jose Abreu
                   ` (2 preceding siblings ...)
  2017-10-20 13:37 ` [PATCH net-next 3/3] net: stmmac: Prevent infinite loop in get_rx_timestamp_status() Jose Abreu
@ 2017-10-22  2:06 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-10-22  2:06 UTC (permalink / raw)
  To: Jose.Abreu
  Cc: netdev, linux-kernel, Joao.Pinto, peppe.cavallaro, alexandre.torgue

From: Jose Abreu <Jose.Abreu@synopsys.com>
Date: Fri, 20 Oct 2017 14:37:33 +0100

> Three fixes for HW timestamping feature, all of them for RX side.

Series applied to 'net', thanks.

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

end of thread, other threads:[~2017-10-22  2:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20 13:37 [PATCH net-next 0/3] net: stmmac: Fix HW timestamping Jose Abreu
2017-10-20 13:37 ` [PATCH net-next 1/3] net: stmmac: Add missing call to dev_kfree_skb() Jose Abreu
2017-10-20 13:37 ` [PATCH net-next 2/3] net: stmmac: Fix stmmac_get_rx_hwtstamp() Jose Abreu
2017-10-20 13:37 ` [PATCH net-next 3/3] net: stmmac: Prevent infinite loop in get_rx_timestamp_status() Jose Abreu
2017-10-22  2:06 ` [PATCH net-next 0/3] net: stmmac: Fix HW timestamping 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).