From: Simon Horman <horms@kernel.org>
To: Michael Chan <michael.chan@broadcom.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com,
michal.swiatkowski@linux.intel.com, helgaas@kernel.org,
Somnath Kotur <somnath.kotur@broadcom.com>,
Ajit Khaparde <ajit.khaparde@broadcom.com>,
David Wei <dw@davidwei.uk>
Subject: Re: [PATCH net-next v2 09/10] bnxt_en: Extend queue stop/start for TX rings
Date: Fri, 17 Jan 2025 15:29:25 +0000 [thread overview]
Message-ID: <20250117152925.GP6206@kernel.org> (raw)
In-Reply-To: <20250116192343.34535-10-michael.chan@broadcom.com>
On Thu, Jan 16, 2025 at 11:23:42AM -0800, Michael Chan wrote:
> From: Somnath Kotur <somnath.kotur@broadcom.com>
>
> In order to use queue_stop/queue_start to support the new Steering
> Tags, we need to free the TX ring and TX completion ring if it is a
> combined channel with TX/RX sharing the same NAPI. Otherwise
> TX completions will not have the updated Steering Tag. With that
> we can now add napi_disable() and napi_enable() during queue_stop()/
> queue_start(). This will guarantee that NAPI will stop processing
> the completion entries in case there are additional pending entries
> in the completion rings after queue_stop().
>
> There could be some NQEs sitting unprocessed while NAPI is disabled
> thereby leaving the NQ unarmed. Explicitly re-arm the NQ after
> napi_enable() in queue start so that NAPI will resume properly.
>
> Error handling in bnxt_queue_start() requires a reset. If a TX
> ring cannot be allocated or initialized properly, it will cause
> TX timeout. The reset will also free any partially allocated
> rings.
>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>
> ---
> Cc: David Wei <dw@davidwei.uk>
>
> v2:
> Add reset for error handling in queue_start().
> Fix compile error.
>
> Discussion about adding napi_disable()/napi_enable():
>
> https://lore.kernel.org/netdev/5336d624-8d8b-40a6-b732-b020e4a119a2@davidwei.uk/#t
> ---
> drivers/net/ethernet/broadcom/bnxt/bnxt.c | 124 ++++++++++++++++++++--
> 1 file changed, 115 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
...
> @@ -15616,6 +15694,7 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
> struct bnxt_rx_ring_info *rxr, *clone;
> struct bnxt_cp_ring_info *cpr;
> struct bnxt_vnic_info *vnic;
> + struct bnxt_napi *bnapi;
> int i, rc;
>
> rxr = &bp->rx_ring[idx];
> @@ -15633,25 +15712,40 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>
> bnxt_copy_rx_ring(bp, rxr, clone);
>
> + bnapi = rxr->bnapi;
> rc = bnxt_hwrm_rx_ring_alloc(bp, rxr);
> if (rc)
> - return rc;
> + goto err_reset_rx;
>
> rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
> if (rc)
> - goto err_free_hwrm_rx_ring;
> + goto err_reset_rx;
>
> rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
> if (rc)
> - goto err_free_hwrm_cp_ring;
> + goto err_reset_rx;
>
> bnxt_db_write(bp, &rxr->rx_db, rxr->rx_prod);
> if (bp->flags & BNXT_FLAG_AGG_RINGS)
> bnxt_db_write(bp, &rxr->rx_agg_db, rxr->rx_agg_prod);
>
> - cpr = &rxr->bnapi->cp_ring;
> + cpr = &bnapi->cp_ring;
> cpr->sw_stats->rx.rx_resets++;
Hi Somnath and Michael,
cpr is initialised here. However, it appears that the above
"goto err_reset_rx" directives will result in cpr being dereferenced.
Flagged by W=1 builds with clang-19, and Smatch.
>
> + if (bp->flags & BNXT_FLAG_SHARED_RINGS) {
> + cpr->sw_stats->tx.tx_resets++;
> + rc = bnxt_tx_queue_start(bp, idx);
> + if (rc) {
> + netdev_warn(bp->dev,
> + "tx queue restart failed: rc=%d\n", rc);
> + bnapi->tx_fault = 1;
> + goto err_reset;
> + }
> + }
> +
> + napi_enable(&bnapi->napi);
> + bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
> +
> for (i = 0; i <= BNXT_VNIC_NTUPLE; i++) {
> vnic = &bp->vnic_info[i];
>
> @@ -15668,10 +15762,12 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx)
>
> return 0;
>
> -err_free_hwrm_cp_ring:
> - bnxt_hwrm_cp_ring_free(bp, rxr->rx_cpr);
> -err_free_hwrm_rx_ring:
> - bnxt_hwrm_rx_ring_free(bp, rxr, false);
> +err_reset_rx:
> + rxr->bnapi->in_reset = true;
> +err_reset:
> + napi_enable(&bnapi->napi);
> + bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons);
> + bnxt_reset_task(bp, true);
> return rc;
> }
...
next prev parent reply other threads:[~2025-01-17 15:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 19:23 [PATCH net-next v2 00/10] bnxt_en: Add NPAR 1.2 and TPH support Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 01/10] bnxt_en: Set NAPR 1.2 support when registering with firmware Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 02/10] bnxt_en Refactor completion ring allocation logic for P5_PLUS chips Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 03/10] bnxt_en: Refactor TX ring allocation logic Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 04/10] bnxt_en: Refactor completion ring free routine Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 05/10] bnxt_en: Refactor bnxt_free_tx_rings() to free per TX ring Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 06/10] bnxt_en: Refactor RX/RX AGG ring parameters setup for P5_PLUS Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 07/10] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 08/10] bnxt_en: Reallocate RX completion ring for TPH support Michael Chan
2025-01-16 19:23 ` [PATCH net-next v2 09/10] bnxt_en: Extend queue stop/start for TX rings Michael Chan
2025-01-17 6:56 ` Michal Swiatkowski
2025-01-17 15:29 ` Simon Horman [this message]
2025-01-17 18:07 ` kernel test robot
2025-01-30 5:39 ` Dan Carpenter
2025-01-16 19:23 ` [PATCH net-next v2 10/10] bnxt_en: Add TPH support in BNXT driver Michael Chan
2025-01-17 7:04 ` Michal Swiatkowski
2025-01-21 22:15 ` Panicker, Manoj
2025-01-17 15:41 ` Simon Horman
-- strict thread matches above, loose matches on Subject: below --
2025-01-30 0:20 [PATCH net-next v2 09/10] bnxt_en: Extend queue stop/start for TX rings kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250117152925.GP6206@kernel.org \
--to=horms@kernel.org \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=helgaas@kernel.org \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=somnath.kotur@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.