From patchwork Fri Dec 28 14:17:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Dunn X-Patchwork-Id: 1915251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 4A58440061 for ; Fri, 28 Dec 2012 14:22:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1ToamA-0003yb-VN; Fri, 28 Dec 2012 14:19:07 +0000 Received: from smtp.newsguy.com ([74.209.136.69]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Toam3-0003x9-ET for linux-arm-kernel@lists.infradead.org; Fri, 28 Dec 2012 14:19:01 +0000 Received: from localhost.localdomain (218.sub-70-199-230.myvzw.com [70.199.230.218]) by smtp.newsguy.com (8.14.3/8.14.3) with ESMTP id qBSEI5kR075784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 Dec 2012 06:18:07 -0800 (PST) (envelope-from mikedunn@newsguy.com) From: Mike Dunn To: alsa-devel@alsa-project.org Subject: [PATCH] ASoC: pxa2xx-ac97: fix oops when codec_driver probe runs Date: Fri, 28 Dec 2012 06:17:55 -0800 Message-Id: <1356704275-3098-1-git-send-email-mikedunn@newsguy.com> X-Mailer: git-send-email 1.7.8.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121228_091859_782582_5F17FF7D X-CRM114-Status: GOOD ( 18.39 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Marek Vasut , Eric Miao , Mark Brown , Haojian Zhuang , Mike Dunn , Tomas Cech , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch fixes a kernel oops that occurs when the snd_soc_codec_driver probe function runs. The exception occurs when the codec calls soc_ac97_ops.reset(). The pxa2xx-ac97's clocks have not been initialized at this point, but the cpu's reset function (pxa_ac97_cold_pxa27x()) expects them to be, resulting in a NULL pointer dereference in the pxa's clk_enable(). The pxa2xx-ac97's clocks are initialized in pxa2xx_ac97_hw_probe(). To ensure that the clocks are initialized when the codec_driver probe runs, the calls to pxa2xx_ac97_hw_{probe,remove}() are moved from the cpu's dai_driver probe/remove functions to those of its platform_driver. This is necessary because snd_soc_instantiate_card() always calls the codec_driver probe before any of the dai_drivers' probes. This change leaves nothing in the cpu's dai_driver probe/remove functions, so those functions are eliminated. Tested on the pxa27x; palmtreo680 machine using the wm9712 codec. Signed-off-by: Mike Dunn --- I'm new to the ASoC code. Experts, please have a look. Thanks! sound/soc/pxa/pxa2xx-ac97.c | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 4b0a009..940e9f4 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -104,17 +104,6 @@ static int pxa2xx_ac97_resume(struct snd_soc_dai *dai) #define pxa2xx_ac97_resume NULL #endif -static int pxa2xx_ac97_probe(struct snd_soc_dai *dai) -{ - return pxa2xx_ac97_hw_probe(to_platform_device(dai->dev)); -} - -static int pxa2xx_ac97_remove(struct snd_soc_dai *dai) -{ - pxa2xx_ac97_hw_remove(to_platform_device(dai->dev)); - return 0; -} - static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) @@ -184,8 +173,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { { .name = "pxa2xx-ac97", .ac97_control = 1, - .probe = pxa2xx_ac97_probe, - .remove = pxa2xx_ac97_remove, .suspend = pxa2xx_ac97_suspend, .resume = pxa2xx_ac97_resume, .playback = { @@ -236,21 +223,34 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops); static int pxa2xx_ac97_dev_probe(struct platform_device *pdev) { + int ret; + if (pdev->id != -1) { dev_err(&pdev->dev, "PXA2xx has only one AC97 port.\n"); return -ENXIO; } - /* Punt most of the init to the SoC probe; we may need the machine - * driver to do interesting things with the clocking to get us up - * and running. - */ - return snd_soc_register_dais(&pdev->dev, pxa_ac97_dai_driver, - ARRAY_SIZE(pxa_ac97_dai_driver)); + ret = snd_soc_register_dais(&pdev->dev, pxa_ac97_dai_driver, + ARRAY_SIZE(pxa_ac97_dai_driver)); + if (ret < 0) { + dev_err(&pdev->dev, "snd_soc_register_dais failed with %d\n", + ret); + return ret; + } + + ret = pxa2xx_ac97_hw_probe(pdev); + if (ret < 0) { + dev_err(&pdev->dev, "pxa2xx_ac97_hw_probe failed with %d\n", + ret); + snd_soc_unregister_dais(&pdev->dev, + ARRAY_SIZE(pxa_ac97_dai_driver)); + } + return ret; } static int pxa2xx_ac97_dev_remove(struct platform_device *pdev) { + pxa2xx_ac97_hw_remove(pdev); snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(pxa_ac97_dai_driver)); return 0; }