Introduce RPM Master stats
v4 cover Introduce RPM Master stats
v3 -> v4:
- Use "data" instead of "d" for naming local struct master_stats_data *
- Add "qcom_" prefix in the debugfs path
- Add "Qualcomm" prefix in MODULE_NAME
- Make the struct __packed__ to avoid padding surprises (even though it looks like there shouldn't be any, by eye)
- use IS_ERR for checking debugfs_create_file return value instead of nullchecking, that apparently changed..
- Use -ENODEV instead of -EINVAL when a MSG RAM handle is not found
- Add missing of_node_put() after of_parse_phandle()
- Vastly improve the documentation bit
v3: https://lore.kernel.org/r/[email protected]
v2 -> v3:
- rename rpm-master-stats.yaml to qcom,rpm-master-stats.yaml
v2: https://lore.kernel.org/r/[email protected]
v1 -> v2:
- Drop the - in /properties/compatible to make our entry be of the correct type [1/2]
- Change %s to %d for printing out the iterator [2/2]
v1: https://lore.kernel.org/r/[email protected]
The RPM MSG ram includes per-subsystem low-power mode entry/exit/ residence/etc. statistics which are very useful for trying to debug what I'd call "SoC insomnia", or IOW the plaftorm refusing to drop the voltage rails to a minimum and gate the non-critical clocks.
This series adds a very short and simple driver to query that data and expose it through debugfs.
The base used for writing this driver is:
https://github.com/sonyxperiadev/kernel/blob/aosp/LA.UM.9.14.r1/drivers/soc/qcom/rpm_master_stat.c
---
Konrad Dybcio (2):
dt-bindings: soc: qcom: Add RPM Master stats
soc: qcom: Introduce RPM master stats driver
.../bindings/soc/qcom/qcom,rpm-master-stats.yaml | 69 +++++++++ drivers/soc/qcom/Kconfig | 11 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 162 +++++++++++++++++++++ 4 files changed, 243 insertions(+)
---
base-commit: d3f2cd24819158bb70701c3549e586f9df9cee67
change-id: 20230405-topic-master_stats-ba201a9af93d
Best regards,
Signature · 1 line
Konrad Dybcio <[email protected]>
PATCH v4 1/2 dt-bindings: soc: qcom: Add RPM Master stats
The RPM MSG RAM contains per-RPM-master (e.g. APPS, ADSP etc.) sleep statistics. They let one assess which core is actively preventing the system from entering a true low-power mode.
--- .../bindings/soc/qcom/qcom,rpm-master-stats.yaml | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,rpm-master-stats.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/qcom/qcom,rpm-master-stats.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies, Inc. (QTI) RPM Master Stats + +maintainers: + - Konrad Dybcio <[email protected]> + +description: | + The Qualcomm RPM (Resource Power Manager) architecture includes a concept + of "RPM Masters". They can be thought of as "the local gang leaders", usually + spanning a single subsystem (e.g. APSS, ADSP, CDSP). All of the RPM decisons + (particularly around entering hardware-driven low power modes: XO shutdown + and total system-wide power collapse) are first made at Master-level, and + only then aggregated for the entire system. + + The Master Stats provide a few useful bits that can be used to assess whether + our device has entered the desired low-power mode, how long it took to do so, + the duration of that residence, how long it took to come back online, + how many times a given sleep state was entered and which cores are actively + voting for staying awake. + + This scheme has been used on various SoCs in the 2013-2023 era, with some + newer or higher-end designs providing this information through an SMEM query. + +properties: + compatible: + const: qcom,rpm-master-stats + + qcom,rpm-msg-ram: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: Phandle to an RPM MSG RAM slice containing the master stats + minItems: 1 + maxItems: 5 + + qcom,master-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: + The name of the RPM Master which owns the MSG RAM slice where this + instance of Master Stats resides + minItems: 1 + maxItems: 5 + +required: + - compatible + - qcom,rpm-msg-ram + - qcom,master-names + +additionalProperties: false + +examples: + - | + stats { + compatible = "qcom,rpm-master-stats"; + qcom,rpm-msg-ram = <&apss_master_stats>, + <&mpss_master_stats>, + <&adsp_master_stats>, + <&cdsp_master_stats>, + <&tz_master_stats>; + qcom,master-names = "APSS", + "MPSS", + "ADSP", + "CDSP", + "TZ"; + }; +...
Signature · 1 line
2.40.0
Re: [PATCH v4 1/2] dt-bindings: soc: qcom: Add RPM Master stats
Quoted 6 lines · Konrad Dybcio
The RPM MSG RAM contains per-RPM-master (e.g. APPS, ADSP etc.) sleep statistics. They let one assess which core is actively preventing the system from entering a true low-power mode.
Signed-off-by Konrad Dybcio <[email protected]>---
Best regards,
Krzysztof
PATCH v4 2/2 soc: qcom: Introduce RPM master stats driver
In reply to Konrad DybcioIntroduce a driver to query and expose detailed, per-subsystem (as opposed to the existing qcom_stats driver which exposes SoC-wide data) about low power mode states of a given RPM master. That includes the APSS (ARM), MPSS (modem) and other remote cores, depending on the platform configuration.
This is a vastly cleaned up and restructured version of a similar driver found in msm-5.4.
--- drivers/soc/qcom/Kconfig | 11 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 162 ++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+)
drivers/soc/qcom/Kconfig +11 -0
@@ -135,6 +135,17 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPM_MASTER_STATS + tristate "Qualcomm RPM Master stats" + depends on ARCH_QCOM || COMPILE_TEST + help + The RPM Master sleep stats driver provides detailed per-subsystem + sleep/wake data, read from the RPM message RAM. It can be used to + assess whether all the low-power modes available are entered as + expected or to check which part of the SoC prevents it from sleeping. + + Say y here if you intend to debug or monitor platform sleep. + config QCOM_RPMH tristate "Qualcomm RPM-Hardened (RPMH) Communication" depends on ARCH_QCOM || COMPILE_TEST
drivers/soc/qcom/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o +obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.o
drivers/soc/qcom/rpm_master_stats.c new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
2.40.0
Re: [PATCH v4 2/2] soc: qcom: Introduce RPM master stats driver
Quoted 84 lines · Konrad Dybcio
Introduce a driver to query and expose detailed, per-subsystem (as opposed to the existing
qcom_statsdriver which exposes SoC-wide data) about low power mode states of a given RPM master. That includes the APSS (ARM), MPSS (modem) and other remote cores, depending on the platform configuration.This is a vastly cleaned up and restructured version of a similar driver found in msm-5.4.
Signed-off-by Konrad Dybcio <[email protected]>--- drivers/soc/qcom/Kconfig | 11 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 162 ++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+)drivers/soc/qcom/Kconfig +11
-0@@ -135,6 +135,17 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPM_MASTER_STATS + tristate "Qualcomm RPM Master stats" + depends on ARCH_QCOM || COMPILE_TEST + help + The RPM Master sleep stats driver provides detailed per-subsystem + sleep/wake data, read from the RPM message RAM. It can be used to + assess whether all the low-power modes available are entered as + expected or to check which part of the SoC prevents it from sleeping. + + Say y here if you intend to debug or monitor platform sleep. + config QCOM_RPMH tristate "Qualcomm RPM-Hardened (RPMH) Communication" depends on ARCH_QCOM || COMPILE_TESTdrivers/soc/qcom/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o +obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.odrivers/soc/qcom/rpm_master_stats.c new file +28
-0@@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. +* Copyright (c) 2023, Linaro Limited +* +* This driver supports what is known as "Master Stats v2" in Qualcomm +* downstream kernel terms, which seems to be the only version which has +* ever shipped, all the way from 2013 to 2023. +*/ + +#include <linux/debugfs.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> + +struct master_stats_data { +void __iomem *base; +const char *label; +}; + +struct rpm_master_stats { +uint32_t active_cores; +uint32_t num_shutdowns; +uint64_t shutdown_req; +uint64_t wakeup_idx; +uint64_t bringup_req;
drivers/soc/qcom/rpm_master_stats.c line 38
Quoted 10 lines
drivers/soc/qcom/rpm_master_stats.c new file +10
-0+uint64_t bringup_ack; +uint32_t wakeup_reason;/* 0 = "rude wakeup", 1 = scheduled wakeup */ +uint32_t last_sleep_trans_dur; +uint32_t last_wake_trans_dur; + +/* Per-subsystem (*not necessarily* SoC-wide) XO shutdown stats */ +uint32_t xo_count; +uint64_t xo_last_enter; +uint64_t last_exit; +uint64_t xo_total_dur;
Still no u64, u32.
Quoted 2 lines
drivers/soc/qcom/rpm_master_stats.c new file +2
-0+} __packed; +
[...]
drivers/soc/qcom/rpm_master_stats.c line 130
Quoted 9 lines
drivers/soc/qcom/rpm_master_stats.c new file +9
-0+/* +* Generally it's not advised to fail on debugfs errors, but this +* driver's only job is exposing data therein. +*/ + dent =debugfs_create_file (data[i].label,0444 , root, + &data[i], &master_stats_fops); +if (IS_ERR (dent)) { +debugfs_remove_recursive (root); +return -EINVAL ;
PTR_ERR(dent). Also it doesn't hurt to use dev_err_probe() here.
Quoted 15 lines
drivers/soc/qcom/rpm_master_stats.c new file +15
-0+ } + } + +device_set_pm_not_required (dev); + +return 0 ; +} + +static void master_stats_remove (struct platform_device *pdev) +{ +struct dentry *root =platform_get_drvdata (pdev); + +debugfs_remove_recursive (root); +} +
drivers/soc/qcom/rpm_master_stats.c line 155
Quoted 10 lines
drivers/soc/qcom/rpm_master_stats.c new file +10
-0+static const struct of_device_id rpm_master_table[] = { + { .compatible ="qcom,rpm-master-stats" }, + { }, +}; + +static struct platform_driver master_stats_driver = { + .probe = master_stats_probe, + .remove_new = master_stats_remove, + .driver = { + .name ="rpm_master_stats" ,
qcom_rpm_master_stats
- Mani
Quoted 11 lines
drivers/soc/qcom/rpm_master_stats.c new file +7
-0+ .of_match_table = rpm_master_table, + }, +}; +module_platform_driver (master_stats_driver); + +MODULE_DESCRIPTION ("Qualcomm RPM Master Statistics driver" ); +MODULE_LICENSE ("GPL" );Signature · 2 lines
-- 2.40.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v4 2/2] soc: qcom: Introduce RPM master stats driver
Quoted 89 lines · Manivannan Sadhasivam
Quoted 88 lines · Konrad Dybcio
Introduce a driver to query and expose detailed, per-subsystem (as opposed to the existing
qcom_statsdriver which exposes SoC-wide data) about low power mode states of a given RPM master. That includes the APSS (ARM), MPSS (modem) and other remote cores, depending on the platform configuration.This is a vastly cleaned up and restructured version of a similar driver found in msm-5.4.
Signed-off-by Konrad Dybcio <[email protected]>--- drivers/soc/qcom/Kconfig | 11 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 162 ++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+)drivers/soc/qcom/Kconfig +11
-0@@ -135,6 +135,17 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPM_MASTER_STATS + tristate "Qualcomm RPM Master stats" + depends on ARCH_QCOM || COMPILE_TEST + help + The RPM Master sleep stats driver provides detailed per-subsystem + sleep/wake data, read from the RPM message RAM. It can be used to + assess whether all the low-power modes available are entered as + expected or to check which part of the SoC prevents it from sleeping. + + Say y here if you intend to debug or monitor platform sleep. + config QCOM_RPMH tristate "Qualcomm RPM-Hardened (RPMH) Communication" depends on ARCH_QCOM || COMPILE_TESTdrivers/soc/qcom/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o +obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.odrivers/soc/qcom/rpm_master_stats.c new file +32
-0@@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. +* Copyright (c) 2023, Linaro Limited +* +* This driver supports what is known as "Master Stats v2" in Qualcomm +* downstream kernel terms, which seems to be the only version which has +* ever shipped, all the way from 2013 to 2023. +*/ + +#include <linux/debugfs.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> + +struct master_stats_data { +void __iomem *base; +const char *label; +}; + +struct rpm_master_stats { +uint32_t active_cores; +uint32_t num_shutdowns; +uint64_t shutdown_req; +uint64_t wakeup_idx; +uint64_t bringup_req; +uint64_t bringup_ack; +uint32_t wakeup_reason;/* 0 = "rude wakeup", 1 = scheduled wakeup */ +uint32_t last_sleep_trans_dur; +uint32_t last_wake_trans_dur;
Quoted 8 lines
drivers/soc/qcom/rpm_master_stats.c line 38
Quoted 6 lines
drivers/soc/qcom/rpm_master_stats.c new file +6
-0+ +/* Per-subsystem (*not necessarily* SoC-wide) XO shutdown stats */ +uint32_t xo_count; +uint64_t xo_last_enter; +uint64_t last_exit; +uint64_t xo_total_dur;Still no u64, u32.
Right, missed that part..
Quoted 6 lines
Quoted 3 lines
drivers/soc/qcom/rpm_master_stats.c new file +2
-0+} __packed; +[...]
Quoted 11 lines
drivers/soc/qcom/rpm_master_stats.c line 130
Quoted 9 lines
drivers/soc/qcom/rpm_master_stats.c new file +9
-0+/* +* Generally it's not advised to fail on debugfs errors, but this +* driver's only job is exposing data therein. +*/ + dent =debugfs_create_file (data[i].label,0444 , root, + &data[i], &master_stats_fops); +if (IS_ERR (dent)) { +debugfs_remove_recursive (root); +return -EINVAL ;
PTR_ERR(dent). Also it doesn't hurt to usedev_err_probe()here.
Totally makes sense.
Quoted 20 lines
Quoted 20 lines
drivers/soc/qcom/rpm_master_stats.c new file +19
-0+ } + } + +device_set_pm_not_required (dev); + +return 0 ; +} + +static void master_stats_remove (struct platform_device *pdev) +{ +struct dentry *root =platform_get_drvdata (pdev); + +debugfs_remove_recursive (root); +} + +static const struct of_device_id rpm_master_table[] = { + { .compatible ="qcom,rpm-master-stats" }, + { }, +};
Quoted 9 lines
drivers/soc/qcom/rpm_master_stats.c line 155
Quoted 6 lines
drivers/soc/qcom/rpm_master_stats.c new file +6
-0+ +static struct platform_driver master_stats_driver = { + .probe = master_stats_probe, + .remove_new = master_stats_remove, + .driver = { + .name ="rpm_master_stats" ,
qcom_rpm_master_stats
Fixed it everywhere else except here, will do!
Konrad
Quoted 14 lines
- Mani
Quoted 11 lines
drivers/soc/qcom/rpm_master_stats.c new file +7
-0+ .of_match_table = rpm_master_table, + }, +}; +module_platform_driver (master_stats_driver); + +MODULE_DESCRIPTION ("Qualcomm RPM Master Statistics driver" ); +MODULE_LICENSE ("GPL" );Signature · 2 lines
-- 2.40.0