bnxt_en: Reduce memory usage when running in kdump kernel. [Linux 5.2]

bnxt_en: Reduce memory usage when running in kdump kernel. [Linux 5.2]

This Linux kernel change "bnxt_en: Reduce memory usage when running in kdump kernel" is included in the Linux 5.2 release. This change is authored by Michael Chan <michael.chan [at] broadcom.com> on Wed May 22 19:12:56 2019 -0400. The commit for this change in Linux stable tree is d629522 (patch).

bnxt_en: Reduce memory usage when running in kdump kernel.

Skip 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.

Fixes: cf6daed098d1 ("bnxt_en: Increase context memory allocations on 57500 chips for RDMA.")
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++--
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index cfcc33c..79812da 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -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.
     */
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index acc73f3..be438d8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -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)           \

Leave a Reply

Your email address will not be published. Required fields are marked *