Skip to content

Commit 3fbc5c3

Browse files
storulfvireshk
authored andcommitted
PM: domains: Introduce dev_pm_domain_set_performance_state()
The generic PM domain is currently the only PM domain variant that supports performance scaling. To allow performance scaling to be supported through a common interface, let's add an optional callback ->set_performance_state(), in the struct dev_pm_domain. Moreover, let's add a function, dev_pm_domain_set_performance_state(), that may be called by consumers to request a new performance state for a device through its PM domain. Note that, in most cases it's preferred that a consumer use the OPP library to request a new performance state for its device. Although, this requires some additional changes to be supported, which are being implemented from subsequent changes. Signed-off-by: Ulf Hansson <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 0bb80ec commit 3fbc5c3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

drivers/base/power/common.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,24 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
228228
device_pm_check_callbacks(dev);
229229
}
230230
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
231+
232+
/**
233+
* dev_pm_domain_set_performance_state - Request a new performance state.
234+
* @dev: The device to make the request for.
235+
* @state: Target performance state for the device.
236+
*
237+
* This function should be called when a new performance state needs to be
238+
* requested for a device that is attached to a PM domain. Note that, the
239+
* support for performance scaling for PM domains is optional.
240+
*
241+
* Returns 0 on success and when performance scaling isn't supported, negative
242+
* error code on failure.
243+
*/
244+
int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state)
245+
{
246+
if (dev->pm_domain && dev->pm_domain->set_performance_state)
247+
return dev->pm_domain->set_performance_state(dev, state);
248+
249+
return 0;
250+
}
251+
EXPORT_SYMBOL_GPL(dev_pm_domain_set_performance_state);

include/linux/pm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ extern void dev_pm_put_subsys_data(struct device *dev);
719719
* @activate: Called before executing probe routines for bus types and drivers.
720720
* @sync: Called after successful driver probe.
721721
* @dismiss: Called after unsuccessful driver probe and after driver removal.
722+
* @set_performance_state: Called to request a new performance state.
722723
*
723724
* Power domains provide callbacks that are executed during system suspend,
724725
* hibernation, system resume and during runtime PM transitions instead of
@@ -731,6 +732,7 @@ struct dev_pm_domain {
731732
int (*activate)(struct device *dev);
732733
void (*sync)(struct device *dev);
733734
void (*dismiss)(struct device *dev);
735+
int (*set_performance_state)(struct device *dev, unsigned int state);
734736
};
735737

736738
/*

include/linux/pm_domain.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ struct device *dev_pm_domain_attach_by_name(struct device *dev,
430430
void dev_pm_domain_detach(struct device *dev, bool power_off);
431431
int dev_pm_domain_start(struct device *dev);
432432
void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
433+
int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state);
433434
#else
434435
static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
435436
{
@@ -452,6 +453,11 @@ static inline int dev_pm_domain_start(struct device *dev)
452453
}
453454
static inline void dev_pm_domain_set(struct device *dev,
454455
struct dev_pm_domain *pd) {}
456+
static inline int dev_pm_domain_set_performance_state(struct device *dev,
457+
unsigned int state)
458+
{
459+
return 0;
460+
}
455461
#endif
456462

457463
#endif /* _LINUX_PM_DOMAIN_H */

0 commit comments

Comments
 (0)