From patchwork Tue May 5 12:45:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 6337441 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0B677BEEE1 for ; Tue, 5 May 2015 12:46:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE6ED20270 for ; Tue, 5 May 2015 12:46:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6528C20268 for ; Tue, 5 May 2015 12:46:29 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E869A2616B9; Tue, 5 May 2015 14:46:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 28A922616B9; Tue, 5 May 2015 14:46:16 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E6E482617C1; Tue, 5 May 2015 14:46:10 +0200 (CEST) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by alsa0.perex.cz (Postfix) with ESMTP id 70E712616B9 for ; Tue, 5 May 2015 14:46:03 +0200 (CEST) Received: by pabtp1 with SMTP id tp1so192212013pab.2 for ; Tue, 05 May 2015 05:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=mXfVvo7pIkUPJ+C9EovSxi1w9+gr5SRRGDEwhBGP64c=; b=n+8csnuh9bOpVlrS2c4PxC4JNVwHM8cw8FRO5x0n/dAGkPphEfy3t520JwG72nKy0J 9s2YjBcQ5+GeHUZB5oXsk7WZGPeyuRz9UfsfvMBxjVwkwzGx2psDB6XYGRktKfKEHcEt KI2oTtFv9IoOQi6QN1WBig1ODJ0L7SALtDCPjutxdRnJki/6wI6c4pXfEcYTkcj/usb7 6Z3My+hVY//jo+CGkLDGjr7Y98GQmyzGGsjEiqR6EV4Xf54XKbGtvr0JpcVzgbRZuh/f UDSTOpDThZcHechVA5J/X5JCLPglmLV2oJEQk2mxJrY3b8to53M8rtcRJofKhskoVqO7 y62Q== X-Received: by 10.68.167.66 with SMTP id zm2mr51542075pbb.164.1430829961932; Tue, 05 May 2015 05:46:01 -0700 (PDT) Received: from localhost ([216.228.120.20]) by mx.google.com with ESMTPSA id fh9sm15928383pdb.17.2015.05.05.05.46.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2015 05:46:01 -0700 (PDT) From: Thierry Reding To: Takashi Iwai Date: Tue, 5 May 2015 14:45:57 +0200 Message-Id: <1430829957-1496-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.3.5 Cc: linux-tegra@vger.kernel.org, Alexandre Courbot , Dylan Reid , alsa-devel@alsa-project.org, Stephen Warren Subject: [alsa-devel] [PATCH] ALSA: hda/tegra - Fix oops X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Commit a41d122449be ("ALSA: hda - Embed bus into controller object") introduced a regression in the Tegra HDA driver that causes the following oops during boot: [ 2.333458] Unable to handle kernel NULL pointer dereference at virtual address 000004c4 [ 2.341537] pgd = c0004000 [ 2.344312] [000004c4] *pgd=00000000 [ 2.347898] Internal error: Oops: 5 [#1] PREEMPT SMP ARM [ 2.353200] Modules linked in: [ 2.356264] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.1.0-rc2-next-20150505-00344-g8577890defbf #79 [ 2.366682] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) [ 2.372939] task: ee0d8b40 ti: ee0da000 task.ti: ee0da000 [ 2.378336] PC is at azx_bus_init+0x18/0xf4 [ 2.382516] LR is at hda_tegra_probe+0x6c/0x478 [ 2.387043] pc : [] lr : [] psr: 60000113 [ 2.387043] sp : ee0dbe38 ip : 00000000 fp : 00000000 [ 2.398501] r10: ed874c00 r9 : 000000fd r8 : 00000000 [ 2.403717] r7 : ed874c10 r6 : 00000000 r5 : 00000000 r4 : ed016810 [ 2.410232] r3 : c08a2ad4 r2 : c08a1ea0 r1 : 00000000 r0 : ed016810 [ 2.416750] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 2.424046] Control: 10c5387d Table: 8000406a DAC: 00000015 [ 2.429783] Process swapper/0 (pid: 1, stack limit = 0xee0da210) [ 2.435778] Stack: (0xee0dbe38 to 0xee0dc000) [ 2.440129] be20: 00000000 ed016810 [ 2.448297] be40: 00000000 c061cf00 00000000 ee0dbe5c ed8735d0 c0a7bc48 ed02fd50 ed016000 [ 2.456462] be60: c1250164 ed874c10 c0c66bf8 fffffdfb 00000000 000000fd c0b8dc98 c046664c [ 2.464628] be80: c0466608 c1250164 ed874c10 00000000 c0c66bf8 c0464eb4 ed874c10 c0c66bf8 [ 2.472793] bea0: ed874c44 c0c43458 00000000 c04650d0 00000000 c0c66bf8 c046503c c04633b4 [ 2.480959] bec0: ee11bea4 ed85f390 c0c66bf8 ed017ac0 00000000 c0464634 c0ab2b7c c0c66bf8 [ 2.489125] bee0: c0bfde20 c0c66bf8 c0bfde20 ed01ce40 c0b7b414 c04656e8 c04665b0 c0bfde20 [ 2.497291] bf00: c0bfde20 c0009770 ee0d8b40 c0c02488 60000113 00000000 00000000 00000003 [ 2.505458] bf20: 00000000 c0c02488 60000113 00000000 c0b54598 c0b16a90 ef7fcc57 c0041228 [ 2.513624] bf40: c0a9150c ef7fcc5f 00000006 00000006 00000000 c0bf1fa8 c0bf2354 00000006 [ 2.521790] bf60: c0b8dc90 c0c7c000 c0c7c000 c0b8dc98 00000000 c0b54dd8 00000006 00000006 [ 2.529956] bf80: c0b54598 00000000 00000000 c07ff08c 00000000 00000000 00000000 00000000 [ 2.538122] bfa0: 00000000 c07ff094 00000000 c000f5a0 00000000 00000000 00000000 00000000 [ 2.546286] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 2.554451] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 fffff7ff c013f264 [ 2.562624] [] (azx_bus_init) from [] (hda_tegra_probe+0x6c/0x478) [ 2.570535] [] (hda_tegra_probe) from [] (platform_drv_probe+0x44/0xa4) [ 2.578879] [] (platform_drv_probe) from [] (driver_probe_device+0x174/0x2b8) [ 2.587739] [] (driver_probe_device) from [] (__driver_attach+0x94/0x98) [ 2.596172] [] (__driver_attach) from [] (bus_for_each_dev+0x6c/0xa0) [ 2.604342] [] (bus_for_each_dev) from [] (bus_add_driver+0x148/0x1f0) [ 2.612597] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 2.620593] [] (driver_register) from [] (do_one_initcall+0x8c/0x1d4) [ 2.628765] [] (do_one_initcall) from [] (kernel_init_freeable+0x144/0x1e4) [ 2.637459] [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe8) [ 2.645543] [] (kernel_init) from [] (ret_from_fork+0x14/0x34) This is caused by azx_bus_init() trying to dereference chip->card, which for the Tegra driver doesn't get initialized until sometime later during the call to hda_tegra_create(). Fix this by mimicking the behaviour of the Intel driver and defer HDA bus initialization until right before the call to snd_device_new(). Signed-off-by: Thierry Reding --- sound/pci/hda/hda_tegra.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 801e9fb4a467..db0bb50fa5b9 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -439,6 +439,10 @@ static int hda_tegra_create(struct snd_card *card, chip->single_cmd = false; chip->snoop = true; + err = azx_bus_init(chip, NULL, &hda_tegra_io_ops); + if (err < 0) + return err; + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { dev_err(card->dev, "Error creating device\n"); @@ -475,10 +479,6 @@ static int hda_tegra_probe(struct platform_device *pdev) return err; } - err = azx_bus_init(chip, NULL, &hda_tegra_io_ops); - if (err < 0) - goto out_free; - err = hda_tegra_create(card, driver_flags, hda); if (err < 0) goto out_free;