diff mbox series

[v2,2/5] net: marvell: prestera: enlarge fw restart time

Message ID 20240320172008.2989693-3-enachman@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Fix prestera driver fail to probe twice | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 939 this patch: 939
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 2 blamed authors not CCed: vadym.kochan@plvision.eu oleksandr.mazur@plvision.eu; 2 maintainers not CCed: vadym.kochan@plvision.eu oleksandr.mazur@plvision.eu
netdev/build_clang success Errors and warnings before: 956 this patch: 956
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: 956 this patch: 956
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 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
netdev/contest fail net-next-2024-03-20--18-00 (tests: 895)

Commit Message

Elad Nachman March 20, 2024, 5:20 p.m. UTC
From: Elad Nachman <enachman@marvell.com>

Increase firmware restart timeout, as current timeout value of 5 seconds
was too small, in actual life it can take up to 30 seconds for firmware
to shutdown and for the firmware loader to shift to the ready to receive
firmware code state.

Reported-by: Köry Maincent <kory.maincent@bootlin.com>
Closes: https://lore.kernel.org/netdev/20240208101005.29e8c7f3@kmaincent-XPS-13-7390/T/
Fixes: 4c2703dfd7fa ("net: marvell: prestera: Add PCI interface support")
Tested-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Elad Nachman <enachman@marvell.com>
---
 drivers/net/ethernet/marvell/prestera/prestera_pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Andrew Lunn March 21, 2024, 12:10 a.m. UTC | #1
On Wed, Mar 20, 2024 at 07:20:05PM +0200, Elad Nachman wrote:
> From: Elad Nachman <enachman@marvell.com>
> 
> Increase firmware restart timeout, as current timeout value of 5 seconds
> was too small, in actual life it can take up to 30 seconds for firmware
> to shutdown and for the firmware loader to shift to the ready to receive
> firmware code state.

So this means the probe can be waiting 30 seconds?

This seems like a really good reason not to reset the hardware during
-EPROBE_DEFER.

	Andrew
Elad Nachman March 21, 2024, 5:24 p.m. UTC | #2
> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Thursday, March 21, 2024 2:10 AM
> To: Elad Nachman <enachman@marvell.com>
> Cc: Taras Chornyi <taras.chornyi@plvision.eu>; davem@davemloft.net;
> edumazet@google.com; kuba@kernel.org; pabeni@redhat.com;
> kory.maincent@bootlin.com; thomas.petazzoni@bootlin.com;
> miquel.raynal@bootlin.com; przemyslaw.kitszel@intel.com;
> dkirjanov@suse.de; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [EXTERNAL] Re: [PATCH v2 2/5] net: marvell: prestera: enlarge fw
> restart time
> 
> Prioritize security for external emails: Confirm sender and content safety
> before clicking links or opening attachments
> 
> ----------------------------------------------------------------------
> On Wed, Mar 20, 2024 at 07:20:05PM +0200, Elad Nachman wrote:
> > From: Elad Nachman <enachman@marvell.com>
> >
> > Increase firmware restart timeout, as current timeout value of 5
> > seconds was too small, in actual life it can take up to 30 seconds for
> > firmware to shutdown and for the firmware loader to shift to the ready
> > to receive firmware code state.
> 
> So this means the probe can be waiting 30 seconds?
> 
> This seems like a really good reason not to reset the hardware during -
> EPROBE_DEFER.
> 
> 	Andrew

Unfortunately that's how the firmware loader on the firmware cpu state machine works.
The so called HW reset will force exit of the current firmware and will move the state machine
To the state that it can receive the next firmware.

Unfortunately, there is no ABI interface to verify which firmware is already loaded, and then supporting
Warm boot reading of the values back to the kernel.
Since many of these firmware binaries are secure-boot protected, upgrading is very tricky.

Elad.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index 35857dc19542..2caa33d195ab 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -24,6 +24,11 @@ 
 #define PRESTERA_FW_ARM64_PATH_FMT "mrvl/prestera/mvsw_prestera_fw_arm64-v%u.%u.img"
 
 #define PRESTERA_FW_HDR_MAGIC		0x351D9D06
+/* Timeout waiting for firmware CPU to reboot and restart
+ * the firmware loading software layer, hence becoming
+ * ready for the next firmware downloading phase:
+ */
+#define PRESTERA_FW_READY_TIMEOUT_MS	30000
 #define PRESTERA_FW_DL_TIMEOUT_MS	50000
 #define PRESTERA_FW_BLK_SZ		1024
 
@@ -765,7 +770,7 @@  static int prestera_fw_load(struct prestera_fw *fw)
 
 	err = prestera_ldr_wait_reg32(fw, PRESTERA_LDR_READY_REG,
 				      PRESTERA_LDR_READY_MAGIC,
-				      5 * MSEC_PER_SEC);
+				      PRESTERA_FW_READY_TIMEOUT_MS);
 	if (err) {
 		dev_err(fw->dev.dev, "waiting for FW loader is timed out");
 		return err;