Skip to content

Commit 674f777

Browse files
dhirschfeld1ogabbay
authored andcommitted
accel/habanalabs: extend preboot timeout when preboot might take longer
There are cases such when FW runs MBIST, that preboot is expected to take longer than the usual. In such cases the firmware reports status SECURITY_READY/IN_PREBOOT and we extend the timeout waiting for it. This is currently implemented for Gaudi2 only. Signed-off-by: Dafna Hirschfeld <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 9dca131 commit 674f777

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

drivers/accel/habanalabs/common/firmware_if.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,9 @@ static void detect_cpu_boot_status(struct hl_device *hdev, u32 status)
14741474
int hl_fw_wait_preboot_ready(struct hl_device *hdev)
14751475
{
14761476
struct pre_fw_load_props *pre_fw_load = &hdev->fw_loader.pre_fw_load;
1477-
u32 status;
1478-
int rc;
1477+
u32 status = 0, timeout;
1478+
int rc, tries = 1;
1479+
bool preboot_still_runs;
14791480

14801481
/* Need to check two possible scenarios:
14811482
*
@@ -1485,6 +1486,8 @@ int hl_fw_wait_preboot_ready(struct hl_device *hdev)
14851486
* All other status values - for older firmwares where the uboot was
14861487
* loaded from the FLASH
14871488
*/
1489+
timeout = pre_fw_load->wait_for_preboot_timeout;
1490+
retry:
14881491
rc = hl_poll_timeout(
14891492
hdev,
14901493
pre_fw_load->cpu_boot_status_reg,
@@ -1493,7 +1496,24 @@ int hl_fw_wait_preboot_ready(struct hl_device *hdev)
14931496
(status == CPU_BOOT_STATUS_READY_TO_BOOT) ||
14941497
(status == CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT),
14951498
hdev->fw_poll_interval_usec,
1496-
pre_fw_load->wait_for_preboot_timeout);
1499+
timeout);
1500+
/*
1501+
* if F/W reports "security-ready" it means preboot might take longer.
1502+
* If the field 'wait_for_preboot_extended_timeout' is non 0 we wait again
1503+
* with that timeout
1504+
*/
1505+
preboot_still_runs = (status == CPU_BOOT_STATUS_SECURITY_READY ||
1506+
status == CPU_BOOT_STATUS_IN_PREBOOT ||
1507+
status == CPU_BOOT_STATUS_FW_SHUTDOWN_PREP ||
1508+
status == CPU_BOOT_STATUS_DRAM_RDY);
1509+
1510+
if (rc && tries && preboot_still_runs) {
1511+
tries--;
1512+
if (pre_fw_load->wait_for_preboot_extended_timeout) {
1513+
timeout = pre_fw_load->wait_for_preboot_extended_timeout;
1514+
goto retry;
1515+
}
1516+
}
14971517

14981518
if (rc) {
14991519
detect_cpu_boot_status(hdev, status);

drivers/accel/habanalabs/common/habanalabs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,8 @@ struct dynamic_fw_load_mgr {
14101410
* @boot_err0_reg: boot_err0 register address
14111411
* @boot_err1_reg: boot_err1 register address
14121412
* @wait_for_preboot_timeout: timeout to poll for preboot ready
1413+
* @wait_for_preboot_extended_timeout: timeout to pull for preboot ready in case where we know
1414+
* preboot needs longer time.
14131415
*/
14141416
struct pre_fw_load_props {
14151417
u32 cpu_boot_status_reg;
@@ -1418,6 +1420,7 @@ struct pre_fw_load_props {
14181420
u32 boot_err0_reg;
14191421
u32 boot_err1_reg;
14201422
u32 wait_for_preboot_timeout;
1423+
u32 wait_for_preboot_extended_timeout;
14211424
};
14221425

14231426
/**

drivers/accel/habanalabs/gaudi2/gaudi2.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4825,6 +4825,8 @@ static void gaudi2_init_firmware_preload_params(struct hl_device *hdev)
48254825
pre_fw_load->boot_err0_reg = mmCPU_BOOT_ERR0;
48264826
pre_fw_load->boot_err1_reg = mmCPU_BOOT_ERR1;
48274827
pre_fw_load->wait_for_preboot_timeout = GAUDI2_PREBOOT_REQ_TIMEOUT_USEC;
4828+
pre_fw_load->wait_for_preboot_extended_timeout =
4829+
GAUDI2_PREBOOT_EXTENDED_REQ_TIMEOUT_USEC;
48284830
}
48294831

48304832
static void gaudi2_init_firmware_loader(struct hl_device *hdev)

drivers/accel/habanalabs/gaudi2/gaudi2P.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#define CORESIGHT_TIMEOUT_USEC 100000 /* 100 ms */
8585

8686
#define GAUDI2_PREBOOT_REQ_TIMEOUT_USEC 25000000 /* 25s */
87+
#define GAUDI2_PREBOOT_EXTENDED_REQ_TIMEOUT_USEC 85000000 /* 85s */
8788

8889
#define GAUDI2_BOOT_FIT_REQ_TIMEOUT_USEC 10000000 /* 10s */
8990

0 commit comments

Comments
 (0)