-
Notifications
You must be signed in to change notification settings - Fork 133
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: Intel/ipc4: Add support for two staged library loading #4521
ASoC: SOF: Intel/ipc4: Add support for two staged library loading #4521
Conversation
82add0a
to
9a23d47
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.
a couple of cosmetic/nit-picks and a more fundamental question on ABI and definition of "legacy".
include/sound/sof/ipc4/header.h
Outdated
@@ -108,6 +108,11 @@ enum sof_ipc4_global_msg { | |||
|
|||
/* Loads library (using Code Load or HD/A Host Output DMA) */ | |||
SOF_IPC4_GLB_LOAD_LIBRARY, | |||
/* | |||
* Prepare the host DMA channel for library loading, must be followed by | |||
* a SOF_IPC4_GLB_LOAD_LIBRARY message as the library loading step |
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.
extra space after 'a'
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.
Ok
sound/soc/sof/intel/hda-loader.c
Outdated
* message with valid dma_id and invalid (0) lib_id | ||
* if the firmware does not have support for the message, we will | ||
* receive -EOPNOTSUPP. In this case we assume legacy, single step library | ||
* loading support and proceed to send the LOAD_LIBRARY message. |
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.
this goes with my question on ABI. Do we even want to support those 'legacy' firmware and why?
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.
I think supporting firmware which does not implement this mode of library loading can be useful and only developers will encounter them.
sound/soc/sof/intel/hda-loader.c
Outdated
|
||
/* | ||
* 1st stage: SOF_IPC4_GLB_LOAD_LIBRARY_PREPARE | ||
* message with valid dma_id and invalid (0) lib_id |
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.
why do you even need to pass an invalid lib_id here?
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.
True, we only send the dma_id.
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.
subject to addressing Pierre's comments - LGTM otherwise
9a23d47
to
6d78705
Compare
Changes since v1:
|
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.
Approved but commit messages can be improved for grammar and clarity, see below.
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.
Code-wise I see nothing wrong. For commit messages, the message in the 3rd commit is a bit hard to follow and mostly redundant, as 4th commit message explains the same thing. Maybe remove most of the 3rd commit message, and just tell that a new message is needed. The explanation comes in the 4th message. From the 4rd I'd just drop "There is" from the beginning. These are only suggestions, so approved.
6d78705
to
3d89465
Compare
Changes since v2:
|
status, | ||
(status & SOF_HDA_SD_FIFOSIZE_FIFOS_MASK), | ||
HDA_DSP_REG_POLL_INTERVAL_US, | ||
HDA_DSP_BASEFW_TIMEOUT_US); |
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 is this just a paranoia check or is it really required to check the FIFO value?
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.
ping @ujfalusi, if we want this in 6.6 we don't have much time left
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.
it is paranoia check, but I feel more comfortable doing this, The firmware will set the GEN bit before it sends the reply.
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.
Oh, the FIFO value check? It is paranoia and also to make sure that we only set the RUN bit after the GEN was set. It should be, but I do feel that this a good practice and provides additional point if the loading fails (like the firmware have bug and not set the GEN bit and returns with success)
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.
ping @ujfalusi, if we want this in 6.6 we don't have much time left
I missed the comment, sorry.
sound/soc/sof/intel/hda-loader.c
Outdated
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_HDA_BAR, | ||
sd_offset + SOF_HDA_ADSP_REG_SD_FIFOSIZE, | ||
status, | ||
(status & SOF_HDA_SD_FIFOSIZE_FIFOS_MASK), |
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.
superfluous parentheses
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.
OK, fixing it, for some reason checkpatch was fine with it.
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.
oh, checkpatch is perfectly happy to swallow as many parentheses as you want to throw at it x = (((((0)))));
3d89465
to
b0a7d2b
Compare
The status code 2 and 15 can be translated to -EOPNOTSUPP, so convert them to a meaningful error number. Signed-off-by: Peter Ujfalusi <[email protected]>
The FIFOS (FIFO Size) field is in bit 0-15 of the register. Use the defined mask instead of a magic number for the FIFOS value masking in hda_dsp_stream_hw_params(). Signed-off-by: Peter Ujfalusi <[email protected]>
On Intel platforms there is a strict order requirement for the DMA programming: DSP side configures the buffer and sets the GEN bit Host side sets the RUN bit. In order to follow this flow, a new global message type has been added to prepare the DSP side of the DMA: host sends LOAD_LIBRARY_PREPARE with the dma_id DSP side sets its buffer and sets the GEN bit Host sets the RUN bit Host sends LOAD_LIBRARY with dma_id and lib_id DSP receives the library data. It is up to the platform code to use the new prepare stage message and how to handle the reply to it from the firmware, which can indicate that the message type is not supported/handled. In this case the kernel should proceed to the LOAD_LIBRARY stage assuming a single stage library loading: host sends LOAD_LIBRARY_PREPARE with the dma_id DSP replies that the message type is not supported/handled Host acknowledges the return code and sets the RUN bit Host sends LOAD_LIBRARY with dma_id and lib_id DSP receives the library data. Signed-off-by: Peter Ujfalusi <[email protected]>
There is a certain sequence needs to be followed when configuring the HDA DMA in host and DSP. The firmware provides a way to handle this two stage sequencing by splitting the library loading into two stage: 1st stage: LOAD_LIBRARY_PREPARE message the lib_id is 0, used to configure the DMA on DSP side 2nd stage: LOAD_LIBRARY message both dma_id and lib_id is valid, used for the actual transfer of the library In case a firmware without support for this two stage loading is used then the second stage message will trigger the loading and the first stage will return with error, which is ignored by the kernel. Signed-off-by: Peter Ujfalusi <[email protected]>
Changes since v3:
|
This is kernel part for loading a module library. The FW part has been merged thesofproject/sof#7986 |
@mengdonglin, that PR was the cleanup and fixes, the two staged one is not yet submitted. |
@ranj063 can you review this one please? |
@ujfalusi there's a genuine checkpatch warning. Maybe you can submit a fixup? |
There are two warnings, one is for 'hda' (misspelled had?) the other is alignment, but that I cannot fix unless we prefer long line warning. Almost all uses of |
Guess what, the checkpatch issue could be fixed without the long line warning. |
Hi,
It was determined that the existing library loading flow cannot follow the hardware programming sequence for the DMA, which is:
DSP side sets buffer and sets the GEN bit
Host side sets the RUN bit
With the single message the current flow is:
Host sets the RUN bit
Host sends LOAD_LIBRARY
DSP side sets buffer and sets the GEN bit
The agreed solution is that we will add a new LOAD_LIBRARY_PREPARE message and by using it in host and firmware side we can have correct programming flow:
host sends LOAD_LIBRARY_PREPARE
DSP side sets it's buffer and sets the GEN bit
Host sets the RUN bit
Host sends LOAD_LIBRARY
DSP recceives the library data.
In case the firmware does not implement this new message (returns with not supported message) then we will proceed and send only the LOAD_LIBRARY message as it was defined by legacy and to maintain backwards compatibility.