Lines Matching +full:uuid +full:- +full:dev

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
12 #include "ipc4-priv.h"
13 #include "sof-audio.h"
14 #include "sof-priv.h"
23 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_fw_parse_ext_man()
24 const struct firmware *fw = fw_lib->sof_fw.fw; in sof_ipc4_fw_parse_ext_man()
35 dev_err(sdev->dev, "%s: ipc4_data is not available\n", __func__); in sof_ipc4_fw_parse_ext_man()
36 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
39 remaining = fw->size; in sof_ipc4_fw_parse_ext_man()
41 dev_err(sdev->dev, "Firmware size is too small: %zu\n", remaining); in sof_ipc4_fw_parse_ext_man()
42 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
45 ext_man_hdr = (struct sof_ext_manifest4_hdr *)fw->data; in sof_ipc4_fw_parse_ext_man()
51 if (ext_man_hdr->id != SOF_EXT_MAN4_MAGIC_NUMBER) { in sof_ipc4_fw_parse_ext_man()
52 dev_err(sdev->dev, in sof_ipc4_fw_parse_ext_man()
54 ext_man_hdr->id); in sof_ipc4_fw_parse_ext_man()
55 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
58 fw_hdr_offset = ipc4_data->manifest_fw_hdr_offset; in sof_ipc4_fw_parse_ext_man()
60 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
62 if (remaining <= ext_man_hdr->len + fw_hdr_offset + sizeof(*fw_header)) { in sof_ipc4_fw_parse_ext_man()
63 dev_err(sdev->dev, "Invalid firmware size %zu, should be at least %zu\n", in sof_ipc4_fw_parse_ext_man()
64 remaining, ext_man_hdr->len + fw_hdr_offset + sizeof(*fw_header)); in sof_ipc4_fw_parse_ext_man()
65 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
69 (fw->data + ext_man_hdr->len + fw_hdr_offset); in sof_ipc4_fw_parse_ext_man()
70 remaining -= (ext_man_hdr->len + fw_hdr_offset); in sof_ipc4_fw_parse_ext_man()
72 if (remaining <= fw_header->len) { in sof_ipc4_fw_parse_ext_man()
73 dev_err(sdev->dev, "Invalid fw_header->len %u\n", fw_header->len); in sof_ipc4_fw_parse_ext_man()
74 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
77 dev_info(sdev->dev, "Loaded firmware library: %s, version: %u.%u.%u.%u\n", in sof_ipc4_fw_parse_ext_man()
78 fw_header->name, fw_header->major_version, fw_header->minor_version, in sof_ipc4_fw_parse_ext_man()
79 fw_header->hotfix_version, fw_header->build_version); in sof_ipc4_fw_parse_ext_man()
80 dev_dbg(sdev->dev, "Header length: %u, module count: %u\n", in sof_ipc4_fw_parse_ext_man()
81 fw_header->len, fw_header->num_module_entries); in sof_ipc4_fw_parse_ext_man()
83 fw_lib->modules = devm_kmalloc_array(sdev->dev, fw_header->num_module_entries, in sof_ipc4_fw_parse_ext_man()
85 if (!fw_lib->modules) in sof_ipc4_fw_parse_ext_man()
86 return -ENOMEM; in sof_ipc4_fw_parse_ext_man()
88 fw_lib->name = fw_header->name; in sof_ipc4_fw_parse_ext_man()
89 fw_lib->num_modules = fw_header->num_module_entries; in sof_ipc4_fw_parse_ext_man()
90 fw_module = fw_lib->modules; in sof_ipc4_fw_parse_ext_man()
92 fm_entry = (struct sof_man4_module *)((u8 *)fw_header + fw_header->len); in sof_ipc4_fw_parse_ext_man()
93 remaining -= fw_header->len; in sof_ipc4_fw_parse_ext_man()
95 if (remaining < fw_header->num_module_entries * sizeof(*fm_entry)) { in sof_ipc4_fw_parse_ext_man()
96 dev_err(sdev->dev, "Invalid num_module_entries %u\n", in sof_ipc4_fw_parse_ext_man()
97 fw_header->num_module_entries); in sof_ipc4_fw_parse_ext_man()
98 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
102 (fm_entry + fw_header->num_module_entries); in sof_ipc4_fw_parse_ext_man()
103 remaining -= (fw_header->num_module_entries * sizeof(*fm_entry)); in sof_ipc4_fw_parse_ext_man()
104 for (i = 0; i < fw_header->num_module_entries; i++) { in sof_ipc4_fw_parse_ext_man()
105 memcpy(&fw_module->man4_module_entry, fm_entry, sizeof(*fm_entry)); in sof_ipc4_fw_parse_ext_man()
107 if (fm_entry->cfg_count) { in sof_ipc4_fw_parse_ext_man()
108 if (remaining < (fm_entry->cfg_offset + fm_entry->cfg_count) * in sof_ipc4_fw_parse_ext_man()
110 dev_err(sdev->dev, "Invalid module cfg_offset %u\n", in sof_ipc4_fw_parse_ext_man()
111 fm_entry->cfg_offset); in sof_ipc4_fw_parse_ext_man()
112 return -EINVAL; in sof_ipc4_fw_parse_ext_man()
115 fw_module->fw_mod_cfg = &fm_config[fm_entry->cfg_offset]; in sof_ipc4_fw_parse_ext_man()
117 dev_dbg(sdev->dev, in sof_ipc4_fw_parse_ext_man()
118 "module %s: UUID %pUL cfg_count: %u, bss_size: %#x\n", in sof_ipc4_fw_parse_ext_man()
119 fm_entry->name, &fm_entry->uuid, fm_entry->cfg_count, in sof_ipc4_fw_parse_ext_man()
120 fm_config[fm_entry->cfg_offset].is_bytes); in sof_ipc4_fw_parse_ext_man()
122 dev_dbg(sdev->dev, "module %s: UUID %pUL\n", fm_entry->name, in sof_ipc4_fw_parse_ext_man()
123 &fm_entry->uuid); in sof_ipc4_fw_parse_ext_man()
126 fw_module->man4_module_entry.id = i; in sof_ipc4_fw_parse_ext_man()
127 ida_init(&fw_module->m_ida); in sof_ipc4_fw_parse_ext_man()
128 fw_module->private = NULL; in sof_ipc4_fw_parse_ext_man()
134 return ext_man_hdr->len; in sof_ipc4_fw_parse_ext_man()
139 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_fw_parse_basefw_ext_man()
144 fw_lib = devm_kzalloc(sdev->dev, sizeof(*fw_lib), GFP_KERNEL); in sof_ipc4_fw_parse_basefw_ext_man()
146 return -ENOMEM; in sof_ipc4_fw_parse_basefw_ext_man()
148 fw_lib->sof_fw.fw = sdev->basefw.fw; in sof_ipc4_fw_parse_basefw_ext_man()
152 fw_lib->sof_fw.payload_offset = payload_offset; in sof_ipc4_fw_parse_basefw_ext_man()
155 fw_lib->id = 0; in sof_ipc4_fw_parse_basefw_ext_man()
156 ret = xa_insert(&ipc4_data->fw_lib_xa, 0, fw_lib, GFP_KERNEL); in sof_ipc4_fw_parse_basefw_ext_man()
165 unsigned long lib_id, const guid_t *uuid) in sof_ipc4_load_library_by_uuid() argument
167 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_load_library_by_uuid()
173 if (!sdev->pdata->fw_lib_prefix) { in sof_ipc4_load_library_by_uuid()
174 dev_err(sdev->dev, in sof_ipc4_load_library_by_uuid()
176 return -EINVAL; in sof_ipc4_load_library_by_uuid()
179 if (!ipc4_data->load_library) { in sof_ipc4_load_library_by_uuid()
180 dev_err(sdev->dev, "Library loading is not supported on this platform\n"); in sof_ipc4_load_library_by_uuid()
181 return -EOPNOTSUPP; in sof_ipc4_load_library_by_uuid()
184 fw_lib = devm_kzalloc(sdev->dev, sizeof(*fw_lib), GFP_KERNEL); in sof_ipc4_load_library_by_uuid()
186 return -ENOMEM; in sof_ipc4_load_library_by_uuid()
189 sdev->pdata->fw_lib_prefix, uuid); in sof_ipc4_load_library_by_uuid()
191 ret = -ENOMEM; in sof_ipc4_load_library_by_uuid()
195 ret = request_firmware(&fw_lib->sof_fw.fw, fw_filename, sdev->dev); in sof_ipc4_load_library_by_uuid()
197 dev_err(sdev->dev, "Library file '%s' is missing\n", fw_filename); in sof_ipc4_load_library_by_uuid()
200 dev_dbg(sdev->dev, "Library file '%s' loaded\n", fw_filename); in sof_ipc4_load_library_by_uuid()
206 ret = -EINVAL; in sof_ipc4_load_library_by_uuid()
213 fw_lib->sof_fw.payload_offset = payload_offset; in sof_ipc4_load_library_by_uuid()
214 fw_lib->id = lib_id; in sof_ipc4_load_library_by_uuid()
217 for (i = 0; i < fw_lib->num_modules; i++) in sof_ipc4_load_library_by_uuid()
218 fw_lib->modules[i].man4_module_entry.id |= (lib_id << SOF_IPC4_MOD_LIB_ID_SHIFT); in sof_ipc4_load_library_by_uuid()
224 ret = pm_runtime_resume_and_get(sdev->dev); in sof_ipc4_load_library_by_uuid()
225 if (ret < 0 && ret != -EACCES) { in sof_ipc4_load_library_by_uuid()
226 dev_err_ratelimited(sdev->dev, "%s: pm_runtime resume failed: %d\n", in sof_ipc4_load_library_by_uuid()
231 ret = ipc4_data->load_library(sdev, fw_lib, false); in sof_ipc4_load_library_by_uuid()
233 pm_runtime_mark_last_busy(sdev->dev); in sof_ipc4_load_library_by_uuid()
234 err = pm_runtime_put_autosuspend(sdev->dev); in sof_ipc4_load_library_by_uuid()
236 dev_err_ratelimited(sdev->dev, "%s: pm_runtime idle failed: %d\n", in sof_ipc4_load_library_by_uuid()
242 ret = xa_insert(&ipc4_data->fw_lib_xa, lib_id, fw_lib, GFP_KERNEL); in sof_ipc4_load_library_by_uuid()
251 release_firmware(fw_lib->sof_fw.fw); in sof_ipc4_load_library_by_uuid()
253 devm_kfree(sdev->dev, fw_lib->modules); in sof_ipc4_load_library_by_uuid()
257 devm_kfree(sdev->dev, fw_lib); in sof_ipc4_load_library_by_uuid()
263 const guid_t *uuid) in sof_ipc4_find_module_by_uuid() argument
265 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_find_module_by_uuid()
270 if (guid_is_null(uuid)) in sof_ipc4_find_module_by_uuid()
273 xa_for_each(&ipc4_data->fw_lib_xa, lib_id, fw_lib) { in sof_ipc4_find_module_by_uuid()
274 for (i = 0; i < fw_lib->num_modules; i++) { in sof_ipc4_find_module_by_uuid()
275 if (guid_equal(uuid, &fw_lib->modules[i].man4_module_entry.uuid)) in sof_ipc4_find_module_by_uuid()
276 return &fw_lib->modules[i]; in sof_ipc4_find_module_by_uuid()
284 if ((lib_id + 1) == ipc4_data->max_libs_count) { in sof_ipc4_find_module_by_uuid()
285 dev_err(sdev->dev, in sof_ipc4_find_module_by_uuid()
287 __func__, ipc4_data->max_libs_count); in sof_ipc4_find_module_by_uuid()
292 ret = sof_ipc4_load_library_by_uuid(sdev, lib_id + 1, uuid); in sof_ipc4_find_module_by_uuid()
297 xa_for_each_start(&ipc4_data->fw_lib_xa, lib_id, fw_lib, lib_id) { in sof_ipc4_find_module_by_uuid()
298 for (i = 0; i < fw_lib->num_modules; i++) { in sof_ipc4_find_module_by_uuid()
299 if (guid_equal(uuid, &fw_lib->modules[i].man4_module_entry.uuid)) in sof_ipc4_find_module_by_uuid()
300 return &fw_lib->modules[i]; in sof_ipc4_find_module_by_uuid()
309 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_validate_firmware()
310 u32 fw_hdr_offset = ipc4_data->manifest_fw_hdr_offset; in sof_ipc4_validate_firmware()
312 const struct firmware *fw = sdev->basefw.fw; in sof_ipc4_validate_firmware()
315 ext_man_hdr = (struct sof_ext_manifest4_hdr *)fw->data; in sof_ipc4_validate_firmware()
317 (fw->data + ext_man_hdr->len + fw_hdr_offset); in sof_ipc4_validate_firmware()
321 dev_dbg(sdev->dev, "Validated firmware version: %u.%u.%u.%u\n", in sof_ipc4_validate_firmware()
322 fw_header->major_version, fw_header->minor_version, in sof_ipc4_validate_firmware()
323 fw_header->hotfix_version, fw_header->build_version); in sof_ipc4_validate_firmware()
330 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_query_fw_configuration()
331 const struct sof_ipc_ops *iops = sdev->ipc->ops; in sof_ipc4_query_fw_configuration()
345 msg.data_size = sdev->ipc->max_payload_size; in sof_ipc4_query_fw_configuration()
348 return -ENOMEM; in sof_ipc4_query_fw_configuration()
350 ret = iops->set_get_data(sdev, &msg, msg.data_size, false); in sof_ipc4_query_fw_configuration()
357 switch (tuple->type) { in sof_ipc4_query_fw_configuration()
359 fw_ver = (struct sof_ipc4_fw_version *)tuple->value; in sof_ipc4_query_fw_configuration()
361 dev_info(sdev->dev, in sof_ipc4_query_fw_configuration()
363 fw_ver->major, fw_ver->minor, fw_ver->hotfix, in sof_ipc4_query_fw_configuration()
364 fw_ver->build); in sof_ipc4_query_fw_configuration()
367 trace_sof_ipc4_fw_config(sdev, "DL mailbox size", *tuple->value); in sof_ipc4_query_fw_configuration()
370 trace_sof_ipc4_fw_config(sdev, "UL mailbox size", *tuple->value); in sof_ipc4_query_fw_configuration()
373 trace_sof_ipc4_fw_config(sdev, "Trace log size", *tuple->value); in sof_ipc4_query_fw_configuration()
374 ipc4_data->mtrace_log_bytes = *tuple->value; in sof_ipc4_query_fw_configuration()
378 *tuple->value); in sof_ipc4_query_fw_configuration()
379 ipc4_data->max_libs_count = *tuple->value; in sof_ipc4_query_fw_configuration()
380 if (!ipc4_data->max_libs_count) in sof_ipc4_query_fw_configuration()
381 ipc4_data->max_libs_count = 1; in sof_ipc4_query_fw_configuration()
384 ipc4_data->max_num_pipelines = *tuple->value; in sof_ipc4_query_fw_configuration()
386 ipc4_data->max_num_pipelines); in sof_ipc4_query_fw_configuration()
387 if (ipc4_data->max_num_pipelines <= 0) { in sof_ipc4_query_fw_configuration()
388 dev_err(sdev->dev, "Invalid max_num_pipelines %d", in sof_ipc4_query_fw_configuration()
389 ipc4_data->max_num_pipelines); in sof_ipc4_query_fw_configuration()
390 ret = -EINVAL; in sof_ipc4_query_fw_configuration()
398 offset += sizeof(*tuple) + tuple->size; in sof_ipc4_query_fw_configuration()
409 struct sof_ipc4_fw_data *ipc4_data = sdev->private; in sof_ipc4_reload_fw_libraries()
414 xa_for_each_start(&ipc4_data->fw_lib_xa, lib_id, fw_lib, 1) { in sof_ipc4_reload_fw_libraries()
415 ret = ipc4_data->load_library(sdev, fw_lib, true); in sof_ipc4_reload_fw_libraries()
417 dev_err(sdev->dev, "%s: Failed to reload library: %s, %d\n", in sof_ipc4_reload_fw_libraries()
418 __func__, fw_lib->name, ret); in sof_ipc4_reload_fw_libraries()
427 * sof_ipc4_update_cpc_from_manifest - Update the cpc in base config from manifest
442 if (!fw_module->fw_mod_cfg) { in sof_ipc4_update_cpc_from_manifest()
455 fw_mod_cfg = fw_module->fw_mod_cfg; in sof_ipc4_update_cpc_from_manifest()
456 for (i = 0; i < fw_module->man4_module_entry.cfg_count; i++) { in sof_ipc4_update_cpc_from_manifest()
457 if (basecfg->obs == fw_mod_cfg[i].obs && in sof_ipc4_update_cpc_from_manifest()
458 basecfg->ibs == fw_mod_cfg[i].ibs && in sof_ipc4_update_cpc_from_manifest()
466 basecfg->cpc = cpc_pick; in sof_ipc4_update_cpc_from_manifest()
469 if (basecfg->cpc) in sof_ipc4_update_cpc_from_manifest()
482 dev_dbg(sdev->dev, "%s (UUID: %pUL): %s (ibs/obs: %u/%u)\n", in sof_ipc4_update_cpc_from_manifest()
483 fw_module->man4_module_entry.name, in sof_ipc4_update_cpc_from_manifest()
484 &fw_module->man4_module_entry.uuid, msg, basecfg->ibs, in sof_ipc4_update_cpc_from_manifest()
485 basecfg->obs); in sof_ipc4_update_cpc_from_manifest()