ASoC: core - Fix dai usage in pcm_new() platform handlers
Subsystems (10)
PATCH 1/1 ASoC: core - Fix dai usage in pcm_new() platform handlers
Commit 552d1ef ("ASoC: core - Optimise and refactor pcm_new() to pass only rtd") refactored the ASoC internal core to only pass a pointer to a runtime as argument to individual pcm_new() functions. However, the new code that was added to the handlers to get access to the dai now uses rtd->cpu_dai, while before this patch, rtd->codec_dai was used.
This patch fixes all the pcm_new() handlers that were affected. Tested on a PXA platform.
--- sound/soc/atmel/atmel-pcm.c | 2 +- sound/soc/blackfin/bf5xx-ac97-pcm.c | 2 +- sound/soc/blackfin/bf5xx-i2s-pcm.c | 2 +- sound/soc/blackfin/bf5xx-tdm-pcm.c | 2 +- sound/soc/davinci/davinci-pcm.c | 2 +- sound/soc/fsl/fsl_dma.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 2 +- sound/soc/imx/imx-pcm-fiq.c | 2 +- sound/soc/imx/imx-ssi.c | 2 +- sound/soc/jz4740/jz4740-pcm.c | 2 +- sound/soc/kirkwood/kirkwood-dma.c | 2 +- sound/soc/mid-x86/sst_platform.c | 2 +- sound/soc/nuc900/nuc900-pcm.c | 2 +- sound/soc/omap/omap-pcm.c | 2 +- sound/soc/pxa/pxa2xx-pcm.c | 2 +- sound/soc/s6000/s6000-pcm.c | 2 +- sound/soc/samsung/dma.c | 2 +- sound/soc/tegra/tegra_pcm.c | 2 +- sound/soc/txx9/txx9aclc.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-)
sound/soc/atmel/atmel-pcm.c +1 -1
@@ -367,7 +367,7 @@ static u64 atmel_pcm_dmamask = 0xffffffff;static int atmel_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/blackfin/bf5xx-ac97-pcm.c +1 -1
@@ -421,7 +421,7 @@ static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);int bf5xx_pcm_ac97_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/blackfin/bf5xx-i2s-pcm.c +1 -1
@@ -251,7 +251,7 @@ static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);int bf5xx_pcm_i2s_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/blackfin/bf5xx-tdm-pcm.c +1 -1
@@ -286,7 +286,7 @@ static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);static int bf5xx_pcm_tdm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/davinci/davinci-pcm.c +1 -1
@@ -836,7 +836,7 @@ static u64 davinci_pcm_dmamask = 0xffffffff;static int davinci_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret;
sound/soc/fsl/fsl_dma.c +1 -1
@@ -297,7 +297,7 @@ static irqreturn_t fsl_dma_isr(int irq, void *dev_id)static int fsl_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;static u64 fsl_dma_dmamask =DMA_BIT_MASK (36 );int ret;
sound/soc/fsl/mpc5200_dma.c +1 -1
@@ -302,7 +302,7 @@ static u64 psc_dma_dmamask = 0xffffffff;static int psc_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;struct psc_dma *psc_dma =snd_soc_dai_get_drvdata (rtd->cpu_dai);size_t size = psc_dma_hardware.buffer_bytes_max;
sound/soc/imx/imx-pcm-fiq.c +1 -1
@@ -241,7 +241,7 @@ static int ssi_irq = 0;static int imx_pcm_fiq_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret;
sound/soc/imx/imx-ssi.c +1 -1
@@ -391,7 +391,7 @@ static u64 imx_pcm_dmamask = DMA_BIT_MASK(32);int imx_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/jz4740/jz4740-pcm.c +1 -1
@@ -302,7 +302,7 @@ static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32);int jz4740_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/kirkwood/kirkwood-dma.c +1 -1
@@ -315,7 +315,7 @@ static int kirkwood_dma_preallocate_dma_buffer(struct snd_pcm *pcm,static int kirkwood_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret;
sound/soc/mid-x86/sst_platform.c +1 -1
@@ -404,7 +404,7 @@ static void sst_pcm_free(struct snd_pcm *pcm)int sst_pcm_new (struct snd_soc_pcm_runtime *rtd) { -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int retval =0 ;
sound/soc/nuc900/nuc900-pcm.c +1 -1
@@ -318,7 +318,7 @@ static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32);static int nuc900_dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;if (!card->dev->dma_mask)
sound/soc/omap/omap-pcm.c +1 -1
@@ -369,7 +369,7 @@ static void omap_pcm_free_dma_buffers(struct snd_pcm *pcm)static int omap_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/pxa/pxa2xx-pcm.c +1 -1
@@ -88,7 +88,7 @@ static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32);static int pxa2xx_soc_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/s6000/s6000-pcm.c +1 -1
@@ -446,7 +446,7 @@ static u64 s6000_pcm_dmamask = DMA_BIT_MASK(32);static int s6000_pcm_new (struct snd_soc_pcm_runtime *runtime) {struct snd_card *card = runtime->card->snd_card; -struct snd_soc_dai *dai = runtime->cpu_dai; +struct snd_soc_dai *dai = runtime->codec_dai;struct snd_pcm *pcm = runtime->pcm;struct s6000_pcm_dma_params *params;int res;
sound/soc/samsung/dma.c +1 -1
@@ -428,7 +428,7 @@ static u64 dma_mask = DMA_BIT_MASK(32);static int dma_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/tegra/tegra_pcm.c +1 -1
@@ -325,7 +325,7 @@ static u64 tegra_dma_mask = DMA_BIT_MASK(32);static int tegra_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
sound/soc/txx9/txx9aclc.c +1 -1
@@ -290,7 +290,7 @@ static void txx9aclc_pcm_free_dma_buffers(struct snd_pcm *pcm)static int txx9aclc_pcm_new (struct snd_soc_pcm_runtime *rtd) { -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;struct platform_device *pdev =to_platform_device (dai->platform->dev);struct txx9aclc_soc_device *dev;
Signature · 1 line
1.7.5.4
Quoted 5 lines · Daniel Mack
Commit 552d1ef ("ASoC: core - Optimise and refactor
pcm_new()to pass only rtd") refactored the ASoC internal core to only pass a pointer to a runtime as argument to individualpcm_new()functions. However, the new code that was added to the handlers to get access to the dai now usesrtd->cpu_dai, while before this patch,rtd->codec_daiwas used.
Which is a problem because...
sound/soc/atmel/atmel-pcm.c static u64 atmel_pcm_dmamask = 0xffffffff; · line 373
Quoted 13 lines
sound/soc/atmel/atmel-pcm.c +1
-1@@ -367,7 +367,7 @@ static u64 atmel_pcm_dmamask = 0xffffffff;static int atmel_pcm_new (struct snd_soc_pcm_runtime *rtd) {struct snd_card *card = rtd->card->snd_card; -struct snd_soc_dai *dai = rtd->cpu_dai; +struct snd_soc_dai *dai = rtd->codec_dai;struct snd_pcm *pcm = rtd->pcm;int ret =0 ;
The original code doesn't look obviously wrong while if the CPU driver is peering at the CODEC driver that smells very bad. What's the actual problem here?
Quoted 18 lines · Mark Brown
Quoted 5 lines · Daniel Mack
Commit 552d1ef ("ASoC: core - Optimise and refactor
pcm_new()to pass only rtd") refactored the ASoC internal core to only pass a pointer to a runtime as argument to individualpcm_new()functions. However, the new code that was added to the handlers to get access to the dai now usesrtd->cpu_dai, while before this patch,rtd->codec_daiwas used.Which is a problem because...
Quoted 9 lines
sound/soc/atmel/atmel-pcm.c +0
-1@@ -367,7 +367,7 @@ static u64 atmel_pcm_dmamask = 0xffffffff; static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; - struct snd_soc_dai *dai = rtd->cpu_dai;
Quoted 8 lines
sound/soc/atmel/atmel-pcm.c static u64 atmel_pcm_dmamask = 0xffffffff; · line 373
Quoted 4 lines
sound/soc/atmel/atmel-pcm.c +1
-0+ struct snd_soc_dai *dai = rtd->codec_dai; struct snd_pcm *pcm = rtd->pcm; int ret = 0;The original code doesn't look obviously wrong while if the CPU driver is peering at the CODEC driver that smells very bad. What's the actual problem here?
I thought so too, but I'm facing an Ooops on 3.0.0-rc4, while the same platform code was running fine on 2.6.39. And while searching for potential reasons for this regression, this commit was quite obvious. But maybe that's indeed fixing the wrong side. What happens is that pxa2xx_pcm_preallocate_dma_buffer() is called for SNDRV_PCM_STREAM_CAPTURE, but pcm->streams[1].substream is NULL.
[ 2.959735] Unable to handle kernel NULL pointer dereference at virtual address 00000050 [ 2.967792] pgd = c0004000 [ 2.970481] [00000050] *pgd=00000000 [ 2.974064] Internal error: Oops: 805 [#1] [ 2.978133] Modules linked in: [ 2.981171] CPU: 0 Not tainted (3.0.0-rc4+ #207) [ 2.986124] PC is at pxa2xx_pcm_preallocate_dma_buffer+0x38/0x8c [ 2.992093] LR is at pxa2xx_pcm_preallocate_dma_buffer+0x34/0x8c [ 2.998067] pc : [<c0296110>] lr : [<c029610c>] psr: 60000013 [ 2.998078] sp : c6033df0 ip : 000033db fp : c61f6e40 [ 3.009467] r10: 00000000 r9 : c6175a00 r8 : 00000001 [ 3.014655] r7 : c61dd340 r6 : c61e7000 r5 : 00000000 r4 : c6175e00 [ 3.021134] r3 : 00000002 r2 : 60000013 r1 : 00000000 r0 : 0000004b [ 3.027615] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 3.034875] Control: 0000397f Table: a0004018 DAC: 00000035 [ 3.040578] Process swapper (pid: 1, stack limit = 0xc6032278) [ 3.046369] Stack: (0xc6033df0 to 0xc6034000) [ 3.050699] 3de0: 00000001 c02a0dcc 00000000 00000000 [ 3.058827] 3e00: c61e7000 c029f188 00000000 c6033e5c c6033e48 c61cfba0 00000000 79616c50 [ 3.066961] 3e20: 6b636162 41545320 2d583233 c61e0030 c6033e68 c00fca2c 00000000 c00fcc8c [ 3.075094] 3e40: c61cfba0 c61e9ea0 c6033e68 c00fcb68 c61cfba0 c61e9ea0 00000000 c6175e00 [ 3.083226] 3e60: c61f6e40 c61cfba0 c0555328 00000000 c61dd340 c61f6e40 00000002 c61e7000 [ 3.091360] 3e80: 00000000 c02990a8 c0555338 c501e480 c0555400 c0555348 c6175a00 c0555700 [ 3.099492] 3ea0: c05553d8 c05553e0 00000000 00000000 c6175d08 c0555340 00000000 c0555328 [ 3.107625] 3ec0: c0554450 00000000 00000000 c6175d10 00000000 c0299ad0 c6175d08 c6175d08 [ 3.115758] 3ee0: c6175d08 c0299b34 c6175d10 00000000 c6175d08 c01e4e28 c6175d08 c01e3b0c [ 3.123891] 3f00: c6175d08 00000000 c01e3c74 c6175d08 c6033f18 c01e304c c602a108 c61f6334 [ 3.132024] 3f20: c04ceff2 c6175d08 c6175d08 c6175d3c 00000013 c01e3d50 c6175d00 c6175d08 [ 3.140156] 3f40: 00000000 c01e2e74 00000000 c01e1dfc 00000000 c0548978 00000000 00000021 [ 3.148289] 3f60: c001bd54 c019c5e0 00000000 c6175d00 00000000 00000000 00000013 c001bd54 [ 3.156423] 3f80: 00000000 00000000 00000000 c01e5428 c6175d08 c00228d0 c0022954 c004985c [ 3.164555] 3fa0: 00000013 c001be6c c004985c 00000013 c001bd48 c00483e0 00000033 00000000 [ 3.172688] 3fc0: 00000013 00000120 c05401c8 c00228d0 c0022954 c004985c 00000013 00000000 [ 3.180821] 3fe0: 00000000 c00083e4 00000000 00000000 c0008370 c004985c ffffffff ffffffff [ 3.189000] [<c0296110>] (pxa2xx_pcm_preallocate_dma_buffer+0x38/0x8c) from [<c029f188>] (soc_new_pcm+0x190/0x1f0) [ 3.199302] [<c029f188>] (soc_new_pcm+0x190/0x1f0) from [<c02990a8>] (snd_soc_instantiate_cards+0x644/0x9b4) [ 3.209076] [<c02990a8>] (snd_soc_instantiate_cards+0x644/0x9b4) from [<c0299ad0>] (snd_soc_register_card+0x180/0x1bc) [ 3.219715] [<c0299ad0>] (snd_soc_register_card+0x180/0x1bc) from [<c0299b34>] (soc_probe+0x28/0x4c) [ 3.228805] [<c0299b34>] (soc_probe+0x28/0x4c) from [<c01e4e28>] (platform_drv_probe+0x1c/0x24) [ 3.237465] [<c01e4e28>] (platform_drv_probe+0x1c/0x24) from [<c01e3b0c>] (driver_probe_device+0xb4/0x198) [ 3.247069] [<c01e3b0c>] (driver_probe_device+0xb4/0x198) from [<c01e304c>] (bus_for_each_drv+0x4c/0x8c) [ 3.256501] [<c01e304c>] (bus_for_each_drv+0x4c/0x8c) from [<c01e3d50>] (device_attach+0x60/0x80) [ 3.265323] [<c01e3d50>] (device_attach+0x60/0x80) from [<c01e2e74>] (bus_probe_device+0x28/0x54) [ 3.274167] [<c01e2e74>] (bus_probe_device+0x28/0x54) from [<c01e1dfc>] (device_add+0x408/0x58c) [ 3.282914] [<c01e1dfc>] (device_add+0x408/0x58c) from [<c01e5428>] (platform_device_add+0x108/0x168) [ 3.292099] [<c01e5428>] (platform_device_add+0x108/0x168) from [<c001be6c>] (raumfeld_audio_init+0x118/0x170) [ 3.302069] [<c001be6c>] (raumfeld_audio_init+0x118/0x170) from [<c00483e0>] (do_one_initcall+0x94/0x164) [ 3.311592] [<c00483e0>] (do_one_initcall+0x94/0x164) from [<c00083e4>] (kernel_init+0x74/0x11c) [ 3.320335] [<c00083e4>] (kernel_init+0x74/0x11c) from [<c004985c>] (kernel_thread_exit+0x0/0x8) [ 3.329074] Code: e1a02005 e59f0054 eb040ce2 e3a03002 (e5853050) [ 3.335251] ---[ end trace b4ec1505aa8093ea ]--- [ 3.339870] Kernel panic - not syncing: Attempted to kill init! [ 3.345830] [<c004d438>] (unwind_backtrace+0x0/0xec) from [<c039935c>] (panic+0x4c/0x188) [ 3.354011] [<c039935c>] (panic+0x4c/0x188) from [<c005ef5c>] (do_exit+0xac/0x630) [ 3.361544] [<c005ef5c>] (do_exit+0xac/0x630) from [<c004bfb4>] (die+0x1b0/0x1e0) [ 3.369022] [<c004bfb4>] (die+0x1b0/0x1e0) from [<c004e5a0>] (__do_kernel_fault+0x64/0x88) [ 3.377282] [<c004e5a0>] (__do_kernel_fault+0x64/0x88) from [<c004e77c>] (do_page_fault+0x1b8/0x1d0) [ 3.386406] [<c004e77c>] (do_page_fault+0x1b8/0x1d0) from [<c00482c0>] (do_DataAbort+0x34/0x94) [ 3.395100] [<c00482c0>] (do_DataAbort+0x34/0x94) from [<c0048b4c>] (__dabt_svc+0x4c/0x60) [ 3.403313] Exception stack(0xc6033da8 to 0xc6033df0) [ 3.408360] 3da0: 0000004b 00000000 60000013 00000002 c6175e00 00000000 [ 3.416518] 3dc0: c61e7000 c61dd340 00000001 c6175a00 00000000 c61f6e40 000033db c6033df0 [ 3.424671] 3de0: c029610c c0296110 60000013 ffffffff [ 3.429708] [<c0048b4c>] (__dabt_svc+0x4c/0x60) from [<c0296110>] (pxa2xx_pcm_preallocate_dma_buffer+0x38/0x8c) [ 3.439791] [<c0296110>] (pxa2xx_pcm_preallocate_dma_buffer+0x38/0x8c) from [<c029f188>] (soc_new_pcm+0x190/0x1f0) [ 3.450114] [<c029f188>] (soc_new_pcm+0x190/0x1f0) from [<c02990a8>] (snd_soc_instantiate_cards+0x644/0x9b4) [ 3.459924] [<c02990a8>] (snd_soc_instantiate_cards+0x644/0x9b4) from [<c0299ad0>] (snd_soc_register_card+0x180/0x1bc) [ 3.470590] [<c0299ad0>] (snd_soc_register_card+0x180/0x1bc) from [<c0299b34>] (soc_probe+0x28/0x4c) [ 3.479711] [<c0299b34>] (soc_probe+0x28/0x4c) from [<c01e4e28>] (platform_drv_probe+0x1c/0x24) [ 3.488401] [<c01e4e28>] (platform_drv_probe+0x1c/0x24) from [<c01e3b0c>] (driver_probe_device+0xb4/0x198) [ 3.498040] [<c01e3b0c>] (driver_probe_device+0xb4/0x198) from [<c01e304c>] (bus_for_each_drv+0x4c/0x8c) [ 3.507496] [<c01e304c>] (bus_for_each_drv+0x4c/0x8c) from [<c01e3d50>] (device_attach+0x60/0x80) [ 3.516353] [<c01e3d50>] (device_attach+0x60/0x80) from [<c01e2e74>] (bus_probe_device+0x28/0x54) [ 3.525223] [<c01e2e74>] (bus_probe_device+0x28/0x54) from [<c01e1dfc>] (device_add+0x408/0x58c) [ 3.534005] [<c01e1dfc>] (device_add+0x408/0x58c) from [<c01e5428>] (platform_device_add+0x108/0x168) [ 3.543189] [<c01e5428>] (platform_device_add+0x108/0x168) from [<c001be6c>] (raumfeld_audio_init+0x118/0x170) [ 3.553192] [<c001be6c>] (raumfeld_audio_init+0x118/0x170) from [<c00483e0>] (do_one_initcall+0x94/0x164) [ 3.562747] [<c00483e0>] (do_one_initcall+0x94/0x164) from [<c00083e4>] (kernel_init+0x74/0x11c) [ 3.571519] [<c00083e4>] (kernel_init+0x74/0x11c) from [<c004985c>] (kernel_thread_exit+0x0/0x8) [ 3.793639] pxa27x-ohci pxa27x-ohci: auto-stop root hub
Quoted 6 lines · Daniel Mack
I thought so too, but I'm facing an Ooops on 3.0.0-rc4, while the same platform code was running fine on 2.6.39. And while searching for potential reasons for this regression, this commit was quite obvious. But maybe that's indeed fixing the wrong side. What happens is that
pxa2xx_pcm_preallocate_dma_buffer()is called forSNDRV_PCM_STREAM_CAPTURE, but pcm->streams[1].substream is NULL.
Note that I have local changes which aren't submitted for mainline yet
- see the patch attached. Is there anything substantionally wrong with these changes?
Daniel
sound/soc/pxa/raumfeld.c +235 -14
@@ -21,6 +21,7 @@#include <linux/delay.h> #include <linux/gpio.h> #include <sound/pcm.h> +#include <sound/pcm_params.h> #include <sound/soc.h> #include <asm/mach-types.h>
@@ -225,6 +226,177 @@ static struct snd_soc_ops raumfeld_ak4104_ops = { .hw_params = raumfeld_ak4104_hw_params, }; +/* STA32X */ +static int raumfeld_sta32x_startup (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai = rtd->codec_dai; + +/* FIXME: currently only fixed MCLK of 12.288MHz is available */ +snd_pcm_hw_constraint_mask64 (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE , +SNDRV_PCM_RATE_32000 | +SNDRV_PCM_RATE_48000 | +SNDRV_PCM_RATE_96000 | +SNDRV_PCM_RATE_192000 ); + +/* PXA DMA cannot do zero extend for 24bit samples, +* thus only 16bit (two samples packet into 32bit word) +* or 32bit samples are possible +*/ +snd_pcm_hw_constraint_mask64 (substream->runtime, +SNDRV_PCM_HW_PARAM_FORMAT , +SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S16_BE | +SNDRV_PCM_FMTBIT_S32_LE |SNDRV_PCM_FMTBIT_S32_BE ); + +/* FIXME: we have a fixed MCLK, set it here so ALSA knows +* the supported sample rates and can resample if necessary +*/ +return snd_soc_dai_set_sysclk (codec_dai,0 ,12288000 ,0 ); +} + +static void raumfeld_sta32x_shutdown (struct snd_pcm_substream *substream) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai = rtd->codec_dai; + +/* set freq to 0 to enable all possible codec sample rates */ +snd_soc_dai_set_sysclk (codec_dai,0 ,0 ,0 ); +} + +static int raumfeld_sta32x_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai = rtd->codec_dai; +struct snd_soc_dai *cpu_dai = rtd->cpu_dai; +unsigned int fmt, clk =0 ; +int ret =0 ; + +// FIXME: currently only fixed MCLK of 12.288MHz is available +switch (params_rate (params)) { +case 32000 : +case 48000 : +case 96000 : +case 192000 : + clk =12288000 ; +break ; +default : +return -EINVAL ; + } + +switch (params_format (params)) { +case SNDRV_PCM_FORMAT_S32_LE : +case SNDRV_PCM_FORMAT_S32_BE : +/* this enables network mode for 2 * 32bit samples */ + ret =snd_soc_dai_set_tdm_slot (cpu_dai,3 ,0 ,2 ,32 ); +if (ret <0 ) +return ret; +break ; +case SNDRV_PCM_FORMAT_S16_LE : +case SNDRV_PCM_FORMAT_S16_BE : +/* this disables network mode */ + ret =snd_soc_dai_set_tdm_slot (cpu_dai,0 ,0 ,0 ,16 ); +if (ret <0 ) +return ret; +break ; +default : +return -EINVAL ; + } + + fmt =SND_SOC_DAIFMT_I2S | +SND_SOC_DAIFMT_NB_NF | +SND_SOC_DAIFMT_CBS_CFS ; + +/* setup the CODEC DAI */ + ret =snd_soc_dai_set_fmt (codec_dai, fmt); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_sysclk (codec_dai,0 , clk,0 ); +if (ret <0 ) +return ret; + +/* setup the CPU DAI */ + ret =snd_soc_dai_set_pll (cpu_dai,0 ,0 ,0 , clk); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_fmt (cpu_dai, fmt); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_clkdiv (cpu_dai,PXA_SSP_DIV_SCR ,4 ); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_sysclk (cpu_dai,PXA_SSP_CLK_EXT , clk,1 ); +if (ret <0 ) +return ret; + +return 0 ; +} + +static struct snd_soc_ops raumfeld_sta32x_ops = { + .startup = raumfeld_sta32x_startup, + .shutdown = raumfeld_sta32x_shutdown, + .hw_params = raumfeld_sta32x_hw_params, +}; + +/* WM8782 */ +static int raumfeld_wm8782_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *cpu_dai = rtd->cpu_dai; +unsigned int fmt, clk =0 ; +int ret =0 ; + +// FIXME: currently only fixed MCLK of 12.288MHz is available +switch (params_rate (params)) { +case 48000 : + clk =12288000 ; +break ; +default : +return -EINVAL ; + } + +switch (params_format (params)) { +case SNDRV_PCM_FORMAT_S16_LE : +case SNDRV_PCM_FORMAT_S16_BE : +break ; +default : +return -EINVAL ; + } + + fmt =SND_SOC_DAIFMT_I2S | +SND_SOC_DAIFMT_NB_NF | +SND_SOC_DAIFMT_CBS_CFS ; + +/* setup the CPU DAI */ + ret =snd_soc_dai_set_pll (cpu_dai,0 ,0 ,0 , clk); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_fmt (cpu_dai, fmt); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_clkdiv (cpu_dai,PXA_SSP_DIV_SCR ,4 ); +if (ret <0 ) +return ret; + + ret =snd_soc_dai_set_sysclk (cpu_dai,PXA_SSP_CLK_EXT , clk,1 ); +if (ret <0 ) +return ret; + +return 0 ; +} + +static struct snd_soc_ops raumfeld_wm8782_ops = { + .hw_params = raumfeld_wm8782_hw_params, +}; +#define DAI_LINK_CS4270 \ { \ .name = "CS4270", \
@@ -247,6 +419,28 @@ static struct snd_soc_ops raumfeld_ak4104_ops = { .codec_name = "spi0.0", \ } +#define DAI_LINK_STA32X \ +{ \ + .name = "STA32X", \ + .stream_name = "Playback", \ + .cpu_dai_name = "pxa-ssp-dai.0", \ + .platform_name = "pxa-pcm-audio", \ + .codec_dai_name = "STA32X", \ + .ops = &raumfeld_sta32x_ops, \ + .codec_name = "sta32x.0-001a", \ +} + +#define DAI_LINK_WM8782 \ +{ \ + .name = "wm8782", \ + .stream_name = "wm8782", \ + .cpu_dai_name = "pxa-ssp-dai.0", \ + .platform_name = "pxa-pcm-audio", \ + .codec_dai_name = "wm8782", \ + .codec_name = "wm8782.0", \ + .ops = &raumfeld_wm8782_ops, \ +} +static struct snd_soc_dai_link snd_soc_raumfeld_connector_dai[] = {DAI_LINK_CS4270 ,
@@ -258,6 +452,12 @@ static struct snd_soc_dai_link snd_soc_raumfeld_speaker_dai[] = DAI_LINK_CS4270, }; +static struct snd_soc_dai_link snd_soc_raumfeld_ddx_dai[] = +{ +DAI_LINK_STA32X , +DAI_LINK_WM8782 , +}; +static struct snd_soc_card snd_soc_raumfeld_connector = { .name ="Raumfeld Connector" , .dai_link = snd_soc_raumfeld_connector_dai,
@@ -274,7 +474,15 @@ static struct snd_soc_card snd_soc_raumfeld_speaker = { .resume_pre = raumfeld_analog_resume, }; -static struct platform_device *raumfeld_audio_device; +static struct snd_soc_card snd_soc_raumfeld_ddx = { + .name ="Raumfeld DDX" , + .dai_link = snd_soc_raumfeld_ddx_dai, + .num_links =ARRAY_SIZE (snd_soc_raumfeld_ddx_dai), + .suspend_post = raumfeld_analog_suspend, + .resume_pre = raumfeld_analog_resume, +}; + +static struct platform_device *raumfeld_audio_device, *wm8782_device;static int __init raumfeld_audio_init (void ) {
@@ -284,26 +492,39 @@ static int __init raumfeld_audio_init(void) !machine_is_raumfeld_connector())return 0 ; - max9486_client =i2c_new_device (i2c_get_adapter (0 ), - &max9486_hwmon_info); +if ((system_rev &0xff00 ) ==0x0400 ) { + wm8782_device =platform_device_alloc ("wm8782" ,0 ); +if (!wm8782_device) +return -ENOMEM ; -if (!max9486_client) -return -ENOMEM ; +platform_device_add (wm8782_device); + }else { + max9486_client =i2c_new_device (i2c_get_adapter (0 ), + &max9486_hwmon_info); + +if (!max9486_client) +return -ENOMEM ; -set_max9485_clk (MAX9485_MCLK_FREQ_122880 ); +set_max9485_clk (MAX9485_MCLK_FREQ_122880 ); + } -/* Register analog device */ +/* Register audio device */ raumfeld_audio_device =platform_device_alloc ("soc-audio" ,0 );if (!raumfeld_audio_device)return -ENOMEM ; -if (machine_is_raumfeld_speaker ()) +if ((system_rev &0xff00 ) ==0x0400 )platform_set_drvdata (raumfeld_audio_device, - &snd_soc_raumfeld_speaker); - -if (machine_is_raumfeld_connector ()) -platform_set_drvdata (raumfeld_audio_device, - &snd_soc_raumfeld_connector); + &snd_soc_raumfeld_ddx); +else { +if (machine_is_raumfeld_speaker ()) +platform_set_drvdata (raumfeld_audio_device, + &snd_soc_raumfeld_speaker); + +if (machine_is_raumfeld_connector ()) +platform_set_drvdata (raumfeld_audio_device, + &snd_soc_raumfeld_connector); + } ret =platform_device_add (raumfeld_audio_device);if (ret <0 )
@@ -317,8 +538,8 @@ static void __exit raumfeld_audio_exit(void) {raumfeld_enable_audio (false); +platform_device_unregister (wm8782_device);platform_device_unregister (raumfeld_audio_device); -i2c_unregister_device (max9486_client);gpio_free (GPIO_MCLK_RESET );
Quoted 6 lines · Daniel Mack
I thought so too, but I'm facing an Ooops on 3.0.0-rc4, while the same platform code was running fine on 2.6.39. And while searching for potential reasons for this regression, this commit was quite obvious. But maybe that's indeed fixing the wrong side. What happens is that
pxa2xx_pcm_preallocate_dma_buffer()is called forSNDRV_PCM_STREAM_CAPTURE, but pcm->streams[1].substream is NULL.
Is this the same issue that Timur was having where he was relying on the channel count of one of the DAI drivers to tell him if the substream was allocated instead of looking to see if the substream was allocated which is the more direct and reliable thing to do? Looking at the code it appears that's the case for PXA.
Quoted 9 lines · Mark Brown
Quoted 6 lines · Daniel Mack
I thought so too, but I'm facing an Ooops on 3.0.0-rc4, while the same platform code was running fine on 2.6.39. And while searching for potential reasons for this regression, this commit was quite obvious. But maybe that's indeed fixing the wrong side. What happens is that
pxa2xx_pcm_preallocate_dma_buffer()is called forSNDRV_PCM_STREAM_CAPTURE, but pcm->streams[1].substream is NULL.
Quoted 5 lines
Is this the same issue that Timur was having where he was relying on the channel count of one of the DAI drivers to tell him if the substream was allocated instead of looking to see if the substream was allocated which is the more direct and reliable thing to do? Looking at the code it appears that's the case for PXA.
And so the bug was always there, it was just hidden by another bug. Thanks for the pointer :)
Daniel