Lines Matching refs:hdev

55 int hl_fw_version_cmp(struct hl_device *hdev, u32 major, u32 minor, u32 subminor)  in hl_fw_version_cmp()  argument
57 if (hdev->fw_sw_major_ver != major) in hl_fw_version_cmp()
58 return (hdev->fw_sw_major_ver > major) ? 1 : -1; in hl_fw_version_cmp()
60 if (hdev->fw_sw_minor_ver != minor) in hl_fw_version_cmp()
61 return (hdev->fw_sw_minor_ver > minor) ? 1 : -1; in hl_fw_version_cmp()
63 if (hdev->fw_sw_sub_minor_ver != subminor) in hl_fw_version_cmp()
64 return (hdev->fw_sw_sub_minor_ver > subminor) ? 1 : -1; in hl_fw_version_cmp()
137 static int hl_get_sw_major_minor_subminor(struct hl_device *hdev, const char *fw_str) in hl_get_sw_major_minor_subminor() argument
164 start = extract_u32_until_given_char(start, &hdev->fw_sw_major_ver, '.'); in hl_get_sw_major_minor_subminor()
169 start = extract_u32_until_given_char(start, &hdev->fw_sw_minor_ver, '.'); in hl_get_sw_major_minor_subminor()
174 start = extract_u32_until_given_char(start, &hdev->fw_sw_sub_minor_ver, '-'); in hl_get_sw_major_minor_subminor()
181 hdev->fw_sw_major_ver = 0; in hl_get_sw_major_minor_subminor()
182 hdev->fw_sw_minor_ver = 0; in hl_get_sw_major_minor_subminor()
183 hdev->fw_sw_sub_minor_ver = 0; in hl_get_sw_major_minor_subminor()
197 static int hl_get_preboot_major_minor(struct hl_device *hdev, char *preboot_ver) in hl_get_preboot_major_minor() argument
199 preboot_ver = extract_u32_until_given_char(preboot_ver, &hdev->fw_inner_major_ver, '.'); in hl_get_preboot_major_minor()
201 dev_err(hdev->dev, "Error parsing preboot major version\n"); in hl_get_preboot_major_minor()
207 preboot_ver = extract_u32_until_given_char(preboot_ver, &hdev->fw_inner_minor_ver, '.'); in hl_get_preboot_major_minor()
209 dev_err(hdev->dev, "Error parsing preboot minor version\n"); in hl_get_preboot_major_minor()
215 hdev->fw_inner_major_ver = 0; in hl_get_preboot_major_minor()
216 hdev->fw_inner_minor_ver = 0; in hl_get_preboot_major_minor()
220 static int hl_request_fw(struct hl_device *hdev, in hl_request_fw() argument
227 rc = request_firmware(firmware_p, fw_name, hdev->dev); in hl_request_fw()
229 dev_err(hdev->dev, "Firmware file %s is not found! (error %d)\n", in hl_request_fw()
236 dev_err(hdev->dev, "Illegal %s firmware size %zu\n", in hl_request_fw()
242 dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size); in hl_request_fw()
245 dev_err(hdev->dev, in hl_request_fw()
284 static int hl_fw_copy_fw_to_device(struct hl_device *hdev, in hl_fw_copy_fw_to_device() argument
295 dev_err(hdev->dev, in hl_fw_copy_fw_to_device()
318 static int hl_fw_copy_msg_to_device(struct hl_device *hdev, in hl_fw_copy_msg_to_device() argument
329 dev_err(hdev->dev, in hl_fw_copy_msg_to_device()
355 int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name, in hl_fw_load_fw_to_device() argument
361 rc = hl_request_fw(hdev, &fw, fw_name); in hl_fw_load_fw_to_device()
365 rc = hl_fw_copy_fw_to_device(hdev, fw, dst, src_offset, size); in hl_fw_load_fw_to_device()
371 int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode, u64 value) in hl_fw_send_pci_access_msg() argument
379 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_pci_access_msg()
381 dev_err(hdev->dev, "Failed to disable FW's PCI access\n"); in hl_fw_send_pci_access_msg()
404 int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, in hl_fw_send_cpu_message() argument
407 struct hl_hw_queue *queue = &hdev->kernel_queues[hw_queue_id]; in hl_fw_send_cpu_message()
408 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_send_cpu_message()
415 pkt = hl_cpu_accessible_dma_pool_alloc(hdev, size, &pkt_dma_addr); in hl_fw_send_cpu_message()
417 dev_err(hdev->dev, "Failed to allocate DMA memory for packet to CPU\n"); in hl_fw_send_cpu_message()
423 mutex_lock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
426 if (hdev->disabled && !hdev->reset_info.in_compute_reset) in hl_fw_send_cpu_message()
429 if (hdev->device_cpu_disabled) { in hl_fw_send_cpu_message()
446 hl_hw_queue_submit_bd(hdev, queue, hl_queue_inc_ptr(queue->pi), size, pkt_dma_addr); in hl_fw_send_cpu_message()
453 rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp, in hl_fw_send_cpu_message()
457 hl_hw_queue_inc_ci_kernel(hdev, hw_queue_id); in hl_fw_send_cpu_message()
463 if (!hl_device_operational(hdev, NULL) && !hdev->reset_info.in_compute_reset) { in hl_fw_send_cpu_message()
464 dev_dbg(hdev->dev, "Device CPU packet timeout (0x%x) due to FW reset\n", in hl_fw_send_cpu_message()
471 dev_err(hdev->dev, "Device CPU packet timeout (status = 0x%x)\n" in hl_fw_send_cpu_message()
476 hdev->device_cpu_disabled = true; in hl_fw_send_cpu_message()
487 dev_dbg(hdev->dev, "F/W ERROR %d for CPU packet %d\n", rc, opcode); in hl_fw_send_cpu_message()
494 dev_err(hdev->dev, in hl_fw_send_cpu_message()
498 dev_err(hdev->dev, in hl_fw_send_cpu_message()
502 dev_dbg(hdev->dev, in hl_fw_send_cpu_message()
506 dev_err(hdev->dev, in hl_fw_send_cpu_message()
511 dev_err(hdev->dev, in hl_fw_send_cpu_message()
535 mutex_unlock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
537 hl_cpu_accessible_dma_pool_free(hdev, size, pkt); in hl_fw_send_cpu_message()
542 int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type) in hl_fw_unmask_irq() argument
554 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_unmask_irq()
558 dev_err(hdev->dev, "failed to unmask event %d", event_type); in hl_fw_unmask_irq()
563 int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr, in hl_fw_unmask_irq_arr() argument
579 dev_err(hdev->dev, "too many elements in IRQ array\n"); in hl_fw_unmask_irq_arr()
593 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt, in hl_fw_unmask_irq_arr()
597 dev_err(hdev->dev, "failed to unmask event array\n"); in hl_fw_unmask_irq_arr()
604 int hl_fw_test_cpu_queue(struct hl_device *hdev) in hl_fw_test_cpu_queue() argument
614 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &test_pkt, in hl_fw_test_cpu_queue()
619 dev_err(hdev->dev, in hl_fw_test_cpu_queue()
622 dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc); in hl_fw_test_cpu_queue()
628 void *hl_fw_cpu_accessible_dma_pool_alloc(struct hl_device *hdev, size_t size, in hl_fw_cpu_accessible_dma_pool_alloc() argument
633 kernel_addr = gen_pool_alloc(hdev->cpu_accessible_dma_pool, size); in hl_fw_cpu_accessible_dma_pool_alloc()
635 *dma_handle = hdev->cpu_accessible_dma_address + in hl_fw_cpu_accessible_dma_pool_alloc()
636 (kernel_addr - (u64) (uintptr_t) hdev->cpu_accessible_dma_mem); in hl_fw_cpu_accessible_dma_pool_alloc()
641 void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size, in hl_fw_cpu_accessible_dma_pool_free() argument
644 gen_pool_free(hdev->cpu_accessible_dma_pool, (u64) (uintptr_t) vaddr, in hl_fw_cpu_accessible_dma_pool_free()
648 int hl_fw_send_soft_reset(struct hl_device *hdev) in hl_fw_send_soft_reset() argument
655 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_soft_reset()
657 dev_err(hdev->dev, "failed to send soft-reset msg (err = %d)\n", rc); in hl_fw_send_soft_reset()
662 int hl_fw_send_device_activity(struct hl_device *hdev, bool open) in hl_fw_send_device_activity() argument
670 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_send_device_activity()
672 dev_err(hdev->dev, "failed to send device activity msg(%u)\n", open); in hl_fw_send_device_activity()
677 int hl_fw_send_heartbeat(struct hl_device *hdev) in hl_fw_send_heartbeat() argument
687 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt, sizeof(hb_pkt), 0, &result); in hl_fw_send_heartbeat()
694 dev_warn(hdev->dev, "FW reported EQ fault during heartbeat\n"); in hl_fw_send_heartbeat()
698 hdev->heartbeat_debug_info.last_pq_heartbeat_ts = ktime_get_real_seconds(); in hl_fw_send_heartbeat()
703 static bool fw_report_boot_dev0(struct hl_device *hdev, u32 err_val, u32 sts_val) in fw_report_boot_dev0() argument
711 dev_err(hdev->dev, "Device boot error - DRAM initialization failed\n"); in fw_report_boot_dev0()
714 dev_err(hdev->dev, "Device boot error - FIT image corrupted\n"); in fw_report_boot_dev0()
717 dev_err(hdev->dev, "Device boot error - Thermal Sensor initialization failed\n"); in fw_report_boot_dev0()
720 if (hdev->bmc_enable) { in fw_report_boot_dev0()
721 dev_err(hdev->dev, "Device boot error - Skipped waiting for BMC\n"); in fw_report_boot_dev0()
723 dev_info(hdev->dev, "Device boot message - Skipped waiting for BMC\n"); in fw_report_boot_dev0()
732 dev_err(hdev->dev, "Device boot error - Serdes data from BMC not available\n"); in fw_report_boot_dev0()
735 dev_err(hdev->dev, "Device boot error - NIC F/W initialization failed\n"); in fw_report_boot_dev0()
738 dev_err(hdev->dev, "Device boot warning - security not ready\n"); in fw_report_boot_dev0()
741 dev_err(hdev->dev, "Device boot error - security failure\n"); in fw_report_boot_dev0()
744 dev_err(hdev->dev, "Device boot error - eFuse failure\n"); in fw_report_boot_dev0()
747 dev_err(hdev->dev, "Device boot error - Failed to load preboot secondary image\n"); in fw_report_boot_dev0()
750 dev_err(hdev->dev, "Device boot error - PLL failure\n"); in fw_report_boot_dev0()
753 dev_err(hdev->dev, "Device boot error - Failed to set threshold for temperature sensor\n"); in fw_report_boot_dev0()
757 dev_dbg(hdev->dev, "device unusable status is set\n"); in fw_report_boot_dev0()
762 dev_err(hdev->dev, "Device boot error - binning failure\n"); in fw_report_boot_dev0()
765 dev_dbg(hdev->dev, "Device status0 %#x\n", sts_val); in fw_report_boot_dev0()
768 dev_err(hdev->dev, "Device boot warning - Skipped DRAM initialization\n"); in fw_report_boot_dev0()
771 dev_err(hdev->dev, "Device boot error - ARC memory scrub failed\n"); in fw_report_boot_dev0()
775 dev_err(hdev->dev, "Device boot error - EEPROM failure detected\n"); in fw_report_boot_dev0()
780 dev_warn(hdev->dev, "Device boot warning - Failed to load preboot primary image\n"); in fw_report_boot_dev0()
783 dev_warn(hdev->dev, "Device boot warning - TPM failure\n"); in fw_report_boot_dev0()
790 lower_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev0()
797 static bool fw_report_boot_dev1(struct hl_device *hdev, u32 err_val, in fw_report_boot_dev1() argument
811 dev_dbg(hdev->dev, "Device status1 %#x\n", sts_val); in fw_report_boot_dev1()
814 dev_err(hdev->dev, in fw_report_boot_dev1()
822 upper_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev1()
828 static int fw_read_errors(struct hl_device *hdev, u32 boot_err0_reg, in fw_read_errors() argument
846 err_exists = fw_report_boot_dev0(hdev, err_val, status_val); in fw_read_errors()
850 err_exists |= fw_report_boot_dev1(hdev, err_val, status_val); in fw_read_errors()
858 int hl_fw_cpucp_info_get(struct hl_device *hdev, in hl_fw_cpucp_info_get() argument
863 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_cpucp_info_get()
871 cpucp_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, sizeof(struct cpucp_info), in hl_fw_cpucp_info_get()
874 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
886 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_info_get()
889 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
894 rc = fw_read_errors(hdev, boot_err0_reg, boot_err1_reg, in hl_fw_cpucp_info_get()
897 dev_err(hdev->dev, "Errors in device boot\n"); in hl_fw_cpucp_info_get()
904 rc = hl_build_hwmon_channel_info(hdev, prop->cpucp_info.sensors); in hl_fw_cpucp_info_get()
906 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
914 dev_info(hdev->dev, "Linux version %s", kernel_ver); in hl_fw_cpucp_info_get()
919 hdev->event_queue.check_eqe_index = false; in hl_fw_cpucp_info_get()
926 hdev->event_queue.check_eqe_index = true; in hl_fw_cpucp_info_get()
933 hl_cpu_accessible_dma_pool_free(hdev, sizeof(struct cpucp_info), cpucp_info_cpu_addr); in hl_fw_cpucp_info_get()
938 static int hl_fw_send_msi_info_msg(struct hl_device *hdev) in hl_fw_send_msi_info_msg() argument
946 if (!hdev->asic_funcs->get_msi_info) in hl_fw_send_msi_info_msg()
957 dev_err(hdev->dev, "CPUCP array data is too big\n"); in hl_fw_send_msi_info_msg()
968 hdev->asic_funcs->get_msi_info(pkt->data); in hl_fw_send_msi_info_msg()
973 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)pkt, in hl_fw_send_msi_info_msg()
985 dev_err(hdev->dev, "failed to send CPUCP array data\n"); in hl_fw_send_msi_info_msg()
992 int hl_fw_cpucp_handshake(struct hl_device *hdev, in hl_fw_cpucp_handshake() argument
999 rc = hl_fw_cpucp_info_get(hdev, sts_boot_dev_sts0_reg, in hl_fw_cpucp_handshake()
1005 return hl_fw_send_msi_info_msg(hdev); in hl_fw_cpucp_handshake()
1008 int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size) in hl_fw_get_eeprom_data() argument
1016 eeprom_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, max_size, in hl_fw_get_eeprom_data()
1019 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1031 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_eeprom_data()
1035 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1044 hl_cpu_accessible_dma_pool_free(hdev, max_size, eeprom_info_cpu_addr); in hl_fw_get_eeprom_data()
1049 int hl_fw_get_monitor_dump(struct hl_device *hdev, void *data) in hl_fw_get_monitor_dump() argument
1061 mon_dump_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, data_size, &mon_dump_dma_addr); in hl_fw_get_monitor_dump()
1063 dev_err(hdev->dev, in hl_fw_get_monitor_dump()
1074 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_monitor_dump()
1078 dev_err(hdev->dev, in hl_fw_get_monitor_dump()
1093 hl_cpu_accessible_dma_pool_free(hdev, data_size, mon_dump_cpu_addr); in hl_fw_get_monitor_dump()
1098 int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev, in hl_fw_cpucp_pci_counters_get() argument
1110 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1114 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1126 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1130 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1141 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1145 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1154 int hl_fw_cpucp_total_energy_get(struct hl_device *hdev, u64 *total_energy) in hl_fw_cpucp_total_energy_get() argument
1163 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_total_energy_get()
1167 dev_err(hdev->dev, in hl_fw_cpucp_total_energy_get()
1177 int get_used_pll_index(struct hl_device *hdev, u32 input_pll_index, in get_used_pll_index() argument
1180 struct asic_fixed_properties *prop = &hdev->asic_prop; in get_used_pll_index()
1201 fw_pll_idx = hdev->asic_funcs->map_pll_idx_to_fw_idx(input_pll_index); in get_used_pll_index()
1203 dev_err(hdev->dev, "Invalid PLL index (%u) error %d\n", in get_used_pll_index()
1213 dev_err(hdev->dev, "PLL index %d is not supported\n", in get_used_pll_index()
1223 int hl_fw_cpucp_pll_info_get(struct hl_device *hdev, u32 pll_index, in hl_fw_cpucp_pll_info_get() argument
1231 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_cpucp_pll_info_get()
1241 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pll_info_get()
1245 dev_err(hdev->dev, "Failed to read PLL info, error %d\n", rc); in hl_fw_cpucp_pll_info_get()
1257 int hl_fw_cpucp_power_get(struct hl_device *hdev, u64 *power) in hl_fw_cpucp_power_get() argument
1269 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_power_get()
1273 dev_err(hdev->dev, "Failed to read power, error %d\n", rc); in hl_fw_cpucp_power_get()
1282 int hl_fw_dram_replaced_row_get(struct hl_device *hdev, in hl_fw_dram_replaced_row_get() argument
1291 cpucp_repl_rows_info_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, in hl_fw_dram_replaced_row_get()
1295 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1307 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_dram_replaced_row_get()
1311 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1319 hl_cpu_accessible_dma_pool_free(hdev, sizeof(struct cpucp_hbm_row_info), in hl_fw_dram_replaced_row_get()
1325 int hl_fw_dram_pending_row_get(struct hl_device *hdev, u32 *pend_rows_num) in hl_fw_dram_pending_row_get() argument
1335 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_dram_pending_row_get()
1338 dev_err(hdev->dev, in hl_fw_dram_pending_row_get()
1348 int hl_fw_cpucp_engine_core_asid_set(struct hl_device *hdev, u32 asid) in hl_fw_cpucp_engine_core_asid_set() argument
1358 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_engine_core_asid_set()
1361 dev_err(hdev->dev, in hl_fw_cpucp_engine_core_asid_set()
1368 void hl_fw_ask_hard_reset_without_linux(struct hl_device *hdev) in hl_fw_ask_hard_reset_without_linux() argument
1371 &hdev->fw_loader.static_loader; in hl_fw_ask_hard_reset_without_linux()
1374 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_hard_reset_without_linux()
1375 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_hard_reset_without_linux()
1377 hdev->fw_loader.cpu_timeout); in hl_fw_ask_hard_reset_without_linux()
1379 dev_err(hdev->dev, "Failed sending COMMS_RST_DEV\n"); in hl_fw_ask_hard_reset_without_linux()
1385 void hl_fw_ask_halt_machine_without_linux(struct hl_device *hdev) in hl_fw_ask_halt_machine_without_linux() argument
1387 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_ask_halt_machine_without_linux()
1393 if (hdev->device_cpu_is_halted) in hl_fw_ask_halt_machine_without_linux()
1397 if (hdev->asic_prop.dynamic_fw_load) { in hl_fw_ask_halt_machine_without_linux()
1402 rc = hl_fw_dynamic_send_protocol_cmd(hdev, &hdev->fw_loader, in hl_fw_ask_halt_machine_without_linux()
1405 dev_err(hdev->dev, "Failed sending COMMS_GOTO_WFE\n"); in hl_fw_ask_halt_machine_without_linux()
1408 hdev, in hl_fw_ask_halt_machine_without_linux()
1412 hdev->fw_poll_interval_usec, in hl_fw_ask_halt_machine_without_linux()
1415 dev_err(hdev->dev, "Current status=%u. Timed-out updating to WFE\n", in hl_fw_ask_halt_machine_without_linux()
1419 static_loader = &hdev->fw_loader.static_loader; in hl_fw_ask_halt_machine_without_linux()
1429 hdev->device_cpu_is_halted = true; in hl_fw_ask_halt_machine_without_linux()
1432 static void detect_cpu_boot_status(struct hl_device *hdev, u32 status) in detect_cpu_boot_status() argument
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()
1467 dev_err(hdev->dev, in detect_cpu_boot_status()
1471 dev_err(hdev->dev, in detect_cpu_boot_status()
1475 dev_err(hdev->dev, in detect_cpu_boot_status()
1479 dev_err(hdev->dev, in detect_cpu_boot_status()
1483 dev_err(hdev->dev, in detect_cpu_boot_status()
1489 int hl_fw_wait_preboot_ready(struct hl_device *hdev) in hl_fw_wait_preboot_ready() argument
1491 struct pre_fw_load_props *pre_fw_load = &hdev->fw_loader.pre_fw_load; in hl_fw_wait_preboot_ready()
1507 hdev, in hl_fw_wait_preboot_ready()
1513 hdev->fw_poll_interval_usec, in hl_fw_wait_preboot_ready()
1537 fw_err = fw_read_errors(hdev, pre_fw_load->boot_err0_reg, in hl_fw_wait_preboot_ready()
1542 detect_cpu_boot_status(hdev, status); in hl_fw_wait_preboot_ready()
1543 dev_err(hdev->dev, "CPU boot %s (status = %d)\n", in hl_fw_wait_preboot_ready()
1548 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_PREBOOT_CPU; in hl_fw_wait_preboot_ready()
1553 static int hl_fw_read_preboot_caps(struct hl_device *hdev) in hl_fw_read_preboot_caps() argument
1560 prop = &hdev->asic_prop; in hl_fw_read_preboot_caps()
1561 pre_fw_load = &hdev->fw_loader.pre_fw_load; in hl_fw_read_preboot_caps()
1563 rc = hl_fw_wait_preboot_ready(hdev); in hl_fw_read_preboot_caps()
1593 hdev->asic_funcs->init_firmware_loader(hdev); in hl_fw_read_preboot_caps()
1595 dev_dbg(hdev->dev, "Attempting %s FW load\n", in hl_fw_read_preboot_caps()
1600 static int hl_fw_static_read_device_fw_version(struct hl_device *hdev, in hl_fw_static_read_device_fw_version() argument
1603 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_static_read_device_fw_version()
1604 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_static_read_device_fw_version()
1611 static_loader = &hdev->fw_loader.static_loader; in hl_fw_static_read_device_fw_version()
1627 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_static_read_device_fw_version()
1635 hdev->pcie_bar[fw_loader->sram_bar_id] + ver_off, in hl_fw_static_read_device_fw_version()
1638 dev_err(hdev->dev, "%s version offset (0x%x) is above SRAM\n", in hl_fw_static_read_device_fw_version()
1647 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_static_read_device_fw_version()
1657 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_static_read_device_fw_version()
1662 dev_info(hdev->dev, "preboot version %s\n", in hl_fw_static_read_device_fw_version()
1680 static void hl_fw_preboot_update_state(struct hl_device *hdev) in hl_fw_preboot_update_state() argument
1682 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_preboot_update_state()
1701 dev_dbg(hdev->dev, "Firmware preboot boot device status0 %#x\n", in hl_fw_preboot_update_state()
1704 dev_dbg(hdev->dev, "Firmware preboot boot device status1 %#x\n", in hl_fw_preboot_update_state()
1707 dev_dbg(hdev->dev, "Firmware preboot hard-reset is %s\n", in hl_fw_preboot_update_state()
1710 dev_dbg(hdev->dev, "firmware-level security is %s\n", in hl_fw_preboot_update_state()
1713 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_preboot_update_state()
1717 static int hl_fw_static_read_preboot_status(struct hl_device *hdev) in hl_fw_static_read_preboot_status() argument
1721 rc = hl_fw_static_read_device_fw_version(hdev, FW_COMP_PREBOOT); in hl_fw_static_read_preboot_status()
1728 int hl_fw_read_preboot_status(struct hl_device *hdev) in hl_fw_read_preboot_status() argument
1732 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU)) in hl_fw_read_preboot_status()
1736 hdev->asic_funcs->init_firmware_preload_params(hdev); in hl_fw_read_preboot_status()
1742 rc = hl_fw_read_preboot_caps(hdev); in hl_fw_read_preboot_status()
1746 hl_fw_preboot_update_state(hdev); in hl_fw_read_preboot_status()
1749 if (hdev->asic_prop.dynamic_fw_load) in hl_fw_read_preboot_status()
1752 return hl_fw_static_read_preboot_status(hdev); in hl_fw_read_preboot_status()
1772 static void hl_fw_dynamic_report_error_status(struct hl_device *hdev, in hl_fw_dynamic_report_error_status() argument
1780 dev_err(hdev->dev, "Device status %s, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1784 dev_err(hdev->dev, "Device status unknown %d, expected status: %s\n", in hl_fw_dynamic_report_error_status()
1803 static void hl_fw_dynamic_send_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_cmd() argument
1815 trace_habanalabs_comms_send_cmd(&hdev->pdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_cmd()
1829 static int hl_fw_dynamic_extract_fw_response(struct hl_device *hdev, in hl_fw_dynamic_extract_fw_response() argument
1841 dev_err(hdev->dev, "FW status: invalid RAM type %u\n", in hl_fw_dynamic_extract_fw_response()
1862 static int hl_fw_dynamic_wait_for_status(struct hl_device *hdev, in hl_fw_dynamic_wait_for_status() argument
1873 trace_habanalabs_comms_wait_status(&hdev->pdev->dev, comms_sts_str_arr[expected_status]); in hl_fw_dynamic_wait_for_status()
1877 hdev, in hl_fw_dynamic_wait_for_status()
1881 hdev->fw_comms_poll_interval_usec, in hl_fw_dynamic_wait_for_status()
1885 hl_fw_dynamic_report_error_status(hdev, status, in hl_fw_dynamic_wait_for_status()
1890 trace_habanalabs_comms_wait_status_done(&hdev->pdev->dev, in hl_fw_dynamic_wait_for_status()
1900 rc = hl_fw_dynamic_extract_fw_response(hdev, fw_loader, in hl_fw_dynamic_wait_for_status()
1920 static int hl_fw_dynamic_send_clear_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_clear_cmd() argument
1923 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_CLR_STS, 0); in hl_fw_dynamic_send_clear_cmd()
1925 return hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_NOOP, in hl_fw_dynamic_send_clear_cmd()
1958 int hl_fw_dynamic_send_protocol_cmd(struct hl_device *hdev, in hl_fw_dynamic_send_protocol_cmd() argument
1965 trace_habanalabs_comms_protocol_cmd(&hdev->pdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_protocol_cmd()
1968 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
1973 hl_fw_dynamic_send_cmd(hdev, fw_loader, cmd, size); in hl_fw_dynamic_send_protocol_cmd()
1976 rc = hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_ACK, in hl_fw_dynamic_send_protocol_cmd()
1982 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
1987 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_NOOP, 0); in hl_fw_dynamic_send_protocol_cmd()
1992 rc = hl_fw_dynamic_wait_for_status(hdev, fw_loader, COMMS_STS_OK, in hl_fw_dynamic_send_protocol_cmd()
1998 rc = hl_fw_dynamic_send_clear_cmd(hdev, fw_loader); in hl_fw_dynamic_send_protocol_cmd()
2003 hl_fw_dynamic_send_cmd(hdev, fw_loader, COMMS_NOOP, 0); in hl_fw_dynamic_send_protocol_cmd()
2038 static int hl_fw_dynamic_validate_memory_bound(struct hl_device *hdev, in hl_fw_dynamic_validate_memory_bound() argument
2047 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2060 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2077 static int hl_fw_dynamic_validate_descriptor(struct hl_device *hdev, in hl_fw_dynamic_validate_descriptor() argument
2090 dev_dbg(hdev->dev, "Invalid magic for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
2094 dev_dbg(hdev->dev, "Invalid version for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
2109 dev_err(hdev->dev, "CRC32 mismatch for dynamic FW descriptor (%x:%x)\n", in hl_fw_dynamic_validate_descriptor()
2116 region_id = hl_get_pci_memory_region(hdev, addr); in hl_fw_dynamic_validate_descriptor()
2118 dev_err(hdev->dev, "Invalid region to copy FW image address=%llx\n", addr); in hl_fw_dynamic_validate_descriptor()
2122 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_validate_descriptor()
2131 rc = hl_fw_dynamic_validate_memory_bound(hdev, addr, in hl_fw_dynamic_validate_descriptor()
2135 dev_err(hdev->dev, "invalid mem transfer request for FW image\n"); in hl_fw_dynamic_validate_descriptor()
2145 static int hl_fw_dynamic_validate_response(struct hl_device *hdev, in hl_fw_dynamic_validate_response() argument
2159 rc = hl_fw_dynamic_validate_memory_bound(hdev, device_addr, in hl_fw_dynamic_validate_response()
2171 static void hl_fw_dynamic_read_descriptor_msg(struct hl_device *hdev, in hl_fw_dynamic_read_descriptor_msg() argument
2187 dev_err(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2190 dev_warn(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2193 dev_info(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2196 dev_dbg(hdev->dev, "fw: %s", fw_desc->ascii_msg[i].msg); in hl_fw_dynamic_read_descriptor_msg()
2210 static int hl_fw_dynamic_read_and_validate_descriptor(struct hl_device *hdev, in hl_fw_dynamic_read_and_validate_descriptor() argument
2228 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_read_and_validate_descriptor()
2230 rc = hl_fw_dynamic_validate_response(hdev, response, region); in hl_fw_dynamic_read_and_validate_descriptor()
2232 dev_err(hdev->dev, in hl_fw_dynamic_read_and_validate_descriptor()
2244 src = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_read_and_validate_descriptor()
2264 rc = hl_fw_dynamic_validate_descriptor(hdev, fw_loader, in hl_fw_dynamic_read_and_validate_descriptor()
2268 hl_fw_dynamic_read_descriptor_msg(hdev, temp_fw_desc); in hl_fw_dynamic_read_and_validate_descriptor()
2284 static int hl_fw_dynamic_request_descriptor(struct hl_device *hdev, in hl_fw_dynamic_request_descriptor() argument
2290 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_PREP_DESC, in hl_fw_dynamic_request_descriptor()
2296 return hl_fw_dynamic_read_and_validate_descriptor(hdev, fw_loader); in hl_fw_dynamic_request_descriptor()
2306 static int hl_fw_dynamic_read_device_fw_version(struct hl_device *hdev, in hl_fw_dynamic_read_device_fw_version() argument
2310 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_dynamic_read_device_fw_version()
2320 dev_info(hdev->dev, "boot-fit version %s\n", boot_ver); in hl_fw_dynamic_read_device_fw_version()
2328 dev_info(hdev->dev, "preboot full version: '%s'\n", preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2333 dev_info(hdev->dev, "%s\n", btl_ver); in hl_fw_dynamic_read_device_fw_version()
2336 rc = hl_get_sw_major_minor_subminor(hdev, preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2341 rc = hl_get_preboot_major_minor(hdev, preboot_ver); in hl_fw_dynamic_read_device_fw_version()
2349 dev_warn(hdev->dev, "Undefined FW component: %d\n", fwc); in hl_fw_dynamic_read_device_fw_version()
2363 static int hl_fw_dynamic_copy_image(struct hl_device *hdev, in hl_fw_dynamic_copy_image() argument
2379 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_image()
2382 rc = hl_fw_copy_fw_to_device(hdev, fw, dest, in hl_fw_dynamic_copy_image()
2396 static int hl_fw_dynamic_copy_msg(struct hl_device *hdev, in hl_fw_dynamic_copy_msg() argument
2411 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_msg()
2414 rc = hl_fw_copy_msg_to_device(hdev, msg, dest, 0, 0); in hl_fw_dynamic_copy_msg()
2429 static void hl_fw_boot_fit_update_state(struct hl_device *hdev, in hl_fw_boot_fit_update_state() argument
2433 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_boot_fit_update_state()
2435 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_BOOT_CPU; in hl_fw_boot_fit_update_state()
2445 dev_dbg(hdev->dev, "Firmware boot CPU status0 %#x\n", in hl_fw_boot_fit_update_state()
2453 dev_dbg(hdev->dev, "Firmware boot CPU status1 %#x\n", in hl_fw_boot_fit_update_state()
2457 dev_dbg(hdev->dev, "Firmware boot CPU hard-reset is %s\n", in hl_fw_boot_fit_update_state()
2461 static void hl_fw_dynamic_update_linux_interrupt_if(struct hl_device *hdev) in hl_fw_dynamic_update_linux_interrupt_if() argument
2464 &hdev->fw_loader.dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_update_linux_interrupt_if()
2469 if (!hdev->asic_prop.gic_interrupts_enable && in hl_fw_dynamic_update_linux_interrupt_if()
2470 !(hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_fw_dynamic_update_linux_interrupt_if()
2475 dev_warn(hdev->dev, in hl_fw_dynamic_update_linux_interrupt_if()
2489 static int hl_fw_dynamic_load_image(struct hl_device *hdev, in hl_fw_dynamic_load_image() argument
2513 rc = hl_request_fw(hdev, &fw, fw_name); in hl_fw_dynamic_load_image()
2520 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, fw->size); in hl_fw_dynamic_load_image()
2525 rc = hl_fw_dynamic_read_device_fw_version(hdev, cur_fwc, in hl_fw_dynamic_load_image()
2531 rc = hl_fw_dynamic_copy_image(hdev, fw, fw_loader); in hl_fw_dynamic_load_image()
2535 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_DATA_RDY, in hl_fw_dynamic_load_image()
2541 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_EXEC, in hl_fw_dynamic_load_image()
2550 static int hl_fw_dynamic_wait_for_boot_fit_active(struct hl_device *hdev, in hl_fw_dynamic_wait_for_boot_fit_active() argument
2568 hdev, in hl_fw_dynamic_wait_for_boot_fit_active()
2573 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_boot_fit_active()
2576 dev_err(hdev->dev, "failed to wait for boot (status = %d)\n", status); in hl_fw_dynamic_wait_for_boot_fit_active()
2580 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_dynamic_wait_for_boot_fit_active()
2584 static int hl_fw_dynamic_wait_for_linux_active(struct hl_device *hdev, in hl_fw_dynamic_wait_for_linux_active() argument
2596 hdev, in hl_fw_dynamic_wait_for_linux_active()
2600 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_linux_active()
2603 dev_err(hdev->dev, "failed to wait for Linux (status = %d)\n", status); in hl_fw_dynamic_wait_for_linux_active()
2607 dev_dbg(hdev->dev, "Boot status = %d\n", status); in hl_fw_dynamic_wait_for_linux_active()
2626 static void hl_fw_linux_update_state(struct hl_device *hdev, in hl_fw_linux_update_state() argument
2630 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_linux_update_state()
2632 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_LINUX; in hl_fw_linux_update_state()
2645 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2649 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_linux_update_state()
2657 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2662 dev_dbg(hdev->dev, "Firmware application CPU hard-reset is %s\n", in hl_fw_linux_update_state()
2665 dev_info(hdev->dev, "Successfully loaded firmware to device\n"); in hl_fw_linux_update_state()
2678 static int hl_fw_dynamic_send_msg(struct hl_device *hdev, in hl_fw_dynamic_send_msg() argument
2699 dev_err(hdev->dev, in hl_fw_dynamic_send_msg()
2706 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, in hl_fw_dynamic_send_msg()
2712 rc = hl_fw_dynamic_copy_msg(hdev, msg, fw_loader); in hl_fw_dynamic_send_msg()
2716 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_DATA_RDY, in hl_fw_dynamic_send_msg()
2722 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_EXEC, in hl_fw_dynamic_send_msg()
2749 static int hl_fw_dynamic_init_cpu(struct hl_device *hdev, in hl_fw_dynamic_init_cpu() argument
2755 dev_info(hdev->dev, in hl_fw_dynamic_init_cpu()
2757 hdev->asic_prop.fw_security_enabled ? "secured " : ""); in hl_fw_dynamic_init_cpu()
2768 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, COMMS_RST_STATE, in hl_fw_dynamic_init_cpu()
2774 if (hdev->reset_info.curr_reset_cause) { in hl_fw_dynamic_init_cpu()
2775 rc = hl_fw_dynamic_send_msg(hdev, fw_loader, in hl_fw_dynamic_init_cpu()
2776 HL_COMMS_RESET_CAUSE_TYPE, &hdev->reset_info.curr_reset_cause); in hl_fw_dynamic_init_cpu()
2781 hdev->reset_info.curr_reset_cause = HL_RESET_CAUSE_UNKNOWN; in hl_fw_dynamic_init_cpu()
2784 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, sizeof(struct lkd_msg_comms)); in hl_fw_dynamic_init_cpu()
2788 if (hdev->asic_prop.support_dynamic_resereved_fw_size) in hl_fw_dynamic_init_cpu()
2789 hdev->asic_prop.reserved_fw_mem_size = in hl_fw_dynamic_init_cpu()
2792 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) { in hl_fw_dynamic_init_cpu()
2796 rc = hl_fw_dynamic_read_device_fw_version(hdev, FW_COMP_PREBOOT, in hl_fw_dynamic_init_cpu()
2802 if (hdev->support_preboot_binning) { in hl_fw_dynamic_init_cpu()
2804 hdev->tpc_binning = le64_to_cpu(binning_info->tpc_mask_l); in hl_fw_dynamic_init_cpu()
2805 hdev->dram_binning = le32_to_cpu(binning_info->dram_mask); in hl_fw_dynamic_init_cpu()
2806 hdev->edma_binning = le32_to_cpu(binning_info->edma_mask); in hl_fw_dynamic_init_cpu()
2807 hdev->decoder_binning = le32_to_cpu(binning_info->dec_mask); in hl_fw_dynamic_init_cpu()
2808 hdev->rotator_binning = le32_to_cpu(binning_info->rot_mask); in hl_fw_dynamic_init_cpu()
2810 rc = hdev->asic_funcs->set_dram_properties(hdev); in hl_fw_dynamic_init_cpu()
2814 rc = hdev->asic_funcs->set_binning_masks(hdev); in hl_fw_dynamic_init_cpu()
2818 dev_dbg(hdev->dev, in hl_fw_dynamic_init_cpu()
2820 hdev->tpc_binning, hdev->dram_binning, hdev->edma_binning, in hl_fw_dynamic_init_cpu()
2821 hdev->decoder_binning, hdev->rotator_binning); in hl_fw_dynamic_init_cpu()
2828 rc = hl_fw_dynamic_load_image(hdev, fw_loader, FW_COMP_BOOT_FIT, in hl_fw_dynamic_init_cpu()
2831 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2835 rc = hl_fw_dynamic_wait_for_boot_fit_active(hdev, fw_loader); in hl_fw_dynamic_init_cpu()
2839 hl_fw_boot_fit_update_state(hdev, in hl_fw_dynamic_init_cpu()
2849 if (hdev->pldm && !(hdev->fw_components & FW_TYPE_LINUX)) in hl_fw_dynamic_init_cpu()
2855 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_dynamic_init_cpu()
2857 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_dynamic_init_cpu()
2858 dev_dbg(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_dynamic_init_cpu()
2863 rc = hl_fw_dynamic_send_protocol_cmd(hdev, fw_loader, in hl_fw_dynamic_init_cpu()
2868 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2874 rc = hl_fw_dynamic_load_image(hdev, fw_loader, FW_COMP_LINUX, in hl_fw_dynamic_init_cpu()
2877 dev_err(hdev->dev, "failed to load Linux\n"); in hl_fw_dynamic_init_cpu()
2881 rc = hl_fw_dynamic_wait_for_linux_active(hdev, fw_loader); in hl_fw_dynamic_init_cpu()
2885 hl_fw_linux_update_state(hdev, in hl_fw_dynamic_init_cpu()
2889 hl_fw_dynamic_update_linux_interrupt_if(hdev); in hl_fw_dynamic_init_cpu()
2893 fw_error_rc = fw_read_errors(hdev, le32_to_cpu(dyn_regs->cpu_boot_err0), in hl_fw_dynamic_init_cpu()
2913 static int hl_fw_static_init_cpu(struct hl_device *hdev, in hl_fw_static_init_cpu() argument
2922 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) in hl_fw_static_init_cpu()
2936 dev_info(hdev->dev, "Going to wait for device boot (up to %lds)\n", in hl_fw_static_init_cpu()
2941 hdev, in hl_fw_static_init_cpu()
2945 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2949 dev_dbg(hdev->dev, in hl_fw_static_init_cpu()
2952 rc = hdev->asic_funcs->load_boot_fit_to_device(hdev); in hl_fw_static_init_cpu()
2964 hdev, in hl_fw_static_init_cpu()
2968 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2972 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2990 hdev, in hl_fw_static_init_cpu()
2997 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
3000 dev_dbg(hdev->dev, "uboot status = %d\n", status); in hl_fw_static_init_cpu()
3003 hl_fw_static_read_device_fw_version(hdev, FW_COMP_BOOT_FIT); in hl_fw_static_init_cpu()
3006 hl_fw_boot_fit_update_state(hdev, cpu_boot_dev_status0_reg, in hl_fw_static_init_cpu()
3010 detect_cpu_boot_status(hdev, status); in hl_fw_static_init_cpu()
3018 hdev->asic_funcs->init_cpu_scrambler_dram(hdev); in hl_fw_static_init_cpu()
3020 if (!(hdev->fw_components & FW_TYPE_LINUX)) { in hl_fw_static_init_cpu()
3021 dev_info(hdev->dev, "Skip loading Linux F/W\n"); in hl_fw_static_init_cpu()
3031 dev_info(hdev->dev, in hl_fw_static_init_cpu()
3034 rc = hdev->asic_funcs->load_firmware_to_device(hdev); in hl_fw_static_init_cpu()
3042 hdev, in hl_fw_static_init_cpu()
3046 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
3050 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3062 hdev, in hl_fw_static_init_cpu()
3066 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
3074 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3077 dev_err(hdev->dev, in hl_fw_static_init_cpu()
3085 rc = fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
3092 hl_fw_linux_update_state(hdev, cpu_boot_dev_status0_reg, in hl_fw_static_init_cpu()
3098 fw_read_errors(hdev, fw_loader->static_loader.boot_err0_reg, in hl_fw_static_init_cpu()
3116 int hl_fw_init_cpu(struct hl_device *hdev) in hl_fw_init_cpu() argument
3118 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_init_cpu()
3119 struct fw_load_mgr *fw_loader = &hdev->fw_loader; in hl_fw_init_cpu()
3122 hl_fw_dynamic_init_cpu(hdev, fw_loader) : in hl_fw_init_cpu()
3123 hl_fw_static_init_cpu(hdev, fw_loader); in hl_fw_init_cpu()
3126 void hl_fw_set_pll_profile(struct hl_device *hdev) in hl_fw_set_pll_profile() argument
3128 hl_fw_set_frequency(hdev, hdev->asic_prop.clk_pll_index, in hl_fw_set_pll_profile()
3129 hdev->asic_prop.max_freq_value); in hl_fw_set_pll_profile()
3132 int hl_fw_get_clk_rate(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk) in hl_fw_get_clk_rate() argument
3136 if (!hl_device_operational(hdev, NULL)) in hl_fw_get_clk_rate()
3139 if (!hdev->pdev) { in hl_fw_get_clk_rate()
3145 value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false); in hl_fw_get_clk_rate()
3148 dev_err(hdev->dev, "Failed to retrieve device max clock %ld\n", value); in hl_fw_get_clk_rate()
3154 value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true); in hl_fw_get_clk_rate()
3157 dev_err(hdev->dev, "Failed to retrieve device current clock %ld\n", value); in hl_fw_get_clk_rate()
3166 long hl_fw_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr) in hl_fw_get_frequency() argument
3173 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_get_frequency()
3187 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_frequency()
3190 dev_err(hdev->dev, "Failed to get frequency of PLL %d, error %d\n", in hl_fw_get_frequency()
3198 void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq) in hl_fw_set_frequency() argument
3204 rc = get_used_pll_index(hdev, pll_index, &used_pll_idx); in hl_fw_set_frequency()
3214 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_set_frequency()
3216 dev_err(hdev->dev, "Failed to set frequency to PLL %d, error %d\n", in hl_fw_set_frequency()
3220 long hl_fw_get_max_power(struct hl_device *hdev) in hl_fw_get_max_power() argument
3230 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_max_power()
3233 dev_err(hdev->dev, "Failed to get max power, error %d\n", rc); in hl_fw_get_max_power()
3240 void hl_fw_set_max_power(struct hl_device *hdev) in hl_fw_set_max_power() argument
3246 if (!hdev->pdev) in hl_fw_set_max_power()
3252 pkt.value = cpu_to_le64(hdev->max_power); in hl_fw_set_max_power()
3254 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_set_max_power()
3256 dev_err(hdev->dev, "Failed to set max power, error %d\n", rc); in hl_fw_set_max_power()
3259 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
3267 req_cpu_addr = hl_cpu_accessible_dma_pool_alloc(hdev, size, &req_dma_addr); in hl_fw_get_sec_attest_data()
3269 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3281 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), timeout, NULL); in hl_fw_get_sec_attest_data()
3284 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3292 hl_cpu_accessible_dma_pool_free(hdev, size, req_cpu_addr); in hl_fw_get_sec_attest_data()
3297 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
3300 return hl_fw_get_sec_attest_data(hdev, CPUCP_PACKET_SEC_ATTEST_GET, sec_attest_info, in hl_fw_get_sec_attest_info()
3305 int hl_fw_get_dev_info_signed(struct hl_device *hdev, in hl_fw_get_dev_info_signed() argument
3308 return hl_fw_get_sec_attest_data(hdev, CPUCP_PACKET_INFO_SIGNED_GET, dev_info_signed, in hl_fw_get_dev_info_signed()
3313 int hl_fw_send_generic_request(struct hl_device *hdev, enum hl_passthrough_type sub_opcode, in hl_fw_send_generic_request() argument
3325 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)&pkt, sizeof(pkt), in hl_fw_send_generic_request()
3329 dev_err(hdev->dev, "failed to send CPUCP data of generic fw pkt\n"); in hl_fw_send_generic_request()
3331 dev_dbg(hdev->dev, "generic pkt was successful, result: 0x%llx\n", result); in hl_fw_send_generic_request()