From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 105A2C433E1 for ; Tue, 18 Aug 2020 02:53:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 626DA2075E for ; Tue, 18 Aug 2020 02:53:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="D6vf+9Km" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 626DA2075E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DDEB41678; Tue, 18 Aug 2020 04:53:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DDEB41678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597719236; bh=z4TZJzDLhEKg4zGiQcqi9hwHbFQpS5W3cYDgT8gFsbs=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=D6vf+9Km/ujFMvlvWx5X1NATrrs+iWdb0J0fQPvLCQ53Yc279wkbc+GTK+/mXpZep vvv0mwLb2jLjxoyFYVVwt6F/Jq5gnrZSmXEU73b6O9qXr/9Ii9Z6ZaCDGgNP75OYN2 ABS2ZY3t5sRYegT/+5FNuDK1puhQWO3EIPzKeSAw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5E7F0F80228; Tue, 18 Aug 2020 04:53:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09982F8023F; Tue, 18 Aug 2020 04:53:01 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 8F9BAF800D3 for ; Tue, 18 Aug 2020 04:52:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8F9BAF800D3 Date: 18 Aug 2020 11:52:53 +0900 X-IronPort-AV: E=Sophos;i="5.76,325,1592838000"; d="scan'208";a="54611195" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 18 Aug 2020 11:52:53 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 2B1314003880; Tue, 18 Aug 2020 11:52:53 +0900 (JST) Message-ID: <87wo1wfz0j.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Mark Brown , Pierre-Louis Bossart Subject: Re: [PATCH] ASoC: soc-core: use client_mutex for snd_soc_find_dai() In-Reply-To: <871rk4hean.wl-kuninori.morimoto.gx@renesas.com> References: <871rk4hean.wl-kuninori.morimoto.gx@renesas.com> User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi Mark > commit 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper") > added snd_soc_dai_link_set_capabilities(). > But it is using snd_soc_find_dai() (A) which is required client_mutex (B). > And client_mutex is soc-core.c local. > > struct snd_soc_dai *snd_soc_find_dai(xxx) > { > ... > (B) lockdep_assert_held(&client_mutex); > ... > } > > void snd_soc_dai_link_set_capabilities(xxx) > { > ... > for_each_pcm_streams(direction) { > ... > for_each_link_cpus(dai_link, i, cpu) { > (A) dai = snd_soc_find_dai(cpu); > ... > } > ... > for_each_link_codecs(dai_link, i, codec) { > (A) dai = snd_soc_find_dai(codec); > ... > } > } > ... > } > > Because of these background, we will get WARNING if .config has CONFIG_LOCKDEP. > > WARNING: CPU: 2 PID: 53 at sound/soc/soc-core.c:814 snd_soc_find_dai+0xf8/0x100 > CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.7.0-rc1+ #328 > Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT) > Workqueue: events deferred_probe_work_func > pstate: 60000005 (nZCv daif -PAN -UAO) > pc : snd_soc_find_dai+0xf8/0x100 > lr : snd_soc_find_dai+0xf4/0x100 > ... > Call trace: > snd_soc_find_dai+0xf8/0x100 > snd_soc_dai_link_set_capabilities+0xa0/0x16c > graph_dai_link_of_dpcm+0x390/0x3c0 > graph_for_each_link+0x134/0x200 > graph_probe+0x144/0x230 > platform_drv_probe+0x5c/0xb0 > really_probe+0xe4/0x430 > driver_probe_device+0x60/0xf4 > > Many drivers are already calling snd_soc_find_dai() and/or snd_soc_dai_link_set_capabilities(). > Thus, same thing can be happen on these drivers, too. > > > grep snd_soc_find_dai -rl sound/soc/* > sound/soc/samsung/tm2_wm5110.c > sound/soc/soc-core.c > sound/soc/soc-dai.c > sound/soc/soc-topology.c > sound/soc/sof/topology.c > > > grep snd_soc_dai_link_set_capabilities -rl sound/soc/* > sound/soc/generic/simple-card.c > sound/soc/generic/audio-graph-card.c > sound/soc/qcom/common.c > sound/soc/soc-dai.c I noticed that samsung / sof are using snd_soc_find_dai() under client_mutex. This means this patch creates deadlock for these. Hmm... we need both _with_mutex() and _without_mutex(). Thank you for your help !! Best regards --- Kuninori Morimoto