diff mbox series

[net,v1] octeon_ep: explicitly test for firmware ready value

Message ID 20231206063549.2590305-1-srasheed@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net,v1] octeon_ep: explicitly test for firmware ready value | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Shinas Rasheed Dec. 6, 2023, 6:35 a.m. UTC
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 <srasheed@marvell.com>
---
 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michal Schmidt Dec. 6, 2023, 1:58 p.m. UTC | #1
On Wed, Dec 6, 2023 at 7:36 AM Shinas Rasheed <srasheed@marvell.com> 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 <srasheed@marvell.com>
> ---
>  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
>
Shinas Rasheed Dec. 6, 2023, 2:12 p.m. UTC | #2
Hi Michal

> -----Original Message-----
> From: Michal Schmidt <mschmidt@redhat.com>
> Sent: Wednesday, December 6, 2023 7:28 PM
> To: Shinas Rasheed <srasheed@marvell.com>
> >                 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)
Michal Schmidt Dec. 6, 2023, 2:20 p.m. UTC | #3
On Wed, Dec 6, 2023 at 3:12 PM Shinas Rasheed <srasheed@marvell.com> wrote:
>
> Hi Michal
>
> > -----Original Message-----
> > From: Michal Schmidt <mschmidt@redhat.com>
> > Sent: Wednesday, December 6, 2023 7:28 PM
> > To: Shinas Rasheed <srasheed@marvell.com>
> > >                 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
Shinas Rasheed Dec. 6, 2023, 2:22 p.m. UTC | #4
> 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
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 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;
 }