Skip to contentSkip to conversation

habanalabs: support multiple types of firmwares

PATCH New Oded Gabbay 1 participant 1 message Nov 2, 2020 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 habanalabs: support multiple types of firmwares

The driver now loads the firmware in two stages. For debugging purposes we need to support situations where only the first stage firmware is loaded.

Therefore, use a bitmask to determine which F/W is loaded

---
 drivers/misc/habanalabs/common/firmware_if.c    |  9 +++++++--
 drivers/misc/habanalabs/common/habanalabs.h     | 14 +++++++++++++-
 drivers/misc/habanalabs/common/habanalabs_drv.c |  1 +
 3 files changed, 21 insertions(+), 3 deletions(-)
drivers/misc/habanalabs/common/firmware_if.c +7 -2
index cd41c7ceb0e7..1340afa8ce3b 100644
@@ -574,6 +574,9 @@ int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
 	u32 status;
 	int rc;
 
+	if (!(hdev->fw_loading & FW_TYPE_BOOT_CPU))
+		return 0;
+
 	dev_info(hdev->dev, "Going to wait for device boot (up to %lds)\n",
 		cpu_timeout / USEC_PER_SEC);
 
@@ -631,6 +634,8 @@ int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
 		10000,
 		cpu_timeout);
 
+	dev_dbg(hdev->dev, "uboot status = %d\n", status);
+
 	/* Read U-Boot version now in case we will later fail */
 	hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_UBOOT);
 
@@ -640,8 +645,8 @@ int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
 		goto out;
 	}
 
-	if (!hdev->fw_loading) {
-		dev_info(hdev->dev, "Skip loading FW\n");
+	if (!(hdev->fw_loading & FW_TYPE_LINUX)) {
+		dev_info(hdev->dev, "Skip loading Linux F/W\n");
 		goto out;
 	}
 
drivers/misc/habanalabs/common/habanalabs.h +13 -1
index d7cf833a20bc..d12f11bdaacf 100644
@@ -124,6 +124,18 @@ enum hl_fw_component {
 	FW_COMP_PREBOOT
 };
 
+/**
+ * enum hl_fw_types - F/W types to load
+ * @FW_TYPE_LINUX: Linux image for device CPU
+ * @FW_TYPE_BOOT_CPU: Boot image for device CPU
+ * @FW_TYPE_ALL_TYPES: Mask for all types
+ */
+enum hl_fw_types {
+	FW_TYPE_LINUX = 0x1,
+	FW_TYPE_BOOT_CPU = 0x2,
+	FW_TYPE_ALL_TYPES = (FW_TYPE_LINUX | FW_TYPE_BOOT_CPU)
+};
+
 /**
  * enum hl_queue_type - Supported QUEUE types.
  * @QUEUE_TYPE_NA: queue is not available.
@@ -1709,12 +1721,12 @@ struct hl_device {
 	u8				supports_cb_mapping;
 
 	/* Parameters for bring-up */
+	u64				fw_loading;
 	u8				mmu_enable;
 	u8				mmu_huge_page_opt;
 	u8				cpu_enable;
 	u8				reset_pcilink;
 	u8				cpu_queues_enable;
-	u8				fw_loading;
 	u8				pldm;
 	u8				axi_drain;
 	u8				sram_scrambler_enable;
drivers/misc/habanalabs/common/habanalabs_drv.c +1 -0
index f9067d3ef437..4c49d6cefa98 100644
@@ -241,6 +241,7 @@ static void set_driver_behavior_per_device(struct hl_device *hdev)
 	hdev->dram_scrambler_enable = 1;
 	hdev->bmc_enable = 1;
 	hdev->hard_reset_on_fw_events = 1;
+	hdev->fw_loading = FW_TYPE_ALL_TYPES;
 }
 
 /*
Signature · 1 line
2.17.1