target_linux_rockchip-6.x/patches-6.6/034-44-v6.10-drm-panthor-Fix-the-CONFIG_PM_n-case.patch
sbwml ae3c1c2368 rockchip: backport panthor gpu driver
* rk3588

Signed-off-by: sbwml <admin@cooluc.com>
2024-07-07 21:39:51 +08:00

76 lines
2.5 KiB
Diff

From 0cd8363ed802922e39446d783f767b3e09335ddc Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@collabora.com>
Date: Mon, 18 Mar 2024 16:31:17 +0100
Subject: [PATCH] drm/panthor: Fix the CONFIG_PM=n case
Putting a hard dependency on CONFIG_PM is not possible because of a
circular dependency issue, and it's actually not desirable either. In
order to support this use case, we forcibly resume at init time, and
suspend at unplug time.
v2:
- Drop the #ifdef CONFIG_PM section around panthor_pm_ops's definition
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403031944.EOimQ8WK-lkp@intel.com/
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240318153117.1321544-1-boris.brezillon@collabora.com
---
drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++--
drivers/gpu/drm/panthor/panthor_drv.c | 2 +-
2 files changed, 12 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/panthor/panthor_device.c
+++ b/drivers/gpu/drm/panthor/panthor_device.c
@@ -87,6 +87,10 @@ void panthor_device_unplug(struct pantho
pm_runtime_dont_use_autosuspend(ptdev->base.dev);
pm_runtime_put_sync_suspend(ptdev->base.dev);
+ /* If PM is disabled, we need to call the suspend handler manually. */
+ if (!IS_ENABLED(CONFIG_PM))
+ panthor_device_suspend(ptdev->base.dev);
+
/* Report the unplug operation as done to unblock concurrent
* panthor_device_unplug() callers.
*/
@@ -218,6 +222,13 @@ int panthor_device_init(struct panthor_d
if (ret)
return ret;
+ /* If PM is disabled, we need to call panthor_device_resume() manually. */
+ if (!IS_ENABLED(CONFIG_PM)) {
+ ret = panthor_device_resume(ptdev->base.dev);
+ if (ret)
+ return ret;
+ }
+
ret = panthor_gpu_init(ptdev);
if (ret)
goto err_rpm_put;
@@ -402,7 +413,6 @@ int panthor_device_mmap_io(struct pantho
return 0;
}
-#ifdef CONFIG_PM
int panthor_device_resume(struct device *dev)
{
struct panthor_device *ptdev = dev_get_drvdata(dev);
@@ -547,4 +557,3 @@ err_set_active:
mutex_unlock(&ptdev->pm.mmio_lock);
return ret;
}
-#endif
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -1416,7 +1416,7 @@ static struct platform_driver panthor_dr
.remove_new = panthor_remove,
.driver = {
.name = "panthor",
- .pm = &panthor_pm_ops,
+ .pm = pm_ptr(&panthor_pm_ops),
.of_match_table = dt_match,
},
};