From patchwork Mon Apr 17 00:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13213103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3087FC77B61 for ; Mon, 17 Apr 2023 00:36:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 95391828; Mon, 17 Apr 2023 02:35:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 95391828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681691796; bh=+a7xq7iJPVLoWDcmmRXsUim5Mp++u52XLu5ufYRvHns=; h=From:Subject:To:In-Reply-To:References:Date:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=O2/sX+xp4WRPHwqFlK6gsSS7mZoID3p9F5PYoZwlQGRLnXVYiUH5ilTegzCweudzJ 4limal2Vzs/KNaS84LPvQpGSMIjxF2ssCmgIgZP2IYqJwAC3F9pnxZ7zqrNQTvgLCh loumQG6G9Y5F0APuZQFVbx0Da6tak02kW3vGzENs= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E68F0F80266; Mon, 17 Apr 2023 02:35:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1D7B8F8051F; Mon, 17 Apr 2023 02:35:12 +0200 (CEST) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on20714.outbound.protection.outlook.com [IPv6:2a01:111:f403:700c::714]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C1E07F80266 for ; Mon, 17 Apr 2023 02:35:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C1E07F80266 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=a0RPZvHp ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MO1oo8sjcXaca/p9P6KuTUcPuRFSxVLydxeLs0lOS/Zly19SNywjYiSvoO+NWb62QQ+F9u/rJ1cCzFeQTbIm7zW0n2Pf8dHTR4wATRS4pS3JBsQpvbQhqqfFFITb+RhfdOaERqsjH1yt5gd2aK5yBGQ4pJdJ9t2q1Oe4EPUkvc5Lkcm9lbIMnV0wgePzw0X2iqGgNgU63ZVqx9sy867R3f58pP4JWnghUVHWOqRGa48Zw0qJtASAp86FZvLAr0EWqdysZqOuLL/EciqOG9ASEcb7KN0EqsvehC9l6cSSwBUsyICvjYxBlIPATuUMxE/svvL222QiSvtuBvnKjFeOjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CGRpMTZYh26PHAM6a/6qiKOkJR5WKm2V+d4xrqzHoMY=; b=YCl0uVwcjq+EF0ZURp0ObXlyV7yTfSuXTbOqP21YRnO66/UPpehWzA3jKde+Wflq57DGlwPTbYzieL63KlpBsr+wDGOYTGQTMXUggE6W1MO/gCYj1m44R8svLBVQ2StI+09JHWqe0vXdL3LYOomHNAJ1uQllC/xtAtbZSlgyTkR0A9O5ISbJRnD0aMBkPfwObI7TixK3tYbYQykOsdnppiwct0p5YaGe+1s+GFfppeH6b4nUFVbc75p0jEjZ/nNoSYxCvp/23qVluKgbqvzmkoaUEVJzNdKSu5RKEOdfED/e7le98ZjGQDgDO5xcFtB/KkhJgsOvOHJwYP62ecYxcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CGRpMTZYh26PHAM6a/6qiKOkJR5WKm2V+d4xrqzHoMY=; b=a0RPZvHpFCdoqXtEnYMVyxFTA1gCYgAEs5FucVtId6uMqVWu5cPJQRWIZK/T7CxaIwwcKem2Gft74vtZFa3OQq8JCxDacH0vAFfgeLbOSWOumkJUiO3ANFtqCRqN1yXrqTZrcY3FoKsiyVmpTGIGmvNZk2aXa0XOf1M0fNmIc18= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYWPR01MB9388.jpnprd01.prod.outlook.com (2603:1096:400:1a5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 00:34:54 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1%3]) with mapi id 15.20.6298.045; Mon, 17 Apr 2023 00:34:54 +0000 Message-ID: <87jzybtkgi.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH resend 1/3] ASoC: expand snd_soc_dapm_mutex_lock/unlock() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown In-Reply-To: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> References: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 17 Apr 2023 00:34:54 +0000 X-ClientProxiedBy: TYAPR03CA0018.apcprd03.prod.outlook.com (2603:1096:404:14::30) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYWPR01MB9388:EE_ X-MS-Office365-Filtering-Correlation-Id: e54ac614-5aa7-43f4-28fb-08db3edb907b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RTRv0y2Ner5Gpk6m6CnKOSTgC+CINyVxF1/q9wJk0oulMXL8zqhGTl750xx6bofFP/5Pme10nT1y+gvESyLemOId5wFqddL7M4MzqllxR7n3q60MDcQEp6+f3FYQhtdJfAP+qCtBKWCMRM7rXXcVSMC0gRTLmtVt6Ho7fUuebxAhUYql1kiaaEWaiLGIvOqx2255NGyk58HMLFxjnBGeGgQPZxzu9Y27B4ZX3S+oQJsn6Yv7wW2e/gCVcxoWUjSQOKy3+U5k4DciaWDKlX4vEUsrZWRrfX9ZCnRRdTVoKhZdIOW5bZqwd9UfhsbTGo7ip4KdIuy1i1tHLc+BzEwmXdslATse0bPFe3OIrAYzY/OCFz6GbpvvnIdAkBiP1zxnb7fUxYUhq6MJmo0UYa04L8dtYsCwgIjad50xLhGYyZsG1J//imgm5pvZWzC8Wd2uhRuDhKleBiGb/yHEPK9auGEwvWlZItEmEDv5tyLxkKjW+s8Ue8YZmF9d6i0NTfEjk8k6CvPRXTpvCDnV3k+N523BK2kk5q9F3MgQ+jAbz3bTw28jVsrRMR0oHC9duzHVpvgc2Rc89wALZl4gPSZ3SNAuuk+eBzMGkP5X4V6K+Uda58kxC6NbV5zZI6/8ws57eaZNJv+tViD0BMKCxSskiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(396003)(366004)(346002)(376002)(451199021)(36756003)(2906002)(30864003)(5660300002)(8936002)(8676002)(41300700001)(38350700002)(38100700002)(86362001)(478600001)(2616005)(6506007)(26005)(6512007)(186003)(6486002)(52116002)(4326008)(6916009)(66476007)(66556008)(66946007)(316002)(83380400001)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: REVT69IQPVqYF9Tm2PqPXe/tUx0CZtFN3UxcHlRMI6Aw0dk0DuTaaG5XpxnjRRG28IkVUWDTF1JNWQjntDJ84lV3Lh1JTEgAuynJwsnfGN8KbNqXeH9XmtGj1c0Qwvf/+Ked+xYsjeivsdai0Hqbq0mRWVF3da8C3xIp8arLdUyrO442oMmvv5vjWYVvDgs4NSSpU3+tuzOujZODofEVLttirk0taa4PPROqkacPIaWCFKKeSQ0HeNacmxKpzRSnJewms/2hFlTZ6/ezdUTgRSnQ5gRXoAPPUQwjE8/ThvZDrLFHYM8Kg7yi/bCNCc4M5UT5cY9GfaI8MoVcSY/xV7G5joPwcS+OohRDtRQ9Krf/6OLQ+3lHAGJqDOYvUIK2hsZ28aRvC+Ux7KWKtbdWek6i6jexXWrsvosJTLkeND5p/w5ApOOlwZL+lPM6KRT0pCsVMUuJN8yALTgk3huq3gkNLDaWkQLV5POmWA3yk1e2HZatkqu5kUPPc1mCzVVc/RymqQqJOqsvs/YFGN2Jc2NX4zUv/6c++OxZ+cQlMInPRT1fD7xVCFopdxvfWZukBQ756RkNWKtp7JaoyNd7IICb2mR1OXfxgT0zQeNzgP+2h6MlKDvRWFViqd6rh9wPvpdXFNCFjyupxb9+qPoo3BYahTFSir4Xa8kCofoPUGrOBR9OnhQYBRqCOSGdx7NTyQfP7qr8N/8cOGKuv7lEd93iwd/9OeBSDtS9VI0eqFVDiBF2UeZukQVlkBlm9t+PYdW/aLu1FQjfYqUSPPFquTfTA0gbmVbtQIylWh9b0F37A7dKhjmqNzDTdrvIrL2iUGJiR27F/8DALoryjSsePkiaKVmCVvx5d4MFJCzpJjGs8iN4GhKYxWupFLK5VO4wfwsmsCcZKEqyD9PCTMEsS8ivq35i5V++OojdIIJ+SQ3eZfi/3s01/Iam7eXnx8SA1csqXKR/q7L4tMkG3KaKjCfMQaLflMEHobIPx7i9uj+JT7LTKAG/oDaGW5wWIUJG7JPYn8GWXBzDGlNKZuQJkvfNup4qEbGOscKNGiHjPPGQw6EyfyEFoF/vmjwf+5urbEfSMwUggZrMmc1F217wYIn7/7aKkXIpaN/N8/bFeZCapmPnVimLVTzC+QeM9X4YCYR0E8LHDWMbt7hdt1MDeCUntfpMMBJpBz0BmcU7yijvw5kLG7n84SzLX5jXP2ywEDlrQr8E6QfGFKKsx24umb4LDf/U0ZMejswXLNJGwtJyciuYNKPcQexHSgUJ+3b64+yBnnsxvmhMboaIPoCMP8CsQ7VmUsbTvFr9rWSiioPems3KaP5ir6EOUG5OI9OC8r2R9gQQliLgwM61y8/UKpuHcL5wrVszOjmYUZ8yWr0eIHmXe0XNsPmFUDgVrxoQVtNM+HLTBtgkCGp0fKpy701mzm1Cvc/3MH2zNqlsO0qyJj5/J+6rFVSCRrtnBCXTcVMDlVd1EouliUAO7g8zj5bKI8beoL1v7iOVcMi40PYD1fRP4Hwbyph/L7DrXcIehdOMsKlmDw6WHMTSjeL4eYEwSc4ZWSnY42S3ZpXVSHVNqLed7wYGSSM6C5uRwwnZBGOgux+wux9osjI7/jQzV9vqlcJDWvjt3v5pw7OjeR8= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: e54ac614-5aa7-43f4-28fb-08db3edb907b X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 00:34:54.6898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ROAXK1RexiqAuTMydzRPrs/bW2uc5gr/oxA5yEiO7WS4HLzvt9+a3o+iPAWMq6uFKkNcg5CI5prYhhbOmYThmLFyWtqMz8xju/y5Wsw6PptSclWbZgsiIQovItcEHmG8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9388 Message-ID-Hash: 6MBVFGROLDJMZB3GXAQRVBKKCDGUXKJ2 X-Message-ID-Hash: 6MBVFGROLDJMZB3GXAQRVBKKCDGUXKJ2 X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Linux-ALSA X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: soc.h has snd_soc_dapm_mutex_lock/unlock() definition and many drivers are using it, but soc-dapm.c is not. 1st reason is snd_soc_dapm_mutex_lock/unlock() requests snd_soc_dapm_context pointer as parameter (A), but sometimes soc-dapm.c needs to use snd_soc_card (B). (A) static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) { mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); } ^^^^^^^^^^ (B) mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); ^^^^ 2nd reason is it want to use SND_SOC_DAPM_CLASS_INIT for mutex_lock_nested(), but helper is using _RUNTIME (A). The conclusion is we want to use "dapm vs card" and "_RUNTIME vs _INIT" for dapm lock/unlock. To enable this selfish request, this patch uses _Generic macro. We can use snd_soc_dapm_mutex_lock/unlock() for both dapm and card case. snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_unlock(dapm); snd_soc_dapm_mutex_lock(card); snd_soc_dapm_mutex_unlock(card); Current soc-dapm.c is using both mutex_lock() and mutex_lock_nested(). This patch handles mutex_lock() as mutex_lock_nested(..., 0), in other words, handles below as same. mutex_lock(&card->dapm_mutex); mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); Because people might misunderstand that _init() is mutex initialization, this patch renames _INIT to _ROOT and adds new snd_soc_dapm_mutex_lock_root() for it. This patch also moves snd_soc_dapm_subclass definition from soc-dapm.h to soc.h to keep related code together. Because very complex soc.h vs soc-dapm.h relationship, it is difficult/impossible to define these helper into soc-dapm.h. Signed-off-by: Kuninori Morimoto --- include/sound/soc-dapm.h | 5 -- include/sound/soc.h | 60 ++++++++++++++++++-- sound/soc/soc-dapm.c | 119 +++++++++++++++++++-------------------- 3 files changed, 113 insertions(+), 71 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 64915ebd641e..87f8e1793af1 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -527,11 +527,6 @@ enum snd_soc_dapm_type { SND_SOC_DAPM_TYPE_COUNT }; -enum snd_soc_dapm_subclass { - SND_SOC_DAPM_CLASS_INIT = 0, - SND_SOC_DAPM_CLASS_RUNTIME = 1, -}; - /* * DAPM audio route definition. * diff --git a/include/sound/soc.h b/include/sound/soc.h index 3833184c187f..0e17e3230c7a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1364,17 +1364,67 @@ extern struct dentry *snd_soc_debugfs_root; extern const struct dev_pm_ops snd_soc_pm_ops; -/* Helper functions */ -static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) +/* + * DAPM helper functions + */ +enum snd_soc_dapm_subclass { + SND_SOC_DAPM_CLASS_ROOT = 0, + SND_SOC_DAPM_CLASS_RUNTIME = 1, +}; + +static inline void _snd_soc_dapm_mutex_lock_root_c(struct snd_soc_card *card) +{ + mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_ROOT); +} + +static inline void _snd_soc_dapm_mutex_lock_c(struct snd_soc_card *card) +{ + mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); +} + +static inline void _snd_soc_dapm_mutex_unlock_c(struct snd_soc_card *card) { - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + mutex_unlock(&card->dapm_mutex); } -static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) +static inline void _snd_soc_dapm_mutex_assert_held_c(struct snd_soc_card *card) { - mutex_unlock(&dapm->card->dapm_mutex); + lockdep_assert_held(&card->dapm_mutex); } +static inline void _snd_soc_dapm_mutex_lock_root_d(struct snd_soc_dapm_context *dapm) +{ + _snd_soc_dapm_mutex_lock_root_c(dapm->card); +} + +static inline void _snd_soc_dapm_mutex_lock_d(struct snd_soc_dapm_context *dapm) +{ + _snd_soc_dapm_mutex_lock_c(dapm->card); +} + +static inline void _snd_soc_dapm_mutex_unlock_d(struct snd_soc_dapm_context *dapm) +{ + _snd_soc_dapm_mutex_unlock_c(dapm->card); +} + +static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context *dapm) +{ + _snd_soc_dapm_mutex_assert_held_c(dapm->card); +} + +#define snd_soc_dapm_mutex_lock_root(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dapm_mutex_lock_root_c, \ + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_root_d)(x) +#define snd_soc_dapm_mutex_lock(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dapm_mutex_lock_c, \ + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_lock_d)(x) +#define snd_soc_dapm_mutex_unlock(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dapm_mutex_unlock_c, \ + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_unlock_d)(x) +#define snd_soc_dapm_mutex_assert_held(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \ + struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x) + #include #include #include diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 36e6f261bcf7..f2f04ce693a1 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -150,7 +150,7 @@ static int dapm_down_seq[] = { static void dapm_assert_locked(struct snd_soc_dapm_context *dapm) { if (snd_soc_card_is_instantiated(dapm->card)) - lockdep_assert_held(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_assert_held(dapm); } static void pop_wait(u32 pop_time) @@ -302,7 +302,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card) { struct snd_soc_dapm_widget *w; - mutex_lock(&card->dapm_mutex); + snd_soc_dapm_mutex_lock_root(card); for_each_card_widgets(card, w) { if (w->is_ep) { @@ -314,7 +314,7 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card) } } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); } EXPORT_SYMBOL_GPL(dapm_mark_endpoints_dirty); @@ -604,7 +604,7 @@ static void dapm_reset(struct snd_soc_card *card) { struct snd_soc_dapm_widget *w; - lockdep_assert_held(&card->dapm_mutex); + snd_soc_dapm_mutex_assert_held(card); memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); @@ -1302,7 +1302,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, int paths; int ret; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { invalidate_paths_ep(w, SND_SOC_DAPM_DIR_OUT); @@ -1322,7 +1322,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, paths = ret; trace_snd_soc_dapm_connected(paths, stream); - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); return paths; } @@ -1952,7 +1952,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) enum snd_soc_bias_level bias; int ret; - lockdep_assert_held(&card->dapm_mutex); + snd_soc_dapm_mutex_assert_held(card); trace_snd_soc_dapm_start(card); @@ -2090,7 +2090,6 @@ static ssize_t dapm_widget_power_read_file(struct file *file, size_t count, loff_t *ppos) { struct snd_soc_dapm_widget *w = file->private_data; - struct snd_soc_card *card = w->dapm->card; enum snd_soc_dapm_direction dir, rdir; char *buf; int in, out; @@ -2101,7 +2100,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, if (!buf) return -ENOMEM; - mutex_lock(&card->dapm_mutex); + snd_soc_dapm_mutex_lock_root(w->dapm); /* Supply widgets are not handled by is_connected_{input,output}_ep() */ if (w->is_supply) { @@ -2145,7 +2144,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, } } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(w->dapm); ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); @@ -2266,7 +2265,7 @@ static int soc_dapm_mux_update_power(struct snd_soc_card *card, int found = 0; bool connect; - lockdep_assert_held(&card->dapm_mutex); + snd_soc_dapm_mutex_assert_held(card); /* find dapm widget path assoc with kcontrol */ dapm_kcontrol_for_each_path(path, kcontrol) { @@ -2293,11 +2292,11 @@ int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, struct snd_soc_card *card = dapm->card; int ret; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); card->update = update; ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); card->update = NULL; - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); if (ret > 0) snd_soc_dpcm_runtime_update(card); return ret; @@ -2312,7 +2311,7 @@ static int soc_dapm_mixer_update_power(struct snd_soc_card *card, struct snd_soc_dapm_path *path; int found = 0; - lockdep_assert_held(&card->dapm_mutex); + snd_soc_dapm_mutex_assert_held(card); /* find dapm widget path assoc with kcontrol */ dapm_kcontrol_for_each_path(path, kcontrol) { @@ -2358,11 +2357,11 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, struct snd_soc_card *card = dapm->card; int ret; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); card->update = update; ret = soc_dapm_mixer_update_power(card, kcontrol, connect, -1); card->update = NULL; - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); if (ret > 0) snd_soc_dpcm_runtime_update(card); return ret; @@ -2441,7 +2440,7 @@ static ssize_t dapm_widget_show(struct device *dev, struct snd_soc_dai *codec_dai; int i, count = 0; - mutex_lock(&rtd->card->dapm_mutex); + snd_soc_dapm_mutex_lock_root(rtd->card); for_each_rtd_codec_dais(rtd, i, codec_dai) { struct snd_soc_component *cmpnt = codec_dai->component; @@ -2449,7 +2448,7 @@ static ssize_t dapm_widget_show(struct device *dev, count = dapm_widget_show_component(cmpnt, buf, count); } - mutex_unlock(&rtd->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(rtd->card); return count; } @@ -2632,9 +2631,9 @@ int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm) { int ret; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); ret = snd_soc_dapm_sync_unlocked(dapm); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } EXPORT_SYMBOL_GPL(snd_soc_dapm_sync); @@ -2703,9 +2702,9 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); int ret; - mutex_lock_nested(&rtd->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(rtd->card); ret = dapm_update_dai_unlocked(substream, params, dai); - mutex_unlock(&rtd->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(rtd->card); return ret; } @@ -3090,14 +3089,14 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, { int i, ret = 0; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); for (i = 0; i < num; i++) { int r = snd_soc_dapm_add_route(dapm, route); if (r < 0) ret = r; route++; } - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -3116,12 +3115,12 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, { int i; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); for (i = 0; i < num; i++) { snd_soc_dapm_del_route(dapm, route); route++; } - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return 0; } @@ -3194,14 +3193,14 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, int i; int ret = 0; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); + snd_soc_dapm_mutex_lock_root(dapm); for (i = 0; i < num; i++) { int err = snd_soc_dapm_weak_route(dapm, route); if (err) ret = err; route++; } - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -3220,7 +3219,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) struct snd_soc_dapm_widget *w; unsigned int val; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); + snd_soc_dapm_mutex_lock_root(card); for_each_card_widgets(card, w) { @@ -3232,7 +3231,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) sizeof(struct snd_kcontrol *), GFP_KERNEL); if (!w->kcontrols) { - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); return -ENOMEM; } } @@ -3275,7 +3274,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) } dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP); - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); return 0; } EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); @@ -3293,7 +3292,6 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_card *card = dapm->card; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -3304,7 +3302,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, unsigned int invert = mc->invert; unsigned int reg_val, val, rval = 0; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) { reg_val = soc_dapm_read(dapm, reg); val = (reg_val >> shift) & mask; @@ -3321,7 +3319,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, if (snd_soc_volsw_is_stereo(mc)) rval = (reg_val >> width) & mask; } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); if (invert) ucontrol->value.integer.value[0] = max - val; @@ -3379,7 +3377,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, rval = max - rval; } - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); /* This assumes field width < (bits in unsigned int / 2) */ if (width > sizeof(unsigned int) * 8 / 2) @@ -3421,7 +3419,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, card->update = NULL; } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); if (ret > 0) snd_soc_dpcm_runtime_update(card); @@ -3443,17 +3441,16 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_card *card = dapm->card; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int reg_val, val; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); if (e->reg != SND_SOC_NOPM && dapm_kcontrol_is_powered(kcontrol)) { reg_val = soc_dapm_read(dapm, e->reg); } else { reg_val = dapm_kcontrol_get_value(kcontrol); } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); val = (reg_val >> e->shift_l) & e->mask; ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val); @@ -3500,7 +3497,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, mask |= e->mask << e->shift_r; } - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); change = dapm_kcontrol_set_value(kcontrol, val); @@ -3521,7 +3518,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, card->update = NULL; } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); if (ret > 0) snd_soc_dpcm_runtime_update(card); @@ -3562,12 +3559,12 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); const char *pin = (const char *)kcontrol->private_value; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); ucontrol->value.integer.value[0] = snd_soc_dapm_get_pin_status(&card->dapm, pin); - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); return 0; } @@ -3586,10 +3583,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, const char *pin = (const char *)kcontrol->private_value; int ret; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); ret = __snd_soc_dapm_set_pin(&card->dapm, pin, !!ucontrol->value.integer.value[0]); - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); snd_soc_dapm_sync(&card->dapm); return ret; @@ -3762,9 +3759,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, { struct snd_soc_dapm_widget *w; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); w = snd_soc_dapm_new_control_unlocked(dapm, widget); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return w; } @@ -3787,7 +3784,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, int i; int ret = 0; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); + snd_soc_dapm_mutex_lock_root(dapm); for (i = 0; i < num; i++) { struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); if (IS_ERR(w)) { @@ -3796,7 +3793,7 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, } widget++; } - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls); @@ -4499,9 +4496,9 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, { struct snd_soc_card *card = rtd->card; - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(card); soc_dapm_stream_event(rtd, stream, event); - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); } void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) @@ -4562,11 +4559,11 @@ int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) { int ret; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); ret = snd_soc_dapm_set_pin(dapm, pin, 1); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -4630,11 +4627,11 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, { int ret; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -4674,11 +4671,11 @@ int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, { int ret; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); ret = snd_soc_dapm_set_pin(dapm, pin, 0); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -4725,11 +4722,11 @@ int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) { int ret; - mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + snd_soc_dapm_mutex_lock(dapm); ret = snd_soc_dapm_set_pin(dapm, pin, 0); - mutex_unlock(&dapm->card->dapm_mutex); + snd_soc_dapm_mutex_unlock(dapm); return ret; } @@ -4826,7 +4823,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) LIST_HEAD(down_list); int powerdown = 0; - mutex_lock(&card->dapm_mutex); + snd_soc_dapm_mutex_lock_root(card); for_each_card_widgets(dapm->card, w) { if (w->dapm != dapm) @@ -4851,7 +4848,7 @@ static void soc_dapm_shutdown_dapm(struct snd_soc_dapm_context *dapm) SND_SOC_BIAS_STANDBY); } - mutex_unlock(&card->dapm_mutex); + snd_soc_dapm_mutex_unlock(card); } /* From patchwork Mon Apr 17 00:35:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13213104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id ACDDDC77B73 for ; Mon, 17 Apr 2023 00:36:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 66E88A4C; Mon, 17 Apr 2023 02:35:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 66E88A4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681691802; bh=GEUdF9JsMfSOLFAnhalNoSjqblqXpNVqiKG9YQ2+qOs=; h=From:Subject:To:In-Reply-To:References:Date:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=glqcgyTHut1cz4y+KHvxaAhsj2iDo49rwbi4f1ps4n0wVi3/Wf96Lp6TgVT4DUbZN 1hOmDd2BDlTJ2C3KAH0YLLtd3Qx+JdcSTsWWPUnOvUBXwSdNrBBU6e8hexlGzfl6b7 wcu7maz0yxrywJdMr8U03FyjSfOVaHLyR8kDz4e0= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9B2C9F80542; Mon, 17 Apr 2023 02:35:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29300F80542; Mon, 17 Apr 2023 02:35:20 +0200 (CEST) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on20720.outbound.protection.outlook.com [IPv6:2a01:111:f403:700c::720]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DAD18F8051F for ; Mon, 17 Apr 2023 02:35:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DAD18F8051F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=KjE/Iqxj ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S1ZH7fWo7jI683i3X/Rbp8a3ejbo20LpldkhINWkRfpyY6k/r6SJ8VwDi6nX3Ct6ZJzJrihP4s8XGHUtPigmbMzOh9IwFZg8WGVhI4Mq96jSqmk0zGRYKdPbOT2PDZEhMwLZitBjowxvh/ruyjyNEPucOv9O4qm76ILJnHJ0lMg+gFeTxMIvqVKoVmIUCJEo9VeLxQ2ak6d7R0t7aD/aegaONH8usoECH7kvalGA7Fr6p1Eh7QpDGzwD1GfgRQxwPhp+v5nscKnqFZsNBlYFsZi3cN4SC8epumGWUCsT7QmcjZYzOk4K54hcqbRKmvxW3HS0/MxC/l/zyV3mvRUKbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8+RsXLhX5apQtwR1gnZ0I9hKnwPXJ32PFXFN1MbLkcA=; b=ZjqWkD50jU/tcfbPv8YVXbwf/5lxn1vQcyMVatrwDpLt1KYnv84ZZR1EswKgiS1VnaCRTaIQcgpKwpt4IozqN5Dlrsg2HY7QdMfSRBjeGq+ArSHB5d6uBYWcrqg71a/0kFGnJy7SPOJ0cdn1tPe6AxG46xS+Ab50Cm3oF+UO+X/1ydR9wKrDOnKfAS5OggD+d+gMgeLo9D3hUJcPuEQ6skIUwChTOJ/bFopUF1Dths/1Ob9iA12cfcpCK7BC//gNpodaOZGY0dQhG0SPzPqEwAF1KGugfAuY6GUnDyQOn31S1TY3vPKViZc7HscpDNlgp3VmHrNpWI9b0WzhEnZSeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8+RsXLhX5apQtwR1gnZ0I9hKnwPXJ32PFXFN1MbLkcA=; b=KjE/IqxjXBK+vVkp2YDvAEN3FJan4AC/wZAZfO1AnsxYJgWGLXPwaQcPlkZkYLZ/z9qL5MqkZ8P5JG7Uqsw812+EDdAUqSto12iOtDs/GFmA/ZtK6oDyf4uStEMUrYOb3VSVBBXCFkqEzQTR4Cpe2A4qoHJKcbH/2GWZdd99swE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYWPR01MB9388.jpnprd01.prod.outlook.com (2603:1096:400:1a5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 00:35:08 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1%3]) with mapi id 15.20.6298.045; Mon, 17 Apr 2023 00:35:08 +0000 Message-ID: <87ildvtkg4.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH resend 2/3] ASoC: expand snd_soc_dpcm_mutex_lock/unlock() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown In-Reply-To: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> References: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 17 Apr 2023 00:35:07 +0000 X-ClientProxiedBy: TYAPR04CA0005.apcprd04.prod.outlook.com (2603:1096:404:15::17) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYWPR01MB9388:EE_ X-MS-Office365-Filtering-Correlation-Id: 8db42257-ba15-486e-552f-08db3edb9866 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TPNU243O3LOQqg8CaGxrbMBYMFwi7DnPkQLZdXHhjYYaRi3BGvcLioCQWJ3W6mp9yc9iEt4A21q0aQFhsGFBFZHB7kiu+OFfbD25lJR4DknAPhWtY2xBG+LnZC48eHri/2ZdJW/cbfoTWPr1CV+Pq0VnuyC0aADAAVpnYlm4lxDXM0Qa8qBl7Raz6mA7NRrzDFaWArB2Im3q/fQaziV48CmbEI2n+SVCbvYJnC5CGQyMmwr7+LPlyAw15IU2Nh91byNmK0xI46tpEzmXXvc/qKUgPw3rTtJIUUxHbmW9JxpSg9HpDGdwIKAVQNOlwupBYJzEAzoYnZZ4zD3TXQjF0PYKqINQ4wajOQh+JROpvFhZ1/5ESiGTNDAu1iQskw9kEi/mjTtaFraIVeeCJx4fRZhH4uGFOhK6BMTmoBTTfaIemTmCGUl8Kb6aFQSF5nOe+EoMGh8lMM+jM/GrhdikVjDStcoqg8NtGDG20MJkYh7TiZcdySNKapNu8AubhpQCIj7FM835YAFv0JURuDv74IRVTM7xRP/0AJXgwKhSumRgpOWAdpq08zvzbPvymC1u91MsjQECR7IL+jhq5HrYuQ1tnMNUmJUwwuU47/5C5rMoyuSsHsDRVEJcBmPSKIhL8boQypG/iFRzToalyfG7ww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(396003)(366004)(346002)(376002)(451199021)(36756003)(2906002)(30864003)(5660300002)(8936002)(8676002)(41300700001)(38350700002)(38100700002)(86362001)(478600001)(2616005)(6506007)(26005)(6512007)(186003)(6486002)(52116002)(4326008)(6916009)(66476007)(66556008)(66946007)(316002)(83380400001)(21314003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b3NzCd9OPKZIZCNRmW2oey6bmkXSD65rSRmGDSVTeN5s/K2QZCkeKtJVK1YNPBrvQ3poIoT5T0a72+alLZvjzQRYqr0/OMxhH9B+cJcg/1m9c6WCWu4FwiQRu1ki+pkPhkKcKmWXAWrgP9choBqcqRgsWn7vf1/VjPlTAEBaX8CapJ/EwLIYaEShERuYOjh2MbP4ONnAFr39dr4rSLyiod28ihqFyVXOSyyl+pq9QMwguvbRslhw5nPoV3KP7qcxZJiFRUYXaFaYV85jqY371iSd78zAxM4WKBK4z5pn+OHM3Z5vVlZChUYSU9nYZZ2rkmYLfocGq1O+YENJY0O4/Fz5XqXNFWnVFlvXfWamZFKP4UWXswBaqdDaDd6KDhneJaUUNFC8B7zYmLYb1vPOOx0imFM2Y6Qf8Xk+hGcw4yecC/WU0/1c2vrUUaX5PwdWOUs518PTeRJ6a4xaYjUVD2G98S+/CfpymTCLWQjXS37/FP4X+Eezwg4/41op/kS+6RUwWklj57ngpDIa4pnwDQx2BPJGJ5vPxBx6c09oOuso5uLmtTxS3fSIyzL+OhcVONnIY1iwf7+t0TYfpV4iY4jSZ5e9VhyzQhOcaUvXwId9iMZkSzuivRBiA82VWLCoyG5iUOf4u9LfvykKqODo/3pzwvch50NxpPfPbKb7WFezSwhk7zA+MYHBa3+Gn1TvS+Ahch0zvwsjHRVWth/OZhBx3uTOpbK9F5sXmUN70khM7zHnIh3P0qYD4U2/Arkp/PEpSrOHsaggajteSd5qnvMJ67LjGsTSVFummK6CqxdqHU/kzkznz5EUA2QB2jLt6KrhidR71PT6+8vr9e2gLfbgn8JizfGsBJ2o8rxmG1JfEuMj4imMDzZKB9R3RtCFlu8JIwucf7yz4alRMEhHq0U+Y/NUDvmWx4CIFYo9tND9OluUuV2q9CViblTIpuiYjVbN4RIkcGusmCkvIsvmCp/T/2/tyEd6qTehNRFiJbZiA/vWKWhFvWcCaqFSoXRWDIiRsmQy25y0vvSAQ6GdQ3BPLEeIeGiJ/eC2ZakAJEhGG/Db7EGIpuYqf4+BcpXmUpQ0otS2TBpB5zv9jN3OWRNXA687Uv04+Z7wYQgpBdhMJOVwYWSVxkvLXo8KnQ9yuCEJ4cOFNHz0s0Tipp5EtsJiUdv39jBpDl0Db5HcHiMGqIwLx1Z0Kbd+wNLGZ4EVzUD91wXP/zE7wl5iCsNXyP/ny4NFVteUIInmeJa7dwXh/SyuOWFGj6WD2SEfAfziL+gpD7DX9pBbI6AtBEdzsnIl7X/kwwU8P9M4jwuUqL+fjM6/UTJo8PoPSwDGHX+O5bmUAYMbtvafF58h2THJBaZrUzxshviFYznJ2BZoSguVl9jL1b2pPOo3t3zBWOv/7CZJvw4whZrX7z+rWinjSeSe2gkZlAuF4Ixs3TX8BVQK47++B3b0ybhIJFP4AH8L6+MnAlCY/NQHKCtIdn69rFoqN+WmM2lvXh9GcTD+ngxPXtw3bWcrBaWKY9TFwunw3UdZELjP/zwWoxzYR34he/+Wr6AX8iZlJBuVorhdeEgihwsPK4ESfikauDjt6xCMIPs4J9CMsCHIVLIoMAYkO2LtAY4ucCLwNPyXgkbvdbc= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8db42257-ba15-486e-552f-08db3edb9866 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 00:35:07.9769 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VniqVN/CXltHJWqpQdY1Qig0CZzsPRf3ojh4ymb7Ha1sqjik3KTBm9uUUWWlOWkK+e6iZiemYqL7I4BZhVH1s6Ab36ByuF8xDrp5feBShrZebvnYNiakPKraDYLDcd8B X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9388 Message-ID-Hash: QW66HWMGQZU7CZVS23QCOUTS333XI2SO X-Message-ID-Hash: QW66HWMGQZU7CZVS23QCOUTS333XI2SO X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Linux-ALSA X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: soc-pcm.c has snd_soc_dpcm_mutex_lock/unlock(), but other files can't use it because it is static function. It requests snd_soc_pcm_runtime as parameter (A), but sometimes we want to use it by snd_soc_card (B). (A) static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd) { mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); } ^^^^^^^^^ (B) mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); ^^^^ We want to use it with both "rtd" and "card" for dapm lock/unlock. To enable it, this patch uses _Generic macro. This patch makes snd_soc_dpcm_mutex_{un}lock() global function, and use it on each files. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 45 +++++++++++++++++++++++++++++++++++++++ sound/soc/soc-component.c | 12 +++++------ sound/soc/soc-compress.c | 42 ++++++++++++++++++------------------ sound/soc/soc-core.c | 4 ++-- sound/soc/soc-pcm.c | 17 ++------------- 5 files changed, 76 insertions(+), 44 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0e17e3230c7a..05004c048dd5 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1425,6 +1425,51 @@ static inline void _snd_soc_dapm_mutex_assert_held_d(struct snd_soc_dapm_context struct snd_soc_card * : _snd_soc_dapm_mutex_assert_held_c, \ struct snd_soc_dapm_context * : _snd_soc_dapm_mutex_assert_held_d)(x) +/* + * PCM helper functions + */ +static inline void _snd_soc_dpcm_mutex_lock_c(struct snd_soc_card *card) +{ + mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); +} + +static inline void _snd_soc_dpcm_mutex_unlock_c(struct snd_soc_card *card) +{ + mutex_unlock(&card->pcm_mutex); +} + +static inline void _snd_soc_dpcm_mutex_assert_held_c(struct snd_soc_card *card) +{ + lockdep_assert_held(&card->pcm_mutex); +} + +static inline void _snd_soc_dpcm_mutex_lock_r(struct snd_soc_pcm_runtime *rtd) +{ + _snd_soc_dpcm_mutex_lock_c(rtd->card); +} + +static inline void _snd_soc_dpcm_mutex_unlock_r(struct snd_soc_pcm_runtime *rtd) +{ + _snd_soc_dpcm_mutex_unlock_c(rtd->card); +} + +static inline void _snd_soc_dpcm_mutex_assert_held_r(struct snd_soc_pcm_runtime *rtd) +{ + _snd_soc_dpcm_mutex_assert_held_c(rtd->card); +} + +#define snd_soc_dpcm_mutex_lock(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dpcm_mutex_lock_c, \ + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_lock_r)(x) + +#define snd_soc_dpcm_mutex_unlock(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dpcm_mutex_unlock_c, \ + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_unlock_r)(x) + +#define snd_soc_dpcm_mutex_assert_held(x) _Generic((x), \ + struct snd_soc_card * : _snd_soc_dpcm_mutex_assert_held_c, \ + struct snd_soc_pcm_runtime * : _snd_soc_dpcm_mutex_assert_held_r)(x) + #include #include #include diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 3cd6952212e1..ff25718ff2e8 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -550,7 +550,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream, struct snd_soc_component *component; int i, ret = 0; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); for_each_rtd_components(rtd, i, component) { if (component->driver->compress_ops && @@ -561,7 +561,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream, } } - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return soc_component_ret(component, ret); } @@ -574,7 +574,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream, struct snd_soc_component *component; int i, ret = 0; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); for_each_rtd_components(rtd, i, component) { if (component->driver->compress_ops && @@ -585,7 +585,7 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream, } } - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return soc_component_ret(component, ret); } @@ -638,7 +638,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream, struct snd_soc_component *component; int i, ret = 0; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); for_each_rtd_components(rtd, i, component) { if (component->driver->compress_ops && @@ -649,7 +649,7 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream, } } - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return soc_component_ret(component, ret); } diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 6e74a6c48986..661e9d70994f 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -62,7 +62,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); if (!rollback) snd_soc_runtime_deactivate(rtd, stream); @@ -84,7 +84,7 @@ static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback) if (!rollback) snd_soc_dapm_stream_stop(rtd, stream); - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback); @@ -107,7 +107,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) if (ret < 0) goto err_no_lock; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); ret = snd_soc_dai_compr_startup(cpu_dai, cstream); if (ret < 0) @@ -123,7 +123,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) snd_soc_runtime_activate(rtd, stream); err: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); err_no_lock: if (ret < 0) soc_compr_clean(cstream, 1); @@ -146,7 +146,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) if (ret < 0) goto be_err; - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(fe); /* calculate valid and active FE <-> BE dpcms */ dpcm_process_paths(fe, stream, &list, 1); @@ -182,7 +182,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; snd_soc_runtime_activate(fe, stream); - mutex_unlock(&fe->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(fe); mutex_unlock(&fe->card->mutex); @@ -209,7 +209,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(fe); snd_soc_runtime_deactivate(fe, stream); fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; @@ -229,7 +229,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) dpcm_be_disconnect(fe, stream); - mutex_unlock(&fe->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(fe); snd_soc_link_compr_shutdown(cstream, 0); @@ -249,7 +249,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int ret; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); ret = snd_soc_component_compr_trigger(cstream, cmd); if (ret < 0) @@ -269,7 +269,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) } out: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return ret; } @@ -327,7 +327,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int ret; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); /* * First we call set_params for the CPU DAI, then the component @@ -352,14 +352,14 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, /* cancel any delayed stream shutdown that is pending */ rtd->pop_wait = 0; - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); cancel_delayed_work_sync(&rtd->delayed_work); return 0; err: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return ret; } @@ -404,9 +404,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, ret = snd_soc_link_compr_set_params(cstream); if (ret < 0) goto out; - mutex_lock_nested(&fe->card->pcm_mutex, fe->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(fe); dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); - mutex_unlock(&fe->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(fe); fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; out: @@ -422,7 +422,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); int ret = 0; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params); if (ret < 0) @@ -430,7 +430,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, ret = snd_soc_component_compr_get_params(cstream, params); err: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return ret; } @@ -440,7 +440,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); int ret; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes); if (ret < 0) @@ -448,7 +448,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) ret = snd_soc_component_compr_ack(cstream, bytes); err: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return ret; } @@ -459,7 +459,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, int ret; struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp); if (ret < 0) @@ -467,7 +467,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, ret = snd_soc_component_compr_pointer(cstream, tstamp); out: - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); return ret; } diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9bbcff492c1e..4594505cdae2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -348,7 +348,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); int playback = SNDRV_PCM_STREAM_PLAYBACK; - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + snd_soc_dpcm_mutex_lock(rtd); dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n", @@ -364,7 +364,7 @@ void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd) SND_SOC_DAPM_STREAM_STOP); } - mutex_unlock(&rtd->card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(rtd); } EXPORT_SYMBOL_GPL(snd_soc_close_delayed_work); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 1d0c3d57f66d..7247f44faa1c 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -49,19 +49,6 @@ static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd, return ret; } -static inline void snd_soc_dpcm_mutex_lock(struct snd_soc_pcm_runtime *rtd) -{ - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); -} - -static inline void snd_soc_dpcm_mutex_unlock(struct snd_soc_pcm_runtime *rtd) -{ - mutex_unlock(&rtd->card->pcm_mutex); -} - -#define snd_soc_dpcm_mutex_assert_held(rtd) \ - lockdep_assert_held(&(rtd)->card->pcm_mutex) - static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd, int stream) { @@ -2664,7 +2651,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) struct snd_soc_pcm_runtime *fe; int ret = 0; - mutex_lock_nested(&card->pcm_mutex, card->pcm_subclass); + snd_soc_dpcm_mutex_lock(card); /* shutdown all old paths first */ for_each_card_rtds(card, fe) { ret = soc_dpcm_fe_runtime_update(fe, 0); @@ -2680,7 +2667,7 @@ int snd_soc_dpcm_runtime_update(struct snd_soc_card *card) } out: - mutex_unlock(&card->pcm_mutex); + snd_soc_dpcm_mutex_unlock(card); return ret; } EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update); From patchwork Mon Apr 17 00:35:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13213105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D110CC77B61 for ; Mon, 17 Apr 2023 00:37:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BC9FE1D9; Mon, 17 Apr 2023 02:36:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC9FE1D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1681691820; bh=M1wSwwL/WspWtOKyPWAAIoRPZ/EbNkDE3jMENU8zgxA=; h=From:Subject:To:In-Reply-To:References:Date:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PjIASr4mpfBB8ornwiMCkjRcUlpxS+Z7WlzWEupSAL38rAJ7RqPxQ24deGvxdd6/5 RovFUIGuThHBZ0Ej6JU4W3gyizg+zE0EYqGveoEEQK5BHF5v6ftb7/csO2/B6M2z0d NF6goEHgrvc1VNvc0Jgmm1D/wKc0VkagglH2Kbok= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 0F494F80551; Mon, 17 Apr 2023 02:35:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2CC0AF80551; Mon, 17 Apr 2023 02:35:28 +0200 (CEST) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on20707.outbound.protection.outlook.com [IPv6:2a01:111:f403:700c::707]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4A539F8051F for ; Mon, 17 Apr 2023 02:35:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4A539F8051F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=OqM43wuX ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LQSizDZk1YeJ3yhCib7i+OPawjbV8tjZ6Oo3QGlfpvQ9k1yQW66llnAb3PXSaWfU2VgRAvt3YruLM0GuYyOyY4JQrzPVgbYHN96QKnsi9V800VjD6OA2qSxN8DA65y8bqjO05ANdTHqcaFSulgwPCq6S1hnCWPDPMQSD+ND+Y0jPcMDps+Hb2Ov5JoGJ06uj3gYSXdetTDH591zALQZd6Qoas0rsIGc2fppStnunImWRaGUx60nR5TEUpAJeRVzhq6Cp31fa3AxOVmMaE4N7vhsvElxW/DBnFYVflTK90l4zwcErvRUymg8n4xy/R2zdpwnMh4QId53IgIAuI0Yvww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1zU1RfcUHNiFAL2zI0ffpyDPF9l0VaQEfDvob84zYKE=; b=mhdgTJaiVgDMNRjXho7V4fhwefoWqvh4mXM7jZIAcEXx9MJEczasXX3ySoGs4ke3DcFBlj28MFICiMM9Iib5EF0HEw04jUwPkM6P1hkgK0qA7J6zhG99NxlQdatc+ilaz77JT4EX7f2mFhWxA/Wv6Z5J0qlfCV6EmfRnh7eoEnLN2uyqw4BLcGc/uC6j8YckEhqF6kcGGFObrxgJkOOk927XHM8m+6LkcmD6V5Jhx6rMExtbovyzwK/12TXoJnAp2eFsMkDwCbyevYJWAP9cSboYfwtSHXpd+R4F4kh1ZV3WUkfrVpMBMQcTMAS+l/049As+NWtXNz24z3YANVLCLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1zU1RfcUHNiFAL2zI0ffpyDPF9l0VaQEfDvob84zYKE=; b=OqM43wuXUqjgXfB1DycERB4uV/Z6TCV1S2YlhWKVZ9HQ+9JYhwwtb8kqW60v1fLo/QJXjYLw4j5xI1YvV9GO5ZI7r7GBdu/kTRsaIvPURlZKZBQPnzbhYHW1jBZCP9jRGL3U0IoaGhLGt9i+spMBSNUFZkj9t0v+AGT/Rd90KMM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by TYWPR01MB9388.jpnprd01.prod.outlook.com (2603:1096:400:1a5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 00:35:18 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::b005:5b0f:6ad8:3eb1%3]) with mapi id 15.20.6298.045; Mon, 17 Apr 2023 00:35:18 +0000 Message-ID: <87h6tftkft.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH resend 3/3] ASoC: add snd_soc_card_mutex_lock/unlock() User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Mark Brown In-Reply-To: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> References: <87leirtkh2.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 17 Apr 2023 00:35:18 +0000 X-ClientProxiedBy: TYCPR01CA0098.jpnprd01.prod.outlook.com (2603:1096:405:4::14) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|TYWPR01MB9388:EE_ X-MS-Office365-Filtering-Correlation-Id: 44265dd0-4c98-492b-e6e6-08db3edb9ec7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YFYf6m9cSTYKh23umiOAJIhy/bYkAI1uh+tt+SFjR4XPuv/QDT6N8tm6cqzBWsMVQ8d4bdhyMw7Mu4YsGL0ZGP8aD7/kBpRzJrJNnjsa1k2qaQBPCCGAunHmTPa+e0DPoft/BmJcbUroEER4KuUi6LtbQK6SY0hMHTVN3rqFX3Bcu+cojSmZlH5c77nbEq+StAv4E+iiHPJDlQzuJAoBf7onPXjE7+SjGeg1MQorYOptjW/pucpXode20RcJgtVMZyH/6qjCD5W1fXE+EXy/pjIvVtAQRYxQydm+wZztUhoMX/sKnKBaBWmt4gF1AZ/n/r4GCcLc5DS1pJ3MVfjA0/wjV/4HZQDlU85TpuMaN+ZxM/ATg4O9Bm9DmpGDqQv1i5vMaezKVEU3WNqz96o1Yjmi4+QcZOPsa1jSigQd/6htJEV4qaon3kdIgSe1dOLHZ7dm/Wzqv0Tin72L+LqDA7YUJ4k/q42p7/aebZ2n5jw3p/zLlb1OVGbEC4MXs7uUxLXLHi71G9/HXF4ip1C3+tYN0uhJz7hMKERM1uHzQaJQa0Udy0MGscgYpzg/JyTKLmBlW1iQ+r556dy2yuZTF6au8tZZEgrmxeATJcAmg6rp81+ySH+mO/shcIer9hb2NNrw0bwJYPBNJK9GqR8m4g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(136003)(396003)(366004)(346002)(376002)(451199021)(36756003)(2906002)(5660300002)(8936002)(8676002)(41300700001)(38350700002)(38100700002)(86362001)(478600001)(2616005)(6506007)(26005)(6512007)(186003)(6486002)(52116002)(4326008)(6916009)(66476007)(66556008)(66946007)(316002)(83380400001)(21314003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O3FH5+v7Aby5S8OnoaoCYW2Lb0fI/eT6QVLRtel5b6XVZvJhZ8qcxMdIlrv/R1B9f9VnunUUN75QhFjiBhbifFBBPEljLgBHFAAh+Ujkip8zzuQnZmlGwYXDsgELj1VVyVXrtBDJofVIFPPbMe0hDwHzJSyUDOb2tJx1aLhSg3m1AidrkbB49lwv1Ule6457zvEP1Bqy5otQpdA6cJYmfwphjN8sc61dEt+afan4Rgh4ofeFl+3+enIjLbvH/kkOnXEn25V2Kd+R6TIzdwFDKEo0eH1BFJdDwgXKd7lOQcI6ma4Au4hVIa9x+uLfJ/8H0ZPuf7d4/huI5eI7ETxFqyAOki3SS2gvC2F1ryRr4pm7vuuwfC6Q1bH1QYj7iPsNF/GRKvW+Mel2L6NvCklbjGBRcqHyBGgiqB8p06zNH0hwyJLF8PApLQMofaLjdIJNQa7bJVKjQ3W4ZX+vY12YMYUODE0XBlpvGk3DujDpk5vwJy1P2GlusOC26kTm5BGdl9Xbvv5J8vJVAYLXhWRbddLNgsRMAZH15sWxCVXRH8XE3ewF7erUEbneVdQGFOk3SFOtV4zowSlG+P//64AEpiQXj7PFpwtRoMxR0AlheYRnl0D+IB/qJttrChWQZQXcVpXOgg4QcdNS8495aL5u0GZ4ImOTMijt4SZzFrGPGMscGOgXg8lJlqND6236S79ZG7QguQGayFc+D07hxDKxh1KMsPm+Le49UmWGv/ZJjZXDvT71QoeUSCpkF3kAGlULRnojLkJra1ME/XEgMlzMSBrhmrCfLdCcFhoIGb60srRc9jBE7hwJoa9RL+htLXCYk7rpG/KW3KQ162vEo7BSoV4IlPmezSX6ViNi4GB3Uc3Ak9YBMJnZ/zi9fAwFfWDzSldoMblhKIUITkZq1njGj+KbecZnlE9ujUqR5AvF5rNd2qMbkeKAwoVRYJyW1qk5Ldf9KRDbhk1msxd668ObY/VonC9faRTLW2WqX/EHwQvwV0Kj4NLNEGFA3bdmEDQ6+Tz8PqDZdLSzIoEIQPi6rTiGQPqvxEwdCkWrRxDSYAWOgw8jVMSUQkehnBvCLG0kEZ2OPVcj3kzAzdFuLTij5Vzfp/SULdUzRRNx57UkCwAq0lFdypJctq+99OP0QLHxr3PbdMNarOe/ycWv7Hqz/+MME7Yu3XSUl4ovDKJ8TJmy3T8r3wmW+TR65pRak6AXFqQKg1KTLPP7VTxVnH6LrN5Vr6Lud0yrnmvZyu+bpW9vefmlPypit/fJ57xoZ49NM1XwGwNP2dCByemcwi3YIXF7Gp10xQEgtD9lFI4phy8S2We4F95WuR+YBPj7jZjQx8b3gZKVMYgiTHG4tECPWYVnBX/Ujl/yX9UwDZvEHafPGFn9F+a4WJc6vRhVrnuUgqvKoYvZsWPNpFyVbWFlBIsvkwIX0ptwdSkMzuzx2aa3YFCP2Nq9tACWYnvxAIrQQ2fO4mz1PGPLjB6jkL3QgODVVSsRmMF/1uR1IOlvejnNnLM3pPuJy+7Bw4Vqm928NBokuTUWCF0v4I60QMDhT9RSNPqw5A+WevmcGnoblsXzecsvgGA4bQtU4baP/6gG9vJ2ftoU8XuaJUecoKI9nCzhpZWTyMj11OT0CtnSnls= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44265dd0-4c98-492b-e6e6-08db3edb9ec7 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 00:35:18.6612 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GLTrWA1/svfeVMRDq4jyC+6EN3YOkzaqJofdRGlxTKMdq206aU0IlZQ+qhcTy2waM7wAKLou5+NTCMz0/B4I4l07KkGmOggDnwsB1RGRYBn8BelFJ+cfucbWxrUj10Pe X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYWPR01MB9388 Message-ID-Hash: 2EWAZQWWTZDD6ZCM3DIHCGK7AZGX7NGQ X-Message-ID-Hash: 2EWAZQWWTZDD6ZCM3DIHCGK7AZGX7NGQ X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Linux-ALSA X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: ASoC need to use card->mutex with _INIT or _RUNTIME, but there is no helper function for it. This patch adds its helper function and use it. Because people might misunderstand that _init() is mutex initialization, this patch renames _INIT to _ROOT and adds new snd_soc_card_mutex_lock_root() for it. Signed-off-by: Kuninori Morimoto --- include/sound/soc-card.h | 17 ++++++++++++++++- sound/soc/soc-compress.c | 18 +++++++++--------- sound/soc/soc-core.c | 4 ++-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h index 9d31a5c0db33..fc94dfb0021f 100644 --- a/include/sound/soc-card.h +++ b/include/sound/soc-card.h @@ -9,10 +9,25 @@ #define __SOC_CARD_H enum snd_soc_card_subclass { - SND_SOC_CARD_CLASS_INIT = 0, + SND_SOC_CARD_CLASS_ROOT = 0, SND_SOC_CARD_CLASS_RUNTIME = 1, }; +static inline void snd_soc_card_mutex_lock_root(struct snd_soc_card *card) +{ + mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_ROOT); +} + +static inline void snd_soc_card_mutex_lock(struct snd_soc_card *card) +{ + mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME); +} + +static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card) +{ + mutex_unlock(&card->mutex); +} + struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, const char *name); int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 661e9d70994f..d8715db5e415 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -140,7 +140,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int ret; - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); + snd_soc_card_mutex_lock(fe->card); ret = dpcm_path_get(fe, stream, &list); if (ret < 0) @@ -184,7 +184,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) snd_soc_runtime_activate(fe, stream); snd_soc_dpcm_mutex_unlock(fe); - mutex_unlock(&fe->card->mutex); + snd_soc_card_mutex_unlock(fe->card); return 0; @@ -196,7 +196,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) dpcm_path_put(&list); be_err: fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; - mutex_unlock(&fe->card->mutex); + snd_soc_card_mutex_unlock(fe->card); return ret; } @@ -207,7 +207,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) struct snd_soc_dpcm *dpcm; int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); + snd_soc_card_mutex_lock(fe->card); snd_soc_dpcm_mutex_lock(fe); snd_soc_runtime_deactivate(fe, stream); @@ -237,7 +237,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0); - mutex_unlock(&fe->card->mutex); + snd_soc_card_mutex_unlock(fe->card); return 0; } @@ -284,7 +284,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) cmd == SND_COMPR_TRIGGER_DRAIN) return snd_soc_component_compr_trigger(cstream, cmd); - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); + snd_soc_card_mutex_lock(fe->card); ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd); if (ret < 0) @@ -315,7 +315,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) out: fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; - mutex_unlock(&fe->card->mutex); + snd_soc_card_mutex_unlock(fe->card); return ret; } @@ -373,7 +373,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ int ret; - mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); + snd_soc_card_mutex_lock(fe->card); /* * Create an empty hw_params for the BE as the machine driver must @@ -411,7 +411,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, out: fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; - mutex_unlock(&fe->card->mutex); + snd_soc_card_mutex_unlock(fe->card); return ret; } diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4594505cdae2..b48efc3a08d2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1938,7 +1938,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) int ret; mutex_lock(&client_mutex); - mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); + snd_soc_card_mutex_lock_root(card); snd_soc_dapm_init(&card->dapm, card, NULL); @@ -2093,7 +2093,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) if (ret < 0) soc_cleanup_card_resources(card); - mutex_unlock(&card->mutex); + snd_soc_card_mutex_unlock(card); mutex_unlock(&client_mutex); return ret;