Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp301049pxj; Tue, 18 May 2021 03:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMmiE2f+Y/Y4q5X+RVD+ADbt/dotCwVAVt0ZsXSP/uwp4lhS9byuAUXWRwVPpnIaCktAxQ X-Received: by 2002:a50:bec7:: with SMTP id e7mr6349666edk.295.1621334976287; Tue, 18 May 2021 03:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621334976; cv=none; d=google.com; s=arc-20160816; b=FwLEtk6ysIzOVeCCsbGjVs/cSwp6YAw+LGcRnTKRGFh44DoR8uWD5dcxffnX2i7IX3 6wgmvLKlFdh0a2rJ4yxr3ckXiSdtTXh0VTiuoKUcl6Cdua00DV9+oR/3PCMdoe6+nEH3 /cKpJxp7IlnFjZz3RRdr+GwfzDE5MN0PzZztKTJ9D11/UcgOtjFw928b7wQZJhj/bNlL gcMCLJkFSx+LCZSDLqvd32KSLBaieblVJFLKeB+rx+nRJNTSF5bkb+sPo6PEldnxt16U Ztp2zugNZ4ckBm/wjwUa3V/l9qJMaffAMCPm+SAQkhso0UtuuVEppgt5MYjvhD1sMvmV ACwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FQcVh0gic4iM8PTNJ8hrezYeFafK5XuTMqBrCuGn6Ww=; b=e+0gXGBmoQQpXjSJGMwDTby3QKFxBK9+nRICOpYUE+9kvsiEFjWkfK4fL9TNWkGK3r U3vFp6kuUuyEGc9MIkR7fXyQVgpqWOcUk+vMnhgd360QWYJeWB2Pn3eWZHyR9wkjGShF B4TGsFjGyzTqffKdGsUf0649TWhnrqAP/N/Xcrebpl+/iNfbuPF10xhfgazH6jDD9hPk X+bsCf0zguCsXGwEgY1CuDkw13z/OZOKztbm5Izl3tDLi8P7nmanttCFk7BMykf/8azL 916G9nicidfCl0EOiFjRaxcHRHw/UewmgZPBMDCRNYGZnKiLZBsmsc1pE7D06xou9lCZ h0SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="kechI9/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si8004002edr.246.2021.05.18.03.49.10; Tue, 18 May 2021 03:49:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="kechI9/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243875AbhEQPPI (ORCPT + 99 others); Mon, 17 May 2021 11:15:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:47774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242882AbhEQPE5 (ORCPT ); Mon, 17 May 2021 11:04:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D51F613DD; Mon, 17 May 2021 14:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261717; bh=crQZifefxFB5zTrNmQ8E/W5S9724KgP2XqK90+Y+VD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kechI9/jX/TcaQIts5RmeNidT07n8TaPa/xUr0bjWWpTYiQLFg4Gd2GyvGX+JtSee pmkltaqOt/Wk0TPJVVyLP3Tsy1+UGE4XsxImvNHIzCoN/lqGT3o+yo9NA5CdzvX4eZ FKQiOC9RG30zO/141/m/ZqXBIQ32aOxnthrar094= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Linh Phung T. Y." , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.10 056/289] ASoC: rsnd: call rsnd_ssi_master_clk_start() from rsnd_ssi_init() Date: Mon, 17 May 2021 15:59:41 +0200 Message-Id: <20210517140307.087144453@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kuninori Morimoto [ Upstream commit a122a116fc6d8fcf2f202dcd185173a54268f239 ] Current rsnd needs to call .prepare (P) for clock settings, .trigger for playback start (S) and stop (E). It should be called as below from SSI point of view. P -> S -> E -> P -> S -> E -> ... But, if you used MIXer, below case might happen (2) 1: P -> S ---> E -> ... 2: P ----> S -> ... (1) (3) P(1) setups clock, but E(2) resets it. and starts playback (3). In such case, it will reports "SSI parent/child should use same rate". rsnd_ssi_master_clk_start() which is the main function at (P) was called from rsnd_ssi_init() (= S) before, but was moved by below patch to rsnd_soc_dai_prepare() (= P) to avoid using clk_get_rate() which shouldn't be used under atomic context. commit 4d230d1271064 ("ASoC: rsnd: fixup not to call clk_get/set under non-atomic") Because of above patch, rsnd_ssi_master_clk_start() is now called at (P) which is for non atomic context. But (P) is assuming that spin lock is *not* used. One issue now is rsnd_ssi_master_clk_start() is checking ssi->xxx which should be protected by spin lock. After above patch, adg.c had below patch for other reasons. commit 06e8f5c842f2d ("ASoC: rsnd: don't call clk_get_rate() under atomic context") clk_get_rate() is used at probe() timing by this patch. In other words, rsnd_ssi_master_clk_start() is no longer using clk_get_rate() any more. This means we can call it from rsnd_ssi_init() (= S) again which is protected by spin lock. This patch re-move it to under spin lock, and solves 1. checking ssi->xxx without spin lock issue. 2. clk setting / device start / device stop race condition. Reported-by: Linh Phung T. Y. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/875z0x1jt5.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sh/rcar/ssi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index d0ded427a836..a2f8138d40c7 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -507,10 +507,15 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); + int ret; if (!rsnd_ssi_is_run_mods(mod, io)) return 0; + ret = rsnd_ssi_master_clk_start(mod, io); + if (ret < 0) + return ret; + ssi->usrcnt++; rsnd_mod_power_on(mod); @@ -1060,13 +1065,6 @@ static int rsnd_ssi_pio_pointer(struct rsnd_mod *mod, return 0; } -static int rsnd_ssi_prepare(struct rsnd_mod *mod, - struct rsnd_dai_stream *io, - struct rsnd_priv *priv) -{ - return rsnd_ssi_master_clk_start(mod, io); -} - static struct rsnd_mod_ops rsnd_ssi_pio_ops = { .name = SSI_NAME, .probe = rsnd_ssi_common_probe, @@ -1079,7 +1077,6 @@ static struct rsnd_mod_ops rsnd_ssi_pio_ops = { .pointer = rsnd_ssi_pio_pointer, .pcm_new = rsnd_ssi_pcm_new, .hw_params = rsnd_ssi_hw_params, - .prepare = rsnd_ssi_prepare, .get_status = rsnd_ssi_get_status, }; @@ -1166,7 +1163,6 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = { .pcm_new = rsnd_ssi_pcm_new, .fallback = rsnd_ssi_fallback, .hw_params = rsnd_ssi_hw_params, - .prepare = rsnd_ssi_prepare, .get_status = rsnd_ssi_get_status, }; -- 2.30.2