From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 9CCCA346A13 for ; Tue, 9 Jun 2026 01:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780968738; cv=none; b=LT7eDF7Im0ZhlgbeHHZvAwukzbC2AAQJMjnpBDpK01xrMN9PSQD46JLt60+1T6s77ptdjJ1aJaSnI4hlCHwZM31tT0SM2rjyJxHkgYZJd1cxYx3wQp8TsSpYQhW6+lnTkTUMIC7I16WTP4N2OORU72DeaX0wimuD4XDXqmcMAfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780968738; c=relaxed/simple; bh=FRuIe996eKvxY8l0bKGRUk8hVAskBRiNmK3+CXj26cE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LTAJ1UYFlcH9UjarPAHbs1n44X9DifoJWT8fNALcYE0sIZByMbeG4cApHi36CyLEf/dvGEKuBhgCW+r0Tcd7Qr5oYJqHDqc6khzJKf2iMEuRtTpHTKYzughtGEau6N8i957bCxF8kadsnIkl6sSpJpsM9D3zpIRQ1q5Nkf+3tJE= 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=HQJu+c9F; arc=none smtp.client-ip=209.85.214.172 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="HQJu+c9F" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2bf1f074a12so51451325ad.0 for ; Mon, 08 Jun 2026 18:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780968734; x=1781573534; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JRUk5lBBY750n5StT+TrvtjJM6eotrKNm2nySlVxLJg=; b=HQJu+c9F0jqhnbaje+hTuaxEICL+AUItZB22sMHGOCjCyfJS/qDqnQIGmcczVB12lp AJxpnjvh6Tbp5q3X/lcph/oaP3Winn0sQAzbU8KwIzCJdRkcROd5GBFmmHBrN80xIZdl hi6OOljz9UYHSS8sixCtV4gnbbw04YYe2uGms2IxOsaUzXnRzy4D8VcpnrPE+g2OY0VD bf9mt40AOzzAOu47a7QYvMa5nA8GdVhQMBkhvLfAZM8BmUwOmRXNIcb23d6VMcnYPkr2 YMIgXglbh3R3k8idyRkcYsje3WggxRMIZvZ7RsAXwolfgw1WqETMCGFlkmEegBaD3j+p djlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780968734; x=1781573534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JRUk5lBBY750n5StT+TrvtjJM6eotrKNm2nySlVxLJg=; b=jSXNKrAku565kJgUCFryHerDIAnFF3dL3GQUDVV2pwIoIBzI7bvKUJc8vfGd/EVqiQ tRPFiuXX6XKW12MW8/7+a6am5WgJ8Z11ZtwhZWKAeNYvcEYKdBvVviy45QHboM+GfOK7 HrUyC/kPgNuxS2nGC3iD16pkm5XSfiOEonTowznFCaQ0yaRZhjUsMbM3HQs+zU7NJCw2 MND44/uystLZK3a18DThoi71oV/N4Z+2x1qbu4BAg+VAumSzoEgRjn708qZNRoIYv+Yc U5GR7tnx0Ai2JTQwjXhWZ4q65/1ZO16AJ7b10K4vRDCmhqrXwfs/mjjx1ztCOJX2gjBo Y7Jw== X-Forwarded-Encrypted: i=1; AFNElJ+eX4O07LggeJ4PK5rCM0/+wXRg5vfDEOvO2HFPzSOz01TRxB7zzRsrgpTpOraFupaPvE2UxbdrOXgR1aQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyBuxWjda+7vhD6OL6xUsbL80HgkL2NgAeJR3Iv2lek0hZQ6VIP N2q2FKUAAiw2Cd2+oXPd4QF4y8VIQrP9pXq7L5I2U2yTV13o5CaU05az X-Gm-Gg: Acq92OEm5A/PHFjO7mRIy3xdDaoAlfpVY7aRxe67a+3oB96B6hWZHlSmVQ25WRWb67g FgEo76Tv+KeNbQAo5k2XO4sXDvK/vwOLGGQpwG2erPWk+h9uQ+wAWG2Kk3IXLgp0Lah/vWnyAHe a3lHdwExCvBdUA5lJCVpwJjhLQVm57C7V7BfB5gf4ZxN1GP9FV2bFJJ34ETPSnGR3htNQZKcqK0 UFz9huKWljFoDkkRxUkpIpeXhjcERxi9EqWoK7lqqWLJyK/cAElJcUdvUXhFTzFZxu4pFgZOvjD ZErZkL7ZkGqzBvfdHmcTy0ITo81Co1iX+vlx4UpyO2+MNxvbRwIa0z8sFE0zQMNr/9seyEFCuLx C0Loz+pma8pxY8KU3Ou/fgrrz2IZfcjz3PRx34U6zKYpdwz9lwxiFm+pdgC0lixroQFsLhyDozZ 0DKEnagU98dXMYfGNVJr6yXxXcifsa+iJVekiJxNOyXlMD6uWoc11FjC3ueYv0JJAb7dpg X-Received: by 2002:a17:903:41d1:b0:2c0:af09:f3c7 with SMTP id d9443c01a7336-2c1e85c0cbamr211904955ad.30.1780968733886; Mon, 08 Jun 2026 18:32:13 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609e627sm198765335ad.52.2026.06.08.18.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 18:32:13 -0700 (PDT) From: phucduc.bui@gmail.com To: Kuninori Morimoto , Mark Brown , Geert Uytterhoeven Cc: Liam Girdwood , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH v5 10/11] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare() Date: Tue, 9 Jun 2026 08:31:06 +0700 Message-ID: <20260609013107.5995-11-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260609013107.5995-1-phucduc.bui@gmail.com> References: <20260609013107.5995-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc Add fsi_clk_prepare() and fsi_clk_unprepare() helpers and call them from fsi_dai_startup() and fsi_dai_shutdown(). This ensures clk_prepare() and clk_unprepare() are executed from sleepable contexts and keeps clocks prepared only while audio streams are active. Suggested-by: Kuninori Morimoto Signed-off-by: bui duc phuc --- Changes in v5: - Drop count & spu_count and rely on the clk core for clock reference counting. Changes in v4: - Move clock->count early return check to the beginning of fsi_clk_[un]prepare() to simplify the code. sound/soc/renesas/fsi.c | 51 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c index 6c432c7235a4..80e87b815c1b 100644 --- a/sound/soc/renesas/fsi.c +++ b/sound/soc/renesas/fsi.c @@ -730,6 +730,54 @@ static int fsi_clk_is_valid(struct fsi_priv *fsi) fsi->clock.rate; } +static int fsi_clk_prepare(struct fsi_priv *fsi) +{ + struct fsi_clk *clock = &fsi->clock; + struct clk *spu = fsi->master->clk_spu; + struct clk *xck = clock->xck; + struct clk *ick = clock->ick; + struct clk *div = clock->div; + int ret; + + ret = clk_prepare(spu); + if (ret) + return ret; + ret = clk_prepare(xck); + if (ret) + goto err_spu; + ret = clk_prepare(ick); + if (ret) + goto err_xck; + ret = clk_prepare(div); + if (ret) + goto err_ick; + + return 0; + +err_ick: + clk_unprepare(ick); +err_xck: + clk_unprepare(xck); +err_spu: + clk_unprepare(spu); + + return ret; +} + +static void fsi_clk_unprepare(struct fsi_priv *fsi) +{ + struct fsi_clk *clock = &fsi->clock; + struct clk *spu = fsi->master->clk_spu; + struct clk *xck = clock->xck; + struct clk *ick = clock->ick; + struct clk *div = clock->div; + + clk_unprepare(div); + clk_unprepare(ick); + clk_unprepare(xck); + clk_unprepare(spu); +} + static int fsi_clk_enable(struct device *dev, struct fsi_priv *fsi) { @@ -1580,7 +1628,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, fsi_clk_invalid(fsi); - return 0; + return fsi_clk_prepare(fsi); } static void fsi_dai_shutdown(struct snd_pcm_substream *substream, @@ -1588,6 +1636,7 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream, { struct fsi_priv *fsi = fsi_get_priv(substream); + fsi_clk_unprepare(fsi); fsi_clk_invalid(fsi); } -- 2.43.0