* [PATCH v12 0/2] Add LPASS VA CSR HeartBeat pulse clock support
@ 2026-10-21 12:40 Sarath Ganapathiraju via B4 Relay
2026-10-21 12:40 ` [PATCH v12 1/2] dt-bindings: clock: qcom: Add LPASS VA CSR HeartBeat pulse clock Sarath Ganapathiraju via B4 Relay
2026-10-21 12:40 ` [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat " Sarath Ganapathiraju via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Sarath Ganapathiraju via B4 Relay @ 2026-10-21 12:40 UTC (permalink / raw)
To: andersson, abelvesa, sboyd, bmasney+clk, jbrunet+clk, robh,
krzk+dt, conor+dt, srinivas.kandagatla, sarath.ganapathiraju
Cc: linux-arm-msm, linux-clk, devicetree, linux-kernel,
prasad.kumpatla
The LPASS VA CSR block contains rate generator hardware that produces
a HeartBeat Pulse (also known as RateGen Pulse). This pulse
synchronizes the start of the DMAs and Codec Interfaces for the audio
usecases and can serve as a periodic wakeup source for the DSP.
This series adds the DT binding and driver support to model this
rate generator as a clock provider.
Patch 1 adds the YAML binding for the new qcom,hawi-lpass-va-csr
clock provider node under Documentation/devicetree/bindings/clock/.
Patch 2 adds the lpass-va-csr driver under drivers/clk/qcom that
registers the lpass_heartbeat_pulse clock and enables/disables the
rate generator via regmap when the clock consumer requests it.
Changes in v12:
- Rebase the series on linux-next next-20261020.
- Depend on PM_CLK so COMPILE_TEST builds cannot select the driver when
pm_clk_suspend() and pm_clk_resume() are unavailable (Sashiko, LKP).
- Link to v11: https://patch.msgid.link/20261012-master-v11-0-15009e3ecac3@oss.qualcomm.com
Changes in v11:
- Rebase the series on linux-next next-20261009.
- Drop the custom heartbeat prepare/unprepare callbacks and rely on CCF
provider runtime PM handling (Ajay).
- Restore the rate generator counter and delay registers from the
runtime resume callback after the LPASS vote clocks are enabled
(Sashiko).
- Add an of_device_get_match_data() NULL guard (Sashiko).
- Link to v10: https://patch.msgid.link/20260930-master-v10-0-105207bc5275@oss.qualcomm.com
Changes in v10:
- Rebase the series on linux-next next-20260929.
- Add clk_is_enabled_regmap() to report the heartbeat gate state for
clk_disable_unused() (Sashiko).
- Add Rob's Reviewed-by tag to the binding patch.
- Link to v9: https://patch.msgid.link/20260928-master-v9-0-2277f09f9a09@oss.qualcomm.com
Changes in v9:
- Rebase the series on linux-next next-20260928.
- Add runtime PM callbacks so the LPASS LPR and audio vote clocks are
enabled by pm_runtime_resume_and_get() before touching VA CSR
registers.
- Keep the LPASS vote clocks enabled across heartbeat clock
enable/disable register accesses by taking a runtime PM reference from
the heartbeat clock prepare path.
- Use synchronous runtime PM put on probe success and error paths.
- Drop the one-use runtime PM error label while keeping synchronous puts (Konrad).
- Wrap the runtime PM ops with pm_ptr() from HTML review.
- Link to v8: https://patch.msgid.link/20260917-master-v8-0-823d2c5d090a@oss.qualcomm.com
Changes in v8:
- Rebase the series on linux-next next-20260916.
- Require the LPASS LPR and audio vote clocks to access VA CSR
register space safely.
- Attach the DT vote clocks to runtime PM and resume the device before
programming the rate generator registers.
- Program the counter and delay registers once during probe.
- Use qcom's simple regmap gate ops for the enable bit (Srinivas).
- Drop the unreachable of_device_get_match_data() NULL check (Srinivas).
- Drop stale Reviewed-by/Tested-by tags after the binding and driver
changes.
- Link to v7: https://patch.msgid.link/20260831-heartbeat-v7-next-20260828-v7-0-e3ffeac46a51@oss.qualcomm.com
Changes in v7:
- Rebase the series on linux-next next-20260828.
- Add Prasad's Reviewed-by and Tested-by tags to patch 2.
- Link to v6: https://patch.msgid.link/20260821-heartbeat-v6-next-20260821-send-v6-0-62c5df84ce21@oss.qualcomm.com
Changes in v6:
- Rebase the series on linux-next next-20260821.
- Capitalize Hawi in binding text (Bjorn).
- Simplify the binding example by removing the soc wrapper and
two-cell address/size setup (Bjorn).
- Keep the full VA CSR register window in the binding and describe it
as the VA CSR register block after Konrad clarified the earlier
register-range concern (Bjorn, Konrad).
- Link to v5: https://patch.msgid.link/20260806-master-20260805-sync-v5-0-0ff42e9b6431@oss.qualcomm.com
Changes in v5:
- Add explicit ARM64 Kconfig gating and Qualcomm default-module policy
for QCOM_CLK_LPASS_HEARTBEAT_PULSE to align with nearby qcom clock
entries.
- Link to v4: https://patch.msgid.link/20260805-master-20260805-sync-v4-0-dfbcbf427c2c@oss.qualcomm.com
Changes in v4:
- Rename the binding filename and schema ID to hawi-specific naming:
qcom,lpass-va-csr.yaml -> qcom,hawi-lpass-va-csr.yaml (Krzysztof).
- Rename Kconfig symbol QCOM_CLK_LPASS_VA_CSR to
QCOM_CLK_LPASS_HEARTBEAT_PULSE (Konrad).
- Add devm_pm_runtime_enable() in the lpass-va-csr probe path.
- Drop the qcom,lpass-va-macro binding extension patch; it will be
resubmitted with the Hawi DTSI changes.
- Drop sound/soc/codecs/Kconfig select wiring to keep this series
clock-only (Konrad).
- Link to v3: https://lore.kernel.org/all/20260723-master-v3-0-3d67b79b0515@oss.qualcomm.com/
Changes in v3:
- Move the qcom,lpass-va-csr binding under
Documentation/devicetree/bindings/clock/ (Krzysztof).
- Move the driver under drivers/clk/qcom/ (Krzysztof).
- Improve the schema description and use generic clock-controller node
naming (Krzysztof).
- Use additionalProperties: false and keep compatibles sorted.
Changes in v2:
- Split the qcom,lpass-va-csr and qcom,lpass-va-macro bindings into
separate patches.
Changes in v1:
- Initial version
Signed-off-by: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com>
---
Sarath Ganapathiraju (2):
dt-bindings: clock: qcom: Add LPASS VA CSR HeartBeat pulse clock
clk: qcom: Add LPASS VA CSR heartbeat pulse clock
.../bindings/clock/qcom,hawi-lpass-va-csr.yaml | 62 +++++++
drivers/clk/qcom/Kconfig | 15 ++
drivers/clk/qcom/Makefile | 1 +
drivers/clk/qcom/lpass-va-csr.c | 180 +++++++++++++++++++++
4 files changed, 258 insertions(+)
---
base-commit: 8f7df005a7564bd7ffa75da9c3085d5b996f1e16
change-id: 20260917-master-6c2778f57a9a
Best regards,
--
Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v12 1/2] dt-bindings: clock: qcom: Add LPASS VA CSR HeartBeat pulse clock 2026-10-21 12:40 [PATCH v12 0/2] Add LPASS VA CSR HeartBeat pulse clock support Sarath Ganapathiraju via B4 Relay @ 2026-10-21 12:40 ` Sarath Ganapathiraju via B4 Relay 2026-10-21 12:40 ` [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat " Sarath Ganapathiraju via B4 Relay 1 sibling, 0 replies; 4+ messages in thread From: Sarath Ganapathiraju via B4 Relay @ 2026-10-21 12:40 UTC (permalink / raw) To: andersson, abelvesa, sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt, srinivas.kandagatla, sarath.ganapathiraju Cc: linux-arm-msm, linux-clk, devicetree, linux-kernel, prasad.kumpatla From: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> Add a binding for the Qualcomm LPASS VA CSR rate generator node that exposes the lpass_heartbeat_pulse clock on Hawi. The HeartBeat Pulse, also known as RateGen Pulse, synchronizes the start of DMAs and Codec Interfaces for the audio usecase and can serve as a periodic wakeup source for the DSP. Require the LPASS LPR and audio vote clocks to access VA CSR register space safely. Reviewed-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> --- .../bindings/clock/qcom,hawi-lpass-va-csr.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/qcom,hawi-lpass-va-csr.yaml b/Documentation/devicetree/bindings/clock/qcom,hawi-lpass-va-csr.yaml new file mode 100644 index 000000000000..601da83add2b --- /dev/null +++ b/Documentation/devicetree/bindings/clock/qcom,hawi-lpass-va-csr.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/qcom,hawi-lpass-va-csr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm LPASS VA CSR heartbeat pulse clock provider + +maintainers: + - Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> + - Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> + +description: + The Hawi LPASS (Low Power Audio Subsystem) VA CSR block contains a + rate generator that produces a periodic HeartBeat Pulse, also known + as the RateGen Pulse. This pulse synchronizes the start of DMAs and + Codec Interfaces for audio usecases and can serve as a periodic wakeup + source for the DSP. + +properties: + compatible: + enum: + - qcom,hawi-lpass-va-csr + + reg: + maxItems: 1 + description: Address and size of the VA CSR register block. + + clocks: + items: + - description: LPASS LPR (Low Power Resource) voting clock + - description: LPASS Audio voting clock + + clock-names: + items: + - const: lpr + - const: audio + + "#clock-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - "#clock-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h> + + clock-controller@7ee0000 { + compatible = "qcom,hawi-lpass-va-csr"; + reg = <0x07ee0000 0xe000>; + clocks = <&q6prmcc LPASS_HW_LPR_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>, + <&q6prmcc LPASS_HW_DCODEC_VOTE LPASS_CLK_ATTRIBUTE_COUPLE_NO>; + clock-names = "lpr", "audio"; + #clock-cells = <0>; + }; -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat pulse clock 2026-10-21 12:40 [PATCH v12 0/2] Add LPASS VA CSR HeartBeat pulse clock support Sarath Ganapathiraju via B4 Relay 2026-10-21 12:40 ` [PATCH v12 1/2] dt-bindings: clock: qcom: Add LPASS VA CSR HeartBeat pulse clock Sarath Ganapathiraju via B4 Relay @ 2026-10-21 12:40 ` Sarath Ganapathiraju via B4 Relay 2026-10-21 13:04 ` sashiko-bot 1 sibling, 1 reply; 4+ messages in thread From: Sarath Ganapathiraju via B4 Relay @ 2026-10-21 12:40 UTC (permalink / raw) To: andersson, abelvesa, sboyd, bmasney+clk, jbrunet+clk, robh, krzk+dt, conor+dt, srinivas.kandagatla, sarath.ganapathiraju Cc: linux-arm-msm, linux-clk, devicetree, linux-kernel, prasad.kumpatla From: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> The HeartBeat Pulse, also known as RateGen Pulse, synchronizes the start of DMAs and Codec Interfaces for the audio usecases and can serve as a periodic wakeup source for the DSP. Add the LPASS VA CSR driver that models the rate generator as a clock provider so consumers can enable and disable it through the common clock framework. Attach the DT vote clocks to runtime PM and program the rate generator counter and delay registers from runtime resume after the votes are enabled. This restores the state if the LPASS register context is lost across runtime suspend. Rely on the clock core provider runtime PM handling around clock prepare and unprepare to keep the votes active for regmap gate accesses. Signed-off-by: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> --- drivers/clk/qcom/Kconfig | 15 ++++ drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/lpass-va-csr.c | 180 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+) diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig index 27d0ab24d50a..718a847fa8a0 100644 --- a/drivers/clk/qcom/Kconfig +++ b/drivers/clk/qcom/Kconfig @@ -2137,6 +2137,21 @@ config CLK_GFM_LPASS_SM8250 Support for the Glitch Free Mux (GFM) Low power audio subsystem (LPASS) clocks found on SM8250 SoCs. +config QCOM_CLK_LPASS_HEARTBEAT_PULSE + tristate "Qualcomm LPASS VA CSR heartbeat pulse clock provider" + depends on COMMON_CLK + depends on ARM64 || COMPILE_TEST + depends on PM_CLK + select REGMAP_MMIO + default m if ARCH_QCOM + help + Qualcomm LPASS VA CSR block contains the rate generator hardware + that produces the HeartBeat Pulse (also known as RateGen Pulse). + This driver models the rate generator as a clock provider so + that consumers can enable or disable it via the common clock + framework, and it can be used to synchronize the start of DMAs + and Codec Interfaces or as a periodic wakeup source for the DSP. + config SM_VIDEOCC_8450 tristate "SM8450 Video Clock Controller" depends on ARM64 || COMPILE_TEST diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile index 6affb5073f26..787a3761af3b 100644 --- a/drivers/clk/qcom/Makefile +++ b/drivers/clk/qcom/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_CLK_ELIZA_GPUCC) += gpucc-eliza.o obj-$(CONFIG_CLK_ELIZA_TCSRCC) += tcsrcc-eliza.o obj-$(CONFIG_CLK_ELIZA_VIDEOCC) += videocc-eliza.o obj-$(CONFIG_CLK_GFM_LPASS_SM8250) += lpass-gfm-sm8250.o +obj-$(CONFIG_QCOM_CLK_LPASS_HEARTBEAT_PULSE) += lpass-va-csr.o obj-$(CONFIG_CLK_GLYMUR_CAMCC) += camcc-glymur.o obj-$(CONFIG_CLK_GLYMUR_DISPCC) += dispcc-glymur.o obj-$(CONFIG_CLK_GLYMUR_EVACC) += evacc-glymur.o diff --git a/drivers/clk/qcom/lpass-va-csr.c b/drivers/clk/qcom/lpass-va-csr.c new file mode 100644 index 000000000000..e5fb870aa36d --- /dev/null +++ b/drivers/clk/qcom/lpass-va-csr.c @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include <linux/clk-provider.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/of_clk.h> +#include <linux/pm_clock.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> + +#include "clk-regmap.h" + +#define LPASS_RATE_GEN_CTRL 0xd000 +#define LPASS_RATE_GEN_COUNTER_0 0xd004 +#define LPASS_RATE_GEN_DELAY 0xd010 + +#define LPASS_RATE_GEN_MAX_REG LPASS_RATE_GEN_DELAY + +#define LPASS_RG_CTRL_EN BIT(0) + +struct lpass_va_csr_data { + u32 counter_0; + u32 delay; +}; + +static const struct lpass_va_csr_data hawi_csr_data = { + .counter_0 = 0x960, + .delay = 0x16, +}; + +static const struct regmap_config lpass_rate_gen_regmap_config = { + .name = "lpass_rate_gen", + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .max_register = LPASS_RATE_GEN_MAX_REG, + .cache_type = REGCACHE_MAPLE, +}; + +struct lpass_va_csr { + const struct lpass_va_csr_data *data; + struct clk_regmap hb; +}; + +static const struct clk_ops lpass_va_csr_hb_ops = { + .enable = clk_enable_regmap, + .disable = clk_disable_regmap, + .is_enabled = clk_is_enabled_regmap, +}; + +static int lpass_va_csr_runtime_resume(struct device *dev) +{ + struct lpass_va_csr *csr = dev_get_drvdata(dev); + const struct lpass_va_csr_data *data = csr->data; + int ret; + + ret = pm_clk_resume(dev); + if (ret) + return ret; + + ret = regmap_write(csr->hb.regmap, LPASS_RATE_GEN_COUNTER_0, + data->counter_0); + if (ret) + goto err_pm_clk_suspend; + + ret = regmap_write(csr->hb.regmap, LPASS_RATE_GEN_DELAY, data->delay); + if (ret) + goto err_pm_clk_suspend; + + return 0; + +err_pm_clk_suspend: + pm_clk_suspend(dev); + return ret; +} + +static int lpass_va_csr_runtime_suspend(struct device *dev) +{ + return pm_clk_suspend(dev); +} + +static int lpass_va_csr_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + const struct lpass_va_csr_data *data = of_device_get_match_data(dev); + struct lpass_va_csr *csr; + struct clk_init_data init = { + .name = "lpass_heartbeat_pulse", + .ops = &lpass_va_csr_hb_ops, + }; + struct regmap *regmap; + void __iomem *base; + int ret; + + csr = devm_kzalloc(dev, sizeof(*csr), GFP_KERNEL); + if (!csr) + return -ENOMEM; + + if (!data) + return dev_err_probe(dev, -EINVAL, "missing match data\n"); + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + regmap = devm_regmap_init_mmio(dev, base, + &lpass_rate_gen_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "failed to init regmap\n"); + + csr->data = data; + csr->hb.regmap = regmap; + csr->hb.enable_reg = LPASS_RATE_GEN_CTRL; + csr->hb.enable_mask = LPASS_RG_CTRL_EN; + csr->hb.hw.init = &init; + + platform_set_drvdata(pdev, csr); + + ret = devm_pm_runtime_enable(dev); + if (ret) + return dev_err_probe(dev, ret, "failed to enable PM runtime\n"); + + ret = devm_pm_clk_create(dev); + if (ret) + return ret; + + ret = of_pm_clk_add_clks(dev); + if (ret < 0) + return dev_err_probe(dev, ret, "failed to get vote clocks\n"); + + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + + ret = devm_clk_register_regmap(dev, &csr->hb); + if (ret) { + pm_runtime_put_sync(dev); + return ret; + } + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &csr->hb.hw); + if (ret) { + pm_runtime_put_sync(dev); + return ret; + } + + pm_runtime_put_sync(dev); + + return 0; +} + +static const struct of_device_id lpass_va_csr_dt_match[] = { + { .compatible = "qcom,hawi-lpass-va-csr", .data = &hawi_csr_data }, + {} +}; +MODULE_DEVICE_TABLE(of, lpass_va_csr_dt_match); + +static const struct dev_pm_ops lpass_va_csr_pm_ops = { + SET_RUNTIME_PM_OPS(lpass_va_csr_runtime_suspend, + lpass_va_csr_runtime_resume, NULL) +}; + +static struct platform_driver lpass_va_csr_driver = { + .driver = { + .name = "qcom-lpass-va-csr", + .of_match_table = lpass_va_csr_dt_match, + .pm = pm_ptr(&lpass_va_csr_pm_ops), + }, + .probe = lpass_va_csr_probe, +}; + +module_platform_driver(lpass_va_csr_driver); + +MODULE_DESCRIPTION("Qualcomm LPASS VA CSR heartbeat pulse clock provider"); +MODULE_LICENSE("GPL"); -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat pulse clock 2026-10-21 12:40 ` [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat " Sarath Ganapathiraju via B4 Relay @ 2026-10-21 13:04 ` sashiko-bot 0 siblings, 0 replies; 4+ messages in thread From: sashiko-bot @ 2026-10-21 13:04 UTC (permalink / raw) To: Sarath Ganapathiraju; +Cc: linux-clk, devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] clk: qcom: enable runtime PM after PM clocks in lpass_va_csr_probe() - [Medium] clk: qcom: lpass-va-csr: stale REGCACHE_MAPLE state across runtime suspend -- commit 5fda051342340a0aea8fc87d53199c8e2fe790df Author: Sarath Ganapathiraju <sarath.ganapathiraju@oss.qualcomm.com> clk: qcom: Add LPASS VA CSR heartbeat pulse clock This commit adds the Qualcomm LPASS VA CSR clock driver, modeling the hardware rate generator as a clock provider that manages LPASS vote clocks and restores counter and delay registers via runtime PM. > diff --git a/drivers/clk/qcom/lpass-va-csr.c b/drivers/clk/qcom/lpass-va-csr.c > new file mode 100644 > index 0000000000000..e5fb870aa36de > --- /dev/null > +++ b/drivers/clk/qcom/lpass-va-csr.c > @@ -0,0 +1,180 @@ [ ... ] > +#define LPASS_RATE_GEN_CTRL 0xd000 > +#define LPASS_RATE_GEN_COUNTER_0 0xd004 > +#define LPASS_RATE_GEN_DELAY 0xd010 > + > +#define LPASS_RATE_GEN_MAX_REG LPASS_RATE_GEN_DELAY > + > +#define LPASS_RG_CTRL_EN BIT(0) [ ... ] > +static const struct regmap_config lpass_rate_gen_regmap_config = { > + .name = "lpass_rate_gen", > + .reg_bits = 32, > + .val_bits = 32, > + .reg_stride = 4, > + .max_register = LPASS_RATE_GEN_MAX_REG, > + .cache_type = REGCACHE_MAPLE, > +}; > + > +struct lpass_va_csr { > + const struct lpass_va_csr_data *data; > + struct clk_regmap hb; > +}; > + > +static const struct clk_ops lpass_va_csr_hb_ops = { > + .enable = clk_enable_regmap, > + .disable = clk_disable_regmap, > + .is_enabled = clk_is_enabled_regmap, > +}; > + > +static int lpass_va_csr_runtime_resume(struct device *dev) > +{ > + struct lpass_va_csr *csr = dev_get_drvdata(dev); > + const struct lpass_va_csr_data *data = csr->data; > + int ret; > + > + ret = pm_clk_resume(dev); > + if (ret) > + return ret; > + > + ret = regmap_write(csr->hb.regmap, LPASS_RATE_GEN_COUNTER_0, > + data->counter_0); > + if (ret) > + goto err_pm_clk_suspend; > + > + ret = regmap_write(csr->hb.regmap, LPASS_RATE_GEN_DELAY, data->delay); > + if (ret) > + goto err_pm_clk_suspend; > + > + return 0; > + > +err_pm_clk_suspend: > + pm_clk_suspend(dev); > + return ret; > +} > + > +static int lpass_va_csr_runtime_suspend(struct device *dev) > +{ > + return pm_clk_suspend(dev); > +} [Severity: Medium] Can setting .cache_type = REGCACHE_MAPLE in lpass_rate_gen_regmap_config cause clk_enable_regmap() and clk_is_enabled_regmap() to use stale cached state for LPASS_RATE_GEN_CTRL after LPASS register context is lost across runtime suspend? Neither lpass_va_csr_runtime_suspend() nor lpass_va_csr_runtime_resume() marks the regcache dirty or drops cached registers, and lpass_va_csr_runtime_resume() only rewrites LPASS_RATE_GEN_COUNTER_0 and LPASS_RATE_GEN_DELAY. If LPASS_RATE_GEN_CTRL has LPASS_RG_CTRL_EN set in hardware when first read (for example, when loaded as a module or booted with clk_ignore_unused and inspected via debugfs clk_summary -> clk_core_is_enabled() -> clk_is_enabled_regmap() -> regmap_read()), _regmap_read() caches that enabled bit in the maple cache. If the device then runtime-suspends and loses LPASS register context, hardware resets LPASS_RATE_GEN_CTRL to 0 while the cache retains the set bit. On a subsequent clk_prepare_enable(), clk_enable_regmap() in drivers/clk/qcom/clk-regmap.c calls regmap_update_bits(): drivers/clk/qcom/clk-regmap.c:clk_enable_regmap() { ... return regmap_update_bits(rclk->regmap, rclk->enable_reg, rclk->enable_mask, val); } Because _regmap_update_bits() sees the cached value already has enable_mask set, it skips the hardware write and leaves the clock disabled in hardware. Should .cache_type be omitted from lpass_rate_gen_regmap_config (or LPASS_RATE_GEN_CTRL marked volatile / the cache invalidated across runtime suspend)? > + > +static int lpass_va_csr_probe(struct platform_device *pdev) > +{ [ ... ] > + platform_set_drvdata(pdev, csr); > + > + ret = devm_pm_runtime_enable(dev); > + if (ret) > + return dev_err_probe(dev, ret, "failed to enable PM runtime\n"); > + > + ret = devm_pm_clk_create(dev); > + if (ret) > + return ret; > + > + ret = of_pm_clk_add_clks(dev); > + if (ret < 0) > + return dev_err_probe(dev, ret, "failed to get vote clocks\n"); [Severity: High] What happens if runtime PM is enabled before the PM vote clocks are created and added in lpass_va_csr_probe()? In drivers/base/power/clock_ops.c, pm_clk_resume() returns 0 immediately when dev_to_psd(dev) is NULL or the clock list is empty: drivers/base/power/clock_ops.c:pm_clk_resume() { struct pm_subsys_data *psd = dev_to_psd(dev); ... if (!psd) return 0; Because devm_pm_runtime_enable(dev) is called before devm_pm_clk_create(dev) and of_pm_clk_add_clks(dev), a runtime resume triggered in that window (such as via sysfs power/control) runs lpass_va_csr_runtime_resume(), receives 0 from pm_clk_resume(dev), and calls regmap_write() on LPASS_RATE_GEN_COUNTER_0 and LPASS_RATE_GEN_DELAY without the vote clocks enabled. In addition, because devres callbacks execute in reverse registration order on driver unbind or probe error, pm_clk_destroy() (registered by devm_pm_clk_create()) runs before pm_runtime_disable_action() (registered by devm_pm_runtime_enable()): drivers/base/power/clock_ops.c:pm_clk_destroy() { ... dev_pm_put_subsys_data(dev); list_for_each_entry_safe_reverse(ce, c, &list, node) { list_del(&ce->node); __pm_clk_remove(ce); } } This disables and removes the vote clocks and clears dev->power.subsys_data while runtime PM is still enabled on the device. Should devm_pm_clk_create(dev) and of_pm_clk_add_clks(dev) be called before devm_pm_runtime_enable(dev) in lpass_va_csr_probe()? [ ... ] > +} > + [ ... ] >+MODULE_DESCRIPTION("Qualcomm LPASS VA CSR heartbeat pulse clock provider"); >+MODULE_LICENSE("GPL"); -- Sashiko AI review · https://sashiko.dev/#/patchset/20261021-master-v12-0-9b3df51fd1d7@oss.qualcomm.com?part=2 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-21 13:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-21 12:40 [PATCH v12 0/2] Add LPASS VA CSR HeartBeat pulse clock support Sarath Ganapathiraju via B4 Relay 2026-10-21 12:40 ` [PATCH v12 1/2] dt-bindings: clock: qcom: Add LPASS VA CSR HeartBeat pulse clock Sarath Ganapathiraju via B4 Relay 2026-10-21 12:40 ` [PATCH v12 2/2] clk: qcom: Add LPASS VA CSR heartbeat " Sarath Ganapathiraju via B4 Relay 2026-10-21 13:04 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox