lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1362383327-32362-2-git-send-email-shangw@linux.vnet.ibm.com>
Date:	Mon,  4 Mar 2013 15:48:47 +0800
From:	Gavin Shan <shangw@...ux.vnet.ibm.com>
To:	netdev@...r.kernel.org
Cc:	sathya.perla@...lex.com, subbu.seetharaman@...lex.com,
	ajit.khaparde@...lex.com, Gavin Shan <shangw@...ux.vnet.ibm.com>
Subject: [PATCH 2/2] benet: Wait I/O while resuming device

After resetting the adapter, the config space register (0x7c) might
give fake information to indicate the f/w is ready. In turn, 0xFF's
is always returned while accessing on I/O space registers. The patch
adds more check to make sure the I/O space is ready for access before
accessing that region.

Signed-off-by: Gavin Shan <shangw@...ux.vnet.ibm.com>
---
 drivers/net/ethernet/emulex/benet/be_cmds.c |   29 +++++++++++++++++++++++++++
 drivers/net/ethernet/emulex/benet/be_cmds.h |    1 +
 drivers/net/ethernet/emulex/benet/be_main.c |    5 ++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 813407f..3e8824e 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -696,6 +696,35 @@ static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)
 	return wrb;
 }
 
+int be_cmd_fw_wait_io(struct be_adapter *adapter)
+{
+	void __iomem *db = adapter->db + MPU_MAILBOX_DB_OFFSET;
+	int timeout = 0;
+	u32 val;
+
+	if (lancer_chip(adapter))
+		return 0;
+
+	do {
+		val = ioread32(db);
+		if (val != 0xffffffff)
+			return 0;
+
+		dev_info(&adapter->pdev->dev,
+			"Wating for I/O (0x%08x), %ds elapsed\n",
+			val, timeout);
+		if (msleep_interruptible(2000)) {
+			dev_err(&adapter->pdev->dev,
+				"Waiting for I/O aborted\n");
+			return -EIO;
+		}
+		timeout += 2;
+	} while (timeout < 60);
+
+	dev_err(&adapter->pdev->dev, "Timeout waiting for I/O (%d)\n", timeout);
+	return -1;
+}
+
 /* Tell fw we're about to start firing cmds by writing a
  * special pattern across the wrb hdr; uses mbox
  */
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 9697086..9d03cb1 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1888,6 +1888,7 @@ int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
 				int offset);
 extern int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac,
 				struct be_dma_mem *nonemb_cmd);
+extern int be_cmd_fw_wait_io(struct be_adapter *adapter);
 extern int be_cmd_fw_init(struct be_adapter *adapter);
 extern int be_cmd_fw_clean(struct be_adapter *adapter);
 extern void be_async_mcc_enable(struct be_adapter *adapter);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 3860888..7609424 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4347,6 +4347,11 @@ static void be_eeh_resume(struct pci_dev *pdev)
 
 	pci_save_state(pdev);
 
+	/* Wating for I/O ready */
+	status = be_cmd_fw_wait_io(adapter);
+	if (status)
+		goto err;
+
 	/* tell fw we're ready to fire cmds */
 	status = be_cmd_fw_init(adapter);
 	if (status)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ