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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 6EA86C33CA2 for ; Thu, 9 Jan 2020 05:36:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43E79206ED for ; Thu, 9 Jan 2020 05:36:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="huiN23DI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbgAIFgf (ORCPT ); Thu, 9 Jan 2020 00:36:35 -0500 Received: from mail-il1-f194.google.com ([209.85.166.194]:37520 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbgAIFge (ORCPT ); Thu, 9 Jan 2020 00:36:34 -0500 Received: by mail-il1-f194.google.com with SMTP id t8so4723589iln.4 for ; Wed, 08 Jan 2020 21:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sAHhoFZ0iYCPxYt+rh/Px3+8GOp5DO3V29oeS42DXAM=; b=huiN23DIYcPHVv1KglkNFE9hwhktEqKgtWXiSkSJK5LmJDTbV3ps3AzdNKFwbVyRLU j6622puSU0EYgKiTBzKbjnldBj6p+SqrQ5IAZDpUi8Mwg/UESiWJuv042WLDon1jb0fb eG6eNsVZVo3F6z3ivbqJ842nbgPQHAGVoqVTN2RjedMNDHo32ifXrKlI4YvixtBl7NHU 2st3DsieNEM8T0b4/zNVLJJWvpkuCbrnmBaRNyYuw+F/Eviulg7v7aA8N2/pQkL2Ybet g/9n823BtG2EUxnmgbY6Vzbo5Id0yUpX+Kfy4DlJQVetjj4ZGHYyMnjKI3X+dy7LGIYJ LJyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sAHhoFZ0iYCPxYt+rh/Px3+8GOp5DO3V29oeS42DXAM=; b=JQ5xq110ktuw6PvPQMNBxdTJT26F7SgjiMsSXQ8qqjn0t6UUfGVyN8/TVwgwS+iD5b fTnYYfH+yzRKTQlB3+UjkrsbaUyGwHbFo1eO1pXTXw7Ucdb0oxJ+5H1+EvbDp71gCUhx 7UUN5H5vXud+focbHuX/9i/L5y7QHLG5w5HgND9MfIVulye3x0XSAR1MFn8WMymgy8PD v6b0ITMO7h3WKSP4lLq18sc4r9nQtey2gXhI2WfhNDcTjnSsTuA/YcDfp0Wiwl7i5eOM VNSCAplLKTOx/ZjU349/JlvQNNQAMunRp/pFyi7O8wydmc7s3SyZ/JkLgYeg4lc/1aDd 4TdA== X-Gm-Message-State: APjAAAXtRAYIwmFAsM79gLjYz5VFwu6JKQ01eULp/8813SWZ/VCMH4Uk /Xl0DU8E27NQIsWRz8cbXd0j+/H4VqnqmDBsh1Ubqg== X-Google-Smtp-Source: APXvYqzFc89SrQMcMWBXOOpciBA/UbRyMnmDTvKUFY09Y6diFKdpRQB/cIzzntYu/ZXrqm6Imlk1zgpmom3NbH7Nup8= X-Received: by 2002:a92:981b:: with SMTP id l27mr7483819ili.118.1578548194052; Wed, 08 Jan 2020 21:36:34 -0800 (PST) MIME-Version: 1.0 References: <20200108115007.31095-1-m.szyprowski@samsung.com> <20200108115007.31095-2-m.szyprowski@samsung.com> In-Reply-To: <20200108115007.31095-2-m.szyprowski@samsung.com> From: Tzung-Bi Shih Date: Thu, 9 Jan 2020 13:36:22 +0800 Message-ID: Subject: Re: [PATCH 2/2] ASoC: max98090: fix lockdep warning To: Marek Szyprowski Cc: ALSA development , Linux Kernel Mailing List , Linux Samsung SOC , Mark Brown , Sylwester Nawrocki , Dylan Reid , Jimmy Cheng-Yi Chiang , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 8, 2020 at 7:50 PM Marek Szyprowski wrote: > Fix this by introducing a separate mutex only for serializing the SHDN > hardware register related operations. This fix makes less sense to me. We used dapm_mutex intentionally because: both DAPM and userspace mixer control would change SHDN bit at the same time. > This fixes the following lockdep warning observed on Exynos4412-based > Odroid U3 board: > ====================================================== > WARNING: possible circular locking dependency detected > 5.5.0-rc5-next-20200107 #166 Not tainted > ------------------------------------------------------ > alsactl/1104 is trying to acquire lock: > ed0d50f4 (&card->dapm_mutex){+.+.}, at: max98090_shdn_save+0x1c/0x28 > > but task is already holding lock: > edb4b49c (&card->controls_rwsem){++++}, at: snd_ctl_ioctl+0xcc/0xbb8 > > which lock already depends on the new lock. > > the existing dependency chain (in reverse order) is: > > -> #1 (&card->controls_rwsem){++++}: > snd_ctl_add_replace+0x3c/0x84 > dapm_create_or_share_kcontrol+0x24c/0x2e0 > snd_soc_dapm_new_widgets+0x308/0x594 > snd_soc_bind_card+0x80c/0xad4 > devm_snd_soc_register_card+0x34/0x6c > odroid_audio_probe+0x288/0x34c > platform_drv_probe+0x6c/0xa4 > really_probe+0x200/0x490 > driver_probe_device+0x78/0x1f8 > bus_for_each_drv+0x74/0xb8 > __device_attach+0xd4/0x16c > bus_probe_device+0x88/0x90 > deferred_probe_work_func+0x3c/0xd0 > process_one_work+0x22c/0x7c4 > worker_thread+0x44/0x524 > kthread+0x130/0x164 > ret_from_fork+0x14/0x20 > 0x0 > > -> #0 (&card->dapm_mutex){+.+.}: > lock_acquire+0xe8/0x270 > __mutex_lock+0x9c/0xb18 > mutex_lock_nested+0x1c/0x24 > max98090_shdn_save+0x1c/0x28 > max98090_put_enum_double+0x20/0x40 > snd_ctl_ioctl+0x190/0xbb8 > ksys_ioctl+0x470/0xaf8 > ret_fast_syscall+0x0/0x28 > 0xbefaa564 As the stack trace suggested: when the card was still registering, alsactl can see the mixer control and try to change it. We have a discussion on an older thread (https://mailman.alsa-project.org/pipermail/alsa-devel/2019-December/160454.html). It is weird: userspace should not see things (e.g. no controlC0) until snd_card_register( ). I would like to spend some time to find the root cause. It would be a little challenging though (I have no real runtime to test...). 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=-0.7 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, 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 EE590C32771 for ; Thu, 9 Jan 2020 05:37:34 +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 EF7A8206ED for ; Thu, 9 Jan 2020 05:37:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="d+oNicqG"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="huiN23DI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF7A8206ED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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 E1B3E1705; Thu, 9 Jan 2020 06:36:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1B3E1705 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1578548252; bh=re43v0I2paeyl1NmMcsW40rlmiAcotJ+2aDSRfVvyQY=; h=References:In-Reply-To:From:Date:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d+oNicqGb74RxQGyBmsmLvtjdwuRPEFyRGuOmcqPOKSXtN1O5FA7NNAglHBi4+ALw pVU5PzYro+LOwD+Cgacovy9/ls+HW9QguohwksfwRhPADm2R0t64zLhSOSKG+nKjM1 Q0dWo/c4bCAOka+Tco85wdTbDTNLuQ5xo5FpfsaI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3CB35F8014E; Thu, 9 Jan 2020 06:36:41 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7B4A2F8015B; Thu, 9 Jan 2020 06:36:39 +0100 (CET) Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6A19AF80101 for ; Thu, 9 Jan 2020 06:36:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6A19AF80101 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="huiN23DI" Received: by mail-il1-x144.google.com with SMTP id s15so4727908iln.1 for ; Wed, 08 Jan 2020 21:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sAHhoFZ0iYCPxYt+rh/Px3+8GOp5DO3V29oeS42DXAM=; b=huiN23DIYcPHVv1KglkNFE9hwhktEqKgtWXiSkSJK5LmJDTbV3ps3AzdNKFwbVyRLU j6622puSU0EYgKiTBzKbjnldBj6p+SqrQ5IAZDpUi8Mwg/UESiWJuv042WLDon1jb0fb eG6eNsVZVo3F6z3ivbqJ842nbgPQHAGVoqVTN2RjedMNDHo32ifXrKlI4YvixtBl7NHU 2st3DsieNEM8T0b4/zNVLJJWvpkuCbrnmBaRNyYuw+F/Eviulg7v7aA8N2/pQkL2Ybet g/9n823BtG2EUxnmgbY6Vzbo5Id0yUpX+Kfy4DlJQVetjj4ZGHYyMnjKI3X+dy7LGIYJ LJyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sAHhoFZ0iYCPxYt+rh/Px3+8GOp5DO3V29oeS42DXAM=; b=gF2WRvK54GoGkcq30n4Yjk0HkhhqpM0eZJD1CdfJXrpbZ8z87F5B2lIMxekcyOtwNy fpG8lSHoNcz1W3Y1MLZ3RL8QsJ3UMsWKx/StX1J5tw1m6z2LKRtE9Pa8vcb5dDPrNOG/ ovh8dyTi73v7yyrpY2obFiUV4VtNddK+shuTB1Q2XL3uSKsZFv6R0uSbaINVTW4x9oGN lW9LpeaCsyHcFEI7Y9l/2O6VTpfgvW44jDe7zuNEj82kzq91h7Jm8Ik+B/sZZO3WKb0K ecGj9Gwi/slPmooXWo2sMj0qzpjbkZsFE4hQLEBl6f5Jr8Jm8ys8vrQmNyMTzDeS/6CH nTBA== X-Gm-Message-State: APjAAAVC98gtlCsIJmin5Iaai4HPBQjgYnYQNDSC8oQ77LMhlsD83+VZ Dj1emd16enchaYZg1O1dr2s0LsBl9z+cZ+TjmtkdvA== X-Google-Smtp-Source: APXvYqzFc89SrQMcMWBXOOpciBA/UbRyMnmDTvKUFY09Y6diFKdpRQB/cIzzntYu/ZXrqm6Imlk1zgpmom3NbH7Nup8= X-Received: by 2002:a92:981b:: with SMTP id l27mr7483819ili.118.1578548194052; Wed, 08 Jan 2020 21:36:34 -0800 (PST) MIME-Version: 1.0 References: <20200108115007.31095-1-m.szyprowski@samsung.com> <20200108115007.31095-2-m.szyprowski@samsung.com> In-Reply-To: <20200108115007.31095-2-m.szyprowski@samsung.com> From: Tzung-Bi Shih Date: Thu, 9 Jan 2020 13:36:22 +0800 Message-ID: To: Marek Szyprowski Cc: ALSA development , Linux Samsung SOC , Jimmy Cheng-Yi Chiang , Bartlomiej Zolnierkiewicz , Linux Kernel Mailing List , Krzysztof Kozlowski , Mark Brown , Sylwester Nawrocki , Dylan Reid Subject: Re: [alsa-devel] [PATCH 2/2] ASoC: max98090: fix lockdep warning 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, Jan 8, 2020 at 7:50 PM Marek Szyprowski wrote: > Fix this by introducing a separate mutex only for serializing the SHDN > hardware register related operations. This fix makes less sense to me. We used dapm_mutex intentionally because: both DAPM and userspace mixer control would change SHDN bit at the same time. > This fixes the following lockdep warning observed on Exynos4412-based > Odroid U3 board: > ====================================================== > WARNING: possible circular locking dependency detected > 5.5.0-rc5-next-20200107 #166 Not tainted > ------------------------------------------------------ > alsactl/1104 is trying to acquire lock: > ed0d50f4 (&card->dapm_mutex){+.+.}, at: max98090_shdn_save+0x1c/0x28 > > but task is already holding lock: > edb4b49c (&card->controls_rwsem){++++}, at: snd_ctl_ioctl+0xcc/0xbb8 > > which lock already depends on the new lock. > > the existing dependency chain (in reverse order) is: > > -> #1 (&card->controls_rwsem){++++}: > snd_ctl_add_replace+0x3c/0x84 > dapm_create_or_share_kcontrol+0x24c/0x2e0 > snd_soc_dapm_new_widgets+0x308/0x594 > snd_soc_bind_card+0x80c/0xad4 > devm_snd_soc_register_card+0x34/0x6c > odroid_audio_probe+0x288/0x34c > platform_drv_probe+0x6c/0xa4 > really_probe+0x200/0x490 > driver_probe_device+0x78/0x1f8 > bus_for_each_drv+0x74/0xb8 > __device_attach+0xd4/0x16c > bus_probe_device+0x88/0x90 > deferred_probe_work_func+0x3c/0xd0 > process_one_work+0x22c/0x7c4 > worker_thread+0x44/0x524 > kthread+0x130/0x164 > ret_from_fork+0x14/0x20 > 0x0 > > -> #0 (&card->dapm_mutex){+.+.}: > lock_acquire+0xe8/0x270 > __mutex_lock+0x9c/0xb18 > mutex_lock_nested+0x1c/0x24 > max98090_shdn_save+0x1c/0x28 > max98090_put_enum_double+0x20/0x40 > snd_ctl_ioctl+0x190/0xbb8 > ksys_ioctl+0x470/0xaf8 > ret_fast_syscall+0x0/0x28 > 0xbefaa564 As the stack trace suggested: when the card was still registering, alsactl can see the mixer control and try to change it. We have a discussion on an older thread (https://mailman.alsa-project.org/pipermail/alsa-devel/2019-December/160454.html). It is weird: userspace should not see things (e.g. no controlC0) until snd_card_register( ). I would like to spend some time to find the root cause. It would be a little challenging though (I have no real runtime to test...). _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel