linux icon indicating copy to clipboard operation
linux copied to clipboard

Chain dma support

Open jsarha opened this issue 3 years ago • 30 comments

Its probably worth squashing this up a bit, especially now that I had to mangle Ranjani's commit quite a bit when solving sof-dev rebase conflicts. But maybe this is easier to review in pieces.

Both 16- and 32-bit audio works with this PR, but getting 44.1kHz need still some more work.

jsarha avatar Oct 24 '22 19:10 jsarha

Could you give a full picture of solution ? How to use chain dma ? How to support in topology ? How does driver do to cooperate with topology?

RanderWang avatar Oct 25 '22 00:10 RanderWang

@jsarha can you please squash the relevant patches and add descriptions? It is very hard to review it like this.

Also, IPC4 test fails spectacularly. So something is not right.

ranj063 avatar Oct 25 '22 03:10 ranj063

Here is the squashed up version, but there is still something severely wrong with normal playback, and I am in the middle of debugging it.

jsarha avatar Oct 25 '22 15:10 jsarha

All the issues found in the review are not yet addressed, but pushed the branch again to trigger CI tests to see if the nocodec problems persist.

jsarha avatar Oct 27 '22 10:10 jsarha

I don't understand why details links lead to 404. Maybe another push will help. There is some more fixes this time too. I think this is the last unresolved issue: https://github.com/thesofproject/linux/pull/3953#discussion_r1005856837

jsarha avatar Oct 27 '22 15:10 jsarha

I don't understand why details links lead to 404. Maybe another push will help. There is some more fixes this time too. I think this is the last unresolved issue: #3953 (comment)

01.org is down. Can you check the internal link @jsarha

ranj063 avatar Oct 27 '22 15:10 ranj063

Hmm, now that I tested this latest change a bit, it does not appear to work as it should. hw:0,0 does not work any more.

jsarha avatar Oct 31 '22 21:10 jsarha

The first patch was updated and now this appears to work Ok.

jsarha avatar Nov 01 '22 10:11 jsarha

Addressed the last comment, but there is conflicts now... rebasing.

jsarha avatar Nov 01 '22 15:11 jsarha

Yesterdays version now pushed again with @plbossart 's suggestions for descriptions and after a rather painful rebase. I am currently looking at how to add codec side format constraints to a chained dma pcm.

jsarha avatar Nov 02 '22 15:11 jsarha

Updated to work with this latest sof topology pr: https://github.com/thesofproject/sof/pull/6524

jsarha avatar Nov 03 '22 17:11 jsarha

Mostly editorial review. The only open I have is how the codec DAI limitation is handled, if at all?

Since this feature is enabled through topology, would it be enough to code the codec dai limitations there too? I think I could dig the hda dai limitations and apply them as constraints to sof pcm when chained dma is in use, but is that really necessary?

jsarha avatar Nov 07 '22 14:11 jsarha

Mostly editorial review. The only open I have is how the codec DAI limitation is handled, if at all?

Since this feature is enabled through topology, would it be enough to code the codec dai limitations there too? I think I could dig the hda dai limitations and apply them as constraints to sof pcm when chained dma is in use, but is that really necessary?

In general anything tied to hardware codec support cannot be part of the topology.

That said you bring-up an interesting point @jsarha. It turns out that the only codec DAI limitation is the 'sig_bits', but those are fixed in sound/soc/codecs/hdac_hda.c. I thought there were determined based on codec capabilities. @kv2019i do you think we could simplify all this, or get the values from the codec directly?

static struct snd_soc_dai_driver hdac_hda_dais[] = {
{
	.id = HDAC_ANALOG_DAI_ID,
	.name = "Analog Codec DAI",
	.ops = &hdac_hda_dai_ops,
	.playback = {
		.stream_name	= "Analog Codec Playback",
		.channels_min	= 1,
		.channels_max	= 16,
		.rates		= SNDRV_PCM_RATE_8000_192000,
		.formats	= STUB_FORMATS,
		.sig_bits	= 24,
	},
	.capture = {
		.stream_name    = "Analog Codec Capture",
		.channels_min   = 1,
		.channels_max   = 16,
		.rates = SNDRV_PCM_RATE_8000_192000,
		.formats = STUB_FORMATS,
		.sig_bits = 24,
	},
},

Adding @ranj063 and @ujfalusi since we have the same codec dai issue for the abstraction and dsp-less PRs.

Edit: in the AVS driver, the DAI information is created dynamically based on codec information, see https://github.com/thesofproject/linux/blob/551c11c310acbe5a6636a1eecedc5c762f407222/sound/soc/codecs/hda.c#L55

                stream->channels_min = pcm->stream[dir].channels_min;
		stream->channels_max = pcm->stream[dir].channels_max;
		stream->rates = pcm->stream[dir].rates;
		stream->formats = pcm->stream[dir].formats;
		stream->sig_bits = pcm->stream[dir].maxbps;

plbossart avatar Nov 07 '22 14:11 plbossart

On more round of applied review fixes, while waiting for https://github.com/thesofproject/linux/pull/3972 to get ready. The sig_bits are still not copied from codec side, but that should not make big functional difference. I'll see if I get it done before #3972 and this is merged , if not I'll do it as a separate PR.

jsarha avatar Nov 09 '22 21:11 jsarha

Latest changes: Make sure the tplg is using use_chain_dma correctly. I keep the loop in sof_ipc4_trigger_pipelines() and then add a check in sof_ipc4_chain_dma_trigger() that all elements in list have the attribute, since that is a requirement for the feature to work. Also improve comments in both places.

jsarha avatar Nov 10 '22 16:11 jsarha

Only the 0xffffffff => SOF_IPC4_INVALID_NODE_ID change.

jsarha avatar Nov 14 '22 16:11 jsarha

Addressed @plbossart 's comments and changed -ENOTSUPP to -ENODEV due to checkpatch error:

WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP #313: FILE: sound/soc/sof/ipc4-topology.c:528:

  •           ret = -ENOTSUPP;
    

jsarha avatar Nov 15 '22 15:11 jsarha

Addressed @plbossart 's comments and changed -ENOTSUPP to -ENODEV due to checkpatch error:

WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP #313: FILE: sound/soc/sof/ipc4-topology.c:528:

  •           ret = -ENOTSUPP;
    

oh, that one you can ignore @jsarha. There is no consensus in maintainer circles on this checkpatch warning so we keep using ENOTSUPP

if it is confusing it's because it is.

plbossart avatar Nov 15 '22 15:11 plbossart

oh, that one you can ignore @jsarha. There is no consensus in maintainer circles on this checkpatch warning so we keep using ENOTSUPP

if it is confusing it's because it is.

I do not think there is any pressing need to use ENOTSUPP either, should I still revert back to ENOTSUPP from ENODEV?

jsarha avatar Nov 15 '22 15:11 jsarha

I have also rebased this PR on top of #3972 if it is merged first.

jsarha avatar Nov 16 '22 12:11 jsarha

@plbossart here is the version that is rebased on top of the latest #3972 : https://github.com/jsarha/linux-sof/pull/new/chain_dma-on_top_of_3972

The only place that looks different to current version of this PR is hda-dai.c and hda-dai-ops.c. I also tested with the rebased PR that playback survives susped-resume cycle when playing and when paused.

jsarha avatar Nov 17 '22 17:11 jsarha

Now the PR is rebased on top of #3972 , so please ignore everything else but the three last commits.

jsarha avatar Nov 17 '22 17:11 jsarha

@plbossart 's comments addressed.

jsarha avatar Nov 17 '22 20:11 jsarha

Some typo and wording fixes applied, end removed one bad fix. Now it works again 😅.

jsarha avatar Nov 17 '22 21:11 jsarha

https://github.com/thesofproject/linux/pull/3972 is merged, please rebase @jsarha. Should be straightforward.

plbossart avatar Nov 18 '22 00:11 plbossart

Rebased on top of the latest sof-dev, fixed couple of typos more, and the checkpatch issue I added last night. Should be good now, please approve @ujfalusi , @ranj063 , @plbossart !

jsarha avatar Nov 18 '22 09:11 jsarha

Addressed @RanderWang 's comment and while at it moved the pipe_widget and pipeline variables down in scope.

jsarha avatar Nov 18 '22 10:11 jsarha

@plbossart @jsarha please don't merge this PR. HDA device with chained DMA has a lot of failures

ranj063 avatar Nov 18 '22 15:11 ranj063

@jsarha the fixes for SOF firmware failures are in https://github.com/thesofproject/linux/pull/4030

ranj063 avatar Nov 19 '22 02:11 ranj063

The problem was SOF FW being sensitive about fifo_size field being present in the message. I developed the whole time against cavs and forgot to test against SOF too. The problem should now be fixed. The changes lie in sof_ipc4_chain_dma_trigger() and in sof_ipc4_chain_dma_send_msg(). @ujfalusi , @ranj063 , @plbossart , and @RanderWang , please review again.

jsarha avatar Nov 20 '22 21:11 jsarha