-
Notifications
You must be signed in to change notification settings - Fork 321
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
audio: base_fw: add platform layer to hw_config data #9012
audio: base_fw: add platform layer to hw_config data #9012
Conversation
@dbaluta @iuliana-prodan this might affect NXP targets for IPC4 not yet in main (but in long term make it easier for you). I'm planning to move more plat spescific data out from base_fw.c but wanted to share this earlier to get feedback on the approach. |
b896576
to
3a658e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but we long term we should be removing the platform specific files as Zephyr will abstract platform. This looks IPC specific.
@lgirdwood wrote:
Ack, we are trackign this is #7248. To me it seems we have a layer of data that is above the RTOS layer and is different between vendors. Currently we use the "platform" layer for this in SOF. You pass a "platform name" to build script Personally I think we need the ability to vary the build contents. Some (most) of this is in terms of Kconfig settings and DTS overrides, but e.g. for the IPC4 tuples, we need content that requires custom code (at least for now). The platform layer in SOF seems like a natural fit. |
Issue in CI on one of the Intel platforms, tagging with DNM while debugging. Please review the concept still. |
3a658e0
to
1bdef88
Compare
V3:
|
1bdef88
to
4ed4eb8
Compare
V4:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something is weird here... same commit twice?..
tuple = tlv_next(tuple); | ||
tlv_value_uint32_set(tuple, IPC4_LP_EBB_COUNT_HW_CFG, PLATFORM_LPSRAM_EBB_COUNT); | ||
/* add platform specific tuples */ | ||
platform_basefw_hw_config(&plat_data_offset, (char *)tuple); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this break non-Intel platforms? Do you need a weak
version? Or is this all Intel-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh This is just like all functions in platform.h, all platforms need to provide one. Let me refresh the series with "posix" platform support, I missed that and that causes some of the CI checks to fail.
The one design open I had (and still have to some extent), is whether to make this a "bigger thing", e.g. something like a "platform/ipc-data.h". But I ended up not doing that and just putting thees in top-level platform.h as the longterm goal is to minimize platform interface (drop all platform/clk.h, platfrom/dma.h as these can all be handled via Zephyr interfaces, we just can't drop them yet as some platfroms still use XTOS). Especially as @lgirdwood is still not convinced we need platform.h at all (see #7248).
One alternative would be just to add src/ipc/ipc4/basefw_intel.c and not try to abstract this now. I'd still want to keep base_fw.c clean of vendor specific parts, so it is easier to use IPC4 for all SOF targets.
my oversight - the description looked very similar, I missed, that the two commits change different functions
@thesofproject/nxp Any thoughts on the high-level concept? So I guess the options would be:
I think some abraction is needed pretty quick to keep base_fw.c clean (e..g we have things like #9031 coming all the time). |
4ed4eb8
to
8284a9d
Compare
V5:
|
V6:
|
8284a9d
to
0319566
Compare
Changing to draft. It seems even with a fresh cycle of cleanup to the platform layer, there is still quite a bit of usage left in the tree, so adding these definitions to main platform.h will not scale. Also, I see many new PRs coming to base_fw.c, so I think the platform-specific layer will have to be grown later. IOW, we need to add some more explicit interface where to put platform specific basefw stuff (versus just putting them to platform.h). |
Depends what you mean by platform specific code, SOF codebase needs to be generic and Zephyr will define the platform. |
0319566
to
4c5808c
Compare
V7:
FYI @thesofproject/nxp -- for your initial IPC4 work, you could link against posix base_fw_platform.c and get a stubbed implementation. This does not currently leave anything out e.g. needed by Linux SOF driver for IPC4. |
struct sof_tlv *tuple = (struct sof_tlv *)data; | ||
uint32_t value; | ||
|
||
tlv_value_uint32_set(tuple, IPC4_HP_EBB_COUNT_HW_CFG, PLATFORM_HPSRAM_EBB_COUNT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To @lgirdwood your question: Not the best example of platform specific data in SOF, but let's use this as example. This is a tuple only needed on Intel platforms (e.g. Linux SOF driver has no need for this info), so even if we could get the data from Zephyr interfaces (or DTS), the decision to put this piece of data into a HW_CONFIG IPC response, is something only SOF built for Intel platforms should do.
Currently in SOF, the way to trigger build target specific behaviour of SOF is via the platform name -- this is our top-level build target. The confusing bit is that in XTOS, platform was also used to abstract "soc" and "board", but these are not used when SOF is built with Zephyr.
So that brings as back to IPC4 base_fw variation. As SOF is built separately for e..g ACE and NXP platforms, we can use this choice (made at built time) to variate the base_fw implementation in a more scalable way.
Things that are purely hw properties, like CPU core count, can be handled completely in generic code as 1) this information is added to HW_CONFIG response always, 2) the information can be queried with standard Zephyr interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put this in src/ipc/ipc4/intel.c
and export several C functions that can be called where vendor data has to be installed (otherwise the are all static inline vendor_add_memory()
and compile out).
The input data for IPC4_HP_EBB_COUNT_HW_CFG, PLATFORM_HPSRAM_EBB_COUNT
has to come from DT, but this could be a secondary PR later on (we could have a comment saying this today).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood That's what this patch now does, ipc4/intel.c code in src/platform/intel/ace/lib/base_fw_platform.c and generic stub in src/platform/posix/base_fw_platform.c.
We can keep this simpler and put this in ipc4/intel.c, but that means we need to maintain a platform/vendor layer in base_fw.h/base_fw_vendor.h and have ifdefs in src/ipc. Current PR keeps the ifdefs out of main src/ipc and ipc/audio trees.
I'm ok with both and can update the PR. There is more code and data to move once the approach is agreed, hw_config is just a start).
Finally figured out the mismatch between github workflow and my local build for fuzzer build, even did an OS upgrade to local build machine to match the github workflow. In the end the rootcause I was testing the pushed version locally, while the github flow was testing against newer SOF with #8737 . That adds constructs to base_fw.h that no longer build with the posix target, and thus my 9012 fails. |
Some of the IPC4 HW_CONFIG fields are platform specific and cannot be filled with generic code. Handle this functionality by separating platform specific parts of base_fw to a new base_fw_platform.h interface. Move out existing code for Intel cAVS and ACE platforms. Add a new stub implementation for posix platform. This posix stub can be also used as a starting point when adding IPC4 support to new platforms. This platform construct can be later used to move out other vendor and platform data out from base_fw.c. Signed-off-by: Kai Vehmanen <[email protected]>
V8:
|
4c5808c
to
478757b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kv2019i, the kernel is not using the HW_CONFIG, yet, probably ever, but I guess we will need similar platform dependent handling?
Do we have indication that the HW_CONFIG is Intel or posix or other vendor's to parse?
@@ -183,6 +184,7 @@ if (CONFIG_SOC_SERIES_INTEL_ADSP_ACE) | |||
# Platform sources | |||
zephyr_library_sources( | |||
${SOF_PLATFORM_PATH}/intel/ace/platform.c | |||
${SOF_PLATFORM_PATH}/intel/ace/lib/base_fw_platform.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally you would use the oldest platform's name, so intel/cavs/lib/base_fw_platform.c for both cavs and ace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ujfalusi Ack. If I can tune this in follow-up? I anticipate the ace one to be the full implementation and thus I put the main implementation here under ace/lib. For cavs we can probably go with a minimal implementation even, to keep the Linux SOF driver happy, but just wanted some example for cavs here as well for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just occurred to me, that on basefw_set side the only supported tlv type looks pretty Intel specific too. Does not happen to be this PR, but it would make sense to move that to platform specific source file too. |
@jsarha wrote:
Ack, a good idea. Also, the function signature could be improved. I now just took the existing code as-is from basefw so it is easier to remove the new layout, but I think this could be improved as well. These functions are now passed a "char *" pointer with no knowledge of size and it's very unobvious how it is handled the the functions don't overwite allocated buffer for the IPC response. |
First patch to address #8391 - more to come later.
Some of the HW_CONFIG fields are platform specific and cannot be filled with generic means in generic code.
Handle this data via a simple platform abstraction to hook platform specific code to HW_CONFIG handling. Move out existing code for Intel cAVS and ACE platforms.