From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (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 4DD2523D2A1 for ; Sat, 11 Jul 2026 01:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783732333; cv=none; b=eiBAY70X0O9TRYFVzbkfHmxLWlrmidpZb2QXJKBlhxA/AcPIjk3VjKT5Gp3BuUWisNvRiR+XOrpAxrc1/k7vzcREUwiV35pXXnRauIkdpKcLBHcOuGniCmBy0mcBfnAOxZJHsTmiReC90bcIbrVMBXNCDjoC2eyjuv8ceypZMK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783732333; c=relaxed/simple; bh=u3feU+XxbkxG//8hCT8B0WoV0SQtpDUBimXlIjrgWBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qSeNFQzkIs463Q6x3gGOCpFyXL8lywPK2OtgXAGC2zVyoQr7N5LGqp3GabM1coEKKE4oKI+pAnmMbscvfloVurrzXH/O2BjR8GviLMVfLEKopG+ZIAcTkExWrdgr/LQsZKp04katOevDJsJ1y132QxDkKGlSN5hNXamT1Nv1bCI= 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=refGNDhA; arc=none smtp.client-ip=209.85.215.173 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="refGNDhA" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-c966b9ee9cbso723634a12.1 for ; Fri, 10 Jul 2026 18:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783732331; x=1784337131; 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=refGNDhABTSRuhaPnsLxEvdztlsXXTo9l/CH6tKrbhGeGmM7mQaOCrowyaJNVoRXVa j58bI7oSjfVqxpdLTA5tD3583HpS4RTBzUNXMT5BL1UvoAlEBp76wbDnKAPYdWhqVlVk kaFaQu21eBIyhj2iQnh6sEmyAMIp1CTahjM7o5fUu9Cm4OutYPW/TJmzH2OmpOT5BIJQ B38AQSEWg6sF5IxIOAusLDllhBBD7uDexzofjuFxgeIIID4IAPBzfFEXU5hTsRjouRYs 81mwP3NL2hnUfz4VAkK+QwLTegLcajrzbA9JgH7OTmlSaWeqzbMKZetNzA17bH7cFmE7 xBpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783732331; x=1784337131; 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=EuxFH6XveTB87Ffx58YT8Nl1LqWNgsw7dUqILYod4MskvB6pGr9AGmEVJtkawEJ1+n m/9Tfbn7DId1a2Svjvk3f6TfGxO4oesYabypz7GXqa0/G5A0C3O/aVV1j7/5j1vheqlA //ueJwT/qlLaMi6Z1+ZdBM3n8q/36gakZs7OBwKKjODs3lwoaU0tmh6YiG7LdhoSnfds 3a2uDm9j0Lz0iG1iSwyM+VBzGfmTWEyLxSQOfXMj+FY/UFvGYBdPyRrKpx7XzQeUzx59 sYt+U9S0uC+dvm4wP+C9Fc6hCqUN5fYWmPypJaVR3vbRurjHoKEV4y/6lfNFXR25tMFr ev/g== X-Forwarded-Encrypted: i=1; AHgh+RqqSFUwMdYRZSuEPFS6wwKYsxYW3Vi9zoPueWuJXGpWxlQ67wsJ9RIUFhUT+Qv0Sln6yKL0CBoZKA1LQ24=@vger.kernel.org X-Gm-Message-State: AOJu0YwDcb+DmNXNLQ+wsfRSJnwcLVWJOQa8f5Bc1ZjiFjLKK/atnn7m wybJDlADXMDyFkMEOfdRw6Xt9jJ2urob3bWYK6nbLH6mZQfiXdLBmgFwMl6Tqw== X-Gm-Gg: AfdE7cltHWedYYWOij9ziRIFX7sLa3LPZIEqoUL5O90ZlnYr1Xau8XOUw14kXs2/M/8 WSMpqV1wheu26ZxPnclPCO+T1wqyiMV9362AlmsrPbZuUgT9DmoFN7hCfQxbruMvtlCinF2Ybz8 7InwO/Uz94IOrYDfNbNYulRmjg9FvLMQSzN5vi2it6kcMLitYQOfcasNyE06ivqfrs+Z67jemvi webbcKljKjLOxv7n8Z2iOsasmkraisFsM0n4f/ihOzkvKFciNxVzqftJ71ZGwaku/6wA1bMRPqx /Mr+SX0g9JCUrM8h1nW6/zYkzLa8C4oz6F1huOpzaw1tm6166O2Mm2yMiZ+/4g9/loF/gI42aoB Ql+wJsDdQ+7bzvKDQw4/ZO2t6KsURU5BpyzTAtbLVN28CC/i0h4xITpKOKe9BotDtpIZpL93GUr 1eZIkL+JizET8bbj6vFbFSmjgrfDbTfFfqjjbKFMIT6T1a/h37R+TxMdYyrxkrTTy/iCQKlg3eL o5WQdhBAO4UooT0yg8mnoH3mow9MdRADTJxgElwaVy7xgz70gdfxP9K92hkNzcUV4eLSZ6p83oz X-Received: by 2002:a05:6a00:a212:b0:848:79af:8b2a with SMTP id d2e1a72fcca58-848896863bcmr1132948b3a.27.1783732331483; Fri, 10 Jul 2026 18:12:11 -0700 (PDT) Received: from [192.168.2.3] ([2403:581e:d87e:0:fc2d:ed31:e80e:412d]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-848530c5a12sm3751929b3a.5.2026.07.10.18.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 18:12:11 -0700 (PDT) From: James Calligeros Date: Sat, 11 Jul 2026 11:11:24 +1000 Subject: [PATCH v4 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: <20260711-apple-audio-redux-v4-6-2994d87c2f24@gmail.com> References: <20260711-apple-audio-redux-v4-0-2994d87c2f24@gmail.com> In-Reply-To: <20260711-apple-audio-redux-v4-0-2994d87c2f24@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=owGbwMvMwCV2xczoYuD3ygTG02pJDFmBM7xXue//3q0hrTxHXs639vb0HfFLIiYeeZ4eufNMm PPldTv/dUxkYRDjYrAUU2TZ0CTkMduI7Wa/SOVemDmsTCBDpEUaGICAhYEvNzGv1EjHSM9U21DP 0EjHWMeIgYtTAKbao5iRoctnzxqRyJhp3ySWlkW26sUpP3Pd2/DNO/qFashOK+F+L4bfrPJpkY/ 8J7GnHjw8a5pE/M6AJekSn8wKVN+ISgr9LO9jBgA= 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