-
Notifications
You must be signed in to change notification settings - Fork 140
ASoC: SOF: Intel: reserve link DMA for sdw bpt stream #5567
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
ujfalusi
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.
@bardliao, I think this is much cleaner than the previous version, few comments to address.
sound/soc/sof/intel/hda-stream.c
Outdated
| goto out_put; | ||
| } | ||
|
|
||
| hstream->period_bytes = 0;/* initialize period_bytes */ |
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.
space before the 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.
not resolved yet
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.
fixed
sound/soc/sof/intel/hda-stream.c
Outdated
|
|
||
| ret = hda_dsp_stream_hw_params(sdev, hext_stream, dmab, NULL); | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); |
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.
no error: in prints, but func helps.
sound/soc/sof/intel/hda-stream.c
Outdated
| struct hdac_ext_stream *hext_stream) | ||
| { | ||
| struct snd_sof_dev *sdev = dev_get_drvdata(dev); | ||
| struct hdac_stream *hstream = &hext_stream->hstream; |
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 have this helper: hdac_stream(hext_stream), might be better to use it here as well?
sound/soc/sof/intel/hda-stream.c
Outdated
| hstream->bufsize = 0; | ||
| hstream->format_val = 0; | ||
| out_put: | ||
| hda_dsp_stream_put(sdev, direction, hstream->stream_tag); |
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.
you likely need to do snd_hdac_ext_stream_release() as well?
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.
you likely need to do snd_hdac_ext_stream_release() as well?
Yes, thanks for the reminding.
sound/soc/sof/intel/hda-stream.c
Outdated
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_get_stream_ldp, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| struct hdac_ext_stream* |
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 a space before the * is due. To align with hda_dsp_stream_get()
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 a space before the
*is due. To align with hda_dsp_stream_get()
Updated.
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.
missing space still?
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 know what happened. I fixed it previously. Then I removed in the last version and copy the function from hda-loader.c again in this version. Fixed it again now.
sound/soc/sof/intel/hda-stream.c
Outdated
|
|
||
| struct hdac_ext_stream * | ||
| hda_dsp_dma_channel_pair_get(struct device *dev, unsigned int format, unsigned int size, | ||
| struct snd_dma_buffer *dmab, int direction) |
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.
Looking at this again, I think the format/size/dmab should not be required to get the channel pair. Strictly speaking from API point of view.
This is how the BPT is using it, yes, but that does not mean that if we have new user (we might never) it will also need this to be done.
Should we restrict this to get the channel pair and add a wrapper in bpt code to request the pair and do the configuration?
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 sounds better. Let's make the helpers more generic.
sound/soc/sof/intel/hda-stream.c
Outdated
| struct hdac_ext_stream *hext_stream = _hda_dsp_stream_get(sdev, direction, flags, true); | ||
|
|
||
| if (hext_stream) | ||
| hext_stream->link_locked = 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.
In theory the link could be snatched by other stream between the call _hda_dsp_stream_get() and this point.
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.
In theory the link could be snatched by other stream between the call _hda_dsp_stream_get() and this point.
Fixed, thanks.
sound/soc/sof/intel/hda-sdw-bpt.c
Outdated
| return sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); | ||
| } | ||
|
|
||
| static struct hdac_ext_stream * |
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.
Can you fix the typo with BPT in the commit 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.
fixed
sound/soc/sof/intel/hda-sdw-bpt.c
Outdated
| } | ||
|
|
||
| static struct hdac_ext_stream * | ||
| hda_sdw_prepare(struct device *dev, unsigned int format, unsigned int size, |
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.
Is the only difference te use of hda_dsp_stream_pair_get() instead of stream_get() compared to hda_cl_prepare()? Can we reduce code duplication by reusing part of the 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.
Is the only difference te use of hda_dsp_stream_pair_get() instead of stream_get() compared to hda_cl_prepare()? Can we reduce code duplication by reusing part of the code?
Yes, updated.
Currently, hda_dsp_stream_get/put are used to get/put the host dma. However, we may want to use a hda stream that both host and link dma are available. Add helper to find the hda stream and reserve/release it. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
sound/soc/sof/intel/hda-stream.c
Outdated
| goto out_put; | ||
| } | ||
|
|
||
| hstream->period_bytes = 0;/* initialize period_bytes */ |
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 resolved yet
sound/soc/sof/intel/hda-stream.c
Outdated
| } | ||
| EXPORT_SYMBOL_NS(hda_dsp_get_stream_ldp, "SND_SOC_SOF_INTEL_HDA_COMMON"); | ||
|
|
||
| struct hdac_ext_stream* |
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.
missing space still?
ujfalusi
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.
only few nitpicks..
sound/soc/sof/intel/hda-stream.c
Outdated
| hext_stream = hda_dsp_stream_get(sdev, direction, 0); | ||
|
|
||
| if (!hext_stream) { | ||
| dev_err(sdev->dev, "error: no stream available\n"); |
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.
drop the error: and replace it with func
sound/soc/sof/intel/hda-stream.c
Outdated
| } else { | ||
| ret = hda_dsp_stream_hw_params(sdev, hext_stream, dmab, NULL); | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "error: hdac prepare failed: %d\n", ret); |
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 same for the other error: in prints.
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.
done
sound/soc/sof/intel/hda-stream.c
Outdated
| struct hdac_ext_stream * | ||
| hda_dma_prepare(struct device *dev, unsigned int format, unsigned int size, | ||
| struct snd_dma_buffer *dmab, bool persistent_buffer, int direction, | ||
| bool is_iccmax, bool pair) |
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.
The generic naming of hda_dma_prepare() / hda_dma_cleanup() I think is confusing.
This is implementing a special use of HD-DMA for data transfer, it does buffer allocation also.
It handles the CL (Code Loader - pair == false) and a data transfer channel to external device.
Can we find a better name? (sorry)
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.
Yeah, I thought about it. But I can't find a better name at that moment. Maybe we can figure one out together. How about hda_dt_prepare/cleanup DT: Data Transfer
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 stick with the existing (not too intuitive) naming convention used within hda-stream.c, what about:
hda_data_stream_prepare() / hda_data_stream_cleanup()
?
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.
Thanks, will update.
SoundWire BPT stream needs to use link and host DMAs. Thus we need helpers to prepare and cleanup the link and host DMAs. Currently the SoundWire BPT stream uses hda_cl_prepare/cleanup helpers. It works fine because we assume the SwoundWire BPT will not run with audio streams simultaneously. The new helpers are copied from hda_cl_prepare/cleanup and add a flag to reserve the paired host and link DMAs. The new helpers will be used by both code loader and SoundWire BPT. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
…eams Currently the SoundWire BPT stream uses the paired link DMA but not reserve it. It works without any issue because we assume the SoundWire BPT will not run with audio streams simultaneously. To support simultaneous audio and BPT streams, we need to use the hda_dma_prepare/cleanup helpers to reserve the pair link host DMA. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
ujfalusi
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.
@bardliao, I think this is a great version!
|
SOFCI TEST |
1 similar comment
|
SOFCI TEST |
Currently, hda_sdw_bpt_dma_prepare() get a HDA stream and use the link DMA but doesn't reserve it. It works fine because
we assume the SwoundWire BPT will not run with audio streams simultaneously. Create and use the new helpers to reserve the link DMA and allow running BTP and audio stream simultaneously.