From patchwork Fri Apr 10 08:49:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 6193281 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EB02ABF4A6 for ; Fri, 10 Apr 2015 08:51:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2BAF203DA for ; Fri, 10 Apr 2015 08:51:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B4CF8201DD for ; Fri, 10 Apr 2015 08:51:09 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C8F95265E27; Fri, 10 Apr 2015 10:51:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 91A1F265DC6; Fri, 10 Apr 2015 10:50:36 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 74376265E2F; Fri, 10 Apr 2015 10:50:35 +0200 (CEST) Received: from relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa0.perex.cz (Postfix) with ESMTP id B8164265DB6 for ; Fri, 10 Apr 2015 10:49:56 +0200 (CEST) Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 10 Apr 2015 17:49:55 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 4B18C3E2E3; Fri, 10 Apr 2015 17:49:52 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 32DFA2806E; Fri, 10 Apr 2015 17:49:52 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 2D5542806D; Fri, 10 Apr 2015 17:49:52 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id TAF31903; Fri, 10 Apr 2015 17:49:52 +0900 X-IronPort-AV: E=Sophos;i="5.11,555,1422889200"; d="scan'208";a="183797358" Received: from mail-hk1lp0119.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.119]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 10 Apr 2015 17:49:51 +0900 Received: from morimoto-PC.renesas.com (211.11.155.132) by SINPR06MB316.apcprd06.prod.outlook.com (10.141.115.155) with Microsoft SMTP Server (TLS) id 15.1.130.23; Fri, 10 Apr 2015 08:49:49 +0000 Message-ID: <8738488j2k.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown In-Reply-To: <8761948j4f.wl%kuninori.morimoto.gx@renesas.com> References: <8761948j4f.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 10 Apr 2015 08:49:49 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: KAWPR01CA0005.jpnprd01.prod.outlook.com (25.161.24.15) To SINPR06MB316.apcprd06.prod.outlook.com (10.141.115.155) Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB316; X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(47776003)(53416004)(50986999)(87976001)(50466002)(229853001)(54356999)(33646002)(66066001)(110136001)(36756003)(76176999)(92566002)(77156002)(62966003)(2950100001)(42186005)(575784001)(46102003)(19580395003)(19580405001)(86362001)(83506001)(40100003)(77096005)(122386002)(23726002)(46406003); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB316; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002010)(5005006); SRVR:SINPR06MB316; BCL:0; PCL:0; RULEID:; SRVR:SINPR06MB316; X-Forefront-PRVS: 054231DC40 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2015 08:49:49.8834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SINPR06MB316 Cc: Linux-ALSA , NAOYA SHIIBA , Liam Girdwood , TOSHIAKI KOMATSU , Simon , Atsushi Tamaki Subject: [alsa-devel] [PATCH 2/5] ASoC: rsnd: make sure it uses lock when it calls rsnd_dai_call X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto rsnd_dai_call() should be called under rsnd_lock Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/core.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a2a0b57..164653c 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -731,10 +731,15 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_dai *dai = rsnd_substream_to_dai(substream); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); + unsigned long flags; int ret; + rsnd_lock(priv, flags); ret = rsnd_dai_call(hw_params, io, substream, hw_params); + rsnd_unlock(priv, flags); + if (ret) return ret; @@ -919,14 +924,16 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod, static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->cpu_dai; + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); - int ret; + unsigned long flags; + int ret = 0; - ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd); - if (ret) - return ret; + rsnd_lock(priv, flags); + ret |= rsnd_dai_call(pcm_new, &rdai->playback, rtd); + ret |= rsnd_dai_call(pcm_new, &rdai->capture, rtd); + rsnd_unlock(priv, flags); - ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd); if (ret) return ret; @@ -949,8 +956,11 @@ static const struct snd_soc_component_driver rsnd_soc_component = { static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, struct rsnd_dai_stream *io) { + unsigned long flags; int ret; + rsnd_lock(priv, flags); + ret = rsnd_dai_call(probe, io, priv); if (ret == -EAGAIN) { /* @@ -983,6 +993,7 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, */ ret = rsnd_dai_call(probe, io, priv); } + rsnd_unlock(priv, flags); return ret; } @@ -998,6 +1009,7 @@ static int rsnd_probe(struct platform_device *pdev) struct rsnd_dai *rdai; const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev); const struct rsnd_of_data *of_data; + unsigned long flags; int (*probe_func[])(struct platform_device *pdev, const struct rsnd_of_data *of_data, struct rsnd_priv *priv) = { @@ -1084,10 +1096,12 @@ static int rsnd_probe(struct platform_device *pdev) exit_snd_soc: snd_soc_unregister_platform(dev); exit_snd_probe: + rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); rsnd_dai_call(remove, &rdai->capture, priv); } + rsnd_unlock(priv, flags); return ret; } @@ -1096,6 +1110,7 @@ static int rsnd_remove(struct platform_device *pdev) { struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev); struct rsnd_dai *rdai; + unsigned long flags; void (*remove_func[])(struct platform_device *pdev, struct rsnd_priv *priv) = { rsnd_ssi_remove, @@ -1106,10 +1121,12 @@ static int rsnd_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { ret |= rsnd_dai_call(remove, &rdai->playback, priv); ret |= rsnd_dai_call(remove, &rdai->capture, priv); } + rsnd_unlock(priv, flags); for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](pdev, priv);