From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796324274; b=Q26wr9++YBp1CR6W5Eh5+EtXOx6eRHp/iKoTrgsS49V95Dw0DxTOisEwE6oe8jpQS3od qmRAsxxGe2P43sSBvF3AubexeeXDbTbX6+MMdrR/zm4CWZyHTBUjskd2bEbgv3Y0qXkw0 eoq+TEhwgbZlkiRdvJ9wvn2twADTNOvKAB2WZ1oZUVY6ylwHzx80t4E8i32Oy3CbLcTm8 H+yKDC0+nvl3OFPWZjw2SJAclBQ0WTmBwcwtHv4P/OKd+acF/cZG7V9yOmPqReHnDU/eD +jEW0eFygzsfp89Hzs4Gvq1Zvk+rpth29nuwnIRW49F16PiP7qlGz/27wA3z4LJ2Nbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796324274; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=CSL2aYSijtHT8X2k6vKnaaJaChCmcKAy18j+qFBfFkM=; b=PPbbaeJwzg0X30COXUSjjM/oGkBBbMK28m9L7xS83iCxnOFMnESUftMVN82bDcoALn4Y FecbLb1EvB2Ux+8pWcK4W2c6B3PHvkly21OdKKQjyyv2IzeNAQRvOcYHIhwZknqS0cw2S Cuy0esG9JgecJLrysU+Up30k2WLJwbL3IqvqnSGhJakgxayN5vbVjO5qIJAT0JrP2ZIZc MP79sexOAbBsgGP15td75Dkh2/M7PSb2kUzmhOPXLmWj3V9cDnK/n3Ka9H531rf7ekwsL ElHHIhHzVi1rH9K0c//c2USwMLpIItsitQx83V7QUdBFycqLLTVy5t/dSQqTNmSdsWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W55KUAYH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27632606A322; Thu, 3 Dec 2026 18:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=W55KUAYH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80F501F000C1; Thu, 3 Dec 2026 18:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796324273; bh=CSL2aYSijtHT8X2k6vKnaaJaChCmcKAy18j+qFBfFkM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=W55KUAYH/AVBzJuBieFmVaaH6GN/x757Wf8NDWbHPhuLdt3FfiQqYgb280MkLYvIy mXq4XoD9Wl2Lis6gfggz1tNpPvpp5ZIszbJSc60viyaQwOO5yggke/LxFr/D+ZG8dk nOL7IHRcXnb0jiYJDvRxW6RCAdqX2uiJdf7zASfS42Kb2Mv63z2P68E5MMVeU1sdyP 2PEH3e9wFXLMjKFJoO0Y7dFC2Zobscgk+qandmWdbWZJEerQe0e6rXNd2OQktVnyxx lMW6GytoE6JxLObBHcgNNfraqty8w0s46mVK7BSbYgbQtYRKp7TVLOJaBqOWgrggv1 7s7IiI0iPhBYw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v16 2/2] clk: qcom: Add LPASS VA CSR heartbeat pulse clock Reply-To: sashiko-reviews@lists.linux.dev To: "Sarath Ganapathiraju" Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203-master-v16-2-f946e4c2686a@oss.qualcomm.com> References: <20261203-master-v16-0-f946e4c2686a@oss.qualcomm.com> <20261203-master-v16-2-f946e4c2686a@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:57:53 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] clk: qcom: AB-BA deadlock between prepare_lock and lpass-va-csr runtime PM - [Medium] clk: qcom: missing NULL check on match data in lpass_va_csr_probe() - [Medium] clk: qcom: unsynchronized hb_enabled race in lpass_va_csr_runtime_resume() - [Low] clk: qcom: unguarded regmap debugfs MMIO reads in lpass-va-csr -- commit 6181a29fe3667ab7db1605811f8d478d055d71b8 Author: Sarath Ganapathiraju clk: qcom: Add LPASS VA CSR heartbeat pulse clock This commit adds the Qualcomm LPASS VA CSR driver that models the heartbeat pulse rate generator as a common clock provider, using runtime PM and PM clocks to manage the vote clocks and restore register state across suspend and resume. > diff --git a/drivers/clk/qcom/lpass-va-csr.c b/drivers/clk/qcom/lpass-va-= csr.c > new file mode 100644 > index 0000000000000..7c6301311575f > --- /dev/null > +++ b/drivers/clk/qcom/lpass-va-csr.c > @@ -0,0 +1,209 @@ [ ... ] > +static const struct regmap_config lpass_rate_gen_regmap_config =3D { > + .name =3D "lpass_rate_gen", > + .reg_bits =3D 32, > + .val_bits =3D 32, > + .reg_stride =3D 4, > + .max_register =3D LPASS_RATE_GEN_MAX_REG, > +}; [Severity: Low] Can reading the regmap debugfs registers file trigger unclocked MMIO reads while the device is runtime-suspended? lpass_rate_gen_regmap_config leaves readable_reg and rd_table unset, and lpass_va_csr_runtime_suspend() calls pm_clk_suspend() without putting the regmap into cache-only mode. Reading /sys/kernel/debug/regmap/-lpass_rate_gen/registers calls regmap_read_debugfs() without resuming runtime PM, issuing raw MMIO readl() accesses across 0x0000..0xd010 with the LPASS vote clocks disabled, which can cause bus errors, SErrors, or hangs (and even when clocked, reads unrelated VA CSR offsets outside the three rate generator registers). Restricting readable registers with readable_reg or rd_table and toggling regcache_cache_only() in runtime suspend and resume would prevent this. [ ... ] > + ret =3D regmap_write(csr->hb.regmap, LPASS_RATE_GEN_COUNTER_0, > + data->counter_0); > + if (ret) > + goto err_pm_clk_suspend; > + > + ret =3D regmap_write(csr->hb.regmap, LPASS_RATE_GEN_DELAY, data->delay); > + if (ret) > + goto err_pm_clk_suspend; > + > + if (csr->hb_enabled) { > + ret =3D regmap_update_bits(csr->hb.regmap, LPASS_RATE_GEN_CTRL, > + LPASS_RG_CTRL_EN, LPASS_RG_CTRL_EN); > + if (ret) > + goto err_pm_clk_suspend; > + } [Severity: Medium] Can csr->hb_enabled and the rate generator register restore race with atomic clk_enable() or clk_disable() during system resume? DEFINE_RUNTIME_DEV_PM_OPS() hooks pm_runtime_force_resume() into regular .resume, which runs after device IRQs and secondary CPUs are already re-enabled. If a consumer kept the clock prepared across suspend, an atomic clk_disable() can interleave with lpass_va_csr_runtime_resume(): CPU0 CPU1 (or ) lpass_va_csr_runtime_resume() if (csr->hb_enabled) /* true */ clk_disable() lpass_va_csr_hb_disable() clk_disable_regmap() csr->hb_enabled =3D false regmap_update_bits(...CTRL_EN) <-- re-enables disabled clock This leaves LPASS_RG_CTRL_EN set in hardware while csr->hb_enabled is false and the clock framework considers it disabled. Similarly, a concurrent clk_enable() after pm_clk_resume() can set LPASS_RG_CTRL_EN before COUNTER_0 and DELAY are restored. Protecting csr->hb_enabled and the register updates in lpass_va_csr_hb_enable(), lpass_va_csr_hb_disable(), and the post-resume restore path with a spinlock using spin_lock_irqsave() would close this race. [ ... ] > + data =3D of_device_get_match_data(dev); [Severity: Medium] Should data be checked for NULL here? If the driver is bound via sysfs driver_override to a non-matching DT platform device that has an MMIO resource and a clocks property, of_device_get_match_data() returns NULL and lpass_va_csr_runtime_resume() dereferences data->counter_0 during pm_runtime_resume_and_get(), causing a NULL pointer dereference. [ ... ] > + ret =3D devm_pm_runtime_enable(dev); > + if (ret) > + return dev_err_probe(dev, ret, "failed to enable PM runtime\n"); > + > + ret =3D pm_runtime_resume_and_get(dev); > + if (ret) > + return ret; > + > + ret =3D devm_clk_register_regmap(dev, &csr->hb); > + if (ret) > + goto err_pm_runtime_put; > + > + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &csr->hb= .hw); > + if (ret) > + goto err_pm_runtime_put; > + > + pm_runtime_put_sync(dev); [Severity: High] Does enabling runtime PM before devm_clk_register_regmap() create an ABBA deadlock between the clock framework's global prepare_lock and this device's runtime PM transitions? Because runtime PM is enabled when devm_clk_register_regmap() runs, the clock core sets core->rpm_enabled =3D true and calls pm_runtime_resume_and_get() and pm_runtime_put_sync() while holding prepare_lock in clk_core_prepare() and clk_core_unprepare(). At the same time, the DT vote clocks attached via of_pm_clk_add_clks() (clk_vote_q6dsp_ops) implement only .prepare and .unprepare, so pm_clk_resume() and pm_clk_suspend() call clk_prepare_enable() and clk_disable_unprepare(), which acquire prepare_lock from inside the runtime PM callbacks. Any runtime PM transition started outside prepare_lock, such as pm_runtime_put_sync(dev) here after devm_of_clk_add_hw_provider() has published the clock, can deadlock against a concurrent clk_prepare(): CPU0 CPU1 ---- ---- rpm_suspend() [RPM_SUSPENDING] lock(&prepare_lock) pm_clk_suspend() clk_disable_unprepare() lock(&prepare_lock) rpm_resume() [waits on RPM_SUSPENDING] *** DEADLOCK *** CPU0: lpass_va_csr_probe() -> pm_runtime_put_sync() -> lpass_va_csr_runtime_suspend() -> pm_clk_suspend() -> clk_disable_unprepare() CPU1: clk_prepare() -> clk_core_prepare() -> clk_pm_runtime_get() -> rpm_resume() Once this hits, both threads hang permanently along with all clock prepare, unprepare, set_rate, and registration operations kernel-wide. Registering the clock with core->rpm_enabled =3D true also causes clk_summary, clk_dump, and clk_disable_unused to perform unnecessary synchronous ADSP GPR IPC wakeups and register writes on this device. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-master-v16= -0-f946e4c2686a@oss.qualcomm.com?part=3D2