habanalabs: read preboot status bits in an earlier stage
authorKoby Elbaz <kelbaz@habana.ai>
Tue, 18 May 2021 12:05:35 +0000 (15:05 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Fri, 18 Jun 2021 12:23:40 +0000 (15:23 +0300)
On newer releases, host won't be able to trigger an interrupt directly
to the ASIC GIC controller.
To be able to decide whether GIC can/not be used, we must read device's
preboot status bits in a stage that precedes the possible first use of
GIC (when device is in dirty state).

Signed-off-by: Koby Elbaz <kelbaz@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/firmware_if.c

index 1717302..cdec721 100644 (file)
@@ -1159,8 +1159,6 @@ static int hl_fw_static_read_preboot_status(struct hl_device *hdev)
        if (rc)
                return rc;
 
-       hl_fw_preboot_update_state(hdev);
-
        return 0;
 }
 
@@ -1189,6 +1187,8 @@ int hl_fw_read_preboot_status(struct hl_device *hdev, u32 cpu_boot_status_reg,
        if (rc)
                return rc;
 
+       hl_fw_preboot_update_state(hdev);
+
        /* no need to read preboot status in dynamic load */
        if (hdev->asic_prop.dynamic_fw_load)
                return 0;
@@ -1864,9 +1864,6 @@ static int hl_fw_dynamic_load_image(struct hl_device *hdev,
                hl_fw_boot_fit_update_state(hdev,
                                le32_to_cpu(dyn_regs->cpu_boot_dev_sts0),
                                le32_to_cpu(dyn_regs->cpu_boot_dev_sts1));
-       } else {
-               /* update state during preboot handshake */
-               hl_fw_preboot_update_state(hdev);
        }
 
        /* copy boot fit to space allocated by FW */
@@ -2097,9 +2094,6 @@ static int hl_fw_dynamic_init_cpu(struct hl_device *hdev,
        }
 
        if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) {
-               /* update the preboot state */
-               hl_fw_preboot_update_state(hdev);
-
                rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, 0);
                if (rc)
                        goto protocol_err;