Lines Matching +full:binary +full:- +full:coded

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2022 HabanaLabs, Ltd.
45 * hl_fw_version_cmp() - compares the FW version to a specific version
50 * @subminor: sub-minor number of a reference version
52 * Return 1 if FW version greater than the reference version, -1 if it's
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()
78 str = strnstr(fw_str, "fw-", VERSION_MAX_LEN); in extract_fw_ver_from_str()
82 /* Skip the fw- part */ in extract_fw_ver_from_str()
84 ver_offset = str - fw_str; in extract_fw_ver_from_str()
87 whitespace = strnstr(str, " ", VERSION_MAX_LEN - ver_offset); in extract_fw_ver_from_str()
91 strscpy(fw_ver, str, whitespace - str + 1); in extract_fw_ver_from_str()
101 * extract_u32_until_given_char() - given a string of the format "<u32><char>*", extract the u32.
113 if (*ch == '\0' || ch == str || ch - str >= sizeof(num_str)) in extract_u32_until_given_char()
116 memcpy(num_str, str, ch - str); in extract_u32_until_given_char()
123 * hl_get_sw_major_minor_subminor() - extract the FW's SW version major, minor, sub-minor
131 * 1) 'Preboot version hl-gaudi2-1.9.0-fw-42.0.1-sec-3'
132 * 2) 'Preboot version hl-gaudi2-1.9.0-rc-fw-42.0.1-sec-3'
141 end = strnstr(fw_str, "-rc-", VERSION_MAX_LEN); in hl_get_sw_major_minor_subminor()
143 return -EINVAL; in hl_get_sw_major_minor_subminor()
146 end = strnstr(fw_str, "-fw-", VERSION_MAX_LEN); in hl_get_sw_major_minor_subminor()
149 return -EINVAL; in hl_get_sw_major_minor_subminor()
152 return -EINVAL; in hl_get_sw_major_minor_subminor()
154 for (start = end - 1; start != fw_str; start--) { in hl_get_sw_major_minor_subminor()
155 if (*start == '-') in hl_get_sw_major_minor_subminor()
160 return -EINVAL; in hl_get_sw_major_minor_subminor()
162 /* start/end point each to the starting and ending hyphen of the sw version e.g. -1.9.0- */ in hl_get_sw_major_minor_subminor()
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()
184 return -EINVAL; in hl_get_sw_major_minor_subminor()
188 * hl_get_preboot_major_minor() - extract the FW's version major, minor from the version string.
192 * preboot_ver is expected to be the format of <major>.<minor>.<sub minor>*, e.g: 42.0.1-sec-3
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()
217 return -EINVAL; in hl_get_preboot_major_minor()
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()
234 fw_size = (*firmware_p)->size; in hl_request_fw()
236 dev_err(hdev->dev, "Illegal %s firmware size %zu\n", in hl_request_fw()
238 rc = -EINVAL; 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()
248 rc = -EINVAL; in hl_request_fw()
261 * hl_release_firmware() - release FW
274 * hl_fw_copy_fw_to_device() - copy FW to device
280 * @size: amount of bytes to copy (0 to copy the whole binary)
282 * actual copy of FW binary data to device, shared by static and dynamic loaders
292 size = fw->size; in hl_fw_copy_fw_to_device()
294 if (src_offset + size > fw->size) { in hl_fw_copy_fw_to_device()
295 dev_err(hdev->dev, in hl_fw_copy_fw_to_device()
298 return -EINVAL; in hl_fw_copy_fw_to_device()
301 fw_data = (const void *) fw->data; in hl_fw_copy_fw_to_device()
308 * hl_fw_copy_msg_to_device() - copy message to device
314 * @size: amount of bytes to copy (0 to copy the whole binary)
329 dev_err(hdev->dev, in hl_fw_copy_msg_to_device()
332 return -EINVAL; in hl_fw_copy_msg_to_device()
343 * hl_fw_load_fw_to_device() - Load F/W code to device's memory.
349 * @size: amount of bytes to copy (0 to copy the whole binary)
353 * Return: 0 on success, non-zero for failure.
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()
387 * hl_fw_send_cpu_message() - send CPU message to the device.
398 * Return: 0 on success, non-zero for failure.
399 * -ENOMEM: memory allocation failure
400 * -EAGAIN: CPU is disabled (try again when enabled)
401 * -ETIMEDOUT: timeout waiting for FW response
402 * -EIO: protocol error
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()
417 dev_err(hdev->dev, "Failed to allocate DMA memory for packet to CPU\n"); in hl_fw_send_cpu_message()
418 return -ENOMEM; in hl_fw_send_cpu_message()
423 mutex_lock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
425 /* CPU-CP messages can be sent during soft-reset */ 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()
430 rc = -EAGAIN; in hl_fw_send_cpu_message()
435 pkt->fence = cpu_to_le32(UINT_MAX); in hl_fw_send_cpu_message()
436 pi = queue->pi; 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()
448 if (prop->fw_app_cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_PKT_PI_ACK_EN) in hl_fw_send_cpu_message()
449 expected_ack_val = queue->pi; in hl_fw_send_cpu_message()
453 rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp, in hl_fw_send_cpu_message()
459 if (rc == -ETIMEDOUT) { 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()
467 struct hl_bd *bd = queue->kernel_address; 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()
473 tmp, pi, pkt_dma_addr, (void *)pkt, bd->len, bd->ctl, bd->ptr, in hl_fw_send_cpu_message()
474 queue->dram_bd); in hl_fw_send_cpu_message()
476 hdev->device_cpu_disabled = true; in hl_fw_send_cpu_message()
480 tmp = le32_to_cpu(pkt->ctl); in hl_fw_send_cpu_message()
486 if (!prop->supports_advanced_cpucp_rc) { 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()
488 rc = -EIO; 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()
519 rc = -EIO; in hl_fw_send_cpu_message()
522 *result = le64_to_cpu(pkt->result); in hl_fw_send_cpu_message()
530 sent_bd = queue->kernel_address; in hl_fw_send_cpu_message()
532 sent_bd->ctl = cpu_to_le32(UINT_MAX); in hl_fw_send_cpu_message()
535 mutex_unlock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
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()
574 /* data should be aligned to 8 bytes in order to CPU-CP to copy it */ in hl_fw_unmask_irq_arr()
579 dev_err(hdev->dev, "too many elements in IRQ array\n"); in hl_fw_unmask_irq_arr()
580 return -EINVAL; in hl_fw_unmask_irq_arr()
585 return -ENOMEM; in hl_fw_unmask_irq_arr()
587 pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0])); in hl_fw_unmask_irq_arr()
588 memcpy(&pkt->irqs, irq_arr, irq_arr_size); in hl_fw_unmask_irq_arr()
590 pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY << 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()
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()
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()
644 gen_pool_free(hdev->cpu_accessible_dma_pool, (u64) (uintptr_t) vaddr, in hl_fw_cpu_accessible_dma_pool_free()
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()
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()
687 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt, sizeof(hb_pkt), 0, &result); in hl_fw_send_heartbeat()
690 return -EIO; in hl_fw_send_heartbeat()
694 dev_warn(hdev->dev, "FW reported EQ fault during heartbeat\n"); in hl_fw_send_heartbeat()
695 rc = -EIO; in hl_fw_send_heartbeat()
698 hdev->heartbeat_debug_info.last_pq_heartbeat_ts = ktime_get_real_seconds(); in hl_fw_send_heartbeat()
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()
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()
815 "Device boot error - unknown ERR1 error 0x%08x\n", in fw_report_boot_dev1()
822 upper_32_bits(hdev->boot_error_status_mask))) in fw_report_boot_dev1()
841 * that is not an error per-se, but it is an error in production in fw_read_errors()
853 return -EIO; in fw_read_errors()
863 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_cpucp_info_get()
874 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
875 "Failed to allocate DMA memory for CPU-CP info packet\n"); in hl_fw_cpucp_info_get()
876 return -ENOMEM; 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()
890 "Failed to handle CPU-CP info pkt, error %d\n", rc); in hl_fw_cpucp_info_get()
897 dev_err(hdev->dev, "Errors in device boot\n"); in hl_fw_cpucp_info_get()
901 memcpy(&prop->cpucp_info, cpucp_info_cpu_addr, in hl_fw_cpucp_info_get()
902 sizeof(prop->cpucp_info)); 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()
908 rc = -EFAULT; in hl_fw_cpucp_info_get()
912 kernel_ver = extract_fw_ver_from_str(prop->cpucp_info.kernel_version); 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()
922 if (prop->fw_cpu_boot_dev_sts0_valid) { in hl_fw_cpucp_info_get()
923 prop->fw_app_cpu_boot_dev_sts0 = RREG32(sts_boot_dev_sts0_reg); in hl_fw_cpucp_info_get()
924 if (prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_cpucp_info_get()
926 hdev->event_queue.check_eqe_index = true; in hl_fw_cpucp_info_get()
929 if (prop->fw_cpu_boot_dev_sts1_valid) in hl_fw_cpucp_info_get()
930 prop->fw_app_cpu_boot_dev_sts1 = RREG32(sts_boot_dev_sts1_reg); in hl_fw_cpucp_info_get()
946 if (!hdev->asic_funcs->get_msi_info) in hl_fw_send_msi_info_msg()
952 /* data should be aligned to 8 bytes in order to CPU-CP to copy it */ 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()
958 return -EINVAL; in hl_fw_send_msi_info_msg()
963 return -ENOMEM; in hl_fw_send_msi_info_msg()
965 pkt->length = cpu_to_le32(CPUCP_NUM_OF_MSI_TYPES); in hl_fw_send_msi_info_msg()
967 memset((void *) &pkt->data, 0xFF, data_size); in hl_fw_send_msi_info_msg()
968 hdev->asic_funcs->get_msi_info(pkt->data); in hl_fw_send_msi_info_msg()
970 pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_MSI_INFO_SET << 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()
978 * this feature and will use default/hard coded MSI values. no reason 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()
1019 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1020 "Failed to allocate DMA memory for CPU-CP EEPROM packet\n"); in hl_fw_get_eeprom_data()
1021 return -ENOMEM; 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()
1034 if (rc != -EAGAIN) in hl_fw_get_eeprom_data()
1035 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
1036 "Failed to handle CPU-CP EEPROM packet, error %d\n", rc); in hl_fw_get_eeprom_data()
1063 dev_err(hdev->dev, in hl_fw_get_monitor_dump()
1064 "Failed to allocate DMA memory for CPU-CP monitor-dump packet\n"); in hl_fw_get_monitor_dump()
1065 return -ENOMEM; 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()
1077 if (rc != -EAGAIN) in hl_fw_get_monitor_dump()
1078 dev_err(hdev->dev, in hl_fw_get_monitor_dump()
1079 "Failed to handle CPU-CP monitor-dump packet, error %d\n", rc); in hl_fw_get_monitor_dump()
1110 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
1113 if (rc != -EAGAIN) in hl_fw_cpucp_pci_counters_get()
1114 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1115 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
1118 counters->rx_throughput = result; 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()
1129 if (rc != -EAGAIN) in hl_fw_cpucp_pci_counters_get()
1130 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1131 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
1134 counters->tx_throughput = result; 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()
1144 if (rc != -EAGAIN) in hl_fw_cpucp_pci_counters_get()
1145 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
1146 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
1149 counters->replay_cnt = (u32) result; in hl_fw_cpucp_pci_counters_get()
1163 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_total_energy_get()
1166 if (rc != -EAGAIN) in hl_fw_cpucp_total_energy_get()
1167 dev_err(hdev->dev, in hl_fw_cpucp_total_energy_get()
1180 struct asic_fixed_properties *prop = &hdev->asic_prop; in get_used_pll_index()
1185 dynamic_pll = !!(prop->fw_app_cpu_boot_dev_sts0 & 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()
1205 return -EINVAL; in get_used_pll_index()
1209 pll_byte = prop->cpucp_info.pll_map[fw_pll_idx >> 3]; in get_used_pll_index()
1213 dev_err(hdev->dev, "PLL index %d is not supported\n", in get_used_pll_index()
1215 return -EINVAL; in get_used_pll_index()
1241 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pll_info_get()
1244 if (rc != -EAGAIN) 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()
1269 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_power_get()
1272 if (rc != -EAGAIN) 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()
1295 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1296 "Failed to allocate DMA memory for CPU-CP replaced rows info packet\n"); in hl_fw_dram_replaced_row_get()
1297 return -ENOMEM; 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()
1310 if (rc != -EAGAIN) in hl_fw_dram_replaced_row_get()
1311 dev_err(hdev->dev, in hl_fw_dram_replaced_row_get()
1312 "Failed to handle CPU-CP replaced rows info pkt, error %d\n", rc); in hl_fw_dram_replaced_row_get()
1335 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_dram_pending_row_get()
1337 if (rc != -EAGAIN) in hl_fw_dram_pending_row_get()
1338 dev_err(hdev->dev, in hl_fw_dram_pending_row_get()
1339 "Failed to handle CPU-CP pending rows info pkt, error %d\n", rc); in hl_fw_dram_pending_row_get()
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()
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()
1381 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_RST_DEV); in hl_fw_ask_hard_reset_without_linux()
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()
1398 pre_fw_load = &fw_loader->pre_fw_load; in hl_fw_ask_halt_machine_without_linux()
1399 cpu_timeout = fw_loader->cpu_timeout; in hl_fw_ask_halt_machine_without_linux()
1400 cpu_boot_status_reg = pre_fw_load->cpu_boot_status_reg; 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()
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()
1420 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_GOTO_WFE); in hl_fw_ask_halt_machine_without_linux()
1421 msleep(static_loader->cpu_reset_wait_msec); in hl_fw_ask_halt_machine_without_linux()
1426 WREG32(static_loader->kmd_msg_to_cpu_reg, KMD_MSG_NA); in hl_fw_ask_halt_machine_without_linux()
1429 hdev->device_cpu_is_halted = true; in hl_fw_ask_halt_machine_without_linux()
1439 dev_err(hdev->dev, in detect_cpu_boot_status()
1440 "Device boot progress - BTL/ROM did NOT run\n"); in detect_cpu_boot_status()
1443 dev_err(hdev->dev, in detect_cpu_boot_status()
1444 "Device boot progress - Stuck inside WFE loop\n"); in detect_cpu_boot_status()
1447 dev_err(hdev->dev, in detect_cpu_boot_status()
1448 "Device boot progress - Stuck in BTL\n"); in detect_cpu_boot_status()
1451 dev_err(hdev->dev, in detect_cpu_boot_status()
1452 "Device boot progress - Stuck in Preboot\n"); in detect_cpu_boot_status()
1455 dev_err(hdev->dev, in detect_cpu_boot_status()
1456 "Device boot progress - Stuck in SPL\n"); in detect_cpu_boot_status()
1459 dev_err(hdev->dev, in detect_cpu_boot_status()
1460 "Device boot progress - Stuck in u-boot\n"); in detect_cpu_boot_status()
1463 dev_err(hdev->dev, in detect_cpu_boot_status()
1464 "Device boot progress - DRAM initialization failed\n"); in detect_cpu_boot_status()
1467 dev_err(hdev->dev, in detect_cpu_boot_status()
1468 "Device boot progress - Cannot boot\n"); in detect_cpu_boot_status()
1471 dev_err(hdev->dev, in detect_cpu_boot_status()
1472 "Device boot progress - Thermal Sensor initialization failed\n"); in detect_cpu_boot_status()
1475 dev_err(hdev->dev, in detect_cpu_boot_status()
1476 "Device boot progress - Stuck in preboot after security initialization\n"); in detect_cpu_boot_status()
1479 dev_err(hdev->dev, in detect_cpu_boot_status()
1480 "Device boot progress - Stuck in preparation for shutdown\n"); in detect_cpu_boot_status()
1483 dev_err(hdev->dev, in detect_cpu_boot_status()
1484 "Device boot progress - Invalid or unexpected status code %d\n", status); in detect_cpu_boot_status()
1491 struct pre_fw_load_props *pre_fw_load = &hdev->fw_loader.pre_fw_load; in hl_fw_wait_preboot_ready()
1498 * CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT - for newer firmwares where in hl_fw_wait_preboot_ready()
1501 * All other status values - for older firmwares where the uboot was in hl_fw_wait_preboot_ready()
1504 timeout = pre_fw_load->wait_for_preboot_timeout; in hl_fw_wait_preboot_ready()
1508 pre_fw_load->cpu_boot_status_reg, in hl_fw_wait_preboot_ready()
1513 hdev->fw_poll_interval_usec, in hl_fw_wait_preboot_ready()
1516 * if F/W reports "security-ready" it means preboot might take longer. in hl_fw_wait_preboot_ready()
1526 tries--; in hl_fw_wait_preboot_ready()
1527 if (pre_fw_load->wait_for_preboot_extended_timeout) { in hl_fw_wait_preboot_ready()
1528 timeout = pre_fw_load->wait_for_preboot_extended_timeout; in hl_fw_wait_preboot_ready()
1536 if (status != -1) 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()
1538 pre_fw_load->boot_err1_reg, in hl_fw_wait_preboot_ready()
1539 pre_fw_load->sts_boot_dev_sts0_reg, in hl_fw_wait_preboot_ready()
1540 pre_fw_load->sts_boot_dev_sts1_reg); in hl_fw_wait_preboot_ready()
1543 dev_err(hdev->dev, "CPU boot %s (status = %d)\n", in hl_fw_wait_preboot_ready()
1545 return -EIO; in hl_fw_wait_preboot_ready()
1548 hdev->fw_loader.fw_comp_loaded |= FW_TYPE_PREBOOT_CPU; in hl_fw_wait_preboot_ready()
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()
1574 * In case it is not enabled the stored value will be left 0- all in hl_fw_read_preboot_caps()
1577 reg_val = RREG32(pre_fw_load->sts_boot_dev_sts0_reg); in hl_fw_read_preboot_caps()
1579 prop->fw_cpu_boot_dev_sts0_valid = true; in hl_fw_read_preboot_caps()
1580 prop->fw_preboot_cpu_boot_dev_sts0 = reg_val; in hl_fw_read_preboot_caps()
1583 reg_val = RREG32(pre_fw_load->sts_boot_dev_sts1_reg); in hl_fw_read_preboot_caps()
1585 prop->fw_cpu_boot_dev_sts1_valid = true; in hl_fw_read_preboot_caps()
1586 prop->fw_preboot_cpu_boot_dev_sts1 = reg_val; in hl_fw_read_preboot_caps()
1589 prop->dynamic_fw_load = !!(prop->fw_preboot_cpu_boot_dev_sts0 & 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()
1596 prop->dynamic_fw_load ? "dynamic" : "legacy"); in hl_fw_read_preboot_caps()
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()
1615 ver_off = RREG32(static_loader->boot_fit_version_offset_reg); in hl_fw_static_read_device_fw_version()
1616 dest = prop->uboot_ver; in hl_fw_static_read_device_fw_version()
1617 name = "Boot-fit"; in hl_fw_static_read_device_fw_version()
1618 limit = static_loader->boot_fit_version_max_off; in hl_fw_static_read_device_fw_version()
1621 ver_off = RREG32(static_loader->preboot_version_offset_reg); in hl_fw_static_read_device_fw_version()
1622 dest = prop->preboot_ver; in hl_fw_static_read_device_fw_version()
1624 limit = static_loader->preboot_version_max_off; 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()
1628 return -EIO; in hl_fw_static_read_device_fw_version()
1631 ver_off &= static_loader->sram_offset_mask; 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()
1641 return -EIO; in hl_fw_static_read_device_fw_version()
1645 boot_ver = extract_fw_ver_from_str(prop->uboot_ver); 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()
1651 preboot_ver = strnstr(prop->preboot_ver, "Preboot", in hl_fw_static_read_device_fw_version()
1653 if (preboot_ver && preboot_ver != prop->preboot_ver) { in hl_fw_static_read_device_fw_version()
1654 strscpy(btl_ver, prop->preboot_ver, in hl_fw_static_read_device_fw_version()
1655 min((int) (preboot_ver - prop->preboot_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()
1660 preboot_ver = extract_fw_ver_from_str(prop->preboot_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()
1672 * hl_fw_preboot_update_state - update internal data structures during
1678 * @return 0 on success, otherwise non-zero error code
1682 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_preboot_update_state()
1685 cpu_boot_dev_sts0 = prop->fw_preboot_cpu_boot_dev_sts0; in hl_fw_preboot_update_state()
1686 cpu_boot_dev_sts1 = prop->fw_preboot_cpu_boot_dev_sts1; in hl_fw_preboot_update_state()
1689 * 1. preboot - a. Check whether the security status bits are valid in hl_fw_preboot_update_state()
1692 * 2. boot cpu - a. Fetch boot cpu security status in hl_fw_preboot_update_state()
1694 * 3. FW application - a. Fetch fw application security status in hl_fw_preboot_update_state()
1697 prop->hard_reset_done_by_fw = !!(cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_FW_HARD_RST_EN); in hl_fw_preboot_update_state()
1699 prop->fw_security_enabled = !!(cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_SECURITY_EN); 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()
1708 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1710 dev_dbg(hdev->dev, "firmware-level security is %s\n", in hl_fw_preboot_update_state()
1711 prop->fw_security_enabled ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1713 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_preboot_update_state()
1714 prop->gic_interrupts_enable ? "enabled" : "disabled"); in hl_fw_preboot_update_state()
1732 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU)) in hl_fw_read_preboot_status()
1735 /* get FW pre-load parameters */ in hl_fw_read_preboot_status()
1736 hdev->asic_funcs->init_firmware_preload_params(hdev); in hl_fw_read_preboot_status()
1749 if (hdev->asic_prop.dynamic_fw_load) in hl_fw_read_preboot_status()
1766 * hl_fw_dynamic_report_error_status - report error status
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()
1790 * hl_fw_dynamic_send_cmd - send LKD to FW cmd
1810 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_send_cmd()
1815 trace_habanalabs_comms_send_cmd(&hdev->pdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_cmd()
1816 WREG32(le32_to_cpu(dyn_regs->kmd_msg_to_cpu), val); in hl_fw_dynamic_send_cmd()
1820 * hl_fw_dynamic_extract_fw_response - update the FW response
1827 * @return 0 on success, otherwise non-zero error code
1834 response->status = FIELD_GET(COMMS_STATUS_STATUS_MASK, status); in hl_fw_dynamic_extract_fw_response()
1835 response->ram_offset = FIELD_GET(COMMS_STATUS_OFFSET_MASK, status) << in hl_fw_dynamic_extract_fw_response()
1837 response->ram_type = FIELD_GET(COMMS_STATUS_RAM_TYPE_MASK, status); in hl_fw_dynamic_extract_fw_response()
1839 if ((response->ram_type != COMMS_SRAM) && in hl_fw_dynamic_extract_fw_response()
1840 (response->ram_type != COMMS_DRAM)) { in hl_fw_dynamic_extract_fw_response()
1841 dev_err(hdev->dev, "FW status: invalid RAM type %u\n", in hl_fw_dynamic_extract_fw_response()
1842 response->ram_type); in hl_fw_dynamic_extract_fw_response()
1843 return -EIO; in hl_fw_dynamic_extract_fw_response()
1850 * hl_fw_dynamic_wait_for_status - wait for status in dynamic FW load
1857 * @return 0 on success, otherwise non-zero error code
1871 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_wait_for_status()
1873 trace_habanalabs_comms_wait_status(&hdev->pdev->dev, comms_sts_str_arr[expected_status]); in hl_fw_dynamic_wait_for_status()
1878 le32_to_cpu(dyn_regs->cpu_cmd_status_to_host), in hl_fw_dynamic_wait_for_status()
1881 hdev->fw_comms_poll_interval_usec, in hl_fw_dynamic_wait_for_status()
1887 return -EIO; in hl_fw_dynamic_wait_for_status()
1890 trace_habanalabs_comms_wait_status_done(&hdev->pdev->dev, in hl_fw_dynamic_wait_for_status()
1901 &fw_loader->dynamic_loader.response, in hl_fw_dynamic_wait_for_status()
1907 * hl_fw_dynamic_send_clear_cmd - send clear command to FW
1912 * @return 0 on success, otherwise non-zero error code
1926 fw_loader->cpu_timeout); in hl_fw_dynamic_send_clear_cmd()
1930 * hl_fw_dynamic_send_protocol_cmd - send LKD to FW cmd and wait for ACK
1939 * @return 0 on success, otherwise non-zero error code
1943 * - send clear (clear command and verify clear status register)
1944 * - send the actual protocol command
1945 * - wait for ACK on the protocol command
1946 * - send clear
1947 * - send NOOP
1949 * - wait for OK
1950 * - send clear
1951 * - send NOOP
1965 trace_habanalabs_comms_protocol_cmd(&hdev->pdev->dev, comms_cmd_str_arr[cmd]); in hl_fw_dynamic_send_protocol_cmd()
2009 * hl_fw_compat_crc32 - CRC compatible with FW
2027 * hl_fw_dynamic_validate_memory_bound - validate memory bounds for memory
2036 * @return 0 on success, otherwise non-zero error code
2046 if (end_addr >= region->region_base + region->region_size) { in hl_fw_dynamic_validate_memory_bound()
2047 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2050 return -EIO; in hl_fw_dynamic_validate_memory_bound()
2058 if (end_addr >= region->region_base - region->offset_in_bar + in hl_fw_dynamic_validate_memory_bound()
2059 region->bar_size) { in hl_fw_dynamic_validate_memory_bound()
2060 dev_err(hdev->dev, in hl_fw_dynamic_validate_memory_bound()
2062 return -EIO; in hl_fw_dynamic_validate_memory_bound()
2069 * hl_fw_dynamic_validate_descriptor - validate FW descriptor
2075 * @return 0 on success, otherwise non-zero error code
2089 if (le32_to_cpu(fw_desc->header.magic) != HL_COMMS_DESC_MAGIC) in hl_fw_dynamic_validate_descriptor()
2090 dev_dbg(hdev->dev, "Invalid magic for dynamic FW descriptor (%x)\n", in hl_fw_dynamic_validate_descriptor()
2091 fw_desc->header.magic); in hl_fw_dynamic_validate_descriptor()
2093 if (fw_desc->header.version != HL_COMMS_DESC_VER) 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()
2095 fw_desc->header.version); in hl_fw_dynamic_validate_descriptor()
2105 data_size = le16_to_cpu(fw_desc->header.size); in hl_fw_dynamic_validate_descriptor()
2108 if (data_crc32 != le32_to_cpu(fw_desc->header.crc32)) { 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()
2110 data_crc32, fw_desc->header.crc32); in hl_fw_dynamic_validate_descriptor()
2111 return -EIO; in hl_fw_dynamic_validate_descriptor()
2115 addr = le64_to_cpu(fw_desc->img_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()
2119 return -EIO; in hl_fw_dynamic_validate_descriptor()
2122 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_validate_descriptor()
2125 fw_loader->dynamic_loader.image_region = region; in hl_fw_dynamic_validate_descriptor()
2132 fw_loader->dynamic_loader.fw_image_size, 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()
2140 fw_loader->dynamic_loader.fw_desc_valid = true; in hl_fw_dynamic_validate_descriptor()
2152 device_addr = region->region_base + response->ram_offset; in hl_fw_dynamic_validate_response()
2157 * type- testing only the end address is enough in hl_fw_dynamic_validate_response()
2166 * hl_fw_dynamic_read_descriptor_msg - read and show the ascii msg that sent by fw
2178 if (!fw_desc->ascii_msg[i].valid) in hl_fw_dynamic_read_descriptor_msg()
2182 msg = fw_desc->ascii_msg[i].msg; in hl_fw_dynamic_read_descriptor_msg()
2183 msg[LKD_FW_ASCII_MSG_MAX_LEN - 1] = '\0'; in hl_fw_dynamic_read_descriptor_msg()
2185 switch (fw_desc->ascii_msg[i].msg_lvl) { in hl_fw_dynamic_read_descriptor_msg()
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()
2203 * hl_fw_dynamic_read_and_validate_descriptor - read and validate FW descriptor
2208 * @return 0 on success, otherwise non-zero error code
2222 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_read_and_validate_descriptor()
2223 response = &fw_loader->dynamic_loader.response; in hl_fw_dynamic_read_and_validate_descriptor()
2225 region_id = (response->ram_type == COMMS_SRAM) ? in hl_fw_dynamic_read_and_validate_descriptor()
2228 region = &hdev->pci_mem_region[region_id]; in hl_fw_dynamic_read_and_validate_descriptor()
2232 dev_err(hdev->dev, in hl_fw_dynamic_read_and_validate_descriptor()
2239 * in addition, as the descriptor value is going to be over-ridden by new data- we mark it in hl_fw_dynamic_read_and_validate_descriptor()
2243 fw_loader->dynamic_loader.fw_desc_valid = false; 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()
2245 response->ram_offset; in hl_fw_dynamic_read_and_validate_descriptor()
2256 fw_data_size = le16_to_cpu(fw_desc->header.size); in hl_fw_dynamic_read_and_validate_descriptor()
2260 return -ENOMEM; in hl_fw_dynamic_read_and_validate_descriptor()
2276 * hl_fw_dynamic_request_descriptor - handshake with CPU to get FW descriptor
2282 * @return 0 on success, otherwise non-zero error code
2292 fw_loader->cpu_timeout); in hl_fw_dynamic_request_descriptor()
2300 * hl_fw_dynamic_read_device_fw_version - read FW version to exposed properties
2310 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_dynamic_read_device_fw_version()
2317 strscpy(prop->uboot_ver, fw_version, VERSION_MAX_LEN); in hl_fw_dynamic_read_device_fw_version()
2318 boot_ver = extract_fw_ver_from_str(prop->uboot_ver); 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()
2326 strscpy(prop->preboot_ver, fw_version, VERSION_MAX_LEN); in hl_fw_dynamic_read_device_fw_version()
2327 preboot_ver = strnstr(prop->preboot_ver, "Preboot", VERSION_MAX_LEN); 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()
2330 if (preboot_ver && preboot_ver != prop->preboot_ver) { in hl_fw_dynamic_read_device_fw_version()
2331 strscpy(btl_ver, prop->preboot_ver, in hl_fw_dynamic_read_device_fw_version()
2332 min((int) (preboot_ver - prop->preboot_ver), 31)); 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()
2339 preboot_ver = extract_fw_ver_from_str(prop->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()
2350 return -EINVAL; in hl_fw_dynamic_read_device_fw_version()
2357 * hl_fw_dynamic_copy_image - copy image to memory allocated by the FW
2373 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_copy_image()
2374 addr = le64_to_cpu(fw_desc->img_addr); in hl_fw_dynamic_copy_image()
2377 region = fw_loader->dynamic_loader.image_region; in hl_fw_dynamic_copy_image()
2379 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_image()
2380 (addr - region->region_base); in hl_fw_dynamic_copy_image()
2383 fw_loader->boot_fit_img.src_off, in hl_fw_dynamic_copy_image()
2384 fw_loader->boot_fit_img.copy_size); in hl_fw_dynamic_copy_image()
2390 * hl_fw_dynamic_copy_msg - copy msg to memory allocated by the FW
2405 fw_desc = &fw_loader->dynamic_loader.comm_desc; in hl_fw_dynamic_copy_msg()
2406 addr = le64_to_cpu(fw_desc->img_addr); in hl_fw_dynamic_copy_msg()
2409 region = fw_loader->dynamic_loader.image_region; in hl_fw_dynamic_copy_msg()
2411 dest = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + in hl_fw_dynamic_copy_msg()
2412 (addr - region->region_base); in hl_fw_dynamic_copy_msg()
2420 * hl_fw_boot_fit_update_state - update internal data structures after boot-fit
2427 * @return 0 on success, otherwise non-zero error code
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()
2438 if (prop->fw_preboot_cpu_boot_dev_sts0 & CPU_BOOT_DEV_STS0_ENABLED) { in hl_fw_boot_fit_update_state()
2439 prop->fw_bootfit_cpu_boot_dev_sts0 = in hl_fw_boot_fit_update_state()
2442 prop->hard_reset_done_by_fw = !!(prop->fw_bootfit_cpu_boot_dev_sts0 & 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()
2446 prop->fw_bootfit_cpu_boot_dev_sts0); in hl_fw_boot_fit_update_state()
2449 if (prop->fw_cpu_boot_dev_sts1_valid) { in hl_fw_boot_fit_update_state()
2450 prop->fw_bootfit_cpu_boot_dev_sts1 = 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()
2454 prop->fw_bootfit_cpu_boot_dev_sts1); 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()
2458 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_boot_fit_update_state()
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()
2472 dyn_regs->gic_host_halt_irq = dyn_regs->gic_host_pi_upd_irq; in hl_fw_dynamic_update_linux_interrupt_if()
2473 dyn_regs->gic_host_ints_irq = dyn_regs->gic_host_pi_upd_irq; in hl_fw_dynamic_update_linux_interrupt_if()
2475 dev_warn(hdev->dev, in hl_fw_dynamic_update_linux_interrupt_if()
2480 * hl_fw_dynamic_load_image - load FW image using dynamic protocol
2487 * @return 0 on success, otherwise non-zero error code
2501 * 1. current FW component is preboot and we want to load boot-fit in hl_fw_dynamic_load_image()
2502 * 2. current FW component is boot-fit and we want to load linux in hl_fw_dynamic_load_image()
2506 fw_name = fw_loader->boot_fit_img.image_name; in hl_fw_dynamic_load_image()
2509 fw_name = fw_loader->linux_img.image_name; in hl_fw_dynamic_load_image()
2518 fw_loader->dynamic_loader.fw_image_size = fw->size; in hl_fw_dynamic_load_image()
2520 rc = hl_fw_dynamic_request_descriptor(hdev, fw_loader, fw->size); in hl_fw_dynamic_load_image()
2526 fw_loader->dynamic_loader.comm_desc.cur_fw_ver); in hl_fw_dynamic_load_image()
2537 fw_loader->cpu_timeout); in hl_fw_dynamic_load_image()
2557 dyn_loader = &fw_loader->dynamic_loader; in hl_fw_dynamic_wait_for_boot_fit_active()
2560 * Make sure CPU boot-loader is running in hl_fw_dynamic_wait_for_boot_fit_active()
2569 le32_to_cpu(dyn_loader->comm_desc.cpu_dyn_regs.cpu_boot_status), in hl_fw_dynamic_wait_for_boot_fit_active()
2573 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_boot_fit_active()
2574 dyn_loader->wait_for_bl_timeout); 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()
2591 dyn_loader = &fw_loader->dynamic_loader; in hl_fw_dynamic_wait_for_linux_active()
2597 le32_to_cpu(dyn_loader->comm_desc.cpu_dyn_regs.cpu_boot_status), in hl_fw_dynamic_wait_for_linux_active()
2600 hdev->fw_poll_interval_usec, in hl_fw_dynamic_wait_for_linux_active()
2601 fw_loader->cpu_timeout); 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()
2612 * hl_fw_linux_update_state - update internal data structures after Linux
2615 * of two stages - loading kernel (SRAM_AVAIL)
2624 * @return 0 on success, otherwise non-zero error code
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()
2635 if (prop->fw_cpu_boot_dev_sts0_valid) { in hl_fw_linux_update_state()
2636 prop->fw_app_cpu_boot_dev_sts0 = RREG32(cpu_boot_dev_sts0_reg); in hl_fw_linux_update_state()
2638 prop->hard_reset_done_by_fw = !!(prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_linux_update_state()
2641 if (prop->fw_app_cpu_boot_dev_sts0 & in hl_fw_linux_update_state()
2643 prop->gic_interrupts_enable = false; in hl_fw_linux_update_state()
2645 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2647 prop->fw_app_cpu_boot_dev_sts0); in hl_fw_linux_update_state()
2649 dev_dbg(hdev->dev, "GIC controller is %s\n", in hl_fw_linux_update_state()
2650 prop->gic_interrupts_enable ? in hl_fw_linux_update_state()
2654 if (prop->fw_cpu_boot_dev_sts1_valid) { in hl_fw_linux_update_state()
2655 prop->fw_app_cpu_boot_dev_sts1 = RREG32(cpu_boot_dev_sts1_reg); in hl_fw_linux_update_state()
2657 dev_dbg(hdev->dev, in hl_fw_linux_update_state()
2659 prop->fw_app_cpu_boot_dev_sts1); 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()
2663 prop->hard_reset_done_by_fw ? "enabled" : "disabled"); in hl_fw_linux_update_state()
2665 dev_info(hdev->dev, "Successfully loaded firmware to device\n"); in hl_fw_linux_update_state()
2669 * hl_fw_dynamic_send_msg - send a COMMS message with attached data
2676 * @return 0 on success, otherwise non-zero error code
2686 return -ENOMEM; in hl_fw_dynamic_send_msg()
2689 msg->header.type = msg_type; in hl_fw_dynamic_send_msg()
2690 msg->header.size = cpu_to_le16(sizeof(struct comms_msg_header)); in hl_fw_dynamic_send_msg()
2691 msg->header.magic = cpu_to_le32(HL_COMMS_MSG_MAGIC); in hl_fw_dynamic_send_msg()
2695 msg->reset_cause = *(__u8 *) data; in hl_fw_dynamic_send_msg()
2699 dev_err(hdev->dev, in hl_fw_dynamic_send_msg()
2700 "Send COMMS message - invalid message type %u\n", in hl_fw_dynamic_send_msg()
2702 rc = -EINVAL; in hl_fw_dynamic_send_msg()
2718 fw_loader->cpu_timeout); in hl_fw_dynamic_send_msg()
2724 fw_loader->cpu_timeout); in hl_fw_dynamic_send_msg()
2732 * hl_fw_dynamic_init_cpu - initialize the device CPU using dynamic protocol
2737 * @return 0 on success, otherwise non-zero error code
2741 * - LKD command register
2742 * - FW status register
2746 * in case of timeout expiration without the desired status from FW- the
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()
2760 fw_loader->dynamic_loader.fw_desc_valid = false; in hl_fw_dynamic_init_cpu()
2763 * In this stage, "cpu_dyn_regs" contains only LKD's hard coded values! in hl_fw_dynamic_init_cpu()
2766 dyn_regs = &fw_loader->dynamic_loader.comm_desc.cpu_dyn_regs; in hl_fw_dynamic_init_cpu()
2770 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2774 if (hdev->reset_info.curr_reset_cause) { 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()
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()
2790 le32_to_cpu(fw_loader->dynamic_loader.comm_desc.rsvd_mem_size_mb) * SZ_1M; in hl_fw_dynamic_init_cpu()
2792 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) { in hl_fw_dynamic_init_cpu()
2797 fw_loader->dynamic_loader.comm_desc.cur_fw_ver); in hl_fw_dynamic_init_cpu()
2802 if (hdev->support_preboot_binning) { in hl_fw_dynamic_init_cpu()
2803 binning_info = &fw_loader->dynamic_loader.comm_desc.binning_info; 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()
2829 fw_loader->boot_fit_timeout); in hl_fw_dynamic_init_cpu()
2831 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2840 le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_init_cpu()
2841 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); 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()
2862 if (fw_loader->skip_bmc) { in hl_fw_dynamic_init_cpu()
2866 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2868 dev_err(hdev->dev, "failed to load boot fit\n"); in hl_fw_dynamic_init_cpu()
2875 fw_loader->cpu_timeout); in hl_fw_dynamic_init_cpu()
2877 dev_err(hdev->dev, "failed to load Linux\n"); in hl_fw_dynamic_init_cpu()
2886 le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_init_cpu()
2887 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); in hl_fw_dynamic_init_cpu()
2892 if (fw_loader->dynamic_loader.fw_desc_valid) { 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()
2894 le32_to_cpu(dyn_regs->cpu_boot_err1), in hl_fw_dynamic_init_cpu()
2895 le32_to_cpu(dyn_regs->cpu_boot_dev_sts0), in hl_fw_dynamic_init_cpu()
2896 le32_to_cpu(dyn_regs->cpu_boot_dev_sts1)); in hl_fw_dynamic_init_cpu()
2906 * hl_fw_static_init_cpu - initialize the device CPU using static protocol
2911 * @return 0 on success, otherwise non-zero error code
2922 if (!(hdev->fw_components & FW_TYPE_BOOT_CPU)) in hl_fw_static_init_cpu()
2926 cpu_timeout = fw_loader->cpu_timeout; in hl_fw_static_init_cpu()
2929 static_loader = &fw_loader->static_loader; in hl_fw_static_init_cpu()
2930 cpu_msg_status_reg = static_loader->cpu_cmd_status_to_host_reg; in hl_fw_static_init_cpu()
2931 msg_to_cpu_reg = static_loader->kmd_msg_to_cpu_reg; in hl_fw_static_init_cpu()
2932 cpu_boot_dev_status0_reg = static_loader->cpu_boot_dev_status0_reg; in hl_fw_static_init_cpu()
2933 cpu_boot_dev_status1_reg = static_loader->cpu_boot_dev_status1_reg; in hl_fw_static_init_cpu()
2934 cpu_boot_status_reg = static_loader->cpu_boot_status_reg; 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()
2945 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2946 fw_loader->boot_fit_timeout); 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()
2968 hdev->fw_poll_interval_usec, in hl_fw_static_init_cpu()
2969 fw_loader->boot_fit_timeout); in hl_fw_static_init_cpu()
2972 dev_err(hdev->dev, in hl_fw_static_init_cpu()
2982 * Make sure CPU boot-loader is running 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()
3002 /* Read U-Boot version now in case we will later fail */ in hl_fw_static_init_cpu()
3011 rc = -EIO; 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()
3038 if (fw_loader->skip_bmc) { 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()
3054 rc = -EIO; 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()
3081 rc = -EIO; 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()
3086 fw_loader->static_loader.boot_err1_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()
3099 fw_loader->static_loader.boot_err1_reg, in hl_fw_static_init_cpu()
3107 * hl_fw_init_cpu - initialize the device CPU
3111 * @return 0 on success, otherwise non-zero error code
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()
3121 return prop->dynamic_fw_load ? in hl_fw_init_cpu()
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()
3137 return -ENODEV; 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()
3187 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_frequency()
3189 if (rc != -EAGAIN) 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()
3214 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_fw_set_frequency()
3215 if (rc && rc != -EAGAIN) 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()
3230 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result); in hl_fw_get_max_power()
3232 if (rc != -EAGAIN) 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()
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()
3255 if (rc && rc != -EAGAIN) 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()
3269 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3270 "Failed to allocate DMA memory for CPU-CP packet %u\n", packet_id); in hl_fw_get_sec_attest_data()
3271 return -ENOMEM; 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()
3283 if (rc != -EAGAIN) in hl_fw_get_sec_attest_data()
3284 dev_err(hdev->dev, in hl_fw_get_sec_attest_data()
3285 "Failed to handle CPU-CP pkt %u, error %d\n", packet_id, rc); in hl_fw_get_sec_attest_data()
3325 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *)&pkt, sizeof(pkt), in hl_fw_send_generic_request()
3328 if (rc != -EAGAIN) 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()