Skip to content

Conversation

@bardliao
Copy link
Collaborator

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.

Copy link
Collaborator

@ujfalusi ujfalusi left a 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.

goto out_put;
}

hstream->period_bytes = 0;/* initialize period_bytes */
Copy link
Collaborator

Choose a reason for hiding this comment

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

space before the comment

Copy link
Collaborator

Choose a reason for hiding this comment

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

not resolved yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed


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);
Copy link
Collaborator

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.

struct hdac_ext_stream *hext_stream)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
struct hdac_stream *hstream = &hext_stream->hstream;
Copy link
Collaborator

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?

hstream->bufsize = 0;
hstream->format_val = 0;
out_put:
hda_dsp_stream_put(sdev, direction, hstream->stream_tag);
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

}
EXPORT_SYMBOL_NS(hda_dsp_get_stream_ldp, "SND_SOC_SOF_INTEL_HDA_COMMON");

struct hdac_ext_stream*
Copy link
Collaborator

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()

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

missing space still?

Copy link
Collaborator Author

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.


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)
Copy link
Collaborator

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?

@kv2019i, @ranj063, what do you think?

Copy link
Collaborator Author

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.

struct hdac_ext_stream *hext_stream = _hda_dsp_stream_get(sdev, direction, flags, true);

if (hext_stream)
hext_stream->link_locked = true;
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

return sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0);
}

static struct hdac_ext_stream *
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

}

static struct hdac_ext_stream *
hda_sdw_prepare(struct device *dev, unsigned int format, unsigned int size,
Copy link
Collaborator

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?

Copy link
Collaborator Author

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>
goto out_put;
}

hstream->period_bytes = 0;/* initialize period_bytes */
Copy link
Collaborator

Choose a reason for hiding this comment

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

not resolved yet

}
EXPORT_SYMBOL_NS(hda_dsp_get_stream_ldp, "SND_SOC_SOF_INTEL_HDA_COMMON");

struct hdac_ext_stream*
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing space still?

Copy link
Collaborator

@ujfalusi ujfalusi left a comment

Choose a reason for hiding this comment

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

only few nitpicks..

hext_stream = hda_dsp_stream_get(sdev, direction, 0);

if (!hext_stream) {
dev_err(sdev->dev, "error: no stream available\n");
Copy link
Collaborator

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

} 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);
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

ranj063
ranj063 previously approved these changes Nov 5, 2025
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)
Copy link
Collaborator

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)

Copy link
Collaborator Author

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

Copy link
Collaborator

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()
?

Copy link
Collaborator Author

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>
Copy link
Collaborator

@ujfalusi ujfalusi left a 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!

@bardliao bardliao requested a review from ranj063 November 12, 2025 07:45
@bardliao
Copy link
Collaborator Author

SOFCI TEST

1 similar comment
@bardliao
Copy link
Collaborator Author

SOFCI TEST

@bardliao bardliao merged commit 964c624 into thesofproject:topic/sof-dev Nov 14, 2025
9 of 16 checks passed
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.

3 participants