From: Andrey Smirnov <andrey.smirnov-MC3rjLPHZ0ivD/XHwUtZZ+TW4wlIGRCZ@public.gmane.org>
To: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Subject: [RFC] tegra_pcm DMA buffers allocation
Date: Thu, 19 Apr 2012 09:00:53 -0700 [thread overview]
Message-ID: <1334851253.13681.49.camel@marvin> (raw)
Hello,
I'm working with a Harmony-based custom Tegra2 board and I'm writing a
driver for a sound capturing I2S device. At this point, for all intents
and purposes the code I use is almost indistinguishable from the similar
code for WM8782(digital microphone) which means that the the structure
describing the DAI has only .capture data and .playback field is left
untouched. This set up, using the tegra-l4t-r15-alpha kernel* results in
the crash because of NULL pointer dereference in
tegra_pcm_preallocate_dma_buffer().
My humble investigation leads me to the following conclusions:
The way I see this code works(correct me if I missed something) is the
following:
soc_probe_dai_link() -> soc_new_pcm() -> snd_pcm_new() ->
snd_pcm_new_stream()
And the decision to allocate a stream is based on the codec_dai's
playback/capture channel count by this piece of code from soc_new_pcm:
if (codec_dai->driver->playback.channels_min)
playback = 1;
if (codec_dai->driver->capture.channels_min)
capture = 1;
Tegra's DMA buffers allocation on the other hand is guided by the amount
of playback capture channels on the cpu_dai as the following excerpt
from tegrap_pcm_new() shows:
struct snd_soc_dai *dai = rtd->cpu_dai;
.
.
.
if (dai->driver->playback.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret)
goto err;
}
if (dai->driver->capture.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_CAPTURE);
if (ret)
goto err_free_play;
}
And wile not positive(unfortunately I didn't have the tenacity required
to actually trace the exact cause of the crash) I'm rather confident
that this is the reason I experience the problem described above, since
working it around the following way:
if (rtd->codec_dai->driver->playback.channels_min &&
dai->driver->playback.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_PLAYBACK);
if (ret)
goto err;
}
if (rtd->codec_dai->driver->playback.channels_min &&
dai->driver->capture.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
SNDRV_PCM_STREAM_CAPTURE);
if (ret)
goto err_free_play;
}
at least allowed the machine to start. Do I miss some additional setup
bit required for this use-case? If not then, what would be the best way
to solve this problem? Declare a fake playback stream in the driver and
ignore it, since there is no physical connection to the corresponding
pins of the T20?
Thank you for you answers, and I apologize if any of my conclusions are
based on faulty premises an therefore are just noise.
Andrey Smirnov
______________
* I know that the code base is different from
git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git
for-next but from what I can tell the code corresponding to the issue at
ahnd is pretty similar.
next reply other threads:[~2012-04-19 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 16:00 Andrey Smirnov [this message]
2012-04-19 20:07 ` [RFC] tegra_pcm DMA buffers allocation Stephen Warren
[not found] ` <4F90708F.8070504-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-19 21:07 ` Andrey Smirnov
2012-04-19 21:37 ` Stephen Warren
[not found] ` <4F90858D.4010206-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-04-19 23:30 ` Andrey Smirnov
2012-04-20 5:58 ` Thierry Reding
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=1334851253.13681.49.camel@marvin \
--to=andrey.smirnov-mc3rjlphz0ivd/xhwutzz+tw4wligrcz@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox