Skip to contentSkip to conversation

octeon_ep: explicitly test for firmware ready value

PATCH Superseded Shinas Rasheed 3 participants 3 messages Dec 7, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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")

---
V2:
- Fixed redundant logic

V1: https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2 -1
index 552970c7dec0..b8ae269f6f97 100644
@@ -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);
 	}
 	return false;
 }
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 23 lines · Shinas Rasheed

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")

---
V2:
- Fixed redundant logic

V1: https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0 -0
index 552970c7dec0..b8ae269f6f97 100644

drivers/net/ethernet/marvell/octeon_ep/octep_main.c static bool get_fw_ready_status(struct pci_dev *pdev) · line 1262

Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2 -1
@@ -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);

The parentheses are not necessary, but if you find it better readable this way, so be it.

Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0 -1
        }
        return false;
 }
--

2.25.1

#2 lore raw
Quoted 25 lines · Thu, Dec 07, 2023 at 09:45:15AM CET, [email protected] wrote:
Quoted 24 lines · Shinas Rasheed

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")

---
V2:
- Fixed redundant logic

V1: https://lore.kernel.org/all/[email protected]/

 drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0 -0
index 552970c7dec0..b8ae269f6f97 100644
@@ -1258,7 +1258,8 @@ static bool get_fw_ready_status(struct pci_dev *pdev)
 
Quoted 8 lines

drivers/net/ethernet/marvell/octeon_ep/octep_main.c static bool get_fw_ready_status(struct pci_dev *pdev) · line 1262

Quoted 5 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2 -1
                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);

The parentheses are not necessary, but if you find it better readable this way, so be it.

Well, since return is not a function, parentheses should not be here. Please drop them.

Quoted 11 lines
Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0 -1
        }
        return false;
 }
--

2.25.1