Skip to contentSkip to conversation

Add RPM sleep stats for MSM8916

PATCH Applied Stephan Gerhold 3 participants 9 messages Nov 19, 2021 – Dec 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add RPM sleep stats for MSM8916

MSM8916 is similar to the other SoCs that had the RPM stats node added in commit 290bc6846547 ("arm64: dts: qcom: Enable RPM Sleep stats"). However, the dynamic offset readable at 0x14 seems only available on some of the newer RPM firmware versions.

To be absolutely sure, this series adds new SoC-specific compatibles for the older SoC that read the sleep stats from a fixed offset of 0xdba0.

This approach was originally suggested by Maulik Shah in:
https://lore.kernel.org/linux-arm-msm/[email protected]/
Bjorn suggested using SoC-specific compatibles instead of a generic qcom,rpm-legacy-stats since there seem to be more legacy variants on even older SoCs.

Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

Stephan Gerhold (3):
dt-bindings: soc: qcom: stats: Document compatibles with fixed offset
soc: qcom: stats: Add fixed sleep stats offset for older RPM firmwares
arm64: dts: qcom: msm8916: Add RPM sleep stats

 .../devicetree/bindings/soc/qcom/qcom-stats.yaml    |  5 +++++
 arch/arm64/boot/dts/qcom/msm8916.dtsi               |  5 +++++
 drivers/soc/qcom/qcom_stats.c                       | 13 +++++++++++++
 3 files changed, 23 insertions(+)
Signature · 1 line
2.34.0
#1 lore raw

PATCH v2 1/3 dt-bindings: soc: qcom: stats: Document compatibles with fixed offset

Document additional compatibles that can be used similarly to qcom,rpm-stats for older RPM firmware versions that have the sleep stats at a fixed offset rather than a dynamic one. The exact offset might vary depending on the SoC so use SoC-specific compatible names to avoid confusion.

---
Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

---
 Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml +5 -0
index 99dff7d73b7e..473adca4e973 100644
@@ -21,6 +21,11 @@ properties:
     enum:
       - qcom,rpmh-stats
       - qcom,rpm-stats
+      # For older RPM firmware versions with fixed offset for the sleep stats
+      - qcom,apq8084-rpm-stats
+      - qcom,msm8226-rpm-stats
+      - qcom,msm8916-rpm-stats
+      - qcom,msm8974-rpm-stats
 
   reg:
     maxItems: 1
Signature · 1 line
2.34.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: soc: qcom: stats: Document compatibles with fixed offset

Quoted 5 lines · Stephan Gerhold

Document additional compatibles that can be used similarly to qcom,rpm-stats for older RPM firmware versions that have the sleep stats at a fixed offset rather than a dynamic one. The exact offset might vary depending on the SoC so use SoC-specific compatible names to avoid confusion.

Regards,
Bjorn

Quoted 28 lines

---
Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

---
 Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml +5 -0
index 99dff7d73b7e..473adca4e973 100644
@@ -21,6 +21,11 @@ properties:
     enum:
       - qcom,rpmh-stats
       - qcom,rpm-stats
+      # For older RPM firmware versions with fixed offset for the sleep stats
+      - qcom,apq8084-rpm-stats
+      - qcom,msm8226-rpm-stats
+      - qcom,msm8916-rpm-stats
+      - qcom,msm8974-rpm-stats
 
   reg:
     maxItems: 1
Signature · 1 line
2.34.0
maintainer Acked-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: soc: qcom: stats: Document compatibles with fixed offset

In reply to Stephan Gerhold
Quoted 5 lines · Stephan Gerhold

Document additional compatibles that can be used similarly to qcom,rpm-stats for older RPM firmware versions that have the sleep stats at a fixed offset rather than a dynamic one. The exact offset might vary depending on the SoC so use SoC-specific compatible names to avoid confusion.

Quoted 9 lines

---
Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

---
 Documentation/devicetree/bindings/soc/qcom/qcom-stats.yaml | 5 +++++
 1 file changed, 5 insertions(+)
#4 lore raw

PATCH v2 2/3 soc: qcom: stats: Add fixed sleep stats offset for older RPM firmwares

In reply to Stephan Gerhold

Not all RPM firmware versions have the dynamic sleep stats offset available. Most older versions use a fixed offset of 0xdba0. Add support for this using new SoC-specific compatibles for APQ8084, MSM8226, MSM8916 and MSM8974.

Even older SoCs seem to use a different offset and stats format. If needed those could be supported in the future by adding separate compatibles for those with a different stats_config.

---
Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

---
 drivers/soc/qcom/qcom_stats.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/soc/qcom/qcom_stats.c +13 -0
index 131d24caabf8..d6bfd1bbdc2a 100644
@@ -237,6 +237,15 @@ static const struct stats_config rpm_data = {
 	.subsystem_stats_in_smem = false,
 };
 
+/* Older RPM firmwares have the stats at a fixed offset instead */
+static const struct stats_config rpm_data_dba0 = {
+	.stats_offset = 0xdba0,
+	.num_records = 2,
+	.appended_stats_avail = true,
+	.dynamic_offset = false,
+	.subsystem_stats_in_smem = false,
+};
+
 static const struct stats_config rpmh_data = {
 	.stats_offset = 0x48,
 	.num_records = 3,
@@ -246,6 +255,10 @@ static const struct stats_config rpmh_data = {
 };
 
 static const struct of_device_id qcom_stats_table[] = {
+	{ .compatible = "qcom,apq8084-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8226-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8916-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8974-rpm-stats", .data = &rpm_data_dba0 },
 	{ .compatible = "qcom,rpm-stats", .data = &rpm_data },
 	{ .compatible = "qcom,rpmh-stats", .data = &rpmh_data },
 	{ }
Signature · 1 line
2.34.0
Reviewed-by on v2 2/3
#5 lore raw

Re: [PATCH v2 2/3] soc: qcom: stats: Add fixed sleep stats offset for older RPM firmwares

Quoted 11 lines · Stephan Gerhold

Not all RPM firmware versions have the dynamic sleep stats offset available. Most older versions use a fixed offset of 0xdba0. Add support for this using new SoC-specific compatibles for APQ8084, MSM8226, MSM8916 and MSM8974.

Even older SoCs seem to use a different offset and stats format. If needed those could be supported in the future by adding separate compatibles for those with a different stats_config.

Regards,
Bjorn

Quoted 41 lines

---
Changes in v2:
- Use SoC-specific compatibles instead of qcom,rpm-legacy-stats

---
 drivers/soc/qcom/qcom_stats.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/soc/qcom/qcom_stats.c +13 -0
index 131d24caabf8..d6bfd1bbdc2a 100644
@@ -237,6 +237,15 @@ static const struct stats_config rpm_data = {
 	.subsystem_stats_in_smem = false,
 };
 
+/* Older RPM firmwares have the stats at a fixed offset instead */
+static const struct stats_config rpm_data_dba0 = {
+	.stats_offset = 0xdba0,
+	.num_records = 2,
+	.appended_stats_avail = true,
+	.dynamic_offset = false,
+	.subsystem_stats_in_smem = false,
+};
+
 static const struct stats_config rpmh_data = {
 	.stats_offset = 0x48,
 	.num_records = 3,
@@ -246,6 +255,10 @@ static const struct stats_config rpmh_data = {
 };
 
 static const struct of_device_id qcom_stats_table[] = {
+	{ .compatible = "qcom,apq8084-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8226-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8916-rpm-stats", .data = &rpm_data_dba0 },
+	{ .compatible = "qcom,msm8974-rpm-stats", .data = &rpm_data_dba0 },
 	{ .compatible = "qcom,rpm-stats", .data = &rpm_data },
 	{ .compatible = "qcom,rpmh-stats", .data = &rpmh_data },
 	{ }
Signature · 1 line
2.34.0
#6 lore raw

PATCH v2 3/3 arm64: dts: qcom: msm8916: Add RPM sleep stats

In reply to Stephan Gerhold

MSM8916 is similar to the other SoCs that had the RPM stats node added in commit 290bc6846547 ("arm64: dts: qcom: Enable RPM Sleep stats"). However, the dynamic offset readable at 0x14 seems only available on some of the newer firmware versions. To be absolutely sure, make use of the new qcom,msm8916-rpm-stats compatible that reads the sleep stats from a fixed offset of 0xdba0.

Statistics are available for a "vmin" and "xosd" low power mode:

$ cat /sys/kernel/debug/qcom_stats/vmin
Count: 0
Last Entered At: 0
Last Exited At: 0
Accumulated Duration: 0
Client Votes: 0x0
$ cat /sys/kernel/debug/qcom_stats/xosd
Count: 0
Last Entered At: 0
Last Exited At: 0
Accumulated Duration: 0
Client Votes: 0x0

---
Changes in v2:
- Use SoC-specific compatible qcom,msm8916-rpm-stats

---
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/msm8916.dtsi +5 -0
index c1c42f26b61e..9044eb41a81d 100644
@@ -453,6 +453,11 @@ rpm_msg_ram: sram@60000 {
 			reg = <0x00060000 0x8000>;
 		};
 
+		sram@290000 {
+			compatible = "qcom,msm8916-rpm-stats";
+			reg = <0x00290000 0x10000>;
+		};
+
 		bimc: interconnect@400000 {
 			compatible = "qcom,msm8916-bimc";
 			reg = <0x00400000 0x62000>;
Signature · 1 line
2.34.0
#7 lore raw

Re: (subset) [PATCH v2 3/3] arm64: dts: qcom: msm8916: Add RPM sleep stats

Quoted 8 lines · Stephan Gerhold

MSM8916 is similar to the other SoCs that had the RPM stats node added in commit 290bc6846547 ("arm64: dts: qcom: Enable RPM Sleep stats"). However, the dynamic offset readable at 0x14 seems only available on some of the newer firmware versions. To be absolutely sure, make use of the new qcom,msm8916-rpm-stats compatible that reads the sleep stats from a fixed offset of 0xdba0.

[...]

Applied, thanks!

[3/3] arm64: dts: qcom: msm8916: Add RPM sleep stats

      commit: 1c0ac047bbfb3efd6549d18c3ca47aa0afedcfbe

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>
#8 lore raw

Re: (subset) [PATCH v2 0/3] Add RPM sleep stats for MSM8916

In reply to Stephan Gerhold
Quoted 9 lines · Stephan Gerhold

MSM8916 is similar to the other SoCs that had the RPM stats node added in commit 290bc6846547 ("arm64: dts: qcom: Enable RPM Sleep stats"). However, the dynamic offset readable at 0x14 seems only available on some of the newer RPM firmware versions.

To be absolutely sure, this series adds new SoC-specific compatibles for the older SoC that read the sleep stats from a fixed offset of 0xdba0.

[...]

Applied, thanks!

[1/3] dt-bindings: soc: qcom: stats: Document compatibles with fixed offset

      commit: 0a023bc0dd3ce6db6d87026c6fce3e2381c30192
[2/3] soc: qcom: stats: Add fixed sleep stats offset for older RPM firmwares
      commit: 569fc4015a93267f50d37f4e85ca6f70428123b2

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>