OSDN Git Service

habanalabs: add CPU-CP packet for engine core ASID cfg
authorTomer Tayar <ttayar@habana.ai>
Thu, 16 Dec 2021 14:31:18 +0000 (16:31 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Sun, 26 Dec 2021 12:39:53 +0000 (14:39 +0200)
In some cases the driver cannot configure ASID of some engines due to
the security level of the relevant registers.
For this a new CPU-CP packet is introduced, which will allow the driver
to ask the F/W to do this configuration instead.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/firmware_if.c
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/include/common/cpucp_if.h

index 1d0d228..2cc2015 100644 (file)
@@ -1059,6 +1059,26 @@ out:
        return rc;
 }
 
+int hl_fw_cpucp_engine_core_asid_set(struct hl_device *hdev, u32 asid)
+{
+       struct cpucp_packet pkt;
+       int rc;
+
+       memset(&pkt, 0, sizeof(pkt));
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_ENGINE_CORE_ASID_SET << CPUCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.value = cpu_to_le64(asid);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+                                               HL_CPUCP_INFO_TIMEOUT_USEC, NULL);
+       if (rc)
+               dev_err(hdev->dev,
+                       "Failed on ASID configuration request for engine core, error %d\n",
+                       rc);
+
+       return rc;
+}
+
 void hl_fw_ask_hard_reset_without_linux(struct hl_device *hdev)
 {
        struct static_fw_load_mgr *static_loader =
index 78772fe..fc1bdc0 100644 (file)
@@ -3065,6 +3065,7 @@ int hl_fw_dynamic_send_protocol_cmd(struct hl_device *hdev,
 int hl_fw_dram_replaced_row_get(struct hl_device *hdev,
                                struct cpucp_hbm_row_info *info);
 int hl_fw_dram_pending_row_get(struct hl_device *hdev, u32 *pend_rows_num);
+int hl_fw_cpucp_engine_core_asid_set(struct hl_device *hdev, u32 asid);
 int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3],
                        bool is_wc[3]);
 int hl_pci_elbi_read(struct hl_device *hdev, u64 addr, u32 *data);
index 0114cb5..737c39f 100644 (file)
@@ -386,6 +386,9 @@ enum pq_init_status {
  *
  * CPUCP_PACKET_POWER_SET -
  *       Resets power history of device to 0
+ *
+ * CPUCP_PACKET_ENGINE_CORE_ASID_SET -
+ *       Packet to perform engine core ASID configuration
  */
 
 enum cpucp_packet_id {
@@ -434,6 +437,8 @@ enum cpucp_packet_id {
        CPUCP_PACKET_HBM_REPLACED_ROWS_INFO_GET,/* internal */
        CPUCP_PACKET_HBM_PENDING_ROWS_STATUS,   /* internal */
        CPUCP_PACKET_POWER_SET,                 /* internal */
+       CPUCP_PACKET_RESERVED,                  /* not used */
+       CPUCP_PACKET_ENGINE_CORE_ASID_SET,      /* internal */
 };
 
 #define CPUCP_PACKET_FENCE_VAL 0xFE8CE7A5