Skip to contentSkip to conversation

pmdomain: st: ux500: Implement ux500 power domains

PATCH Superseded Linus Walleij 8 participants 34 messages Jun 18 – Aug 20

Subsystems (11)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Linus Walleij

author maintainer
#0 lore raw

cover pmdomain: st: ux500: Implement ux500 power domains

Today the Ux500 SoC specifically DB8500 is using what is called "EPOD regulators" (EPOD = Electric POwer Domain) to control its power domains. This was done like this because at the time, power domains did not exist as a concept in the Linux kernel.

This patch series completes the ambitious work started in
commit cd931dcfda5e ("ARM: ux500: Initial support for PM domains") which added a dummy domain driver for Ux500 in the following steps:

- Convert the old Ux500 power domain text DT bindings to YAML schema.

- Extend the bindings with all the 16 power domains actually existing in the hardware.

- Add these domains to the existing ux500 power domain driver (still as dummy domains).

- Add the power domains to the DB8500 SoC DTSI file.

- Move code over from the EPOD regulators to the actual power domain driver. Since the two drivers now control the same hardware, make the drivers mutually exclusive.

- Modify the MCDE display driver to use the power domain instead of the EPOS regulators.

- Modify the DMA40 DMA controller to use the power domain instead of the EPOD regulators.

- Delete the old EPOD regulators.

- Implement regulators activating the VANA and VSMPS2 power domains for the power domain voltage rails that are routed off-chip as external supplies, re-using the existing EPOD regulator bindings.

- Delete the references to the unused EPOD regulators from the device tree, keeping the references to VANA and VSMPS2.

This is a bit of brain transplant on the Ux500, and the series is not very boot-bisectable.

For simplicity, the series can be merged in separate paths and subsystems as there are no build-time dependencies, as long as the result ends up in kernel v7.3. Once the concept and patches are ACKed by the power domain folks, I will send the patches that can be split out individually to each maintainer and it can all be merged in parallel.

---
Linus Walleij (11):
dt-bindings: power: Convert Ux500 PM domains to schema
dt-bindings: Add the actual power domains on U8500
pmdomain: st: ux500: Implement more power domains
ARM: dts: ux500: Rename power domains node
ARM: dts: ux500: Add power domains
pmdomain: st: ux500: Control DB8500 EPODs drm/mcde: Use power domain for display power
dmaengine: ste_dma40: Use power domain for LCLA SRAM
regulator: db8500-prcmu: Remove EPOD regulators
regulator: db8500: Add power domain regulators
ARM: dts: ux500: Remove DB8500 EPOD regulators

 .../devicetree/bindings/arm/ux500/power_domain.txt |  35 --
 .../power/stericsson,ux500-pm-domains.yaml         |  46 ++
 MAINTAINERS                                        |   1 +
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi               | 134 ++----
 arch/arm/mach-ux500/Kconfig                        |   2 +-
 drivers/dma/ste_dma40.c                            |  97 ++--
 drivers/gpu/drm/mcde/mcde_clk_div.c                |   4 +-
 drivers/gpu/drm/mcde/mcde_display.c                |  11 +-
 drivers/gpu/drm/mcde/mcde_drm.h                    |   2 -
 drivers/gpu/drm/mcde/mcde_drv.c                    |  63 +--
 drivers/gpu/drm/mcde/mcde_dsi.c                    |   1 -
 drivers/mfd/db8500-prcmu.c                         | 239 +---------
 drivers/pmdomain/st/ste-ux500-pm-domain.c          | 353 ++++++++++++++-
 drivers/regulator/Kconfig                          |  22 +-
 drivers/regulator/Makefile                         |   3 +-
 drivers/regulator/db8500-prcmu.c                   | 501 ---------------------
 drivers/regulator/db8500-regulator.c               | 221 +++++++++
 drivers/regulator/dbx500-prcmu.c                   | 155 -------
 drivers/regulator/dbx500-prcmu.h                   |  55 ---
 include/dt-bindings/arm/ux500_pm_domains.h         |  17 +-
 include/linux/regulator/db8500-prcmu.h             |  38 --
 21 files changed, 748 insertions(+), 1252 deletions(-)

---
base-commit: 8cd9520d35a6c38db6567e97dd93b1f11f185dc6
change-id: 20260618-ux500-power-domains-v7-1-3c9d095828c2

Best regards,

Signature · 1 line
Linus Walleij <[email protected]>
author maintainer
#1 lore raw

PATCH 1/11 dt-bindings: power: Convert Ux500 PM domains to schema

Convert the legacy Ux500 power domain text binding to YAML.

Move it under bindings/power.

Reference the generic power-domain schema.

Update MAINTAINERS for the new path.

Assisted-by Codex:gpt-5-5
---
 .../devicetree/bindings/arm/ux500/power_domain.txt | 35 ----------------
 .../power/stericsson,ux500-pm-domains.yaml         | 46 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 3 files changed, 47 insertions(+), 35 deletions(-)
Documentation/devicetree/bindings/arm/ux500/power_domain.txt deleted +0 -35
deleted file mode 100644
index 5679d1742d3e..000000000000
@@ -1,35 +0,0 @@
-* ST-Ericsson UX500 PM Domains
-
-UX500 supports multiple PM domains which are used to gate power to one or
-more peripherals on the SOC.
-
-The implementation of PM domains for UX500 are based upon the generic PM domain
-and use the corresponding DT bindings.
-
-==PM domain providers==
-
-Required properties:
- - compatible: Must be "stericsson,ux500-pm-domains".
- - #power-domain-cells : Number of cells in a power domain specifier, must be 1.
-
-Example:
-	pm_domains: pm_domains0 {
-		compatible = "stericsson,ux500-pm-domains";
-		#power-domain-cells = <1>;
-	};
-
-==PM domain consumers==
-
-Required properties:
- - power-domains: A phandle and PM domain specifier. Below are the list of
-		valid specifiers:
-
-		Index	Specifier
-		-----	---------
-		0	DOMAIN_VAPE
-
-Example:
-	sdi0_per1@80126000 {
-		compatible = "arm,pl18x", "arm,primecell";
-		power-domains = <&pm_domains DOMAIN_VAPE>
-	};
Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.yaml new file +46 -0

46 lines not on this page · raw message

MAINTAINERS +1 -0
index c8d4b913f26c..a984c4647cc7 100644
@@ -3167,6 +3167,7 @@ F:	Documentation/devicetree/bindings/arm/ux500.yaml
 F:	Documentation/devicetree/bindings/arm/ux500/
 F:	Documentation/devicetree/bindings/gpio/st,nomadik-gpio.yaml
 F:	Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml
+F:	Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.yaml
 F:	arch/arm/boot/dts/st/ste-*
 F:	arch/arm/mach-nomadik/
 F:	arch/arm/mach-ux500/
Signature · 1 line
2.54.0
#2 lore raw

Re: [PATCH 01/11] dt-bindings: power: Convert Ux500 PM domains to schema

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The example consumer node `sdi0_per1@80126000` will fail `dt_binding_check` validation due to…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The example consumer node sdi0_per1@80126000 will fail dt_binding_check validation due to missing required properties and will trigger a dtc warning. --

commit b98e3bf1a2da87a6966744348740e230bb97bdfd
Author: Linus Walleij <[email protected]>

dt-bindings: power: Convert Ux500 PM domains to schema

This commit converts the legacy Ux500 power domain text binding to YAML. It moves the binding under bindings/power and updates the MAINTAINERS file accordingly.

Quoted 5 lines
Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.yaml new file +0 -0
new file mode 100644
index 0000000000000..72c39c083efbf

[ ... ]

Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.yaml line 46

Quoted 13 lines
Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.yaml new file +13 -0
+examples:
+  - |
+    #include <dt-bindings/arm/ux500_pm_domains.h>
+
+    pm_domains: power-controller {
+        compatible = "stericsson,ux500-pm-domains";
+        #power-domain-cells = <1>;
+    };
+
+    sdi0_per1@80126000 {
+        compatible = "arm,pl18x", "arm,primecell";
+        power-domains = <&pm_domains DOMAIN_VAPE>;
+    };

[Severity: Low]
Will this example consumer node trigger warnings during dt_binding_check?

The node is matched against the arm,pl18x.yaml schema, which requires both the reg and interrupts properties. Since they are missing here, dt-schema will likely report validation errors.

Additionally, because the node includes a unit address (@80126000) but lacks a reg property, does this cause dtc to emit a unit_address_vs_reg warning? Should dummy reg and interrupts properties be added to the example to satisfy the schema validation?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH 01/11] dt-bindings: power: Convert Ux500 PM domains to schema

In reply to Linus Walleij
Quoted 8 lines · Linus Walleij

Convert the legacy Ux500 power domain text binding to YAML.

Move it under bindings/power.

Reference the generic power-domain schema.

Update MAINTAINERS for the new path.

Quoted 8 lines
Assisted-by Codex:gpt-5-5
---
 .../devicetree/bindings/arm/ux500/power_domain.txt | 35 ----------------
 .../power/stericsson,ux500-pm-domains.yaml         | 46 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 3 files changed, 47 insertions(+), 35 deletions(-)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.example.dts:25.28-28.11: Warning (unit_address_vs_reg): /example-0/sdi0_per1@80126000: node has a unit name, but no reg or ranges property /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.example.dtb: sdi0_per1@80126000 (arm,pl18x): $nodename:0: 'sdi0_per1@80126000' does not match '^mmc(@.*)?$'
from schema $id: http://devicetree.org/schemas/mmc/arm,pl18x.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.example.dtb: sdi0_per1@80126000 (arm,pl18x): 'oneOf' conditional failed, one must be fixed:
'interrupts' is a required property
'interrupts-extended' is a required property
from schema $id: http://devicetree.org/schemas/mmc/arm,pl18x.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/power/stericsson,ux500-pm-domains.example.dtb: sdi0_per1@80126000 (arm,pl18x): 'reg' is a required property
from schema $id: http://devicetree.org/schemas/mmc/arm,pl18x.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

author maintainer
#4 lore raw

PATCH 2/11 dt-bindings: Add the actual power domains on U8500

In reply to Linus Walleij

This file has been left in an unfinished state just defining the root power domain for the U8500 SoC. Fix it up by adding the actual existing power domains in this SoC.

The PRCMU code and old regulator driver is mentioning some *_RET domains, this means "retention" and is a state in the domain and not a domain of its own.

---
 include/dt-bindings/arm/ux500_pm_domains.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
include/dt-bindings/arm/ux500_pm_domains.h +16 -1
index 9bd764f0c9e6..1c168e59ac90 100644
@@ -8,8 +8,23 @@
 #define _DT_BINDINGS_ARM_UX500_PM_DOMAINS_H
 
 #define DOMAIN_VAPE		0
+#define DOMAIN_VARM		1
+#define DOMAIN_VMODEM		2
+#define DOMAIN_VPLL		3
+#define DOMAIN_VSMPS1		4
+#define DOMAIN_VSMPS2		5
+#define DOMAIN_VSMPS3		6
+#define DOMAIN_VRF1		7
+#define DOMAIN_SVA_MMDSP	8
+#define DOMAIN_SVA_PIPE		9
+#define DOMAIN_SIA_MMDSP	10
+#define DOMAIN_SIA_PIPE		11
+#define DOMAIN_SGA		12
+#define DOMAIN_B2R2_MCDE	13
+#define DOMAIN_ESRAM_12		14
+#define DOMAIN_ESRAM_34		15
 
 /* Number of PM domains. */
-#define NR_DOMAINS		(DOMAIN_VAPE + 1)
+#define NR_DOMAINS		(DOMAIN_ESRAM_34 + 1)
 
 #endif
Signature · 1 line
2.54.0
#5 lore raw

Re: [PATCH 02/11] dt-bindings: Add the actual power domains on U8500

Quoted 9 lines · Linus Walleij

This file has been left in an unfinished state just defining the root power domain for the U8500 SoC. Fix it up by adding the actual existing power domains in this SoC.

The PRCMU code and old regulator driver is mentioning some *_RET domains, this means "retention" and is a state in the domain and not a domain of its own.

From/SoB mismatch.

Quoted 21 lines
---
 include/dt-bindings/arm/ux500_pm_domains.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
include/dt-bindings/arm/ux500_pm_domains.h +9 -0
index 9bd764f0c9e6..1c168e59ac90 100644
@@ -8,8 +8,23 @@
 #define _DT_BINDINGS_ARM_UX500_PM_DOMAINS_H
 
 #define DOMAIN_VAPE		0
+#define DOMAIN_VARM		1
+#define DOMAIN_VMODEM		2
+#define DOMAIN_VPLL		3
+#define DOMAIN_VSMPS1		4
+#define DOMAIN_VSMPS2		5
+#define DOMAIN_VSMPS3		6
+#define DOMAIN_VRF1		7
+#define DOMAIN_SVA_MMDSP	8
+#define DOMAIN_SVA_PIPE		9

include/dt-bindings/arm/ux500_pm_domains.h line 28

Quoted 10 lines
include/dt-bindings/arm/ux500_pm_domains.h +7 -1
+#define DOMAIN_SIA_MMDSP	10
+#define DOMAIN_SIA_PIPE		11
+#define DOMAIN_SGA		12
+#define DOMAIN_B2R2_MCDE	13
+#define DOMAIN_ESRAM_12		14
+#define DOMAIN_ESRAM_34		15
 
 /* Number of PM domains. */
-#define NR_DOMAINS		(DOMAIN_VAPE + 1)
+#define NR_DOMAINS		(DOMAIN_ESRAM_34 + 1)

In a separate commit, instead you need to drop NR_DOMAINS and move them to driver. If this changes, then it is not ABI. We did similarly for many clock bindings/drivers.

Best regards,
Krzysztof

author maintainer
#6 lore raw

PATCH 3/11 pmdomain: st: ux500: Implement more power domains

In reply to Linus Walleij

This starts to implement the power domains that are just skeleton implementations right now.

---
 drivers/pmdomain/st/ste-ux500-pm-domain.c | 125 +++++++++++++++++++++++++++++-
 1 file changed, 124 insertions(+), 1 deletion(-)
drivers/pmdomain/st/ste-ux500-pm-domain.c +124 -1
index 6896cb4a7b71..723001004690 100644
@@ -41,14 +41,137 @@ static int pd_power_on(struct generic_pm_domain *domain)
 	return 0;
 }
 
+/*
+ * Apart from these voltage domains there is also VSAFE which is always
+ * on. Vape_esram0_pwr for eSRAM0 is connected to VSAFE.
+ */
 static struct generic_pm_domain ux500_pm_domain_vape = {
-	.name = "VAPE",
+	/* Vape_pwr */
+	.name = "VAPE",  /* 0.95 .. 1.20 V */
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_varm = {
+	.name = "VARM",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_vmodem = {
+	.name = "VMODEM",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_vpll = {
+	.name = "VPLL", /* 1.8 V */
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+/*
+ * CHECKME: as these are used directly by peripherals as regulators,
+ * perhaps they should stay in the regulator subsystem?
+ */
+static struct generic_pm_domain ux500_pm_domain_vsmps1 = {
+	.name = "VSMPS1", /* Also called VIO (1.2V) */
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_vsmps2 = {
+	.name = "VSMPS2", /* Also called VIO (1.8V) */
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_vsmps3 = {
+	.name = "VSMPS3",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_vrf1 = {
+	.name = "VRF1",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+/* The following are technically children of VAPE */
+static struct generic_pm_domain ux500_pm_domain_sva_mmdsp = {
+	/* Vape_SVA_MMDSP_pwr */
+	.name = "SVA_MMDSP",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_sva_pipe = {
+	/* Vape_SVA_pwr */
+	.name = "SVA_PIPE",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_sia_mmdsp = {
+	/* Vape_SIA_MMDSP_pwr */
+	.name = "SIA_MMDSP",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_sia_pipe = {
+	/* Vape_SIA_pwr */
+	.name = "SIA_PIPE",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_sga = {
+	/* Vape_SGA_pwr */
+	.name = "SGA",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_b2r2_mcde = {
+	/* Vape_DSS_pwr DSS (display subsystem) */
+	.name = "B2R2_MCDE",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_esram_12 = {
+	/* Vape_esram0_pwr, Vape_esram1_pwr */
+	.name = "ESRAM_12",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_esram_34 = {
+	/* Vape_esram3_pwr, Vape_esram4_pwr */
+	.name = "ESRAM_34",
 	.power_off = pd_power_off,
 	.power_on = pd_power_on,
 };
 
 static struct generic_pm_domain *ux500_pm_domains[NR_DOMAINS] = {
 	[DOMAIN_VAPE] = &ux500_pm_domain_vape,
+	[DOMAIN_VARM] = &ux500_pm_domain_varm,
+	[DOMAIN_VMODEM] = &ux500_pm_domain_vmodem,
+	[DOMAIN_VPLL] = &ux500_pm_domain_vpll,
+	[DOMAIN_VSMPS1] = &ux500_pm_domain_vsmps1,
+	[DOMAIN_VSMPS2] = &ux500_pm_domain_vsmps2,
+	[DOMAIN_VSMPS3] = &ux500_pm_domain_vsmps3,
+	[DOMAIN_VRF1] = &ux500_pm_domain_vrf1,
+	[DOMAIN_SVA_MMDSP] = &ux500_pm_domain_sva_mmdsp,
+	[DOMAIN_SVA_PIPE] = &ux500_pm_domain_sva_pipe,
+	[DOMAIN_SIA_MMDSP] = &ux500_pm_domain_sia_mmdsp,
+	[DOMAIN_SIA_PIPE] = &ux500_pm_domain_sia_pipe,
+	[DOMAIN_SGA] = &ux500_pm_domain_sga,
+	[DOMAIN_B2R2_MCDE] = &ux500_pm_domain_b2r2_mcde,
+	[DOMAIN_ESRAM_12] = &ux500_pm_domain_esram_12,
+	[DOMAIN_ESRAM_34] = &ux500_pm_domain_esram_34,
 };
 
 static const struct of_device_id ux500_pm_domain_matches[] = {
Signature · 1 line
2.54.0
#7 lore raw

Re: [PATCH 03/11] pmdomain: st: ux500: Implement more power domains

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The comment regarding Vape_esram0_pwr contradicts the implementation of ux500_pm_domain_esram_12. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The comment regarding Vape_esram0_pwr contradicts the implementation of ux500_pm_domain_esram_12. --

commit e7c9ddf5e852fa7ba6bbf083dd8b845efaaf86e5
Author: Linus Walleij <[email protected]>

pmdomain: st: ux500: Implement more power domains

This starts to implement the power domains that are just skeleton implementations right now.

Quoted 13 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +4 -0
index 6896cb4a7b716..7230010046908 100644
@@ -41,14 +41,137 @@ static int pd_power_on(struct generic_pm_domain *domain)
 	return 0;
 }
 
+/*
+ * Apart from these voltage domains there is also VSAFE which is always
+ * on. Vape_esram0_pwr for eSRAM0 is connected to VSAFE.
+ */
 static struct generic_pm_domain ux500_pm_domain_vape = {

[ ... ]

drivers/pmdomain/st/ste-ux500-pm-domain.c static int pd_power_on(struct generic_pm_domain *domain) · line 146

Quoted 10 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +10 -0
+static struct generic_pm_domain ux500_pm_domain_b2r2_mcde = {
+	/* Vape_DSS_pwr DSS (display subsystem) */
+	.name = "B2R2_MCDE",
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
+
+static struct generic_pm_domain ux500_pm_domain_esram_12 = {
+	/* Vape_esram0_pwr, Vape_esram1_pwr */
+	.name = "ESRAM_12",

[Severity: Low]
Is this comment accurate? An earlier comment states that Vape_esram0_pwr for eSRAM0 is connected to the always-on VSAFE domain, but it is listed here as part of the switchable ESRAM_12 power domain. Should this comment refer to Vape_esram1_pwr and Vape_esram2_pwr instead?

Quoted 3 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +3 -0
+	.power_off = pd_power_off,
+	.power_on = pd_power_on,
+};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author maintainer
#8 lore raw

PATCH 4/11 ARM: dts: ux500: Rename power domains node

In reply to Linus Walleij

This matches the naming used in the binding document Documentation/devicetree/bindings/power/power-domain.yaml It's most logical to call it a power controller.

---
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -1
index 0f87abeddc33..d76a65da7011 100644
@@ -343,7 +343,7 @@ pmu {
 			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
-		pm_domains: pm_domains0 {
+		pm_domains: power-controller {
 			compatible = "stericsson,ux500-pm-domains";
 			#power-domain-cells = <1>;
 		};
Signature · 1 line
2.54.0
author maintainer
#9 lore raw

PATCH 5/11 ARM: dts: ux500: Add power domains

In reply to Linus Walleij

Add the actual power domains to all the SoC peripherals.

---
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi | 58 ++++++++++++++++++++++++++++++------
 1 file changed, 49 insertions(+), 9 deletions(-)
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +49 -9
index d76a65da7011..a6fef302c994 100644
@@ -154,6 +154,7 @@ sram@40020000 {
 			reg = <0x40020000 0x40000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			power-domains = <&pm_domains DOMAIN_ESRAM_12>;
 			ranges = <0 0x40020000 0x40000>;
 		};
 		sram@40060000 {
@@ -162,6 +163,7 @@ sram@40060000 {
 			reg = <0x40060000 0x40000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+			power-domains = <&pm_domains DOMAIN_ESRAM_34>;
 			ranges = <0 0x40060000 0x40000>;
 
 			lcla: sram@20000 {
@@ -181,7 +183,7 @@ lcla: sram@20000 {
 		ptm@801ae000 {
 			compatible = "arm,coresight-etm3x", "arm,primecell";
 			reg = <0x801ae000 0x1000>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&prcmu_clk PRCMU_APETRACECLK>, <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "apb_pclk", "atclk";
 			cpu = <&CPU0>;
@@ -197,7 +199,7 @@ ptm0_out_port: endpoint {
 		ptm@801af000 {
 			compatible = "arm,coresight-etm3x", "arm,primecell";
 			reg = <0x801af000 0x1000>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&prcmu_clk PRCMU_APETRACECLK>, <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "apb_pclk", "atclk";
 			cpu = <&CPU1>;
@@ -213,7 +215,7 @@ ptm1_out_port: endpoint {
 		funnel@801a6000 {
 			compatible = "arm,coresight-dynamic-funnel", "arm,primecell";
 			reg = <0x801a6000 0x1000>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&prcmu_clk PRCMU_APETRACECLK>, <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "apb_pclk", "atclk";
 			out-ports {
@@ -249,6 +251,7 @@ replicator {
 			compatible = "arm,coresight-static-replicator";
 			clocks = <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "atclk";
+			power-domains = <&pm_domains DOMAIN_VARM>;
 
 			out-ports {
 				#address-cells = <1>;
@@ -280,7 +283,7 @@ replicator_in_port0: endpoint {
 		tpiu@80190000 {
 			compatible = "arm,coresight-tpiu", "arm,primecell";
 			reg = <0x80190000 0x1000>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&prcmu_clk PRCMU_APETRACECLK>, <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "apb_pclk", "atclk";
 			in-ports {
@@ -295,7 +298,7 @@ tpiu_in_port: endpoint {
 		etb@801a4000 {
 			compatible = "arm,coresight-etb10", "arm,primecell";
 			reg = <0x801a4000 0x1000>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&prcmu_clk PRCMU_APETRACECLK>, <&prcmu_clk PRCMU_APEATCLK>;
 			clock-names = "apb_pclk", "atclk";
 			in-ports {
@@ -314,11 +317,13 @@ intc: interrupt-controller@a0411000 {
 			interrupt-controller;
 			reg = <0xa0411000 0x1000>,
 			      <0xa0410100 0x100>;
+			power-domains = <&pm_domains DOMAIN_VARM>;
 		};
 
 		scu@a0410000 {
 			compatible = "arm,cortex-a9-scu";
 			reg = <0xa0410000 0x100>;
+			power-domains = <&pm_domains DOMAIN_VARM>;
 		};
 
 		/*
@@ -326,6 +331,7 @@ scu@a0410000 {
 		 * and various things like spin tables
 		 */
 		backupram@80150000 {
+			/* This memory is in the VSAFE (always on) power domain */
 			compatible = "ste,dbx500-backupram";
 			reg = <0x80150000 0x2000>;
 		};
@@ -334,6 +340,7 @@ L2: cache-controller {
 			compatible = "arm,pl310-cache";
 			reg = <0xa0412000 0x1000>;
 			interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			cache-unified;
 			cache-level = <2>;
 		};
@@ -341,6 +348,7 @@ L2: cache-controller {
 		pmu {
 			compatible = "arm,cortex-a9-pmu";
 			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pm_domains DOMAIN_VARM>;
 		};
 
 		pm_domains: power-controller {
@@ -357,6 +365,7 @@ clocks {
 			reg = <0x8012f000 0x1000>, <0x8011f000 0x1000>,
 			    <0x8000f000 0x1000>, <0xa03ff000 0x1000>,
 			    <0xa03cf000 0x1000>;
+			power-domains = <&pm_domains DOMAIN_VPLL>; /* CHECKME: correct domain? */
 
 			prcmu_clk: prcmu-clock {
 				#clock-cells = <1>;
@@ -393,7 +402,7 @@ mtu@a03c6000 {
 			compatible = "st,nomadik-mtu";
 			reg = <0xa03c6000 0x1000>;
 			interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
-
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 			clocks = <&prcmu_clk PRCMU_TIMCLK>, <&prcc_pclk 6 6>;
 			clock-names = "timclk", "apb_pclk";
 		};
@@ -402,7 +411,7 @@ timer@a0410600 {
 			compatible = "arm,cortex-a9-twd-timer";
 			reg = <0xa0410600 0x20>;
 			interrupts = <GIC_PPI 13 (GIC_CPU_MASK_RAW(3) | IRQ_TYPE_LEVEL_HIGH)>;
-
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&smp_twd_clk>;
 		};
 
@@ -410,14 +419,15 @@ watchdog@a0410620 {
 			compatible = "arm,cortex-a9-twd-wdt";
 			reg = <0xa0410620 0x20>;
 			interrupts = <GIC_PPI 14 (GIC_CPU_MASK_RAW(3) | IRQ_TYPE_LEVEL_HIGH)>;
+			power-domains = <&pm_domains DOMAIN_VARM>;
 			clocks = <&smp_twd_clk>;
 		};
 
 		rtc@80154000 {
+			/* This peripheral is in the VSAFE (always on) power domain */
 			compatible = "arm,pl031", "arm,primecell";
 			reg = <0x80154000 0x1000>;
 			interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
-
 			clocks = <&rtc_clk>;
 			clock-names = "apb_pclk";
 		};
@@ -435,6 +445,7 @@ gpio0: gpio@8012e000 {
 			gpio-bank = <0>;
 			gpio-ranges = <&pinctrl 0 0 32>;
 			clocks = <&prcc_pclk 1 9>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio1: gpio@8012e080 {
@@ -450,6 +461,7 @@ gpio1: gpio@8012e080 {
 			gpio-bank = <1>;
 			gpio-ranges = <&pinctrl 0 32 5>;
 			clocks = <&prcc_pclk 1 9>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio2: gpio@8000e000 {
@@ -465,6 +477,7 @@ gpio2: gpio@8000e000 {
 			gpio-bank = <2>;
 			gpio-ranges = <&pinctrl 0 64 32>;
 			clocks = <&prcc_pclk 3 8>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio3: gpio@8000e080 {
@@ -480,6 +493,7 @@ gpio3: gpio@8000e080 {
 			gpio-bank = <3>;
 			gpio-ranges = <&pinctrl 0 96 2>;
 			clocks = <&prcc_pclk 3 8>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio4: gpio@8000e100 {
@@ -495,6 +509,7 @@ gpio4: gpio@8000e100 {
 			gpio-bank = <4>;
 			gpio-ranges = <&pinctrl 0 128 32>;
 			clocks = <&prcc_pclk 3 8>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio5: gpio@8000e180 {
@@ -510,6 +525,7 @@ gpio5: gpio@8000e180 {
 			gpio-bank = <5>;
 			gpio-ranges = <&pinctrl 0 160 12>;
 			clocks = <&prcc_pclk 3 8>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio6: gpio@8011e000 {
@@ -525,6 +541,7 @@ gpio6: gpio@8011e000 {
 			gpio-bank = <6>;
 			gpio-ranges = <&pinctrl 0 192 32>;
 			clocks = <&prcc_pclk 2 11>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio7: gpio@8011e080 {
@@ -540,6 +557,7 @@ gpio7: gpio@8011e080 {
 			gpio-bank = <7>;
 			gpio-ranges = <&pinctrl 0 224 7>;
 			clocks = <&prcc_pclk 2 11>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		gpio8: gpio@a03fe000 {
@@ -555,6 +573,7 @@ gpio8: gpio@a03fe000 {
 			gpio-bank = <8>;
 			gpio-ranges = <&pinctrl 0 256 12>;
 			clocks = <&prcc_pclk 5 1>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		pinctrl: pinctrl {
@@ -570,6 +589,7 @@ usb_per5@a03e0000 {
 			reg = <0xa03e0000 0x10000>;
 			interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
 			interrupt-names = "mc";
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			dr_mode = "otg";
 
@@ -613,9 +633,11 @@ dma: dma-controller@801C0000 {
 			memcpy-channels = <56 57 58 59 60>;
 
 			clocks = <&prcmu_clk PRCMU_DMACLK>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		prcmu: prcmu@80157000 {
+			/* This peripheral is in the VSAFE (always on) power domain */
 			compatible = "stericsson,db8500-prcmu", "syscon";
 			reg = <0x80157000 0x2000>, <0x801b0000 0x8000>, <0x801b8000 0x1000>;
 			reg-names = "prcmu", "prcmu-tcpm", "prcmu-tcdm";
@@ -641,6 +663,10 @@ thermal: thermal@801573c0 {
 				#thermal-sensor-cells = <0>;
 			};
 
+			/*
+			 * TODO: Delete these bogus regulators and replace with power
+			 * domains.
+			 */
 			db8500-prcmu-regulators {
 				compatible = "stericsson,db8500-prcmu-regulator";
 
@@ -932,6 +958,7 @@ serial0: serial@80120000 {
 
 			clocks = <&prcc_kclk 1 0>, <&prcc_pclk 1 0>;
 			clock-names = "uart", "apb_pclk";
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 			resets = <&prcc_reset DB8500_PRCC_1 DB8500_PRCC_1_RESET_UART0>;
 
 			status = "disabled";
@@ -948,6 +975,7 @@ serial1: serial@80121000 {
 
 			clocks = <&prcc_kclk 1 1>, <&prcc_pclk 1 1>;
 			clock-names = "uart", "apb_pclk";
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 			resets = <&prcc_reset DB8500_PRCC_1 DB8500_PRCC_1_RESET_UART1>;
 
 			status = "disabled";
@@ -964,6 +992,7 @@ serial2: serial@80007000 {
 
 			clocks = <&prcc_kclk 3 6>, <&prcc_pclk 3 6>;
 			clock-names = "uart", "apb_pclk";
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 			resets = <&prcc_reset DB8500_PRCC_3 DB8500_PRCC_3_RESET_UART2>;
 
 			status = "disabled";
@@ -1080,7 +1109,9 @@ msp0: msp@80123000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80123000 0x1000>;
 			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+			/* TODO: delete and replace with power-domain handling */
 			v-ape-supply = <&db8500_vape_reg>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			dmas = <&dma 31 0 0x12>, /* Logical - DevToMem - HighPrio */
 			       <&dma 31 0 0x10>; /* Logical - MemToDev - HighPrio */
@@ -1097,7 +1128,9 @@ msp1: msp@80124000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80124000 0x1000>;
 			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+			/* TODO: delete and replace with power-domain handling */
 			v-ape-supply = <&db8500_vape_reg>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			/* This DMA channel only exist on DB8500 v1 */
 			dmas = <&dma 30 0 0x10>; /* Logical - MemToDev - HighPrio */
@@ -1115,7 +1148,9 @@ msp2: msp@80117000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80117000 0x1000>;
 			interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+			/* TODO: delete and replace with power-domain handling */
 			v-ape-supply = <&db8500_vape_reg>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			dmas = <&dma 14 0 0x12>, /* Logical  - DevToMem - HighPrio */
 			       <&dma 14 1 0x19>; /* Physical Chan 1 - MemToDev
@@ -1133,7 +1168,9 @@ msp3: msp@80125000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80125000 0x1000>;
 			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+			/* TODO: delete and replace with power-domain handling */
 			v-ape-supply = <&db8500_vape_reg>;
+			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			/* This DMA channel only exist on DB8500 v2 */
 			dmas = <&dma 30 0 0x12>; /* Logical - DevToMem - HighPrio */
@@ -1175,14 +1212,17 @@ gpu@a0300000 {
 					  "combined";
 			clocks = <&prcmu_clk PRCMU_ACLK>, <&prcmu_clk PRCMU_SGACLK>;
 			clock-names = "bus", "core";
+			power-domains = <&pm_domains DOMAIN_SGA>;
+			/* TODO: delete and replace with power-domain handling */
 			mali-supply = <&db8500_sga_reg>;
-			power-domains = <&pm_domains DOMAIN_VAPE>;
 		};
 
 		mcde@a0350000 {
 			compatible = "ste,mcde";
 			reg = <0xa0350000 0x1000>;
 			interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pm_domains DOMAIN_B2R2_MCDE>;
+			/* TODO: delete and replace with power-domain handling */
 			epod-supply = <&db8500_b2r2_mcde_reg>;
 			clocks = <&prcmu_clk PRCMU_MCDECLK>, /* Main MCDE clock */
 				 <&prcmu_clk PRCMU_LCDCLK>, /* LCD clock */
Signature · 1 line
2.54.0
#10 lore raw

Re: [PATCH 05/11] ARM: dts: ux500: Add power domains

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The `clocks` node is incorrectly assigned to `DOMAIN_VPLL` instead of `DOMAIN_VAPE` and includes…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The clocks node is incorrectly assigned to DOMAIN_VPLL instead of DOMAIN_VAPE and includes an unresolved CHECKME comment.
- [Medium] Adding power-domains to nodes whose binding schemas do not allow it will cause dtbs_check validation errors. --

commit 57cdb12b349af07637860b10a8f8232b9e2930bc
Author: Linus Walleij <[email protected]>

ARM: dts: ux500: Add power domains

Add the actual power domains to all the SoC peripherals.

Quoted 4 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -0
index d76a65da70111..a6fef302c994e 100644

[ ... ]

arch/arm/boot/dts/st/ste-dbx5x0.dtsi L2: cache-controller { · line 343

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -334,6 +340,7 @@ L2: cache-controller {
 			compatible = "arm,pl310-cache";
 			reg = <0xa0412000 0x1000>;
 			interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+			power-domains = <&pm_domains DOMAIN_VARM>;

[Severity: Medium]
Will adding power-domains here cause dtbs_check validation errors?

The l2c2x0.yaml binding schema (along with others modified in this patch like arm/pmu.yaml, stericsson,u8500-clks.yaml, arm,twd-timer.yaml, arm,twd-wdt.yaml, and ste,mcde.yaml) does not include power-domains in its list of allowed properties.

Do these bindings need to be updated to document the power-domains capability before it can be used?

Quoted 3 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -0
 			cache-unified;
 			cache-level = <2>;
 		};

[ ... ]

arch/arm/boot/dts/st/ste-dbx5x0.dtsi clocks { · line 368

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -357,6 +365,7 @@ clocks {
 			reg = <0x8012f000 0x1000>, <0x8011f000 0x1000>,
 			    <0x8000f000 0x1000>, <0xa03ff000 0x1000>,
 			    <0xa03cf000 0x1000>;
+			power-domains = <&pm_domains DOMAIN_VPLL>; /* CHECKME: correct domain? */

[Severity: High]
Should this be DOMAIN_VAPE instead of DOMAIN_VPLL?

The PRCC registers mapped here for peripheral groups 1, 2, 3, 5, and 6 reside in the VAPE power domain alongside the peripherals they clock.

If the clock controller is assigned to DOMAIN_VPLL, the power domain framework won't guarantee DOMAIN_VAPE is powered on when accessing these registers, which could cause a synchronous external abort.

Also, is the CHECKME comment intended to be resolved before merging?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
author maintainer
#11 lore raw

PATCH 6/11 pmdomain: st: ux500: Control DB8500 EPODs

In reply to Linus Walleij

Move the DB8500 EPOD state handling into the Ux500 power-domain driver.

Keep the old regulator driver mutually exclusive with the pmdomain driver.

Assisted-by Codex:gpt-5-5
---
 arch/arm/mach-ux500/Kconfig               |   2 +-
 drivers/pmdomain/st/ste-ux500-pm-domain.c | 380 ++++++++++++++++++++++--------
 drivers/regulator/Kconfig                 |   1 +
 3 files changed, 282 insertions(+), 101 deletions(-)
arch/arm/mach-ux500/Kconfig +1 -1
index c18def269137..56636c993f49 100644
@@ -26,7 +26,7 @@ menuconfig ARCH_U8500
 	select PL310_ERRATA_753970 if CACHE_L2X0
 	select PM_GENERIC_DOMAINS if PM
 	select REGULATOR
-	select REGULATOR_DB8500_PRCMU
+	select UX500_PM_DOMAIN
 	select REGULATOR_FIXED_VOLTAGE
 	select SOC_BUS
 	select RESET_CONTROLLER
drivers/pmdomain/st/ste-ux500-pm-domain.c +280 -100

470 lines not on this page · raw message

drivers/regulator/Kconfig +1 -0
index 87554ab92801..35d1b191462c 100644
@@ -414,6 +414,7 @@ config REGULATOR_DBX500_PRCMU
 config REGULATOR_DB8500_PRCMU
 	bool "ST-Ericsson DB8500 Voltage Domain Regulators"
 	depends on MFD_DB8500_PRCMU
+	depends on !UX500_PM_DOMAIN
 	select REGULATOR_DBX500_PRCMU
 	help
 	  This driver supports the voltage domain regulators controlled by the
Signature · 1 line
2.54.0
#12 lore raw

Re: [PATCH 06/11] pmdomain: st: ux500: Control DB8500 EPODs

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Probe error path leaks dynamically allocated memory, fails to unregister PM domains, and lacks…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Probe error path leaks dynamically allocated memory, fails to unregister PM domains, and lacks rollback for partially added subdomains.
- [High] Hardware RAM retention capabilities are entirely lost, rendering related state handling logic dead code.
- [Medium] Bisection breakage: Disabling REGULATOR_DB8500_PRCMU causes consumer devices expecting v-ape-supply to permanently fail to probe. --

commit 26ccd884add2c876cdf4c876688df7b868a2fa06
Author: Linus Walleij <[email protected]>

pmdomain: st: ux500: Control DB8500 EPODs

Move the DB8500 EPOD state handling into the Ux500 power-domain driver. Keep the old regulator driver mutually exclusive with the pmdomain driver.

Quoted 3 lines
arch/arm/mach-ux500/Kconfig +0 -0

[ ... ]

arch/arm/mach-ux500/Kconfig menuconfig ARCH_U8500 · line 32

Quoted 9 lines
arch/arm/mach-ux500/Kconfig +1 -1
@@ -26,7 +26,7 @@ menuconfig ARCH_U8500
 	select PL310_ERRATA_753970 if CACHE_L2X0
 	select PM_GENERIC_DOMAINS if PM
 	select REGULATOR
-	select REGULATOR_DB8500_PRCMU
+	select UX500_PM_DOMAIN
 	select REGULATOR_FIXED_VOLTAGE
 	select SOC_BUS
 	select RESET_CONTROLLER

[Severity: Medium]
Does this break git bisect by disabling the regulator provider before consumer devices are updated?

Consumer devices depending on v-ape-supply may receive -EPROBE_DEFER indefinitely if the regulator driver is disabled here. I see this is fixed in a later commit ("regulator: db8500: Add power domain regulators"), but is it possible to reorder the changes to avoid breaking bisection?

Quoted 3 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +0 -0

[ ... ]

Quoted 4 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +4 -0
+static int disable_epod(u16 epod_id, bool ramret)
+{
+	int ret;
+

drivers/pmdomain/st/ste-ux500-pm-domain.c line 94

Quoted 10 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +10 -0
+	if (ramret) {
+		if (!epod_on[epod_id]) {
+			ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
+			if (ret < 0)
+				return ret;
+		}
+		epod_ramret[epod_id] = false;
+	} else {
+		if (epod_ramret[epod_id]) {
+			ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);

[Severity: High]
Is the hardware RAM retention capability effectively lost here?

The struct dbx500_powerdomain_info defines is_ramret, but none of the newly defined domains initialize it to true (e.g., for SVAMMDSP or SIAMMDSP). Because ramret is always false, epod_ramret[] is never set, making the EPOD_STATE_RAMRET state unreachable. Does this dead code need to be activated by setting is_ramret on the appropriate domains?

[ ... ]

Quoted 9 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +2 -0
+static int ux500_pm_domains_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct genpd_onecell_data *genpd_data;
 	int i;
+	int ret;
 
 	if (!np)
 		return -ENODEV;

[ ... ]

drivers/pmdomain/st/ste-ux500-pm-domain.c static int ux500_pm_domains_probe(struct platform_device *pdev) · line 379

Quoted 7 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +5 -1
 	for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i)
-		pm_genpd_init(ux500_pm_domains[i], NULL, false);
+		pm_genpd_init(ux500_pm_domains[i], NULL, true);
+
+	ret = ux500_pm_domains_add_subdomains();
+	if (ret)
+		return ret;

[Severity: High]
Does this error path leak memory and leave the power domains registered?

If ux500_pm_domains_add_subdomains() fails, it returns an error directly. This leaves genpd_data allocated and the domains initialized and linked into the global gpd_list via pm_genpd_init().

If a driver unbind/rebind occurs, could INIT_LIST_HEAD be invoked on elements already in the list, potentially corrupting the doubly linked list and causing a kernel panic?

Should pm_genpd_remove() be called for initialized domains, and the added subdomains be rolled back with pm_genpd_remove_subdomain() before returning?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#13 lore raw

Re: [PATCH 06/11] pmdomain: st: ux500: Control DB8500 EPODs

In reply to Linus Walleij
Quoted 83 lines · Linus Walleij

Move the DB8500 EPOD state handling into the Ux500 power-domain driver.

Keep the old regulator driver mutually exclusive with the pmdomain driver.

Assisted-by Codex:gpt-5-5
---
 arch/arm/mach-ux500/Kconfig               |   2 +-
 drivers/pmdomain/st/ste-ux500-pm-domain.c | 380 ++++++++++++++++++++++--------
 drivers/regulator/Kconfig                 |   1 +
 3 files changed, 282 insertions(+), 101 deletions(-)
arch/arm/mach-ux500/Kconfig +1 -1
index c18def269137..56636c993f49 100644
@@ -26,7 +26,7 @@ menuconfig ARCH_U8500
        select PL310_ERRATA_753970 if CACHE_L2X0
        select PM_GENERIC_DOMAINS if PM
        select REGULATOR
-       select REGULATOR_DB8500_PRCMU
+       select UX500_PM_DOMAIN
        select REGULATOR_FIXED_VOLTAGE
        select SOC_BUS
        select RESET_CONTROLLER
drivers/pmdomain/st/ste-ux500-pm-domain.c +33 -7
index 723001004690..1cd5b4985db0 100644
@@ -6,172 +6,315 @@
  *
  * Implements PM domains using the generic PM domain for ux500.
  */
+#include <linux/cleanup.h>
 #include <linux/device.h>
+#include <linux/err.h>
 #include <linux/kernel.h>
+#include <linux/mfd/dbx500-prcmu.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 #include <linux/printk.h>
 #include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/of.h>
-#include <linux/pm_domain.h>
 
 #include <dt-bindings/arm/ux500_pm_domains.h>
 
-static int pd_power_off(struct generic_pm_domain *domain)
+#define UX500_EPOD_NONE                NUM_EPOD_ID
+
+/**
+ * struct dbx500_powerdomain_info - dbx500 power domain information
+ * @genpd: generic power domain
+ * @epod_id: id for EPOD (power domain)
+ * @is_ramret: RAM retention switch for EPOD (power domain)
+ * @exclude_from_power_state: exclude domain from power state count
+ */
+struct dbx500_powerdomain_info {
+       struct generic_pm_domain genpd;
+       u16 epod_id;
+       bool is_ramret;
+       bool exclude_from_power_state;
+};
+
+static DEFINE_MUTEX(ux500_pd_lock);
+static int power_state_active_cnt;
+static bool epod_on[NUM_EPOD_ID];
+static bool epod_ramret[NUM_EPOD_ID];
+
+static void power_state_active_enable(void)
+{
+       power_state_active_cnt++;
+}
+
+static int power_state_active_disable(void)
 {
-       /*
-        * Handle the gating of the PM domain regulator here.
-        *

drivers/pmdomain/st/ste-ux500-pm-domain.c line 56

Quoted 10 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +6 -4
-        * Drivers/subsystems handling devices in the PM domain needs to perform
-        * register context save/restore from their respective runtime PM
-        * callbacks, to be able to enable PM domain gating/ungating.
-        */
+       if (power_state_active_cnt <= 0) {
+               pr_err("power state: unbalanced enable/disable calls\n");
+               return -EINVAL;
+       }
+
+       power_state_active_cnt--;

The whole power_state_active_cnt thing seems to be a leftover from debug exercise, no?

At least, I can't see that it actually adds much - or maybe following patches makes use of it somehow?

Quoted 88 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +73 -8
        return 0;
 }
 
-static int pd_power_on(struct generic_pm_domain *domain)
+static int enable_epod(u16 epod_id, bool ramret)
 {
-       /*
-        * Handle the ungating of the PM domain regulator here.
-        *
-        * Drivers/subsystems handling devices in the PM domain needs to perform
-        * register context save/restore from their respective runtime PM
-        * callbacks, to be able to enable PM domain gating/ungating.
-        */
+       int ret;
+
+       if (ramret) {
+               if (!epod_on[epod_id]) {
+                       ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
+                       if (ret < 0)
+                               return ret;
+               }
+               epod_ramret[epod_id] = true;
+       } else {
+               ret = prcmu_set_epod(epod_id, EPOD_STATE_ON);
+               if (ret < 0)
+                       return ret;
+               epod_on[epod_id] = true;
+       }
+
+       return 0;
+}
+
+static int disable_epod(u16 epod_id, bool ramret)
+{
+       int ret;
+
+       if (ramret) {
+               if (!epod_on[epod_id]) {
+                       ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
+                       if (ret < 0)
+                               return ret;
+               }
+               epod_ramret[epod_id] = false;
+       } else {
+               if (epod_ramret[epod_id]) {
+                       ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
+                       if (ret < 0)
+                               return ret;
+               } else {
+                       ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
+                       if (ret < 0)
+                               return ret;
+               }
+               epod_on[epod_id] = false;
+       }
+
        return 0;
 }
 
+static int pd_power_off(struct generic_pm_domain *domain)
+{
+       struct dbx500_powerdomain_info *info =
+               container_of(domain, struct dbx500_powerdomain_info, genpd);
+       int ret = 0;
+
+       guard(mutex)(&ux500_pd_lock);
+       if (info->epod_id < NUM_EPOD_ID)
+               ret = disable_epod(info->epod_id, info->is_ramret);
+       else if (!info->exclude_from_power_state)
+               ret = power_state_active_disable();
+
+       return ret;
+}
+
+static int pd_power_on(struct generic_pm_domain *domain)
+{
+       struct dbx500_powerdomain_info *info =
+               container_of(domain, struct dbx500_powerdomain_info, genpd);
+       int ret = 0;
+
+       guard(mutex)(&ux500_pd_lock);
+       if (info->epod_id < NUM_EPOD_ID)
+               ret = enable_epod(info->epod_id, info->is_ramret);
+       else if (!info->exclude_from_power_state)
+               power_state_active_enable();
+
+       return ret;
+}

[...]

Quoted 22 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +21 -0
+static int ux500_pm_domain_add_subdomain(struct generic_pm_domain *domain)
+{
+       return pm_genpd_add_subdomain(&ux500_pm_domain_vape.genpd, domain);
+}
+
+static int ux500_pm_domains_add_subdomains(void)
+{
+       int ret;
+
+       ret = ux500_pm_domain_add_subdomain(&ux500_pm_domain_sva_mmdsp.genpd);
+       if (ret)
+               return ret;
+
+       ret = ux500_pm_domain_add_subdomain(&ux500_pm_domain_sva_pipe.genpd);
+       if (ret)
+               return ret;
+
+       ret = ux500_pm_domain_add_subdomain(&ux500_pm_domain_sia_mmdsp.genpd);
+       if (ret)
+               return ret;
+

drivers/pmdomain/st/ste-ux500-pm-domain.c static const struct of_device_id ux500_pm_domain_matches[] = { · line 355

Quoted 10 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +10 -0
+       ret = ux500_pm_domain_add_subdomain(&ux500_pm_domain_sia_pipe.genpd);
+       if (ret)
+               return ret;
+
+       ret = ux500_pm_domain_add_subdomain(&ux500_pm_domain_sga.genpd);
+       if (ret)
+               return ret;
+
+       return ux500_pm_domain_add_subdomain(&ux500_pm_domain_b2r2_mcde.genpd);
+}

We recently added a generic "power-domains-child-ids" DT property, that allows us to describe child power-domains for these kinds of cases.

Moreover, we have of_genpd_add|remove_child_ids() to easily hook them up when probing. I suggest we use that here as well.

Quoted 37 lines
drivers/pmdomain/st/ste-ux500-pm-domain.c +7 -1
+
 static int ux500_pm_domains_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct genpd_onecell_data *genpd_data;
        int i;
+       int ret;
 
        if (!np)
                return -ENODEV;
@@ -196,7 +372,11 @@ static int ux500_pm_domains_probe(struct platform_device *pdev)
        genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains);
 
        for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i)
-               pm_genpd_init(ux500_pm_domains[i], NULL, false);
+               pm_genpd_init(ux500_pm_domains[i], NULL, true);
+
+       ret = ux500_pm_domains_add_subdomains();
+       if (ret)
+               return ret;
 
        of_genpd_add_provider_onecell(np, genpd_data);
        return 0;
drivers/regulator/Kconfig +1 -1
index 87554ab92801..35d1b191462c 100644
@@ -414,6 +414,7 @@ config REGULATOR_DBX500_PRCMU
 config REGULATOR_DB8500_PRCMU
        bool "ST-Ericsson DB8500 Voltage Domain Regulators"
        depends on MFD_DB8500_PRCMU
+       depends on !UX500_PM_DOMAIN
        select REGULATOR_DBX500_PRCMU
        help
          This driver supports the voltage domain regulators controlled by the
 
--
Quoted 2 lines

2.54.0

Kind regards
Uffe

author maintainer
#14 lore raw

PATCH 7/11 drm/mcde: Use power domain for display power

In reply to Linus Walleij

Replace explicit EPOD regulator handling with runtime PM.

Use the MCDE power domain and drop the regulator dependency.

Assisted-by Codex:gpt-5-5
---
 drivers/gpu/drm/mcde/mcde_clk_div.c |  4 +--
 drivers/gpu/drm/mcde/mcde_display.c | 11 +++----
 drivers/gpu/drm/mcde/mcde_drm.h     |  2 --
 drivers/gpu/drm/mcde/mcde_drv.c     | 63 +++++++++++--------------------------
 drivers/gpu/drm/mcde/mcde_dsi.c     |  1 -
 5 files changed, 25 insertions(+), 56 deletions(-)
drivers/gpu/drm/mcde/mcde_clk_div.c +2 -2
index 8c5af2677357..1a22e6233946 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/clk-provider.h>
 #include <linux/io.h>
-#include <linux/regulator/consumer.h>
+#include <linux/pm_runtime.h>
 
 #include "mcde_drm.h"
 #include "mcde_display_regs.h"
@@ -95,7 +95,7 @@ static unsigned long mcde_clk_div_recalc_rate(struct clk_hw *hw,
 	 * It will come up with 0 in the divider register bits, which
 	 * means "divide by 2".
 	 */
-	if (!regulator_is_enabled(mcde->epod))
+	if (!pm_runtime_active(mcde->dev))
 		return DIV_ROUND_UP_ULL(prate, 2);
 
 	cr = readl(mcde->regs + cdiv->cr);
drivers/gpu/drm/mcde/mcde_display.c +5 -6
index 257a6e84dd58..52f071bb347c 100644
@@ -7,7 +7,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-buf.h>
-#include <linux/regulator/consumer.h>
+#include <linux/pm_runtime.h>
 #include <linux/media-bus-format.h>
 
 #include <drm/drm_device.h>
@@ -1168,16 +1168,15 @@ static void mcde_display_enable(struct drm_simple_display_pipe *pipe,
 	int ret;
 
 	/* This powers up the entire MCDE block and the DSI hardware */
-	ret = regulator_enable(mcde->epod);
+	ret = pm_runtime_resume_and_get(mcde->dev);
 	if (ret) {
-		dev_err(drm->dev, "can't re-enable EPOD regulator\n");
+		dev_err(drm->dev, "can't enable MCDE power domain\n");
 		return;
 	}
 
 	dev_info(drm->dev, "enable MCDE, %d x %d format %p4cc\n",
 		 mode->hdisplay, mode->vdisplay, &format);
 
-
 	/* Clear any pending interrupts */
 	mcde_display_disable_irqs(mcde);
 	writel(0, mcde->regs + MCDE_IMSCERR);
@@ -1327,9 +1326,9 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)
 		spin_unlock_irq(&crtc->dev->event_lock);
 	}
 
-	ret = regulator_disable(mcde->epod);
+	ret = pm_runtime_put_sync_suspend(mcde->dev);
 	if (ret)
-		dev_err(drm->dev, "can't disable EPOD regulator\n");
+		dev_err(drm->dev, "can't disable MCDE power domain\n");
 	/* Make sure we are powered down (before we may power up again) */
 	usleep_range(50000, 70000);
 
drivers/gpu/drm/mcde/mcde_drm.h +0 -2
index ecb70b4b737c..d4ff7606d917 100644
@@ -91,8 +91,6 @@ struct mcde {
 	/* Locks the MCDE FIFO control register A and B */
 	spinlock_t fifo_crx1_lock;
 
-	struct regulator *epod;
-	struct regulator *vana;
 };
 
 #define to_mcde(dev) container_of(dev, struct mcde, drm)
drivers/gpu/drm/mcde/mcde_drv.c +18 -45

117 lines not on this page · raw message

drivers/gpu/drm/mcde/mcde_dsi.c +0 -1
index 47d45897ed06..e09b2d4aca0c 100644
@@ -8,7 +8,6 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-#include <linux/regulator/consumer.h>
 #include <video/mipi_display.h>
 
 #include <drm/drm_atomic_helper.h>
Signature · 1 line
2.54.0
#15 lore raw

Re: [PATCH 07/11] drm/mcde: Use power domain for display power

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Incorrect return value check for pm_runtime_put_sync_suspend(), treating success as an error.…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect return value check for pm_runtime_put_sync_suspend(), treating success as an error.
- [High] Resource leak of the main clock (mcde_clk) on the probe error path.
--

commit 1e2436e1c266a49af52c126fb77756c71e5e0e91
Author: Linus Walleij <[email protected]>

drm/mcde: Use power domain for display power

Replace explicit EPOD regulator handling with runtime PM. Use the MCDE power domain and drop the regulator dependency.

Quoted 4 lines
drivers/gpu/drm/mcde/mcde_display.c +0 -0
index 257a6e84dd583..52f071bb347c4 100644

[ ... ]

drivers/gpu/drm/mcde/mcde_display.c static void mcde_display_disable(struct drm_simple_display_pipe *pipe) · line 1331

Quoted 9 lines
drivers/gpu/drm/mcde/mcde_display.c +2 -2
@@ -1327,9 +1326,9 @@ static void mcde_display_disable(struct drm_simple_display_pipe *pipe)
 		spin_unlock_irq(&crtc->dev->event_lock);
 	}
 
-	ret = regulator_disable(mcde->epod);
+	ret = pm_runtime_put_sync_suspend(mcde->dev);
 	if (ret)
-		dev_err(drm->dev, "can't disable EPOD regulator\n");
+		dev_err(drm->dev, "can't disable MCDE power domain\n");

[Severity: High]
According to the Runtime PM API contract, pm_runtime_put_sync_suspend() returns 1 when the device is already in the RPM_SUSPENDED state. Is it intentional to treat a positive return value as an error here? If the device is already suspended, this will log a false-positive error.

Quoted 7 lines
drivers/gpu/drm/mcde/mcde_display.c +0 -0
 	/* Make sure we are powered down (before we may power up again) */
 	usleep_range(50000, 70000);
 
drivers/gpu/drm/mcde/mcde_drv.c +0 -0
index 5f2c462bad7e1..3f966cccda5a3 100644

[ ... ]

Quoted 8 lines
drivers/gpu/drm/mcde/mcde_drv.c +1 -1
@@ -412,14 +392,15 @@ static int mcde_probe(struct platform_device *pdev)
 
 	/*
 	 * Perform an invasive reset of the MCDE and all blocks by
-	 * cutting the power to the subsystem, then bring it back up
+	 * powering down the subsystem, then bring it back up
 	 * later when we enable the display as a result of
 	 * component_master_add_with_match().

drivers/gpu/drm/mcde/mcde_drv.c static int mcde_probe(struct platform_device *pdev) · line 404

Quoted 10 lines
drivers/gpu/drm/mcde/mcde_drv.c +4 -3
 	 */
-	ret = regulator_disable(mcde->epod);
+	ret = pm_runtime_put_sync_suspend(dev);
 	if (ret) {
-		dev_err(dev, "can't disable EPOD regulator\n");
-		return ret;
+		dev_err(dev, "can't disable MCDE power domain\n");
+		pm_runtime_get_noresume(dev);
+		goto clk_disable;
 	}

[Severity: High]
Does this incorrectly abort the probe sequence if the device is already suspended?

pm_runtime_put_sync_suspend() returns 1 if the device was already in the RPM_SUSPENDED state, which is a success condition, but the if (ret) check here treats it as a failure.

Quoted 2 lines
drivers/gpu/drm/mcde/mcde_drv.c +0 -0
 	/* Wait 50 ms so we are sure we cut the power */
 	usleep_range(50000, 70000);

[ ... ]

Quoted 19 lines
drivers/gpu/drm/mcde/mcde_drv.c +1 -8
@@ -428,25 +409,18 @@ static int mcde_probe(struct platform_device *pdev)
 					      match);
 	if (ret) {
 		dev_err(dev, "failed to add component master\n");
-		/*
-		 * The EPOD regulator is already disabled at this point so some
-		 * special errorpath code is needed
-		 */
-		clk_disable_unprepare(mcde->mcde_clk);
-		regulator_disable(mcde->vana);
-		return ret;
+		goto clk_disable_pm_disabled;
 	}
 
 	return 0;
 
 clk_disable:
 	clk_disable_unprepare(mcde->mcde_clk);
-regulator_off:

drivers/gpu/drm/mcde/mcde_drv.c static int mcde_probe(struct platform_device *pdev) · line 424

Quoted 10 lines
drivers/gpu/drm/mcde/mcde_drv.c +4 -4
-	regulator_disable(mcde->vana);
-regulator_epod_off:
-	regulator_disable(mcde->epod);
+pm_runtime_put:
+	pm_runtime_put_sync_suspend(dev);
+clk_disable_pm_disabled:
+	pm_runtime_disable(dev);
 	return ret;
-
 }

[Severity: High]
Does this code leak the main clock when component_master_add_with_match() fails?

The goto clk_disable_pm_disabled jump skips over the clk_disable label, so clk_disable_unprepare(mcde->mcde_clk) is never called.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
author maintainer
#16 lore raw

PATCH 8/11 dmaengine: ste_dma40: Use power domain for LCLA SRAM

In reply to Linus Walleij

Replace the LCLA ESRAM regulator with runtime PM.

Use the SRAM device that owns the ESRAM34 power domain.

Hold that domain while DMA transfers are active.

Assisted-by Codex:gpt-5-5
---
 drivers/dma/ste_dma40.c | 97 ++++++++++++++++++++++++++++---------------------
 1 file changed, 55 insertions(+), 42 deletions(-)
drivers/dma/ste_dma40.c +55 -42
index 9b803c0aec25..6ca67ec446dc 100644
@@ -21,8 +21,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_dma.h>
+#include <linux/of_platform.h>
 #include <linux/amba/bus.h>
-#include <linux/regulator/consumer.h>
 
 #include "dmaengine.h"
 #include "ste_dma40.h"
@@ -571,7 +571,8 @@ struct d40_gen_dmac {
  * to phy_chans entries.
  * @plat_data: Pointer to provided platform_data which is the driver
  * configuration.
- * @lcpa_regulator: Pointer to hold the regulator for the esram bank for lcla.
+ * @lcla_dev: SRAM device for the ESRAM bank used by LCLA.
+ * @lcla_pm_enabled: Whether runtime PM was enabled for LCLA by this driver.
  * @phy_res: Vector containing all physical channels.
  * @lcla_pool: lcla pool settings and data.
  * @lcpa_base: The virtual mapped address of LCPA.
@@ -607,7 +608,8 @@ struct d40_base {
 	struct d40_chan			**lookup_log_chans;
 	struct d40_chan			**lookup_phy_chans;
 	struct stedma40_platform_data	 *plat_data;
-	struct regulator		 *lcpa_regulator;
+	struct device			 *lcla_dev;
+	bool				  lcla_pm_enabled;
 	/* Physical half channels */
 	struct d40_phy_res		 *phy_res;
 	struct d40_lcla_pool		  lcla_pool;
@@ -628,6 +630,22 @@ static struct device *chan2dev(struct d40_chan *d40c)
 	return &d40c->chan.dev->device;
 }
 
+static void d40_transfer_runtime_get(struct d40_base *base)
+{
+	if (base->lcla_dev)
+		pm_runtime_get_sync(base->lcla_dev);
+
+	pm_runtime_get_sync(base->dev);
+}
+
+static void d40_transfer_runtime_put(struct d40_base *base)
+{
+	pm_runtime_put_autosuspend(base->dev);
+
+	if (base->lcla_dev)
+		pm_runtime_put_sync_suspend(base->lcla_dev);
+}
+
 static bool chan_is_physical(struct d40_chan *chan)
 {
 	return chan->log_num == D40_PHY_CHAN;
@@ -1516,7 +1534,7 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)
 	if (d40d != NULL) {
 		if (!d40c->busy) {
 			d40c->busy = true;
-			pm_runtime_get_sync(d40c->base->dev);
+			d40_transfer_runtime_get(d40c->base);
 		}
 
 		/* Remove from queue */
@@ -1579,7 +1597,7 @@ static void dma_tc_handle(struct d40_chan *d40c)
 		if (d40_queue_start(d40c) == NULL) {
 			d40c->busy = false;
 
-			pm_runtime_put_autosuspend(d40c->base->dev);
+			d40_transfer_runtime_put(d40c->base);
 		}
 
 		d40_desc_remove(d40d);
@@ -2052,7 +2070,7 @@ static int d40_free_dma(struct d40_chan *d40c)
 		d40c->base->lookup_phy_chans[phy->num] = NULL;
 
 	if (d40c->busy)
-		pm_runtime_put_autosuspend(d40c->base->dev);
+		d40_transfer_runtime_put(d40c->base);
 
 	d40c->busy = false;
 	d40c->phy_chan = NULL;
@@ -2613,7 +2631,7 @@ static int d40_terminate_all(struct dma_chan *chan)
 	d40_term_all(d40c);
 	pm_runtime_put_autosuspend(d40c->base->dev);
 	if (d40c->busy)
-		pm_runtime_put_autosuspend(d40c->base->dev);
+		d40_transfer_runtime_put(d40c->base);
 	d40c->busy = false;
 
 	spin_unlock_irqrestore(&d40c->lock, flags);
@@ -2916,29 +2934,11 @@ static int __init d40_dmaengine_init(struct d40_base *base,
 #ifdef CONFIG_PM_SLEEP
 static int dma40_suspend(struct device *dev)
 {
-	struct d40_base *base = dev_get_drvdata(dev);
-	int ret;
-
-	ret = pm_runtime_force_suspend(dev);
-	if (ret)
-		return ret;
-
-	if (base->lcpa_regulator)
-		ret = regulator_disable(base->lcpa_regulator);
-	return ret;
+	return pm_runtime_force_suspend(dev);
 }
 
 static int dma40_resume(struct device *dev)
 {
-	struct d40_base *base = dev_get_drvdata(dev);
-	int ret = 0;
-
-	if (base->lcpa_regulator) {
-		ret = regulator_enable(base->lcpa_regulator);
-		if (ret)
-			return ret;
-	}
-
 	return pm_runtime_force_resume(dev);
 }
 #endif
@@ -3492,7 +3492,10 @@ static int __init d40_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *np_lcpa;
+	struct device_node *np_lcla;
+	struct device_node *np_lcla_parent;
 	struct d40_base *base;
+	struct platform_device *lcla_pdev;
 	struct resource *res;
 	struct resource res_lcpa;
 	int num_reserved_chans;
@@ -3590,23 +3593,32 @@ static int __init d40_probe(struct platform_device *pdev)
 	}
 
 	if (base->plat_data->use_esram_lcla) {
+		np_lcla = of_parse_phandle(np, "sram", 1);
+		if (!np_lcla) {
+			dev_err(dev, "no LCLA SRAM node\n");
+			ret = -EINVAL;
+			goto destroy_cache;
+		}
 
-		base->lcpa_regulator = regulator_get(base->dev, "lcla_esram");
-		if (IS_ERR(base->lcpa_regulator)) {
-			d40_err(dev, "Failed to get lcpa_regulator\n");
-			ret = PTR_ERR(base->lcpa_regulator);
-			base->lcpa_regulator = NULL;
+		np_lcla_parent = of_get_parent(np_lcla);
+		of_node_put(np_lcla);
+		if (!np_lcla_parent) {
+			dev_err(dev, "no LCLA SRAM parent node\n");
+			ret = -EINVAL;
 			goto destroy_cache;
 		}
 
-		ret = regulator_enable(base->lcpa_regulator);
-		if (ret) {
-			d40_err(dev,
-				"Failed to enable lcpa_regulator\n");
-			regulator_put(base->lcpa_regulator);
-			base->lcpa_regulator = NULL;
+		lcla_pdev = of_find_device_by_node(np_lcla_parent);
+		of_node_put(np_lcla_parent);
+		if (!lcla_pdev) {
+			ret = -EPROBE_DEFER;
 			goto destroy_cache;
 		}
+		base->lcla_dev = &lcla_pdev->dev;
+		if (!pm_runtime_enabled(base->lcla_dev)) {
+			pm_runtime_enable(base->lcla_dev);
+			base->lcla_pm_enabled = true;
+		}
 	}
 
 	writel_relaxed(D40_DREG_GCC_ENABLE_ALL, base->virtbase + D40_DREG_GCC);
@@ -3642,16 +3654,17 @@ static int __init d40_probe(struct platform_device *pdev)
 				 SZ_1K * base->num_phy_chans,
 				 DMA_TO_DEVICE);
 
-	if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)
+	if (!base->lcla_pool.base_unaligned && base->lcla_pool.base &&
+	    base->lcla_pool.pages)
 		free_pages((unsigned long)base->lcla_pool.base,
 			   base->lcla_pool.pages);
 
 	kfree(base->lcla_pool.base_unaligned);
 
-	if (base->lcpa_regulator) {
-		regulator_disable(base->lcpa_regulator);
-		regulator_put(base->lcpa_regulator);
-	}
+	if (base->lcla_pm_enabled)
+		pm_runtime_disable(base->lcla_dev);
+	if (base->lcla_dev)
+		put_device(base->lcla_dev);
 	pm_runtime_disable(base->dev);
 
  report_failure:
Signature · 1 line
2.54.0
#17 lore raw

Re: [PATCH 08/11] dmaengine: ste_dma40: Use power domain for LCLA SRAM

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:

New issues:
- [High] Calling synchronous runtime PM functions on a non-IRQ-safe device from atomic context.
- [High] Forcing immediate synchronous suspend of the SRAM PM domain defeats the DMA controller's autosuspend design and causes severe performance degradation.
- [High] The consumer driver forcefully enables runtime PM on a supplier device, risking unbalanced PM states.
- [High] Missing device link between the DMA controller and the external LCLA SRAM device, leading to system suspend ordering races.

Pre-existing issues:
- [Critical] Validation logic incorrectly bounds dev_type, leading to a critical out-of-bounds pointer write in lookup_log_chans.
- [High] An early probe failure unconditionally calls pm_runtime_disable(base->dev), permanently disabling runtime PM on subsequent probe retries.
- [High] Missing free_irq() in the error paths of d40_probe().
- [High] Unchecked return value of d40_queue_start() leaks runtime PM reference and permanently hangs the channel.
--

commit ee86cbf896c47f035fc9bd6d0f30e49d8a83841a
Author: Linus Walleij <[email protected]>

dmaengine: ste_dma40: Use power domain for LCLA SRAM

This patch replaces the LCLA ESRAM regulator with runtime PM support. It fetches the SRAM device for the ESRAM34 power domain from the device tree. The driver then holds a runtime PM reference on this domain while DMA transfers are active.

Quoted 4 lines
drivers/dma/ste_dma40.c +0 -0
index 9b803c0aec254..6ca67ec446dc5 100644

[ ... ]

drivers/dma/ste_dma40.c static struct device *chan2dev(struct d40_chan *d40c) · line 636

Quoted 8 lines
drivers/dma/ste_dma40.c +4 -0
@@ -628,6 +630,22 @@ static struct device *chan2dev(struct d40_chan *d40c)
 	return &d40c->chan.dev->device;
 }
 
+static void d40_transfer_runtime_get(struct d40_base *base)
+{
+	if (base->lcla_dev)
+		pm_runtime_get_sync(base->lcla_dev);

[Severity: High]
Does this code call a blocking runtime PM function on an external SRAM device from an atomic context?

d40_transfer_runtime_get() and d40_transfer_runtime_put() are called from d40_queue_start() and dma_tc_handle(). Both of these execute under the d40c->lock spinlock, and dma_tc_handle() runs from the hardirq handler.

Because base->lcla_dev is an external SRAM device whose PM domain requires sleeping locks to power on or off, it is not IRQ-safe. Calling synchronous PM operations on it in an atomic context might trigger a might_sleep() warning and a scheduling-while-atomic kernel panic.

drivers/dma/ste_dma40.c static struct device *chan2dev(struct d40_chan *d40c) · line 646

Quoted 10 lines
drivers/dma/ste_dma40.c +10 -0
+
+	pm_runtime_get_sync(base->dev);
+}
+
+static void d40_transfer_runtime_put(struct d40_base *base)
+{
+	pm_runtime_put_autosuspend(base->dev);
+
+	if (base->lcla_dev)
+		pm_runtime_put_sync_suspend(base->lcla_dev);

[Severity: High]
Could forcing an immediate synchronous suspend of the SRAM PM domain defeat the DMA controller's autosuspend design and cause performance degradation?

By using pm_runtime_put_sync_suspend() here, the external SRAM device is forced to power down immediately as soon as a single DMA transfer completes. The DMA controller itself uses pm_runtime_put_autosuspend() to handle bursty transfers efficiently.

Suspending the shared SRAM immediately and synchronously might cause every subsequent DMA transfer to block while the PM domain wakes up, which could introduce significant latency.

Quoted 1 line
drivers/dma/ste_dma40.c +1 -0
+}

[ ... ]

drivers/dma/ste_dma40.c static struct d40_desc *d40_queue_start(struct d40_chan *d40c) · line 1540

Quoted 9 lines
drivers/dma/ste_dma40.c +1 -1
@@ -1516,7 +1534,7 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)
 	if (d40d != NULL) {
 		if (!d40c->busy) {
 			d40c->busy = true;
-			pm_runtime_get_sync(d40c->base->dev);
+			d40_transfer_runtime_get(d40c->base);
 		}
 
 		/* Remove from queue */

[Severity: High]
This is a pre-existing issue, but does d40_queue_start() leak a runtime PM reference and hang the channel if the hardware start fails?

If d40_start(d40c) fails later in this function, it returns NULL without reverting d40c->busy or dropping the PM reference:

    err = d40_start(d40c);
    if (err)
        return NULL;

Callers like d40_issue_pending() ignore this return value. The channel then remains permanently marked as busy, preventing future transfers, and the leaked PM reference prevents the device from suspending.

[ ... ]

Quoted 27 lines
drivers/dma/ste_dma40.c +11 -8
@@ -3590,23 +3593,32 @@ static int __init d40_probe(struct platform_device *pdev)
 	}
 
 	if (base->plat_data->use_esram_lcla) {
+		np_lcla = of_parse_phandle(np, "sram", 1);
+		if (!np_lcla) {
+			dev_err(dev, "no LCLA SRAM node\n");
+			ret = -EINVAL;
+			goto destroy_cache;
+		}
 
-		base->lcpa_regulator = regulator_get(base->dev, "lcla_esram");
-		if (IS_ERR(base->lcpa_regulator)) {
-			d40_err(dev, "Failed to get lcpa_regulator\n");
-			ret = PTR_ERR(base->lcpa_regulator);
-			base->lcpa_regulator = NULL;
+		np_lcla_parent = of_get_parent(np_lcla);
+		of_node_put(np_lcla);
+		if (!np_lcla_parent) {
+			dev_err(dev, "no LCLA SRAM parent node\n");
+			ret = -EINVAL;
 			goto destroy_cache;
 		}
 
-		ret = regulator_enable(base->lcpa_regulator);
-		if (ret) {
-			d40_err(dev,

drivers/dma/ste_dma40.c static int __init d40_probe(struct platform_device *pdev) · line 3617

Quoted 10 lines
drivers/dma/ste_dma40.c +5 -3
-				"Failed to enable lcpa_regulator\n");
-			regulator_put(base->lcpa_regulator);
-			base->lcpa_regulator = NULL;
+		lcla_pdev = of_find_device_by_node(np_lcla_parent);
+		of_node_put(np_lcla_parent);
+		if (!lcla_pdev) {
+			ret = -EPROBE_DEFER;
 			goto destroy_cache;
 		}
+		base->lcla_dev = &lcla_pdev->dev;

[Severity: High]
Is a device link missing between the DMA controller and the external LCLA SRAM device?

The driver relies on the runtime PM of lcla_dev, but it doesn't appear to call device_link_add() to inform the PM core that base->dev depends on base->lcla_dev.

During a system sleep transition, the PM core might suspend devices in parallel or based on standard device tree hierarchy, potentially suspending lcla_dev before the DMA controller. This could physically power off the SRAM while active DMA transfers are still running.

drivers/dma/ste_dma40.c static int __init d40_probe(struct platform_device *pdev) · line 3619

Quoted 2 lines
drivers/dma/ste_dma40.c +2 -0
+		if (!pm_runtime_enabled(base->lcla_dev)) {
+			pm_runtime_enable(base->lcla_dev);

[Severity: High]
Is it safe for a consumer driver to forcefully alter the core runtime PM state of an external supplier device?

A consumer driver generally shouldn't manually manipulate the enable/disable state of a supplier device it does not own.

If the supplier SRAM driver probes concurrently or manages its own state, its call to pm_runtime_enable() will find disable_depth already at 0, which could trigger an "Unbalanced pm_runtime_enable!" warning and corrupt the device's internal power state machine.

Quoted 5 lines
drivers/dma/ste_dma40.c +2 -0
+			base->lcla_pm_enabled = true;
+		}
 	}
 
 	writel_relaxed(D40_DREG_GCC_ENABLE_ALL, base->virtbase + D40_DREG_GCC);

[ ... ]

Quoted 11 lines
drivers/dma/ste_dma40.c +2 -1
@@ -3642,16 +3654,17 @@ static int __init d40_probe(struct platform_device *pdev)
 				 SZ_1K * base->num_phy_chans,
 				 DMA_TO_DEVICE);
 
-	if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)
+	if (!base->lcla_pool.base_unaligned && base->lcla_pool.base &&
+	    base->lcla_pool.pages)
 		free_pages((unsigned long)base->lcla_pool.base,
 			   base->lcla_pool.pages);
 
 	kfree(base->lcla_pool.base_unaligned);

drivers/dma/ste_dma40.c static int __init d40_probe(struct platform_device *pdev) · line 3668

Quoted 10 lines
drivers/dma/ste_dma40.c +4 -4
 
-	if (base->lcpa_regulator) {
-		regulator_disable(base->lcpa_regulator);
-		regulator_put(base->lcpa_regulator);
-	}
+	if (base->lcla_pm_enabled)
+		pm_runtime_disable(base->lcla_dev);
+	if (base->lcla_dev)
+		put_device(base->lcla_dev);
 	pm_runtime_disable(base->dev);

[Severity: High]
This is a pre-existing issue, but might this error path permanently disable runtime PM on subsequent probe retries?

If d40_probe() encounters an error before pm_runtime_enable(base->dev) is executed (for example, when lcla_pdev is not found and returns -EPROBE_DEFER), it jumps to destroy_cache.

This unconditionally calls pm_runtime_disable(base->dev), incrementing disable_depth from 1 to 2. When the probe is retried and succeeds, pm_runtime_enable() will only decrement the depth to 1, leaving the device permanently disabled for runtime PM.

[Severity: High]
This is a pre-existing issue, but could the destroy_cache error path leak the registered IRQ?

Earlier in d40_probe(), request_irq() is called to register the hardware interrupt handler:

    ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base);

If a subsequent step fails, the function jumps to destroy_cache, which cleans up memory and DMA mappings but does not call free_irq().

The interrupt handler remains registered for a device whose driver data and resources have been freed. If the hardware asserts an interrupt, the kernel might execute the handler using freed memory.

drivers/dma/ste_dma40.c static int __init d40_probe(struct platform_device *pdev) · line 3670

Quoted 2 lines
drivers/dma/ste_dma40.c +0 -0
  report_failure:

[Severity: Critical]
This is a pre-existing issue, but does the validation logic for dev_type allow an out-of-bounds write during channel allocation?

In d40_validate_conf(), conf->dev_type is validated against num_log_chans:

    if ((is_log && conf->dev_type > d40c->base->num_log_chans)

However, in d40_allocate_channel(), log_num is calculated as either 2 * dev_type or 2 * dev_type + 1. This allows log_num to reach up to 2 * 256 + 1 = 513.

The driver then writes to the lookup array:

    d40c->base->lookup_log_chans[d40c->log_num] = d40c;

Since lookup_log_chans is only sized to hold num_log_chans elements, this results in a write past the end of the array.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
#18 lore raw

Re: [PATCH 08/11] dmaengine: ste_dma40: Use power domain for LCLA SRAM

In reply to Linus Walleij
Quoted 47 lines · Linus Walleij

Replace the LCLA ESRAM regulator with runtime PM.

Use the SRAM device that owns the ESRAM34 power domain.

Hold that domain while DMA transfers are active.

Assisted-by Codex:gpt-5-5
---
 drivers/dma/ste_dma40.c | 97 ++++++++++++++++++++++++++++---------------------
 1 file changed, 55 insertions(+), 42 deletions(-)
drivers/dma/ste_dma40.c +5 -3
index 9b803c0aec25..6ca67ec446dc 100644
@@ -21,8 +21,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_dma.h>
+#include <linux/of_platform.h>
 #include <linux/amba/bus.h>
-#include <linux/regulator/consumer.h>
 
 #include "dmaengine.h"
 #include "ste_dma40.h"
@@ -571,7 +571,8 @@ struct d40_gen_dmac {
  * to phy_chans entries.
  * @plat_data: Pointer to provided platform_data which is the driver
  * configuration.
- * @lcpa_regulator: Pointer to hold the regulator for the esram bank for lcla.
+ * @lcla_dev: SRAM device for the ESRAM bank used by LCLA.
+ * @lcla_pm_enabled: Whether runtime PM was enabled for LCLA by this driver.
  * @phy_res: Vector containing all physical channels.
  * @lcla_pool: lcla pool settings and data.
  * @lcpa_base: The virtual mapped address of LCPA.
@@ -607,7 +608,8 @@ struct d40_base {
 	struct d40_chan			**lookup_log_chans;
 	struct d40_chan			**lookup_phy_chans;
 	struct stedma40_platform_data	 *plat_data;
-	struct regulator		 *lcpa_regulator;
+	struct device			 *lcla_dev;
+	bool				  lcla_pm_enabled;
 	/* Physical half channels */
 	struct d40_phy_res		 *phy_res;
 	struct d40_lcla_pool		  lcla_pool;

drivers/dma/ste_dma40.c static struct device *chan2dev(struct d40_chan *d40c) · line 638

Quoted 9 lines
drivers/dma/ste_dma40.c +6 -0
@@ -628,6 +630,22 @@ static struct device *chan2dev(struct d40_chan *d40c)
 	return &d40c->chan.dev->device;
 }
 
+static void d40_transfer_runtime_get(struct d40_base *base)
+{
+	if (base->lcla_dev)
+		pm_runtime_get_sync(base->lcla_dev);
+
+	pm_runtime_get_sync(base->dev);

Suggest create device link between base->dev and base->lcla_dev, so run time pm framework will auto do it for you

Ref: https://lore.kernel.org/imx/[email protected]/

Frank

author maintainer
#19 lore raw

PATCH 9/11 regulator: db8500-prcmu: Remove EPOD regulators

In reply to Linus Walleij

Remove the obsolete DB8500 PRCMU regulator drivers.

Drop the regulator build hooks now that EPODs are power domains.

Keep the MFD cell around because a later patch reuses it for a small compatibility regulator driver.

Assisted-by Codex:gpt-5-5
---
 drivers/mfd/db8500-prcmu.c             | 239 +---------------
 drivers/regulator/Kconfig              |  12 -
 drivers/regulator/Makefile             |   2 -
 drivers/regulator/db8500-prcmu.c       | 501 ---------------------------------
 drivers/regulator/dbx500-prcmu.c       | 155 ----------
 drivers/regulator/dbx500-prcmu.h       |  55 ----
 include/linux/regulator/db8500-prcmu.h |  38 ---
 7 files changed, 1 insertion(+), 1001 deletions(-)
drivers/mfd/db8500-prcmu.c +1 -238
index 21e68a382b11..f1eeab3e6270 100644
@@ -34,8 +34,6 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/dbx500-prcmu.h>
 #include <linux/mfd/abx500/ab8500.h>
-#include <linux/regulator/db8500-prcmu.h>
-#include <linux/regulator/machine.h>
 #include "db8500-prcmu-regs.h"
 
 /* Index of different voltages to be used when accessing AVSData */
@@ -2704,248 +2702,13 @@ static void init_prcm_registers(void)
 	writel(val, (PRCM_A9PL_FORCE_CLKEN));
 }
 
-/*
- * Power domain switches (ePODs) modeled as regulators for the DB8500 SoC
- */
-static struct regulator_consumer_supply db8500_vape_consumers[] = {
-	REGULATOR_SUPPLY("v-ape", NULL),
-	REGULATOR_SUPPLY("v-i2c", "nmk-i2c.0"),
-	REGULATOR_SUPPLY("v-i2c", "nmk-i2c.1"),
-	REGULATOR_SUPPLY("v-i2c", "nmk-i2c.2"),
-	REGULATOR_SUPPLY("v-i2c", "nmk-i2c.3"),
-	REGULATOR_SUPPLY("v-i2c", "nmk-i2c.4"),
-	/* "v-mmc" changed to "vcore" in the mainline kernel */
-	REGULATOR_SUPPLY("vcore", "sdi0"),
-	REGULATOR_SUPPLY("vcore", "sdi1"),
-	REGULATOR_SUPPLY("vcore", "sdi2"),
-	REGULATOR_SUPPLY("vcore", "sdi3"),
-	REGULATOR_SUPPLY("vcore", "sdi4"),
-	REGULATOR_SUPPLY("v-dma", "dma40.0"),
-	REGULATOR_SUPPLY("v-ape", "ab8500-usb.0"),
-	/* "v-uart" changed to "vcore" in the mainline kernel */
-	REGULATOR_SUPPLY("vcore", "uart0"),
-	REGULATOR_SUPPLY("vcore", "uart1"),
-	REGULATOR_SUPPLY("vcore", "uart2"),
-	REGULATOR_SUPPLY("v-ape", "nmk-ske-keypad.0"),
-	REGULATOR_SUPPLY("v-hsi", "ste_hsi.0"),
-	REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
-};
-
-static struct regulator_consumer_supply db8500_vsmps2_consumers[] = {
-	REGULATOR_SUPPLY("musb_1v8", "ab8500-usb.0"),
-	/* AV8100 regulator */
-	REGULATOR_SUPPLY("hdmi_1v8", "0-0070"),
-};
-
-static struct regulator_consumer_supply db8500_b2r2_mcde_consumers[] = {
-	REGULATOR_SUPPLY("vsupply", "b2r2_bus"),
-	REGULATOR_SUPPLY("vsupply", "mcde"),
-};
-
-/* SVA MMDSP regulator switch */
-static struct regulator_consumer_supply db8500_svammdsp_consumers[] = {
-	REGULATOR_SUPPLY("sva-mmdsp", "cm_control"),
-};
-
-/* SVA pipe regulator switch */
-static struct regulator_consumer_supply db8500_svapipe_consumers[] = {
-	REGULATOR_SUPPLY("sva-pipe", "cm_control"),
-};
-
-/* SIA MMDSP regulator switch */
-static struct regulator_consumer_supply db8500_siammdsp_consumers[] = {
-	REGULATOR_SUPPLY("sia-mmdsp", "cm_control"),
-};
-
-/* SIA pipe regulator switch */
-static struct regulator_consumer_supply db8500_siapipe_consumers[] = {
-	REGULATOR_SUPPLY("sia-pipe", "cm_control"),
-};
-
-static struct regulator_consumer_supply db8500_sga_consumers[] = {
-	REGULATOR_SUPPLY("v-mali", NULL),
-};
-
-/* ESRAM1 and 2 regulator switch */
-static struct regulator_consumer_supply db8500_esram12_consumers[] = {
-	REGULATOR_SUPPLY("esram12", "cm_control"),
-};
-
-/* ESRAM3 and 4 regulator switch */
-static struct regulator_consumer_supply db8500_esram34_consumers[] = {
-	REGULATOR_SUPPLY("v-esram34", "mcde"),
-	REGULATOR_SUPPLY("esram34", "cm_control"),
-	REGULATOR_SUPPLY("lcla_esram", "dma40.0"),
-};
-
-static struct regulator_init_data db8500_regulators[DB8500_NUM_REGULATORS] = {
-	[DB8500_REGULATOR_VAPE] = {
-		.constraints = {
-			.name = "db8500-vape",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-			.always_on = true,
-		},
-		.consumer_supplies = db8500_vape_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_vape_consumers),
-	},
-	[DB8500_REGULATOR_VARM] = {
-		.constraints = {
-			.name = "db8500-varm",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_VMODEM] = {
-		.constraints = {
-			.name = "db8500-vmodem",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_VPLL] = {
-		.constraints = {
-			.name = "db8500-vpll",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_VSMPS1] = {
-		.constraints = {
-			.name = "db8500-vsmps1",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_VSMPS2] = {
-		.constraints = {
-			.name = "db8500-vsmps2",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_vsmps2_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_vsmps2_consumers),
-	},
-	[DB8500_REGULATOR_VSMPS3] = {
-		.constraints = {
-			.name = "db8500-vsmps3",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_VRF1] = {
-		.constraints = {
-			.name = "db8500-vrf1",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
-		/* dependency to u8500-vape is handled outside regulator framework */
-		.constraints = {
-			.name = "db8500-sva-mmdsp",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_svammdsp_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_svammdsp_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
-		.constraints = {
-			/* "ret" means "retention" */
-			.name = "db8500-sva-mmdsp-ret",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_SWITCH_SVAPIPE] = {
-		/* dependency to u8500-vape is handled outside regulator framework */
-		.constraints = {
-			.name = "db8500-sva-pipe",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_svapipe_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_svapipe_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_SIAMMDSP] = {
-		/* dependency to u8500-vape is handled outside regulator framework */
-		.constraints = {
-			.name = "db8500-sia-mmdsp",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_siammdsp_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_siammdsp_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = {
-		.constraints = {
-			.name = "db8500-sia-mmdsp-ret",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_SWITCH_SIAPIPE] = {
-		/* dependency to u8500-vape is handled outside regulator framework */
-		.constraints = {
-			.name = "db8500-sia-pipe",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_siapipe_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_siapipe_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_SGA] = {
-		.supply_regulator = "db8500-vape",
-		.constraints = {
-			.name = "db8500-sga",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_sga_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_sga_consumers),
-
-	},
-	[DB8500_REGULATOR_SWITCH_B2R2_MCDE] = {
-		.supply_regulator = "db8500-vape",
-		.constraints = {
-			.name = "db8500-b2r2-mcde",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_b2r2_mcde_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_b2r2_mcde_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_ESRAM12] = {
-		/*
-		 * esram12 is set in retention and supplied by Vsafe when Vape is off,
-		 * no need to hold Vape
-		 */
-		.constraints = {
-			.name = "db8500-esram12",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_esram12_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_esram12_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_ESRAM12RET] = {
-		.constraints = {
-			.name = "db8500-esram12-ret",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-	[DB8500_REGULATOR_SWITCH_ESRAM34] = {
-		/*
-		 * esram34 is set in retention and supplied by Vsafe when Vape is off,
-		 * no need to hold Vape
-		 */
-		.constraints = {
-			.name = "db8500-esram34",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-		.consumer_supplies = db8500_esram34_consumers,
-		.num_consumer_supplies = ARRAY_SIZE(db8500_esram34_consumers),
-	},
-	[DB8500_REGULATOR_SWITCH_ESRAM34RET] = {
-		.constraints = {
-			.name = "db8500-esram34-ret",
-			.valid_ops_mask = REGULATOR_CHANGE_STATUS,
-		},
-	},
-};
-
 static const struct mfd_cell common_prcmu_devs[] = {
 	MFD_CELL_NAME("db8500_wdt"),
 	MFD_CELL_NAME("db8500-cpuidle"),
 };
 
 static const struct mfd_cell db8500_prcmu_devs[] = {
-	MFD_CELL_OF("db8500-prcmu-regulators", NULL,
-		    &db8500_regulators, sizeof(db8500_regulators), 0,
+	MFD_CELL_OF("db8500-prcmu-regulators", NULL, NULL, 0, 0,
 		    "stericsson,db8500-prcmu-regulator"),
 	MFD_CELL_OF("db8500-thermal",
 		    NULL, NULL, 0, 0, "stericsson,db8500-thermal"),
drivers/regulator/Kconfig +0 -12
index 35d1b191462c..acc698c17bd2 100644
@@ -408,18 +408,6 @@ config REGULATOR_DA9211
 	  step down converter 12A or 16A DC-DC Buck controlled through an I2C
 	  interface.
 
-config REGULATOR_DBX500_PRCMU
-	bool
-
-config REGULATOR_DB8500_PRCMU
-	bool "ST-Ericsson DB8500 Voltage Domain Regulators"
-	depends on MFD_DB8500_PRCMU
-	depends on !UX500_PM_DOMAIN
-	select REGULATOR_DBX500_PRCMU
-	help
-	  This driver supports the voltage domain regulators controlled by the
-	  DB8500 PRCMU
-
 config REGULATOR_FAN53555
 	tristate "Fairchild FAN53555 Regulator"
 	depends on I2C
drivers/regulator/Makefile +0 -2
index 35639f3115fd..96a02063b843 100644
@@ -48,8 +48,6 @@ obj-$(CONFIG_REGULATOR_DA9063)	+= da9063-regulator.o
 obj-$(CONFIG_REGULATOR_DA9121) += da9121-regulator.o
 obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o
 obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o
-obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
-obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
 obj-$(CONFIG_REGULATOR_FAN53880) += fan53880.o
 obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
drivers/regulator/db8500-prcmu.c deleted +0 -501

501 lines not on this page · raw message

drivers/regulator/dbx500-prcmu.c deleted +0 -155

155 lines not on this page · raw message

drivers/regulator/dbx500-prcmu.h deleted +0 -55

55 lines not on this page · raw message

include/linux/regulator/db8500-prcmu.h deleted +0 -38
deleted file mode 100644
index d58ff273157e..000000000000
@@ -1,38 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) ST-Ericsson SA 2010
- *
- * Author: Bengt Jonsson <[email protected]> for ST-Ericsson
- *
- * Interface to power domain regulators on DB8500
- */
-
-#ifndef __REGULATOR_H__
-#define __REGULATOR_H__
-
-/* Number of DB8500 regulators and regulator enumeration */
-enum db8500_regulator_id {
-	DB8500_REGULATOR_VAPE,
-	DB8500_REGULATOR_VARM,
-	DB8500_REGULATOR_VMODEM,
-	DB8500_REGULATOR_VPLL,
-	DB8500_REGULATOR_VSMPS1,
-	DB8500_REGULATOR_VSMPS2,
-	DB8500_REGULATOR_VSMPS3,
-	DB8500_REGULATOR_VRF1,
-	DB8500_REGULATOR_SWITCH_SVAMMDSP,
-	DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
-	DB8500_REGULATOR_SWITCH_SVAPIPE,
-	DB8500_REGULATOR_SWITCH_SIAMMDSP,
-	DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
-	DB8500_REGULATOR_SWITCH_SIAPIPE,
-	DB8500_REGULATOR_SWITCH_SGA,
-	DB8500_REGULATOR_SWITCH_B2R2_MCDE,
-	DB8500_REGULATOR_SWITCH_ESRAM12,
-	DB8500_REGULATOR_SWITCH_ESRAM12RET,
-	DB8500_REGULATOR_SWITCH_ESRAM34,
-	DB8500_REGULATOR_SWITCH_ESRAM34RET,
-	DB8500_NUM_REGULATORS
-};
-
-#endif
Signature · 1 line
2.54.0
#20 lore raw

Re: [PATCH 09/11] regulator: db8500-prcmu: Remove EPOD regulators

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Calling pm_runtime_get_sync() and pm_runtime_put_sync_suspend() on lcla_dev from the DMA hardirq handler causes a 'sleeping in atomic context' bug. --

commit faf19ae1be6f68a94634761ce6a55206f7f124da
Author: Linus Walleij <[email protected]>

regulator: db8500-prcmu: Remove EPOD regulators

Remove the obsolete DB8500 PRCMU regulator drivers.

Quoted 1 line

Drop the regulator build hooks now that EPODs are power domains.

[Severity: High]
This isn't a bug introduced by this patch, but since the EPODs are now power domains, is it safe to use them from atomic contexts?

An earlier patch in this series transitioned the LCLA SRAM to use power domains, but the DMA interrupt handler d40_handle_interrupt() acquires spinlocks (base->interrupt_lock and d40c->lock) before taking this path:

d40_handle_interrupt()
dma_tc_handle()

    d40_queue_start()
      d40_transfer_runtime_get()
        pm_runtime_get_sync(base->lcla_dev)
      
      d40_transfer_runtime_put()
        pm_runtime_put_sync_suspend(base->lcla_dev)

Because base->lcla_dev is tied to the ESRAM34 generic PM domain and is not marked IRQ-safe (GENPD_FLAG_IRQ_SAFE), its callbacks are invoked, leading to sleeping operations while holding spinlocks:

pd_power_off()
guard(mutex)(&ux500_pd_lock)
db8500_prcmu_set_epod()
mutex_lock(&mb2_transfer.lock)

Could this lead to scheduling while atomic bugs and deadlocks?

Quoted 5 lines

Keep the MFD cell around because a later patch reuses it for a small compatibility regulator driver.

Assisted-by Codex:gpt-5-5

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
maintainer
#22 lore raw

Re: [PATCH 09/11] regulator: db8500-prcmu: Remove EPOD regulators

In reply to Linus Walleij
Quoted 9 lines · Linus Walleij

Remove the obsolete DB8500 PRCMU regulator drivers.

Drop the regulator build hooks now that EPODs are power domains.

Keep the MFD cell around because a later patch reuses it for a small compatibility regulator driver.

Assisted-by Codex:gpt-5-5
Quoted 9 lines
---
 drivers/mfd/db8500-prcmu.c             | 239 +---------------
 drivers/regulator/Kconfig              |  12 -
 drivers/regulator/Makefile             |   2 -
 drivers/regulator/db8500-prcmu.c       | 501 ---------------------------------
 drivers/regulator/dbx500-prcmu.c       | 155 ----------
 drivers/regulator/dbx500-prcmu.h       |  55 ----
 include/linux/regulator/db8500-prcmu.h |  38 ---
 7 files changed, 1 insertion(+), 1001 deletions(-)

Any deps?

Signature · 1 line
Lee Jones
author maintainer
#23 lore raw

Re: [PATCH 09/11] regulator: db8500-prcmu: Remove EPOD regulators

Quoted 21 lines · Lee Jones
Quoted 9 lines · Linus Walleij

Remove the obsolete DB8500 PRCMU regulator drivers.

Drop the regulator build hooks now that EPODs are power domains.

Keep the MFD cell around because a later patch reuses it for a small compatibility regulator driver.

Assisted-by Codex:gpt-5-5
Quoted 9 lines
---
 drivers/mfd/db8500-prcmu.c             | 239 +---------------
 drivers/regulator/Kconfig              |  12 -
 drivers/regulator/Makefile             |   2 -
 drivers/regulator/db8500-prcmu.c       | 501 ---------------------------------
 drivers/regulator/dbx500-prcmu.c       | 155 ----------
 drivers/regulator/dbx500-prcmu.h       |  55 ----
 include/linux/regulator/db8500-prcmu.h |  38 ---
 7 files changed, 1 insertion(+), 1001 deletions(-)
Quoted 1 line

Any deps?

Not really, was planning to split off the stuff that can go directly to MFD and resend it with all the ACKs.

Yours,
Linus Walleij

maintainer
#24 lore raw

Re: [PATCH 09/11] regulator: db8500-prcmu: Remove EPOD regulators

Quoted 22 lines · Linus Walleij
Quoted 21 lines · Lee Jones
Quoted 18 lines · Linus Walleij

Remove the obsolete DB8500 PRCMU regulator drivers.

Drop the regulator build hooks now that EPODs are power domains.

Keep the MFD cell around because a later patch reuses it for a small compatibility regulator driver.

Assisted-by Codex:gpt-5-5
---
 drivers/mfd/db8500-prcmu.c             | 239 +---------------
 drivers/regulator/Kconfig              |  12 -
 drivers/regulator/Makefile             |   2 -
 drivers/regulator/db8500-prcmu.c       | 501 ---------------------------------
 drivers/regulator/dbx500-prcmu.c       | 155 ----------
 drivers/regulator/dbx500-prcmu.h       |  55 ----
 include/linux/regulator/db8500-prcmu.h |  38 ---
 7 files changed, 1 insertion(+), 1001 deletions(-)
Quoted 4 lines
Quoted 1 line

Any deps?

Not really, was planning to split off the stuff that can go directly to MFD and resend it with all the ACKs.

Sounds good.

Signature · 1 line
Lee Jones
author maintainer
#25 lore raw

PATCH 10/11 regulator: db8500: Add power domain regulators

In reply to Linus Walleij

Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes.

Back the regulator enable state with the corresponding power domains.

This is done for off-chip consumers: the corresponding voltage rails are routed out so they are used for powering different peripherals using these voltages as supplies.

Assisted-by Codex:gpt-5-5
---
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi |   2 +
 drivers/regulator/Kconfig            |  11 ++
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/db8500-regulator.c | 221 +++++++++++++++++++++++++++++++++++
 4 files changed, 235 insertions(+)
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +2 -0
index a6fef302c994..fd6a075e4c93 100644
@@ -673,6 +673,7 @@ db8500-prcmu-regulators {
 				// DB8500_REGULATOR_VAPE
 				db8500_vape_reg: db8500_vape {
 					regulator-always-on;
+					power-domains = <&pm_domains DOMAIN_VAPE>;
 				};
 
 				// DB8500_REGULATOR_VARM
@@ -693,6 +694,7 @@ db8500_vsmps1_reg: db8500_vsmps1 {
 
 				// DB8500_REGULATOR_VSMPS2
 				db8500_vsmps2_reg: db8500_vsmps2 {
+					power-domains = <&pm_domains DOMAIN_VSMPS2>;
 				};
 
 				// DB8500_REGULATOR_VSMPS3
drivers/regulator/Kconfig +11 -0
index acc698c17bd2..8db63d8d3fa4 100644
@@ -397,6 +397,17 @@ config REGULATOR_DA9210
 	  converter 12A DC-DC Buck controlled through an I2C
 	  interface.
 
+config REGULATOR_DB8500
+	bool "ST-Ericsson DB8500 power domain regulators"
+	depends on MFD_DB8500_PRCMU && UX500_PM_DOMAIN && OF
+	default ARCH_U8500
+	help
+	  This driver supports the DB8500 VAPE and VSMPS2 regulators.
+	  These supplies are represented by generic power domains in hardware,
+	  but the same voltage rails are routed out of the chip and used to
+	  supply external peripherals.
+	  Enable this driver to bridge those regulator consumers to genpd.
+
 config REGULATOR_DA9211
 	tristate "Dialog Semiconductor DA9211/DA9212/DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 96a02063b843..f4109549525a 100644
@@ -48,6 +48,7 @@ obj-$(CONFIG_REGULATOR_DA9063)	+= da9063-regulator.o
 obj-$(CONFIG_REGULATOR_DA9121) += da9121-regulator.o
 obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o
 obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o
+obj-$(CONFIG_REGULATOR_DB8500) += db8500-regulator.o
 obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
 obj-$(CONFIG_REGULATOR_FAN53880) += fan53880.o
 obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
drivers/regulator/db8500-regulator.c new file +221 -0

221 lines not on this page · raw message

Signature · 1 line
2.54.0
#26 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] The `db8500_regulator_disable` callback incorrectly treats a return value of 1 from…

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The db8500_regulator_disable callback incorrectly treats a return value of 1 from pm_runtime_put_sync_suspend as an error, causing early abort and state desynchronization.
- [High] Mismatched Genpd APIs (of_genpd_add_device paired with dev_pm_domain_detach) lead to a silent detach failure and Use-After-Free list corruption.
- [High] Embedding a struct device in a devres-managed structure (devm_kzalloc) with an empty release function causes a lifecycle violation and Use-After-Free.
- [High] The virtual device is never fully registered with device_add(), leading to a memory leak of PM QoS constraints.
- [High] The driver saves an OF node pointer to the persistent device structure without incrementing its reference count, risking a dangling pointer.
--

commit abd72295748300bd01e4a7216b2321ff24b1a38f
Author: Linus Walleij <[email protected]>

regulator: db8500: Add power domain regulators

Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes, backing the regulator enable state with corresponding power domains.

Quoted 5 lines
drivers/regulator/db8500-regulator.c new file +0 -0
new file mode 100644
index 0000000000000..c5a9a1baaf8ea

[ ... ]

drivers/regulator/db8500-regulator.c line 66

Quoted 8 lines
drivers/regulator/db8500-regulator.c new file +8 -0
+static int db8500_regulator_disable(struct regulator_dev *rdev)
+{
+	struct db8500_regulator_info *info = rdev_get_drvdata(rdev);
+	int ret;
+
+	ret = pm_runtime_put_sync_suspend(&info->pd_dev);
+	if (ret)
+		return ret;

[Severity: High]
Does this propagate a success status as an error?

According to the PM subsystem rules, pm_runtime_put_sync_suspend() returns 1 when the device is already in the RPM_SUSPENDED state. Since this checks if (ret) and returns it, won't the regulator core treat this as a failure, aborting the disable operation and leaving the regulator's use_count and enable_count out of sync?

[ ... ]

drivers/regulator/db8500-regulator.c line 98

Quoted 3 lines
drivers/regulator/db8500-regulator.c new file +3 -0
+static void db8500_regulator_release(struct device *dev)
+{
+}

[Severity: High]
Does this empty release function circumvent kobject lifecycle tracking?

The struct device is embedded in devres memory allocated via devm_kzalloc(). Since put_device() does not guarantee synchronous memory reclamation, will devres forcibly free the memory when the driver unbinds, creating a use-after-free for any subsystem still holding a reference to pd_dev?

drivers/regulator/db8500-regulator.c line 105

Quoted 7 lines
drivers/regulator/db8500-regulator.c new file +7 -0
+
+static void db8500_regulator_cleanup(void *data)
+{
+	struct db8500_regulator_info *info = data;
+
+	pm_runtime_disable(&info->pd_dev);
+	dev_pm_domain_detach(&info->pd_dev, true);

[Severity: High]
Will this detach silently fail?

The device is attached using of_genpd_add_device(), which adds it to genpd->dev_list but does not populate the dev->pm_domain->detach callback.

Since dev_pm_domain_detach() checks for that callback, won't it be a no-op, leaving the device in the genpd active lists when freed and causing a use-after-free?

Should this use pm_genpd_remove_device() instead?

Quoted 2 lines
drivers/regulator/db8500-regulator.c new file +2 -0
+	put_device(&info->pd_dev);
+}

[ ... ]

Quoted 3 lines
drivers/regulator/db8500-regulator.c new file +3 -0
+static int db8500_regulator_register(struct platform_device *pdev,
+				     struct device_node *np)
+{

[ ... ]

drivers/regulator/db8500-regulator.c line 143

Quoted 7 lines
drivers/regulator/db8500-regulator.c new file +7 -0
+	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	device_initialize(&info->pd_dev);
+	info->pd_dev.parent = &pdev->dev;
+	info->pd_dev.of_node = np;

[Severity: High]
Could this leave a dangling pointer in info->pd_dev.of_node?

The np pointer is provided by for_each_available_child_of_node() in db8500_regulator_probe(), which automatically drops the reference on the node when advancing the loop.

Since of_node_get() isn't used here to increment the reference count, will the reference be dropped when the loop concludes?

drivers/regulator/db8500-regulator.c line 153

Quoted 10 lines
drivers/regulator/db8500-regulator.c new file +10 -0
+	info->pd_dev.release = db8500_regulator_release;
+	ret = dev_set_name(&info->pd_dev, "%s-pd", match->name);
+	if (ret)
+		goto put_device;
+
+	ret = of_parse_phandle_with_args(np, "power-domains", cells, 0, &pd_args);
+	if (ret)
+		goto put_device;
+
+	ret = of_genpd_add_device(&pd_args, &info->pd_dev);

[Severity: High]
Does this leak PM QoS constraints?

The device is initialized with device_initialize() but never fully registered with device_add().

Since of_genpd_add_device() automatically registers a resume latency QoS notifier that dynamically allocates PM QoS constraint structures, and those are normally freed by device_del(), will these structures leak upon cleanup because device_del() is never called?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
maintainer
#27 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

In reply to Linus Walleij

drivers/regulator/db8500-regulator.c line 87

Quoted 9 lines · Linus Walleij
drivers/regulator/db8500-regulator.c new file +9 -0
+static int db8500_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct db8500_regulator_info *info = rdev_get_drvdata(rdev);
+
+	if (!info->desc.fixed_uV)
+		return -EINVAL;
+
+	return info->desc.fixed_uV;
+}

The core supports single fixed voltages, set desc->fixed_uV.

#28 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

In reply to Linus Walleij
Quoted 23 lines · Linus Walleij

Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes.

Back the regulator enable state with the corresponding power domains.

This is done for off-chip consumers: the corresponding voltage rails are routed out so they are used for powering different peripherals using these voltages as supplies.

Assisted-by Codex:gpt-5-5
---
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi |   2 +
 drivers/regulator/Kconfig            |  11 ++
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/db8500-regulator.c | 221 +++++++++++++++++++++++++++++++++++
 4 files changed, 235 insertions(+)
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -0
index a6fef302c994..fd6a075e4c93 100644

arch/arm/boot/dts/st/ste-dbx5x0.dtsi db8500-prcmu-regulators { · line 676

Quoted 4 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -673,6 +673,7 @@ db8500-prcmu-regulators {
                                // DB8500_REGULATOR_VAPE
                                db8500_vape_reg: db8500_vape {
                                        regulator-always-on;
+                                       power-domains = <&pm_domains DOMAIN_VAPE>;

Hmm, isn't this the other way around? The power-domains node should have a regulator supply?

We may even consider to skip to model the regulator altogether and make the power domain operate directly on the prcmu instead.

arch/arm/boot/dts/st/ste-dbx5x0.dtsi db8500_vsmps1_reg: db8500_vsmps1 { · line 697

Quoted 8 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
                                };
 
                                // DB8500_REGULATOR_VARM
@@ -693,6 +694,7 @@ db8500_vsmps1_reg: db8500_vsmps1 {
 
                                // DB8500_REGULATOR_VSMPS2
                                db8500_vsmps2_reg: db8500_vsmps2 {
+                                       power-domains = <&pm_domains DOMAIN_VSMPS2>;

Ditto.

drivers/regulator/Kconfig config REGULATOR_DA9210 · line 399

Quoted 11 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -0
                                };
 
                                // DB8500_REGULATOR_VSMPS3
drivers/regulator/Kconfig +0 -0
index acc698c17bd2..8db63d8d3fa4 100644
@@ -397,6 +397,17 @@ config REGULATOR_DA9210
          converter 12A DC-DC Buck controlled through an I2C
          interface.
 

[...]

Kind regards
Uffe

author maintainer
#29 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

Quoted 12 lines · Ulf Hansson
Quoted 11 lines · Linus Walleij

Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes.

Back the regulator enable state with the corresponding power domains.

This is done for off-chip consumers: the corresponding voltage rails are routed out so they are used for powering different peripherals using these voltages as supplies.

Assisted-by Codex:gpt-5-5

(...)

Quoted 8 lines

arch/arm/boot/dts/st/ste-dbx5x0.dtsi db8500-prcmu-regulators { · line 676

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -673,6 +673,7 @@ db8500-prcmu-regulators {
                                // DB8500_REGULATOR_VAPE
                                db8500_vape_reg: db8500_vape {
                                        regulator-always-on;
+                                       power-domains = <&pm_domains DOMAIN_VAPE>;

Hmm, isn't this the other way around? The power-domains node should have a regulator supply?

They probably have that, but that is not what this is about, it's the other way around.

Quoted 2 lines

We may even consider to skip to model the regulator altogether and make the power domain operate directly on the prcmu instead.

That is what the series tries to do, as a whole. Sorry if that was unclear...

What we do in this patch is to deal with the fact that two of the power domains, when enabled, also turn on two external power rails outside of the SoC.

Since external components such as I2C devices cannot really be claimed as "being inside a power domain" they take a regulator.

This is based on my understanding that power domains is an SoC-internal concept only, so there is a clear boundary if something outside of the SoC starts to use such an externalized power rail.

All this regulator does is to make sure the corresponding power domain is enabled when the regulator is enabled.

I will repost all the patches once v7.3-rc1 is out.

Yours,
Linus Walleij

#30 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

Quoted 31 lines · Linus Walleij
Quoted 12 lines · Ulf Hansson
Quoted 11 lines · Linus Walleij

Add a DB8500 regulator driver for the VAPE and VSMPS2 compatibility nodes.

Back the regulator enable state with the corresponding power domains.

This is done for off-chip consumers: the corresponding voltage rails are routed out so they are used for powering different peripherals using these voltages as supplies.

Assisted-by Codex:gpt-5-5

(...)

Quoted 8 lines

arch/arm/boot/dts/st/ste-dbx5x0.dtsi db8500-prcmu-regulators { · line 676

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -673,6 +673,7 @@ db8500-prcmu-regulators {
                                // DB8500_REGULATOR_VAPE
                                db8500_vape_reg: db8500_vape {
                                        regulator-always-on;
+                                       power-domains = <&pm_domains DOMAIN_VAPE>;

Hmm, isn't this the other way around? The power-domains node should have a regulator supply?

They probably have that, but that is not what this is about, it's the other way around.

Quoted 2 lines

We may even consider to skip to model the regulator altogether and make the power domain operate directly on the prcmu instead.

Quoted 8 lines

That is what the series tries to do, as a whole. Sorry if that was unclear...

What we do in this patch is to deal with the fact that two of the power domains, when enabled, also turn on two external power rails outside of the SoC.

Since external components such as I2C devices cannot really be claimed as "being inside a power domain" they take a regulator.

So with I2C devices you are not referring to the I2C controllers, right?

Are you saying that these external I2C devices consume the same regulator as the power-domain DOMAIN_VAPE uses?

I thought these types of external devices in general use a different voltage range. Moreover, do note that DOMAIN_VAPE also has corresponding OPPs (performance states) that change the voltage level based on the requested OPP. I am not sure an external I2C would be able to cope with that.

Quoted 5 lines

This is based on my understanding that power domains is an SoC-internal concept only, so there is a clear boundary if something outside of the SoC starts to use such an externalized power rail.

Quoted 7 lines

All this regulator does is to make sure the corresponding power domain is enabled when the regulator is enabled.

I will repost all the patches once v7.3-rc1 is out.

Yours,
Linus Walleij

Great! I really appreciate that you move this forward!

Kind regards
Uffe

author maintainer
#31 lore raw

Re: [PATCH 10/11] regulator: db8500: Add power domain regulators

Quoted 28 lines · Ulf Hansson
Quoted 15 lines · Linus Walleij
Quoted 8 lines

arch/arm/boot/dts/st/ste-dbx5x0.dtsi db8500-prcmu-regulators { · line 676

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +1 -0
@@ -673,6 +673,7 @@ db8500-prcmu-regulators {
                                // DB8500_REGULATOR_VAPE
                                db8500_vape_reg: db8500_vape {
                                        regulator-always-on;
+                                       power-domains = <&pm_domains DOMAIN_VAPE>;

Hmm, isn't this the other way around? The power-domains node should have a regulator supply?

They probably have that, but that is not what this is about, it's the other way around.

Quoted 2 lines

We may even consider to skip to model the regulator altogether and make the power domain operate directly on the prcmu instead.

Quoted 8 lines

That is what the series tries to do, as a whole. Sorry if that was unclear...

What we do in this patch is to deal with the fact that two of the power domains, when enabled, also turn on two external power rails outside of the SoC.

Since external components such as I2C devices cannot really be claimed as "being inside a power domain" they take a regulator.

So with I2C devices you are not referring to the I2C controllers, right?

Quoted 8 lines

Are you saying that these external I2C devices consume the same regulator as the power-domain DOMAIN_VAPE uses?

I thought these types of external devices in general use a different voltage range. Moreover, do note that DOMAIN_VAPE also has corresponding OPPs (performance states) that change the voltage level based on the requested OPP. I am not sure an external I2C would be able to cope with that.

I did the mistake to trust the device trees :(

It seems all the device trees are buggy, because components that should be connected to VSMPS2 from the AB8500 PMIC have been instead connected to the DB8500 VSMPS2 power domain... The one instance of VARM being used outside of the SoC was a bug as well.

OK I go and fix this, worst case I add a fixed regulator for it, it's an "always on except during sleep" type of thing.

We should be able to drop this patch entirely!

Yours,
Linus Walleij

author maintainer
#32 lore raw

PATCH 11/11 ARM: dts: ux500: Remove DB8500 EPOD regulators

In reply to Linus Walleij

Delete the obsolete DB8500 EPOD regulator nodes.

Keep the VAPE and VSMPS2 compatibility regulators.

Assisted-by Codex:gpt-5-5
---
 arch/arm/boot/dts/st/ste-dbx5x0.dtsi | 92 ------------------------------------
 1 file changed, 92 deletions(-)
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -92
index fd6a075e4c93..18727953a863 100644
@@ -663,97 +663,17 @@ thermal: thermal@801573c0 {
 				#thermal-sensor-cells = <0>;
 			};
 
-			/*
-			 * TODO: Delete these bogus regulators and replace with power
-			 * domains.
-			 */
 			db8500-prcmu-regulators {
 				compatible = "stericsson,db8500-prcmu-regulator";
 
-				// DB8500_REGULATOR_VAPE
 				db8500_vape_reg: db8500_vape {
 					regulator-always-on;
 					power-domains = <&pm_domains DOMAIN_VAPE>;
 				};
 
-				// DB8500_REGULATOR_VARM
-				db8500_varm_reg: db8500_varm {
-				};
-
-				// DB8500_REGULATOR_VMODEM
-				db8500_vmodem_reg: db8500_vmodem {
-				};
-
-				// DB8500_REGULATOR_VPLL
-				db8500_vpll_reg: db8500_vpll {
-				};
-
-				// DB8500_REGULATOR_VSMPS1
-				db8500_vsmps1_reg: db8500_vsmps1 {
-				};
-
-				// DB8500_REGULATOR_VSMPS2
 				db8500_vsmps2_reg: db8500_vsmps2 {
 					power-domains = <&pm_domains DOMAIN_VSMPS2>;
 				};
-
-				// DB8500_REGULATOR_VSMPS3
-				db8500_vsmps3_reg: db8500_vsmps3 {
-				};
-
-				// DB8500_REGULATOR_VRF1
-				db8500_vrf1_reg: db8500_vrf1 {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SVAMMDSP
-				db8500_sva_mmdsp_reg: db8500_sva_mmdsp {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SVAMMDSPRET
-				db8500_sva_mmdsp_ret_reg: db8500_sva_mmdsp_ret {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SVAPIPE
-				db8500_sva_pipe_reg: db8500_sva_pipe {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SIAMMDSP
-				db8500_sia_mmdsp_reg: db8500_sia_mmdsp {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SIAMMDSPRET
-				db8500_sia_mmdsp_ret_reg: db8500_sia_mmdsp_ret {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SIAPIPE
-				db8500_sia_pipe_reg: db8500_sia_pipe {
-				};
-
-				// DB8500_REGULATOR_SWITCH_SGA
-				db8500_sga_reg: db8500_sga {
-					vin-supply = <&db8500_vape_reg>;
-				};
-
-				// DB8500_REGULATOR_SWITCH_B2R2_MCDE
-				db8500_b2r2_mcde_reg: db8500_b2r2_mcde {
-					vin-supply = <&db8500_vape_reg>;
-				};
-
-				// DB8500_REGULATOR_SWITCH_ESRAM12
-				db8500_esram12_reg: db8500_esram12 {
-				};
-
-				// DB8500_REGULATOR_SWITCH_ESRAM12RET
-				db8500_esram12_ret_reg: db8500_esram12_ret {
-				};
-
-				// DB8500_REGULATOR_SWITCH_ESRAM34
-				db8500_esram34_reg: db8500_esram34 {
-				};
-
-				// DB8500_REGULATOR_SWITCH_ESRAM34RET
-				db8500_esram34_ret_reg: db8500_esram34_ret {
-				};
 			};
 		};
 
@@ -1111,8 +1031,6 @@ msp0: msp@80123000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80123000 0x1000>;
 			interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-			/* TODO: delete and replace with power-domain handling */
-			v-ape-supply = <&db8500_vape_reg>;
 			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			dmas = <&dma 31 0 0x12>, /* Logical - DevToMem - HighPrio */
@@ -1130,8 +1048,6 @@ msp1: msp@80124000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80124000 0x1000>;
 			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
-			/* TODO: delete and replace with power-domain handling */
-			v-ape-supply = <&db8500_vape_reg>;
 			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			/* This DMA channel only exist on DB8500 v1 */
@@ -1150,8 +1066,6 @@ msp2: msp@80117000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80117000 0x1000>;
 			interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
-			/* TODO: delete and replace with power-domain handling */
-			v-ape-supply = <&db8500_vape_reg>;
 			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			dmas = <&dma 14 0 0x12>, /* Logical  - DevToMem - HighPrio */
@@ -1170,8 +1084,6 @@ msp3: msp@80125000 {
 			compatible = "stericsson,ux500-msp-i2s";
 			reg = <0x80125000 0x1000>;
 			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
-			/* TODO: delete and replace with power-domain handling */
-			v-ape-supply = <&db8500_vape_reg>;
 			power-domains = <&pm_domains DOMAIN_VAPE>;
 
 			/* This DMA channel only exist on DB8500 v2 */
@@ -1215,8 +1127,6 @@ gpu@a0300000 {
 			clocks = <&prcmu_clk PRCMU_ACLK>, <&prcmu_clk PRCMU_SGACLK>;
 			clock-names = "bus", "core";
 			power-domains = <&pm_domains DOMAIN_SGA>;
-			/* TODO: delete and replace with power-domain handling */
-			mali-supply = <&db8500_sga_reg>;
 		};
 
 		mcde@a0350000 {
@@ -1224,8 +1134,6 @@ mcde@a0350000 {
 			reg = <0xa0350000 0x1000>;
 			interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
 			power-domains = <&pm_domains DOMAIN_B2R2_MCDE>;
-			/* TODO: delete and replace with power-domain handling */
-			epod-supply = <&db8500_b2r2_mcde_reg>;
 			clocks = <&prcmu_clk PRCMU_MCDECLK>, /* Main MCDE clock */
 				 <&prcmu_clk PRCMU_LCDCLK>, /* LCD clock */
 				 <&prcmu_clk PRCMU_PLLDSI>; /* HDMI clock */
Signature · 1 line
2.54.0
#33 lore raw

Re: [PATCH 11/11] ARM: dts: ux500: Remove DB8500 EPOD regulators

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Critical] Removing the EPOD regulator nodes and consumer supply properties breaks backwards…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Removing the EPOD regulator nodes and consumer supply properties breaks backwards compatibility with older kernels.
- [Low] Removed EPOD regulators and epod-supply property are still marked as required in their respective YAML binding schemas, causing make dtbs_check to fail. --

commit cc40a973d5076813fb2d1de31c4ef7f4d0231e78
Author: Linus Walleij <[email protected]>

ARM: dts: ux500: Remove DB8500 EPOD regulators

This commit deletes the obsolete DB8500 EPOD regulator nodes from the device tree. It retains only the VAPE and VSMPS2 compatibility regulators.

Quoted 5 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -0
index fd6a075e4c93c..18727953a8630 100644

arch/arm/boot/dts/st/ste-dbx5x0.dtsi thermal: thermal@801573c0 { · line 667

Quoted 9 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -4
@@ -663,97 +663,17 @@ thermal: thermal@801573c0 {
 				#thermal-sensor-cells = <0>;
 			};
 
-			/*
-			 * TODO: Delete these bogus regulators and replace with power
-			 * domains.
-			 */
 			db8500-prcmu-regulators {
 				compatible = "stericsson,db8500-prcmu-regulator";

[Severity: Low]
Does this commit also need to update the YAML binding schemas?

It appears that Documentation/devicetree/bindings/mfd/stericsson,db8500-prcmu.yaml still mandates the presence of deleted EPOD nodes (e.g., db8500_varm, db8500_sga) in its required: block, which could cause dtbs_check to fail.

[ ... ]

arch/arm/boot/dts/st/ste-dbx5x0.dtsi gpu@a0300000 { · line 1130

Quoted 7 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -2
@@ -1215,8 +1127,6 @@ gpu@a0300000 {
 			clocks = <&prcmu_clk PRCMU_ACLK>, <&prcmu_clk PRCMU_SGACLK>;
 			clock-names = "bus", "core";
 			power-domains = <&pm_domains DOMAIN_SGA>;
-			/* TODO: delete and replace with power-domain handling */
-			mali-supply = <&db8500_sga_reg>;
 		};

[Severity: Critical]
Does removing the mali-supply property and its target regulator break backwards compatibility with older kernels?

Device trees are considered a stable ABI, and older kernels lacking the updated ste-ux500-pm-domain driver might rely entirely on the legacy db8500-prcmu-regulator driver to power these components.

By aggressively removing these regulators, older kernels might fall back to dummy regulators and leave the physical hardware unpowered, leading to crashes when drivers attempt to access unclocked and unpowered hardware registers.

arch/arm/boot/dts/st/ste-dbx5x0.dtsi mcde@a0350000 { · line 1228

Quoted 8 lines
arch/arm/boot/dts/st/ste-dbx5x0.dtsi +0 -2
 		mcde@a0350000 {
@@ -1224,8 +1134,6 @@ mcde@a0350000 {
 			reg = <0xa0350000 0x1000>;
 			interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
 			power-domains = <&pm_domains DOMAIN_B2R2_MCDE>;
-			/* TODO: delete and replace with power-domain handling */
-			epod-supply = <&db8500_b2r2_mcde_reg>;

[Severity: Critical]
Similar to the mali-supply removal above, does dropping the epod-supply property break the display subsystem power management on older kernels that rely on it?

[Severity: Low]
Additionally, is epod-supply still required by the display subsystem binding schema? Documentation/devicetree/bindings/display/ste,mcde.yaml seems to still mandate epod-supply in its required: block.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11