* [PATCH] ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers
@ 2024-11-07 12:15 Peter Ujfalusi
2024-11-07 15:23 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2024-11-07 12:15 UTC (permalink / raw)
To: lgirdwood, broonie
Cc: linux-sound, kai.vehmanen, ranjani.sridharan, yung-chuan.liao,
pierre-louis.bossart, liam.r.girdwood
The HDA specification states that the SDnLVI (Last Valid Index) must be at
least 1 (two BDLE entry).
Update the debug prints as well to provide better information.
While the LVI=0 worked so far without issues, it is better to align with
the specification to avoid unforeseen issues with FW loading.
Notes:
- The LVI > 0 rules is valid and honored for audio use cases
- LVI == 0 is used with software controlled (SPIB) transfers only for
firmware and library loading, which is permitted by the hardware
- This is not spelled out in the specification and it is better to avoid
cases
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
sound/soc/sof/intel/hda-stream.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index 3ac63ce67ab1..519bafd3b947 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -119,13 +119,39 @@ int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
int remain, ioc;
period_bytes = hstream->period_bytes;
- dev_dbg(sdev->dev, "period_bytes:0x%x\n", period_bytes);
- if (!period_bytes)
+ dev_dbg(sdev->dev, "period_bytes: %#x, bufsize: %#x\n", period_bytes,
+ hstream->bufsize);
+
+ if (!period_bytes) {
+ unsigned int chunk_size;
+
+ chunk_size = snd_sgbuf_get_chunk_size(dmab, 0, hstream->bufsize);
+
period_bytes = hstream->bufsize;
+ /*
+ * HDA spec demands that the LVI value must be at least one
+ * before the DMA operation can begin. This means that there
+ * must be at least two BDLE present for the transfer.
+ *
+ * If the buffer is not a single continuous area then the
+ * hda_setup_bdle() will create multiple BDLEs for each segment.
+ * If the memory is a single continuous area, force it to be
+ * split into two 'periods', otherwise the transfer will be
+ * split to multiple BDLE for each chunk in hda_setup_bdle()
+ *
+ * Note: period_bytes == 0 can only happen for firmware or
+ * library loading. The data size is 4K aligned, which ensures
+ * that the second chunk's start address will be 128-byte
+ * aligned.
+ */
+ if (chunk_size == hstream->bufsize)
+ period_bytes /= 2;
+ }
+
periods = hstream->bufsize / period_bytes;
- dev_dbg(sdev->dev, "periods:%d\n", periods);
+ dev_dbg(sdev->dev, "periods: %d\n", periods);
remain = hstream->bufsize % period_bytes;
if (remain)
--
2.47.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers
2024-11-07 12:15 [PATCH] ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers Peter Ujfalusi
@ 2024-11-07 15:23 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-11-07 15:23 UTC (permalink / raw)
To: lgirdwood, Peter Ujfalusi
Cc: linux-sound, kai.vehmanen, ranjani.sridharan, yung-chuan.liao,
pierre-louis.bossart, liam.r.girdwood
On Thu, 07 Nov 2024 14:15:32 +0200, Peter Ujfalusi wrote:
> The HDA specification states that the SDnLVI (Last Valid Index) must be at
> least 1 (two BDLE entry).
>
> Update the debug prints as well to provide better information.
>
> While the LVI=0 worked so far without issues, it is better to align with
> the specification to avoid unforeseen issues with FW loading.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers
commit: 1b1f491dac4f6ee88ec7c36c4fd27880b0a89f41
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-07 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 12:15 [PATCH] ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers Peter Ujfalusi
2024-11-07 15:23 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox