drivers/accel/ivpu/ivpu_fw.c
Source file repositories/reference/linux-study-clean/drivers/accel/ivpu/ivpu_fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/ivpu/ivpu_fw.c- Extension
.c- Size
- 24882 bytes
- Lines
- 725
- Domain
- Driver Families
- Bucket
- drivers/accel
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hlinux/highmem.hlinux/moduleparam.hlinux/pci.hvpu_boot_api.hivpu_drv.hivpu_fw.hivpu_fw_log.hivpu_gem.hivpu_hw.hivpu_ipc.hivpu_pm.h
Detected Declarations
function ivpu_fw_requestfunction ivpu_fw_check_apifunction ivpu_fw_check_api_ver_ltfunction ivpu_is_within_rangefunction ivpu_fw_sched_mode_selectfunction ivpu_preemption_config_parsefunction ivpu_fw_parsefunction ivpu_fw_releasefunction ivpu_fw_mem_initfunction ivpu_fw_mem_finifunction ivpu_fw_initfunction ivpu_fw_finifunction ivpu_fw_loadfunction ivpu_fw_boot_params_printfunction ivpu_fw_boot_params_setup
Annotated Snippet
if (!ret) {
vdev->fw->name = fw_names[i].name;
return 0;
}
}
ivpu_err(vdev, "Failed to request firmware: %d\n", ret);
return ret;
}
static int
ivpu_fw_check_api(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr,
const char *str, int index, u16 expected_major, u16 expected_minor,
u16 min_major)
{
u16 major = (u16)(fw_hdr->api_version[index] >> 16);
u16 minor = (u16)(fw_hdr->api_version[index]);
if (major < min_major) {
ivpu_err(vdev, "Incompatible FW %s API version: %d.%d, required %d.0 or later\n",
str, major, minor, min_major);
return -EINVAL;
}
if (major != expected_major) {
ivpu_warn(vdev, "Major FW %s API version different: %d.%d (expected %d.%d)\n",
str, major, minor, expected_major, expected_minor);
}
ivpu_dbg(vdev, FW_BOOT, "FW %s API version: %d.%d (expected %d.%d)\n",
str, major, minor, expected_major, expected_minor);
return 0;
}
static bool
ivpu_fw_check_api_ver_lt(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr,
const char *str, int index, u16 major, u16 minor)
{
u16 fw_major = (u16)(fw_hdr->api_version[index] >> 16);
u16 fw_minor = (u16)(fw_hdr->api_version[index]);
if (fw_major < major || (fw_major == major && fw_minor < minor))
return true;
return false;
}
bool ivpu_is_within_range(u64 addr, size_t size, struct ivpu_addr_range *range)
{
u64 addr_end;
if (!range || check_add_overflow(addr, size, &addr_end))
return false;
if (addr < range->start || addr_end > range->end)
return false;
return true;
}
static u32
ivpu_fw_sched_mode_select(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr)
{
if (ivpu_hw_ip_gen(vdev) >= IVPU_HW_IP_60XX &&
ivpu_sched_mode == VPU_SCHEDULING_MODE_OS) {
ivpu_warn(vdev, "OS sched mode is not supported, using HW mode\n");
return VPU_SCHEDULING_MODE_HW;
}
if (ivpu_sched_mode != IVPU_SCHED_MODE_AUTO)
return ivpu_sched_mode;
if (IVPU_FW_CHECK_API_VER_LT(vdev, fw_hdr, JSM, 3, 24))
return VPU_SCHEDULING_MODE_OS;
return VPU_SCHEDULING_MODE_HW;
}
static void
ivpu_preemption_config_parse(struct ivpu_device *vdev, const struct vpu_firmware_header *fw_hdr)
{
struct ivpu_fw_info *fw = vdev->fw;
u32 primary_preempt_buf_size, secondary_preempt_buf_size;
if (fw_hdr->preemption_buffer_1_max_size)
primary_preempt_buf_size = fw_hdr->preemption_buffer_1_max_size;
else
primary_preempt_buf_size = fw_hdr->preemption_buffer_1_size;
if (fw_hdr->preemption_buffer_2_max_size)
secondary_preempt_buf_size = fw_hdr->preemption_buffer_2_max_size;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/highmem.h`, `linux/moduleparam.h`, `linux/pci.h`, `vpu_boot_api.h`, `ivpu_drv.h`, `ivpu_fw.h`, `ivpu_fw_log.h`.
- Detected declarations: `function ivpu_fw_request`, `function ivpu_fw_check_api`, `function ivpu_fw_check_api_ver_lt`, `function ivpu_is_within_range`, `function ivpu_fw_sched_mode_select`, `function ivpu_preemption_config_parse`, `function ivpu_fw_parse`, `function ivpu_fw_release`, `function ivpu_fw_mem_init`, `function ivpu_fw_mem_fini`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.