linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: netdev@vger.kernel.org, michael.chan@broadcom.com, davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, Dept-GELinuxNICDev@cavium.com,
	rasesh.mody@cavium.com, harish.patil@cavium.com,
	frank@undermydesk.org, jsr@dex.edzone.net, pmenzel@molgen.mpg.de,
	jroedel@suse.de, dyoung@redhat.com, Baoquan He <bhe@redhat.com>
Subject: [PATCH v2 2/2] bnx2: Wait for in-flight DMA to complete at probe stage
Date: Sun, 13 Nov 2016 13:01:33 +0800	[thread overview]
Message-ID: <1479013293-21001-3-git-send-email-bhe@redhat.com> (raw)
In-Reply-To: <1479013293-21001-1-git-send-email-bhe@redhat.com>

In-flight DMA from 1st kernel could continue going in kdump kernel.
New io-page table has been created before bnx2 does reset at open stage.
We have to wait for the in-flight DMA to complete to avoid it look up
into the newly created io-page table at probe stage.

Suggested-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2.c | 38 ++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index c557972..1f7034d 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -49,6 +49,7 @@
 #include <linux/firmware.h>
 #include <linux/log2.h>
 #include <linux/aer.h>
+#include <linux/crash_dump.h>
 
 #if IS_ENABLED(CONFIG_CNIC)
 #define BCM_CNIC 1
@@ -4764,15 +4765,16 @@ bnx2_setup_msix_tbl(struct bnx2 *bp)
 	BNX2_WR(bp, BNX2_PCI_GRC_WINDOW3_ADDR, BNX2_MSIX_PBA_ADDR);
 }
 
-static int
-bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
+static void
+bnx2_wait_dma_complete(struct bnx2 *bp)
 {
 	u32 val;
-	int i, rc = 0;
-	u8 old_port;
+	int i;
 
-	/* Wait for the current PCI transaction to complete before
-	 * issuing a reset. */
+	/*
+	 * Wait for the current PCI transaction to complete before
+	 * issuing a reset.
+	 */
 	if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) ||
 	    (BNX2_CHIP(bp) == BNX2_CHIP_5708)) {
 		BNX2_WR(bp, BNX2_MISC_ENABLE_CLR_BITS,
@@ -4796,6 +4798,21 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
 		}
 	}
 
+	return;
+}
+
+
+static int
+bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
+{
+	u32 val;
+	int i, rc = 0;
+	u8 old_port;
+
+	/* Wait for the current PCI transaction to complete before
+	 * issuing a reset. */
+	bnx2_wait_dma_complete(bp);
+
 	/* Wait for the firmware to tell us it is ok to issue a reset. */
 	bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code, 1, 1);
 
@@ -8580,6 +8597,15 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	pci_set_drvdata(pdev, dev);
 
+	/*
+	 * In-flight DMA from 1st kernel could continue going in kdump kernel.
+	 * New io-page table has been created before bnx2 does reset at open stage.
+	 * We have to wait for the in-flight DMA to complete to avoid it look up
+	 * into the newly created io-page table.
+	 */
+	if (is_kdump_kernel())
+		bnx2_wait_dma_complete(bp);
+
 	memcpy(dev->dev_addr, bp->mac_addr, ETH_ALEN);
 
 	dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
-- 
2.5.5

  parent reply	other threads:[~2016-11-13  5:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-13  5:01 [PATCH v2 0/2] bnx2: Wait for in-flight DMA to complete at probe stage Baoquan He
2016-11-13  5:01 ` [PATCH v2 1/2] Revert "bnx2: Reset device during driver initialization" Baoquan He
2016-11-13  5:01 ` Baoquan He [this message]
2016-11-13 19:02   ` [PATCH v2 2/2] bnx2: Wait for in-flight DMA to complete at probe stage Michael Chan
2016-11-14  8:25 ` [PATCH v2 0/2] " Paul Menzel
2016-11-14  9:10   ` Baoquan He
2016-11-14 17:28   ` David Miller
2016-11-14 17:35     ` Paul Menzel
2016-11-14 21:21 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2016-11-11 13:46 [PATCH 0/2] bnx2: Hard reset bnx2 chip " Baoquan He
2016-11-11 13:46 ` [PATCH 2/2] " Baoquan He
2016-11-13  4:15   ` [PATCH v2 2/2] bnx2: Wait for in-flight DMA to complete " Baoquan He
2016-11-13  4:40     ` David Miller
2016-11-13  4:54       ` Baoquan He

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=1479013293-21001-3-git-send-email-bhe@redhat.com \
    --to=bhe@redhat.com \
    --cc=Dept-GELinuxNICDev@cavium.com \
    --cc=davem@davemloft.net \
    --cc=dyoung@redhat.com \
    --cc=frank@undermydesk.org \
    --cc=harish.patil@cavium.com \
    --cc=jroedel@suse.de \
    --cc=jsr@dex.edzone.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    --cc=rasesh.mody@cavium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).