habanalabs: support multiple types of firmwares
authorOded Gabbay <ogabbay@kernel.org>
Thu, 1 Oct 2020 10:46:37 +0000 (13:46 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Mon, 30 Nov 2020 08:47:27 +0000 (10:47 +0200)
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

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/firmware_if.c
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/common/habanalabs_drv.c

index cd41c7c..1340afa 100644 (file)
@@ -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;
        }
 
index f493fb2..4ab5c28 100644 (file)
@@ -125,6 +125,18 @@ enum hl_fw_component {
 };
 
 /**
+ * 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.
  * @QUEUE_TYPE_EXT: external queue which is a DMA channel that may access the
@@ -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;
index f9067d3..4c49d6c 100644 (file)
@@ -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;
 }
 
 /*