Skip to content

Commit d76ebdf

Browse files
loki666stevenprice-arm
authored andcommitted
drm/panfrost: Add PM runtime flag
When the GPU is the only device attached to a single power domain, core genpd disable and enable it when gpu enter and leave runtime suspend. Some power-domain requires a sequence before disabled, and the reverse when enabled. Add GPU_PM_RT flag, and implement in panfrost_device_runtime_suspend/resume. Reviewed-by: Steven Price <steven.price@arm.com> Signed-off-by: Philippe Simons <simons.philippe@gmail.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20250403055210.54486-2-simons.philippe@gmail.com
1 parent a22e005 commit d76ebdf

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

drivers/gpu/drm/panfrost/panfrost_device.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,36 @@ void panfrost_device_reset(struct panfrost_device *pfdev)
406406
static int panfrost_device_runtime_resume(struct device *dev)
407407
{
408408
struct panfrost_device *pfdev = dev_get_drvdata(dev);
409+
int ret;
410+
411+
if (pfdev->comp->pm_features & BIT(GPU_PM_RT)) {
412+
ret = reset_control_deassert(pfdev->rstc);
413+
if (ret)
414+
return ret;
415+
416+
ret = clk_enable(pfdev->clock);
417+
if (ret)
418+
goto err_clk;
419+
420+
if (pfdev->bus_clock) {
421+
ret = clk_enable(pfdev->bus_clock);
422+
if (ret)
423+
goto err_bus_clk;
424+
}
425+
}
409426

410427
panfrost_device_reset(pfdev);
411428
panfrost_devfreq_resume(pfdev);
412429

413430
return 0;
431+
432+
err_bus_clk:
433+
if (pfdev->comp->pm_features & BIT(GPU_PM_RT))
434+
clk_disable(pfdev->clock);
435+
err_clk:
436+
if (pfdev->comp->pm_features & BIT(GPU_PM_RT))
437+
reset_control_assert(pfdev->rstc);
438+
return ret;
414439
}
415440

416441
static int panfrost_device_runtime_suspend(struct device *dev)
@@ -426,6 +451,14 @@ static int panfrost_device_runtime_suspend(struct device *dev)
426451
panfrost_gpu_suspend_irq(pfdev);
427452
panfrost_gpu_power_off(pfdev);
428453

454+
if (pfdev->comp->pm_features & BIT(GPU_PM_RT)) {
455+
if (pfdev->bus_clock)
456+
clk_disable(pfdev->bus_clock);
457+
458+
clk_disable(pfdev->clock);
459+
reset_control_assert(pfdev->rstc);
460+
}
461+
429462
return 0;
430463
}
431464

drivers/gpu/drm/panfrost/panfrost_device.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ enum panfrost_drv_comp_bits {
3636
* enum panfrost_gpu_pm - Supported kernel power management features
3737
* @GPU_PM_CLK_DIS: Allow disabling clocks during system suspend
3838
* @GPU_PM_VREG_OFF: Allow turning off regulators during system suspend
39+
* @GPU_PM_RT: Allow disabling clocks and asserting the reset control during
40+
* system runtime suspend
3941
*/
4042
enum panfrost_gpu_pm {
4143
GPU_PM_CLK_DIS,
4244
GPU_PM_VREG_OFF,
45+
GPU_PM_RT
4346
};
4447

4548
/**

0 commit comments

Comments
 (0)