Lines Matching refs:vdev
36 #define IVPU_FW_CHECK_API(vdev, fw_hdr, name, min_major) \
37 ivpu_fw_check_api(vdev, fw_hdr, #name, \
58 static int ivpu_fw_request(struct ivpu_device *vdev)
64 ret = request_firmware(&vdev->fw->file, ivpu_firmware, vdev->drm.dev);
66 vdev->fw->name = ivpu_firmware;
71 if (fw_names[i].gen != ivpu_hw_gen(vdev))
74 ret = firmware_request_nowarn(&vdev->fw->file, fw_names[i].name, vdev->drm.dev);
76 vdev->fw->name = fw_names[i].name;
81 ivpu_err(vdev, "Failed to request firmware: %d\n", ret);
86 ivpu_fw_check_api(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr,
94 ivpu_err(vdev, "Incompatible FW %s API version: %d.%d, required %d.0 or later\n",
99 ivpu_warn(vdev, "Major FW %s API version different: %d.%d (expected %d.%d)\n",
102 ivpu_dbg(vdev, FW_BOOT, "FW %s API version: %d.%d (expected %d.%d)\n",
108 static int ivpu_fw_parse(struct ivpu_device *vdev)
110 struct ivpu_fw_info *fw = vdev->fw;
115 ivpu_err(vdev, "Firmware file is too small: %zu\n", fw->file->size);
120 ivpu_err(vdev, "Invalid firmware header version: %u\n", fw_hdr->header_version);
130 ivpu_err(vdev, "Invalid firmware runtime address: 0x%llx\n", runtime_addr);
135 ivpu_err(vdev, "Invalid firmware runtime size: %llu\n", runtime_size);
140 ivpu_err(vdev, "Invalid image size: %llu\n", image_size);
146 ivpu_err(vdev, "Invalid firmware load address size: 0x%llx and size %llu\n",
152 ivpu_err(vdev, "SHAVE NN firmware is too big: %u\n", fw_hdr->shave_nn_fw_size);
158 ivpu_err(vdev, "Invalid entry point: 0x%llx\n", fw_hdr->entry_point);
161 ivpu_dbg(vdev, FW_BOOT, "Header version: 0x%x, format 0x%x\n",
164 ivpu_info(vdev, "Firmware: %s, version: %s", fw->name,
167 if (IVPU_FW_CHECK_API(vdev, fw_hdr, BOOT, 3))
169 if (IVPU_FW_CHECK_API(vdev, fw_hdr, JSM, 3))
185 ivpu_dbg(vdev, FW_BOOT, "Size: file %lu image %u runtime %u shavenn %u\n",
187 ivpu_dbg(vdev, FW_BOOT, "Address: runtime 0x%llx, load 0x%llx, entry point 0x%llx\n",
193 static void ivpu_fw_release(struct ivpu_device *vdev)
195 release_firmware(vdev->fw->file);
198 static int ivpu_fw_update_global_range(struct ivpu_device *vdev)
200 struct ivpu_fw_info *fw = vdev->fw;
205 ivpu_err(vdev, "No space for shared region, start %lld, size %lld\n", start, size);
209 ivpu_hw_init_range(&vdev->hw->ranges.global, start, size);
213 static int ivpu_fw_mem_init(struct ivpu_device *vdev)
215 struct ivpu_fw_info *fw = vdev->fw;
219 ret = ivpu_fw_update_global_range(vdev);
223 fw->mem = ivpu_bo_alloc_internal(vdev, fw->runtime_addr, fw->runtime_size, DRM_IVPU_BO_WC);
225 ivpu_err(vdev, "Failed to allocate firmware runtime memory\n");
229 fw->mem_log_crit = ivpu_bo_alloc_internal(vdev, 0, IVPU_FW_CRITICAL_BUFFER_SIZE,
232 ivpu_err(vdev, "Failed to allocate critical log buffer\n");
242 fw->mem_log_verb = ivpu_bo_alloc_internal(vdev, 0, log_verb_size, DRM_IVPU_BO_CACHED);
244 ivpu_err(vdev, "Failed to allocate verbose log buffer\n");
250 fw->mem_shave_nn = ivpu_bo_alloc_internal(vdev, vdev->hw->ranges.shave.start,
253 ivpu_err(vdev, "Failed to allocate shavenn buffer\n");
270 static void ivpu_fw_mem_fini(struct ivpu_device *vdev)
272 struct ivpu_fw_info *fw = vdev->fw;
288 int ivpu_fw_init(struct ivpu_device *vdev)
292 ret = ivpu_fw_request(vdev);
296 ret = ivpu_fw_parse(vdev);
300 ret = ivpu_fw_mem_init(vdev);
307 ivpu_fw_release(vdev);
311 void ivpu_fw_fini(struct ivpu_device *vdev)
313 ivpu_fw_mem_fini(vdev);
314 ivpu_fw_release(vdev);
317 int ivpu_fw_load(struct ivpu_device *vdev)
319 struct ivpu_fw_info *fw = vdev->fw;
338 static void ivpu_fw_boot_params_print(struct ivpu_device *vdev, struct vpu_boot_params *boot_params)
340 ivpu_dbg(vdev, FW_BOOT, "boot_params.magic = 0x%x\n",
342 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_id = 0x%x\n",
344 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_count = 0x%x\n",
346 ivpu_dbg(vdev, FW_BOOT, "boot_params.frequency = %u\n",
348 ivpu_dbg(vdev, FW_BOOT, "boot_params.perf_clk_frequency = %u\n",
351 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_header_area_start = 0x%llx\n",
353 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_header_area_size = 0x%x\n",
355 ivpu_dbg(vdev, FW_BOOT, "boot_params.shared_region_base = 0x%llx\n",
357 ivpu_dbg(vdev, FW_BOOT, "boot_params.shared_region_size = 0x%x\n",
359 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_payload_area_start = 0x%llx\n",
361 ivpu_dbg(vdev, FW_BOOT, "boot_params.ipc_payload_area_size = 0x%x\n",
363 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_aliased_pio_base = 0x%llx\n",
365 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_aliased_pio_size = 0x%x\n",
368 ivpu_dbg(vdev, FW_BOOT, "boot_params.autoconfig = 0x%x\n",
371 ivpu_dbg(vdev, FW_BOOT, "boot_params.cache_defaults[VPU_BOOT_L2_CACHE_CFG_NN].use = 0x%x\n",
373 ivpu_dbg(vdev, FW_BOOT, "boot_params.cache_defaults[VPU_BOOT_L2_CACHE_CFG_NN].cfg = 0x%x\n",
376 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_memory_allocator_base = 0x%llx\n",
378 ivpu_dbg(vdev, FW_BOOT, "boot_params.global_memory_allocator_size = 0x%x\n",
381 ivpu_dbg(vdev, FW_BOOT, "boot_params.shave_nn_fw_base = 0x%llx\n",
384 ivpu_dbg(vdev, FW_BOOT, "boot_params.watchdog_irq_mss = 0x%x\n",
386 ivpu_dbg(vdev, FW_BOOT, "boot_params.watchdog_irq_nce = 0x%x\n",
388 ivpu_dbg(vdev, FW_BOOT, "boot_params.host_to_vpu_irq = 0x%x\n",
390 ivpu_dbg(vdev, FW_BOOT, "boot_params.job_done_irq = 0x%x\n",
393 ivpu_dbg(vdev, FW_BOOT, "boot_params.host_version_id = 0x%x\n",
395 ivpu_dbg(vdev, FW_BOOT, "boot_params.si_stepping = 0x%x\n",
397 ivpu_dbg(vdev, FW_BOOT, "boot_params.device_id = 0x%llx\n",
399 ivpu_dbg(vdev, FW_BOOT, "boot_params.feature_exclusion = 0x%llx\n",
401 ivpu_dbg(vdev, FW_BOOT, "boot_params.sku = 0x%llx\n",
403 ivpu_dbg(vdev, FW_BOOT, "boot_params.min_freq_pll_ratio = 0x%x\n",
405 ivpu_dbg(vdev, FW_BOOT, "boot_params.pn_freq_pll_ratio = 0x%x\n",
407 ivpu_dbg(vdev, FW_BOOT, "boot_params.max_freq_pll_ratio = 0x%x\n",
409 ivpu_dbg(vdev, FW_BOOT, "boot_params.default_trace_level = 0x%x\n",
411 ivpu_dbg(vdev, FW_BOOT, "boot_params.tracing_buff_message_format_mask = 0x%llx\n",
413 ivpu_dbg(vdev, FW_BOOT, "boot_params.trace_destination_mask = 0x%x\n",
415 ivpu_dbg(vdev, FW_BOOT, "boot_params.trace_hw_component_mask = 0x%llx\n",
417 ivpu_dbg(vdev, FW_BOOT, "boot_params.boot_type = 0x%x\n",
419 ivpu_dbg(vdev, FW_BOOT, "boot_params.punit_telemetry_sram_base = 0x%llx\n",
421 ivpu_dbg(vdev, FW_BOOT, "boot_params.punit_telemetry_sram_size = 0x%llx\n",
423 ivpu_dbg(vdev, FW_BOOT, "boot_params.vpu_telemetry_enable = 0x%x\n",
427 void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params *boot_params)
429 struct ivpu_bo *ipc_mem_rx = vdev->ipc->mem_rx;
432 if (!ivpu_fw_is_cold_boot(vdev)) {
434 vdev->pm->is_warmboot = true;
439 vdev->pm->is_warmboot = false;
442 boot_params->vpu_id = to_pci_dev(vdev->drm.dev)->bus->number;
443 boot_params->frequency = ivpu_hw_reg_pll_freq_get(vdev);
449 boot_params->shared_region_base = vdev->hw->ranges.global.start;
450 boot_params->shared_region_size = vdev->hw->ranges.global.end -
451 vdev->hw->ranges.global.start;
459 boot_params->global_aliased_pio_base = vdev->hw->ranges.user.start;
460 boot_params->global_aliased_pio_size = ivpu_hw_range_size(&vdev->hw->ranges.user);
468 ADDR_TO_L2_CACHE_CFG(vdev->hw->ranges.shave.start);
470 if (vdev->fw->mem_shave_nn)
471 boot_params->shave_nn_fw_base = vdev->fw->mem_shave_nn->vpu_addr;
475 boot_params->si_stepping = ivpu_revision(vdev);
476 boot_params->device_id = ivpu_device_id(vdev);
477 boot_params->feature_exclusion = vdev->hw->tile_fuse;
478 boot_params->sku = vdev->hw->sku;
480 boot_params->min_freq_pll_ratio = vdev->hw->pll.min_ratio;
481 boot_params->pn_freq_pll_ratio = vdev->hw->pll.pn_ratio;
482 boot_params->max_freq_pll_ratio = vdev->hw->pll.max_ratio;
484 boot_params->default_trace_level = vdev->fw->trace_level;
486 boot_params->trace_destination_mask = vdev->fw->trace_destination_mask;
487 boot_params->trace_hw_component_mask = vdev->fw->trace_hw_component_mask;
488 boot_params->crit_tracing_buff_addr = vdev->fw->mem_log_crit->vpu_addr;
489 boot_params->crit_tracing_buff_size = vdev->fw->mem_log_crit->base.size;
490 boot_params->verbose_tracing_buff_addr = vdev->fw->mem_log_verb->vpu_addr;
491 boot_params->verbose_tracing_buff_size = vdev->fw->mem_log_verb->base.size;
493 boot_params->punit_telemetry_sram_base = ivpu_hw_reg_telemetry_offset_get(vdev);
494 boot_params->punit_telemetry_sram_size = ivpu_hw_reg_telemetry_size_get(vdev);
495 boot_params->vpu_telemetry_enable = ivpu_hw_reg_telemetry_enable_get(vdev);
499 ivpu_fw_boot_params_print(vdev, boot_params);