From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C202D6409 for ; Sun, 5 Jul 2026 03:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783222740; cv=none; b=FW+eZy4w+CTlrMcAeirjLh5wnJvlb/rMigKEpLAO/GSQm8mAQPU9DPCwZtpZqNZF8pc024jiu0fiXUWielyfsk8f+yZX61X0KzVTl1QAC4JI5ftNhw6QG+JyhICmIgskcQRrUiEsJBLtNhkyN2JgPK4q0EeDGEQ7WwxDLXOEAl4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783222740; c=relaxed/simple; bh=u3feU+XxbkxG//8hCT8B0WoV0SQtpDUBimXlIjrgWBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O8r3WZ0YPxEMSJC9gn1mTLe9ta22Qe2pLxnJCKmA6aVK1w950/D5UJayEcaPGuHWQ7si2tfKyhAISJPUUvuNh9i7U412Ccfnj5gSDrMFGJju4piIrBTnXSRRYldRfFhGNhDJmHbvP1g1t2uZyDEXehKpLIVPPfvDHzVQlF4u/xI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=akLbzkaY; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="akLbzkaY" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-84794e800f4so952920b3a.0 for ; Sat, 04 Jul 2026 20:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783222737; x=1783827537; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mN+pJBIMoW7rE9Ren2+zTaJ8YB+31uYcQku98tORliE=; b=akLbzkaYMl0amaJ17KtRs8XpQ/L+tkmn9UNDsFl2nNmMDTEbj6Spunr4ul2k0fytdQ p0D8O2vydSGrxqElbC4P5iwmoebs+xDYDV7Jt88LR64GovYvkCacYJe8Ikyr4LSB37Nl CqPq4v67FJhj2U8FiGQviwrcr2QArZhc7t5nmOx1SuXAbwCOcZUS+BvfUuLwTnHBTDVT JNmN1W0lEtlq3D/zyaUxD6uN1TIf6ORzvEPhnYZwwnQ9ID6zLhV5m6wsH9TrIKLAgck8 QoW2jJvyAmuBHrdnm5ns6+Na7R7OkQmAquAs4KCN1UGnOTkdcgpifRC9elF/cSQ5zDpT VPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783222737; x=1783827537; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mN+pJBIMoW7rE9Ren2+zTaJ8YB+31uYcQku98tORliE=; b=f/IVOyhxRZF1e2uU0uelwkRc2xPSf+Etk8QN/8p3up7ASl5bc7nUXg4M74DxP+X++2 N3gWyxT+ZWbuZptugErDwrGtqNS8MCxsQ9B6i9VWHp5F+WZ+qb/jpeyOBNpjw49Op5BM Md4txyZPpFR9nMRlH6/XSNalDUodczgwR0/2btviMDG5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a8af0-3c03e4aa5c8mr5520256637.35.1783222737181; Sat, 04 Jul 2026 20:38:57 -0700 (PDT) Received: from [192.168.2.3] ([2403:581e:d87e:0:fc2d:ed31:e80e:412d]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b41c364d5sm35463845c88.14.2026.07.04.20.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2026 20:38:56 -0700 (PDT) From: James Calligeros Date: Sun, 05 Jul 2026 13:37:55 +1000 Subject: [PATCH v3 6/7] ASoC: apple: mca: Do not mark clocks in use for non-providers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260705-apple-audio-redux-v3-6-ff7a7afe2b6b@gmail.com> References: <20260705-apple-audio-redux-v3-0-ff7a7afe2b6b@gmail.com> In-Reply-To: <20260705-apple-audio-redux-v3-0-ff7a7afe2b6b@gmail.com> To: =?utf-8?q?Martin_Povi=C5=A1er?= , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: asahi@lists.linux.dev, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , James Calligeros X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3278; i=jcalligeros99@gmail.com; h=from:subject:message-id; bh=oPUxYsS4dAnn3g0MJvrYuVUHiPTpgN/zgb3R1tQjvLc=; b=owGbwMvMwCV2xczoYuD3ygTG02pJDFmeF7eaF73WU3vsxbJ5q/Z6pSdF7sxMpWlpFb82+/87t ZOzintSx0QWBjEuBksxRZYNTUIes43YbvaLVO6FmcPKBDJEWqSBAQhYGPhyE/NKjXSM9Ey1DfUM jXSMdYwYuDgFYKo1DRj+Z53We/RA6fCMyMUOGRzf12QUS09dkJYn4XRvYeNhh7reSwx/hfPe+M3 vPpa85d6ULzym7yal786u3pFSq5TH/VpQcTsLKwA= X-Developer-Key: i=jcalligeros99@gmail.com; a=openpgp; fpr=B08212489B3206D98F1479BDD43632D151F77960 From: Hector Martin On the speakers PCM, this sequence: 1. Open playback 2. Open sense 3. Close playback 4. Close sense would result in the sense FE being marked as clocks in use at (2), since there is a clock provider (playback FE). Then at (4) this would WARN since there is no driver any more when closing the in use clocks. If (1) and (2) are reversed this does not happen, since the sense PCM is not marked as using the clocks when there is no provider yet. So, check explicitly whether the substream FE is a clock provider in be_prepare, and skip everything if it isn't. Signed-off-by: Hector Martin Signed-off-by: James Calligeros --- sound/soc/apple/mca.c | 67 ++++++++++++++----------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/sound/soc/apple/mca.c b/sound/soc/apple/mca.c index d8973e5611dd..322dd8771111 100644 --- a/sound/soc/apple/mca.c +++ b/sound/soc/apple/mca.c @@ -346,36 +346,6 @@ static bool mca_fe_clocks_in_use(struct mca_cluster *cl) return false; } -static int mca_be_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct mca_cluster *cl = mca_dai_to_cluster(dai); - struct mca_data *mca = cl->host; - struct mca_cluster *fe_cl; - int ret; - - if (cl->port_clk_driver < 0) - return 0; - - fe_cl = &mca->clusters[cl->port_clk_driver]; - - /* - * Typically the CODECs we are paired with will require clocks - * to be present at time of unmute with the 'mute_stream' op - * or at time of DAPM widget power-up. We need to enable clocks - * here at the latest (frontend prepare would be too late). - */ - if (!mca_fe_clocks_in_use(fe_cl)) { - ret = mca_fe_enable_clocks(fe_cl); - if (ret < 0) - return ret; - } - - cl->clocks_in_use[substream->stream] = true; - - return 0; -} - static int mca_be_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -805,6 +775,43 @@ static struct snd_soc_pcm_runtime *mca_be_get_fe(struct snd_soc_pcm_runtime *be, return fe; } +static int mca_be_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *be = snd_soc_substream_to_rtd(substream); + struct snd_soc_pcm_runtime *fe = mca_be_get_fe(be, substream->stream); + struct mca_cluster *cl = mca_dai_to_cluster(dai); + struct mca_data *mca = cl->host; + struct mca_cluster *fe_cl, *fe_clk_cl; + int ret; + + fe_cl = mca_dai_to_cluster(snd_soc_rtd_to_cpu(fe, 0)); + + if (!fe_cl->clk_provider) + return 0; + + if (cl->port_clk_driver < 0) + return 0; + + fe_clk_cl = &mca->clusters[cl->port_clk_driver]; + + /* + * Typically the CODECs we are paired with will require clocks + * to be present at time of unmute with the 'mute_stream' op + * or at time of DAPM widget power-up. We need to enable clocks + * here at the latest (frontend prepare would be too late). + */ + if (!mca_fe_clocks_in_use(fe_clk_cl)) { + ret = mca_fe_enable_clocks(fe_clk_cl); + if (ret < 0) + return ret; + } + + cl->clocks_in_use[substream->stream] = true; + + return 0; +} + static int mca_be_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { -- 2.55.0