All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
	Daniel Jurgens <danielj@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH net 04/13] net/mlx5: Fix wait_vital for VFs and remove fixed sleep
Date: Thu, 30 Jun 2016 17:34:41 +0300	[thread overview]
Message-ID: <1467297290-11443-5-git-send-email-saeedm@mellanox.com> (raw)
In-Reply-To: <1467297290-11443-1-git-send-email-saeedm@mellanox.com>

From: Daniel Jurgens <danielj@mellanox.com>

The device ID for VFs is in a different location than PFs. This results
in the poll always timing out for VFs. There's no good way to read the
VF device ID without using the PF's configuration space.  Switch to waiting
for the health poll to start incrementing. Also remove the 1s sleep
at the beginning.

fixes: 89d44f0a6c73 ('net/mlx5_core: Add pci error handlers to mlx5_core
driver')
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 41 ++++++++++----------------
 1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index c65f4a1..6695893 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1422,46 +1422,31 @@ void mlx5_disable_device(struct mlx5_core_dev *dev)
 	mlx5_pci_err_detected(dev->pdev, 0);
 }
 
-/* wait for the device to show vital signs. For now we check
- * that we can read the device ID and that the health buffer
- * shows a non zero value which is different than 0xffffffff
+/* wait for the device to show vital signs by waiting
+ * for the health counter to start counting.
  */
-static void wait_vital(struct pci_dev *pdev)
+static int wait_vital(struct pci_dev *pdev)
 {
 	struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
 	struct mlx5_core_health *health = &dev->priv.health;
 	const int niter = 100;
+	u32 last_count = 0;
 	u32 count;
-	u16 did;
 	int i;
 
-	/* Wait for firmware to be ready after reset */
-	msleep(1000);
-	for (i = 0; i < niter; i++) {
-		if (pci_read_config_word(pdev, 2, &did)) {
-			dev_warn(&pdev->dev, "failed reading config word\n");
-			break;
-		}
-		if (did == pdev->device) {
-			dev_info(&pdev->dev, "device ID correctly read after %d iterations\n", i);
-			break;
-		}
-		msleep(50);
-	}
-	if (i == niter)
-		dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);
-
 	for (i = 0; i < niter; i++) {
 		count = ioread32be(health->health_counter);
 		if (count && count != 0xffffffff) {
-			dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);
-			break;
+			if (last_count && last_count != count) {
+				dev_info(&pdev->dev, "Counter value 0x%x after %d iterations\n", count, i);
+				return 0;
+			}
+			last_count = count;
 		}
 		msleep(50);
 	}
 
-	if (i == niter)
-		dev_warn(&pdev->dev, "%s-%d: could not read device ID\n", __func__, __LINE__);
+	return -ETIMEDOUT;
 }
 
 static void mlx5_pci_resume(struct pci_dev *pdev)
@@ -1473,7 +1458,11 @@ static void mlx5_pci_resume(struct pci_dev *pdev)
 	dev_info(&pdev->dev, "%s was called\n", __func__);
 
 	pci_save_state(pdev);
-	wait_vital(pdev);
+	err = wait_vital(pdev);
+	if (err) {
+		dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);
+		return;
+	}
 
 	err = mlx5_load_one(dev, priv);
 	if (err)
-- 
2.8.0

  parent reply	other threads:[~2016-06-30 14:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 14:34 [PATCH net 00/13] Mellanox 100G mlx5 resiliency and xmit path fixes Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 01/13] net/mlx5: Fix teardown errors that happen in pci error handler Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 02/13] net/mlx5: Avoid calling sleeping function by the health poll thread Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 03/13] net/mlx5: Fix incorrect page count when in internal error Saeed Mahameed
2016-06-30 14:34 ` Saeed Mahameed [this message]
2016-06-30 14:34 ` [PATCH net 05/13] net/mlx5: Fix potential deadlock in command mode change Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 06/13] net/mlx5: Add timeout handle to commands with callback Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 07/13] net/mlx5e: Timeout if SQ doesn't flush during close Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 08/13] net/mlx5e: Implement ndo_tx_timeout callback Saeed Mahameed
2016-06-30 15:15   ` Yuval Mintz
2016-06-30 15:27     ` Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 09/13] net/mlx5e: Handle RQ flush in error cases Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 10/13] net/mlx5e: Copy all L2 headers into inline segment Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 11/13] net/mlx5e: Fix select queue callback Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 12/13] net/mlx5e: Validate BW weight values of ETS Saeed Mahameed
2016-06-30 14:34 ` [PATCH net 13/13] net/mlx5e: Log link state changes Saeed Mahameed
2016-07-01 10:14 ` [PATCH net 00/13] Mellanox 100G mlx5 resiliency and xmit path fixes David Miller
2016-07-01 11:11   ` Saeed Mahameed
2016-07-01 11:22   ` Saeed Mahameed

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=1467297290-11443-5-git-send-email-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=danielj@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.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.