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

UUID Firmware support #2920

Merged
merged 6 commits into from
Aug 5, 2020
Merged

UUID Firmware support #2920

merged 6 commits into from
Aug 5, 2020

Conversation

keyonjie
Copy link
Contributor

@keyonjie keyonjie commented May 9, 2020

This is the Firmware part series for UUID support, it should be used together with the tplg part and kernel part.

@keyonjie
Copy link
Contributor Author

keyonjie commented May 9, 2020

the corresponding tplg PR: #2919
the corresponding Linux PR: thesofproject/linux#2215

@keyonjie keyonjie mentioned this pull request May 9, 2020
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Please do the generic process comp type first. It should be usptream before any other patches are merged.

src/include/ipc/topology.h Outdated Show resolved Hide resolved
src/include/ipc/topology.h Outdated Show resolved Hide resolved
src/audio/component.c Outdated Show resolved Hide resolved
@keyonjie keyonjie changed the title [RFC]UUID Firmware support UUID Firmware support May 29, 2020
@keyonjie
Copy link
Contributor Author

This is ready for review now. @lgirdwood @kv2019i @mmaka1 @ktrzcinx

Comment on lines 73 to 77
if (!rstrncmp((const char *)info->drv->uid,
(const char *)uuid, UUID_SIZE)) {
tr_info(&comp_tr,
"get_drv_from_uuid(), found driver type %d, uuid %s",
info->drv->type, info->drv->uid);
Copy link
Member

Choose a reason for hiding this comment

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

There is some mismatch - UUID_SIZE is equal to 16, what is binary UUID number size, so it should be compared with memcmp and printing this value can't be done with %s, or when UUID should be passed in text form, then drv->uid size is too small.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The uuid is passed in binary mode for the comparing, the printing here is for the full text(including the naming).

Copy link
Member

Choose a reason for hiding this comment

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

why are we comparing strings ? I would expect us to compare the binary a.b.c.d data/struct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed now.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@keyonjie @ktrzcinx we have several PRs now for UUID, I need you guys to work out the merge ordering so we dont break anything. Please add PR title prefix to [DO NO MERGE]xxxx if teh PR is blocking on other PRs, this can then be removed when it's ready to merge.

@@ -64,6 +64,7 @@ struct sof_ipc_comp {
enum sof_comp_type type;
uint32_t pipeline_id;
uint32_t core;
uint8_t uuid[16]; /**< 16 Bytes UUID of the component */
Copy link
Member

Choose a reason for hiding this comment

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

can we use the same a.b.c.d structure that @mmaka1 has already defined. This will need to be a new IPC struct too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andy from the kernel side suggest not to use uuid_t or guid_t struct as ABI, see here: thesofproject/linux#2090 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

use the FW structure here exactly.

Comment on lines 73 to 77
if (!rstrncmp((const char *)info->drv->uid,
(const char *)uuid, UUID_SIZE)) {
tr_info(&comp_tr,
"get_drv_from_uuid(), found driver type %d, uuid %s",
info->drv->type, info->drv->uid);
Copy link
Member

Choose a reason for hiding this comment

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

why are we comparing strings ? I would expect us to compare the binary a.b.c.d data/struct

@keyonjie
Copy link
Contributor Author

@lgirdwood It's in byte(or binary, not a(4B)/b(2B)/c(2B)/d(B * 8)) from the driver, so we are comparing bytes here actually.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@ktrzcinx @keyonjie seems like we may be duplicating some patches, can you guys align. Thanks.

@@ -464,6 +460,11 @@ SECTIONS
KEEP (*(.fw_ready_metadata))
} >sof_fw :sof_fw_phdr

.static_uuid_entries : ALIGN(4)
Copy link
Member

Choose a reason for hiding this comment

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

Is this the same change that @ktrzcinx has just submitted ? Can you guys align.

Copy link
Member

Choose a reason for hiding this comment

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

No, this one is about .static_uuid_entries, I've made PR for .trace_ctx section.

Copy link
Member

Choose a reason for hiding this comment

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

ok, so we have any dependencies for merging ?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so

src/lib/lib.c Show resolved Hide resolved
@@ -64,6 +64,7 @@ struct sof_ipc_comp {
enum sof_comp_type type;
uint32_t pipeline_id;
uint32_t core;
uint8_t uuid[16]; /**< 16 Bytes UUID of the component */
Copy link
Member

Choose a reason for hiding this comment

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

use the FW structure here exactly.

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.

Implementation needs some iteration, but main principles seem right.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

I think extended_data_length is a good trade-off between backward compatibility, protocol simplicity and code clarity, thanks! I think the sanity check ("validation" sounds a bit pretentious) can be both clearer and stricter, see below.


/* validate the hdr.size */
if (comp->hdr.size < comp->ext_data_length) {
tr_err(&comp_tr, "Invalid size, hdr.size:0x%x, ext_data_length:0x%x\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming I got this right, replace with:

// Basic sanity check of total length and extended data length.
// In this generic code we don't know which specific comp and how much it adds
if (comp->hdr.size < sizeof(sof_ipc_comp) + comp->ext_data_length) {
  • stricter so catches more errors
  • makes it clearer that hdr.size is actually hdr.total_size without changing its name.

Copy link
Member

Choose a reason for hiding this comment

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

ack - with C style comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb, this is not included in your fixup commits?

@@ -86,10 +86,12 @@
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Core |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Reserved |
* | ext_data_length |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I doubt ext_data_length will ever need 32bits / 4GB, will it? If not then some bits should be kept reserved.

PS: thanks to little-endianness these bits could easily be reserved again even after this gets merged.

Copy link
Member

Choose a reason for hiding this comment

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

Lets use full extended size - anything new here will be added to extended data and this keeps it simple prior to IPC2.0

Copy link
Collaborator

Choose a reason for hiding this comment

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

@marc-hb I agree with Liam. 32bit fields are faster to parse on the DSP and if we need to add something more, we now have the extended data defined, so you can add any new fields at end of extended data.

@marc-hb
Copy link
Collaborator

marc-hb commented Jul 21, 2020

I shared 2-3 fixup! commits at https://github.com/marc-hb/sof/commits/uuid-2020-07-21

@lgirdwood
Copy link
Member

I shared 2-3 fixup! commits at https://github.com/marc-hb/sof/commits/uuid-2020-07-21

Thank you @marc-hb, these all look good. @keyonjie can you squash these into the PR.

@marc-hb
Copy link
Collaborator

marc-hb commented Jul 21, 2020

In these fixups I removed the word "new" from struct sof_ipc_comp_new_ext. However based on a more recent comment in the corresponding kernel review (which we want to keep consistent), I'm not 100% sure I understood "new"

@keyonjie
Copy link
Contributor Author

I shared 2-3 fixup! commits at https://github.com/marc-hb/sof/commits/uuid-2020-07-21

Thank you @marc-hb, these all look good. @keyonjie can you squash these into the PR.

Sure. I prefer to rename the sof_ipc_comp_ext_data to sof_ipc_comp_ext to avoid too long naming, is that sounds good for you @liam and @marc?

@liam
Copy link

liam commented Jul 22, 2020 via email

@lgirdwood
Copy link
Member

@marc-hb removing "new" is good.
@keyonjie short name is fine.

@keyonjie
Copy link
Contributor Author

@marc-hb removing "new" is good.
@keyonjie short name is fine.

OK, let me squashing and updating them now. @marc-hb for the documentation update, I would prefer to keep the name of each member and add the corresponding explain to the subsequent '()', which will be easier for understanding while reading document with the struct definition header file together.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@plbossart @ranj063 @keyonjie how is the kernel side looking ?

@lgirdwood
Copy link
Member

CI bat sounds fine at 997.

@keyonjie
Copy link
Contributor Author

@plbossart @ranj063 @keyonjie how is the kernel side looking ?

The kernel side is also updated and aligned with FW, @plbossart @ranj063 can you help to review as @kv2019i won't be available in the coming 2 weeks?

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

I prefer to rename the sof_ipc_comp_ext_data to sof_ipc_comp_ext to avoid too long naming, is that sounds good for you @liam and @marc?

Either is fine by me. Just for the record sof_ipc_comp_ext_data was only one character longer than the original sof_ipc_comp_new_ext! :-)

It's still too long.

C lacks namespaces.

@marc-hb for the documentation update, I would prefer to keep the name of each member and add the corresponding explain to the subsequent '()',

While this should certainly not hold back this PR, I disagree and for at least for IPC2.0 let me explain why. The purpose of the protocol documentation is to take a bit of distance with respect to the too short or too long C-symbol-of-the-day or other implementation details and use plain English instead to describe and focus on the protocol design, on the corresponding high level logic and on any corner cases. This is how @kv2019i started this document and the ext_data_length symbol you're adding is inconsistent with all the other lines in the same table.

which will be easier for understanding while reading document with the struct definition header file together.

In general, if someone finds it difficult to match the protocol description in plain English with the code when they are side by side (even though the fields are in the exact same order!) then it means there is a much bigger problem: either the English is really bad, or the symbol names are bad, or they both are.

In this particular case I can't imagine anyone struggling to match the "Extended Data Size" in English with extended_data_length in the code.

@liam
Copy link

liam commented Jul 23, 2020 via email

@cujomalainey
Copy link
Member

@liam apologies, you can unsubscribe yourself using the web view and clicking "unsubscribe" near the bottom of the right hand menu

@keyonjie
Copy link
Contributor Author

@liam apologies, you can unsubscribe yourself using the web view and clicking "unsubscribe" near the bottom of the right hand menu

Sorry @liam I tagged you by mistake but I can't stop github from sending related email to you, can you unsubscribe or unwatch to fix that?

keyonjie and others added 6 commits July 30, 2020 16:04
Initial the struct sof_ipc_comp_file to make sure all no updated flags
are 0s.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Initial the definition of struct sof_ipc_comp_new_ext, which will be
used to align the extended data between FW and the SW, add UUID array to
it.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Use the 32bit reserved member of the struct sof_ipc_comp as the extended
data length, this will help to minimize the ABI change for adding new
extended data to the struct sof_ipc_comp, usually only minor ABI version
bump needed for every update with this new solution.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add function memcmp for comparing two length-limited memory.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Switch to use UUID for component creation, if it is provided from the
host, otherwise, use component type for the component driver matching.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Update the IPC protocol documentation to include the extended data.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
@lgirdwood
Copy link
Member

SOFCI

@lgirdwood
Copy link
Member

Will apply after CI completes now that we have both FW and kernel dev approvals.

@lgirdwood
Copy link
Member

Internal CI showing all green on build and scheduler tests. Jenkins showing unrelated alsabat failure. @zrombel I assume internal CI is good to merge ?

@zrombel
Copy link

zrombel commented Aug 5, 2020

@lgirdwood yes, from internal CI view, PR is good to go.

@lgirdwood lgirdwood merged commit cf74566 into thesofproject:master Aug 5, 2020
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.

10 participants