linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Liam Girdwood <lrg@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	<alsa-devel@alsa-project.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Neil <neil.jones@imgtec.com>
Subject: bugs in "ASoC: core - Optimise and refactor pcm_new() to pass only rtd"?
Date: Wed, 14 Dec 2011 12:43:50 +0000	[thread overview]
Message-ID: <4EE89A06.80101@imgtec.com> (raw)

Hi,

I've bisected a problem with an out of tree set of asoc drivers down to commit
552d1ef6b5a98d7b95959d5b139071e3c90cebf1 ("ASoC: core - Optimise and refactor
pcm_new() to pass only rtd"). By the looks of it this change was intended not 
to change the workings of the code, however the dai parameter of pcm_new used
to be passed codec_dai in soc_new_pcm() (initialised from rtd->codec_dai), but
each driver now sets it's dai to rtd->cpu_dai instead. This seems to make the
driver check the wrong dai's driver->capture.channels_min in the pcm_new
callback, which makes it dereference
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream in the driver's
preallocate_dma_buffer() function which can be NULL. Is this a bug (in every
pcm asoc driver) that just happens not to have been noticed, or have I
misunderstood it?

Relevant snippets of the original patch below.

Thanks
James

diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
index 5cb3b88..9465588 100644
--- a/sound/soc/samsung/dma.c
+++ b/sound/soc/samsung/dma.c
@@ -425,9 +425,11 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm)
 
 static u64 dma_mask = DMA_BIT_MASK(32);
 
-static int dma_new(struct snd_card *card,
-	struct snd_soc_dai *dai, struct snd_pcm *pcm)
+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_pcm *pcm = rtd->pcm;
 	int ret = 0;
 
 	pr_debug("Entered %s\n", __func__);


diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c53f5d5..29bf9fb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2143,8 +2143,7 @@ static int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
 
 	if (platform->driver->pcm_new) {
-		ret = platform->driver->pcm_new(rtd->card->snd_card,
-						codec_dai, pcm);
+		ret = platform->driver->pcm_new(rtd);
 		if (ret < 0) {
 			pr_err("asoc: platform pcm constructor failed\n");
 			return ret;


             reply	other threads:[~2011-12-14 12:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 12:43 James Hogan [this message]
2011-12-14 13:34 ` bugs in "ASoC: core - Optimise and refactor pcm_new() to pass only rtd"? Mark Brown
2011-12-14 13:58   ` James Hogan

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=4EE89A06.80101@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=neil.jones@imgtec.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).