2023-12-06 06:37:21

by Shinas Rasheed

[permalink] [raw]
Subject: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

The firmware ready value is 1, and get firmware ready status
function should explicitly test for that value. The firmware
ready value read will be 2 after driver load, and on unbind
till firmware rewrites the firmware ready back to 0, the value
seen by driver will be 2, which should be regarded as not ready.

Fixes: 10c073e40469 ("octeon_ep: defer probe if firmware not ready")
Signed-off-by: Shinas Rasheed <[email protected]>
---
drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
index 552970c7dec0..b8ae269f6f97 100644
--- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
+++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
@@ -1258,7 +1258,8 @@ static bool get_fw_ready_status(struct pci_dev *pdev)

pci_read_config_byte(pdev, (pos + 8), &status);
dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
- return status;
+#define FW_STATUS_READY 1ULL
+ return (status == FW_STATUS_READY) ? true : false;
}
return false;
}
--
2.25.1


2023-12-06 13:58:31

by Michal Schmidt

[permalink] [raw]
Subject: Re: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

On Wed, Dec 6, 2023 at 7:36 AM Shinas Rasheed <[email protected]> wrote:
>
> The firmware ready value is 1, and get firmware ready status
> function should explicitly test for that value. The firmware
> ready value read will be 2 after driver load, and on unbind
> till firmware rewrites the firmware ready back to 0, the value
> seen by driver will be 2, which should be regarded as not ready.
>
> Fixes: 10c073e40469 ("octeon_ep: defer probe if firmware not ready")
> Signed-off-by: Shinas Rasheed <[email protected]>
> ---
> drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> index 552970c7dec0..b8ae269f6f97 100644
> --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c
> @@ -1258,7 +1258,8 @@ static bool get_fw_ready_status(struct pci_dev *pdev)
>
> pci_read_config_byte(pdev, (pos + 8), &status);
> dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
> - return status;
> +#define FW_STATUS_READY 1ULL
> + return (status == FW_STATUS_READY) ? true : false;

"status == FW_STATUS_READY" is already the bool value you want. You
don't need to use the ternary operator here.

> }
> return false;
> }
> --
> 2.25.1
>

2023-12-06 14:13:01

by Shinas Rasheed

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

Hi Michal

> -----Original Message-----
> From: Michal Schmidt <[email protected]>
> Sent: Wednesday, December 6, 2023 7:28 PM
> To: Shinas Rasheed <[email protected]>
> > pci_read_config_byte(pdev, (pos + 8), &status);
> > dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
> > - return status;
> > +#define FW_STATUS_READY 1ULL
> > + return (status == FW_STATUS_READY) ? true : false;
>
> "status == FW_STATUS_READY" is already the bool value you want. You
> don't need to use the ternary operator here.
>

In some abnormal cases, the driver can read the firmware ready status as 2. Hence this need for explicitly checking if status
is indeed 1 or not. If it is 2, the function should understand it as the firmware is not ready. (It has to be strictly 1 for the driver
to understand it as ready)

2023-12-06 14:21:17

by Michal Schmidt

[permalink] [raw]
Subject: Re: [EXT] Re: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

On Wed, Dec 6, 2023 at 3:12 PM Shinas Rasheed <[email protected]> wrote:
>
> Hi Michal
>
> > -----Original Message-----
> > From: Michal Schmidt <[email protected]>
> > Sent: Wednesday, December 6, 2023 7:28 PM
> > To: Shinas Rasheed <[email protected]>
> > > pci_read_config_byte(pdev, (pos + 8), &status);
> > > dev_info(&pdev->dev, "Firmware ready status = %u\n", status);
> > > - return status;
> > > +#define FW_STATUS_READY 1ULL
> > > + return (status == FW_STATUS_READY) ? true : false;
> >
> > "status == FW_STATUS_READY" is already the bool value you want. You
> > don't need to use the ternary operator here.
> >
>
> In some abnormal cases, the driver can read the firmware ready status as 2. Hence this need for explicitly checking if status
> is indeed 1 or not. If it is 2, the function should understand it as the firmware is not ready. (It has to be strictly 1 for the driver
> to understand it as ready)

I'm not disputing that. I'm saying that this:
return (status == FW_STATUS_READY) ? true : false;
is equivalent to:
return status == FW_STATUS_READY;

Michal

2023-12-06 14:22:40

by Shinas Rasheed

[permalink] [raw]
Subject: RE: [EXT] Re: [PATCH net v1] octeon_ep: explicitly test for firmware ready value

> I'm not disputing that. I'm saying that this:
> return (status == FW_STATUS_READY) ? true : false;
> is equivalent to:
> return status == FW_STATUS_READY;

Oh got it! Thanks for the catch, will correct and send it now.

Shinas