From patchwork Thu Mar 8 01:21:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10265777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 593F960247 for ; Thu, 8 Mar 2018 01:21:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 472E329253 for ; Thu, 8 Mar 2018 01:21:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45AEB29642; Thu, 8 Mar 2018 01:21:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BB5A2965C for ; Thu, 8 Mar 2018 01:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References: In-Reply-To:Subject:To:From:Message-ID:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yI8HyVH7anT/xiPa1vD78uYwpEML4WEkTLoicBlM0OY=; b=tFHztQlh9D8ZKIO3cviUt7YMMW StYh8FLl2G2LpBXfZsDerU5ljTCVMHNi0XCXSEUp3WKdFfEQywf6Z0JJhwLWoq9TbvOuiBbFP3fup s7TYT3rnHXUvtB4kTR8BlVdOMDymW5WZaHeSfxFtISTRgvtIHDaKLiB/m2OrJmWhjJcnHqP/3SDdx pLrn7LSMF/zMP09mxfIyt2w1Z4XGZMP5sWXmUtxtyfbUNnVe4St5nYQy9UtLv3ULIg07qgPHCmfLo HpHHj/KL1qZxAeQBgE/28mMOJ8sI2qRNJ2LFf0xjHdLtDJKr3WkEFzhhHGR3kprTHDHaFUfI4chze 1mdY3GNw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etkFK-0008J6-En; Thu, 08 Mar 2018 01:21:26 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie1.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1etkFE-0008GP-7x for linux-arm-kernel@lists.infradead.org; Thu, 08 Mar 2018 01:21:24 +0000 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 08 Mar 2018 10:21:07 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 1A2C66D839; Thu, 8 Mar 2018 10:21:07 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.47,438,1515423600"; d="scan'208";a="274517640" Received: from mail-os2jpn01lp0143.outbound.protection.outlook.com (HELO JPN01-OS2-obe.outbound.protection.outlook.com) ([23.103.139.143]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Mar 2018 10:21:06 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=QaYCc66T0PvuRJs2kN9aFzAu+vaTsP4VnHjqgqLUToc=; b=diWZbaYuUJT7P7Kh5D+sdQGdhQBjtZqixum1KP6rOxIovcJJ/5hSQXo43my7Kw+MtxKQs1QF2lhdYtCiw/HbUhwf9iuna0oKRocTxsKEjQlWcPHqTYpIFmneUwVlhrr9E7diPxYzsSnsnt9AdmUHOBNtz77JiSqBx3HeSEQJQxk= Received: from morimoto-PC.renesas.com (211.11.155.138) by TYAPR01MB2077.jpnprd01.prod.outlook.com (2603:1096:404:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Thu, 8 Mar 2018 01:21:02 +0000 Message-ID: <87efkvtldx.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Jernej =?ISO-8859-2?Q?=A9krabec?= Subject: Re: [BUG] Kernel crash on Allwinner H3 due to sound core changes In-Reply-To: <1832733.mujlD9skaR@jernej-laptop> References: <2424862.oPtAVTfrB9@jernej-laptop> <20180302124050.GF6255@sirena.org.uk> <26212674.B0xcQEiVyd@jernej-laptop> <1832733.mujlD9skaR@jernej-laptop> User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 8 Mar 2018 01:21:02 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: OSAPR01CA0047.jpnprd01.prod.outlook.com (2603:1096:603:14::35) To TYAPR01MB2077.jpnprd01.prod.outlook.com (2603:1096:404:7::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a433c81e-6236-4c65-340d-08d58492dbd0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:TYAPR01MB2077; X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2077; 3:rPM5gSNPulaHBZ1XtQYvp4CqVH2JLPfwttJNYv8w5c0YHmfa97ilM1alMRuA/NUfmvvnrC/XZbVClNsDc0BcZaruffCkyimpHWIRf9WbgVXz/DX57olCDipObwGvKi+5JFPEZ2sK/tkQ1HCXbim/N8LbxEISalvRqJQZ/11n6wWWGRiqOGU2bpzr09JiryZYL8rPcGDnLVnGZZAQNN3FKQzFvvemqxJQtslupySysrN3ER/yMj+V8qKzKE/gkgX7; 25:y6wJuDi3jc752LTD0Fk+KDoKbKrSHlyngAJeO29gXDOOi4GkICjaAcao+AbC8DRnLFLrIWlLhs4WnGup9/AfGJkzhmgNbTrgVLeMtoTzxGXKf4gbt00jvKB81vVjcle3M0cqcJFoYpBvjPTNZfjqTHKo5VrsHkcdEgK2IaNzlXj+uAXi8ilEYXRchChFM6o6ef45xinHqonlxXW6do3WvTx4RvwZ6+Hm+O7S4dRZFOVHRhpUhdyxDaVQyVUmdEjhyncT7Jk+ASzdmzKXr6SDYPtDp9wJ6pCYfmvpZi5wkJOQgADRHh4d4DIJpqX/LMascPLLRB/kh5kyTOKmuhz4qw==; 31:scrnx2npiZlO08bHtxAq+DLrkVBfoZz0Ool4sSp81TXsE6SE48WZ0VcxlauUfAGqiZ0kbDB64mO/VXco6sPHCtdw2G7GU1Fnei7YmZoRYkejdmy/dsJuvVOjCFrtxxi6oRx5brnehWxPDqSSgA1i3npenRWC/Lzx+fEOiWRMikYuCLiA38/8jsk+rAr3ooF/VUfjf9JbO2YY3PB/pqZv3hYRLdTJxF55/6bH0pzcyns= X-MS-TrafficTypeDiagnostic: TYAPR01MB2077: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2077; 20:IEoAeCwM9NvjJujKZwJdrfA8qgT8DPDcxTcj/F007yuysawwdJniBKMQzXc2chAC8tVv+Xeu4f57CulN1BFnEan5//sfwklsDAmV/WmtyEBwuIfIYIcFJBYwYOF3+mARh8SdVcA0g2SB2MqjjGpO6Vn+lUTs0EKGEu+SG9ZPaRMytA6h72mufPvHcxFwUB/4s/kxUJ9uqPjgyD/vp2WZKMmMvkxiuRn0Ryf0lxBVp61x/sTOjm9QNt5fekrGBTcpku4dbOTFnJ6h7GYk8JkajD8pk9tyk92n1TanBmBnbmbXsetCZ11KbPBHHp8srbklWpmHn9qaT8WRQwVyHfjx0SWyw7+qYBrPRF5HbUyGdlmbwxVfe6Li+V6ZPMk6IRxjJXR49bCOU7F89C2o5Z7hdLXIJqaAxRMO0y1hYhpr0jMAv/ZYlyADE9pmQaGD2HX40JC35f+jetyBoKuE5b6OcF3DVapAWqJ8tQdpwbVmC9e0/IiToV5wkpi54X6qid5A; 4:NmGSI0hvn3AECItKGAxqTF4C7WxEO8dQ1Az7Yqt3fyVt43Fxu/NAAH3YgmPcK56y9XAiYTXzth48WJJU7N1DDZIFnd2qCONZ1TJb7Z+esk3+SFbglxJZ2JtHzwJkk+2d195WpdaZc55gobRlnRsfurSRVX9jPyMJMzrml0LNCW/gKTflBT1A4IvuqpoOalwlhwZsJfwGjTJeLLmGaObXC5gxHg3KYaEKHNgb85mUNGsNatqSJo+JX1ezT2PAYTPriUKwMp/RvkOlkFbH8dPf/WAcWVogdzw2uwlRfnWpvhNmCLkcaFXZsv9gcCXp+BxG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(3231220)(944501244)(52105095)(10201501046)(6055026)(6041288)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:TYAPR01MB2077; BCL:0; PCL:0; RULEID:; SRVR:TYAPR01MB2077; X-Forefront-PRVS: 060503E79B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39380400002)(376002)(396003)(366004)(39860400002)(346002)(189003)(199004)(229853002)(5660300001)(6916009)(23726003)(53416004)(2950100002)(575784001)(86362001)(3846002)(36756003)(81156014)(81166006)(8676002)(6116002)(47776003)(8936002)(97736004)(66066001)(7736002)(305945005)(50466002)(4326008)(105586002)(106356001)(69596002)(2906002)(76176011)(25786009)(58126008)(7696005)(16526019)(93886005)(186003)(386003)(68736007)(54906003)(316002)(52116002)(59450400001)(26005)(345774005)(6246003)(16586007)(53936002)(6486002)(478600001)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:TYAPR01MB2077; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; TYAPR01MB2077; 23:IrvALx/5XNCGlww8BYxiC3qB5LDp8TldKzb5TGsCC?= =?us-ascii?Q?grSUKFhct10W1osY/5qlS95SazqtK59+FdAziRCOI/qrOtSPVEdTh+9hNTYC?= =?us-ascii?Q?nAY3ac6xyq6XEnGW3WxAIn8RZ1ktlkVPVu9Hk8T7v0535vXGm8wdD4PFT4HR?= =?us-ascii?Q?mfIMg159kYuKrh27N7iGC+uTWMnKG96mOx+wf5ZoCVI/T1Cv3wYhC1S1x5Z1?= =?us-ascii?Q?IIIPmY3HKyr5FHmJUhX393Zrw4B9ILjhWZgixaEQyfILb2Yz9szHYbm101kZ?= =?us-ascii?Q?yMJtFOOF7oQFT2hWVxxG5GBe/m2GhCoz9HJ28b5gOUn/KhhjFSw3P0BSGx/V?= =?us-ascii?Q?ZOzB5NK/3E5S+zon58ipVANNok8D0RqVVFljmToF2zd/vLpAK27hGMywbMKB?= =?us-ascii?Q?S2yCJ5toJDqQ/5cbs/kWtNiZw2vRan/az3NJTDyGxoPpWyPilug86DLv+186?= =?us-ascii?Q?axvJmiJV+z+DjZqiavwhtkifnHg86Uu4k0O8kz9K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-Microsoft-Exchange-Diagnostics: 1; TYAPR01MB2077; 20:kE8E+YAjqwiN6idsYCUwZ0EWfCVTKq+tC6N8fn9IZuT9zhKlWtT/2ySiezc30caQ6qTM8UoVtQOWLC2i6cfj04powkftPKUM/EvBiObpt5kz0NSo9prt7kp61GBfb81B7T6qMWk61wSID6RkDMBby9E0erys8PyPEQfEOUYo8tE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2018 01:21:02.7146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a433c81e-6236-4c65-340d-08d58492dbd0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB2077 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180307_172121_894762_2701D202 X-CRM114-Status: GOOD ( 24.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, wens@csie.org, Mark Brown , maxime.ripard@free-electrons.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jernej Thank you for your hard work > I found the issue. Commit be7ee5f32a9a ("ASoC: soc-generic-dmaengine-pcm: > replace platform to component") changes struct dmaengine_pcm: > > struct dmaengine_pcm { > struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; > const struct snd_dmaengine_pcm_config *config; > - struct snd_soc_platform platform; > + struct snd_soc_component component; > unsigned int flags; > }; > > In snd_dmaengine_pcm_register(): > ret = snd_soc_add_component(dev, &pcm->component, > &dmaengine_pcm_component, NULL, 0); > > And now, sun4i-codec first time returns -EPROBE_DEFER since driver for analog > part is not yet loaded. Because of that, all components get destroyed. > > snd_dmaengine_pcm_unregister() calls snd_soc_unregister_component() and that > one calls __snd_soc_unregister_component() multiple times (until it fails). > > Issue is that __snd_soc_unregister_component() uses kfree() on component > pointer and that naturally can't succed since component was never kmalloc'ed > since it is a part of a bigger structure - struct dmaengine_pcm. > > What would be the best fix? Changing struct dmaengine_pcm to have pointer to a > component, so it can be freed? Ahh.. indeed. Good catch ! How about to add such flag ? This is just idea. No tested, No compiled, but can help you ? One note here is that reusing "registered_as_component" flag is not good idea, because it will be removed when platform/codec were removed ------------------------ ------------------------ Reported-by: Jernej Skrabec Tested-by: Jernej Skrabec diff --git a/include/sound/soc.h b/include/sound/soc.h index 1a73232..b9b1b4c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -853,6 +853,7 @@ struct snd_soc_component { unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ unsigned int registered_as_component:1; unsigned int suspended:1; /* is in suspend PM state */ + unsigned int alloced_component:1; struct list_head list; struct list_head card_aux_list; /* for auxiliary bound components */ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c0edac8..0e33bcf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3492,6 +3492,7 @@ int snd_soc_register_component(struct device *dev, if (!component) return -ENOMEM; + component->alloced_component = 1; return snd_soc_add_component(dev, component, component_driver, dai_drv, num_dai); } @@ -3523,7 +3524,9 @@ static int __snd_soc_unregister_component(struct device *dev) if (found) { snd_soc_component_cleanup(component); - kfree(component); + + if (component->alloced_component) + kfree(component); } return found;