All of lore.kernel.org
 help / color / mirror / Atom feed
From: voice.shen@atmel.com (Bo Shen)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
Date: Fri, 5 Jul 2013 09:25:08 +0800	[thread overview]
Message-ID: <51D62074.9070303@atmel.com> (raw)
In-Reply-To: <CACQ1gAio0ekQMgyfrLjTHmMPGJQoKoe61GreFQDN-iLjxbLQ0w@mail.gmail.com>

Hi Richard,

On 7/4/2013 21:44, Richard Genoud wrote:
> 2013/7/4 Bo Shen <voice.shen@atmel.com>:
>> Hi Richard,
>>
>>
>> On 7/3/2013 23:51, Richard Genoud wrote:
>>>>
>>>>> but there's a violent hang (kernel stops, no trace) when I try the
>>>>> record :
>>>>> arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav
>>>>> last thing I see is :
>>>>> dma dma0chan3: atc_control (3)
>>
>>
>> I don't meet this issue. Playback and recording works well on my side on
>> at91sam9g35ek board.
>>
>>
>>>>> I'll try to trace that.
>>>
>>> I think it's DMA related.
>>> the last thing done by the kernel is:
>>>    i2c i2c-0: i2c_outb: 0x34 A
>>>    i2c i2c-0: i2c_outb: 0x0c A
>>>    i2c i2c-0: i2c_outb: 0x5a A
>>> meaning: enable power on, LINE IN, ADC, OSC, on the WM8731
>>> so, after that, data is comming from the codec to the SSC and then is
>>> handled by the DMA.
>>> there must be something nasty on the DMA bus to hang everything like
>>> that...
>>
>>
>> Will you try i2c without DMA support to test this issue?
>
> Ok, I nailed it !
>
> To be sure we are on the same base, here is what I have done:
> onto next-20130704:
> - your 5 patches:
> ASoC: atmel_ssc_dai: move set dma data to startup callback
> ASoC: atmel_ssc_dai: add error mask define
> ASoC: atmel-pcm-dma: move prepare for dma to dai prepare
> ARM: atmel-ssc: change phybase type to dma_addr_t
> ASoC: atmel-pcm: use generic dmaengine framework
> - my patches 4-8:
> ARM: at91: DTS: sam9x5: add SSC DMA parameters
> ARM: AT91: DTS: sam9x5ek: add WM8731 codec
> ARM: AT91: DTS: sam9x5ek: add sound configuration
> ARM: AT91: DTS: sam9x5ek: enable SSC
> sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
>
> To be sure that dma-I2c doesn't disturb something, I use i2c gpio bitbang:
> diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi
> b/arch/arm/boot/dts/at91sam9x5ek.dtsi
> index 6684d4b..53a991e 100644
> --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi
> @@ -57,15 +57,6 @@
>   				status = "okay";
>   			};
>
> -			i2c0: i2c at f8010000 {
> -				status = "okay";
> -
> -				wm8731: wm8731 at 1a {
> -					compatible = "wm8731";
> -					reg = <0x1a>;
> -				};
> -			};
> -
>   			pinctrl at fffff400 {
>   				mmc0 {
>   					pinctrl_board_mmc0: mmc0-board {
> @@ -114,6 +105,15 @@
>   		};
>   	};
>
> +	i2c at 0 {
> +		status = "okay";
> +
> +		wm8731: wm8731 at 1a {
> +			compatible = "wm8731";
> +			reg = <0x1a>;
> +		};
> +	};
> +
>   	sound {
>   		compatible = "atmel,sam9x5-audio-wm8731";
>
> with that configuration, it hangs when I do a:
> arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav
>
> Now, if I remove the overrun error on ssc in rx_mask:
> diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
> index 0ecf356..c04e825 100644
> --- a/sound/soc/atmel/atmel_ssc_dai.c
> +++ b/sound/soc/atmel/atmel_ssc_dai.c
> @@ -83,7 +83,6 @@ static struct atmel_ssc_mask ssc_rx_mask = {
>   	.ssc_disable	= SSC_BIT(CR_RXDIS),
>   	.ssc_endx	= SSC_BIT(SR_ENDRX),
>   	.ssc_endbuf	= SSC_BIT(SR_RXBUFF),
> -	.ssc_error	= SSC_BIT(SR_OVRUN),
>   	.pdc_enable	= ATMEL_PDC_RXTEN,
>   	.pdc_disable	= ATMEL_PDC_RXTDIS,
>   };
>
> It doesn't hang any more doing a simple record.
> BUT it still hangs if we do record and play at the same time.
>
> Removing the overrun on tx_mask prevent the hang:
> diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
> index 0ecf356..41e15c2 100644
> --- a/sound/soc/atmel/atmel_ssc_dai.c
> +++ b/sound/soc/atmel/atmel_ssc_dai.c
> @@ -73,7 +73,6 @@ static struct atmel_ssc_mask ssc_tx_mask = {
>   	.ssc_disable	= SSC_BIT(CR_TXDIS),
>   	.ssc_endx	= SSC_BIT(SR_ENDTX),
>   	.ssc_endbuf	= SSC_BIT(SR_TXBUFE),
> -	.ssc_error	= SSC_BIT(SR_OVRUN),
>   	.pdc_enable	= ATMEL_PDC_TXTEN,
>   	.pdc_disable	= ATMEL_PDC_TXTDIS,
>   };
>
> i.e. when I revert "ASoC: atmel_ssc_dai: add error mask define", I
> don't see any hang.
>
> Could you test and confirm that behaviour please ?

Yes, I aware this issue.
Actually the system not hang, the resource all are occupied by the 
interrupt. This because, we enable the interrupt, when once interrupt 
occur, I try many methods to clear it, however we can not clear it. So, 
it generates the interrupt all the time. It seems the system hang.

Temp solution: not enable the interrupt. use the following patch to 
disable the interrupt.
---8>---
diff --git a/sound/soc/atmel/atmel_ssc_dai.c 
b/sound/soc/atmel/atmel_ssc_dai.c
index 0ecf356..bb53dea 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -649,7 +649,7 @@ static int atmel_ssc_prepare(struct 
snd_pcm_substream *substream,
         dma_params = ssc_p->dma_params[dir];

         ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
-       ssc_writel(ssc_p->ssc->regs, IER, dma_params->mask->ssc_error);
+       ssc_writel(ssc_p->ssc->regs, IDR, dma_params->mask->ssc_error);

         pr_debug("%s enabled SSC_SR=0x%08x\n",
                         dir ? "receive" : "transmit",
---<8---

BTW, I am checking this with our IP team, if find the real solution, I 
will fix it.

> I attached a the (simple) .config I used for the tests.
>
> PS: I hope the patches won't be mangled by gmail...
>
> Best regards,
> Richard.

Best Regards,
Bo Shen

WARNING: multiple messages have this Message-ID (diff)
From: Bo Shen <voice.shen@atmel.com>
To: Richard Genoud <richard.genoud@gmail.com>
Cc: devicetree-discuss@lists.ozlabs.org,
	"Nicolas Ferre" <nicolas.ferre@atmel.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support
Date: Fri, 5 Jul 2013 09:25:08 +0800	[thread overview]
Message-ID: <51D62074.9070303@atmel.com> (raw)
In-Reply-To: <CACQ1gAio0ekQMgyfrLjTHmMPGJQoKoe61GreFQDN-iLjxbLQ0w@mail.gmail.com>

Hi Richard,

On 7/4/2013 21:44, Richard Genoud wrote:
> 2013/7/4 Bo Shen <voice.shen@atmel.com>:
>> Hi Richard,
>>
>>
>> On 7/3/2013 23:51, Richard Genoud wrote:
>>>>
>>>>> but there's a violent hang (kernel stops, no trace) when I try the
>>>>> record :
>>>>> arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav
>>>>> last thing I see is :
>>>>> dma dma0chan3: atc_control (3)
>>
>>
>> I don't meet this issue. Playback and recording works well on my side on
>> at91sam9g35ek board.
>>
>>
>>>>> I'll try to trace that.
>>>
>>> I think it's DMA related.
>>> the last thing done by the kernel is:
>>>    i2c i2c-0: i2c_outb: 0x34 A
>>>    i2c i2c-0: i2c_outb: 0x0c A
>>>    i2c i2c-0: i2c_outb: 0x5a A
>>> meaning: enable power on, LINE IN, ADC, OSC, on the WM8731
>>> so, after that, data is comming from the codec to the SSC and then is
>>> handled by the DMA.
>>> there must be something nasty on the DMA bus to hang everything like
>>> that...
>>
>>
>> Will you try i2c without DMA support to test this issue?
>
> Ok, I nailed it !
>
> To be sure we are on the same base, here is what I have done:
> onto next-20130704:
> - your 5 patches:
> ASoC: atmel_ssc_dai: move set dma data to startup callback
> ASoC: atmel_ssc_dai: add error mask define
> ASoC: atmel-pcm-dma: move prepare for dma to dai prepare
> ARM: atmel-ssc: change phybase type to dma_addr_t
> ASoC: atmel-pcm: use generic dmaengine framework
> - my patches 4-8:
> ARM: at91: DTS: sam9x5: add SSC DMA parameters
> ARM: AT91: DTS: sam9x5ek: add WM8731 codec
> ARM: AT91: DTS: sam9x5ek: add sound configuration
> ARM: AT91: DTS: sam9x5ek: enable SSC
> sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards
>
> To be sure that dma-I2c doesn't disturb something, I use i2c gpio bitbang:
> diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi
> b/arch/arm/boot/dts/at91sam9x5ek.dtsi
> index 6684d4b..53a991e 100644
> --- a/arch/arm/boot/dts/at91sam9x5ek.dtsi
> +++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi
> @@ -57,15 +57,6 @@
>   				status = "okay";
>   			};
>
> -			i2c0: i2c@f8010000 {
> -				status = "okay";
> -
> -				wm8731: wm8731@1a {
> -					compatible = "wm8731";
> -					reg = <0x1a>;
> -				};
> -			};
> -
>   			pinctrl@fffff400 {
>   				mmc0 {
>   					pinctrl_board_mmc0: mmc0-board {
> @@ -114,6 +105,15 @@
>   		};
>   	};
>
> +	i2c@0 {
> +		status = "okay";
> +
> +		wm8731: wm8731@1a {
> +			compatible = "wm8731";
> +			reg = <0x1a>;
> +		};
> +	};
> +
>   	sound {
>   		compatible = "atmel,sam9x5-audio-wm8731";
>
> with that configuration, it hangs when I do a:
> arecord -v -V stereo -Dplug:default -f cd -t wav -c 2 /tmp/toto.wav
>
> Now, if I remove the overrun error on ssc in rx_mask:
> diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
> index 0ecf356..c04e825 100644
> --- a/sound/soc/atmel/atmel_ssc_dai.c
> +++ b/sound/soc/atmel/atmel_ssc_dai.c
> @@ -83,7 +83,6 @@ static struct atmel_ssc_mask ssc_rx_mask = {
>   	.ssc_disable	= SSC_BIT(CR_RXDIS),
>   	.ssc_endx	= SSC_BIT(SR_ENDRX),
>   	.ssc_endbuf	= SSC_BIT(SR_RXBUFF),
> -	.ssc_error	= SSC_BIT(SR_OVRUN),
>   	.pdc_enable	= ATMEL_PDC_RXTEN,
>   	.pdc_disable	= ATMEL_PDC_RXTDIS,
>   };
>
> It doesn't hang any more doing a simple record.
> BUT it still hangs if we do record and play at the same time.
>
> Removing the overrun on tx_mask prevent the hang:
> diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
> index 0ecf356..41e15c2 100644
> --- a/sound/soc/atmel/atmel_ssc_dai.c
> +++ b/sound/soc/atmel/atmel_ssc_dai.c
> @@ -73,7 +73,6 @@ static struct atmel_ssc_mask ssc_tx_mask = {
>   	.ssc_disable	= SSC_BIT(CR_TXDIS),
>   	.ssc_endx	= SSC_BIT(SR_ENDTX),
>   	.ssc_endbuf	= SSC_BIT(SR_TXBUFE),
> -	.ssc_error	= SSC_BIT(SR_OVRUN),
>   	.pdc_enable	= ATMEL_PDC_TXTEN,
>   	.pdc_disable	= ATMEL_PDC_TXTDIS,
>   };
>
> i.e. when I revert "ASoC: atmel_ssc_dai: add error mask define", I
> don't see any hang.
>
> Could you test and confirm that behaviour please ?

Yes, I aware this issue.
Actually the system not hang, the resource all are occupied by the 
interrupt. This because, we enable the interrupt, when once interrupt 
occur, I try many methods to clear it, however we can not clear it. So, 
it generates the interrupt all the time. It seems the system hang.

Temp solution: not enable the interrupt. use the following patch to 
disable the interrupt.
---8>---
diff --git a/sound/soc/atmel/atmel_ssc_dai.c 
b/sound/soc/atmel/atmel_ssc_dai.c
index 0ecf356..bb53dea 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -649,7 +649,7 @@ static int atmel_ssc_prepare(struct 
snd_pcm_substream *substream,
         dma_params = ssc_p->dma_params[dir];

         ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable);
-       ssc_writel(ssc_p->ssc->regs, IER, dma_params->mask->ssc_error);
+       ssc_writel(ssc_p->ssc->regs, IDR, dma_params->mask->ssc_error);

         pr_debug("%s enabled SSC_SR=0x%08x\n",
                         dir ? "receive" : "transmit",
---<8---

BTW, I am checking this with our IP team, if find the real solution, I 
will fix it.

> I attached a the (simple) .config I used for the tests.
>
> PS: I hope the patches won't be mangled by gmail...
>
> Best regards,
> Richard.

Best Regards,
Bo Shen

  reply	other threads:[~2013-07-05  1:25 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  8:39 [RFC PATCH 00/13] audio support for at91sam9x5ek board Richard Genoud
2013-07-01  8:39 ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 01/13] misc: atmel_ssc: add device tree DMA support Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-02  3:01   ` Bo Shen
2013-07-02  3:01     ` Bo Shen
2013-07-02  8:13     ` Richard Genoud
2013-07-02  8:13       ` Richard Genoud
2013-07-02  9:11       ` Bo Shen
2013-07-02  9:11         ` Bo Shen
2013-07-03 12:21         ` Richard Genoud
2013-07-03 12:21           ` Richard Genoud
2013-07-03 15:51           ` Richard Genoud
2013-07-03 15:51             ` Richard Genoud
2013-07-04  1:15             ` Bo Shen
2013-07-04  1:15               ` Bo Shen
2013-07-04 13:44               ` Richard Genoud
2013-07-04 13:44                 ` Richard Genoud
2013-07-04 13:44                 ` Richard Genoud
2013-07-05  1:25                 ` Bo Shen [this message]
2013-07-05  1:25                   ` Bo Shen
2013-07-05  7:16                   ` Richard Genoud
2013-07-05  7:16                     ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 02/13] misc: atmel_ssc: keep the count of pdev->id Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-02  3:03   ` Bo Shen
2013-07-02  3:03     ` Bo Shen
2013-07-05 15:16     ` Richard Genoud
2013-07-05 15:16       ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 03/13] ARM: at91: DTS: sam9x5: add clock for SSC DT entry Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-02  3:05   ` Bo Shen
2013-07-02  3:05     ` Bo Shen
2013-07-05 15:16     ` Richard Genoud
2013-07-05 15:16       ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 04/13] ARM: at91: DTS: sam9x5: add SSC DMA parameters Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 05/13] ARM: AT91: DTS: sam9x5ek: add WM8731 codec Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 06/13] ARM: AT91: DTS: sam9x5ek: add sound configuration Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 07/13] ARM: AT91: DTS: sam9x5ek: enable SSC Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 08/13] sound: sam9x5_wm8731: machine driver for at91sam9x5 wm8731 boards Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-02  3:21   ` Bo Shen
2013-07-02  3:21     ` Bo Shen
2013-07-05 15:15     ` Richard Genoud
2013-07-05 15:15       ` Richard Genoud
2013-07-05 18:06       ` Mark Brown
2013-07-05 18:06         ` Mark Brown
2013-07-05 18:06         ` Mark Brown
2013-07-05 18:12         ` Richard Genoud
2013-07-05 18:12           ` Richard Genoud
2013-07-08  2:01       ` Bo Shen
2013-07-08  2:01         ` Bo Shen
2013-07-08  7:55         ` Richard Genoud
2013-07-08  7:55           ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 09/13] sound: atmel-pcm: don't return ok if pcm-dma is not implemented Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 10/13] sound: atmel_ssc_dai: PM: actually stopping clock on suspend/resume Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 11/13] sound: atmel-pcm-dma: check pointer before dereference Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 12/13] sound: wm8731: rework power management Richard Genoud
2013-07-01  8:39   ` Richard Genoud
2013-07-01  8:39 ` [RFC PATCH 13/13] sound: codec: wm8371: correct capture line/mic Richard Genoud
2013-07-01  8:39   ` Richard Genoud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51D62074.9070303@atmel.com \
    --to=voice.shen@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.