2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
Commit Graph

241 Commits

Author SHA1 Message Date
Sukrut Bellary
36795548dc pmdomain: ti: Fix STANDBY handling of PER power domain
Per AM335x TRM[1](section 8.1.4.3 Power mode), in case of STANDBY,
PER domain should be ON. So, fix the PER power domain handling on standby.

[1] https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf

Signed-off-by: Sukrut Bellary <sbellary@baylibre.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Tested-by: Judith Mendez <jm@ti.com>
Link: https://lore.kernel.org/r/20250318230042.3138542-3-sbellary@baylibre.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-05-19 16:11:05 +02:00
Ulf Hansson
3611434467 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.15-rc[n] into the next branch, to allow
them to get tested together with the new changes that are targeted for
v6.16.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-05-08 13:31:15 +02:00
Dan Carpenter
0f5757667e pmdomain: core: Fix error checking in genpd_dev_pm_attach_by_id()
The error checking for of_count_phandle_with_args() does not handle
negative error codes correctly.  The problem is that "index" is a u32 so
in the condition "if (index >= num_domains)" negative error codes stored
in "num_domains" are type promoted to very high positive values and
"index" is always going to be valid.

Test for negative error codes first and then test if "index" is valid.

Fixes: 3ccf3f0cd1 ("PM / Domains: Enable genpd_dev_pm_attach_by_id|name() for single PM domain")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/aBxPQ8AI8N5v-7rL@stanley.mountain
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-05-08 13:29:30 +02:00
Christophe JAILLET
e3407cc5ee pmdomain: amlogic: Constify some structures
Most structures in this driver are not modified.

Constifying these structures moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers. (This is the case for see meson_ee_pwrc_domain_desc)

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   8924	   3832	      0	  12756	   31d4	drivers/pmdomain/amlogic/meson-ee-pwrc.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  12396	    336	      0	  12732	   31bc	drivers/pmdomain/amlogic/meson-ee-pwrc.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/edc560afe2a8763c93341d161daeb8b33ba606c6.1746199917.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-05-05 10:22:21 +02:00
Ulf Hansson
f80fa80a4e pmdomain: core: Use genpd->opp_table to simplify error/remove path
While we add an OF-provider we may, based upon a specific condition, also
assign genpd->opp_table. Rather using the same specific condition in the
error/remove path, let's check genpd->opp_table instead as it makes the
code easier.

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250417142513.312939-4-ulf.hansson@linaro.org
2025-05-02 12:34:06 +02:00
Ulf Hansson
f34a067627 pmdomain: core: Simplify return statement in genpd_power_off()
Rather than using two if-clauses immediately after each to check for
similar reasons to prevent the power-off, let's combine them into one
if-clause to simplify the code.

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250417142513.312939-3-ulf.hansson@linaro.org
2025-05-02 12:34:01 +02:00
Ulf Hansson
0e3b66725e pmdomain: core: Convert genpd_power_off() to void
At some point it made sense to have genpd_power_off() to return an error
code. That hasn't been the case for quite some time, so let's convert it
into a static void function and simplify some of the corresponding code.

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250417142513.312939-2-ulf.hansson@linaro.org
2025-05-02 12:33:06 +02:00
Ulf Hansson
4133b1c469 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.15-rc[n] into the next branch, to allow
them to get tested together with the new changes that are targeted for
v6.16.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-29 11:24:43 +02:00
Geert Uytterhoeven
13a6d42656 pmdomain: renesas: rcar: Remove obsolete nullify checks
All nullify users and helpers were removed, but the R-Car SYSC drivers
still checked for nullified domains.  Remove the obsolete checks.

Fixes: c8d8770444 ("pmdomain: renesas: rcar-sysc: Remove rcar_sysc_nullify() helper")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/107f2bf9f13b29f0f623d2959a5347ec151fb089.1745840768.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-29 11:22:27 +02:00
Ulf Hansson
54ce9aa582 pmdomain: core: Convert to device_awake_path()
As device_wakeup_path() is intended to be removed, let's switch to use the
device_awake_path() instead. No functional change.

Acked-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250425113942.134458-1-ulf.hansson@linaro.org
2025-04-29 11:19:49 +02:00
Chen-Yu Tsai
0c1ddc7bb3 pmdomain: mediatek: Add error messages for missing regmaps
A recent change to the syscon regmap API caused the MediaTek power
controller drivers to fail, as the required regmap could no longer be
retrieved. The error did not have an accompanying message, making the
failure less obvious. The aforementioned change has since been reverted.

Add error messages to all the regmap retrievals, thereby making all
error paths in scpsys_add_one_domain() have visible error messages.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20250421090951.395467-1-wenst@chromium.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-25 12:17:55 +02:00
Krzysztof Kozlowski
359a8ff433 pmdomain: arm: Do not enable by default during compile testing
Enabling the compile test should not cause automatic enabling of all
drivers, but only allow to choose to compile them.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20250417074645.81480-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-25 12:15:52 +02:00
Ajit Pandey
85728ba0c5 pmdomain: qcom: rpmhpd: Add SM4450 power domains
Add power domains exposed by RPMh in the Qualcomm SM4450 platform.

Signed-off-by: Ajit Pandey <quic_ajipan@quicinc.com>
Link: https://lore.kernel.org/r/20250417-sm4450_rpmhpd-v1-2-361846750d3a@quicinc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-24 18:01:50 +02:00
Andre Przywara
ca677196a9 pmdomain: sunxi: add H6 PRCM PPU driver
The Allwinner Power Reset Clock Management (RPCM) block contains a few
bits that control some power domains. The most prominent one is the one
for the Mali GPU. On the Allwinner H6 this domain is enabled at reset, so
we didn't care about it so far, but the H616 defaults to it being disabled.

Add a power domain driver for those bits. Some BSP code snippets and
some spare documentation describe three bits, slightly different between
the H6 and H616, so add three power domains for each SoC, connected to
their compatible string.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20250416224839.9840-3-andre.przywara@arm.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-24 17:47:16 +02:00
Stefan Wahren
f6a305309b pmdomain: bcm: bcm2835-power: Use devm_clk_get_optional
The driver tries to implement optional clock handling with devm_clk_get.
It treats all errors except EPROBE_DEFER as a missing clock, which is
not correct. So use devm_clk_get_optional here and get the corner-cases
right.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20250415190558.16354-1-wahrenst@gmx.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-23 14:32:13 +02:00
Finley Xiao
f89c082d44 pmdomain: rockchip: Add support for RK3562 SoC
This driver is modified to support RK3562 SoC.
Add support to ungate clk.
Add support to shut down memory for RK3562.

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20250415032314.44997-2-kever.yang@rock-chips.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-23 14:11:30 +02:00
AngeloGioacchino Del Regno
5342f018e9 pmdomain: mediatek: Add support for Dimensity 1200 MT6893
Add power domains definitions to implement support for the
MediaTek Dimensity 1200 (MT6893) SoC.

Since this chip's MTCMOS are similar to the ones of Kompanio
820 (MT8192), the definitions from that have been reused where
possible.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Link: https://lore.kernel.org/r/20250410143944.475773-4-angelogioacchino.delregno@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-23 10:28:13 +02:00
AngeloGioacchino Del Regno
92d25c5742 pmdomain: mediatek: Bump maximum bus protect data array elements
In preparation for adding support for the MediaTek Dimensity 1200
MT6893 SoC, bump the maximum elements of the bp_cfg array to 7.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Link: https://lore.kernel.org/r/20250410143944.475773-3-angelogioacchino.delregno@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-04-23 10:28:05 +02:00
Ulf Hansson
99012014c9 pmdomain: core: Reset genpd->states to avoid freeing invalid data
If genpd_alloc_data() allocates data for the default power-states for the
genpd, let's make sure to also reset the pointer in the error path. This
makes sure a genpd provider driver doesn't end up trying to free the data
again, but using an invalid pointer.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Link: https://lore.kernel.org/r/20250402120613.1116711-1-ulf.hansson@linaro.org
2025-04-23 10:08:34 +02:00
Ulf Hansson
0a8a888167 pmdomain: core: Add residency reflection for domain-idlestates to debugfs
For regular cpuidle states we are reflecting over the selected/entered
state to see if the sleep-duration meets the residency for the state. The
output from the reflection is an "above" value to indicate the number of
times the state was too deep and a "below" value for the number of times it
was too shallow.

Let's implement the similar thing for genpd's domain-idlestates along with
genpd's governor and put the information in the genpd's debugfs.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250314100103.1294715-5-ulf.hansson@linaro.org
2025-04-23 10:08:34 +02:00
Ulf Hansson
9861f21ff1 pmdomain: core: Add genpd helper to correct the usage/rejected counters
In the cpuidle-psci-domain case the ->power_off() callback is usually
returning zero to indicate success. This is because the actual call to the
PSCI FW to enter the selected domain-idlestate, needs to be done after the
->power_off() callback has returned.

When the call to the PSCI FW fails, this leads to receiving an incorrect
tracking of the usage/rejected counts for the selected domain-idlestate.
In other words, the presented debug-statistics for genpd may look better
than what the actually are.

To allow a better correctness of the data, let's add a new genpd helper
function, which enables the caller adjust the usage/rejected counters for a
domain-idlestate, in cases of errors during power-off.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250314100103.1294715-2-ulf.hansson@linaro.org
2025-04-23 10:08:33 +02:00
Sudeep Holla
6cf5db71dc pmdomain: arm: scmi_pm_domain: Remove redundant state verification
Currently, scmi_pd_power() explicitly verifies whether the requested
power state was applied by calling state_get(). While this check could
detect failures where the state was not properly updated, ensuring
correctness is the responsibility of the SCMI firmware.

Removing this redundant state_get() call eliminates an unnecessary
round-trip to the firmware, improving efficiency. Any mismatches
between the requested and actual states should be handled by the SCMI
firmware, which must return a failure if state_set() is unsuccessful.

Additionally, in some cases, checking the state after powering off a
domain may be unreliable or unsafe, depending on the firmware
implementation.

This patch removes the redundant verification, simplifying the function
without compromising correctness.

Reported-and-tested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20250314095851.443979-1-sudeep.holla@arm.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-17 11:12:01 +01:00
Arnd Bergmann
6ec7c4a297 pmdomain: thead: fix TH1520_AON_PROTOCOL dependency
Kconfig treats the dependency as optional, but the header file only provides
normal declarations and no empty API stubs:

ld: fs/btrfs/extent_io.o: in function `writepage_delalloc':
extent_io.c:(.text+0x2b42): undefined reference to `__udivdi3'
ld: drivers/pmdomain/thead/th1520-pm-domains.o: in function `th1520_pd_power_off':
th1520-pm-domains.c:(.text+0x57): undefined reference to `th1520_aon_power_update'
ld: drivers/pmdomain/thead/th1520-pm-domains.o: in function `th1520_pd_power_on':
th1520-pm-domains.c:(.text+0x8a): undefined reference to `th1520_aon_power_update'
ld: drivers/pmdomain/thead/th1520-pm-domains.o: in function `th1520_pd_probe':
th1520-pm-domains.c:(.text+0xb8): undefined reference to `th1520_aon_init'
ld: th1520-pm-domains.c:(.text+0x1c6): undefined reference to `th1520_aon_power_update'

Since the firmware code can easily be enabled for compile testing, there
is no need to add stubs either, so just make it a hard dependency.

Fixes: dc9a897dbb ("pmdomain: thead: Add power-domain driver for TH1520")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://lore.kernel.org/r/20250314154834.4053416-1-arnd@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-17 11:09:50 +01:00
Michal Wilczynski
dc9a897dbb pmdomain: thead: Add power-domain driver for TH1520
The T-Head TH1520 SoC contains multiple power islands that can be
programmatically turned on and off using the AON (Always-On) protocol
and a hardware mailbox [1]. The relevant mailbox driver has already been
merged into the mainline kernel in commit 5d4d263e1c ("mailbox:
Introduce support for T-head TH1520 Mailbox driver");

Introduce a power-domain driver for the TH1520 SoC, which is using AON
firmware protocol to communicate with E902 core through the hardware
mailbox. This way it can send power on/off commands to the E902 core.

The interaction with AUDIO power island e.g trying to turn it OFF proved
to crash the firmware running on the E902 core. Introduce the workaround
to disable interacting with the power island.

[1]
Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf

Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Acked-by: Drew Fustini <drew@pdp7.com>
Link: https://lore.kernel.org/r/20250311171900.1549916-5-m.wilczynski@samsung.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-13 14:42:06 +01:00
Ulf Hansson
b90a6e6061 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.14-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.15.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-05 15:52:15 +01:00
Xianwei Zhao
ef17b51908 pmdomain: amlogic: fix T7 ISP secpower
ISP and MIPI_ISP, these two have a parent-child relationship,
ISP depends on MIPI_ISP.

Fixes: ca75e4b214 ("pmdomain: amlogic: Add support for T7 power domains controller")
Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250303-fix-t7-pwrc-v1-1-b563612bcd86@amlogic.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-05 15:51:04 +01:00
Arnd Bergmann
a4cb906628 pmdomain: rockchip: add regulator dependency
When CONFIG_REGULATOR is disabled, this pmdomain driver fails to build:

drivers/pmdomain/rockchip/pm-domains.c:653:30: error: implicit declaration of function 'devm_of_regulator_get'; did you mean 'devm_regulator_get'? [-Wimplicit-function-declaration]
  653 |                 pd->supply = devm_of_regulator_get(pmu->dev, pd->node, "domain");
      |                              ^~~~~~~~~~~~~~~~~~~~~
      |                              devm_regulator_get
drivers/pmdomain/rockchip/pm-domains.c:653:28: error: assignment to 'struct regulator *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  653 |                 pd->supply = devm_of_regulator_get(pmu->dev, pd->node, "domain");
      |                            ^

Add a Kconfig dependency.

Fixes: db6df2e3fc ("pmdomain: rockchip: add regulator support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Dragan Simic <dsimic@manjaro.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20250304142803.689201-1-arnd@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-03-05 15:46:33 +01:00
Sebastian Reichel
db6df2e3fc pmdomain: rockchip: add regulator support
Some power domains require extra voltages to be applied. For example
trying to enable the GPU power domain on RK3588 fails when the SoC
does not have VDD GPU enabled. The same is expected to happen for
the NPU, which also has a dedicated supply line.

We get the regulator using devm_of_regulator_get(), so a missing
dependency in the devicetree is handled gracefully by printing a warning
and creating a dummy regulator. This is necessary, since existing DTs do
not have the regulator described. They might still work if the regulator
is marked as always-on. It is also working if the regulator is enabled
at boot time and the GPU driver is probed before the kernel disables
unused regulators.

The regulator itself is not acquired at driver probe time, since that
creates an unsolvable circular dependency. The power domain driver must
be probed early, since SoC peripherals need it. Regulators on the other
hand depend on SoC peripherals like SPI, I2C or GPIO. MediaTek does not
run into this, since they have two power domain drivers.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-7-a4f9c24e5b81@kernel.org
[Ulf: Fixed conflict when applying]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-28 13:10:28 +01:00
Peter Geis
6b2690df3f pmdomain: rockchip: fix rockchip_pd_power error handling
The calls rockchip_pd_power makes to rockchip_pmu_set_idle_request lack
any return error handling, causing device drivers to incorrectly believe
the hardware idle requests succeed when they may have failed. This leads
to software possibly accessing hardware that is powered off and the
subsequent SError panic that follows.

Add error checking and return errors to the calling function to prevent
such crashes.

gst-launch-1.0 videotestsrc num-buffers=2000 ! v4l2jpegenc ! fakesink
Setting pipeline to PAUSED ...er-x64
Pipeline is PREROLLING ...
Redistribute latency...
rockchip-pm-domain ff100000.syscon:power-controller: failed to get ack on domain 'hevc', val=0x98260
SError Interrupt on CPU2, code 0x00000000bf000002 -- SError

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Link: https://lore.kernel.org/r/20241214215802.23989-1-pgwipeout@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-5-a4f9c24e5b81@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-28 13:07:04 +01:00
Sebastian Reichel
edcef66707 pmdomain: rockchip: reduce indentation in rockchip_pd_power
Rework the logic, so that the function exits early when the
power domain state is already correct to reduce code indentation.

No functional change intended.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Adrian Larumbe <adrian.larumbe@collabora.com> # On Rock 5B
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-4-a4f9c24e5b81@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-28 13:06:53 +01:00
Sebastian Reichel
7ab6c930b9 pmdomain: rockchip: forward rockchip_do_pmu_set_power_domain errors
Currently rockchip_do_pmu_set_power_domain prints a warning if there
have been errors turning on the power domain, but it does not return
any errors and rockchip_pd_power() tries to continue setting up the
QOS registers. This usually results in accessing unpowered registers,
which triggers an SError and a full system hang.

This improves the error handling by forwarding the error to avoid
kernel panics.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Adrian Larumbe <adrian.larumbe@collabora.com> # On Rock 5B
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-3-a4f9c24e5b81@kernel.org
[Ulf: Fixed conflict when applying]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-28 13:04:50 +01:00
Sebastian Reichel
83b2fbac89 pmdomain: rockchip: cleanup mutex handling in rockchip_pd_power
Use the cleanup infrastructure to handle the mutex, which
slightly improve code readability for this function.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Adrian Larumbe <adrian.larumbe@collabora.com> # On Rock 5B
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250220-rk3588-gpu-pwr-domain-regulator-v6-2-a4f9c24e5b81@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-28 12:52:34 +01:00
Ulf Hansson
36ccabe59d pmdomain: Merge branch rockchip into next
Merge the immutable branch rockchip into next, to allow it to be tested
together with the changes that are targeted for v6.15.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-24 13:11:42 +01:00
Ulf Hansson
bc4bc2a160 pmdomain: rockchip: Fix build error
To resolve the build error with undefined reference to
`arm_smccc_1_1_get_conduit', let's add a build dependency to
HAVE_ARM_SMCCC_DISCOVERY.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: 61eeb96787 ("pmdomain: rockchip: Check if SMC could be handled by TA")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-24 13:05:29 +01:00
Ahmad Fatoum
6568cb40e7 pmdomain: imx: gpcv2: use proper helper for property detection
Starting with commit c141ecc3ce ("of: Warn when of_property_read_bool()
is used on non-boolean properties"), probing the gpcv2 device on i.MX8M
SoCs leads to warnings when LOCKDEP is enabled.

Fix this by checking property presence with of_property_present as
intended.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.kernel.org/r/20250218-gpcv2-of-property-present-v1-1-3bb1a9789654@pengutronix.de
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-19 12:59:09 +01:00
Ulf Hansson
00fa8243e5 pmdomain: Merge branch rockchip into next
Merge the immutable branch rockchip into next, to allow it to be tested
together with the changes that are targeted for v6.15.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-19 12:48:23 +01:00
Shawn Lin
61eeb96787 pmdomain: rockchip: Check if SMC could be handled by TA
Non-existent trusted-firmware could lead to SMC calls into some unset
location, that breaks the system. Let's check that it's supported before
executing the SMC.

Reported-by: Steven Price <steven.price@arm.com>
Suggested-by: Heiko Stuebner <heiko@sntech.de>
Fixes: 58ebba35dd ("pmdomain: rockchip: Add smc call to inform firmware")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/1739926689-151827-1-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-19 12:44:33 +01:00
Geert Uytterhoeven
c2851be5f1 pmdomain: renesas: rcar-sysc: Drop fwnode_dev_initialized() call
As of commit bab2d712ee ("PM: domains: Mark fwnodes when their
powerdomain is added/removed") in v5.12, the pmdomain core takes care of
marking the fwnode initialized, so there is no need to repeat it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/05c2ef630694a28b560426d8c426881cc14e8f7c.1738748678.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-14 12:24:12 +01:00
Andras Szemzo
c41bac728a pmdomain: sunxi: add V853 ppu support
V853 has a similar ppu like Allwinner D1, add compatible and the available pd names.

Signed-off-by: Andras Szemzo <szemzo.andras@gmail.com>
Link: https://lore.kernel.org/r/20250205125225.1152849-7-szemzo.andras@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-14 12:23:05 +01:00
Ulf Hansson
7ad91e9c4a mdomain: Merge branch rockchip into next
Merge the immutable branch rockchip into next, to allow it to be tested
together with the changes that are targeted for v6.15.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-13 14:51:28 +01:00
Shawn Lin
58ebba35dd pmdomain: rockchip: Add smc call to inform firmware
Inform firmware to keep the power domain on or off.

Suggested-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/1738736156-119203-5-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-13 14:47:48 +01:00
Ulf Hansson
cd3fa304ba pmdomain: core: Introduce dev_pm_genpd_rpm_always_on()
For some usecases a consumer driver requires its device to remain power-on
from the PM domain perspective during runtime. Using dev PM qos along with
the genpd governors, doesn't work for this case as would potentially
prevent the device from being runtime suspended too.

To support these usecases, let's introduce dev_pm_genpd_rpm_always_on() to
allow consumers drivers to dynamically control the behaviour in genpd for a
device that is attached to it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1738736156-119203-4-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-13 14:47:48 +01:00
Stefan Wahren
43b73a5a03 pmdomain: bcm2835-power: set flag GENPD_FLAG_ACTIVE_WAKEUP
Set flag GENPD_FLAG_ACTIVE_WAKEUP to bcm2835_power genpd, then when a
device is set as wakeup source using device_set_wakeup_enable, the power
domain could be kept on to make sure the device could wakeup the system.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20250201111926.31278-1-wahrenst@gmx.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-13 14:43:02 +01:00
Geert Uytterhoeven
c4f5ac99f8 pmdomain: ti: Use of_property_present() for non-boolean properties
On BeagleBone Black:

    OF: /ocp: Read of boolean property 'clocks' with a value.
    OF: /ocp/interconnect@44c00000: Read of boolean property 'clocks' with a value.
    OF: /ocp/interconnect@48000000: Read of boolean property 'clocks' with a value.
    OF: /ocp/interconnect@4a000000: Read of boolean property 'clocks' with a value.

The use of of_property_read_bool() for non-boolean properties is
deprecated in favor of of_property_present() when testing for property
presence.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/accb12bd6d048d95bd1feea07dd1a799ad3f8b31.1737532423.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-02-13 14:43:02 +01:00
Christian Marangi
885f5669f2 pmdomain: airoha: Fix compilation error with Clang-20 and Thumb2 mode
The use of R7 in the SMCCC conflicts with the compiler's use of R7 as a frame
pointer in Thumb2 mode, which is forcibly enabled by Clang when profiling
hooks are inserted via the -pg switch.

This is a known issue and similar driver workaround this with a Makefile
ifdef. Exact workaround are applied in
drivers/firmware/arm_scmi/transports/Makefile and other similar driver.

Suggested-by: Sudeep Holla <sudeep.holla@arm.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501201840.XmpHXpQ4-lkp@intel.com/
Fixes: 82e703dd43 ("pmdomain: airoha: Add Airoha CPU PM Domain support")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20250120153817.11807-1-ansuelsmth@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-01-21 10:45:24 +01:00
Sudeep Holla
c2d7aa308e pmdomain: arm: scmi_pm_domain: Send an explicit request to set the current state
On a system with multiple active SCMI agents, one agent(other than OSPM/
Linux or bootloader) would request to turn on a shared power domain
before the Linux boots/initialise the genpds. So when the Linux boots
and gets the power state as already ON, it just registers the genpd with
a default ON state.

However, when the driver that needs this shared power domain is probed
genpd sees that the power domain status is ON and never makes any SCMI
call to power it up which is correct. But, since Linux didn't make an
explicit request to turn on the shared power domain, the SCMI platform
firmware will not know if the OSPM agent is actively using it.

Suppose the other agent that requested the shared power domain to be
powered ON requests to power it OFF as it no longer needs it, the SCMI
platform firmware needs to turn it off if there are no active users of
it which in the above scenaro is the case.

As a result of SCMI platform firmware turning off the resource, OSPM/
Linux will crash the moment as it expects the shared power domain to be
powered ON.

Send an explicit request to set the current state when setting up the
genpd power domains so that OSPM registers its vote in the power domain
state with the SCMI platform firmware.

The other option is to not read the state and set the genpds as default
OFF, but it can't handle the scenario on certain platforms where SCMI
platform keeps all the power domains turned ON by default for faster boot
(or any other such variations) and expect the OSPM to turn off the unused
domains if power saving is required.

Link: https://lore.kernel.org/all/Z4aBkezSWOPCXcUh@bogus
Reported-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Reported-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20250115113931.1181309-1-sudeep.holla@arm.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-01-17 12:17:16 +01:00
Ulf Hansson
9cba694710 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.13-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.14.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-01-16 16:55:54 +01:00
Xiaolei Wang
726efa92e0 pmdomain: imx8mp-blk-ctrl: add missing loop break condition
Currently imx8mp_blk_ctrl_remove() will continue the for loop
until an out-of-bounds exception occurs.

pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : dev_pm_domain_detach+0x8/0x48
lr : imx8mp_blk_ctrl_shutdown+0x58/0x90
sp : ffffffc084f8bbf0
x29: ffffffc084f8bbf0 x28: ffffff80daf32ac0 x27: 0000000000000000
x26: ffffffc081658d78 x25: 0000000000000001 x24: ffffffc08201b028
x23: ffffff80d0db9490 x22: ffffffc082340a78 x21: 00000000000005b0
x20: ffffff80d19bc180 x19: 000000000000000a x18: ffffffffffffffff
x17: ffffffc080a39e08 x16: ffffffc080a39c98 x15: 4f435f464f006c72
x14: 0000000000000004 x13: ffffff80d0172110 x12: 0000000000000000
x11: ffffff80d0537740 x10: ffffff80d05376c0 x9 : ffffffc0808ed2d8
x8 : ffffffc084f8bab0 x7 : 0000000000000000 x6 : 0000000000000000
x5 : ffffff80d19b9420 x4 : fffffffe03466e60 x3 : 0000000080800077
x2 : 0000000000000000 x1 : 0000000000000001 x0 : 0000000000000000
Call trace:
 dev_pm_domain_detach+0x8/0x48
 platform_shutdown+0x2c/0x48
 device_shutdown+0x158/0x268
 kernel_restart_prepare+0x40/0x58
 kernel_kexec+0x58/0xe8
 __do_sys_reboot+0x198/0x258
 __arm64_sys_reboot+0x2c/0x40
 invoke_syscall+0x5c/0x138
 el0_svc_common.constprop.0+0x48/0xf0
 do_el0_svc+0x24/0x38
 el0_svc+0x38/0xc8
 el0t_64_sync_handler+0x120/0x130
 el0t_64_sync+0x190/0x198
Code: 8128c2d0 ffffffc0 aa1e03e9 d503201f

Fixes: 556f5cf956 ("soc: imx: add i.MX8MP HSIO blk-ctrl")
Cc: stable@vger.kernel.org
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20250115014118.4086729-1-xiaolei.wang@windriver.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-01-16 16:10:32 +01:00
Christian Marangi
82e703dd43 pmdomain: airoha: Add Airoha CPU PM Domain support
Add Airoha CPU PM Domain support to control frequency and power of CPU
present on Airoha EN7581 SoC.

Frequency and power can be controlled with the use of the SMC command by
passing the performance state. The driver also expose a read-only clock
that expose the current CPU frequency with SMC command.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20250109131313.32317-1-ansuelsmth@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2025-01-16 16:01:27 +01:00
Ulf Hansson
094041b176 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.13-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.14.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-19 15:49:44 +01:00