diff mbox series

[net-next,v3,1/7] octeon_ep: defer probe if firmware not ready

Message ID 20230214051422.13705-2-vburru@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series octeon_ep: deferred probe and mailbox | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Veerasenareddy Burru Feb. 14, 2023, 5:14 a.m. UTC
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>
---
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(+)

Comments

Fijalkowski, Maciej Feb. 14, 2023, 5:32 p.m. UTC | #1
On Mon, Feb 13, 2023 at 09:14:16PM -0800, Veerasenareddy Burru wrote:
> 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>
> ---
> 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 5a898fb88e37..5620df4c6d55 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -1017,6 +1017,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 ? true : false;

nit:

return !!status;

?

> +	}
> +	return false;
> +}
> +
>  /**
>   * octep_probe() - Octeon PCI device probe handler.
>   *
> @@ -1053,6 +1073,12 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	pci_enable_pcie_error_reporting(pdev);
>  	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
>
Leon Romanovsky Feb. 15, 2023, 11:43 a.m. UTC | #2
On Tue, Feb 14, 2023 at 06:32:05PM +0100, Maciej Fijalkowski wrote:
> On Mon, Feb 13, 2023 at 09:14:16PM -0800, Veerasenareddy Burru wrote:
> > 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>
> > ---
> > 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 5a898fb88e37..5620df4c6d55 100644
> > --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> > +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> > @@ -1017,6 +1017,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 ? true : false;
> 
> nit:
> 
> return !!status;

"return status;" is enough, there is no need in "!!".

Thanks
Veerasenareddy Burru Feb. 17, 2023, 8:21 a.m. UTC | #3
> -----Original Message-----
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Sent: Tuesday, February 14, 2023 9:32 AM
> To: Veerasenareddy Burru <vburru@marvell.com>
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Abhijit Ayarekar
> <aayarekar@marvell.com>; Sathesh B Edara <sedara@marvell.com>;
> Satananda Burla <sburla@marvell.com>; linux-doc@vger.kernel.org; David S.
> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>;
> Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>
> Subject: [EXT] Re: [PATCH net-next v3 1/7] octeon_ep: defer probe if
> firmware not ready
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Mon, Feb 13, 2023 at 09:14:16PM -0800, Veerasenareddy Burru wrote:
> > 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>
> > ---
> > v2 -> v3:
> >  * fix review comments
> >    https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__lore.kernel.org_all_Y4chWyR6qTlptkTE-
> 40unreal_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=XkP_75lnbPIeeucsP
> X36ZgjiMqEKttwZfwNyWMCLjT0&m=4b7d0RrdHBeSeuVxcgazZ-
> kuSb9u5rGArB5Mio0glbruzVrVD25vZP2M2f1jPteh&s=JhMZ44LA1ICu-
> gf3_8cI2F_pN7OFsWMNHp2Od7u26Gk&e=
> >    - 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 5a898fb88e37..5620df4c6d55 100644
> > --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> > +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> > @@ -1017,6 +1017,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 ? true : false;
> 
> nit:
> 
> return !!status;
> 
> ?
> 

Thank you for the feedback. Will update in next revision.

> > +	}
> > +	return false;
> > +}
> > +
> >  /**
> >   * octep_probe() - Octeon PCI device probe handler.
> >   *
> > @@ -1053,6 +1073,12 @@ static int octep_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> >  	pci_enable_pcie_error_reporting(pdev);
> >  	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
> >
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index 5a898fb88e37..5620df4c6d55 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -1017,6 +1017,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 ? true : false;
+	}
+	return false;
+}
+
 /**
  * octep_probe() - Octeon PCI device probe handler.
  *
@@ -1053,6 +1073,12 @@  static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_enable_pcie_error_reporting(pdev);
 	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) {