Skip to contentSkip to conversation

sDMA on i.mx7d

DISCUSSION Alexandre Belloni 5 participants 13 messages Feb 14, 2017 – Feb 20, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

I've been trying to get a PCM3168s codec with a Colibri iMX7 using TDM on SAI2.
I've got it working properly with the 4.1.35 kernel from Toradex (based on the 4.1.15 from Freescale).
It is working fine with and without providing a firmware to the sDMA.

But, I couldn't get that to work with v4.9. I actually managed to reproduce the issue using the SGTL5000 so I don't have any patch on top of v4.9.

I really suspect the DMA driver as the issue varies with the selected period/buffer size.

Basically, the samples in a period are in the correct order but the periods are mixed up.

This is what I'm playing in a loop:
http://free-electrons.com/~alexandre/source.png

This is the output I get:
http://free-electrons.com/~alexandre/playback.png

The configuration for the cyclic transfer seems to be fine and I don't know enough about the sdma to investigate further.
I can try to backport b7d2648ac3d4 "dmaengine: imx-sdma: Add i.MX7 support" to v4.8 and test I you think that can be useful

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#1 lore raw

Hi Alexandre,

Quoted 11 lines · Alexandre Belloni

Hi,

I've been trying to get a PCM3168s codec with a Colibri iMX7 using TDM on SAI2.
I've got it working properly with the 4.1.35 kernel from Toradex (based on the 4.1.15 from Freescale).
It is working fine with and without providing a firmware to the sDMA.

But, I couldn't get that to work with v4.9. I actually managed to reproduce the issue using the SGTL5000 so I don't have any patch on top of v4.9.

I guess you are using the on module SGTL5000 to reproduce?

When I added audio support I remember that the sound seemed to be ok to me. Is the corruption such that you can hear it?

Quoted 6 lines

I really suspect the DMA driver as the issue varies with the selected period/buffer size.

Basically, the samples in a period are in the correct order but the periods are mixed up.

Maybe a endian issue?

Quoted 11 lines

This is what I'm playing in a loop:
http://free-electrons.com/~alexandre/source.png

This is the output I get:
http://free-electrons.com/~alexandre/playback.png

The configuration for the cyclic transfer seems to be fine and I don't know enough about the sdma to investigate further.
I can try to backport b7d2648ac3d4 "dmaengine: imx-sdma: Add i.MX7 support" to v4.8 and test I you think that can be useful

I'll do a test with v4.9 on Colibri iMX7 internal SGTL5000.

--
Stefan

#2 lore raw

Hi Alexandre,

Quoted 11 lines · Stefan Agner

Hi Alexandre,

Quoted 8 lines · Alexandre Belloni

Hi,

I've been trying to get a PCM3168s codec with a Colibri iMX7 using TDM on SAI2.
I've got it working properly with the 4.1.35 kernel from Toradex (based on the 4.1.15 from Freescale).
It is working fine with and without providing a firmware to the sDMA.

Quoted 8 lines
Quoted 3 lines

But, I couldn't get that to work with v4.9. I actually managed to reproduce the issue using the SGTL5000 so I don't have any patch on top of v4.9.

I guess you are using the on module SGTL5000 to reproduce?

When I added audio support I remember that the sound seemed to be ok to me. Is the corruption such that you can hear it?

I haven't noticed this issue on a warp7 board.

Could you please share your .wav files and reproduction steps?

Thanks

#3 lore raw
In reply to Stefan Agner
Quoted 9 lines · Stefan Agner
Quoted 8 lines · Alexandre Belloni

Hi,

I've been trying to get a PCM3168s codec with a Colibri iMX7 using TDM on SAI2.
I've got it working properly with the 4.1.35 kernel from Toradex (based on the 4.1.15 from Freescale).
It is working fine with and without providing a firmware to the sDMA.

Quoted 6 lines
Quoted 3 lines

But, I couldn't get that to work with v4.9. I actually managed to reproduce the issue using the SGTL5000 so I don't have any patch on top of v4.9.

I guess you are using the on module SGTL5000 to reproduce?

Yes, using the on module sgtl5000 of a colibri on an iris.

Quoted 3 lines

When I added audio support I remember that the sound seemed to be ok to me. Is the corruption such that you can hear it?

You can hear it but not if you are playing a simple sine at a frequency that is a multiple of 10 (e.g. 440Hz)

Quoted 8 lines
Quoted 5 lines

I really suspect the DMA driver as the issue varies with the selected period/buffer size.

Basically, the samples in a period are in the correct order but the periods are mixed up.

Maybe a endian issue?

I don't think so.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#4 lore raw
Quoted 17 lines · Alexandre Belloni
Quoted 9 lines · Stefan Agner
Quoted 8 lines · Alexandre Belloni

Hi,

I've been trying to get a PCM3168s codec with a Colibri iMX7 using TDM on SAI2.
I've got it working properly with the 4.1.35 kernel from Toradex (based on the 4.1.15 from Freescale).
It is working fine with and without providing a firmware to the sDMA.

Quoted 6 lines
Quoted 3 lines

But, I couldn't get that to work with v4.9. I actually managed to reproduce the issue using the SGTL5000 so I don't have any patch on top of v4.9.

I guess you are using the on module SGTL5000 to reproduce?

Quoted 9 lines

Yes, using the on module sgtl5000 of a colibri on an iris.

Quoted 3 lines

When I added audio support I remember that the sound seemed to be ok to me. Is the corruption such that you can hear it?

You can hear it but not if you are playing a simple sine at a frequency that is a multiple of 10 (e.g. 440Hz)

Compiled v4.9 and played a song, I could clearly hear constant "noise" during playback.

I went back to my v4.8-rc3 + some patches applied back when I tested audio and submitted the device tree change, and the noise isn't there.

In a "I feel lucky" manor I just reverted the last patch 5881826ded79 ("dmaengine: imx-sdma - update the residue calculation for cyclic channels") and the song sounded clean as always again!

Alexandre, does reverting this helps your issue too?

+Nandor, Author of said patch. Any idea?

--
Stefan

#5 lore raw
Quoted 12 lines · Stefan Agner

Compiled v4.9 and played a song, I could clearly hear constant "noise" during playback.

I went back to my v4.8-rc3 + some patches applied back when I tested audio and submitted the device tree change, and the noise isn't there.

In a "I feel lucky" manor I just reverted the last patch 5881826ded79 ("dmaengine: imx-sdma - update the residue calculation for cyclic channels") and the song sounded clean as always again!

Alexandre, does reverting this helps your issue too?

I confirm it is the culprit.

Quoted 2 lines

+Nandor, Author of said patch. Any idea?

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#6 lore raw

Hi Alexandre,

Quoted 1 line · Alexandre Belloni

I confirm it is the culprit.

Does this mean that PCM3168s codec works fine on imx7 using SAI on 4.9.x plus the revert?

#7 lore raw
Quoted 9 lines · Fabio Estevam

Hi Alexandre,

Quoted 1 line · Alexandre Belloni

I confirm it is the culprit.

Does this mean that PCM3168s codec works fine on imx7 using SAI on 4.9.x plus the revert?

It does work after the revert but the driver needs a small modification to accommodate TDM instead of i2s. I'll send that.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#8 lore raw

Am Donnerstag, den 16.02.2017, 17:40 +0100 schrieb Alexandre Belloni:

Quoted 10 lines · Fabio Estevam
Quoted 9 lines

Hi Alexandre,

Quoted 1 line · Alexandre Belloni

I confirm it is the culprit.

Does this mean that PCM3168s codec works fine on imx7 using SAI on 4.9.x plus the revert?

And there is already a fix for this in 4.10:
85f57752b33c (dmaengine: imx-sdma - correct the dma transfer residue calculation)

This fixes audio output on i.MX6 and should probably be sent to -stable. Can you see if applying this patch gets rid of the issues on i.MX7?

Regards,
Lucas

#9 lore raw
Quoted 12 lines · Lucas Stach

Am Donnerstag, den 16.02.2017, 17:40 +0100 schrieb Alexandre Belloni:

Quoted 10 lines · Fabio Estevam
Quoted 9 lines

Hi Alexandre,

Quoted 1 line · Alexandre Belloni

I confirm it is the culprit.

Does this mean that PCM3168s codec works fine on imx7 using SAI on 4.9.x plus the revert?

Quoted 7 lines

And there is already a fix for this in 4.10:
85f57752b33c (dmaengine: imx-sdma - correct the dma transfer residue calculation)

This fixes audio output on i.MX6 and should probably be sent to -stable. Can you see if applying this patch gets rid of the issues on i.MX7?

It does too, thanks!
It is probably worth having it on 4.9.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#10 lore raw

EXT: Re: sDMA on i.mx7d

Quoted 17 lines · Alexandre Belloni
Quoted 16 lines · Lucas Stach

Am Donnerstag, den 16.02.2017, 17:40 +0100 schrieb Alexandre Belloni:

Quoted 10 lines · Fabio Estevam
Quoted 9 lines

Hi Alexandre,

Quoted 1 line · Alexandre Belloni

I confirm it is the culprit.

Does this mean that PCM3168s codec works fine on imx7 using SAI on 4.9.x plus the revert?

And there is already a fix for this in 4.10:
85f57752b33c (dmaengine: imx-sdma - correct the dma transfer residue calculation)

Quoted 7 lines
Quoted 3 lines

This fixes audio output on i.MX6 and should probably be sent to -stable. Can you see if applying this patch gets rid of the issues on i.MX7?

It does too, thanks!
It is probably worth having it on 4.9.

Hi,
Thanks for mention the problem and confirm that the above patch fixed
the issue.

I'm a bit surprised about the issue that Stefan mention, which in his case was a "noise". In my case was more like a sound interruption (I was testing on a iMX6).

But good to hear that works :)

Regards,
Nandor

Signature · 2 lines
Regards,
     Nandi
#11 lore raw

EXT: Re: sDMA on i.mx7d

Nandor,

Quoted 9 lines · Nandor (GE Healthcare)

Hi,
Thanks for mention the problem and confirm that the above patch fixed the
issue.

I'm a bit surprised about the issue that Stefan mention, which in his case was a "noise". In my case was more like a sound interruption (I was testing on a iMX6).

But good to hear that works :)

As 4.9 is broken, could you please submit the fix to kernel 4.9 and Cc stable?

#12 lore raw

EXT: Re: sDMA on i.mx7d

Quoted 9 lines · Fabio Estevam

Nandor,

Quoted 4 lines · Nandor (GE Healthcare)

Hi,
Thanks for mention the problem and confirm that the above patch fixed the
issue.

Quoted 8 lines
Quoted 5 lines

I'm a bit surprised about the issue that Stefan mention, which in his case was a "noise". In my case was more like a sound interruption (I was testing on a iMX6).

But good to hear that works :)

As 4.9 is broken, could you please submit the fix to kernel 4.9 and Cc stable?

Fabio,
I will try to send it ASAP when I find some free time (I will try
this week)

Signature · 2 lines
Regards,
     Nandi