All of lore.kernel.org
 help / color / mirror / Atom feed
From: Veerasenareddy Burru <vburru@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<aayarekar@marvell.com>, <sedara@marvell.com>,
	<sburla@marvell.com>
Cc: <linux-doc@vger.kernel.org>,
	Veerasenareddy Burru <vburru@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next v4 1/8] octeon_ep: defer probe if firmware not ready
Date: Wed, 22 Mar 2023 02:19:50 -0700	[thread overview]
Message-ID: <20230322091958.13103-2-vburru@marvell.com> (raw)
In-Reply-To: <20230322091958.13103-1-vburru@marvell.com>

Defer probe if firmware is not ready for device usage.

Signed-off-by: Veerasenareddy Burru <vburru@marvell.com>
Signed-off-by: Abhijit Ayarekar <aayarekar@marvell.com>
Signed-off-by: Satananda Burla <sburla@marvell.com>
---
v3 -> v4:
 * address review comments
   https://lore.kernel.org/all/Y+vFlfakHj33DEkt@boxer/
   - fix return statement for get_fw_ready_status().

v2 -> v3:
 * fix review comments
   https://lore.kernel.org/all/Y4chWyR6qTlptkTE@unreal/
   - change get_fw_ready_status() to return bool
   - fix the success oriented flow while looking for
     PCI extended capability

v1 -> v2:
 * was scheduling workqueue task to wait for firmware ready,
   to probe/initialize the device.
 * now, removed the workqueue task; the probe returns EPROBE_DEFER,
   if firmware is not ready.
 * removed device status oct->status, as it is not required with the
   modified implementation.

 .../ethernet/marvell/octeon_ep/octep_main.c   | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index fdce78ceea87..0a50da52dc27 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -1016,6 +1016,26 @@ static void octep_device_cleanup(struct octep_device *oct)
 	oct->conf = NULL;
 }
 
+static bool get_fw_ready_status(struct pci_dev *pdev)
+{
+	u32 pos = 0;
+	u16 vsec_id;
+	u8 status;
+
+	while ((pos = pci_find_next_ext_capability(pdev, pos,
+						   PCI_EXT_CAP_ID_VNDR))) {
+		pci_read_config_word(pdev, pos + 4, &vsec_id);
+#define FW_STATUS_VSEC_ID  0xA3
+		if (vsec_id != FW_STATUS_VSEC_ID)
+			continue;
+
+		pci_read_config_byte(pdev, (pos + 8), &status);
+		dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
+		return status;
+	}
+	return false;
+}
+
 /**
  * octep_probe() - Octeon PCI device probe handler.
  *
@@ -1051,6 +1071,12 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	pci_set_master(pdev);
 
+	if (!get_fw_ready_status(pdev)) {
+		dev_notice(&pdev->dev, "Firmware not ready; defer probe.\n");
+		err = -EPROBE_DEFER;
+		goto err_alloc_netdev;
+	}
+
 	netdev = alloc_etherdev_mq(sizeof(struct octep_device),
 				   OCTEP_MAX_QUEUES);
 	if (!netdev) {
-- 
2.36.0


  reply	other threads:[~2023-03-22  9:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22  9:19 [PATCH net-next v4 0/8] octeon_ep: deferred probe and mailbox Veerasenareddy Burru
2023-03-22  9:19 ` Veerasenareddy Burru [this message]
2023-03-22  9:19 ` [PATCH net-next v4 2/8] octeon_ep: poll for control messages Veerasenareddy Burru
2023-03-22  9:19 ` [PATCH net-next v4 3/8] octeon_ep: control mailbox for multiple PFs Veerasenareddy Burru
2023-03-22  9:19 ` [PATCH net-next v4 4/8] octeon_ep: add separate mailbox command and response queues Veerasenareddy Burru
2023-03-22  9:19 ` [PATCH net-next v4 5/8] octeon_ep: include function id in mailbox commands Veerasenareddy Burru
2023-03-22  9:19 ` [PATCH net-next v4 6/8] octeon_ep: support asynchronous notifications Veerasenareddy Burru
2023-03-23 10:39   ` Leon Romanovsky
2023-03-23 17:24     ` [EXT] " Veerasenareddy Burru
2023-03-29  7:29       ` Leon Romanovsky
2023-03-22  9:19 ` [PATCH net-next v4 7/8] octeon_ep: function id in link info and stats mailbox commands Veerasenareddy Burru
2023-03-22  9:19 ` [PATCH net-next v4 8/8] octeon_ep: add heartbeat monitor Veerasenareddy Burru
2023-03-23 10:47   ` Leon Romanovsky
2023-03-23 18:14     ` [EXT] " Veerasenareddy Burru
2023-03-29  7:33       ` Leon Romanovsky

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=20230322091958.13103-2-vburru@marvell.com \
    --to=vburru@marvell.com \
    --cc=aayarekar@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sburla@marvell.com \
    --cc=sedara@marvell.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.