-
Notifications
You must be signed in to change notification settings - Fork 139
ASoC: SOF: hda-sdw-bpt: mark bpt_stream->link_locked #5500
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
Conversation
|
@bardliao the design assumptions was that all the frame was allocated to BPT or audio, I don't think it's possible to mix the two, nor why we would need this capability. |
|
@plbossart The request is from Cirrus. One scenario is that one codec and one amp are on the same SDW link. We may want to write the AMP firmware while the codec is playing. @charleskeepax @stuhenderson Do you have any comment? |
kv2019i
left a comment
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.
Hmm, even if we end up not supporting concurrent use, this would seem a safe thing to align bpt assignement with the flow in hda_link_stream_assign() and mark the link as locked as done here.
sound/soc/sof/intel/hda-sdw-bpt.c
Outdated
| return PTR_ERR(bpt_stream); | ||
| } | ||
| /* Mark the HDA stream link is used */ | ||
| bpt_stream->link_locked = 1; |
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.
@bardliao IMO this may not be enough to meet the requirement for concurrent BPT and regular streams. I think we;d be oversimplifying it by assuming that the link DMA is always available when picking the host DMA channel isnt it? What if the link is already taken?
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 don't think the BPT stream will use a stream that bpt_stream->link_locked = 1. Both BTP and regular stream use hda_dsp_stream_get/put with the opened flag to manage the hdac_stream. So that BTP stream should not get a hdac_stream that is opened. But hda_link_stream_assign checked hext_stream->link_locked and that is why we need to set link_locked as regular streams.
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.
@bardliao I think you should squash the 2 patches and do the link_locked set/clear in the stream_get/put functions
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.
@bardliao I think you should squash the 2 patches and do the link_locked set/clear in the stream_get/put functions
Updated.
5e10347 to
c79e2c5
Compare
c79e2c5 to
943ac4c
Compare
kv2019i
left a comment
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'm afraid V2 raised some new questions, please see inline.
|
|
||
| if (use_link_dma) | ||
| snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK); | ||
|
|
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.
And do we really need to remember to pass "use_link_dma" to put? Shouldn't this be recorded in get and we allocated a linked link dma, we release it in put?
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.
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.
And do we really need to remember to pass "use_link_dma" to put? Shouldn't this be recorded in get and we allocated a linked link dma, we release it in put?
I thought about that, but I can't find a place to record the link_locked is set by hda_dsp_stream_get(). That's why originally, I set link_locked and call snd_hdac_ext_stream_release in hda_sdw_bpt_dma_prepare and hda_sdw_bpt_dma_deprepare where the stream is used/released.
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.
sound/soc/sof/intel/hda-loader.c
Outdated
| int ret; | ||
|
|
||
| hext_stream = hda_dsp_stream_get(sdev, direction, 0); | ||
| hext_stream = hda_dsp_stream_get(sdev, direction, 0, true); |
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'm not a fan of these true/false parameters. Can we add a enum or define for this?
hext_stream = hda_dsp_stream_get(sdev, direction, 0, HDA_STREAM_USE_LINK_DMA);
is much more readable. I know we have many true/false interfaces in existing code, so if you @bardliao @ranj063 @ujfalusi are ok, I'm not going to block, but I do find these hard to read (in the calling code).
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'm not a fan of these true/false parameters. Can we add a enum or define for this?
hext_stream = hda_dsp_stream_get(sdev, direction, 0, HDA_STREAM_USE_LINK_DMA);is much more readable. I know we have many true/false interfaces in existing code, so if you @bardliao @ranj063 @ujfalusi are ok, I'm not going to block, but I do find these hard to read (in the calling code).
Updated
Currently, we get host and link DMA streams separately by hda_dsp_stream_get() and hda_link_stream_assign(). However, in some cases like SoundWire BPT, we use hda_dsp_stream_get() to get the HDA stream and use the same HDA stream for both host and link DMAs. Add a use_link_dma flag to handle the case. Signed-off-by: Bard Liao <[email protected]>
| int ret; | ||
|
|
||
| hext_stream = hda_dsp_stream_get(sdev, direction, 0); | ||
| hext_stream = hda_dsp_stream_get(sdev, direction, 0, HDA_STREAM_USE_HOST_LINK_DMA); |
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 would you need LinkDMA for Code Loader? It only needs hostDMA.
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.
| enum sof_hda_stream_type { | ||
| HDA_STREAM_USE_HOST_DMA, | ||
| HDA_STREAM_USE_HOST_LINK_DMA, | ||
| }; |
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 this is a bool reserve_dma_pair sort of thing at the end, no?
What would happen if BRA would use hda_link_stream_assign() to grab the Link channel or is it mandatory that we must use the host/link with the same index?
Say, you use a wrapper in BR to get the two channels, host via hda_dsp_stream_get() and link via hda_link_stream_assign()
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.
Or for BRA we need to allocate the pairs like for platforms that have the PROCEN_FMT_QUIRK set?
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.
Not mandatory, but we set the same ID for host and link.
msg.primary |= SOF_IPC4_GLB_CHAIN_DMA_HOST_ID(dma_id);
msg.primary |= SOF_IPC4_GLB_CHAIN_DMA_LINK_ID(dma_id);https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/intel/hda-sdw-bpt.c#L73
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 this is a
bool reserve_dma_pairsort of thing at the end, no?
To me, yes. Using enum is an ask from @kv2019i to make the code more readable.
What would happen if BRA would use hda_link_stream_assign() to grab the Link channel or is it mandatory that we must use the host/link with the same index?
Say, you use a wrapper in BR to get the two channels, host via
hda_dsp_stream_get()and link viahda_link_stream_assign()
I thought about this. However, it will be more complicated. Besides, we can always use the same index for both host and link. Just have to use unused host/link.
Currently, the BPT stream will not run with other streams. So there is no issue we don't mark bpt_stream->link_locked. But we will support the BRA and audio streams run simultaneously. Therefore, marking link_locked is required to prevent the link being used by different streams.