Commit Graph

192 Commits

Author SHA1 Message Date
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
Lucas Stach
f64f610ec6 pmdomain: core: add dummy release function to genpd device
The genpd device, which is really only used as a handle to lookup
OPP, but not even registered to the device core otherwise and thus
lifetime linked to the genpd struct it is contained in, is missing
a release function. After b8f7bbd1f4 ("pmdomain: core: Add
missing put_device()") the device will be cleaned up going through
the driver core device_release() function, which will warn when no
release callback is present for the device. Add a dummy release
function to shut up the warning.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Fixes: b8f7bbd1f4 ("pmdomain: core: Add missing put_device()")
Cc: stable@vger.kernel.org
Message-ID: <20241218184433.1930532-1-l.stach@pengutronix.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-19 15:47:02 +01:00
Joe Hattori
469c0682e0 pmdomain: imx: gpcv2: fix an OF node reference leak in imx_gpcv2_probe()
imx_gpcv2_probe() leaks an OF node reference obtained by
of_get_child_by_name(). Fix it by declaring the device node with the
__free(device_node) cleanup construct.

This bug was found by an experimental static analysis tool that I am
developing.

Fixes: 03aa12629f ("soc: imx: Add GPCv2 power gating driver")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Cc: stable@vger.kernel.org
Message-ID: <20241215030159.1526624-1-joe@pf.is.s.u-tokyo.ac.jp>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-19 15:26:37 +01:00
Kevin Hilman
b06bc47279 pmdomain: ti_sci: handle wake IRQs for IO daisy chain wakeups
When a device supports IO daisy-chain wakeups, it uses a dedicated
wake IRQ.  Devices with IO daisy-chain wakeups enabled should not set
wakeup constraints since these can happen even from deep power states,
so should not prevent the DM from picking deep power states.

Wake IRQs are set with dev_pm_set_wake_irq() or
dev_pm_set_dedicated_wake_irq().  The latter is used by the serial
driver used on K3 platforms (drivers/tty/serial/8250/8250_omap.c)
when the interrupts-extended property is used to describe the
dedicated wakeup interrupt.

Detect these wake IRQs in the suspend path, and if set, skip sending
constraint.

Tested-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241206-lpm-v6-10-constraints-pmdomain-v6-3-833980158c68@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:37:26 +01:00
Kevin Hilman
9d8aa0dd3b pmdomain: ti_sci: add wakeup constraint management
During system-wide suspend, check all devices connected to PM domain
to see if they are wakeup-enabled.  If so, set a TI SCI device
constraint.

Note: DM firmware clears all constraints on resume.

Co-developed-by: Vibhore Vardhan <vibhore@ti.com>
Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241206-lpm-v6-10-constraints-pmdomain-v6-2-833980158c68@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:37:26 +01:00
Kevin Hilman
b5fc945365 pmdomain: ti_sci: add per-device latency constraint management
For each device in a TI SCI PM domain, check whether the device has
any resume latency constraints set via per-device PM QoS.  If
constraints are set, send them to DM via the new SCI constraints API.

Checking for constraints happen for each device before system-wide
suspend (via ->suspend() hook.)

An important detail here is that the PM domain driver inserts itself
into the path of both the ->suspend() and ->resume() hook path
of *all* devices in the PM domain.  This allows generic PM domain code
to handle the constraint management and communication with TI SCI.

Further, this allows device drivers to use existing PM QoS APIs to
add/update constraints.

DM firmware clears constraints during its resume, so Linux has
to check/update/send constraints each time system suspends.

Also note that the PM QoS framework uses usecs as the units for
latency whereas the TI SCI firmware uses msecs, so a conversion is
needed before passing to TI SCI.

Co-developed-by: Vibhore Vardhan <vibhore@ti.com>
Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241206-lpm-v6-10-constraints-pmdomain-v6-1-833980158c68@baylibre.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:37:26 +01:00
Peng Fan
e1a8757034 pmdomain: imx-gpcv2: Suppress bind attrs
The gpcv2 drivers on imx8m series are registered as platform
devices and this opens the possibility of reloading the driver
at runtime.

But this doesn't actually work. There are some hardware sequence
dependecy between blk ctrl and gpc, also power domains are used
by other peripherals, so fix this by explicitly suppressing bind
attrs.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-ID: <20241206112731.98244-2-peng.fan@oss.nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:37:20 +01:00
Peng Fan
afb2a86f00 pmdomain: imx8m[p]-blk-ctrl: Suppress bind attrs
The blk ctrl drivers on imx8m series are registered as platform
devices and this opens the possibility of reloading the driver
at runtime.

But this doesn't actually work. There are some hardware sequence
dependecy between blk ctrl and gpc, also power domains are used
by other peripherals, so fix this by explicitly suppressing bind
attrs.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-ID: <20241206112731.98244-1-peng.fan@oss.nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:34:52 +01:00
Konrad Dybcio
b04b981f3a pmdomain: core: Support naming idle states
Commit 422f2d4181 ("arm64: dts: qcom: Drop undocumented domain
"idle-state-name"") brought to light the common misbelief that
idle-state-names also applies to e.g. PSCI power domain idle states.

Make that a reality, mimicking the property name used by cpuidle
states.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Message-ID: <20241130-topic-idle_state_name-v1-2-d0ff67b0c8e9@oss.qualcomm.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-10 12:16:43 +01:00
Linus Torvalds
fa4c221fa1 pmdomain core:
- Fix a couple of memory-leaks during genpd init/remove
 
 pmdomain providers:
  - imx: Adjust delay for gpcv2 to fix power up handshake
  - mediatek: Fix DT bindings by adding another nested power-domain layer
 -----BEGIN PGP SIGNATURE-----
 
 iQJLBAABCgA1FiEEugLDXPmKSktSkQsV/iaEJXNYjCkFAmdSt34XHHVsZi5oYW5z
 c29uQGxpbmFyby5vcmcACgkQ/iaEJXNYjCndLxAA1LCeZzCj2nolAmr6W0MZcH2/
 RWqiAMIecjAcLDVp5y0Ld9dV/c44AWRzxc2kE8L1EehDlVATWZlNo6p4c2EPCJhh
 C0SXJx3Dh7MLJuwNxTno8cxUKsKVArFUd6X4jbiPoDNgKfMYols/9N9KdR/QCbFI
 SEwpwJlerOn6UeTAP7nEattelX/4CjamzwDqVoScIANIN3wuDXrVmgdTpjZPLmyM
 HWYTwraA6gqzEcp/QkfyoFasWWFBD4eQgGssbb6qnxeqWUnGON1VJLOuC2QDIQS/
 4swsS08rG3SrKnbvXepOnb6ToW7L7KR8qbjc02sDrrTPp9lrmPIt7XG1thcOhxYw
 wUXpVUM48AbgfRnZct870HUiZ1aWE0SswsOMlLTv7G5zIILKb+huKvnN0dMHJn70
 flno1+ORGQs+flHRN8DhmZop9wYa+62xljIFSjTJkoFkq7VGLKWevqZE28L8CGY+
 VwXoc2gn+qPaJs7mhNOyk/v11CQEWxVMM2dRhXrAjK5/h/wnQGdavwbpdLdla5rL
 mV9E0bEPeafYrWIfQHnEGOOZWpsK2seAJx2+0kE38/0d1UVzFlxPMjyakLeURvYG
 bsJRwxkEjTb4TkmyRbyFQPps99L1vOy/T1wvT01lgM2BrPtyeeJK1XaA2O16B/WE
 0gjYeGq59UYFhrAHOok=
 =fCUR
 -----END PGP SIGNATURE-----

Merge tag 'pmdomain-v6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm

Pull pmdomain fixes from Ulf Hansson:
 "Core:
   - Fix a couple of memory-leaks during genpd init/remove

  Providers:
   - imx: Adjust delay for gpcv2 to fix power up handshake
   - mediatek: Fix DT bindings by adding another nested power-domain
     layer"

* tag 'pmdomain-v6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
  pmdomain: imx: gpcv2: Adjust delay after power up handshake
  pmdomain: core: Fix error path in pm_genpd_init() when ida alloc fails
  pmdomain: core: Add missing put_device()
  dt-bindings: power: mediatek: Add another nested power-domain layer
2024-12-06 11:24:00 -08:00
Shengjiu Wang
2379fb937d pmdomain: imx: gpcv2: Adjust delay after power up handshake
The udelay(5) is not enough, sometimes below kernel panic
still be triggered:

[    4.012973] Kernel panic - not syncing: Asynchronous SError Interrupt
[    4.012976] CPU: 2 UID: 0 PID: 186 Comm: (udev-worker) Not tainted 6.12.0-rc2-0.0.0-devel-00004-g8b1b79e88956 #1
[    4.012982] Hardware name: Toradex Verdin iMX8M Plus WB on Dahlia Board (DT)
[    4.012985] Call trace:
[...]
[    4.013029]  arm64_serror_panic+0x64/0x70
[    4.013034]  do_serror+0x3c/0x70
[    4.013039]  el1h_64_error_handler+0x30/0x54
[    4.013046]  el1h_64_error+0x64/0x68
[    4.013050]  clk_imx8mp_audiomix_runtime_resume+0x38/0x48
[    4.013059]  __genpd_runtime_resume+0x30/0x80
[    4.013066]  genpd_runtime_resume+0x114/0x29c
[    4.013073]  __rpm_callback+0x48/0x1e0
[    4.013079]  rpm_callback+0x68/0x80
[    4.013084]  rpm_resume+0x3bc/0x6a0
[    4.013089]  __pm_runtime_resume+0x50/0x9c
[    4.013095]  pm_runtime_get_suppliers+0x60/0x8c
[    4.013101]  __driver_probe_device+0x4c/0x14c
[    4.013108]  driver_probe_device+0x3c/0x120
[    4.013114]  __driver_attach+0xc4/0x200
[    4.013119]  bus_for_each_dev+0x7c/0xe0
[    4.013125]  driver_attach+0x24/0x30
[    4.013130]  bus_add_driver+0x110/0x240
[    4.013135]  driver_register+0x68/0x124
[    4.013142]  __platform_driver_register+0x24/0x30
[    4.013149]  sdma_driver_init+0x20/0x1000 [imx_sdma]
[    4.013163]  do_one_initcall+0x60/0x1e0
[    4.013168]  do_init_module+0x5c/0x21c
[    4.013175]  load_module+0x1a98/0x205c
[    4.013181]  init_module_from_file+0x88/0xd4
[    4.013187]  __arm64_sys_finit_module+0x258/0x350
[    4.013194]  invoke_syscall.constprop.0+0x50/0xe0
[    4.013202]  do_el0_svc+0xa8/0xe0
[    4.013208]  el0_svc+0x3c/0x140
[    4.013215]  el0t_64_sync_handler+0x120/0x12c
[    4.013222]  el0t_64_sync+0x190/0x194
[    4.013228] SMP: stopping secondary CPUs

The correct way is to wait handshake, but it needs BUS clock of
BLK-CTL be enabled, which is in separate driver. So delay is the
only option here. The udelay(10) is a data got by experiment.

Fixes: e8dc41afca ("pmdomain: imx: gpcv2: Add delay after power up handshake")
Reported-by: Francesco Dolcini <francesco@dolcini.it>
Closes: https://lore.kernel.org/lkml/20241007132555.GA53279@francesco-nb/
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Cc: stable@vger.kernel.org
Message-ID: <20241121075231.3910922-1-shengjiu.wang@nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-12-02 17:09:26 +01:00
Ulf Hansson
3e3b71d35a pmdomain: core: Fix error path in pm_genpd_init() when ida alloc fails
When the ida allocation fails we need to free up the previously allocated
memory before returning the error code. Let's fix this and while at it,
let's also move the ida allocation to genpd_alloc_data() and the freeing to
genpd_free_data(), as it better belongs there.

Fixes: 899f44531f ("pmdomain: core: Add GENPD_FLAG_DEV_NAME_FW flag")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Message-ID: <20241122134207.157283-3-ulf.hansson@linaro.org>
2024-12-02 17:06:09 +01:00
Ulf Hansson
b8f7bbd1f4 pmdomain: core: Add missing put_device()
When removing a genpd we don't clean up the genpd->dev correctly. Let's add
the missing put_device() in genpd_free_data() to fix this.

Fixes: 401ea1572d ("PM / Domain: Add struct device to genpd")
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Message-ID: <20241122134207.157283-2-ulf.hansson@linaro.org>
2024-12-02 17:06:09 +01:00
Linus Torvalds
e70140ba0d Get rid of 'remove_new' relic from platform driver struct
The continual trickle of small conversion patches is grating on me, and
is really not helping.  Just get rid of the 'remove_new' member
function, which is just an alias for the plain 'remove', and had a
comment to that effect:

  /*
   * .remove_new() is a relic from a prototype conversion of .remove().
   * New drivers are supposed to implement .remove(). Once all drivers are
   * converted to not use .remove_new any more, it will be dropped.
   */

This was just a tree-wide 'sed' script that replaced '.remove_new' with
'.remove', with some care taken to turn a subsequent tab into two tabs
to make things line up.

I did do some minimal manual whitespace adjustment for places that used
spaces to line things up.

Then I just removed the old (sic) .remove_new member function, and this
is the end result.  No more unnecessary conversion noise.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-01 15:12:43 -08:00
Jishnu Prakash
3d25d46a25 pmdomain: qcom: rpmhpd: Add rpmhpd support for SM8750
This adds the RPMHPD present in SM8750 SoCs.

Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
Signed-off-by: Taniya Das <quic_tdas@quicinc.com>
Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
Message-ID: <20241112002444.2802092-3-quic_molvera@quicinc.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-11-12 19:46:51 +01:00
Rob Herring (Arm)
8d04dfdbc3 pmdomain: imx: Use of_property_present() for non-boolean properties
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: Rob Herring (Arm) <robh@kernel.org>
Message-ID: <20241104190742.276710-1-robh@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-11-12 19:46:51 +01:00
Ulf Hansson
bc4fc409f4 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.12-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.13.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-11-01 12:56:48 +01:00
Peng Fan
f7c7c5aa55 pmdomain: imx93-blk-ctrl: correct remove path
The check condition should be 'i < bc->onecell_data.num_domains', not
'bc->onecell_data.num_domains' which will make the look never finish
and cause kernel panic.

Also disable runtime to address
"imx93-blk-ctrl 4ac10000.system-controller: Unbalanced pm_runtime_enable!"

Fixes: e9aa77d413 ("soc: imx: add i.MX93 media blk ctrl driver")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Cc: stable@vger.kernel.org
Message-ID: <20241101101252.1448466-1-peng.fan@oss.nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-11-01 12:53:16 +01:00
Dario Binacchi
da3d242cf1 pmdomain: imx: gpcv2: replace dev_err() with dev_err_probe()
The patch standardizes the probe() code by replacing the two occurrences
of dev_err() with dev_err_probe(). Indeed, dev_err_probe() was used in all
other error paths of the probe() function.
Note that dev_err_probe() has advantages even if the error code is not
EPROBE_DEFER, such as the symbolic output of the error code. Therefore,
it should generally be preferred over dev_err().

Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Message-ID: <20241025160430.4113467-1-dario.binacchi@amarulasolutions.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-31 11:41:20 +01:00
Zhang Zekun
88e98cd5d3 pmdomain: ti-sci: Use scope based of_node_put() to simplify code.
Use scope based of_node_put() to simplify the code logic, and we don't
need to call of_node_put(). Besides, put of_parse_phandle_with_args() in
the while loop to make code more simple.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241024030442.119506-3-zhangzekun11@huawei.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-31 11:30:57 +01:00
Zhang Zekun
afc2331ef8 pmdomain: ti-sci: Add missing of_node_put() for args.np
of_parse_phandle_with_args() needs to call of_node_put() to decrement
the refcount of args.np. So, Add the missing of_node_put() in the loop.

Fixes: efa5c01cd7 ("soc: ti: ti_sci_pm_domains: switch to use multiple genpds instead of one")
Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Message-ID: <20241024030442.119506-2-zhangzekun11@huawei.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-31 11:30:57 +01:00
Ulf Hansson
cc8eeff3e8 pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.12-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.13.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-30 17:14:44 +01:00
Thomas Richard
15d392281d pmdomain: ti-sci: set the GENPD_FLAG_ACTIVE_WAKEUP flag for all PM domains
With this flag, if a device is marked on the wakeup path, the corresponding
PM domain is kept powered on.

This commit fixes the no_console_suspend support for some TI platforms
(tested on J7200). In case of no_console_suspend the serial core marks the
device on the wakeup path, but without this patch the power domain is
powered off anyway.

Suggested-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Link: https://lore.kernel.org/r/20241022-8250-omap-no-console-suspend-v2-1-cc3d102b8a1e@bootlin.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-30 17:14:00 +01:00
Sibi Sankar
0bf0203442 pmdomain: arm: Use FLAG_DEV_NAME_FW to ensure unique names
The domain attributes returned by the perf protocol can end up reporting
identical names across domains, resulting in debugfs node creation failure.
Use the GENPD_FLAG_DEV_NAME_FW to ensure the genpd providers end up with an
unique name.

Logs: [X1E reports 'NCC' for all its scmi perf domains]
debugfs: Directory 'NCC' with parent 'pm_genpd' already present!
debugfs: Directory 'NCC' with parent 'pm_genpd' already present!

Reported-by: Johan Hovold <johan+linaro@kernel.org>
Closes: https://lore.kernel.org/lkml/ZoQjAWse2YxwyRJv@hovoldconsulting.com/
Suggested-by: Ulf Hansson <ulf.hansson@linaro.org>
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
Cc: stable@vger.kernel.org
Message-ID: <20241030125512.2884761-6-quic_sibis@quicinc.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-30 17:11:56 +01:00
Sibi Sankar
899f44531f pmdomain: core: Add GENPD_FLAG_DEV_NAME_FW flag
Introduce GENPD_FLAG_DEV_NAME_FW flag which instructs genpd to generate
an unique device name using ida. It is aimed to be used by genpd providers
which derive their names directly from FW making them susceptible to
debugfs node creation failures.

Reported-by: Johan Hovold <johan+linaro@kernel.org>
Closes: https://lore.kernel.org/lkml/ZoQjAWse2YxwyRJv@hovoldconsulting.com/
Fixes: 718072ceb2 ("PM: domains: create debugfs nodes when adding power domains")
Suggested-by: Ulf Hansson <ulf.hansson@linaro.org>
Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
Cc: stable@vger.kernel.org
Message-ID: <20241030125512.2884761-5-quic_sibis@quicinc.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-30 17:11:28 +01:00
Yassine Oudjana
c2114a0d17 pmdomain: mediatek: Add support for MT6735
Add support for SCPSYS power domains of MT6735. All non-CPU power domains
are added except for MD2 (C2K modem), which is left out due to issues
with powering it on.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20241017085136.68053-3-y.oudjana@protonmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-22 13:08:11 +02:00
Dmitry Baryshkov
5473cff939 pmdomain: qcom: rpmhpd: add support for SAR2130P
Define power domains as supported by the RPMh on the SAR2130P platform.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20241017-sar2130p-rpmhpd-v1-2-f4bf7f6fd12e@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-22 13:06:41 +02:00
Ulf Hansson
e130ca9d48 pmdomain: core: Set the required dev for a required OPP during genpd attach
In the single PM domain case there is no need for platform code to specify
the index of the corresponding required OPP in DT, as the index must be
zero. This allows us to assign a required dev for the required OPP from
genpd, while attaching a device to its PM domain.

In this way, we can remove some of the genpd specific code in the OPP core
for the single PM domain case. Although, this cleanup is made from a
subsequent change.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20241002122232.194245-7-ulf.hansson@linaro.org
2024-10-10 14:15:10 +02:00
Ulf Hansson
cf06fb6f0b pmdomain: core: Manage the default required OPP from a separate function
To improve the readability of the code in __genpd_dev_pm_attach(), let's
move out the required OPP handling into a separate function.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20241002122232.194245-6-ulf.hansson@linaro.org
2024-10-10 14:14:36 +02:00
Ulf Hansson
69f4d1b1cb pmdomain: Merge branch fixes into next
Merge the pmdomain fixes for v6.12-rc[n] into the next branch, to allow them
to get tested together with the new changes that are targeted for v6.13.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-02 12:56:08 +02:00
Tingguo Cheng
ba84ca67ac pmdomain: qcom: rpmhpd: Add qcs615 power domains
Add support for power domains exposed by RPMh on the qcs615 platform.
Only CX/CX_AO are exposed by RPMh. Consumers such as VDD_MX, EBI, LPI_
MX and LPI_CX will share the power domains.

Signed-off-by: Tingguo Cheng <quic_tingguoc@quicinc.com>
Link: https://lore.kernel.org/r/20240927-add_qcs615_qcs8300_powerdomains_driver_support-v2-4-18c030ad7b68@quicinc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-02 12:52:57 +02:00
Tingguo Cheng
aaccaf7aa1 pmdomain: qcom: rpmhpd: Add qcs8300 power domains
Add support for the power domains exposed by RPMh on the qcs8300
platform. MMCX depends on CX, so mark CX as the parent of MMCX.

Co-developed-by: Shazad Hussain <quic_shazhuss@quicinc.com>
Signed-off-by: Shazad Hussain <quic_shazhuss@quicinc.com>
Signed-off-by: Tingguo Cheng <quic_tingguoc@quicinc.com>
Link: https://lore.kernel.org/r/20240927-add_qcs615_qcs8300_powerdomains_driver_support-v2-2-18c030ad7b68@quicinc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-02 12:52:57 +02:00
Zhang Zekun
500580c7ae pmdomain: qcom-cpr: Fix the return of uninitialized variable
The of_property_read_u64() can fail and remain the variable uninitialized,
which will then be returned. Initializing the variable "rate" to zero to
fix this problem.

Fixes: 181c814855 ("pmdomain: qcom-cpr: Use scope based of_node_put() to simplify code.")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/455a6a49-41d2-4a20-9a31-f57ee7a67920@huawei.com/T/#m0a62b501b453a6d6e94c52a428a66f65b5422c65
Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240926134211.45394-1-zhangzekun11@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-02 12:38:53 +02:00
Chen-Yu Tsai
ca824b2d69 pmdomain: mediatek: Use OF-specific regulator API to get power domain supply
The MediaTek power domain driver contains a hack that assigns the device
node of the power domain to the struct device of the power domain
controller in order to use the devres regulator API.

Now that there is a proper OF-specific regulator API, and even a devres
version, replace the hack with proper code.

This change is incompatible with incomplete device trees. Instead of
assigning the dummy regulator in cases where the power domain requires
a supply but the device tree does not provide one, the driver will just
error out. This will be seen on the MT8390 EVK, which is missing
supplies for the IMG_VCORE and CAM_VCORE domains. And likely all the
MediaTek EVBs, which have no power domain supplies specified. This is
however the correct behavior. If the power domain's supply is missing,
then it should not work. Relying on other parts of the system to keep
the unattached regulator enabled is likely to break in ways less easier
to understand.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/20240930044525.2043884-4-wenst@chromium.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-10-02 12:28:30 +02:00
Geert Uytterhoeven
c6ccb691d4 pmdomain: core: Reduce debug summary table width
Commit 9094e53ff5 ("pmdomain: core: Use dev_name() instead of
kobject_get_path() in debugfs") severely shortened the names of devices
in a PM Domain.  Now the most common format[1] consists of a 32-bit
unit-address (8 characters), followed by a dot and a node name (20
characters for "air-pollution-sensor" and "interrupt-controller", which
are the longest generic node names documented in the Devicetree
Specification), for a typical maximum of 29 characters.

This offers a good opportunity to reduce the table width of the debug
summary:
  - Reduce the device name field width from 50 to 30 characters, which
    matches the PM Domain name width,
  - Reduce the large inter-column space between the "performance" and
    "managed by" columns.

Visual impact:
  - The "performance" column now starts at a position that is a
    multiple of 16, just like the "status" and "children" columns,
  - All of the "/device", "runtime status", and "managed by" columns are
    now indented 4 characters more than the columns right above them,
  - Everything fits in (one less than) 80 characters again ;-)

[1] Note that some device names (e.g. TI AM335x interconnect target
    modules) do not follow this convention, and may be much longer, but
    these didn't fit in the old 50-character column width either.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/f8e1821364b6d5d11350447c128f6d2b470f33fe.1725459707.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:41:33 +02:00
Geert Uytterhoeven
2fc934190e pmdomain: core: Move mode_status_str()
Move mode_status_str() below perf_status_str(), to make declaration
order match calling order of the various *_status_str() helpers.

While at it, add a blank line for consistency among the three helpers.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/18ed6fb2bb92860f3af1bc7e5e4a01e9dacf2126.1725459707.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:39:27 +02:00
Geert Uytterhoeven
987a43e89e pmdomain: core: Fix "managed by" alignment in debug summary
The "performance" column contains variable-width values.  Hence when
their printed values contain more than one digit, all values in
successive columns become misaligned.

Fix this by formatting it as a fixed-width field.  Adjust successive
spaces and field widths to retain the exiting layout.

Fixes: 0155aaf95a ("PM: domains: Add the domain HW-managed mode to the summary")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/e004f9d2a75e9a49c269507bb8a4514001751e85.1725459707.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:38:41 +02:00
Geert Uytterhoeven
692c20c4d0 pmdomain: core: Harden inter-column space in debug summary
The inter-column space in the debug summary is two spaces.  However, in
one case, the extra space is handled implicitly in a field width
specifier.  Make inter-column space explicit to ease future maintenance.

Fixes: 45fbc464b0 ("PM: domains: Add "performance" column to debug summary")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/ae61eb363621b981edde878e1e74d701702a579f.1725459707.git.geert+renesas@glider.be
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:34:52 +02:00
Detlev Casanova
d030e94d81 pmdomain: rockchip: Add gating masks for rk3576
The RK3576 SoC needs to ungate the power domains before their status can
be modified.

The values have been taken from the rockchip downstream driver.

Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
Link: https://lore.kernel.org/r/20240829202732.75961-3-detlev.casanova@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:01:47 +02:00
Detlev Casanova
8b579881de pmdomain: rockchip: Add gating support
Some rockchip SoC need to ungate power domains before their power status
can be changed.

Each power domain has a gate mask that is set to 1 to ungate it when
manipulating power status, then set back to 0 to gate it again.

Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com>
Link: https://lore.kernel.org/r/20240829202732.75961-2-detlev.casanova@collabora.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 13:01:47 +02:00
Krzysztof Kozlowski
4c621d6e66 pmdomain: rockchip: Simplify dropping OF node reference
Drop OF node reference immediately after using it in
syscon_node_to_regmap(), which is both simpler and typical/expected
code pattern.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20240825183116.102953-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:52:13 +02:00
Hongbo Li
391a2e64d7 pmdomain: mediatek: make use of dev_err_cast_probe()
Using dev_err_cast_probe() to simplify the code.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/20240828121230.3696315-1-lihongbo22@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:48:34 +02:00
Dario Binacchi
1a2e369aa2 pmdomain: imx93-pd: drop the context variable "init_off"
This variable is only used within the probe() function, so let's remove
it from the context and define it locally within the same function.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/r/20240825143428.556439-3-dario.binacchi@amarulasolutions.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:45:40 +02:00
Dario Binacchi
28717ec8b9 pmdomain: imx93-pd: don't unprepare clocks on driver remove
The removed code was added to handle the case where the power domain is
already on during the driver's probing. In this use case, the "is_off"
parameter is passed as false to pm_genpd_init() to inform it not to call
the power_on() callback, as it's unnecessary to perform the hardware
power-on procedure since the power domain is already on. Therefore, with
the call to clk_bulk_prepare_enable() by probe(), the system is in the
same operational state as when "is_off" is passed as true after the
power_on() callback execution:

 probe() -> is_off == true  -> clk_bulk_prepare_enable() called by power_on()
 probe() -> is_off == false -> clk_bulk_prepare_enable() called by probe()

Reaching the same logical and operational state, it follows that upon
driver removal, there is no need to perform different actions depending
on the power domain's on/off state during probing.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Link: https://lore.kernel.org/r/20240825143428.556439-2-dario.binacchi@amarulasolutions.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:45:39 +02:00
Dario Binacchi
06cee3c6b3 pmdomain: imx93-pd: replace dev_err() with dev_err_probe()
This way, the code becomes more compact, and dev_err_probe() is used in
every error path of the probe() function.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20240825143428.556439-1-dario.binacchi@amarulasolutions.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:45:39 +02:00
Krzysztof Kozlowski
f3185222cc pmdomain: qcom: rpmpd: Simplify locking with guard()
Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-8-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:21:04 +02:00
Krzysztof Kozlowski
005d29ac59 pmdomain: qcom: rpmhpd: Simplify locking with guard()
Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-7-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:21:04 +02:00
Krzysztof Kozlowski
ba3a65c69b pmdomain: qcom: cpr: Simplify locking with guard()
Simplify error handling (less gotos) over locks with guard().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-6-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:21:04 +02:00
Krzysztof Kozlowski
584dc41b3d pmdomain: qcom: cpr: Simplify with dev_err_probe()
Use dev_err_probe() to make defer code handling simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-5-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:21:04 +02:00
Krzysztof Kozlowski
13bd778c90 pmdomain: imx: gpcv2: Simplify with scoped for each OF child loop
Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240823-cleanup-h-guard-pm-domain-v1-4-8320722eaf39@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2024-09-13 12:21:04 +02:00