drm/panthor: Fix the CONFIG_PM=n case
Subsystems (3)
Boris Brezillon
maintainerPATCH 1/1 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.
---
Tested by faking CONFIG_PM=n in the driver (basically commenting all pm_runtime calls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) since CONFIG_ARCH_ROCKCHIP selects CONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that has CONFIG_PM=n.
--- drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++-- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/panthor/panthor_device.c +11 -2
@@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)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_device *ptdev)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 panthor_device *ptdev, struct vm_area_struct *return 0 ; } -#ifdef CONFIG_PM int panthor_device_resume (struct device *dev) {struct panthor_device *ptdev =dev_get_drvdata (dev);
@@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)mutex_unlock (&ptdev->pm.mmio_lock);return ret; } -#endif
drivers/gpu/drm/panthor/panthor_drv.c +3 -1
@@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +#ifdef CONFIG_PM static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops, panthor_device_suspend, panthor_device_resume, NULL); +#endif static struct platform_driver panthor_driver = { .probe = panthor_probe, .remove_new = panthor_remove, .driver = { .name ="panthor" , - .pm = &panthor_pm_ops, + .pm =pm_ptr (&panthor_pm_ops), .of_match_table = dt_match, }, };
Signature · 1 line
2.43.0
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.
Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.
Yes, there are no realistic platforms to test where you can enable panthor but disable runtime power management. All our emulator configuration are based on Juno (ARCH_VEXPRESS) which select CONFIG_PM.
Best regards,
Liviu
Quoted 75 lines
--- drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++-- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/gpu/drm/panthor/panthor_device.c +11
-2@@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)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_device *ptdev)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 panthor_device *ptdev, struct vm_area_struct *return 0 ; } -#ifdef CONFIG_PM int panthor_device_resume (struct device *dev) {struct panthor_device *ptdev =dev_get_drvdata (dev);@@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)mutex_unlock (&ptdev->pm.mmio_lock);return ret; } -#endif drivers/gpu/drm/panthor/panthor_drv.c +3
-1@@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +#ifdef CONFIG_PM static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops, panthor_device_suspend, panthor_device_resume, NULL); +#endif static struct platform_driver panthor_driver = { .probe = panthor_probe, .remove_new = panthor_remove, .driver = { .name ="panthor" , - .pm = &panthor_pm_ops, + .pm =pm_ptr (&panthor_pm_ops), .of_match_table = dt_match, }, };Signature · 1 line
2.43.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.
Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop. Of course if there is actually anyone who has a platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.
Steve
Quoted 72 lines
--- drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++-- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/gpu/drm/panthor/panthor_device.c +11
-2@@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)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_device *ptdev)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 panthor_device *ptdev, struct vm_area_struct *return 0 ; } -#ifdef CONFIG_PM int panthor_device_resume (struct device *dev) {struct panthor_device *ptdev =dev_get_drvdata (dev);@@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)mutex_unlock (&ptdev->pm.mmio_lock);return ret; } -#endif drivers/gpu/drm/panthor/panthor_drv.c +3
-1@@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +#ifdef CONFIG_PM static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops, panthor_device_suspend, panthor_device_resume, NULL); +#endif static struct platform_driver panthor_driver = { .probe = panthor_probe, .remove_new = panthor_remove, .driver = { .name ="panthor" , - .pm = &panthor_pm_ops, + .pm =pm_ptr (&panthor_pm_ops), .of_match_table = dt_match, }, };
Boris Brezillon
maintainerQuoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.
Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Doesn't seem to work with COMPILE_TEST though? I mean, we need something like
depends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PM
but kconfig doesn't like that
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!drivers/gpu/drm/panthor/Kconfig:3: symbol DRM_PANTHOR depends on
PM kernel/power/Kconfig:183: symbol PM is selected by DRM_PANTHOR
which id why I initially when for a depends on PM
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.
Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Steven Price
maintainerQuoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PM
Or at least that appears to work for me.
Quoted 7 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the virt_to_pfn() problem. On x86 with COMPILE_TEST I still get an error. Looking at the code it appears that virt_to_pfn() isn't available on x86... it overrides asm/page.h and doesn't provide a definition. The definition on x86 is hiding in asm/xen/page.h.
Outside of arch code it's only drivers/xen that currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)
Steve
Quoted 74 lines · Steven Price
Quoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PMOr at least that appears to work for me.
Quoted 7 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the
virt_to_pfn()problem. On x86 withCOMPILE_TESTI still get an error. Looking at the code it appears thatvirt_to_pfn()isn't available on x86... it overridesasm/page.hand doesn't provide a definition. The definition on x86 is hiding inasm/xen/page.h.
Quoted 3 lines
Outside of arch code it's only
drivers/xenthat currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)
FWIW from a quick look it might be cleaner to store the struct page pointer for the dummy page - especially since the VA only seems to be used once in panthor_device_init() anyway - then use page_to_pfn() at the business end.
Cheers,
Robin.
Boris Brezillon
maintainerQuoted 40 lines · On Mon, 18 Mar 2024 13:49:52 +0000 Steven Price <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Quoted 7 lines
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PMOr at least that appears to work for me.
Uh, you're right, sorry for the brain fart. This is being said, I see no other driver selecting the PM option directly (if you grep for 'select PM' in drivers/, you'll find occurrences in drivers/soc, but those are under ARCH_/SOC_ options, which means they are indirectly arch/platform dependent, not driver dependent). I'm really not sure selecting PM here from a driver is right to be honest.
Quoted 20 lines
Quoted 8 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
Quoted 6 lines
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the
virt_to_pfn()problem. On x86 withCOMPILE_TESTI still get an error. Looking at the code it appears thatvirt_to_pfn()isn't available on x86... it overridesasm/page.hand doesn't provide a definition. The definition on x86 is hiding inasm/xen/page.h.
Looks like the kbuild bot didn't catch that yet :-).
Quoted 4 lines
Outside of arch code it's only
drivers/xenthat currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)
Mind sending a fix for that?
Steven Price
maintainerQuoted 49 lines · Boris Brezillon
Quoted 46 lines · On Mon, 18 Mar 2024 13:49:52 +0000 Steven Price <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PM
Quoted 8 lines
Quoted 1 line
Or at least that appears to work for me.
Uh, you're right, sorry for the brain fart. This is being said, I see no other driver selecting the PM option directly (if you grep for 'select PM' in
drivers/, you'll find occurrences indrivers/soc, but those are under ARCH_/SOC_ options, which means they are indirectlyarch/platformdependent, not driver dependent). I'm really not sure selecting PM here from a driver is right to be honest.
Yeah, I'm not very convinced about that either. It's just a pain that the code is going to go untested.
Quoted 27 lines
Quoted 20 lines
Quoted 8 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
Quoted 6 lines
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the
virt_to_pfn()problem. On x86 withCOMPILE_TESTI still get an error. Looking at the code it appears thatvirt_to_pfn()isn't available on x86... it overridesasm/page.hand doesn't provide a definition. The definition on x86 is hiding inasm/xen/page.h.
Quoted 8 lines
Looks like the kbuild bot didn't catch that yet :-).
Quoted 4 lines
Outside of arch code it's only
drivers/xenthat currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)Mind sending a fix for that?
Yeah, I'll have a go at Robin's suggestion of storing the struct page instead.
Steve
Boris Brezillon
maintainerQuoted 59 lines · On Mon, 18 Mar 2024 14:34:07 +0000 Steven Price <[email protected]> wrote:
Quoted 49 lines · Boris Brezillon
Quoted 46 lines · On Mon, 18 Mar 2024 13:49:52 +0000 Steven Price <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PMQuoted 8 lines
Quoted 1 line
Or at least that appears to work for me.
Uh, you're right, sorry for the brain fart. This is being said, I see no other driver selecting the PM option directly (if you grep for 'select PM' in
drivers/, you'll find occurrences indrivers/soc, but those are under ARCH_/SOC_ options, which means they are indirectlyarch/platformdependent, not driver dependent). I'm really not sure selecting PM here from a driver is right to be honest.
Quoted 2 lines
Yeah, I'm not very convinced about that either. It's just a pain that the code is going to go untested.
If that's really bothering you, let's just return an error in the probe path when CONFIG_PM=n as you were suggesting last week.
Quoted 31 lines
Quoted 31 lines
Quoted 21 lines
Quoted 9 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
Quoted 6 lines
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the
virt_to_pfn()problem. On x86 withCOMPILE_TESTI still get an error. Looking at the code it appears thatvirt_to_pfn()isn't available on x86... it overridesasm/page.hand doesn't provide a definition. The definition on x86 is hiding inasm/xen/page.h.Looks like the kbuild bot didn't catch that yet :-).
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Outside of arch code it's only
drivers/xenthat currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)Mind sending a fix for that?
Yeah, I'll have a go at Robin's suggestion of storing the struct page instead.
If that's not too much to ask, could you also send a variant of this patch returning an error when CONFIG_PM is disabled (and fixing the other mistake I made, of course)?
Thanks,
Boris
Steven Price
maintainerQuoted 62 lines · Boris Brezillon
Quoted 59 lines · On Mon, 18 Mar 2024 14:34:07 +0000 Steven Price <[email protected]> wrote:
Quoted 57 lines · Boris Brezillon
Quoted 40 lines · On Mon, 18 Mar 2024 13:49:52 +0000 Steven Price <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 20 lines · On Mon, 18 Mar 2024 11:31:05 +0000 Steven Price <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reviewed-by Steven Price <[email protected]>Quoted 7 lines
---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.Quoted 6 lines
The same - I can't test this properly :(
Note that the other option (which AFAICT doesn't cause any problems) is to "select PM" rather than depend on it - AIUI the 'select' dependency is considered in the opposite direction by kconfig so won't cause the dependency loop.
Quoted 8 lines
Doesn't seem to work with
COMPILE_TESTthough? I mean, we need something likedepends on ARM || ARM64 || (COMPILE_TEST && PM) ... select PMbut kconfig doesn't like that
Quoted 7 lines
Why do we need the "&& PM" part? Just:
depends on ARM || ARM64 || COMPILE_TEST ... select PMOr at least that appears to work for me.
Uh, you're right, sorry for the brain fart. This is being said, I see no other driver selecting the PM option directly (if you grep for 'select PM' in
drivers/, you'll find occurrences indrivers/soc, but those are under ARCH_/SOC_ options, which means they are indirectlyarch/platformdependent, not driver dependent). I'm really not sure selecting PM here from a driver is right to be honest.
Quoted 5 lines
Quoted 2 lines
Yeah, I'm not very convinced about that either. It's just a pain that the code is going to go untested.
If that's really bothering you, let's just return an error in the probe path when
CONFIG_PM=nas you were suggesting last week.
Honestly I'm fine with this patch (modulo it needs compile testing!). I'd obviously just be happier if someone actually had a platform where this could be tested. But really one of two things will happen:
a) Nobody will ever execute the code. In which case it doesn't really
matter as long as it builds.
b) Someone will execute the code, and it'll either work which is great
(and so we won't hear), or it will break and hopefully then we'll have a willing tester ;)
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 21 lines
Quoted 9 lines
drivers/gpu/drm/panthor/Kconfig:3:error: recursive dependency detected!
drivers/gpu/drm/panthor/Kconfig:3: symbolDRM_PANTHORdepends on
PMkernel/power/Kconfig:183: symbol PM is selected byDRM_PANTHORwhich id why I initially when for a depends on PM
Quoted 8 lines
Quoted 4 lines
Of course if there is actually anyone who has a
platform which can be built !CONFIG_PM then that won't help. But the inability of anyone to actually properly test this configuration does worry me a little.Well, as long as it doesn't regress the PM behavior, I think I'm happy to take the risk. Worst case scenario, someone complains that this is not working properly when they do the !PM bringup :-).
Indeed, I've no objection to this patch - although I really should have compiled tested it as Robin pointed out ;)
Quoted 6 lines
But one other thing I've noticed when compile testing it - we don't appear to have fully fixed the
virt_to_pfn()problem. On x86 withCOMPILE_TESTI still get an error. Looking at the code it appears thatvirt_to_pfn()isn't available on x86... it overridesasm/page.hand doesn't provide a definition. The definition on x86 is hiding inasm/xen/page.h.Looks like the kbuild bot didn't catch that yet :-).
Quoted 4 lines
Outside of arch code it's only
drivers/xenthat currently uses that function. So I guess it's probably best to do a PFN_DOWN(virt_to_phys(...)) instead. Or look to fix x86 :)
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Mind sending a fix for that?
Yeah, I'll have a go at Robin's suggestion of storing the struct page instead.
If that's not too much to ask, could you also send a variant of this patch returning an error when
CONFIG_PMis disabled (and fixing the other mistake I made, of course)?
Too late ;)
Are you happy to respin this with the #ifdef dropped?
Thanks,
Steve
Quoted 67 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reported-by kernel test robot <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.--- drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++-- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/gpu/drm/panthor/panthor_device.c +11
-2@@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)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_device *ptdev)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 panthor_device *ptdev, struct vm_area_struct *return 0 ; } -#ifdef CONFIG_PM int panthor_device_resume (struct device *dev) {struct panthor_device *ptdev =dev_get_drvdata (dev);@@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)mutex_unlock (&ptdev->pm.mmio_lock);return ret; } -#endif drivers/gpu/drm/panthor/panthor_drv.c +0
-0
drivers/gpu/drm/panthor/panthor_drv.c static const struct of_device_id dt_match[] = { · line 1410
Quoted 4 lines
drivers/gpu/drm/panthor/panthor_drv.c +1
-0@@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +#ifdef CONFIG_PM
This #ifdef isn't necessary, and in fact will break the !PM build - pm_ptr() already takes care of allowing the compiler to optimise out the ops structure itself without any further annotations.
Thanks,
Robin.
Quoted 16 lines
drivers/gpu/drm/panthor/panthor_drv.c +2
-1static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops, panthor_device_suspend, panthor_device_resume, NULL); +#endif static struct platform_driver panthor_driver = { .probe = panthor_probe, .remove_new = panthor_remove, .driver = { .name ="panthor" , - .pm = &panthor_pm_ops, + .pm =pm_ptr (&panthor_pm_ops), .of_match_table = dt_match, }, };
Boris Brezillon
maintainerQuoted 71 lines · On Mon, 18 Mar 2024 12:18:53 +0000 Robin Murphy <[email protected]> wrote:
Quoted 70 lines · Boris Brezillon
Putting a hard dependency on
CONFIG_PMis 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.Reported-by kernel test robot <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Tested by fakingCONFIG_PM=nin the driver (basically commenting allpm_runtimecalls, and making the panthor_device_suspend/resume() calls unconditional in the panthor_device_unplug/init() path) sinceCONFIG_ARCH_ROCKCHIPselectsCONFIG_PM. Seems to work fine, but I can't be 100% sure this will work correctly on a platform that hasCONFIG_PM=n.--- drivers/gpu/drm/panthor/panthor_device.c | 13 +++++++++++-- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/gpu/drm/panthor/panthor_device.c +11
-2@@ -87,6 +87,10 @@ void panthor_device_unplug(struct panthor_device *ptdev)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_device *ptdev)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 panthor_device *ptdev, struct vm_area_struct *return 0 ; } -#ifdef CONFIG_PM int panthor_device_resume (struct device *dev) {struct panthor_device *ptdev =dev_get_drvdata (dev);@@ -547,4 +557,3 @@ int panthor_device_suspend(struct device *dev)mutex_unlock (&ptdev->pm.mmio_lock);return ret; } -#endif drivers/gpu/drm/panthor/panthor_drv.c +0
-0@@ -1407,17 +1407,19 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match);
Quoted 5 lines
drivers/gpu/drm/panthor/panthor_drv.c static const struct of_device_id dt_match[] = { · line 1410
Quoted 1 line
drivers/gpu/drm/panthor/panthor_drv.c +1
-0+#ifdef CONFIG_PM This #ifdef isn't necessary, and in fact will break the !PM build -
pm_ptr()already takes care of allowing the compiler to optimise out the ops structure itself without any further annotations.
Oops, I forgot how pm_ptr() was working (I thought it had 2 definitions, one for the PM case and another for the !PM one).
Quoted 20 lines
Thanks,
Robin.Quoted 16 lines
drivers/gpu/drm/panthor/panthor_drv.c +2
-1static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops, panthor_device_suspend, panthor_device_resume, NULL); +#endif static struct platform_driver panthor_driver = { .probe = panthor_probe, .remove_new = panthor_remove, .driver = { .name ="panthor" , - .pm = &panthor_pm_ops, + .pm =pm_ptr (&panthor_pm_ops), .of_match_table = dt_match, }, };