Skip to content

Allow sending of compress parameters to SOF firmware#3552

Merged
dbaluta merged 4 commits into
thesofproject:topic/sof-devfrom
dbaluta:add_compr
Jul 5, 2022
Merged

Allow sending of compress parameters to SOF firmware#3552
dbaluta merged 4 commits into
thesofproject:topic/sof-devfrom
dbaluta:add_compr

Conversation

@dbaluta

@dbaluta dbaluta commented Mar 28, 2022

Copy link
Copy Markdown
Collaborator

This is the kernel part of SOF FW series in (thesofproject/sof#5591, thesofproject/sof#5592, thesofproject/sof#5596).

In particular we are interested right now to send the codec id to SOF FW, in order to properly select the correct API processing function.

Comment thread include/uapi/sound/sof/abi.h
Comment thread sound/soc/sof/compress.c Outdated

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks mostly good to me @dbaluta

Comment thread include/uapi/sound/sof/abi.h
Comment thread sound/soc/sof/compress.c Outdated
@dbaluta dbaluta changed the title [RFC] Allow sending of compress parameters to SOF firmware Allow sending of compress parameters to SOF firmware May 3, 2022
@dbaluta

dbaluta commented May 3, 2022

Copy link
Copy Markdown
Collaborator Author

@lgirdwood @plbossart @ujfalusi @ranj063 this is ready for merge as the previous ABI patches were merged.

Corresponding patch for FW is already in.

Comment thread sound/soc/sof/compress.c
@dbaluta

dbaluta commented May 17, 2022

Copy link
Copy Markdown
Collaborator Author

@plbossart @ranj063 @paulstelian97 @lgirdwood this should be ready for merge.

/* SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 21
#define SOF_ABI_MINOR 22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@dbaluta looks like this can be squashed with the previous patch right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 I've seen previous changes preferred this approach of having a separate patch. I wouldn't mind either.

@plbossart what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A separate patch is fine, this allows for a more space in the commit message to explain the interoperability between firmware and kernel versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Older FW will work with newer kernels as they will directly ignore ext_data_length field."

that's true, but functionally the parameters will be ignored and the result is undefined. If the firmware version is < 3.22 you probably don't want to even such an IPC at all, and probably want to prevent this path from being created in the first place.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not fully clear on new kernel + old firmware cases.

Comment thread include/sound/sof/stream.h Outdated

uint8_t reserved[5];
uint8_t reserved0;
int16_t ext_data_length; /** < 0, means no extended data */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

spurious space between /** and < ?

Comment thread sound/soc/sof/compress.c Outdated
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
data_size = sizeof(params->codec);

if (data_size + sizeof(*pcm) > SOF_IPC_MSG_MAX_SIZE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit-pick: for consistency with the rest of the code, maybe sizeof(*pcm) + data_size?

/* SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 21
#define SOF_ABI_MINOR 22

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A separate patch is fine, this allows for a more space in the commit message to explain the interoperability between firmware and kernel versions.

/* SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 21
#define SOF_ABI_MINOR 22

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Older FW will work with newer kernels as they will directly ignore ext_data_length field."

that's true, but functionally the parameters will be ignored and the result is undefined. If the firmware version is < 3.22 you probably don't want to even such an IPC at all, and probably want to prevent this path from being created in the first place.

@dbaluta

dbaluta commented May 25, 2022

Copy link
Copy Markdown
Collaborator Author

@plbossart fixed the nitpicks. The only thing remaining is:

If the firmware version is < 3.22 you probably don't want to even such an IPC at all, and probably want to prevent this path from being created in the first place.

Not sure how to deal with this. If the kernel figures out that the FW is older than 3.22 should we return an error in sof_compr_set_params?

@marc-hb

marc-hb commented May 25, 2022

Copy link
Copy Markdown
Collaborator

BYT failures in https://sof-ci.01.org/linuxpr/PR3552/build164/devicetest should be addressed by fresh sof-test PR

Sorry for the inconvenience.

@plbossart

Copy link
Copy Markdown
Member

@plbossart fixed the nitpicks. The only thing remaining is:

If the firmware version is < 3.22 you probably don't want to even such an IPC at all, and probably want to prevent this path from being created in the first place.

Not sure how to deal with this. If the kernel figures out that the FW is older than 3.22 should we return an error in sof_compr_set_params?

I think so. We clearly have a problem in our definition of ABI. There are cases where the communication will work with an older firmware, the firmware will be able to only use the parameters that were defined when it was build, so in theory there's backwards compatibility in terms of communication protocol, but from the application level the results will be broken.

@marc-hb

marc-hb commented May 26, 2022

Copy link
Copy Markdown
Collaborator

I think so. We clearly have a problem in our definition of ABI.

Discussed previously in

and others linked from there

@dbaluta

dbaluta commented May 30, 2022

Copy link
Copy Markdown
Collaborator Author

@plbossart should be fine now. Should i squash the FW version check patch into the previous one?

plbossart
plbossart previously approved these changes Jun 7, 2022
@dbaluta

dbaluta commented Jun 9, 2022

Copy link
Copy Markdown
Collaborator Author

@ranj063 @lyakh @lgirdwood can you please have a look?


uint8_t reserved[5];
uint8_t reserved0;
int16_t ext_data_length; /**< 0, means no extended data */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might have been already answered, but why we need the reserved0? To bring the ext_data_length to 16bit alignment?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

for that one could just place ext_data_length after the 3 reserved bytes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately the change was already merged in the FW side so we cannot change it here. Sorry for late answer I just came back from vacation :)

Comment thread include/sound/sof/stream.h Outdated
int16_t ext_data_length; /**< 0, means no extended data */
uint8_t reserved[2];
uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */
uint8_t data[]; /**< extended data */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ext_data ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think you are right on this, but the change was already merged in the FW side and would like to keep the names the same.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

at a second glance this is not ABI. I can rename it in the FW too. Thanks!

Comment thread sound/soc/sof/compress.c
struct sof_ipc_pcm_params *pcm;
struct snd_sof_pcm *spcm;
int data_size;
int ret;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there is no need for a new line for the data_size, can be added after the existing int ret;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

or should data_size be size_t?

Comment thread sound/soc/sof/compress.c Outdated
pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
data_size = sizeof(params->codec);

if (sizeof(*pcm) + data_size > SOF_IPC_MSG_MAX_SIZE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Better use sdev->ipc->max_payload_size instead SOF_IPC_MSG_MAX_SIZE to avoid surprises if this is used with other than IPC3?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ok, i will fix this.

Comment thread sound/soc/sof/compress.c
@dbaluta

dbaluta commented Jun 29, 2022

Copy link
Copy Markdown
Collaborator Author

SOFCI TEST

dbaluta added 4 commits June 29, 2022 15:57
We need to extend sof_ipc_pcm_parmas with additional data in order
to send compress_params to SOF FW.

The extensions will be done at runtime so we need to dynamically
allocate pcm object of type struct sof_ipc_pcm_params.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Allocate memory at the end of sof_ipc_stream_params to store
snd_compr_params in order to be sent them to SOF firmware.

This will help firmware correctly configure codecs parameters.

Notice, that we use 2 bytes from the reserved pool in order to store
the extended data length. This is compatible with older FWs where
there was no extended data.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
After introducing extended parameters we need to forbid older firmware
versions to run with the current and future kernel versions.

Although in theory the communication protocol will still work the
semantics at application level are undefined. So, prevent this by
disallowing older firmwares to run with newer kernels.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Add new field to sof_ipc_stream_params in order to extend
stream params struct with extended data to store compress parameters.

Older kernel will still work this as they ext_data_length will always be
zero.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
@plbossart
plbossart requested review from ranj063 and ujfalusi June 29, 2022 16:04
@dbaluta

dbaluta commented Jul 4, 2022

Copy link
Copy Markdown
Collaborator Author

@ujfalusi all comments should be addressed now. Care to have a look?

@ujfalusi ujfalusi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@dbaluta, sorry for the delay...

@dbaluta
dbaluta merged commit caa7bc7 into thesofproject:topic/sof-dev Jul 5, 2022
@dbaluta
dbaluta deleted the add_compr branch July 5, 2022 06:09
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.

6 participants