Skip to contentSkip to conversation

PM: runtime: add system sleep callbacks to EXPORT_*_RUNTIME_DEV_PM_OPS()

PATCH In review Neel Bullywon 2 participants 2 messages Mar 1 – Mar 6 Power management core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: runtime: add system sleep callbacks to EXPORT_*_RUNTIME_DEV_PM_OPS()

DEFINE_RUNTIME_DEV_PM_OPS() sets pm_runtime_force_suspend() and pm_runtime_force_resume() as system sleep callbacks via _DEFINE_DEV_PM_OPS(), but the exported variants (EXPORT_RUNTIME_DEV_PM_OPS, EXPORT_GPL_RUNTIME_DEV_PM_OPS, EXPORT_NS_RUNTIME_DEV_PM_OPS, EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS) only set RUNTIME_PM_OPS() and omit SYSTEM_SLEEP_PM_OPS(). This means drivers using the export macros do not get system sleep support, contrary to what the documentation suggests.

Add SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) to all four export variants to match the behavior of DEFINE_RUNTIME_DEV_PM_OPS().

All current users of these macros are IIO drivers (bme680, bmp280, kxsd9, mpl115, bmi088-accel) and none implement custom system sleep callbacks, so this change is safe for all existing callers.

---
 include/linux/pm_runtime.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/pm_runtime.h +8 -0
index 41037c513f06..c6a6a0569b11 100644
@@ -42,18 +42,26 @@
 
 #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
 	EXPORT_DEV_PM_OPS(name) = { \
+		SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+				    pm_runtime_force_resume) \
 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 	}
 #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
 	EXPORT_GPL_DEV_PM_OPS(name) = { \
+		SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+				    pm_runtime_force_resume) \
 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 	}
 #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
 	EXPORT_NS_DEV_PM_OPS(name, ns) = { \
+		SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+				    pm_runtime_force_resume) \
 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 	}
 #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
 	EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
+		SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+				    pm_runtime_force_resume) \
 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
 	}
 
Signature · 1 line
2.44.0
#1 lore raw
Quoted 4 lines · Neel Bullywon

DEFINE_RUNTIME_DEV_PM_OPS() sets pm_runtime_force_suspend() and pm_runtime_force_resume() as system sleep callbacks via _DEFINE_DEV_PM_OPS(),

Isn't that a mistake?

I'm not actually sure if it would work for everybody. Stuff like USB may want to use the exact same callbacks for runtime PM and system-wide PM.

Quoted 7 lines

but the exported variants
(EXPORT_RUNTIME_DEV_PM_OPS, EXPORT_GPL_RUNTIME_DEV_PM_OPS, EXPORT_NS_RUNTIME_DEV_PM_OPS, EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS) only set RUNTIME_PM_OPS() and omit SYSTEM_SLEEP_PM_OPS(). This means drivers using the export macros do not get system sleep support, contrary to what the documentation suggests.

Quoted 7 lines

Add SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) to all four export variants to match the behavior of DEFINE_RUNTIME_DEV_PM_OPS().

All current users of these macros are IIO drivers (bme680, bmp280, kxsd9, mpl115, bmi088-accel) and none implement custom system sleep callbacks, so this change is safe for all existing callers.

So maybe let IIO have their own set of macros?

Quoted 41 lines
---
 include/linux/pm_runtime.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/pm_runtime.h +8 -1
index 41037c513f06..c6a6a0569b11 100644
@@ -42,18 +42,26 @@
 
 #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
        EXPORT_DEV_PM_OPS(name) = { \
+               SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+                                   pm_runtime_force_resume) \
                RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
        }
 #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
        EXPORT_GPL_DEV_PM_OPS(name) = { \
+               SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+                                   pm_runtime_force_resume) \
                RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
        }
 #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
        EXPORT_NS_DEV_PM_OPS(name, ns) = { \
+               SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+                                   pm_runtime_force_resume) \
                RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
        }
 #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
        EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
+               SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, \
+                                   pm_runtime_force_resume) \
                RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
        }
 
--

2.44.0