-
Notifications
You must be signed in to change notification settings - Fork 140
Support extended manifest config data for clock config #2297
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,6 +294,9 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { | |
| .pre_fw_run = hda_dsp_pre_fw_run, | ||
| .post_fw_run = hda_dsp_post_fw_run, | ||
|
|
||
| /* parse platform specific extended manifest */ | ||
| .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why add this parse as ops?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xiulipan yes we will. For example, why would the IMX platforms have the LPRO config elem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ranj063 A good question here, but I think we should parse the platform manifest in one place and config them to each platform.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xiulipan I'm afraid this is a bit wrong audience. The ABI was already added to FW with 3.17 in thesofproject/sof#2893 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ranj063 @fredoh9 @kv2019i My only concern here is about the generic part in |
||
|
|
||
| /* dsp core power up/down */ | ||
| .core_power_up = hda_dsp_enable_core, | ||
| .core_power_down = hda_dsp_core_reset_power_down, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ | ||
| /* | ||
| * This file is provided under a dual BSD/GPLv2 license. When using or | ||
| * redistributing this file, you may do so under either license. | ||
| * | ||
| * Copyright(c) 2020 Intel Corporation. All rights reserved. | ||
| */ | ||
|
|
||
| /* | ||
| * Intel extended manifest is a extra place to store Intel cavs specific | ||
| * metadata about firmware, for example LPRO/HPRO configuration is | ||
| * Intel cavs specific. This part of output binary is not signed. | ||
| */ | ||
|
|
||
| #ifndef __INTEL_CAVS_EXT_MANIFEST_H__ | ||
| #define __INTEL_CAVS_EXT_MANIFEST_H__ | ||
|
|
||
| #include <sound/sof/ext_manifest.h> | ||
|
|
||
| /* EXT_MAN_ELEM_PLATFORM_CONFIG_DATA elements identificators */ | ||
| enum sof_cavs_config_elem_type { | ||
fredoh9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| SOF_EXT_MAN_CAVS_CONFIG_EMPTY = 0, | ||
| SOF_EXT_MAN_CAVS_CONFIG_CAVS_LPRO = 1, | ||
| SOF_EXT_MAN_CAVS_CONFIG_OUTBOX_SIZE = 2, | ||
| SOF_EXT_MAN_CAVS_CONFIG_INBOX_SIZE = 3, | ||
| SOF_EXT_MAN_CAVS_CONFIG_LAST_ELEM, /**< keep it at the end of enum list */ | ||
| }; | ||
|
|
||
| /* EXT_MAN_ELEM_PLATFORM_CONFIG_DATA elements */ | ||
| struct sof_ext_man_cavs_config_data { | ||
| struct sof_ext_man_elem_header hdr; | ||
|
|
||
| struct sof_config_elem elems[SOF_EXT_MAN_CAVS_CONFIG_LAST_ELEM]; | ||
| } __packed; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this got me thinking. This means, that every time you add a new config element type this structure will change size. So if you run a kernel and a firmware with different minor versions the kernel won't know what size of this structure should actually be there. I think you need a normal variable length array here like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was my point to, but variable explicit defining number of elements will be hard to achieve from FW side, there should be calculation based on
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not have a MAX_ELEMS instead then?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially I thought that defining MAX enum is easy and better way but I'm investigating @lyakh @ktrzcinx 's comments right now.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@ktrzcinx you mean the xcc's problem with variable size arrays?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. xcc's problem with variable size arrays is one issue, another is is explicit defining number of elements from FW side. From FW side those are global, const structs, filling them looks like this: As I know inserting
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dropped variable size arrays. After investigating SOF firmware side change, first XCC bug and second, implementation is unnecessary complicated(even ignoring XCC bug). Instead I bring back LAST_ELEM but LAST_ELEM is initialized with last element of that enum. And also added first enum EMPTY as Explicit 0, this is more clear(even i forgot why it started from 1). Even with LAST_ELEM, calculating number of elem from header size is good idea. So I kept that also. To sync up with SOF firmware header, I submit a PR to SOF side as well. thesofproject/sof#3510
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still disagree, that setting the array size to the number of currently defined parameters is a good idea. If these parameters are going to be used, then we'll get more than 1 of them pretty quickly, with each time having to modify the ABI. If this will never be extended beyond the original 1 value, well, maybe we don't need an array then in the first place at all.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If this array is flex array from kernel point of view and unknown elements are ignored, then ABI change won't be needed after extend (eg. multiple usage of single key). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some finding about the elem_size here. see https://github.com/thesofproject/linux/pull/2459/files#r508172578 |
||
|
|
||
| #endif /* __INTEL_CAVS_EXT_MANIFEST_H__ */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| #include <sound/hdaudio_ext.h> | ||
| #include <sound/hda_register.h> | ||
| #include <sound/sof.h> | ||
| #include "ext_manifest.h" | ||
| #include "../ops.h" | ||
| #include "hda.h" | ||
|
|
||
|
|
@@ -470,3 +471,39 @@ int hda_dsp_post_fw_run(struct snd_sof_dev *sdev) | |
| /* re-enable clock gating and power gating */ | ||
| return hda_dsp_ctrl_clock_power_gating(sdev, true); | ||
| } | ||
|
|
||
| int hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev, | ||
fredoh9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const struct sof_ext_man_elem_header *hdr) | ||
| { | ||
| const struct sof_ext_man_cavs_config_data *config_data = | ||
| container_of(hdr, struct sof_ext_man_cavs_config_data, hdr); | ||
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | ||
| int i, elem_num; | ||
|
|
||
| /* calculate total number of config data elements */ | ||
| elem_num = (hdr->size - sizeof(struct sof_ext_man_elem_header)) / sizeof(struct sof_config_elem); | ||
| if (elem_num <= 0) { | ||
| dev_err(sdev->dev, "cavs config data is inconsistent: %d\n", elem_num); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| for (i = 0; i < elem_num; i++) | ||
| switch (config_data->elems[i].token) { | ||
| case SOF_EXT_MAN_CAVS_CONFIG_EMPTY: | ||
| /* skip empty token */ | ||
| break; | ||
| case SOF_EXT_MAN_CAVS_CONFIG_CAVS_LPRO: | ||
| hda->clk_config_lpro = config_data->elems[i].value; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you would better to have some ops for the clk_config setting for each platform. |
||
| dev_dbg(sdev->dev, "FW clock config: %s\n", hda->clk_config_lpro ? "LPRO" : "HPRO"); | ||
| break; | ||
| case SOF_EXT_MAN_CAVS_CONFIG_OUTBOX_SIZE: | ||
| case SOF_EXT_MAN_CAVS_CONFIG_INBOX_SIZE: | ||
| /* This elem is supported but config data is not being used yet */ | ||
| break; | ||
| default: | ||
| dev_warn(sdev->dev, "unsupported token type: %d\n", | ||
fredoh9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| config_data->elems[i].token); | ||
fredoh9 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
Comment on lines
+475
to
+509
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will suggest to move this function to loader.c and only do something like Then in |
||
Uh oh!
There was an error while loading. Please reload this page.