From nobody Sun Feb 8 05:28:35 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 9E9783E9F73 for ; Fri, 6 Feb 2026 13:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770385278; cv=none; b=XHmLCwNajZbUVz/6tTxQhcAqFfsIthcqmqpotDGfsVs1KRtQGdONk1N+lnES3scXnF9HRA3CU5anD8lMFmmQj+FVzbUaqe813dLIxx7WsYZgIKbzPnV8MOqK2ndjt9ypthSh0NWDq7X+7tJm6i5S9SNEGM/II63iz7q2hJYCHy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770385278; c=relaxed/simple; bh=pNmYl4SRRlxoqTa+HBhQFonZHLfqFv5puocqMEMJFj0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=M+EkJG3YY3CQCN/ApvbncIqPHrNLhu5xm8QxBSs/G8P8gKJNZX0lHj/Tz0UloIuUK1mIa7gMt0tlIs+/GwnVg823JOAGYXkE0U5/DQ+CBJi0alk7f3lwiZcrKMjn1TanUV+75jxlkoDv8zvUDDPDeJm8acPtzLdfHFDLfDn2E3k= 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=mpkrKjFL; arc=none smtp.client-ip=209.85.128.46 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="mpkrKjFL" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4801bc32725so5765035e9.0 for ; Fri, 06 Feb 2026 05:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770385276; x=1770990076; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c3KiMSbLBLSEsZOHG/N7zBYQbCkkX7NdFxJPu+HPiHo=; b=mpkrKjFLWlPK798p7MsBCUYBfHq29fQuEpM51w+laLP9PB1XJwAlkjeSSnwvFurN6y 6ia7B/kW8+j715tuGe2pfo49GBRrEs4cduuRRPcgyczQL9vzHEK1J2PF6KSPXmve/EK/ tzAIuYDDDHD7qFxI8dnlwoledmVSkj3n23yph14of4QhynVcujbylWnH+jRjLJLrnczN jhBMt0lQcapIwFXq8IwIo83w6Dd6Awvl64Z0872Fj6XSL2MDTygDWt6WWipBBOzJ0KVE NuWIqmWLf2pkhMnl25DYCez8fI/w0o0VKRRK5ywzinowFr9SjLE0oQal19shSQLmfzkJ LkzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770385276; x=1770990076; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c3KiMSbLBLSEsZOHG/N7zBYQbCkkX7NdFxJPu+HPiHo=; b=UNdrFsHYbhtP60g/+ktBre3kaZ+heMOECFZerVISQa51GP9X5zbq67xUCZ8vNsZ5Tj sLUYJts1MmOPhkmiGyXoHveb4MBKrWsmkceDU9bnG5OnmOaw6nW28deSAW9DQ0+LS2jX wg1iP9afYyDZvxLbnQyyzG1Y8C7C8LkcfgBcECzZ75rwWn4BOgTZK65DWHUsbHpgdbr0 t3e7lM4ymKItx2tccCgfOkGcPlNg+wY5dED9r+0i+YiJlXM7Q326dUKwCokoHFg02Z74 ODKMj0lOsJar5d6UEVsJqe24gBF/hF3uPJ7V1beAgl3RK+sgxf2exJOJrlfjKOblUqh7 beRA== X-Forwarded-Encrypted: i=1; AJvYcCUem41WbHr7Vrk2zqRYMcUOceqk4lSbvtShqYF/d/tJyU9JwpMFzMsT7aMTPsD2zBnxLUQG/9tu3GevDLo=@vger.kernel.org X-Gm-Message-State: AOJu0YzSfBDiQ9dyFxHEqTi+JhFmooMTaggSVr3GOXWpkyaIe8d65kys KAfYzPsfOymSOtX2v0OUCZ/0mbWEVkmgDQ11bSzDvVfkSOIbFwv79khpKwQkyQ== X-Gm-Gg: AZuq6aJ4mHUk/Gi3/YfIGIbco54dauz4iFgpqYa8KbJKMlGm/N5xc6Gb2CnUlj1MQaN 1pw5pryjhJFCDp2CvgpL06OV/gJ0TAvV2UUVDKBaZb+RLLkwhkEBTYy4E06OcDp9Jj3tVRcTEtg LAmyzv17tb75qzv8O5KvsvEmrkFqhT+JAHVwIpIpOGXDAD3KRzp9RN8BTX4jTaxDmFgEv4NRS1w IzvceOXcRh9KMpAeS6Uh2YsXOC/UJj1HW/9815vxhLTS9LPpF3M53ppzf6Mym7sotY8d6bTXYqj g8g3B2XA9/MIwZOTpwf0pGhFGfrGPQJFk0Z+MScMsnaxwGF3Sc5D90YQprB2/vk7+53tvIpOT9s vL0WhNC3vxr4x9cn9kFS7TJL1114dz8Iwo0BDiVB/qrgI1U+DAFWllsS5TjCSlL/1hd4U+kArA/ Yz28f81sZq0JskPAnRALPcziok+yqvznRhvWRbUi4+h/7AP6nfXjAy1lUTDih6zY3sJO7qAdfUT g538yjqdBWG7iuBI1/ZkFgCS3g= X-Received: by 2002:a05:600c:37c8:b0:47e:e952:86c9 with SMTP id 5b1f17b1804b1-4832017dcfcmr39432355e9.0.1770385275553; Fri, 06 Feb 2026 05:41:15 -0800 (PST) Received: from Lord-Beerus.station (net-188-152-100-94.cust.dsl.teletu.it. [188.152.100.94]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4832039d238sm33156995e9.0.2026.02.06.05.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 05:41:15 -0800 (PST) From: Stefano Radaelli X-Google-Original-From: Stefano Radaelli To: Mark Brown , Kuninori Morimoto , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alexander.h@variscite.com, pierluigi.p@variscite.com, Stefano Radaelli Subject: [PATCH v1] ASoC: simple-card-utils: set CPU sysclk before codec for mclk-fs Date: Fri, 6 Feb 2026 14:40:14 +0100 Message-ID: <20260206134014.143057-1-stefano.r@variscite.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Radaelli When simple-audio-card uses simple-audio-card,mclk-fs, simple_util_hw_params() programs sysclk for codec DAIs and CPU DAIs. Some CPU DAIs may apply the final MCLK rate as part of their .set_sysclk() callback (e.g. by changing the underlying clock rate via clk_set_rate()). If codec sysclk is configured before the CPU DAI applies the final MCLK rate, the codec may configure its internal clocking based on a non-final MCLK setting, leading to an incorrect clocking state on the first playback after boot. This behaviour was observed on i.MX95 systems using fsl_sai with downstream kernels, which made the issue visible. However, the problem is generic and can affect any setup where the CPU DAI applies the final MCLK rate in set_sysclk() while simple-audio-card uses mclk-fs. A reproducible symptom is that the first playback runs at the wrong speed ("slow" audio), while subsequent playbacks work correctly. Example setup: - CPU DAI: fsl_sai (i.MX95) - Codec: wm8904 - simple-audio-card,mclk-fs enabled Reproducer: aplay -D hw:wm8904audio /home/Front_Center_8k.wav Debug evidence: ftrace showed snd_soc_dai_set_sysclk() called from simple_util_hw_params for both codec and CPU DAIs, and confirmed wm8904_set_sysclk() ran before the CPU DAI sysclk call, and the CPU DAI then applied the final MCLK settings. Fix this by setting the CPU DAI sysclk before the codec sysclk when mclk-fs is used, so that the codec always configures its internal clocking based on the final MCLK rate. Signed-off-by: Stefano Radaelli --- sound/soc/generic/simple-card-utils.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simp= le-card-utils.c index bdc02e85b089..50f60e4996a5 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -501,15 +501,21 @@ int simple_util_hw_params(struct snd_pcm_substream *s= ubstream, goto end; } =20 - for_each_rtd_codec_dais(rtd, i, sdai) { - pdai =3D simple_props_to_dai_codec(props, i); + /* + * When mclk-fs is used, some CPU DAIs may change the + * actual MCLK rate in set_sysclk() (e.g. via clk_set_rate()). + * Configure CPU DAI first so codec clocking/FLL sees + * the final MCLK rate. + */ + for_each_rtd_cpu_dais(rtd, i, sdai) { + pdai =3D simple_props_to_dai_cpu(props, i); ret =3D snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); if (ret && ret !=3D -ENOTSUPP) goto end; } =20 - for_each_rtd_cpu_dais(rtd, i, sdai) { - pdai =3D simple_props_to_dai_cpu(props, i); + for_each_rtd_codec_dais(rtd, i, sdai) { + pdai =3D simple_props_to_dai_codec(props, i); ret =3D snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); if (ret && ret !=3D -ENOTSUPP) goto end; base-commit: b7ff7151e653aa296ab6c5495b2c1ab7c21eb250 --=20 2.47.3