bnxt_en: Bug fixes.
Michael Chan
maintainercover bnxt_en: Bug fixes.
There are 4 driver fixes in this series:
1. Fix RX buffer leak during OOM condition.
2. Call pci_disable_msix() under correct conditions to prevent hitting BUG.
3. Reduce unneeded mmeory allocation in kdump kernel to prevent OOM.
4. Don't read device serial number on VFs because it is not supported.
Please queue #1, #2, #3 for -stable as well. Thanks.
Michael Chan (3):
bnxt_en: Fix aggregation buffer leak under OOM condition.
bnxt_en: Fix possible BUG() condition when calling pci_disable_msix().
bnxt_en: Reduce memory usage when running in kdump kernel.
Vasundhara Volam (1):
bnxt_en: Device serial number is supported only for PFs.
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 30 +++++++++++++---------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 6 +++-- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-)
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 1/4 bnxt_en: Fix aggregation buffer leak under OOM condition.
For every RX packet, the driver replenishes all buffers used for that packet and puts them back into the RX ring and RX aggregation ring. In one code path where the RX packet has one RX buffer and one or more aggregation buffers, we missed recycling the aggregation buffer(s) if we are unable to allocate a new SKB buffer. This leads to the aggregation ring slowly running out of buffers over time. Fix it by properly recycling the aggregation buffers.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -0
@@ -1642,6 +1642,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, skb =bnxt_copy_skb (bnapi, data_ptr, len, dma_addr);bnxt_reuse_rx_data (rxr, cons, data);if (!skb) { +if (agg_bufs) +bnxt_reuse_rx_agg_bufs (cpr, cp_cons, agg_bufs); rc = -ENOMEM ; goto next_rx; }
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 2/4 bnxt_en: Fix possible BUG() condition when calling pci_disable_msix().
In reply to Michael ChanWhen making configuration changes, the driver calls bnxt_close_nic() and then bnxt_open_nic() for the changes to take effect. A parameter irq_re_init is passed to the call sequence to indicate if IRQ should be re-initialized. This irq_re_init parameter needs to be included in the bnxt_reserve_rings() call. bnxt_reserve_rings() can only call pci_disable_msix() if the irq_re_init parameter is true, otherwise it may hit BUG() because some IRQs may not have been freed yet.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -6
@@ -7618,22 +7618,23 @@ static void bnxt_clear_int_mode(struct bnxt *bp) bp->flags &= ~BNXT_FLAG_USING_MSIX ; } -int bnxt_reserve_rings (struct bnxt *bp) +int bnxt_reserve_rings (struct bnxt *bp,bool irq_re_init) {int tcs =netdev_get_num_tc (bp->dev); -bool reinit_irq = false; +bool irq_cleared = false;int rc;if (!bnxt_need_reserve_rings (bp))return 0 ; -if (BNXT_NEW_RM (bp) && (bnxt_get_num_msix (bp) != bp->total_irqs)) { +if (irq_re_init &&BNXT_NEW_RM (bp) && +bnxt_get_num_msix (bp) != bp->total_irqs) {bnxt_ulp_irq_stop (bp);bnxt_clear_int_mode (bp); - reinit_irq = true; + irq_cleared = true; } rc =__bnxt_reserve_rings (bp); -if (reinit_irq) { +if (irq_cleared) {if (!rc) rc =bnxt_init_int_mode (bp);bnxt_ulp_irq_restart (bp, rc);
@@ -8532,7 +8533,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)return rc; } } - rc =bnxt_reserve_rings (bp); + rc =bnxt_reserve_rings (bp, irq_re_init);if (rc)return rc; if ((bp->flags & BNXT_FLAG_RFS) &&
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -1
@@ -1790,7 +1790,7 @@ unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp);unsigned int bnxt_get_avail_cp_rings_for_en (struct bnxt *bp);int bnxt_get_avail_msix (struct bnxt *bp,int num); -int bnxt_reserve_rings (struct bnxt *bp); +int bnxt_reserve_rings (struct bnxt *bp,bool irq_re_init);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);int bnxt_hwrm_set_pause (struct bnxt *);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -1
@@ -831,7 +831,7 @@ static int bnxt_set_channels(struct net_device *dev,*/ } }else { - rc =bnxt_reserve_rings (bp); + rc =bnxt_reserve_rings (bp, true); }return rc;
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +1 -1
@@ -147,7 +147,7 @@ static int bnxt_req_msix_vecs(struct bnxt_en_dev *edev, int ulp_id,bnxt_close_nic (bp, true, false); rc =bnxt_open_nic (bp, true, false); }else { - rc =bnxt_reserve_rings (bp); + rc =bnxt_reserve_rings (bp, true); } }if (rc) {
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 3/4 bnxt_en: Reduce memory usage when running in kdump kernel.
In reply to Michael ChanSkip RDMA context memory allocations, reduce to 1 ring, and disable TPA when running in the kdump kernel. Without this patch, the driver fails to initialize with memory allocation errors when running in a typical kdump kernel.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -2
@@ -6379,7 +6379,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)if (!ctx || (ctx->flags &BNXT_CTX_FLAG_INITED ))return 0 ; -if (bp->flags &BNXT_FLAG_ROCE_CAP ) { +if ((bp->flags &BNXT_FLAG_ROCE_CAP ) && !is_kdump_kernel ()) { pg_lvl =2 ; extra_qps =65536 ; extra_srqs =8192 ;
@@ -10437,7 +10437,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)if (sh) bp->flags |=BNXT_FLAG_SHARED_RINGS ; - dflt_rings =netif_get_num_default_rss_queues (); + dflt_rings =is_kdump_kernel () ?1 :netif_get_num_default_rss_queues ();/* Reduce default rings on multi-port cards so that total default * rings do not exceed CPU count. */
drivers/net/ethernet/broadcom/bnxt/bnxt.h +3 -1
@@ -20,6 +20,7 @@#include <linux/interrupt.h> #include <linux/rhashtable.h> +#include <linux/crash_dump.h> #include <net/devlink.h> #include <net/dst_metadata.h> #include <net/xdp.h>
@@ -1369,7 +1370,8 @@ struct bnxt {#define BNXT_CHIP_TYPE_NITRO_A0 (bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0)#define BNXT_RX_PAGE_MODE (bp) ((bp)->flags & BNXT_FLAG_RX_PAGE_MODE)#define BNXT_SUPPORTS_TPA (bp) (!BNXT_CHIP_TYPE_NITRO_A0(bp) && \ - !(bp->flags & BNXT_FLAG_CHIP_P5)) + !(bp->flags & BNXT_FLAG_CHIP_P5) && \ + !is_kdump_kernel())/* Chip class phase 5 */ #define BNXT_CHIP_P5 (bp) \
Signature · 1 line
2.5.1
Michael Chan
maintainerPATCH 4/4 bnxt_en: Device serial number is supported only for PFs.
In reply to Michael ChanFrom: Vasundhara Volam <[email protected]>
Don't read DSN on VFs that do not have the PCI capability.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -5
@@ -10725,11 +10725,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto init_err_pci_clean; } -/* Read the adapter's DSN to use as the eswitch switch_id */ - rc =bnxt_pcie_dsn_get (bp, bp->switch_id); -if (rc) - goto init_err_pci_clean; - +if (BNXT_PF (bp)) { +/* Read the adapter's DSN to use as the eswitch switch_id */ + rc =bnxt_pcie_dsn_get (bp, bp->switch_id); +if (rc) + goto init_err_pci_clean; + }bnxt_hwrm_func_qcfg (bp);bnxt_hwrm_vnic_qcaps (bp);bnxt_hwrm_port_led_qcaps (bp);
Signature · 1 line
2.5.1
From: Michael Chan <[email protected]>
Date: Wed, 22 May 2019 19:12:53 -0400
Quoted 6 lines
There are 4 driver fixes in this series:
1. Fix RX buffer leak during OOM condition.
2. Callpci_disable_msix()under correct conditions to prevent hitting BUG.
3. Reduce unneeded mmeory allocation in kdump kernel to prevent OOM.
4. Don't read device serial number on VFs because it is not supported.
Series applied.
Quoted 1 line
Please queue #1, #2, #3 for -stable as well. Thanks.
Queued up, thank you.