diff mbox series

[net,3/3] bnxt_en: Restore PTP tx_avail count in case of skb_pad() error

Message ID 20240618215313.29631-4-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit 1e7962114c10957fe4d10a15eb714578a394e90b
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Bug fixes for net | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 859 this patch: 859
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: richardcochran@gmail.com
netdev/build_clang success Errors and warnings before: 863 this patch: 863
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 fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 865 this patch: 865
netdev/checkpatch warning WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: 99dc214eaeb2 ("bnxt_en: Restore PTP tx_avail count in case of skb_pad() error")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan June 18, 2024, 9:53 p.m. UTC
From: Pavan Chebbi <pavan.chebbi@broadcom.com>

The current code only restores PTP tx_avail count when we get DMA
mapping errors.  Fix it so that the PTP tx_avail count will be
restored for both DMA mapping errors and skb_pad() errors.
Otherwise PTP TX timestamp will not be available after a PTP
packet hits the skb_pad() error.

Fixes: 83bb623c968e ("bnxt_en: Transmit and retrieve packet timestamps"
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Simon Horman June 19, 2024, 8:02 p.m. UTC | #1
On Tue, Jun 18, 2024 at 02:53:13PM -0700, Michael Chan wrote:
> From: Pavan Chebbi <pavan.chebbi@broadcom.com>
> 
> The current code only restores PTP tx_avail count when we get DMA
> mapping errors.  Fix it so that the PTP tx_avail count will be
> restored for both DMA mapping errors and skb_pad() errors.
> Otherwise PTP TX timestamp will not be available after a PTP
> packet hits the skb_pad() error.
> 
> Fixes: 83bb623c968e ("bnxt_en: Transmit and retrieve packet timestamps"
> Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
> Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 89d29d6d7517..a6d69a45fa01 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -732,9 +732,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  	return NETDEV_TX_OK;
>  
>  tx_dma_error:
> -	if (BNXT_TX_PTP_IS_SET(lflags))
> -		atomic_inc(&bp->ptp_cfg->tx_avail);
> -
>  	last_frag = i;
>  
>  	/* start back at beginning and unmap skb */
> @@ -756,6 +753,8 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
>  tx_free:
>  	dev_kfree_skb_any(skb);
>  tx_kick_pending:
> +	if (BNXT_TX_PTP_IS_SET(lflags))
> +		atomic_inc(&bp->ptp_cfg->tx_avail);
>  	if (txr->kick_pending)
>  		bnxt_txr_db_kick(bp, txr, txr->tx_prod);
>  	txr->tx_buf_ring[txr->tx_prod].skb = NULL;

This now also applies to jumps to tx_free.

I assume that is fine because although atomic_dec_if_positive() called on
&bp->ptp_cfg->tx_avail, has not net been called, neither has the bit
TX_BD_FLAGS_STAMP of lflags been set.

Reviewed-by: Simon Horman <horms@kernel.org>
Simon Horman June 19, 2024, 8:04 p.m. UTC | #2
On Wed, Jun 19, 2024 at 09:02:53PM +0100, Simon Horman wrote:
> On Tue, Jun 18, 2024 at 02:53:13PM -0700, Michael Chan wrote:
> > From: Pavan Chebbi <pavan.chebbi@broadcom.com>
> > 
> > The current code only restores PTP tx_avail count when we get DMA
> > mapping errors.  Fix it so that the PTP tx_avail count will be
> > restored for both DMA mapping errors and skb_pad() errors.
> > Otherwise PTP TX timestamp will not be available after a PTP
> > packet hits the skb_pad() error.
> > 
> > Fixes: 83bb623c968e ("bnxt_en: Transmit and retrieve packet timestamps"

Sorry, I missed that the Fixes tag is truncated.

Fixes: 83bb623c968e ("bnxt_en: Transmit and retrieve packet timestamps")

...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 89d29d6d7517..a6d69a45fa01 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -732,9 +732,6 @@  static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	return NETDEV_TX_OK;
 
 tx_dma_error:
-	if (BNXT_TX_PTP_IS_SET(lflags))
-		atomic_inc(&bp->ptp_cfg->tx_avail);
-
 	last_frag = i;
 
 	/* start back at beginning and unmap skb */
@@ -756,6 +753,8 @@  static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
 tx_free:
 	dev_kfree_skb_any(skb);
 tx_kick_pending:
+	if (BNXT_TX_PTP_IS_SET(lflags))
+		atomic_inc(&bp->ptp_cfg->tx_avail);
 	if (txr->kick_pending)
 		bnxt_txr_db_kick(bp, txr, txr->tx_prod);
 	txr->tx_buf_ring[txr->tx_prod].skb = NULL;