* [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC
@ 2026-05-22 15:16 Imran Shaik
2026-05-22 15:16 ` [PATCH v4 1/2] dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS Imran Shaik
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Imran Shaik @ 2026-05-22 15:16 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Manivannan Sadhasivam
Cc: Ajit Pandey, Taniya Das, Jagadeesh Kona, linux-pm, devicetree,
linux-kernel, linux-arm-msm, Imran Shaik, Krzysztof Kozlowski,
Konrad Dybcio
This series adds cpufreq scaling support on Qualcomm Shikra SoC.
Signed-off-by: Imran Shaik <imran.shaik@oss.qualcomm.com>
---
Changes in v4:
- Drop CPUFREQ and use EPSS in bindings [Krzysztof]
- Update bindings patch commit subject with correct subsystem prefix [Krzysztof]
- Link to v3: https://lore.kernel.org/r/20260521-shikra-cpufreq-scaling-v3-0-883c13d1e514@oss.qualcomm.com
Changes in v3:
- Updated bindings as per the review comments [Krzysztof]
- Updated driver patch commit text [Dmitry]
- Updated compatible in driver patch as per the bindings
- Link to v2: https://lore.kernel.org/r/20260519-shikra-cpufreq-scaling-v2-0-2b09f0e1c9d8@oss.qualcomm.com
Changes in v2:
- Dropped the generic compatible approach, and introduced Shikra
specific bindings [Krzysztof]
- Updated the driver patch as per the latest bindings changes
- Added R-By tag received in V1.
- Link to v1: https://lore.kernel.org/r/20260501-shikra-cpufreq-scaling-v1-0-c78b95f53b91@oss.qualcomm.com
---
Imran Shaik (1):
dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS
Taniya Das (1):
cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC
.../bindings/cpufreq/qcom,shikra-epss.yaml | 96 ++++++++++++++++++++++
drivers/cpufreq/qcom-cpufreq-hw.c | 23 +++++-
2 files changed, 116 insertions(+), 3 deletions(-)
---
base-commit: 0787c45ea08a13b5482e701fabc741877cf681f6
change-id: 20260430-shikra-cpufreq-scaling-aff690130063
Best regards,
--
Imran Shaik <imran.shaik@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v4 1/2] dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS 2026-05-22 15:16 [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik @ 2026-05-22 15:16 ` Imran Shaik 2026-05-22 15:16 ` [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik 2026-06-08 5:37 ` [PATCH v4 0/2] " Viresh Kumar 2 siblings, 0 replies; 5+ messages in thread From: Imran Shaik @ 2026-05-22 15:16 UTC (permalink / raw) To: Rafael J. Wysocki, Viresh Kumar, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Manivannan Sadhasivam Cc: Ajit Pandey, Taniya Das, Jagadeesh Kona, linux-pm, devicetree, linux-kernel, linux-arm-msm, Imran Shaik, Krzysztof Kozlowski The Qualcomm Shikra cpufreq hardware is functionally identical to EPSS, but supports only up to 12 frequency lookup table (LUT) entries. Introduce Shikra specific bindings to represent this constrained EPSS variant. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Signed-off-by: Imran Shaik <imran.shaik@oss.qualcomm.com> --- .../bindings/cpufreq/qcom,shikra-epss.yaml | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/Documentation/devicetree/bindings/cpufreq/qcom,shikra-epss.yaml b/Documentation/devicetree/bindings/cpufreq/qcom,shikra-epss.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1a3105e86980a14069f8fb40c92d1f9cc71c6c1c --- /dev/null +++ b/Documentation/devicetree/bindings/cpufreq/qcom,shikra-epss.yaml @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cpufreq/qcom,shikra-epss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Shikra SoC EPSS + +maintainers: + - Imran Shaik <imran.shaik@oss.qualcomm.com> + - Taniya Das <taniya.das@oss.qualcomm.com> + +description: | + EPSS is a hardware engine used by some Qualcomm SoCs to manage + frequency in hardware. It is capable of controlling frequency for + multiple clusters. + + The Qualcomm Shikra SoC EPSS supports up to 12 frequency lookup table + (LUT) entries. + +properties: + compatible: + enum: + - qcom,shikra-epss + + reg: + items: + - description: Frequency domain 0 register region + - description: Frequency domain 1 register region + + reg-names: + items: + - const: freq-domain0 + - const: freq-domain1 + + clocks: + items: + - description: XO Clock + - description: GPLL0 Clock + + clock-names: + items: + - const: xo + - const: alternate + + interrupts: + items: + - description: IRQ line for DCVSH 0 + - description: IRQ line for DCVSH 1 + + interrupt-names: + items: + - const: dcvsh-irq-0 + - const: dcvsh-irq-1 + + '#freq-domain-cells': + const: 1 + + '#clock-cells': + const: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - '#freq-domain-cells' + - '#clock-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,rpmcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + soc { + #address-cells = <1>; + #size-cells = <1>; + + cpufreq@fd91000 { + compatible = "qcom,shikra-epss"; + reg = <0x0fd91000 0x1000>, <0x0fd92000 0x1000>; + reg-names = "freq-domain0", "freq-domain1"; + clocks = <&rpmcc RPM_SMD_XO_CLK_SRC>, <&gpll0>; + clock-names = "xo", "alternate"; + interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "dcvsh-irq-0", "dcvsh-irq-1"; + #freq-domain-cells = <1>; + #clock-cells = <1>; + }; + }; +... -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC 2026-05-22 15:16 [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik 2026-05-22 15:16 ` [PATCH v4 1/2] dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS Imran Shaik @ 2026-05-22 15:16 ` Imran Shaik 2026-05-22 16:06 ` sashiko-bot 2026-06-08 5:37 ` [PATCH v4 0/2] " Viresh Kumar 2 siblings, 1 reply; 5+ messages in thread From: Imran Shaik @ 2026-05-22 15:16 UTC (permalink / raw) To: Rafael J. Wysocki, Viresh Kumar, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Manivannan Sadhasivam Cc: Ajit Pandey, Taniya Das, Jagadeesh Kona, linux-pm, devicetree, linux-kernel, linux-arm-msm, Imran Shaik, Konrad Dybcio From: Taniya Das <taniya.das@oss.qualcomm.com> The Qualcomm Shikra cpufreq hardware is functionally identical to EPSS, but supports only up to 12 frequency lookup table (LUT) entries. When all 12 entries are populated, the existing repetitive LUT entry check may read beyond valid entries and expose incorrect frequencies. Hence, introduce shikra_epss_soc_data that reuses EPSS configuration with appropriate LUT entries limit. Signed-off-by: Taniya Das <taniya.das@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Imran Shaik <imran.shaik@oss.qualcomm.com> --- drivers/cpufreq/qcom-cpufreq-hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index ea9a20d27b8fdceb9341ee53e5fa27b7a6d92483..3d5a865fb8a35e112cb4d040fb519e2c122a91dc 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. */ #include <linux/bitfield.h> @@ -40,6 +41,7 @@ struct qcom_cpufreq_soc_data { u32 reg_intr_clr; u32 reg_current_vote; u32 reg_perf_state; + u32 lut_max_entries; u8 lut_row_size; }; @@ -156,7 +158,7 @@ static unsigned int qcom_cpufreq_get_freq(struct cpufreq_policy *policy) soc_data = qcom_cpufreq.soc_data; index = readl_relaxed(data->base + soc_data->reg_perf_state); - index = min(index, LUT_MAX_ENTRIES - 1); + index = min(index, soc_data->lut_max_entries - 1); return policy->freq_table[index].frequency; } @@ -211,7 +213,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, struct qcom_cpufreq_data *drv_data = policy->driver_data; const struct qcom_cpufreq_soc_data *soc_data = qcom_cpufreq.soc_data; - table = kzalloc_objs(*table, LUT_MAX_ENTRIES + 1); + table = kzalloc_objs(*table, soc_data->lut_max_entries + 1); if (!table) return -ENOMEM; @@ -236,7 +238,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, icc_scaling_enabled = false; } - for (i = 0; i < LUT_MAX_ENTRIES; i++) { + for (i = 0; i < soc_data->lut_max_entries; i++) { data = readl_relaxed(drv_data->base + soc_data->reg_freq_lut + i * soc_data->lut_row_size); src = FIELD_GET(LUT_SRC, data); @@ -405,6 +407,7 @@ static const struct qcom_cpufreq_soc_data qcom_soc_data = { .reg_current_vote = 0x704, .reg_perf_state = 0x920, .lut_row_size = 32, + .lut_max_entries = LUT_MAX_ENTRIES, }; static const struct qcom_cpufreq_soc_data epss_soc_data = { @@ -416,11 +419,25 @@ static const struct qcom_cpufreq_soc_data epss_soc_data = { .reg_intr_clr = 0x308, .reg_perf_state = 0x320, .lut_row_size = 4, + .lut_max_entries = LUT_MAX_ENTRIES, +}; + +static const struct qcom_cpufreq_soc_data shikra_epss_soc_data = { + .reg_enable = 0x0, + .reg_domain_state = 0x20, + .reg_dcvs_ctrl = 0xb0, + .reg_freq_lut = 0x100, + .reg_volt_lut = 0x200, + .reg_intr_clr = 0x308, + .reg_perf_state = 0x320, + .lut_row_size = 4, + .lut_max_entries = 12, }; static const struct of_device_id qcom_cpufreq_hw_match[] = { { .compatible = "qcom,cpufreq-hw", .data = &qcom_soc_data }, { .compatible = "qcom,cpufreq-epss", .data = &epss_soc_data }, + { .compatible = "qcom,shikra-epss", .data = &shikra_epss_soc_data }, {} }; MODULE_DEVICE_TABLE(of, qcom_cpufreq_hw_match); -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC 2026-05-22 15:16 ` [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik @ 2026-05-22 16:06 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-05-22 16:06 UTC (permalink / raw) To: Imran Shaik; +Cc: robh, conor+dt, devicetree Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: Pre-existing issues: - [Critical] Calling kfree() on an interior pointer of a devm-managed array causes severe memory corruption. - [High] The turbo/boost frequency is improperly ignored and left invalid when the hardware LUT is fully populated. - [High] The LMh throttle delayed work can outlive the `qcom_cpufreq_data` structure, causing a Use-After-Free when the policy is destroyed. -- commit 04a4ff128bbeeee8119bf80c19ea931913c35395 Author: Taniya Das <taniya.das@oss.qualcomm.com> cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC This commit adds cpufreq scaling support for the Qualcomm Shikra SoC. It introduces the shikra_epss_soc_data structure which reuses the EPSS configuration but limits the maximum lookup table entries to 12. > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index ea9a20d27b8fd..3d5a865fb8a35 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c [ ... ] > @@ -236,7 +238,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, > icc_scaling_enabled = false; > } > > - for (i = 0; i < LUT_MAX_ENTRIES; i++) { > + for (i = 0; i < soc_data->lut_max_entries; i++) { > data = readl_relaxed(drv_data->base + soc_data->reg_freq_lut + > i * soc_data->lut_row_size); > src = FIELD_GET(LUT_SRC, data); [Severity: High] This is a pre-existing issue, but does this loop handle a fully populated LUT where the last entry is a turbo frequency? When a frequency has a core_count of LUT_TURBO_IND, it is initially marked as CPUFREQ_ENTRY_INVALID. The code relies on encountering a duplicate frequency on the next iteration to convert that invalid entry into CPUFREQ_BOOST_FREQ. If the hardware LUT is completely filled with unique entries up to its capacity limit, the loop terminates naturally. Does this leave the final turbo entry ignored and invalid since the duplicate check is never reached? [ ... ] [Severity: Critical] This is a pre-existing issue, but could the teardown path free a devm-managed interior pointer? During policy initialization, the driver assigns policy->driver_data to point to an interior element within a collectively allocated devm-managed array: qcom_cpufreq_hw_cpu_init() policy->driver_data = &qcom_cpufreq.data[index]; During teardown, the driver appears to manually free this pointer: qcom_cpufreq_hw_cpu_exit() kfree(data); Can this manual kfree() on an interior pointer bypass devres management and cause memory issues during device unbind or CPU hotplug? [Severity: High] This is a pre-existing issue, but is there a race between the LMh throttle delayed work and the CPU offline sequence? In qcom_cpufreq_hw_cpu_offline(), the driver cancels the work before disabling the interrupt: qcom_cpufreq_hw_cpu_offline() cancel_delayed_work_sync(&data->throttle_work); disable_irq_nosync(); If the hardware interrupt fires during this window, the interrupt handler qcom_lmh_dcvs_handle_irq() unconditionally re-arms the delayed work. Later, when qcom_cpufreq_hw_cpu_exit() frees the data structure, the re-armed work could still execute and attempt to access the freed memory: qcom_lmh_dcvs_poll() mutex_lock(&data->throttle_lock); Could the driver disable the IRQ before canceling the work to ensure the work is not re-armed? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260522-shikra-cpufreq-scaling-v4-0-f042a25896c5@oss.qualcomm.com?part=2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC 2026-05-22 15:16 [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik 2026-05-22 15:16 ` [PATCH v4 1/2] dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS Imran Shaik 2026-05-22 15:16 ` [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik @ 2026-06-08 5:37 ` Viresh Kumar 2 siblings, 0 replies; 5+ messages in thread From: Viresh Kumar @ 2026-06-08 5:37 UTC (permalink / raw) To: Imran Shaik Cc: Rafael J. Wysocki, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Manivannan Sadhasivam, Ajit Pandey, Taniya Das, Jagadeesh Kona, linux-pm, devicetree, linux-kernel, linux-arm-msm, Krzysztof Kozlowski, Konrad Dybcio On 22-05-26, 20:46, Imran Shaik wrote: > This series adds cpufreq scaling support on Qualcomm Shikra SoC. > > Signed-off-by: Imran Shaik <imran.shaik@oss.qualcomm.com> > --- > Changes in v4: > - Drop CPUFREQ and use EPSS in bindings [Krzysztof] > - Update bindings patch commit subject with correct subsystem prefix [Krzysztof] > - Link to v3: https://lore.kernel.org/r/20260521-shikra-cpufreq-scaling-v3-0-883c13d1e514@oss.qualcomm.com Applied. Thanks. -- viresh ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-08 5:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-22 15:16 [PATCH v4 0/2] Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik 2026-05-22 15:16 ` [PATCH v4 1/2] dt-bindings: cpufreq: Document Qualcomm Shikra SoC EPSS Imran Shaik 2026-05-22 15:16 ` [PATCH v4 2/2] cpufreq: qcom: Add cpufreq scaling support for Qualcomm Shikra SoC Imran Shaik 2026-05-22 16:06 ` sashiko-bot 2026-06-08 5:37 ` [PATCH v4 0/2] " Viresh Kumar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox