-
Notifications
You must be signed in to change notification settings - Fork 130
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: hda-stream: Always use at least two BDLE for transfers #5181
ASoC: SOF: Intel: hda-stream: Always use at least two BDLE for transfers #5181
Conversation
sound/soc/sof/intel/hda-stream.c
Outdated
if (!period_bytes) | ||
period_bytes = hstream->bufsize; | ||
period_bytes = hstream->bufsize / 2; |
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.
Sorry, I didn't get the relationship between the comment and the change. Why do we change period_bytes from hstream->bufsize to hstream->bufsize / 2?
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.
because then there'll be 2 period each of size bufsize/2
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 for the explanation. I got it now.
fff0164
to
448843a
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.
No objection on enforcing the two BDLE for audio streams, but I don't think we have any configurations where this isn't the case already?
This doesn't look like a fix to me, more a constraint in case a topology file is not correct.
|
||
periods = hstream->bufsize / period_bytes; | ||
|
||
dev_dbg(sdev->dev, "periods:%d\n", periods); | ||
dev_dbg(sdev->dev, "periods: %d\n", periods); |
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 commit message says
"
While the LVI=0 worked so far without issues, it is better to align with
the specification to avoid unforeseen issues with FW loading.
"
But there are no issues with FW loading that are fixed by this commit.
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.
That is true, LVI=0 worked correctly but the specification explicitly saying that LVI must be at least 1 for the DMA to start.
We don't really know why LVI=0 but it cannot be take granted as it is against the spec.
It could be that SPIB changes the rules to allow LVI=0, but it is not documented afaik.
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.
SPIB will definitively prevent the DMA from continuing, so and since we use SPIB for firmware download I really don't see what this fixes.
We've been using this for over 10 years now, if it was wrong we would have detected it, no?
I think the risk of splitting firmware downloads in two chunks offsets the unproven benefit of fixing a hypothetical problem.
wow this almost sounds like fridge poetry haha.
sound/soc/sof/intel/hda-stream.c
Outdated
* HDA spec demands at least two 'periods' for the DMA to work correctly | ||
* Note: period_bytes == 0 can only happen for firmware or library | ||
* loading, the binary sizes have the necessary alignment requirements | ||
* met |
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.
what alignment requirements are you referring to?
The only requirement for HDaudio DMA is that the start address be aligned on 128 bytes. The size can be arbitrary.
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.
Right, I need to move parts of the comment with the new change where I force two periods to get two BLDEs.
The comment tries to say that the firmware size is such that if we split it to two (and it is in a continuous area) then the second chunk will have start address 128-byte align as well.
*/ | ||
if (chunk_size == hstream->bufsize) | ||
period_bytes /= 2; | ||
} |
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 other open I have is that the number of periods comes from topology, and I don't think we've ever had a solution with a single period.
So the question is: what does this commit actually fix?
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.
With audio we always have at least two periods. The only case when we don't is the firmware and library loading.
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.
Hrm, we could have periods_min set to 1... Interesting, that will not work for sure.
This patch only handles the firmware/library loading (when hstream->period_bytes is set to 0).
PCM with periods=1 cannot work...
448843a
to
316650f
Compare
Changes since v2:
|
Moving back from draft as I got confirmation that LVI=0 is invalid regardless of SPIB use. It is working by 'luck', LVI=0 has not been validated with any version of HDA by hw validation teams. |
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 Just typos, no other issues found.
sound/soc/sof/intel/hda-stream.c
Outdated
* 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 are then the |
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.
s/are/area/
sound/soc/sof/intel/hda-stream.c
Outdated
* must be at least two BDLE present for the transfer. | ||
* | ||
* If the buffer is not a single continuous are then the | ||
* hda_setup_bdle() will create multiple BLDEs for each segment. |
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.
s/BLDE/BDLE/
316650f
to
7a72c99
Compare
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>
Changes since v3:
|
The HDA specification states that the SDnLVI (Last Valid Index) must be at least 1 (two BDLE entry).
While the LVI=0 worked so far without issues, it is better to align with the specification to avoid unforeseen issues with FW loading.