Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pmdomain: ti-sci: Set PD on/off state according to the HW state

At the moment the driver sets the power state of all the PDs it creates
to off, regardless of the actual HW state. This has two drawbacks:

1) The kernel cannot disable unused PDs automatically for power saving,
as it thinks they are off already

2) A more specific case (but perhaps applicable to other scenarios
also): bootloader enabled splash-screen cannot be kept on the screen.

The issue in 2) is that the driver framework automatically enables the
device's PD before calling probe() and disables it after the probe().
This means that when the display subsystem (DSS) driver probes, but e.g.
fails due to deferred probing, the DSS PD gets turned off and the driver
cannot do anything to affect that.

Solving the 2) requires more changes to actually keep the PD on during
the boot, but a prerequisite for it is to have the correct power state
for the PD.

The downside with this patch is that it takes time to call the 'is_on'
op, and we need to call it for each PD. In my tests with AM62 SK, using
defconfig, I see an increase from ~3.5ms to ~7ms. However, the added
feature is valuable, so in my opinion it's worth it.

The performance could probably be improved with a new firmware API which
returns the power states of all the PDs.

There's also a related HW issue at play here: if the DSS IP is enabled
and active, and its PD is turned off without first disabling the DSS
display outputs, the DSS IP will hang and causes the kernel to halt if
and when the DSS driver accesses the DSS registers the next time.

With the current upstream kernel, with this patch applied, this means
that if the bootloader enables the display, and the DSS driver is
compiled as a module, the kernel will at some point disable unused PDs,
including the DSS PD. When the DSS module is later loaded, it will hang
the kernel.

The same issue is already there, even without this patch, as the DSS
driver may hit deferred probing, which causes the PD to be turned off,
and leading to kernel halt when the DSS driver is probed again. This
issue has been made quite rare with some arrangements in the DSS
driver's probe, but it's still there.

With recent change from Ulf (e.g. commit 13a4b7fb6260 ("pmdomain: core:
Leave powered-on genpds on until late_initcall_sync")), the sync state
mechanism comes to rescue. It will keep the power domains enabled, until
the drivers have probed, or the sync-state is triggered via some other
mechanism (e.g. manually by the boot scripts).

Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Tested-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Tomi Valkeinen and committed by
Ulf Hansson
0b5fe1c4 b283b709

+23 -1
+23 -1
drivers/pmdomain/ti/ti_sci_pm_domains.c
··· 200 200 return false; 201 201 } 202 202 203 + static bool ti_sci_pm_pd_is_on(struct ti_sci_genpd_provider *pd_provider, 204 + int pd_idx) 205 + { 206 + bool is_on; 207 + int ret; 208 + 209 + if (!pd_provider->ti_sci->ops.dev_ops.is_on) 210 + return false; 211 + 212 + ret = pd_provider->ti_sci->ops.dev_ops.is_on(pd_provider->ti_sci, 213 + pd_idx, NULL, &is_on); 214 + if (ret) 215 + return false; 216 + 217 + return is_on; 218 + } 219 + 203 220 static int ti_sci_pm_domain_probe(struct platform_device *pdev) 204 221 { 205 222 struct device *dev = &pdev->dev; ··· 248 231 index, &args)) { 249 232 250 233 if (args.args_count >= 1 && args.np == dev->of_node) { 234 + bool is_on; 235 + 251 236 of_node_put(args.np); 252 237 if (args.args[0] > max_id) { 253 238 max_id = args.args[0]; ··· 283 264 pd_provider->ti_sci->ops.pm_ops.set_latency_constraint) 284 265 pd->pd.domain.ops.suspend = ti_sci_pd_suspend; 285 266 286 - pm_genpd_init(&pd->pd, NULL, true); 267 + is_on = ti_sci_pm_pd_is_on(pd_provider, 268 + pd->idx); 269 + 270 + pm_genpd_init(&pd->pd, NULL, !is_on); 287 271 288 272 list_add(&pd->node, &pd_provider->pd_list); 289 273 } else {