Skip to content

lib: dma: simplify DMAC search and fix users to max channels - #687

Merged
lgirdwood merged 1 commit into
masterfrom
lrg/topic/dma_fixes
Dec 17, 2018
Merged

lgirdwood merged 1 commit into
masterfrom
lrg/topic/dma_fixes

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Currently the dai user only increments the DMA channel usage count on
channel start and decrements on stop. This doesn't align with the current
DMAC allocator so ensure that the DMAC allocator cannot over subscribe
a DMAC with more users than channels. i.e. DAI config will try and allocate
a channel and fail if over subscribed.

This needs to be revisisted with changes to DAI to allow over subscription.

Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com

Currently the dai user only increments the DMA channel usage count on
channel start and decrements on stop. This doesn't align with the current
DMAC allocator so ensure that the DMAC allocator cannot over subscribe
a DMAC with more users than channels. i.e. DAI config will try and allocate
a channel and fail if over subscribed.

This needs to be revisisted with changes to DAI to allow over subscription.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
lgirdwood requested a review from libinyang as a code owner December 7, 2018 21:14

@libinyang libinyang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the sof code, host and dai will comsume a lot of dma channels. Only dai will get dma channels in initialization and host doesn't.

For byt, there are only 2 dmacs.
For apl-like, there are 2 GPDMA which has 8 channels for each; one host-in DMAC which has 7 channels; one host-out DMAC which has 6 or 9 channels. one link-in DMAC which has 8 or 9 channels; one link-out DMAC which has 8 or 7 channels.

This patch will introduce the new limitation for host components. If pipelines are more than the host dma for apl, it will not work. (GPDMA channel number is 8 for dai, while host dma channel number is 6 for host component. So it will definitely no dmac for host). For byt, both host and dai will use GPDMA, if pipelines are more than 8, it will use 2x8 DMA channels and it will complain no channels.

@lgirdwood

Copy link
Copy Markdown
Member Author

@libinyang there is already a limitation on each DMAC today with the generic DAI driver which grabs a DMA channel on every call to DAI config (even if the DAI is never used). This needs rework later after 0.3 release, but this change today only limits the number of users to the number of channels (otherwise some nocodec topologies will not load)..

As far as pipelines that over commit the host DMA channels then these are not supported since they cannot be guaranteed to run concurrently. They are mutually exclusive by design and hence will result in new errors being propagated up the stack.

@libinyang

Copy link
Copy Markdown
Contributor

@lgirdwood
Yes, this is why we need such patch.
However, this patch is changing dma_get() which is a very general function. It will impact on all DMACs for all kinds of dma_get(). For example, if we try to get host dma on APL, it will increase the count. But the host dma channel is not enough for all pipelines. So APL will fail with this patch.
I test your patch on APL nocodec, it will cause sof audio driver initialization failing when init host. The log are:
0 1 DMA 97044.218750 97044.218750 dma.c:100 No DMAC dir 2 caps 0x0 dev 0x1 flags 0x0
0 1 DMA 97051.145833 6.927083 dma.c:106 DMAC ID 0 users 8 busy channels 0
0 1 DMA 97057.031250 5.885417 dma.c:108 caps 0x2 dev 0xc
0 1 DMA 97062.343750 5.312500 dma.c:106 DMAC ID 1 users 2 busy channels 0
0 1 DMA 97068.072917 5.729167 dma.c:108 caps 0x2 dev 0xc
0 1 DMA 97073.385417 5.312500 dma.c:106 DMAC ID 4 users 6 busy channels 1
0 1 DMA 97079.166667 5.781250 dma.c:108 caps 0x1 dev 0x1
0 1 DMA 97084.375000 5.208333 dma.c:106 DMAC ID 5 users 6 busy channels 0
0 1 DMA 97090.156250 5.781250 dma.c:108 caps 0x1 dev 0x1
0 1 DMA 97095.364583 5.208333 dma.c:106 DMAC ID 6 users 0 busy channels 0
0 1 DMA 97101.145833 5.781250 dma.c:108 caps 0x1 dev 0x2
0 1 DMA 97106.510417 5.364583 dma.c:106 DMAC ID 7 users 0 busy channels 0
0 1 DMA 97112.135417 5.625000 dma.c:108 caps 0x1 dev 0x2
0 1 HOST 97117.604167 5.468750 host.c:365 eDM
0 1 COMP 97127.447917 9.843750 component.c:89 eCN
0 1 IPC 97131.822917 4.375000 ipc.c:119 eCn
0 1 IPC 97136.406250 4.583333 handler.c:837 ipc: pipe 11 comp 60 creation failed -22

-               if (d->sref >= d->plat_data.channels)
+               if (d->sref >= d->plat_data.channels && dev != DMA_DEV_HOST)

can fix this issue. But I believe this fix is still not enough on byt platform as host dma and dai dma are using GPDMA together.

@lgirdwood

lgirdwood commented Dec 11, 2018 •

Copy link
Copy Markdown
Member Author

Yes, this is why we need such patch.
However, this patch is changing dma_get() which is a very general function. It will impact on all DMACs for all kinds of dma_get(). For example, if we try to get host dma on APL, it will increase the count.

This is the intention.

But the host dma channel is not enough for all pipelines.

Pipelines must not over commit DMAC channels as playback is not guaranteed for any pipeline in this case.

So APL will fail with this patch.
I test your patch on APL nocodec, it will cause sof audio driver initialization failing when init host. The log are:
0 1 DMA 97044.218750 97044.218750 dma.c:100 No DMAC dir 2 caps 0x0 dev 0x1 flags 0x0
0 1 DMA 97051.145833 6.927083 dma.c:106 DMAC ID 0 users 8 busy channels 0
0 1 DMA 97057.031250 5.885417 dma.c:108 caps 0x2 dev 0xc
0 1 DMA 97062.343750 5.312500 dma.c:106 DMAC ID 1 users 2 busy channels 0
0 1 DMA 97068.072917 5.729167 dma.c:108 caps 0x2 dev 0xc
0 1 DMA 97073.385417 5.312500 dma.c:106 DMAC ID 4 users 6 busy channels 1
0 1 DMA 97079.166667 5.781250 dma.c:108 caps 0x1 dev 0x1
0 1 DMA 97084.375000 5.208333 dma.c:106 DMAC ID 5 users 6 busy channels 0
0 1 DMA 97090.156250 5.781250 dma.c:108 caps 0x1 dev 0x1
0 1 DMA 97095.364583 5.208333 dma.c:106 DMAC ID 6 users 0 busy channels 0
0 1 DMA 97101.145833 5.781250 dma.c:108 caps 0x1 dev 0x2
0 1 DMA 97106.510417 5.364583 dma.c:106 DMAC ID 7 users 0 busy channels 0
0 1 DMA 97112.135417 5.625000 dma.c:108 caps 0x1 dev 0x2
0 1 HOST 97117.604167 5.468750 host.c:365 eDM
0 1 COMP 97127.447917 9.843750 component.c:89 eCN
0 1 IPC 97131.822917 4.375000 ipc.c:119 eCn
0 1 IPC 97136.406250 4.583333 handler.c:837 ipc: pipe 11 comp 60 creation failed -22

So topology here is broken or someone is asking for multiple channels.... either way a bug.

@libinyang

Copy link
Copy Markdown
Contributor

@lgirdwood
If Pipelines doesn't over commit DMAC channels, link dma channel is not enough in some cases. On APL there is only 6 DMA channels for host dma.

@lgirdwood

Copy link
Copy Markdown
Member Author

If Pipelines doesn't over commit DMAC channels, link dma channel is not enough in some cases. On APL there is only 6 DMA channels for host dma.

Then the topology is broken for that platform. Which topologies do you mean ?

@libinyang

Copy link
Copy Markdown
Contributor

Then the topology is broken for that platform. Which topologies do you mean ?

@lgirdwood I'm using sof-apl-nocodec.tplg to test

@lgirdwood
lgirdwood merged commit ba4054b into master Dec 17, 2018
@lgirdwood
lgirdwood deleted the lrg/topic/dma_fixes branch December 17, 2018 21:07
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