Skip to content

Commit 1c2a66d

Browse files
superm1rafaeljw
authored andcommitted
ACPI: x86: s2idle: Add a function to get LPS0 constraint for a device
Other parts of the kernel may use LPS0 constraints information to make decisions on what power state to put a device into. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> [ rjw: Rewrite kerneldoc, rearrange if () statement, edit subject and changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 4123398 commit 1c2a66d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,30 @@ static void lpi_device_get_constraints(void)
299299
ACPI_FREE(out_obj);
300300
}
301301

302+
/**
303+
* acpi_get_lps0_constraint - Get the LPS0 constraint for a device.
304+
* @adev: Device to get the constraint for.
305+
*
306+
* The LPS0 constraint is the shallowest (minimum) power state in which the
307+
* device can be so as to allow the platform as a whole to achieve additional
308+
* energy conservation by utilizing a system-wide low-power state.
309+
*
310+
* Returns:
311+
* - ACPI power state value of the constraint for @adev on success.
312+
* - Otherwise, ACPI_STATE_UNKNOWN.
313+
*/
314+
int acpi_get_lps0_constraint(struct acpi_device *adev)
315+
{
316+
struct lpi_constraints *entry;
317+
318+
for_each_lpi_constraint(entry) {
319+
if (adev->handle == entry->handle)
320+
return entry->min_dstate;
321+
}
322+
323+
return ACPI_STATE_UNKNOWN;
324+
}
325+
302326
static void lpi_check_constraints(void)
303327
{
304328
struct lpi_constraints *entry;

include/linux/acpi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,12 @@ struct acpi_s2idle_dev_ops {
11091109
};
11101110
int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg);
11111111
void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg);
1112+
int acpi_get_lps0_constraint(struct acpi_device *adev);
1113+
#else /* CONFIG_SUSPEND && CONFIG_X86 */
1114+
static inline int acpi_get_lps0_constraint(struct device *dev)
1115+
{
1116+
return ACPI_STATE_UNKNOWN;
1117+
}
11121118
#endif /* CONFIG_SUSPEND && CONFIG_X86 */
11131119
#ifndef CONFIG_IA64
11141120
void arch_reserve_mem_area(acpi_physical_address addr, size_t size);

0 commit comments

Comments
 (0)