Lines Matching full:vdev
37 #define IVPU_FW_CHECK_API_COMPAT(vdev, fw_hdr, name, min_major) \ argument
38 ivpu_fw_check_api(vdev, fw_hdr, #name, \
44 #define IVPU_FW_CHECK_API_VER_LT(vdev, fw_hdr, name, major, minor) \ argument
45 ivpu_fw_check_api_ver_lt(vdev, fw_hdr, #name, VPU_##name##_API_VER_INDEX, major, minor)
67 static int ivpu_fw_request(struct ivpu_device *vdev) in ivpu_fw_request() argument
73 ret = request_firmware(&vdev->fw->file, ivpu_firmware, vdev->drm.dev); in ivpu_fw_request()
75 vdev->fw->name = ivpu_firmware; in ivpu_fw_request()
80 if (fw_names[i].gen != ivpu_hw_ip_gen(vdev)) in ivpu_fw_request()
83 ret = firmware_request_nowarn(&vdev->fw->file, fw_names[i].name, vdev->drm.dev); in ivpu_fw_request()
85 vdev->fw->name = fw_names[i].name; in ivpu_fw_request()
90 ivpu_err(vdev, "Failed to request firmware: %d\n", ret); in ivpu_fw_request()
95 ivpu_fw_check_api(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr, in ivpu_fw_check_api() argument
103 ivpu_err(vdev, "Incompatible FW %s API version: %d.%d, required %d.0 or later\n", in ivpu_fw_check_api()
108 ivpu_warn(vdev, "Major FW %s API version different: %d.%d (expected %d.%d)\n", in ivpu_fw_check_api()
111 ivpu_dbg(vdev, FW_BOOT, "FW %s API version: %d.%d (expected %d.%d)\n", in ivpu_fw_check_api()
118 ivpu_fw_check_api_ver_lt(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr, in ivpu_fw_check_api_ver_lt() argument
138 static int ivpu_fw_parse(struct ivpu_device *vdev) in ivpu_fw_parse() argument
140 struct ivpu_fw_info *fw = vdev->fw; in ivpu_fw_parse()
145 ivpu_err(vdev, "Firmware file is too small: %zu\n", fw->file->size); in ivpu_fw_parse()
150 ivpu_err(vdev, "Invalid firmware header version: %u\n", fw_hdr->header_version); in ivpu_fw_parse()
160 ivpu_err(vdev, "Invalid firmware runtime address: 0x%llx\n", runtime_addr); in ivpu_fw_parse()
165 ivpu_err(vdev, "Invalid firmware runtime size: %llu\n", runtime_size); in ivpu_fw_parse()
170 ivpu_err(vdev, "Invalid image size: %llu\n", image_size); in ivpu_fw_parse()
176 ivpu_err(vdev, "Invalid firmware load address size: 0x%llx and size %llu\n", in ivpu_fw_parse()
182 ivpu_err(vdev, "SHAVE NN firmware is too big: %u\n", fw_hdr->shave_nn_fw_size); in ivpu_fw_parse()
188 ivpu_err(vdev, "Invalid entry point: 0x%llx\n", fw_hdr->entry_point); in ivpu_fw_parse()
191 ivpu_dbg(vdev, FW_BOOT, "Header version: 0x%x, format 0x%x\n", in ivpu_fw_parse()
194 ivpu_info(vdev, "Firmware: %s, version: %s", fw->name, in ivpu_fw_parse()
197 if (IVPU_FW_CHECK_API_COMPAT(vdev, fw_hdr, BOOT, 3)) in ivpu_fw_parse()
199 if (IVPU_FW_CHECK_API_COMPAT(vdev, fw_hdr, JSM, 3)) in ivpu_fw_parse()
224 ivpu_err(vdev, "Invalid read-only section: start address 0x%llx, size %u\n", in ivpu_fw_parse()
232 ivpu_dbg(vdev, FW_BOOT, "Size: file %lu image %u runtime %u shavenn %u\n", in ivpu_fw_parse()
234 ivpu_dbg(vdev, FW_BOOT, "Address: runtime 0x%llx, load 0x%llx, entry point 0x%llx\n", in ivpu_fw_parse()
236 ivpu_dbg(vdev, FW_BOOT, "Read-only section: address 0x%llx, size %u\n", in ivpu_fw_parse()
242 static void ivpu_fw_release(struct ivpu_device *vdev) in ivpu_fw_release() argument
244 release_firmware(vdev->fw->file); in ivpu_fw_release()
249 ivpu_fw_init_wa(struct ivpu_device *vdev) in ivpu_fw_init_wa() argument
251 const struct vpu_firmware_header *fw_hdr = (const void *)vdev->fw->file->data; in ivpu_fw_init_wa()
253 if (IVPU_FW_CHECK_API_VER_LT(vdev, fw_hdr, BOOT, 3, 17) || in ivpu_fw_init_wa()
255 vdev->wa.disable_d0i3_msg = true; in ivpu_fw_init_wa()
259 vdev->wa.disable_d0i3_msg = false; in ivpu_fw_init_wa()
264 static int ivpu_fw_update_global_range(struct ivpu_device *vdev) in ivpu_fw_update_global_range() argument
266 struct ivpu_fw_info *fw = vdev->fw; in ivpu_fw_update_global_range()
271 ivpu_err(vdev, "No space for shared region, start %lld, size %lld\n", start, size); in ivpu_fw_update_global_range()
275 ivpu_hw_range_init(&vdev->hw->ranges.global, start, size); in ivpu_fw_update_global_range()
279 static int ivpu_fw_mem_init(struct ivpu_device *vdev) in ivpu_fw_mem_init() argument
281 struct ivpu_fw_info *fw = vdev->fw; in ivpu_fw_mem_init()
286 ret = ivpu_fw_update_global_range(vdev); in ivpu_fw_mem_init()
292 fw->mem = ivpu_bo_create(vdev, &vdev->gctx, &fw_range, fw->runtime_size, in ivpu_fw_mem_init()
295 ivpu_err(vdev, "Failed to create firmware runtime memory buffer\n"); in ivpu_fw_mem_init()
299 ret = ivpu_mmu_context_set_pages_ro(vdev, &vdev->gctx, fw->read_only_addr, in ivpu_fw_mem_init()
302 ivpu_err(vdev, "Failed to set firmware image read-only\n"); in ivpu_fw_mem_init()
306 fw->mem_log_crit = ivpu_bo_create_global(vdev, IVPU_FW_CRITICAL_BUFFER_SIZE, in ivpu_fw_mem_init()
309 ivpu_err(vdev, "Failed to create critical log buffer\n"); in ivpu_fw_mem_init()
319 fw->mem_log_verb = ivpu_bo_create_global(vdev, log_verb_size, in ivpu_fw_mem_init()
322 ivpu_err(vdev, "Failed to create verbose log buffer\n"); in ivpu_fw_mem_init()
328 fw->mem_shave_nn = ivpu_bo_create(vdev, &vdev->gctx, &vdev->hw->ranges.shave, in ivpu_fw_mem_init()
331 ivpu_err(vdev, "Failed to create shavenn buffer\n"); in ivpu_fw_mem_init()
348 static void ivpu_fw_mem_fini(struct ivpu_device *vdev) in ivpu_fw_mem_fini() argument
350 struct ivpu_fw_info *fw = vdev->fw; in ivpu_fw_mem_fini()
366 int ivpu_fw_init(struct ivpu_device *vdev) in ivpu_fw_init() argument
370 ret = ivpu_fw_request(vdev); in ivpu_fw_init()
374 ret = ivpu_fw_parse(vdev); in ivpu_fw_init()
378 ivpu_fw_init_wa(vdev); in ivpu_fw_init()
380 ret = ivpu_fw_mem_init(vdev); in ivpu_fw_init()
384 ivpu_fw_load(vdev); in ivpu_fw_init()
389 ivpu_fw_release(vdev); in ivpu_fw_init()
393 void ivpu_fw_fini(struct ivpu_device *vdev) in ivpu_fw_fini() argument
395 ivpu_fw_mem_fini(vdev); in ivpu_fw_fini()
396 ivpu_fw_release(vdev); in ivpu_fw_fini()
399 void ivpu_fw_load(struct ivpu_device *vdev) in ivpu_fw_load() argument
401 struct ivpu_fw_info *fw = vdev->fw; in ivpu_fw_load()
418 static void ivpu_fw_boot_params_print(struct ivpu_device *vdev, struct vpu_boot_params *boot_params) in ivpu_fw_boot_params_print() argument
420 ivpu_dbg(vdev, FW_BOOT, "boot_params.magic = 0x%x\n", in ivpu_fw_boot_params_print()
422 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_id = 0x%x\n", in ivpu_fw_boot_params_print()
424 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_count = 0x%x\n", in ivpu_fw_boot_params_print()
426 ivpu_dbg(vdev, FW_BOOT, "boot_params.frequency = %u\n", in ivpu_fw_boot_params_print()
428 ivpu_dbg(vdev, FW_BOOT, "boot_params.perf_clk_frequency = %u\n", in ivpu_fw_boot_params_print()
431 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_header_area_start = 0x%llx\n", in ivpu_fw_boot_params_print()
433 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_header_area_size = 0x%x\n", in ivpu_fw_boot_params_print()
435 ivpu_dbg(vdev, FW_BOOT, "boot_params.shared_region_base = 0x%llx\n", in ivpu_fw_boot_params_print()
437 ivpu_dbg(vdev, FW_BOOT, "boot_params.shared_region_size = 0x%x\n", in ivpu_fw_boot_params_print()
439 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_payload_area_start = 0x%llx\n", in ivpu_fw_boot_params_print()
441 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_payload_area_size = 0x%x\n", in ivpu_fw_boot_params_print()
443 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_aliased_pio_base = 0x%llx\n", in ivpu_fw_boot_params_print()
445 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_aliased_pio_size = 0x%x\n", in ivpu_fw_boot_params_print()
448 ivpu_dbg(vdev, FW_BOOT, "boot_params.autoconfig = 0x%x\n", in ivpu_fw_boot_params_print()
451 ivpu_dbg(vdev, FW_BOOT, "boot_params.cache_defaults[VPU_BOOT_L2_CACHE_CFG_NN].use = 0x%x\n", in ivpu_fw_boot_params_print()
453 ivpu_dbg(vdev, FW_BOOT, "boot_params.cache_defaults[VPU_BOOT_L2_CACHE_CFG_NN].cfg = 0x%x\n", in ivpu_fw_boot_params_print()
456 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_memory_allocator_base = 0x%llx\n", in ivpu_fw_boot_params_print()
458 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_memory_allocator_size = 0x%x\n", in ivpu_fw_boot_params_print()
461 ivpu_dbg(vdev, FW_BOOT, "boot_params.shave_nn_fw_base = 0x%llx\n", in ivpu_fw_boot_params_print()
464 ivpu_dbg(vdev, FW_BOOT, "boot_params.watchdog_irq_mss = 0x%x\n", in ivpu_fw_boot_params_print()
466 ivpu_dbg(vdev, FW_BOOT, "boot_params.watchdog_irq_nce = 0x%x\n", in ivpu_fw_boot_params_print()
468 ivpu_dbg(vdev, FW_BOOT, "boot_params.host_to_vpu_irq = 0x%x\n", in ivpu_fw_boot_params_print()
470 ivpu_dbg(vdev, FW_BOOT, "boot_params.job_done_irq = 0x%x\n", in ivpu_fw_boot_params_print()
473 ivpu_dbg(vdev, FW_BOOT, "boot_params.host_version_id = 0x%x\n", in ivpu_fw_boot_params_print()
475 ivpu_dbg(vdev, FW_BOOT, "boot_params.si_stepping = 0x%x\n", in ivpu_fw_boot_params_print()
477 ivpu_dbg(vdev, FW_BOOT, "boot_params.device_id = 0x%llx\n", in ivpu_fw_boot_params_print()
479 ivpu_dbg(vdev, FW_BOOT, "boot_params.feature_exclusion = 0x%llx\n", in ivpu_fw_boot_params_print()
481 ivpu_dbg(vdev, FW_BOOT, "boot_params.sku = 0x%llx\n", in ivpu_fw_boot_params_print()
483 ivpu_dbg(vdev, FW_BOOT, "boot_params.min_freq_pll_ratio = 0x%x\n", in ivpu_fw_boot_params_print()
485 ivpu_dbg(vdev, FW_BOOT, "boot_params.pn_freq_pll_ratio = 0x%x\n", in ivpu_fw_boot_params_print()
487 ivpu_dbg(vdev, FW_BOOT, "boot_params.max_freq_pll_ratio = 0x%x\n", in ivpu_fw_boot_params_print()
489 ivpu_dbg(vdev, FW_BOOT, "boot_params.default_trace_level = 0x%x\n", in ivpu_fw_boot_params_print()
491 ivpu_dbg(vdev, FW_BOOT, "boot_params.tracing_buff_message_format_mask = 0x%llx\n", in ivpu_fw_boot_params_print()
493 ivpu_dbg(vdev, FW_BOOT, "boot_params.trace_destination_mask = 0x%x\n", in ivpu_fw_boot_params_print()
495 ivpu_dbg(vdev, FW_BOOT, "boot_params.trace_hw_component_mask = 0x%llx\n", in ivpu_fw_boot_params_print()
497 ivpu_dbg(vdev, FW_BOOT, "boot_params.boot_type = 0x%x\n", in ivpu_fw_boot_params_print()
499 ivpu_dbg(vdev, FW_BOOT, "boot_params.punit_telemetry_sram_base = 0x%llx\n", in ivpu_fw_boot_params_print()
501 ivpu_dbg(vdev, FW_BOOT, "boot_params.punit_telemetry_sram_size = 0x%llx\n", in ivpu_fw_boot_params_print()
503 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_telemetry_enable = 0x%x\n", in ivpu_fw_boot_params_print()
505 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_scheduling_mode = 0x%x\n", in ivpu_fw_boot_params_print()
507 ivpu_dbg(vdev, FW_BOOT, "boot_params.dvfs_mode = %u\n", in ivpu_fw_boot_params_print()
509 ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_delayed_entry = %d\n", in ivpu_fw_boot_params_print()
511 ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_residency_time_us = %lld\n", in ivpu_fw_boot_params_print()
513 ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_entry_vpu_ts = %llu\n", in ivpu_fw_boot_params_print()
515 ivpu_dbg(vdev, FW_BOOT, "boot_params.system_time_us = %llu\n", in ivpu_fw_boot_params_print()
519 void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params *boot_params) in ivpu_fw_boot_params_setup() argument
521 struct ivpu_bo *ipc_mem_rx = vdev->ipc->mem_rx; in ivpu_fw_boot_params_setup()
524 if (!ivpu_fw_is_cold_boot(vdev)) { in ivpu_fw_boot_params_setup()
526 ktime_us_delta(ktime_get_boottime(), vdev->hw->d0i3_entry_host_ts); in ivpu_fw_boot_params_setup()
527 boot_params->d0i3_entry_vpu_ts = vdev->hw->d0i3_entry_vpu_ts; in ivpu_fw_boot_params_setup()
530 ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_residency_time_us = %lld\n", in ivpu_fw_boot_params_setup()
532 ivpu_dbg(vdev, FW_BOOT, "boot_params.d0i3_entry_vpu_ts = %llu\n", in ivpu_fw_boot_params_setup()
534 ivpu_dbg(vdev, FW_BOOT, "boot_params.system_time_us = %llu\n", in ivpu_fw_boot_params_setup()
538 vdev->pm->is_warmboot = true; in ivpu_fw_boot_params_setup()
543 vdev->pm->is_warmboot = false; in ivpu_fw_boot_params_setup()
546 boot_params->vpu_id = to_pci_dev(vdev->drm.dev)->bus->number; in ivpu_fw_boot_params_setup()
547 boot_params->frequency = ivpu_hw_pll_freq_get(vdev); in ivpu_fw_boot_params_setup()
554 boot_params->perf_clk_frequency = ivpu_hw_profiling_freq_get(vdev); in ivpu_fw_boot_params_setup()
560 boot_params->shared_region_base = vdev->hw->ranges.global.start; in ivpu_fw_boot_params_setup()
561 boot_params->shared_region_size = vdev->hw->ranges.global.end - in ivpu_fw_boot_params_setup()
562 vdev->hw->ranges.global.start; in ivpu_fw_boot_params_setup()
570 boot_params->global_aliased_pio_base = vdev->hw->ranges.user.start; in ivpu_fw_boot_params_setup()
571 boot_params->global_aliased_pio_size = ivpu_hw_range_size(&vdev->hw->ranges.user); in ivpu_fw_boot_params_setup()
579 ADDR_TO_L2_CACHE_CFG(vdev->hw->ranges.shave.start); in ivpu_fw_boot_params_setup()
581 if (vdev->fw->mem_shave_nn) in ivpu_fw_boot_params_setup()
582 boot_params->shave_nn_fw_base = vdev->fw->mem_shave_nn->vpu_addr; in ivpu_fw_boot_params_setup()
586 boot_params->si_stepping = ivpu_revision(vdev); in ivpu_fw_boot_params_setup()
587 boot_params->device_id = ivpu_device_id(vdev); in ivpu_fw_boot_params_setup()
588 boot_params->feature_exclusion = vdev->hw->tile_fuse; in ivpu_fw_boot_params_setup()
589 boot_params->sku = vdev->hw->sku; in ivpu_fw_boot_params_setup()
591 boot_params->min_freq_pll_ratio = vdev->hw->pll.min_ratio; in ivpu_fw_boot_params_setup()
592 boot_params->pn_freq_pll_ratio = vdev->hw->pll.pn_ratio; in ivpu_fw_boot_params_setup()
593 boot_params->max_freq_pll_ratio = vdev->hw->pll.max_ratio; in ivpu_fw_boot_params_setup()
595 boot_params->default_trace_level = vdev->fw->trace_level; in ivpu_fw_boot_params_setup()
597 boot_params->trace_destination_mask = vdev->fw->trace_destination_mask; in ivpu_fw_boot_params_setup()
598 boot_params->trace_hw_component_mask = vdev->fw->trace_hw_component_mask; in ivpu_fw_boot_params_setup()
599 boot_params->crit_tracing_buff_addr = vdev->fw->mem_log_crit->vpu_addr; in ivpu_fw_boot_params_setup()
600 boot_params->crit_tracing_buff_size = ivpu_bo_size(vdev->fw->mem_log_crit); in ivpu_fw_boot_params_setup()
601 boot_params->verbose_tracing_buff_addr = vdev->fw->mem_log_verb->vpu_addr; in ivpu_fw_boot_params_setup()
602 boot_params->verbose_tracing_buff_size = ivpu_bo_size(vdev->fw->mem_log_verb); in ivpu_fw_boot_params_setup()
604 boot_params->punit_telemetry_sram_base = ivpu_hw_telemetry_offset_get(vdev); in ivpu_fw_boot_params_setup()
605 boot_params->punit_telemetry_sram_size = ivpu_hw_telemetry_size_get(vdev); in ivpu_fw_boot_params_setup()
606 boot_params->vpu_telemetry_enable = ivpu_hw_telemetry_enable_get(vdev); in ivpu_fw_boot_params_setup()
607 boot_params->vpu_scheduling_mode = vdev->hw->sched_mode; in ivpu_fw_boot_params_setup()
608 if (vdev->hw->sched_mode == VPU_SCHEDULING_MODE_HW) in ivpu_fw_boot_params_setup()
610 boot_params->dvfs_mode = vdev->fw->dvfs_mode; in ivpu_fw_boot_params_setup()
619 ivpu_fw_boot_params_print(vdev, boot_params); in ivpu_fw_boot_params_setup()