Lines Matching refs:hdev

111 static int hl_get_sw_major_minor_subminor(struct hl_device *hdev, const char *fw_str)  in hl_get_sw_major_minor_subminor()  argument
138 start = extract_u32_until_given_char(start, &hdev->fw_sw_major_ver, '.'); in hl_get_sw_major_minor_subminor()
143 start = extract_u32_until_given_char(start, &hdev->fw_sw_minor_ver, '.'); in hl_get_sw_major_minor_subminor()
148 start = extract_u32_until_given_char(start, &hdev->fw_sw_sub_minor_ver, '-'); in hl_get_sw_major_minor_subminor()
155 hdev->fw_sw_major_ver = 0; in hl_get_sw_major_minor_subminor()
156 hdev->fw_sw_minor_ver = 0; in hl_get_sw_major_minor_subminor()
157 hdev->fw_sw_sub_minor_ver = 0; in hl_get_sw_major_minor_subminor()
171 static int hl_get_preboot_major_minor(struct hl_device *hdev, char *preboot_ver) in hl_get_preboot_major_minor() argument
173 preboot_ver = extract_u32_until_given_char(preboot_ver, &hdev->fw_inner_major_ver, '.'); in hl_get_preboot_major_minor()
175 dev_err(hdev->dev, "Error parsing preboot major version\n"); in hl_get_preboot_major_minor()
181 preboot_ver = extract_u32_until_given_char(preboot_ver, &hdev->fw_inner_minor_ver, '.'); in hl_get_preboot_major_minor()
183 dev_err(hdev->dev, "Error parsing preboot minor version\n"); in hl_get_preboot_major_minor()
189 hdev->fw_inner_major_ver = 0; in hl_get_preboot_major_minor()
190 hdev->fw_inner_minor_ver = 0; in hl_get_preboot_major_minor()
194 static int hl_request_fw(struct hl_device *hdev, in hl_request_fw() argument
201 rc = request_firmware(firmware_p, fw_name, hdev->dev); in hl_request_fw()
203 dev_err(hdev->dev, "Firmware file %s is not found! (error %d)\n", in hl_request_fw()
210 dev_err(hdev->dev, "Illegal %s firmware size %zu\n", in hl_request_fw()
216 dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size); in hl_request_fw()
219 dev_err(hdev->dev, in hl_request_fw()
258 static int hl_fw_copy_fw_to_device(struct hl_device *hdev, in hl_fw_copy_fw_to_device() argument
269 dev_err(hdev->dev, in hl_fw_copy_fw_to_device()
292 static int hl_fw_copy_msg_to_device(struct hl_device *hdev, in hl_fw_copy_msg_to_device() argument
303 dev_err(hdev->dev, in hl_fw_copy_msg_to_device()
329 int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name, in hl_fw_load_fw_to_device() argument
335 rc = hl_request_fw(hdev, &fw, fw_name); in hl_fw_load_fw_to_device()
339 rc = hl_fw_copy_fw_to_device(hdev, fw, dst, src_offset, size); in hl_fw_load_fw_to_device()
345 int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode, u64 value) in hl_fw_send_pci_access_msg() argument
352 return hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_pci_access_msg()
355 int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, in hl_fw_send_cpu_message() argument
358 struct hl_hw_queue *queue = &hdev->kernel_queues[hw_queue_id]; in hl_fw_send_cpu_message()
359 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_send_cpu_message()
366 pkt = hl_cpu_accessible_dma_pool_alloc(hdev, len, &pkt_dma_addr); in hl_fw_send_cpu_message()
368 dev_err(hdev->dev, in hl_fw_send_cpu_message()
375 mutex_lock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
378 if (hdev->disabled && !hdev->reset_info.in_compute_reset) { in hl_fw_send_cpu_message()
383 if (hdev->device_cpu_disabled) { in hl_fw_send_cpu_message()
400 hl_hw_queue_submit_bd(hdev, queue, hl_queue_inc_ptr(queue->pi), len, pkt_dma_addr); in hl_fw_send_cpu_message()
407 rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp, in hl_fw_send_cpu_message()
411 hl_hw_queue_inc_ci_kernel(hdev, hw_queue_id); in hl_fw_send_cpu_message()
417 if (!hl_device_operational(hdev, NULL) && !hdev->reset_info.in_compute_reset) in hl_fw_send_cpu_message()
418 dev_dbg(hdev->dev, "Device CPU packet timeout (0x%x) due to FW reset\n", in hl_fw_send_cpu_message()
421 dev_err(hdev->dev, "Device CPU packet timeout (status = 0x%x)\n", tmp); in hl_fw_send_cpu_message()
422 hdev->device_cpu_disabled = true; in hl_fw_send_cpu_message()
433 dev_dbg(hdev->dev, "F/W ERROR %d for CPU packet %d\n", rc, opcode); in hl_fw_send_cpu_message()
440 dev_err(hdev->dev, in hl_fw_send_cpu_message()
444 dev_err(hdev->dev, in hl_fw_send_cpu_message()
448 dev_dbg(hdev->dev, in hl_fw_send_cpu_message()
452 dev_err(hdev->dev, in hl_fw_send_cpu_message()
457 dev_err(hdev->dev, in hl_fw_send_cpu_message()
481 mutex_unlock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
483 hl_cpu_accessible_dma_pool_free(hdev, len, pkt); in hl_fw_send_cpu_message()
488 int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type) in hl_fw_unmask_irq() argument
500 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_unmask_irq()
504 dev_err(hdev->dev, "failed to unmask RAZWI IRQ %d", event_type); in hl_fw_unmask_irq()
509 int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr, in hl_fw_unmask_irq_arr() argument
525 dev_err(hdev->dev, "too many elements in IRQ array\n"); in hl_fw_unmask_irq_arr()
539 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt, in hl_fw_unmask_irq_arr()
543 dev_err(hdev->dev, "failed to unmask IRQ array\n"); in hl_fw_unmask_irq_arr()
550 int hl_fw_test_cpu_queue(struct hl_device *hdev) in hl_fw_test_cpu_queue() argument
560 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &test_pkt, in hl_fw_test_cpu_queue()
565 dev_err(hdev->dev, in hl_fw_test_cpu_queue()
568 dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc); in hl_fw_test_cpu_queue()
574 void *hl_fw_cpu_accessible_dma_pool_alloc(struct hl_device *hdev, size_t size, in hl_fw_cpu_accessible_dma_pool_alloc() argument
579 kernel_addr = gen_pool_alloc(hdev->cpu_accessible_dma_pool, size); in hl_fw_cpu_accessible_dma_pool_alloc()
581 *dma_handle = hdev->cpu_accessible_dma_address + in hl_fw_cpu_accessible_dma_pool_alloc()
582 (kernel_addr - (u64) (uintptr_t) hdev->cpu_accessible_dma_mem); in hl_fw_cpu_accessible_dma_pool_alloc()
587 void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size, in hl_fw_cpu_accessible_dma_pool_free() argument
590 gen_pool_free(hdev->cpu_accessible_dma_pool, (u64) (uintptr_t) vaddr, in hl_fw_cpu_accessible_dma_pool_free()
594 int hl_fw_send_soft_reset(struct hl_device *hdev) in hl_fw_send_soft_reset() argument
601 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_soft_reset()
603 dev_err(hdev->dev, "failed to send soft-reset msg (err = %d)\n", rc); in hl_fw_send_soft_reset()
608 int hl_fw_send_device_activity(struct hl_device *hdev, bool open) in hl_fw_send_device_activity() argument
616 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_device_activity()
618 dev_err(hdev->dev, "failed to send device activity msg(%u)\n", open); in hl_fw_send_device_activity()
623 int hl_fw_send_heartbeat(struct hl_device *hdev) in hl_fw_send_heartbeat() argument
634 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt, in hl_fw_send_heartbeat()
642 dev_warn(hdev->dev, "FW reported EQ fault during heartbeat\n"); in hl_fw_send_heartbeat()
649 static bool fw_report_boot_dev0(struct hl_device *hdev, u32 err_val, in fw_report_boot_dev0() argument
658 dev_err(hdev->dev, in fw_report_boot_dev0()
664 dev_err(hdev->dev, "Device boot error - FIT image corrupted\n"); in fw_report_boot_dev0()
669 dev_err(hdev->dev, in fw_report_boot_dev0()
675 if (hdev->bmc_enable) { in fw_report_boot_dev0()
676 dev_err(hdev->dev, in fw_report_boot_dev0()
680 dev_info(hdev->dev, in fw_report_boot_dev0()
690 dev_err(hdev->dev, in fw_report_boot_dev0()
696 dev_err(hdev->dev, in fw_report_boot_dev0()
702 dev_err(hdev->dev, in fw_report_boot_dev0()
708 dev_err(hdev->dev, "Device boot error - security failure\n"); in fw_report_boot_dev0()
713 dev_err(hdev->dev, "Device boot error - eFuse failure\n"); in fw_report_boot_dev0()
718 dev_err(hdev->dev, "Device boot error - Failed to load preboot secondary image\n"); in fw_report_boot_dev0()
723 dev_err(hdev->dev, "Device boot error - PLL failure\n"); in fw_report_boot_dev0()
729 dev_dbg(hdev->dev, "device unusable status is set\n"); in fw_report_boot_dev0()
734 dev_err(hdev->dev, "Device boot error - binning failure\n"); in fw_report_boot_dev0()
739 dev_dbg(hdev->dev, "Device status0 %#x\n", sts_val); in fw_report_boot_dev0()
742 dev_err(hdev->dev, "Device boot error - EEPROM failure detected\n"); in fw_report_boot_dev0()
748 dev_warn(hdev->dev, in fw_report_boot_dev0()
757 dev_warn(hdev->dev, in fw_report_boot_dev0()
766 dev_warn(hdev->dev, in fw_report_boot_dev0()
775 dev_err(hdev->dev, in fw_report_boot_dev0()
782 lower_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev0()
789 static bool fw_report_boot_dev1(struct hl_device *hdev, u32 err_val, in fw_report_boot_dev1() argument
803 dev_dbg(hdev->dev, "Device status1 %#x\n", sts_val); in fw_report_boot_dev1()
806 dev_err(hdev->dev, in fw_report_boot_dev1()
814 upper_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev1()
820 static int fw_read_errors(struct hl_device *hdev, u32 boot_err0_reg, in fw_read_errors() argument
838 err_exists = fw_report_boot_dev0(hdev, err_val, status_val); in fw_read_errors()
842 err_exists |= fw_report_boot_dev1(hdev, err_val, status_val); in fw_read_errors()
850 int hl_fw_cpucp_info_get(struct hl_device *hdev, in hl_fw_cpucp_info_get() argument
855 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_cpucp_info_get()
863 cpucp_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, sizeof(struct cpucp_info), in hl_fw_cpucp_info_get()
866 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
878 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_info_get()
881 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
886 rc = fw_read_errors(hdev, boot_err0_reg, boot_err1_reg, in hl_fw_cpucp_info_get()
889 dev_err(hdev->dev, "Errors in device boot\n"); in hl_fw_cpucp_info_get()
896 rc = hl_build_hwmon_channel_info(hdev, prop->cpucp_info.sensors); in hl_fw_cpucp_info_get()
898 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
906 dev_info(hdev->dev, "Linux version %s", kernel_ver); in hl_fw_cpucp_info_get()
911 hdev->event_queue.check_eqe_index = false; in hl_fw_cpucp_info_get()
918 hdev->event_queue.check_eqe_index = true; in hl_fw_cpucp_info_get()
925 hl_cpu_accessible_dma_pool_free(hdev, sizeof(struct cpucp_info), cpucp_info_cpu_addr); in hl_fw_cpucp_info_get()
930 static int hl_fw_send_msi_info_msg(struct hl_device *hdev) in hl_fw_send_msi_info_msg() argument
938 if (!hdev->asic_funcs->get_msi_info) in hl_fw_send_msi_info_msg()
949 dev_err(hdev->dev, "CPUCP array data is too big\n"); in hl_fw_send_msi_info_msg()
960 hdev->asic_funcs->get_msi_info(pkt->data); in hl_fw_send_msi_info_msg()
965 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)pkt, in hl_fw_send_msi_info_msg()
977 dev_err(hdev->dev, "failed to send CPUCP array data\n"); in hl_fw_send_msi_info_msg()
984 int hl_fw_cpucp_handshake(struct hl_device *hdev, in hl_fw_cpucp_handshake() argument
991 rc = hl_fw_cpucp_info_get(hdev, sts_boot_dev_sts0_reg, in hl_fw_cpucp_handshake()
997 return hl_fw_send_msi_info_msg(hdev); in hl_fw_cpucp_handshake()
1000 int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size) in hl_fw_get_eeprom_data() argument
1008 eeprom_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, max_size, in hl_fw_get_eeprom_data()
1011 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1023 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_eeprom_data()
1027 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1037 hl_cpu_accessible_dma_pool_free(hdev, max_size, eeprom_info_cpu_addr); in hl_fw_get_eeprom_data()
1042 int hl_fw_get_monitor_dump(struct hl_device *hdev, void *data) in hl_fw_get_monitor_dump() argument
1054 mon_dump_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, data_size, &mon_dump_dma_addr); in hl_fw_get_monitor_dump()
1056 dev_err(hdev->dev, in hl_fw_get_monitor_dump()
1067 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_monitor_dump()
1070 dev_err(hdev->dev, "Failed to handle CPU-CP monitor-dump packet, error %d\n", rc); in hl_fw_get_monitor_dump()
1084 hl_cpu_accessible_dma_pool_free(hdev, data_size, mon_dump_cpu_addr); in hl_fw_get_monitor_dump()
1089 int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev, in hl_fw_cpucp_pci_counters_get() argument
1101 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1104 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1116 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1119 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1130 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1133 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1142 int hl_fw_cpucp_total_energy_get(struct hl_device *hdev, u64 *total_energy) in hl_fw_cpucp_total_energy_get() argument
1151 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_total_energy_get()
1154 dev_err(hdev->dev, in hl_fw_cpucp_total_energy_get()
1165 int get_used_pll_index(struct hl_device *hdev, u32 input_pll_index, in get_used_pll_index() argument
1168 struct asic_fixed_properties *prop = &hdev->asic_prop; in get_used_pll_index()
1189 fw_pll_idx = hdev->asic_funcs->map_pll_idx_to_fw_idx(input_pll_index); in get_used_pll_index()
1191 dev_err(hdev->dev, "Invalid PLL index (%u) error %d\n", in get_used_pll_index()
1201 dev_err(hdev->dev, "PLL index %d is not supported\n", in get_used_pll_index()
1211 int hl_fw_cpucp_pll_info_get(struct hl_device *hdev, u32 pll_index, in hl_fw_cpucp_pll_info_get() argument
1219 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_cpucp_pll_info_get()
1229 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pll_info_get()
1232 dev_err(hdev->dev, "Failed to read PLL info, error %d\n", rc); in hl_fw_cpucp_pll_info_get()
1244 int hl_fw_cpucp_power_get(struct hl_device *hdev, u64 *power) in hl_fw_cpucp_power_get() argument
1256 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_power_get()
1259 dev_err(hdev->dev, "Failed to read power, error %d\n", rc); in hl_fw_cpucp_power_get()
1268 int hl_fw_dram_replaced_row_get(struct hl_device *hdev, in hl_fw_dram_replaced_row_get() argument
1277 cpucp_repl_rows_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, in hl_fw_dram_replaced_row_get()
1281 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1293 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_dram_replaced_row_get()
1296 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1304 hl_cpu_accessible_dma_pool_free(hdev, sizeof(struct cpucp_hbm_row_info), in hl_fw_dram_replaced_row_get()
1310 int hl_fw_dram_pending_row_get(struct hl_device *hdev, u32 *pend_rows_num) in hl_fw_dram_pending_row_get() argument
1320 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_dram_pending_row_get()
1322 dev_err(hdev->dev, in hl_fw_dram_pending_row_get()
1332 int hl_fw_cpucp_engine_core_asid_set(struct hl_device *hdev, u32 asid) in hl_fw_cpucp_engine_core_asid_set() argument
1342 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_engine_core_asid_set()
1345 dev_err(hdev->dev, in hl_fw_cpucp_engine_core_asid_set()
1352 void hl_fw_ask_hard_reset_without_linux(struct hl_device *hdev) in hl_fw_ask_hard_reset_without_linux() argument
1355 &hdev->fw_loader.static_loader; in hl_fw_ask_hard_reset_without_linux()
1358 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_hard_reset_without_linux()
1359 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_hard_reset_without_linux()
1361 hdev->fw_loader.cpu_timeout); in hl_fw_ask_hard_reset_without_linux()
1363 dev_err(hdev->dev, "Failed sending COMMS_RST_DEV\n"); in hl_fw_ask_hard_reset_without_linux()
1369 void hl_fw_ask_halt_machine_without_linux(struct hl_device *hdev) in hl_fw_ask_halt_machine_without_linux() argument
1371 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_ask_halt_machine_without_linux()
1377 if (hdev->device_cpu_is_halted) in hl_fw_ask_halt_machine_without_linux()
1381 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_halt_machine_without_linux()
1386 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_halt_machine_without_linux()
1389 dev_err(hdev->dev, "Failed sending COMMS_GOTO_WFE\n"); in hl_fw_ask_halt_machine_without_linux()
1392 hdev, in hl_fw_ask_halt_machine_without_linux()
1396 hdev->fw_poll_interval_usec, in hl_fw_ask_halt_machine_without_linux()
1399 dev_err(hdev->dev, "Current status=%u. Timed-out updating to WFE\n", in hl_fw_ask_halt_machine_without_linux()
1403 static_loader = &hdev->fw_loader.static_loader; in hl_fw_ask_halt_machine_without_linux()
1413 hdev->device_cpu_is_halted = true; in hl_fw_ask_halt_machine_without_linux()
1416 static void detect_cpu_boot_status(struct hl_device *hdev, u32 status) in detect_cpu_boot_status() argument
1423 dev_err(hdev->dev, in detect_cpu_boot_status()
1427 dev_err(hdev->dev, in detect_cpu_boot_status()
1431 dev_err(hdev->dev, in detect_cpu_boot_status()
1435 dev_err(hdev->dev, in detect_cpu_boot_status()
1439 dev_err(hdev->dev, in detect_cpu_boot_status()
1443 dev_err(hdev->dev, in detect_cpu_boot_status()
1447 dev_err(hdev->dev, in detect_cpu_boot_status()
1451 dev_err(hdev->dev, in detect_cpu_boot_status()
1455 dev_err(hdev->dev, in detect_cpu_boot_status()
1459 dev_err(hdev->dev, in detect_cpu_boot_status()
1463 dev_err(hdev->dev, in detect_cpu_boot_status()
1469 int hl_fw_wait_preboot_ready(struct hl_device *hdev) in hl_fw_wait_preboot_ready() argument
1471 struct pre_fw_load_props *pre_fw_load = &hdev->fw_loader.pre_fw_load; in hl_fw_wait_preboot_ready()
1484 hdev, in hl_fw_wait_preboot_ready()
1490 hdev->fw_poll_interval_usec, in hl_fw_wait_preboot_ready()
1494 detect_cpu_boot_status(hdev, status); in hl_fw_wait_preboot_ready()
1495 dev_err(hdev->dev, "CPU boot ready timeout (status = %d)\n", status); in hl_fw_wait_preboot_ready()
1501 fw_read_errors(hdev, pre_fw_load->boot_err0_reg, in hl_fw_wait_preboot_ready()
1508 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_PREBOOT_CPU; in hl_fw_wait_preboot_ready()
1513 static int hl_fw_read_preboot_caps(struct hl_device *hdev) in hl_fw_read_preboot_caps() argument
1520 prop = &hdev->asic_prop; in hl_fw_read_preboot_caps()
1521 pre_fw_load = &hdev->fw_loader.pre_fw_load; in hl_fw_read_preboot_caps()
1523 rc = hl_fw_wait_preboot_ready(hdev); in hl_fw_read_preboot_caps()
1553 hdev->asic_funcs->init_firmware_loader(hdev); in hl_fw_read_preboot_caps()
1555 dev_dbg(hdev->dev, "Attempting %s FW load\n", in hl_fw_read_preboot_caps()
1560 static int hl_fw_static_read_device_fw_version(struct hl_device *hdev, in hl_fw_static_read_device_fw_version() argument
1563 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_static_read_device_fw_version()
1564 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_static_read_device_fw_version()
1571 static_loader = &hdev->fw_loader.static_loader; in hl_fw_static_read_device_fw_version()
1587 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_static_read_device_fw_version()
1595 hdev->pcie_bar[fw_loader->sram_bar_id] + ver_off, in hl_fw_static_read_device_fw_version()
1598 dev_err(hdev->dev, "%s version offset (0x%x) is above SRAM\n", in hl_fw_static_read_device_fw_version()
1607 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_static_read_device_fw_version()
1617 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_static_read_device_fw_version()
1622 dev_info(hdev->dev, "preboot version %s\n", in hl_fw_static_read_device_fw_version()
1640 static void hl_fw_preboot_update_state(struct hl_device *hdev) in hl_fw_preboot_update_state() argument
1642 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_preboot_update_state()
1661 dev_dbg(hdev->dev, "Firmware preboot boot device status0 %#x\n", in hl_fw_preboot_update_state()
1664 dev_dbg(hdev->dev, "Firmware preboot boot device status1 %#x\n", in hl_fw_preboot_update_state()
1667 dev_dbg(hdev->dev, "Firmware preboot hard-reset is %s\n", in hl_fw_preboot_update_state()
1670 dev_dbg(hdev->dev, "firmware-level security is %s\n", in hl_fw_preboot_update_state()
1673 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_preboot_update_state()
1677 static int hl_fw_static_read_preboot_status(struct hl_device *hdev) in hl_fw_static_read_preboot_status() argument
1681 rc = hl_fw_static_read_device_fw_version(hdev, FW_COMP_PREBOOT); in hl_fw_static_read_preboot_status()
1688 int hl_fw_read_preboot_status(struct hl_device *hdev) in hl_fw_read_preboot_status() argument
1692 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU)) in hl_fw_read_preboot_status()
1696 hdev->asic_funcs->init_firmware_preload_params(hdev); in hl_fw_read_preboot_status()
1702 rc = hl_fw_read_preboot_caps(hdev); in hl_fw_read_preboot_status()
1706 hl_fw_preboot_update_state(hdev); in hl_fw_read_preboot_status()
1709 if (hdev->asic_prop.dynamic_fw_load) in hl_fw_read_preboot_status()
1712 return hl_fw_static_read_preboot_status(hdev); in hl_fw_read_preboot_status()
1732 static void hl_fw_dynamic_report_error_status(struct hl_device *hdev, in hl_fw_dynamic_report_error_status() argument
1740 dev_err(hdev->dev, "Device status %s, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1744 dev_err(hdev->dev, "Device status unknown %d, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1763 static void hl_fw_dynamic_send_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_cmd() argument
1775 trace_habanalabs_comms_send_cmd(hdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_cmd()
1789 static int hl_fw_dynamic_extract_fw_response(struct hl_device *hdev, in hl_fw_dynamic_extract_fw_response() argument
1801 dev_err(hdev->dev, "FW status: invalid RAM type %u\n", in hl_fw_dynamic_extract_fw_response()
1822 static int hl_fw_dynamic_wait_for_status(struct hl_device *hdev, in hl_fw_dynamic_wait_for_status() argument
1833 trace_habanalabs_comms_wait_status(hdev->dev, comms_sts_str_arr[expected_status]); in hl_fw_dynamic_wait_for_status()
1837 hdev, in hl_fw_dynamic_wait_for_status()
1841 hdev->fw_comms_poll_interval_usec, in hl_fw_dynamic_wait_for_status()
1845 hl_fw_dynamic_report_error_status(hdev, status, in hl_fw_dynamic_wait_for_status()
1850 trace_habanalabs_comms_wait_status_done(hdev->dev, comms_sts_str_arr[expected_status]); in hl_fw_dynamic_wait_for_status()
1859 rc = hl_fw_dynamic_extract_fw_response(hdev, fw_loader, in hl_fw_dynamic_wait_for_status()
1879 static int hl_fw_dynamic_send_clear_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_clear_cmd() argument
1882 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_CLR_STS, 0); in hl_fw_dynamic_send_clear_cmd()
1884 return hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_NOOP, in hl_fw_dynamic_send_clear_cmd()
1917 int hl_fw_dynamic_send_protocol_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_protocol_cmd() argument
1924 trace_habanalabs_comms_protocol_cmd(hdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_protocol_cmd()
1927 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
1932 hl_fw_dynamic_send_cmd(hdev, fw_loader, cmd, size); in hl_fw_dynamic_send_protocol_cmd()
1935 rc = hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_ACK, in hl_fw_dynamic_send_protocol_cmd()
1941 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
1946 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_NOOP, 0); in hl_fw_dynamic_send_protocol_cmd()
1951 rc = hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_OK, in hl_fw_dynamic_send_protocol_cmd()
1957 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
1962 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_NOOP, 0); in hl_fw_dynamic_send_protocol_cmd()
1997 static int hl_fw_dynamic_validate_memory_bound(struct hl_device *hdev, in hl_fw_dynamic_validate_memory_bound() argument
2006 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2019 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2036 static int hl_fw_dynamic_validate_descriptor(struct hl_device *hdev, in hl_fw_dynamic_validate_descriptor() argument
2049 dev_dbg(hdev->dev, "Invalid magic for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
2053 dev_dbg(hdev->dev, "Invalid version for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
2068 dev_err(hdev->dev, "CRC32 mismatch for dynamic FW descriptor (%x:%x)\n", in hl_fw_dynamic_validate_descriptor()
2075 region_id = hl_get_pci_memory_region(hdev, addr); in hl_fw_dynamic_validate_descriptor()
2077 dev_err(hdev->dev, "Invalid region to copy FW image address=%llx\n", addr); in hl_fw_dynamic_validate_descriptor()
2081 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_validate_descriptor()
2090 rc = hl_fw_dynamic_validate_memory_bound(hdev, addr, in hl_fw_dynamic_validate_descriptor()
2094 dev_err(hdev->dev, "invalid mem transfer request for FW image\n"); in hl_fw_dynamic_validate_descriptor()
2104 static int hl_fw_dynamic_validate_response(struct hl_device *hdev, in hl_fw_dynamic_validate_response() argument
2118 rc = hl_fw_dynamic_validate_memory_bound(hdev, device_addr, in hl_fw_dynamic_validate_response()
2130 static void hl_fw_dynamic_read_descriptor_msg(struct hl_device *hdev, in hl_fw_dynamic_read_descriptor_msg() argument
2146 dev_err(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2149 dev_warn(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2152 dev_info(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2155 dev_dbg(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2169 static int hl_fw_dynamic_read_and_validate_descriptor(struct hl_device *hdev, in hl_fw_dynamic_read_and_validate_descriptor() argument
2187 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_read_and_validate_descriptor()
2189 rc = hl_fw_dynamic_validate_response(hdev, response, region); in hl_fw_dynamic_read_and_validate_descriptor()
2191 dev_err(hdev->dev, in hl_fw_dynamic_read_and_validate_descriptor()
2203 src = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_read_and_validate_descriptor()
2223 rc = hl_fw_dynamic_validate_descriptor(hdev, fw_loader, in hl_fw_dynamic_read_and_validate_descriptor()
2227 hl_fw_dynamic_read_descriptor_msg(hdev, temp_fw_desc); in hl_fw_dynamic_read_and_validate_descriptor()
2243 static int hl_fw_dynamic_request_descriptor(struct hl_device *hdev, in hl_fw_dynamic_request_descriptor() argument
2249 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_PREP_DESC, in hl_fw_dynamic_request_descriptor()
2255 return hl_fw_dynamic_read_and_validate_descriptor(hdev, fw_loader); in hl_fw_dynamic_request_descriptor()
2265 static int hl_fw_dynamic_read_device_fw_version(struct hl_device *hdev, in hl_fw_dynamic_read_device_fw_version() argument
2269 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_dynamic_read_device_fw_version()
2279 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_dynamic_read_device_fw_version()
2287 dev_info(hdev->dev, "preboot full version: '%s'\n", preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2292 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_dynamic_read_device_fw_version()
2295 rc = hl_get_sw_major_minor_subminor(hdev, preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2300 rc = hl_get_preboot_major_minor(hdev, preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2308 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_dynamic_read_device_fw_version()
2322 static int hl_fw_dynamic_copy_image(struct hl_device *hdev, in hl_fw_dynamic_copy_image() argument
2338 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_image()
2341 rc = hl_fw_copy_fw_to_device(hdev, fw, dest, in hl_fw_dynamic_copy_image()
2355 static int hl_fw_dynamic_copy_msg(struct hl_device *hdev, in hl_fw_dynamic_copy_msg() argument
2370 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_msg()
2373 rc = hl_fw_copy_msg_to_device(hdev, msg, dest, 0, 0); in hl_fw_dynamic_copy_msg()
2388 static void hl_fw_boot_fit_update_state(struct hl_device *hdev, in hl_fw_boot_fit_update_state() argument
2392 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_boot_fit_update_state()
2394 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_BOOT_CPU; in hl_fw_boot_fit_update_state()
2404 dev_dbg(hdev->dev, "Firmware boot CPU status0 %#x\n", in hl_fw_boot_fit_update_state()
2412 dev_dbg(hdev->dev, "Firmware boot CPU status1 %#x\n", in hl_fw_boot_fit_update_state()
2416 dev_dbg(hdev->dev, "Firmware boot CPU hard-reset is %s\n", in hl_fw_boot_fit_update_state()
2420 static void hl_fw_dynamic_update_linux_interrupt_if(struct hl_device *hdev) in hl_fw_dynamic_update_linux_interrupt_if() argument
2423 &hdev->fw_loader.dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_update_linux_interrupt_if()
2428 if (!hdev->asic_prop.gic_interrupts_enable && in hl_fw_dynamic_update_linux_interrupt_if()
2429 !(hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_fw_dynamic_update_linux_interrupt_if()
2434 dev_warn(hdev->dev, in hl_fw_dynamic_update_linux_interrupt_if()
2448 static int hl_fw_dynamic_load_image(struct hl_device *hdev, in hl_fw_dynamic_load_image() argument
2472 rc = hl_request_fw(hdev, &fw, fw_name); in hl_fw_dynamic_load_image()
2479 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, fw->size); in hl_fw_dynamic_load_image()
2484 rc = hl_fw_dynamic_read_device_fw_version(hdev, cur_fwc, in hl_fw_dynamic_load_image()
2490 rc = hl_fw_dynamic_copy_image(hdev, fw, fw_loader); in hl_fw_dynamic_load_image()
2494 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_DATA_RDY, in hl_fw_dynamic_load_image()
2500 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_EXEC, in hl_fw_dynamic_load_image()
2509 static int hl_fw_dynamic_wait_for_boot_fit_active(struct hl_device *hdev, in hl_fw_dynamic_wait_for_boot_fit_active() argument
2527 hdev, in hl_fw_dynamic_wait_for_boot_fit_active()
2532 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_boot_fit_active()
2535 dev_err(hdev->dev, "failed to wait for boot (status = %d)\n", status); in hl_fw_dynamic_wait_for_boot_fit_active()
2539 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_dynamic_wait_for_boot_fit_active()
2543 static int hl_fw_dynamic_wait_for_linux_active(struct hl_device *hdev, in hl_fw_dynamic_wait_for_linux_active() argument
2555 hdev, in hl_fw_dynamic_wait_for_linux_active()
2559 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_linux_active()
2562 dev_err(hdev->dev, "failed to wait for Linux (status = %d)\n", status); in hl_fw_dynamic_wait_for_linux_active()
2566 dev_dbg(hdev->dev, "Boot status = %d\n", status); in hl_fw_dynamic_wait_for_linux_active()
2585 static void hl_fw_linux_update_state(struct hl_device *hdev, in hl_fw_linux_update_state() argument
2589 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_linux_update_state()
2591 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_LINUX; in hl_fw_linux_update_state()
2604 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2608 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_linux_update_state()
2616 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2621 dev_dbg(hdev->dev, "Firmware application CPU hard-reset is %s\n", in hl_fw_linux_update_state()
2624 dev_info(hdev->dev, "Successfully loaded firmware to device\n"); in hl_fw_linux_update_state()
2637 static int hl_fw_dynamic_send_msg(struct hl_device *hdev, in hl_fw_dynamic_send_msg() argument
2658 dev_err(hdev->dev, in hl_fw_dynamic_send_msg()
2665 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, in hl_fw_dynamic_send_msg()
2671 rc = hl_fw_dynamic_copy_msg(hdev, msg, fw_loader); in hl_fw_dynamic_send_msg()
2675 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_DATA_RDY, in hl_fw_dynamic_send_msg()
2681 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_EXEC, in hl_fw_dynamic_send_msg()
2708 static int hl_fw_dynamic_init_cpu(struct hl_device *hdev, in hl_fw_dynamic_init_cpu() argument
2714 dev_info(hdev->dev, in hl_fw_dynamic_init_cpu()
2716 hdev->asic_prop.fw_security_enabled ? "secured " : ""); in hl_fw_dynamic_init_cpu()
2727 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_RST_STATE, in hl_fw_dynamic_init_cpu()
2733 if (hdev->reset_info.curr_reset_cause) { in hl_fw_dynamic_init_cpu()
2734 rc = hl_fw_dynamic_send_msg(hdev, fw_loader, in hl_fw_dynamic_init_cpu()
2735 HL_COMMS_RESET_CAUSE_TYPE, &hdev->reset_info.curr_reset_cause); in hl_fw_dynamic_init_cpu()
2740 hdev->reset_info.curr_reset_cause = HL_RESET_CAUSE_UNKNOWN; in hl_fw_dynamic_init_cpu()
2743 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) { in hl_fw_dynamic_init_cpu()
2746 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, 0); in hl_fw_dynamic_init_cpu()
2751 rc = hl_fw_dynamic_read_device_fw_version(hdev, FW_COMP_PREBOOT, in hl_fw_dynamic_init_cpu()
2758 if (hdev->support_preboot_binning) { in hl_fw_dynamic_init_cpu()
2760 hdev->tpc_binning = le64_to_cpu(binning_info->tpc_mask_l); in hl_fw_dynamic_init_cpu()
2761 hdev->dram_binning = le32_to_cpu(binning_info->dram_mask); in hl_fw_dynamic_init_cpu()
2762 hdev->edma_binning = le32_to_cpu(binning_info->edma_mask); in hl_fw_dynamic_init_cpu()
2763 hdev->decoder_binning = le32_to_cpu(binning_info->dec_mask); in hl_fw_dynamic_init_cpu()
2764 hdev->rotator_binning = le32_to_cpu(binning_info->rot_mask); in hl_fw_dynamic_init_cpu()
2766 rc = hdev->asic_funcs->set_dram_properties(hdev); in hl_fw_dynamic_init_cpu()
2770 rc = hdev->asic_funcs->set_binning_masks(hdev); in hl_fw_dynamic_init_cpu()
2774 dev_dbg(hdev->dev, in hl_fw_dynamic_init_cpu()
2776 hdev->tpc_binning, hdev->dram_binning, hdev->edma_binning, in hl_fw_dynamic_init_cpu()
2777 hdev->decoder_binning, hdev->rotator_binning); in hl_fw_dynamic_init_cpu()
2784 rc = hl_fw_dynamic_load_image(hdev, fw_loader, FW_COMP_BOOT_FIT, in hl_fw_dynamic_init_cpu()
2787 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2791 rc = hl_fw_dynamic_wait_for_boot_fit_active(hdev, fw_loader); in hl_fw_dynamic_init_cpu()
2795 hl_fw_boot_fit_update_state(hdev, in hl_fw_dynamic_init_cpu()
2805 if (hdev->pldm && !(hdev->fw_components & FW_TYPE_LINUX)) in hl_fw_dynamic_init_cpu()
2811 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_dynamic_init_cpu()
2813 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_dynamic_init_cpu()
2814 dev_info(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_dynamic_init_cpu()
2819 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, in hl_fw_dynamic_init_cpu()
2824 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2830 rc = hl_fw_dynamic_load_image(hdev, fw_loader, FW_COMP_LINUX, in hl_fw_dynamic_init_cpu()
2833 dev_err(hdev->dev, "failed to load Linux\n"); in hl_fw_dynamic_init_cpu()
2837 rc = hl_fw_dynamic_wait_for_linux_active(hdev, fw_loader); in hl_fw_dynamic_init_cpu()
2841 hl_fw_linux_update_state(hdev, in hl_fw_dynamic_init_cpu()
2845 hl_fw_dynamic_update_linux_interrupt_if(hdev); in hl_fw_dynamic_init_cpu()
2849 fw_error_rc = fw_read_errors(hdev, le32_to_cpu(dyn_regs->cpu_boot_err0), in hl_fw_dynamic_init_cpu()
2869 static int hl_fw_static_init_cpu(struct hl_device *hdev, in hl_fw_static_init_cpu() argument
2878 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) in hl_fw_static_init_cpu()
2892 dev_info(hdev->dev, "Going to wait for device boot (up to %lds)\n", in hl_fw_static_init_cpu()
2897 hdev, in hl_fw_static_init_cpu()
2901 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2905 dev_dbg(hdev->dev, in hl_fw_static_init_cpu()
2908 rc = hdev->asic_funcs->load_boot_fit_to_device(hdev); in hl_fw_static_init_cpu()
2920 hdev, in hl_fw_static_init_cpu()
2924 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2928 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2946 hdev, in hl_fw_static_init_cpu()
2953 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2956 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_static_init_cpu()
2959 hl_fw_static_read_device_fw_version(hdev, FW_COMP_BOOT_FIT); in hl_fw_static_init_cpu()
2962 hl_fw_boot_fit_update_state(hdev, cpu_boot_dev_status0_reg, in hl_fw_static_init_cpu()
2966 detect_cpu_boot_status(hdev, status); in hl_fw_static_init_cpu()
2974 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_static_init_cpu()
2976 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_static_init_cpu()
2977 dev_info(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_static_init_cpu()
2987 dev_info(hdev->dev, in hl_fw_static_init_cpu()
2990 rc = hdev->asic_funcs->load_firmware_to_device(hdev); in hl_fw_static_init_cpu()
2998 hdev, in hl_fw_static_init_cpu()
3002 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
3006 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3018 hdev, in hl_fw_static_init_cpu()
3022 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
3030 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3033 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3041 rc = fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
3048 hl_fw_linux_update_state(hdev, cpu_boot_dev_status0_reg, in hl_fw_static_init_cpu()
3054 fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
3072 int hl_fw_init_cpu(struct hl_device *hdev) in hl_fw_init_cpu() argument
3074 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_init_cpu()
3075 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_init_cpu()
3078 hl_fw_dynamic_init_cpu(hdev, fw_loader) : in hl_fw_init_cpu()
3079 hl_fw_static_init_cpu(hdev, fw_loader); in hl_fw_init_cpu()
3082 void hl_fw_set_pll_profile(struct hl_device *hdev) in hl_fw_set_pll_profile() argument
3084 hl_fw_set_frequency(hdev, hdev->asic_prop.clk_pll_index, in hl_fw_set_pll_profile()
3085 hdev->asic_prop.max_freq_value); in hl_fw_set_pll_profile()
3088 int hl_fw_get_clk_rate(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk) in hl_fw_get_clk_rate() argument
3092 if (!hl_device_operational(hdev, NULL)) in hl_fw_get_clk_rate()
3095 if (!hdev->pdev) { in hl_fw_get_clk_rate()
3101 value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false); in hl_fw_get_clk_rate()
3104 dev_err(hdev->dev, "Failed to retrieve device max clock %ld\n", value); in hl_fw_get_clk_rate()
3110 value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true); in hl_fw_get_clk_rate()
3113 dev_err(hdev->dev, "Failed to retrieve device current clock %ld\n", value); in hl_fw_get_clk_rate()
3122 long hl_fw_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr) in hl_fw_get_frequency() argument
3129 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_get_frequency()
3143 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_frequency()
3146 dev_err(hdev->dev, "Failed to get frequency of PLL %d, error %d\n", in hl_fw_get_frequency()
3154 void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq) in hl_fw_set_frequency() argument
3160 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_set_frequency()
3170 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_set_frequency()
3173 dev_err(hdev->dev, "Failed to set frequency to PLL %d, error %d\n", in hl_fw_set_frequency()
3177 long hl_fw_get_max_power(struct hl_device *hdev) in hl_fw_get_max_power() argument
3187 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_max_power()
3190 dev_err(hdev->dev, "Failed to get max power, error %d\n", rc); in hl_fw_get_max_power()
3197 void hl_fw_set_max_power(struct hl_device *hdev) in hl_fw_set_max_power() argument
3203 if (!hdev->pdev) in hl_fw_set_max_power()
3209 pkt.value = cpu_to_le64(hdev->max_power); in hl_fw_set_max_power()
3211 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_set_max_power()
3214 dev_err(hdev->dev, "Failed to set max power, error %d\n", rc); in hl_fw_set_max_power()
3217 static int hl_fw_get_sec_attest_data(struct hl_device *hdev, u32 packet_id, void *data, u32 size, in hl_fw_get_sec_attest_data() argument
3225 req_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, size, &req_dma_addr); in hl_fw_get_sec_attest_data()
3227 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3239 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_sec_attest_data()
3242 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3250 hl_cpu_accessible_dma_pool_free(hdev, size, req_cpu_addr); in hl_fw_get_sec_attest_data()
3255 int hl_fw_get_sec_attest_info(struct hl_device *hdev, struct cpucp_sec_attest_info *sec_attest_info, in hl_fw_get_sec_attest_info() argument
3258 return hl_fw_get_sec_attest_data(hdev, CPUCP_PACKET_SEC_ATTEST_GET, sec_attest_info, in hl_fw_get_sec_attest_info()
3263 int hl_fw_send_generic_request(struct hl_device *hdev, enum hl_passthrough_type sub_opcode, in hl_fw_send_generic_request() argument
3275 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)&pkt, sizeof(pkt), in hl_fw_send_generic_request()
3278 dev_err(hdev->dev, "failed to send CPUCP data of generic fw pkt\n"); in hl_fw_send_generic_request()
3280 dev_dbg(hdev->dev, "generic pkt was successful, result: 0x%llx\n", result); in hl_fw_send_generic_request()