From nobody Sun May 24 19:34:51 2026 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 119C72FDC3C for ; Fri, 22 May 2026 02:30:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779417019; cv=none; b=rUGgfLHmi822rPj3fngnMCNzyWiXo/jsVzOtUDi5P9V6jTguLgeaDSJWsX0UlQiCOT50g0R3dZnD5ervyl23l0bdCrxjbs5TavEEcKUXeaG6cwDt6Q9Aos1y9bkqAmqqPpOJs2BELmVHmb9w3B849ww+QSPcxmEsg6EXN8cpOVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779417019; c=relaxed/simple; bh=TMV3OUjSiKWrVH9DS2Bb4U32yk1kAQtbOJI6PQhF/+k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=hx6nDd1CQInsQRGhe2oCiMfAbr8PotPMQ44tZohL4TncRLh5cQht2VIbMwMg4tzTNexGoA+ogRtBB3AuCvdevPIWwJ7/mXxQW/KtINQG0W0gKZX3aCEs6ywI7Tsz7mUZjxEdjRN904cX/fJoTkbiht5tT8S+jmbZbBIQKD4ViFk= 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=rUHfnre8; arc=none smtp.client-ip=74.125.82.41 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="rUHfnre8" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1363e78746eso1654113c88.1 for ; Thu, 21 May 2026 19:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779417017; x=1780021817; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=7P3tHPmrG3wLPqmsJl2HC3o69eg3JUch5W4/s30Hz1E=; b=rUHfnre8k7jaOqen7DrXBemdgW7umzjudtUTFdnZN304vd3Z3OB1AIhtr+iEQPqh+S Tqadd0mSfMBFyfgmUcg78wGTTyMsrQ3wP9frSfGgqqi8Yt2nMdDI3VyKUFHWrUel61HW TPBW4+foBQ7KFYQvAqLVWUyMFI2gYVoQXrpUCTzEIpALfj5wOOmN5WzQbGLBJwc6ReqW 1VxVmYaNkFlrKHpHA4WGa883Xnc9M9bW6eAxf0z1Pf8pq4zEsfGNdiJkYRVxDigGUVnX qADMajh31AGHz6P+OH3FrMNQvEf0FD98UswiYjofHltQwQUCtxIZELO/h9nFafAyFB00 LE9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779417017; x=1780021817; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7P3tHPmrG3wLPqmsJl2HC3o69eg3JUch5W4/s30Hz1E=; b=OcNc4geHRkTKKNtiVQqcVT0RGmZtby7Yp4BTrrOVkjamEqUS0moNF0QNiFUtJQGFmy CRINHeXfC3Bj/0Lz1jUjaOXqM3KnfdyDYY+vuFJSffvdBBn00e4aWOqzbVSz211JxFof 5zLt8Zw5BgiRCdwWkSbbYTXrWDAJAAx4YKec9SpSmmO1/A2nM6b93FzbAmN9LDLGM46N MDkwlR5PVsKXEAWWom8JkOkXUQbVbKVBrCupd3aWl8qzykHeqdnoLVpX73fKFRELavkG 23qwRNwv7ujcRpu07o1NbUlBJ4DI9/xOQ3so5gM8AZh462fC0mZO51Uj6BZj/Ib5Gt23 ta/g== X-Forwarded-Encrypted: i=1; AFNElJ8HGcy256xN19p/g3OfkUjDGkHTk3pps2E/jAlX0um+FVeFq6T9YQbqtkDotSiqcWS0Ob2w0nBCQVM8vEA=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0Mdw1ynIz4qnD4rMzTQCkVrG7ngzpIxBc1ibxW42oGvJTdMK0 0y042BVDV3B26QLbIgvHh05kQY+8VDhIs95enFFiyKG76KxlT8EA0RRd X-Gm-Gg: Acq92OGXXpOTBTLrGLCyD0TSSGC+tTKmsCnKg/VcSonHGJGmL8RqR22kIiXyE+xv20i o7I1qIxLr2FxIe7gqYgGMc92pMA1+e3Shnsz1/hONvkCyRzDguJp7wjg4PESagAoXI7p9UklJwf +GI6tyFgz7b1AiC4zFdwav3CyI/r/8ceYE9/Ps8zMSoecJ4slxekRHUeBtHH+Fv/yKT1lzEb4IS pPSzLSBuwznAr9dcjWM5JCR02MtIQrwvRb+ZrZd89NuHQGOkQtgfD+Gadl1CYbN5icFsIFzGsvC E/gt+yu/RxcbFb+IOOwtuKZOcsrF6/So/l6orvf35xM6EtFkvfXO53Xfjyr9entHpoU9y49XGDM vdG+hnpZBPmkHDpltwuZRsI54X6piLhECVCwwJRe8gvx1lvpA19y73+L1gnDbDPP7bx6Ryb8/EX q9aJ1/MundVMw59EqTDpSWQdirm5HzcqLbk+sV5foPwZjwMvVKUk2J6u1xJTN3MlxOl5OGnED0T Q== X-Received: by 2002:a05:7022:661f:b0:135:f2aa:46da with SMTP id a92af1059eb24-1365f812eefmr696894c88.16.1779417017083; Thu, 21 May 2026 19:30:17 -0700 (PDT) Received: from [192.168.1.18] (177-4-162-74.user3p.v-tal.net.br. [177.4.162.74]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13669c6a2adsm293024c88.0.2026.05.21.19.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 19:30:16 -0700 (PDT) From: =?utf-8?q?C=C3=A1ssio_Gabriel?= Date: Thu, 21 May 2026 23:30:07 -0300 Subject: [PATCH] ASoC: rockchip: i2s: Use managed hclk and runtime PM cleanup 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: quoted-printable Message-Id: <20260521-asoc-rockchip-i2s-devm-cleanup-v1-1-9319bd781393@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yXNywrCMBBG4Vcps3agDaagryIu4uSvHS9NyNgil L67UZff5pyVDEVhdGxWKljUNE0V3a4hGcN0BWusJte6vvWu42BJuCS5y6iZ1RlHLE+WB8I0Z+4 lRPhhf/DwVCO5YND3b3A6/23z5QZ5fau0bR/FocZRggAAAA== X-Change-ID: 20260521-asoc-rockchip-i2s-devm-cleanup-6cade5f495e5 To: Liam Girdwood , Mark Brown , Takashi Iwai , Jaroslav Kysela , Heiko Stuebner Cc: linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?C=C3=A1ssio_Gabriel?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5256; i=cassiogabrielcontato@gmail.com; h=from:subject:message-id; bh=TMV3OUjSiKWrVH9DS2Bb4U32yk1kAQtbOJI6PQhF/+k=; b=owGbwMvMwCV2IdZeKur/u2bG02pJDFn8+7c+Pl3a4dA4+WnT0pC6856eb3pTIvWsll/tLAv/s 1bePsGxo5SFQYyLQVZMkWV10iLLPV0PrtbHrfCAmcPKBDKEgYtTACYSK8fwz9R8pszmW4U/8iYG 5VU7t8kESQb88EvrWX5vh1mvgrwXB8M/5cWzy6b+X9q3dUegnmSFT+rqjJN+wUa7/SOWc37vVvn MDQA= X-Developer-Key: i=cassiogabrielcontato@gmail.com; a=openpgp; fpr=AB62A239BC8AE0D57F5EA848D05D3F1A5AFFEE83 The Rockchip I2S driver mixes devm-managed probe resources with manual runtime PM and hclk cleanup. This leaves the remove path doing runtime PM shutdown and clock disable before devm-managed ASoC and PCM resources are released. Keep the bus clock enabled for the device lifetime with devm_clk_get_enabled(), and move the runtime PM teardown into devres so the unwind order matches the managed registrations. This also removes the remove callback, which only existed for cleanup. Use a devm action for the final runtime suspend and register it before the managed runtime PM action, so teardown disables runtime PM before forcing the device into the suspended state. Signed-off-by: C=C3=A1ssio Gabriel --- sound/soc/rockchip/rockchip_i2s.c | 68 +++++++++++++++--------------------= ---- 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchi= p_i2s.c index 49ff86b35ef1..4e3af0f37941 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -664,6 +664,14 @@ static const struct of_device_id rockchip_i2s_match[] = __maybe_unused =3D { }; MODULE_DEVICE_TABLE(of, rockchip_i2s_match); =20 +static void rockchip_i2s_suspend(void *data) +{ + struct device *dev =3D data; + + if (!pm_runtime_status_suspended(dev)) + i2s_runtime_suspend(dev); +} + static int rockchip_i2s_init_dai(struct rk_i2s_dev *i2s, struct resource *= res, struct snd_soc_dai_driver **dp) { @@ -758,37 +766,28 @@ static int rockchip_i2s_probe(struct platform_device = *pdev) } =20 /* try to prepare related clocks */ - i2s->hclk =3D devm_clk_get(&pdev->dev, "i2s_hclk"); + i2s->hclk =3D devm_clk_get_enabled(&pdev->dev, "i2s_hclk"); if (IS_ERR(i2s->hclk)) { dev_err(&pdev->dev, "Can't retrieve i2s bus clock\n"); return PTR_ERR(i2s->hclk); } - ret =3D clk_prepare_enable(i2s->hclk); - if (ret) { - dev_err(i2s->dev, "hclock enable failed %d\n", ret); - return ret; - } =20 i2s->mclk =3D devm_clk_get(&pdev->dev, "i2s_clk"); if (IS_ERR(i2s->mclk)) { dev_err(&pdev->dev, "Can't retrieve i2s master clock\n"); - ret =3D PTR_ERR(i2s->mclk); - goto err_clk; + return PTR_ERR(i2s->mclk); } =20 regs =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(regs)) { - ret =3D PTR_ERR(regs); - goto err_clk; - } + if (IS_ERR(regs)) + return PTR_ERR(regs); =20 i2s->regmap =3D devm_regmap_init_mmio(&pdev->dev, regs, &rockchip_i2s_regmap_config); if (IS_ERR(i2s->regmap)) { dev_err(&pdev->dev, "Failed to initialise managed register map\n"); - ret =3D PTR_ERR(i2s->regmap); - goto err_clk; + return PTR_ERR(i2s->regmap); } =20 i2s->bclk_ratio =3D 64; @@ -799,8 +798,7 @@ static int rockchip_i2s_probe(struct platform_device *p= dev) i2s->bclk_off =3D pinctrl_lookup_state(i2s->pinctrl, "bclk_off"); if (IS_ERR_OR_NULL(i2s->bclk_off)) { dev_err(&pdev->dev, "failed to find i2s bclk_off\n"); - ret =3D -EINVAL; - goto err_clk; + return -EINVAL; } } } else { @@ -811,16 +809,23 @@ static int rockchip_i2s_probe(struct platform_device = *pdev) =20 dev_set_drvdata(&pdev->dev, i2s); =20 - pm_runtime_enable(&pdev->dev); + ret =3D devm_add_action(&pdev->dev, rockchip_i2s_suspend, &pdev->dev); + if (ret) + return ret; + + ret =3D devm_pm_runtime_enable(&pdev->dev); + if (ret) + return ret; + if (!pm_runtime_enabled(&pdev->dev)) { ret =3D i2s_runtime_resume(&pdev->dev); if (ret) - goto err_pm_disable; + return ret; } =20 ret =3D rockchip_i2s_init_dai(i2s, res, &dai); if (ret) - goto err_pm_disable; + return ret; =20 ret =3D devm_snd_soc_register_component(&pdev->dev, &rockchip_i2s_component, @@ -828,36 +833,16 @@ static int rockchip_i2s_probe(struct platform_device = *pdev) =20 if (ret) { dev_err(&pdev->dev, "Could not register DAI\n"); - goto err_suspend; + return ret; } =20 ret =3D devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); if (ret) { dev_err(&pdev->dev, "Could not register PCM\n"); - goto err_suspend; + return ret; } =20 return 0; - -err_suspend: - if (!pm_runtime_status_suspended(&pdev->dev)) - i2s_runtime_suspend(&pdev->dev); -err_pm_disable: - pm_runtime_disable(&pdev->dev); -err_clk: - clk_disable_unprepare(i2s->hclk); - return ret; -} - -static void rockchip_i2s_remove(struct platform_device *pdev) -{ - struct rk_i2s_dev *i2s =3D dev_get_drvdata(&pdev->dev); - - pm_runtime_disable(&pdev->dev); - if (!pm_runtime_status_suspended(&pdev->dev)) - i2s_runtime_suspend(&pdev->dev); - - clk_disable_unprepare(i2s->hclk); } =20 static const struct dev_pm_ops rockchip_i2s_pm_ops =3D { @@ -866,7 +851,6 @@ static const struct dev_pm_ops rockchip_i2s_pm_ops =3D { =20 static struct platform_driver rockchip_i2s_driver =3D { .probe =3D rockchip_i2s_probe, - .remove =3D rockchip_i2s_remove, .driver =3D { .name =3D DRV_NAME, .of_match_table =3D of_match_ptr(rockchip_i2s_match), --- base-commit: 40cc9602caf2539369bd3dd7d66ee67e204e75ef change-id: 20260521-asoc-rockchip-i2s-devm-cleanup-6cade5f495e5 Best regards, -- =20 C=C3=A1ssio Gabriel