Lines Matching +full:u +full:- +full:boot +full:- +full:spl
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2019 HabanaLabs, Ltd.
13 #include <linux/io-64-nonatomic-lo-hi.h>
18 * hl_fw_load_fw_to_device() - Load F/W code to device's memory.
26 * Return: 0 on success, non-zero for failure.
36 rc = request_firmware(&fw, fw_name, hdev->dev); in hl_fw_load_fw_to_device()
38 dev_err(hdev->dev, "Firmware file %s is not found!\n", fw_name); in hl_fw_load_fw_to_device()
42 fw_size = fw->size; in hl_fw_load_fw_to_device()
44 dev_err(hdev->dev, "Illegal %s firmware size %zu\n", in hl_fw_load_fw_to_device()
46 rc = -EINVAL; in hl_fw_load_fw_to_device()
50 dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size); in hl_fw_load_fw_to_device()
53 dev_err(hdev->dev, in hl_fw_load_fw_to_device()
54 "FW file size %zu exceeds maximum of %u bytes\n", in hl_fw_load_fw_to_device()
56 rc = -EINVAL; in hl_fw_load_fw_to_device()
60 fw_data = (const u64 *) fw->data; in hl_fw_load_fw_to_device()
75 return hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, in hl_fw_send_pci_access_msg()
87 pkt = hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, len, in hl_fw_send_cpu_message()
90 dev_err(hdev->dev, in hl_fw_send_cpu_message()
92 return -ENOMEM; in hl_fw_send_cpu_message()
97 mutex_lock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
99 if (hdev->disabled) in hl_fw_send_cpu_message()
102 if (hdev->device_cpu_disabled) { in hl_fw_send_cpu_message()
103 rc = -EIO; in hl_fw_send_cpu_message()
109 dev_err(hdev->dev, "Failed to send CB on CPU PQ (%d)\n", rc); in hl_fw_send_cpu_message()
113 rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp, in hl_fw_send_cpu_message()
119 if (rc == -ETIMEDOUT) { in hl_fw_send_cpu_message()
120 dev_err(hdev->dev, "Device CPU packet timeout (0x%x)\n", tmp); in hl_fw_send_cpu_message()
121 hdev->device_cpu_disabled = true; in hl_fw_send_cpu_message()
125 tmp = le32_to_cpu(pkt->ctl); in hl_fw_send_cpu_message()
129 dev_err(hdev->dev, "F/W ERROR %d for CPU packet %d\n", in hl_fw_send_cpu_message()
133 rc = -EIO; in hl_fw_send_cpu_message()
135 *result = (long) le64_to_cpu(pkt->result); in hl_fw_send_cpu_message()
139 mutex_unlock(&hdev->send_cpu_message_lock); in hl_fw_send_cpu_message()
141 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, len, pkt); in hl_fw_send_cpu_message()
158 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_unmask_irq()
162 dev_err(hdev->dev, "failed to unmask RAZWI IRQ %d", event_type); in hl_fw_unmask_irq()
178 /* data should be aligned to 8 bytes in order to CPU-CP to copy it */ in hl_fw_unmask_irq_arr()
183 dev_err(hdev->dev, "too many elements in IRQ array\n"); in hl_fw_unmask_irq_arr()
184 return -EINVAL; in hl_fw_unmask_irq_arr()
189 return -ENOMEM; in hl_fw_unmask_irq_arr()
191 pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0])); in hl_fw_unmask_irq_arr()
192 memcpy(&pkt->irqs, irq_arr, irq_arr_size); in hl_fw_unmask_irq_arr()
194 pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY << in hl_fw_unmask_irq_arr()
197 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt, in hl_fw_unmask_irq_arr()
201 dev_err(hdev->dev, "failed to unmask IRQ array\n"); in hl_fw_unmask_irq_arr()
218 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &test_pkt, in hl_fw_test_cpu_queue()
223 dev_err(hdev->dev, in hl_fw_test_cpu_queue()
226 dev_err(hdev->dev, "CPU queue test failed, error %d\n", rc); in hl_fw_test_cpu_queue()
237 kernel_addr = gen_pool_alloc(hdev->cpu_accessible_dma_pool, size); in hl_fw_cpu_accessible_dma_pool_alloc()
239 *dma_handle = hdev->cpu_accessible_dma_address + in hl_fw_cpu_accessible_dma_pool_alloc()
240 (kernel_addr - (u64) (uintptr_t) hdev->cpu_accessible_dma_mem); in hl_fw_cpu_accessible_dma_pool_alloc()
248 gen_pool_free(hdev->cpu_accessible_dma_pool, (u64) (uintptr_t) vaddr, in hl_fw_cpu_accessible_dma_pool_free()
262 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt, in hl_fw_send_heartbeat()
266 rc = -EIO; in hl_fw_send_heartbeat()
273 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_fw_cpucp_info_get()
281 hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, in hl_fw_cpucp_info_get()
285 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
286 "Failed to allocate DMA memory for CPU-CP info packet\n"); in hl_fw_cpucp_info_get()
287 return -ENOMEM; in hl_fw_cpucp_info_get()
297 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_info_get()
300 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
301 "Failed to handle CPU-CP info pkt, error %d\n", rc); in hl_fw_cpucp_info_get()
305 memcpy(&prop->cpucp_info, cpucp_info_cpu_addr, in hl_fw_cpucp_info_get()
306 sizeof(prop->cpucp_info)); in hl_fw_cpucp_info_get()
308 rc = hl_build_hwmon_channel_info(hdev, prop->cpucp_info.sensors); in hl_fw_cpucp_info_get()
310 dev_err(hdev->dev, in hl_fw_cpucp_info_get()
312 rc = -EFAULT; in hl_fw_cpucp_info_get()
317 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, in hl_fw_cpucp_info_get()
332 hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, in hl_fw_get_eeprom_data()
335 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
336 "Failed to allocate DMA memory for CPU-CP EEPROM packet\n"); in hl_fw_get_eeprom_data()
337 return -ENOMEM; in hl_fw_get_eeprom_data()
347 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_get_eeprom_data()
351 dev_err(hdev->dev, in hl_fw_get_eeprom_data()
352 "Failed to handle CPU-CP EEPROM packet, error %d\n", in hl_fw_get_eeprom_data()
361 hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev, max_size, in hl_fw_get_eeprom_data()
379 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
382 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
383 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
386 counters->rx_throughput = result; in hl_fw_cpucp_pci_counters_get()
390 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
393 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
394 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
397 counters->tx_throughput = result; in hl_fw_cpucp_pci_counters_get()
403 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_pci_counters_get()
406 dev_err(hdev->dev, in hl_fw_cpucp_pci_counters_get()
407 "Failed to handle CPU-CP PCI info pkt, error %d\n", rc); in hl_fw_cpucp_pci_counters_get()
410 counters->replay_cnt = (u32) result; in hl_fw_cpucp_pci_counters_get()
424 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_fw_cpucp_total_energy_get()
427 dev_err(hdev->dev, in hl_fw_cpucp_total_energy_get()
448 * that is not an error per-se, but it is an error in production in fw_read_errors()
456 dev_err(hdev->dev, in fw_read_errors()
457 "Device boot error - DRAM initialization failed\n"); in fw_read_errors()
459 dev_err(hdev->dev, "Device boot error - FIT image corrupted\n"); in fw_read_errors()
461 dev_err(hdev->dev, in fw_read_errors()
462 "Device boot error - Thermal Sensor initialization failed\n"); in fw_read_errors()
464 dev_warn(hdev->dev, in fw_read_errors()
465 "Device boot warning - Skipped DRAM initialization\n"); in fw_read_errors()
467 dev_warn(hdev->dev, in fw_read_errors()
468 "Device boot error - Skipped waiting for BMC\n"); in fw_read_errors()
470 dev_err(hdev->dev, in fw_read_errors()
471 "Device boot error - Serdes data from BMC not available\n"); in fw_read_errors()
473 dev_err(hdev->dev, in fw_read_errors()
474 "Device boot error - NIC F/W initialization failed\n"); in fw_read_errors()
484 dev_err(hdev->dev, in detect_cpu_boot_status()
485 "Device boot error - BTL did NOT run\n"); in detect_cpu_boot_status()
488 dev_err(hdev->dev, in detect_cpu_boot_status()
489 "Device boot error - Stuck inside WFE loop\n"); in detect_cpu_boot_status()
492 dev_err(hdev->dev, in detect_cpu_boot_status()
493 "Device boot error - Stuck in BTL\n"); in detect_cpu_boot_status()
496 dev_err(hdev->dev, in detect_cpu_boot_status()
497 "Device boot error - Stuck in Preboot\n"); in detect_cpu_boot_status()
500 dev_err(hdev->dev, in detect_cpu_boot_status()
501 "Device boot error - Stuck in SPL\n"); in detect_cpu_boot_status()
504 dev_err(hdev->dev, in detect_cpu_boot_status()
505 "Device boot error - Stuck in u-boot\n"); in detect_cpu_boot_status()
508 dev_err(hdev->dev, in detect_cpu_boot_status()
509 "Device boot error - DRAM initialization failed\n"); in detect_cpu_boot_status()
512 dev_err(hdev->dev, in detect_cpu_boot_status()
513 "Device boot error - u-boot stopped by user\n"); in detect_cpu_boot_status()
516 dev_err(hdev->dev, in detect_cpu_boot_status()
517 "Device boot error - Thermal Sensor initialization failed\n"); in detect_cpu_boot_status()
520 dev_err(hdev->dev, in detect_cpu_boot_status()
521 "Device boot error - Invalid status code %d\n", in detect_cpu_boot_status()
533 if (!hdev->cpu_enable) in hl_fw_read_preboot_ver()
538 * CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT - for newer firmwares where in hl_fw_read_preboot_ver()
539 * the preboot is waiting for the boot fit in hl_fw_read_preboot_ver()
541 * All other status values - for older firmwares where the uboot was in hl_fw_read_preboot_ver()
558 dev_err(hdev->dev, "Failed to read preboot version\n"); in hl_fw_read_preboot_ver()
561 return -EIO; in hl_fw_read_preboot_ver()
564 hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_PREBOOT); in hl_fw_read_preboot_ver()
577 dev_info(hdev->dev, "Going to wait for device boot (up to %lds)\n", in hl_fw_init_cpu()
580 /* Wait for boot FIT request */ in hl_fw_init_cpu()
590 dev_dbg(hdev->dev, in hl_fw_init_cpu()
591 "No boot fit request received, resuming boot\n"); in hl_fw_init_cpu()
593 rc = hdev->asic_funcs->load_boot_fit_to_device(hdev); in hl_fw_init_cpu()
600 /* Signal device CPU that boot loader is ready */ in hl_fw_init_cpu()
613 dev_err(hdev->dev, in hl_fw_init_cpu()
614 "Timeout waiting for boot fit load ack\n"); in hl_fw_init_cpu()
622 /* Make sure CPU boot-loader is running */ in hl_fw_init_cpu()
634 /* Read U-Boot version now in case we will later fail */ in hl_fw_init_cpu()
635 hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_UBOOT); in hl_fw_init_cpu()
639 rc = -EIO; in hl_fw_init_cpu()
643 if (!hdev->fw_loading) { in hl_fw_init_cpu()
644 dev_info(hdev->dev, "Skip loading FW\n"); in hl_fw_init_cpu()
651 dev_info(hdev->dev, in hl_fw_init_cpu()
654 rc = hdev->asic_funcs->load_firmware_to_device(hdev); in hl_fw_init_cpu()
670 dev_err(hdev->dev, in hl_fw_init_cpu()
674 rc = -EIO; in hl_fw_init_cpu()
694 dev_err(hdev->dev, in hl_fw_init_cpu()
697 dev_err(hdev->dev, in hl_fw_init_cpu()
701 rc = -EIO; in hl_fw_init_cpu()
705 dev_info(hdev->dev, "Successfully loaded firmware to device\n"); in hl_fw_init_cpu()