diff mbox series

net: ftgmac100: Ensure tx descriptor updates are visible

Message ID 20240822073006.817173-1-jacky_chou@aspeedtech.com (mailing list archive)
State Accepted
Commit 4186c8d9e6af57bab0687b299df10ebd47534a0a
Delegated to: Netdev Maintainers
Headers show
Series net: ftgmac100: Ensure tx descriptor updates are visible | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 73 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-25--21-00 (tests: 714)

Commit Message

Jacky Chou Aug. 22, 2024, 7:30 a.m. UTC
The driver must ensure TX descriptor updates are visible
before updating TX pointer and TX clear pointer.

This resolves TX hangs observed on AST2600 when running
iperf3.

Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
 drivers/net/ethernet/faraday/ftgmac100.c | 26 ++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Aug. 26, 2024, 1:10 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 22 Aug 2024 15:30:06 +0800 you wrote:
> The driver must ensure TX descriptor updates are visible
> before updating TX pointer and TX clear pointer.
> 
> This resolves TX hangs observed on AST2600 when running
> iperf3.
> 
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> 
> [...]

Here is the summary with links:
  - net: ftgmac100: Ensure tx descriptor updates are visible
    https://git.kernel.org/netdev/net/c/4186c8d9e6af

You are awesome, thank you!
Joel Stanley Sept. 9, 2024, 5:44 a.m. UTC | #2
On Thu, 22 Aug 2024 at 17:00, Jacky Chou <jacky_chou@aspeedtech.com> wrote:
>
> The driver must ensure TX descriptor updates are visible
> before updating TX pointer and TX clear pointer.
>
> This resolves TX hangs observed on AST2600 when running
> iperf3.

Thanks for re-submitting my patch and getting it merged. In the
future, it would be best if you left the authorship, and preserved my
commit message.

 https://lore.kernel.org/all/20201020220639.130696-1-joel@jms.id.au/

Cheers,

Joel

>
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 26 ++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 93862b027be0..9c521d0af7ac 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -582,7 +582,7 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
>         (*processed)++;
>         return true;
>
> - drop:
> +drop:
>         /* Clean rxdes0 (which resets own bit) */
>         rxdes->rxdes0 = cpu_to_le32(status & priv->rxdes0_edorr_mask);
>         priv->rx_pointer = ftgmac100_next_rx_pointer(priv, pointer);
> @@ -666,6 +666,11 @@ static bool ftgmac100_tx_complete_packet(struct ftgmac100 *priv)
>         ftgmac100_free_tx_packet(priv, pointer, skb, txdes, ctl_stat);
>         txdes->txdes0 = cpu_to_le32(ctl_stat & priv->txdes0_edotr_mask);
>
> +       /* Ensure the descriptor config is visible before setting the tx
> +        * pointer.
> +        */
> +       smp_wmb();
> +
>         priv->tx_clean_pointer = ftgmac100_next_tx_pointer(priv, pointer);
>
>         return true;
> @@ -819,6 +824,11 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
>         dma_wmb();
>         first->txdes0 = cpu_to_le32(f_ctl_stat);
>
> +       /* Ensure the descriptor config is visible before setting the tx
> +        * pointer.
> +        */
> +       smp_wmb();
> +
>         /* Update next TX pointer */
>         priv->tx_pointer = pointer;
>
> @@ -839,7 +849,7 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
>
>         return NETDEV_TX_OK;
>
> - dma_err:
> +dma_err:
>         if (net_ratelimit())
>                 netdev_err(netdev, "map tx fragment failed\n");
>
> @@ -861,7 +871,7 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
>          * last fragment, so we know ftgmac100_free_tx_packet()
>          * hasn't freed the skb yet.
>          */
> - drop:
> +drop:
>         /* Drop the packet */
>         dev_kfree_skb_any(skb);
>         netdev->stats.tx_dropped++;
> @@ -1354,7 +1364,7 @@ static void ftgmac100_reset(struct ftgmac100 *priv)
>         ftgmac100_init_all(priv, true);
>
>         netdev_dbg(netdev, "Reset done !\n");
> - bail:
> +bail:
>         if (priv->mii_bus)
>                 mutex_unlock(&priv->mii_bus->mdio_lock);
>         if (netdev->phydev)
> @@ -1554,15 +1564,15 @@ static int ftgmac100_open(struct net_device *netdev)
>
>         return 0;
>
> - err_ncsi:
> +err_ncsi:
>         napi_disable(&priv->napi);
>         netif_stop_queue(netdev);
> - err_alloc:
> +err_alloc:
>         ftgmac100_free_buffers(priv);
>         free_irq(netdev->irq, netdev);
> - err_irq:
> +err_irq:
>         netif_napi_del(&priv->napi);
> - err_hw:
> +err_hw:
>         iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
>         ftgmac100_free_rings(priv);
>         return err;
> --
> 2.25.1
>
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 93862b027be0..9c521d0af7ac 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -582,7 +582,7 @@  static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 	(*processed)++;
 	return true;
 
- drop:
+drop:
 	/* Clean rxdes0 (which resets own bit) */
 	rxdes->rxdes0 = cpu_to_le32(status & priv->rxdes0_edorr_mask);
 	priv->rx_pointer = ftgmac100_next_rx_pointer(priv, pointer);
@@ -666,6 +666,11 @@  static bool ftgmac100_tx_complete_packet(struct ftgmac100 *priv)
 	ftgmac100_free_tx_packet(priv, pointer, skb, txdes, ctl_stat);
 	txdes->txdes0 = cpu_to_le32(ctl_stat & priv->txdes0_edotr_mask);
 
+	/* Ensure the descriptor config is visible before setting the tx
+	 * pointer.
+	 */
+	smp_wmb();
+
 	priv->tx_clean_pointer = ftgmac100_next_tx_pointer(priv, pointer);
 
 	return true;
@@ -819,6 +824,11 @@  static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	dma_wmb();
 	first->txdes0 = cpu_to_le32(f_ctl_stat);
 
+	/* Ensure the descriptor config is visible before setting the tx
+	 * pointer.
+	 */
+	smp_wmb();
+
 	/* Update next TX pointer */
 	priv->tx_pointer = pointer;
 
@@ -839,7 +849,7 @@  static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
 
 	return NETDEV_TX_OK;
 
- dma_err:
+dma_err:
 	if (net_ratelimit())
 		netdev_err(netdev, "map tx fragment failed\n");
 
@@ -861,7 +871,7 @@  static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	 * last fragment, so we know ftgmac100_free_tx_packet()
 	 * hasn't freed the skb yet.
 	 */
- drop:
+drop:
 	/* Drop the packet */
 	dev_kfree_skb_any(skb);
 	netdev->stats.tx_dropped++;
@@ -1354,7 +1364,7 @@  static void ftgmac100_reset(struct ftgmac100 *priv)
 	ftgmac100_init_all(priv, true);
 
 	netdev_dbg(netdev, "Reset done !\n");
- bail:
+bail:
 	if (priv->mii_bus)
 		mutex_unlock(&priv->mii_bus->mdio_lock);
 	if (netdev->phydev)
@@ -1554,15 +1564,15 @@  static int ftgmac100_open(struct net_device *netdev)
 
 	return 0;
 
- err_ncsi:
+err_ncsi:
 	napi_disable(&priv->napi);
 	netif_stop_queue(netdev);
- err_alloc:
+err_alloc:
 	ftgmac100_free_buffers(priv);
 	free_irq(netdev->irq, netdev);
- err_irq:
+err_irq:
 	netif_napi_del(&priv->napi);
- err_hw:
+err_hw:
 	iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
 	ftgmac100_free_rings(priv);
 	return err;