net: stmmac: Fix HW timestamping
Subsystems (4)
cover net: stmmac: Fix HW timestamping
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.
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(-)
Signature · 1 line
1.9.1
PATCH 1/3 net: stmmac: Add missing call to dev_kfree_skb()
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.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
@@ -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],
Signature · 1 line
1.9.1
PATCH 2/3 net: stmmac: Fix stmmac_get_rx_hwtstamp()
In reply to Jose AbreuWhen 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.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -7
@@ -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 ));
Signature · 1 line
1.9.1
PATCH 3/3 net: stmmac: Prevent infinite loop in get_rx_timestamp_status()
In reply to Jose AbreuPrevent infinite loop by correctly setting the loop condition to break when i == 10.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +1 -1
@@ -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 ;
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Jose Abreu <[email protected]>
Date: Fri, 20 Oct 2017 14:37:33 +0100
Quoted 1 line
Three fixes for HW timestamping feature, all of them for RX side.
Series applied to 'net', thanks.