Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: file layout profile handling with fallback mechanism #4309

Conversation

ujfalusi
Copy link
Collaborator

Hi,

replaces #4308

This PR contains #4301 as the first 10 patch, the topmost two patch is the new one:
ASoC: SOF: Add library function for constructing loadable file paths, names
ASoC: SOF: sof-pci-dev: Use sof_create_file_profile() to create the file paths

Instead of cleaning up the current path/filename definitions in sof_dev_desc, this PR will introduce (the last two patch) a library file which can set/craft the paths, names used by the driver to load firmware files.
The entry to the library is the sof_create_file_profile() function which can handle overrides and also fallback to other IPC types in case the defaults are used (no override for firmware path or name).

Only sof-pci-dev.c is converted to use it atm as we only have multiple IPC types supported only with PCI devices.

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few quick comments. I'll try to test this still a bit before casting my final vote.

if (path_override->tplg_name)
out_profile->tplg_name = path_override->tplg_name;

out_profile->ipc_type = ipc_type;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess on remaining complication is that if e.g. default IPC type is 4 for a platform, but the override passes path to a IPC 3 FW, the test would be skipped (due to override) and but FW load would fail (kernel configured to IPC4 but FW is actually IPC3). I believe this is the typical case for many Chromebooks, so a pretty common case.

Not really a problem with this PR, but basicly limits the usefulness. If we keep IPC3 as the default for all platforms (that support multiple IPCs), then IPC3 will always be chosen as that's always available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is the user who is asking for it, right? It will fail later.
If we change the IPC type based on what the override points to then we would need to verify that the tplg path is aligned, so we would need to look for a matching tplg default path if it is not overridden, and that will open other door.

This is why I decided to not verify in case the fw path or/and name is overridden, it is something we cannot handle in a clean and sane way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i, to the specific scenario: I don't have a good answer. I don't know how that can be handled apart from requiring user to specify the IPC type alongside the fw path/name change to make sure they are aligned.

If you have a good algorithm to follow to cover that case, I'm all ears, but it is a bit of a wack-a-mole game with almost unlimited holes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing might work:
If a fw path/name override is asked we would first test it and.take the IPC type from the file and proceed further to gather other paths.
We could warn if the IPC types differ, but not fail.

I think this can close the loophole.

desc->default_fw_filename[i]);
}

dev_err(dev, "Check if you have 'sof-firmware' package installed.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: not sure how stable "sof-firmware" is as a pointer. In many RPM-based distros, package name is alsa-sof-firmware. Thus we just referred to sof-bin in the kernel error in the past.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the user should try to find a distro way first before reaching out to wget ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi Yup, we could add a "If you are seeing this message, you are looking too close." disclaimer here. ;)

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fully getting the picture @ujfalusi

/* firmware path */
if (path_override->fw_path) {
out_profile->fw_path = path_override->fw_path;
} else if (path_override->fw_path_postfix) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any incompatibility between fw_path and fw_path_postfix? I can recall any of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if the path is overridden then it is the full path, the postfix is ignored.
The postfix is the 'community' in Intel platforms.
If the user sets the path to "/home/developer/work/my_firmware" then that should be used, no?

if (i == ipc_type)
marker = "Requested";
else
marker = "Fallback";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would need to verify which IPC_TYPE is supported for a given platforms. Some only have IPC3, some only IPC4.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, true, I missed it from here.

if (i == ipc_type)
marker = "Requested";
else
marker = "Fallback";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other problem here is that for IPC4 on TGL the default is the 'IPC4 tester', not cSOF.

static const struct sof_dev_desc tgl_desc = {
	
	.default_fw_path = {
		[SOF_IPC] = "intel/sof",
		[SOF_INTEL_IPC4] = "intel/avs/tgl",
	},
	.default_lib_path = {
		[SOF_INTEL_IPC4] = "intel/avs-lib/tgl",
	},
	.default_tplg_path = {
		[SOF_IPC] = "intel/sof-tplg",
		[SOF_INTEL_IPC4] = "intel/avs-tplg",
	},
	.default_fw_filename = {
		[SOF_IPC] = "sof-tgl.ri",
		[SOF_INTEL_IPC4] = "dsp_basefw.bin",
	},

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that is a problem, and the now closed PR would have solved that issue, but since that did not received well, I have dropped that to follow the suggestion to not support multiple profiles per IPC types.

We have one set of paths per IPC type and that can only be changed with a change similar to what was introduced by #4308

@ujfalusi ujfalusi force-pushed the peter/sof/pr/file_layout_profile_with_fallback_01 branch from 1d005c7 to 9f86975 Compare April 20, 2023 14:14
@ujfalusi
Copy link
Collaborator Author

Changes since v1:

  • Mostly rewritten, now the whole process is moved to core, sof-acpi/of/pci-dev is only saving the override strings, they don't do much.
  • Based on the saved parameters, the core will call sof_create_ipc_file_profile() to gather the paths and to have the firmware file existence verified before proceeding further.
  • We still support fallback from default fw locations
  • We support IPC type adjustment in case of a custom FW path/name is asked.

@ujfalusi ujfalusi force-pushed the peter/sof/pr/file_layout_profile_with_fallback_01 branch from 9f86975 to 03cdad1 Compare April 21, 2023 10:36
@ujfalusi
Copy link
Collaborator Author

Changes since v2:

  • free up possibly allocated fw_path if default path with postfix is used and the firmware is not present.

@dbaluta
Copy link
Collaborator

dbaluta commented Apr 21, 2023

What is the purpose of this feature? To handle paths/etc in a single place?

@ujfalusi ujfalusi force-pushed the peter/sof/pr/file_layout_profile_with_fallback_01 branch from 03cdad1 to 09dc400 Compare April 21, 2023 11:13
Add a struct sof_loadable_file_profile which can be filled by platforms
(sof-acpi-dev.c, sof-of-dev.c and sof-acpi-dev.c) to be able to use common,
generic code to handle path customization.

Signed-off-by: Peter Ujfalusi <[email protected]>
Store the default IPC type and the firmware and topology path overrides to
ipc_file_profile_base

Signed-off-by: Peter Ujfalusi <[email protected]>
Store the default IPC type and the firmware and topology path overrides to
ipc_file_profile_base

Signed-off-by: Peter Ujfalusi <[email protected]>
Store the default IPC type and the overrides to ipc_file_profile_base

Signed-off-by: Peter Ujfalusi <[email protected]>
Use the information stored in ipc_file_profile_base by platforms to
construct the paths, filenames that are going to be used to load the
firmware and topology files.

The sof_create_ipc_file_profile() function will perform firmware file
presence checking and it can also fall back to other supported IPC types
in case the requested file for the type is not present.

If the firmware path or name is overridden by a module parameter, we will
check the file's IPC type and adjust the all other paths accordingly.

Signed-off-by: Peter Ujfalusi <[email protected]>
The core is now using the information from ipc_file_profile_base to create
the paths for the loadable files, no need to set it in here anymore.

Signed-off-by: Peter Ujfalusi <[email protected]>
The core is now using the information from ipc_file_profile_base to create
the paths for the loadable files, no need to set it in here anymore.

Signed-off-by: Peter Ujfalusi <[email protected]>
The core is now using the information from ipc_file_profile_base to create
the paths for the loadable files, no need to set it in here anymore.

Signed-off-by: Peter Ujfalusi <[email protected]>
@ujfalusi
Copy link
Collaborator Author

Changes since v3:

  • Fix fallback handling in case of default paths and ipc type is 1

@ujfalusi
Copy link
Collaborator Author

What is the purpose of this feature? To handle paths/etc in a single place?

Yes, this series is doing that with the additional bonus of handling fallback path in case the default firmware is not in place - fallback to different IPC type, that is.

This is just on part of the puzzle I'm trying to solve, which is to be able to verify both firmware and topology file existence and if any of them is missing, try other ipc type.
We have IPC3 used by distributions and if we want to provide a path for users to move to IPC4 we need to make sure that their system can fall back to IPC3 in case the files are not in place.

I could have tried to aim only for sof-pci-dev, but I think this feature can be useful for all of us in the long run and the code is not in hot path, so a bit of logic would not hurt performance, but let us use common ways to craft the paths (if they are let to their defaults).

Does this answer your question?

@dbaluta
Copy link
Collaborator

dbaluta commented Apr 21, 2023

@ujfalusi thanks this answers the question and now things are more clear. Ideally this explanation should be placed in one of the commit messages that gets kept in git history.

Also, thanks for going the generic way with pci/of/acpi.

@ujfalusi
Copy link
Collaborator Author

I'm going to replace this PR with a new one which will be able to do the topology file existence check also

@ujfalusi
Copy link
Collaborator Author

Replaced by take 3 at #4331, closing

@ujfalusi ujfalusi closed this Apr 27, 2023
@ujfalusi ujfalusi deleted the peter/sof/pr/file_layout_profile_with_fallback_01 branch December 13, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants