ACPI / Sleep: Check low power idle constraints for debug only
Subsystems (3)
PATCH v3 1/1 ACPI / Sleep: Check low power idle constraints for debug only
For SoC to achieve its lowest power platform idle state a set of hardware preconditions must be met. These preconditions or constraints can be obtained by issuing a device specific method (_DSM) with function "1". Refer to the document provided in the link below.
Here during initialization (from attach() callback of LPS0 device), invoke function 1 to get the device constraints. Each enabled constraint is stored in a table.
The devices in this table are used to check whether they were in required minimum state, while entering suspend. This check is done from platform freeze wake() callback, only when /sys/power/pm_debug_messages attribute is non zero.
If any constraint is not met and device is ACPI power managed then it prints the device name to kernel logs.
Also if debug is enabled in acpi/sleep.c, the constraint table and state of each device on wake is dumped in kernel logs.
Since pm_debug_messages_on setting is used as condition to check constraints outside kernel/power/main.c, pm_debug_messages_on is changed to a global variable.
---
v3
- Removed the patch 0001 for exporting pm_debug_messages_on via a function. As suggested by Rafael, made the pm_debug_messages_on a global variable instead.
- Moved the constraint check outside if() block and valid for all calls to acpi_freeze_wakeup()
- Dumping irrespective of return value of acpi_device_get_power().
- Rebased to linux-next as of today
v2
- Changes as suggested by Lukas Wunner.
- Using pm_debug_messages_on attribute to prevent constraints check to save some cycles on wake.
drivers/acpi/sleep.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/suspend.h | 2 + kernel/power/main.c | 2 +- 3 files changed, 172 insertions(+), 1 deletion(-)
drivers/acpi/sleep.c +169 -0
@@ -669,6 +669,7 @@ static const struct acpi_device_id lps0_device_ids[] = {#define ACPI_LPS0_DSM_UUID "c4eb40a0-6cd2-11e2-bcfd-0800200c9a66" +#define ACPI_LPS0_GET_DEVICE_CONSTRAINTS 1#define ACPI_LPS0_SCREEN_OFF 3#define ACPI_LPS0_SCREEN_ON 4#define ACPI_LPS0_ENTRY 5
@@ -680,6 +681,167 @@ static acpi_handle lps0_device_handle;static guid_t lps0_dsm_guid;static char lps0_dsm_func_mask; +/* Device constraint entry structure */ +struct lpi_device_info { +char *name; +int enabled; +union acpi_object *package; +}; + +/* Constraint package structure */ +struct lpi_device_constraint { +int uid; +int min_dstate; +int function_states; +}; + +struct lpi_constraints { +char *name; +int min_dstate; +}; + +static struct lpi_constraints *lpi_constraints_table; +static int lpi_constraints_table_size; + +static void lpi_device_get_constraints (void ) +{ +union acpi_object *out_obj; +int i; + + out_obj =acpi_evaluate_dsm_typed (lps0_device_handle, &lps0_dsm_guid, +1 ,ACPI_LPS0_GET_DEVICE_CONSTRAINTS , +NULL ,ACPI_TYPE_PACKAGE ); + +acpi_handle_debug (lps0_device_handle,"_DSM function 1 eval %s\n" , + out_obj ?"successful" :"failed" ); + +if (!out_obj) +return ; + + lpi_constraints_table =kcalloc (out_obj->package.count, +sizeof (*lpi_constraints_table), +GFP_KERNEL ); +if (!lpi_constraints_table) + goto free_acpi_buffer; + +pr_debug ("LPI: constraints dump begin\n" ); +for (i =0 ; i < out_obj->package.count; i++) { +union acpi_object *package = &out_obj->package.elements[i]; +struct lpi_device_info info = { }; +int package_count =0 , j; + +if (!package) +continue ; + +for (j =0 ; j < package->package.count; ++j) { +union acpi_object *element = + &(package->package.elements[j]); + +switch (element->type) { +case ACPI_TYPE_INTEGER : + info.enabled = element->integer.value; +break ; +case ACPI_TYPE_STRING : + info.name = element->string.pointer; +break ; +case ACPI_TYPE_PACKAGE : + package_count = element->package.count; + info.package = element->package.elements; +break ; + } + } + +if (!info.enabled || !info.package || !info.name) +continue ; + + lpi_constraints_table[lpi_constraints_table_size].name = +kstrdup (info.name,GFP_KERNEL ); +if (!lpi_constraints_table[lpi_constraints_table_size].name) + goto free_constraints; + +pr_debug ("index:%d Name:%s\n" , i, info.name); + +for (j =0 ; j < package_count; ++j) { +union acpi_object *info_obj = &info.package[j]; +union acpi_object *cnstr_pkg; +union acpi_object *obj; +struct lpi_device_constraint dev_info; + +switch (info_obj->type) { +case ACPI_TYPE_INTEGER : +/* version */ +break ; +case ACPI_TYPE_PACKAGE : +if (info_obj->package.count <2 ) +break ; + + cnstr_pkg = info_obj->package.elements; + obj = &cnstr_pkg[0 ]; + dev_info.uid = obj->integer.value; + obj = &cnstr_pkg[1 ]; + dev_info.min_dstate = obj->integer.value; +pr_debug ("uid %d min_dstate %d\n" , + dev_info.uid, + dev_info.min_dstate); + lpi_constraints_table[ + lpi_constraints_table_size].min_dstate = + dev_info.min_dstate; +break ; + } + } + + lpi_constraints_table_size++; + } + +pr_debug ("LPI: constraints dump end\n" ); +free_acpi_buffer: +ACPI_FREE (out_obj); +return ; + +free_constraints: +ACPI_FREE (out_obj); +for (i =0 ; i < lpi_constraints_table_size; ++i) +kfree (lpi_constraints_table[i].name); +kfree (lpi_constraints_table); + lpi_constraints_table_size =0 ; +} + +static void lpi_check_constraints (void ) +{ +int i; + +for (i =0 ; i < lpi_constraints_table_size; ++i) { +acpi_handle handle; +struct acpi_device *adev; +int state, ret; + +if (ACPI_FAILURE (acpi_get_handle (NULL , + lpi_constraints_table[i].name, + &handle))) +continue ; + +if (acpi_bus_get_device (handle, &adev)) +continue ; + + ret =acpi_device_get_power (adev, &state); +if (ret) +pr_debug ("LPI: %s required min power state %d, current power state %d, real power state [ERROR]\n" , + lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate, + adev->power.state); +else +pr_debug ("LPI: %s required min power state %d, current power state %d, real power state %d\n" , + lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate, + adev->power.state, state); + +if (adev->flags.power_manageable && adev->power.state < + lpi_constraints_table[i].min_dstate) +pr_info ("LPI: Constraint [%s] not matched\n" , + lpi_constraints_table[i].name); + } +} +static void acpi_sleep_run_lps0_dsm (unsigned int func) {union acpi_object *out_obj;
@@ -729,6 +891,9 @@ static int lps0_device_attach(struct acpi_device *adev, "_DSM function 0 evaluation failed\n"); }ACPI_FREE (out_obj); + +lpi_device_get_constraints (); +return 0 ; }
@@ -766,6 +931,10 @@ static int acpi_freeze_prepare(void)static void acpi_freeze_wake (void ) { + +if (pm_debug_messages_on) +lpi_check_constraints (); +/* * If IRQD_WAKEUP_ARMED is not set for the SCI at this point, it means * that the SCI has triggered while suspended, so cancel the wakeup in
include/linux/suspend.h +2 -0
@@ -495,9 +495,11 @@ static inline void unlock_system_sleep(void) {}#ifdef CONFIG_PM_SLEEP_DEBUG extern bool pm_print_times_enabled; +extern bool pm_debug_messages_on; extern __printf(2, 3) void __pm_pr_dbg(bool defer, const char *fmt, ...); #else #define pm_print_times_enabled (false) +#define pm_debug_messages_on (false)#include <linux/printk.h>
kernel/power/main.c +1 -1
@@ -361,7 +361,7 @@ static ssize_t pm_wakeup_irq_show(struct kobject *kobj,power_attr_ro (pm_wakeup_irq); -static bool pm_debug_messages_on__read_mostly ; +bool pm_debug_messages_on__read_mostly ;static ssize_t pm_debug_messages_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf)
Signature · 1 line
2.7.5
Quoted 69 lines · CEST Srinivas Pandruvada
For SoC to achieve its lowest power platform idle state a set of hardware preconditions must be met. These preconditions or constraints can be obtained by issuing a device specific method (
_DSM) with function "1". Refer to the document provided in the link below.Here during initialization (from
attach()callback of LPS0 device), invoke function 1 to get the device constraints. Each enabled constraint is stored in a table.The devices in this table are used to check whether they were in required minimum state, while entering suspend. This check is done from platform freeze
wake()callback, only when/sys/power/pm_debug_messagesattribute is non zero.If any constraint is not met and device is ACPI power managed then it prints the device name to kernel logs.
Also if debug is enabled in
acpi/sleep.c, the constraint table and state of each device on wake is dumped in kernel logs.Since
pm_debug_messages_onsetting is used as condition to check constraints outsidekernel/power/main.c,pm_debug_messages_onis changed to a global variable.Signed-off-by Srinivas Pandruvada <[email protected]>---
v3
- Removed the patch 0001 for exportingpm_debug_messages_onvia a function. As suggested by Rafael, made thepm_debug_messages_ona global variable instead.
- Moved the constraint check outsideif()block and valid for all calls toacpi_freeze_wakeup()
- Dumping irrespective of return value ofacpi_device_get_power().
- Rebased to linux-next as of todayv2
- Changes as suggested by Lukas Wunner.
- Usingpm_debug_messages_onattribute to prevent constraints check to save some cycles on wake.drivers/acpi/sleep.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/suspend.h | 2 + kernel/power/main.c | 2 +- 3 files changed, 172 insertions(+), 1 deletion(-)drivers/acpi/sleep.c +8
-0@@ -669,6 +669,7 @@ static const struct acpi_device_id lps0_device_ids[] = {#define ACPI_LPS0_DSM_UUID "c4eb40a0-6cd2-11e2-bcfd-0800200c9a66" +#define ACPI_LPS0_GET_DEVICE_CONSTRAINTS 1#define ACPI_LPS0_SCREEN_OFF 3#define ACPI_LPS0_SCREEN_ON 4#define ACPI_LPS0_ENTRY 5@@ -680,6 +681,167 @@ static acpi_handle lps0_device_handle;static guid_t lps0_dsm_guid;static char lps0_dsm_func_mask; +/* Device constraint entry structure */ +struct lpi_device_info { +char *name; +int enabled; +union acpi_object *package; +}; +
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 700
Quoted 10 lines
drivers/acpi/sleep.c +10
-0+/* Constraint package structure */ +struct lpi_device_constraint { +int uid; +int min_dstate; +int function_states; +}; + +struct lpi_constraints { +char *name; +int min_dstate;
If you store the handle here as well, you won't need to look it up every time _check_constraints() is called.
Quoted 17 lines
drivers/acpi/sleep.c +17
-0+}; + +static struct lpi_constraints *lpi_constraints_table; +static int lpi_constraints_table_size; + +static void lpi_device_get_constraints (void ) +{ +union acpi_object *out_obj; +int i; + + out_obj =acpi_evaluate_dsm_typed (lps0_device_handle, &lps0_dsm_guid, +1 ,ACPI_LPS0_GET_DEVICE_CONSTRAINTS , +NULL ,ACPI_TYPE_PACKAGE ); + +acpi_handle_debug (lps0_device_handle,"_DSM function 1 eval %s\n" , + out_obj ?"successful" :"failed" ); +
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 727
Quoted 10 lines
drivers/acpi/sleep.c +10
-0+if (!out_obj) +return ; + + lpi_constraints_table =kcalloc (out_obj->package.count, +sizeof (*lpi_constraints_table), +GFP_KERNEL ); +if (!lpi_constraints_table) + goto free_acpi_buffer; + +pr_debug ("LPI: constraints dump begin\n" );
Please add an empty line after this. Also something like "constraints list begin" would sound better IMO.
Quoted 19 lines
drivers/acpi/sleep.c +19
-0+for (i =0 ; i < out_obj->package.count; i++) { +union acpi_object *package = &out_obj->package.elements[i]; +struct lpi_device_info info = { }; +int package_count =0 , j; + +if (!package) +continue ; + +for (j =0 ; j < package->package.count; ++j) { +union acpi_object *element = + &(package->package.elements[j]); + +switch (element->type) { +case ACPI_TYPE_INTEGER : + info.enabled = element->integer.value; +break ; +case ACPI_TYPE_STRING : + info.name = element->string.pointer; +break ;
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 756
Quoted 10 lines
drivers/acpi/sleep.c +10
-0+case ACPI_TYPE_PACKAGE : + package_count = element->package.count; + info.package = element->package.elements; +break ; + } + } + +if (!info.enabled || !info.package || !info.name) +continue ; +
I would evaluate acpi_get_handle() here and store the handle in the constraints table (if persent). And you can skip the entry altogether if not present, because you won't be printing it anyway.
Quoted 55 lines
drivers/acpi/sleep.c +55
-0+ lpi_constraints_table[lpi_constraints_table_size].name = +kstrdup (info.name,GFP_KERNEL ); +if (!lpi_constraints_table[lpi_constraints_table_size].name) + goto free_constraints; + +pr_debug ("index:%d Name:%s\n" , i, info.name); + +for (j =0 ; j < package_count; ++j) { +union acpi_object *info_obj = &info.package[j]; +union acpi_object *cnstr_pkg; +union acpi_object *obj; +struct lpi_device_constraint dev_info; + +switch (info_obj->type) { +case ACPI_TYPE_INTEGER : +/* version */ +break ; +case ACPI_TYPE_PACKAGE : +if (info_obj->package.count <2 ) +break ; + + cnstr_pkg = info_obj->package.elements; + obj = &cnstr_pkg[0 ]; + dev_info.uid = obj->integer.value; + obj = &cnstr_pkg[1 ]; + dev_info.min_dstate = obj->integer.value; +pr_debug ("uid %d min_dstate %d\n" , + dev_info.uid, + dev_info.min_dstate); + lpi_constraints_table[ + lpi_constraints_table_size].min_dstate = + dev_info.min_dstate; +break ; + } + } + + lpi_constraints_table_size++; + } + +pr_debug ("LPI: constraints dump end\n" ); +free_acpi_buffer: +ACPI_FREE (out_obj); +return ; + +free_constraints: +ACPI_FREE (out_obj); +for (i =0 ; i < lpi_constraints_table_size; ++i) +kfree (lpi_constraints_table[i].name); +kfree (lpi_constraints_table); + lpi_constraints_table_size =0 ; +} + +static void lpi_check_constraints (void ) +{ +int i;
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 821
Quoted 10 lines
drivers/acpi/sleep.c +10
-0+ +for (i =0 ; i < lpi_constraints_table_size; ++i) { +acpi_handle handle; +struct acpi_device *adev; +int state, ret; + +if (ACPI_FAILURE (acpi_get_handle (NULL , + lpi_constraints_table[i].name, + &handle))) +continue ;
So if you store the handle, the above won't be necessary.
Quoted 5 lines
drivers/acpi/sleep.c +5
-0+ +if (acpi_bus_get_device (handle, &adev)) +continue ; + + ret =acpi_device_get_power (adev, &state);
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 836
Quoted 10 lines
drivers/acpi/sleep.c +10
-0+if (ret) +pr_debug ("LPI: %s required min power state %d, current power state %d, real power state [ERROR]\n" , + lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate, + adev->power.state); +else +pr_debug ("LPI: %s required min power state %d, current power state %d, real power state %d\n" , + lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate, + adev->power.state, state);
I'm not convinced about the value of the above TBH.
Also in theory _PSC may go and access things like PCI config spaces of devices which isn't a good idea for devices in D3_cold, so maybe skip this?
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 840
Quoted 4 lines
drivers/acpi/sleep.c +4
-0+ +if (adev->flags.power_manageable && adev->power.state < + lpi_constraints_table[i].min_dstate) + pr_info("LPI: Constraint [%s] not matched\n",
"Constrant [%s] not met"?
Also I'd use acpi_handle_info(adev->handle, ...) to print this.
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 841
Quoted 1 line
drivers/acpi/sleep.c +1
-0+ lpi_constraints_table[i].name);
I would print a message if !flags.power_manageable, because it means we can't get the constraint right in general.
Also I would print both power.state and min_state (possibly using acpi_power_state_string()) in this message as that is valuable for debugging.
Thanks,
Rafael
On Sat, 2017-08-12 at 16:27 +0200, Rafael J. Wysocki wrote:
[...]
Quoted 6 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 700
Quoted 4 lines
drivers/acpi/sleep.c +4
-0+ +struct lpi_constraints { +char *name; +int min_dstate;If you store the handle here as well, you won't need to look it up every time
_check_constraints()is called.
The reason I didn't keep handle here, I thought handle can be stale or change for PnP device on plug in and out. Is this not true?
Quoted 28 lines
Quoted 28 lines
drivers/acpi/sleep.c +11
-0+}; + +static struct lpi_constraints *lpi_constraints_table; +static int lpi_constraints_table_size; + +static void lpi_device_get_constraints (void ) +{ +union acpi_object *out_obj; +int i; + + out_obj = acpi_evaluate_dsm_typed(lps0_device_handle,
&lps0_dsm_guid,(quoted diff) +1
-0+ 1,
ACPI_LPS0_GET_DEVICE_CONSTRAINTS,(quoted diff) +1
-0+ NULL,
ACPI_TYPE_PACKAGE);(quoted diff) +2
-0+ + acpi_handle_debug(lps0_device_handle, "_DSM function 1eval %s\n",
drivers/acpi/sleep.c +7
-0+ out_obj ? "successful" : "failed"); + +if (!out_obj) +return ; + + lpi_constraints_table = kcalloc(out_obj->package.count, + sizeof(*lpi_constraints_table),
Quoted 9 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 727
Quoted 5 lines
drivers/acpi/sleep.c +5
-0+ GFP_KERNEL); +if (!lpi_constraints_table) + goto free_acpi_buffer; + +pr_debug ("LPI: constraints dump begin\n" );Please add an empty line after this. Also something like "constraints
list begin" would sound better IMO.
OK.
Quoted 140 lines
Quoted 29 lines
(quoted diff) +2
-0+ for (i = 0; i < out_obj->package.count; i++) { + union acpi_object *package = &out_obj-Quoted 1 line
package.elements[i];
drivers/acpi/sleep.c +9
-0+struct lpi_device_info info = { }; +int package_count =0 , j; + +if (!package) +continue ; + +for (j =0 ; j < package->package.count; ++j) { + union acpi_object *element = + &(package-Quoted 1 line
package.elements[j]);
drivers/acpi/sleep.c +4
-0+ +switch (element->type) { +case ACPI_TYPE_INTEGER : + info.enabled = element-Quoted 1 line
integer.value;
drivers/acpi/sleep.c +3
-0+break ; +case ACPI_TYPE_STRING : + info.name = element-Quoted 1 line
string.pointer;
drivers/acpi/sleep.c +3
-0+break ; +case ACPI_TYPE_PACKAGE : + package_count = element-Quoted 1 line
package.count;
(quoted diff) +1
-0+ info.package = element-Quoted 1 line
package.elements;
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 756
Quoted 7 lines
drivers/acpi/sleep.c +7
-0+break ; + } + } + +if (!info.enabled || !info.package || !info.name) +continue ; +I would evaluate
acpi_get_handle()here and store the handle in the constraints table (if persent). And you can skip the entry altogether
if not present, because you won't be printing it anyway.Quoted 73 lines
(quoted diff) +1
-0+ lpi_constraints_table[lpi_constraints_table_size].name =
(quoted diff) +1
-0+ kstrdup(info.name,
GFP_KERNEL);(quoted diff) +1
-0+ if(!lpi_constraints_table[lpi_constraints_table_size].name)
drivers/acpi/sleep.c +6
-0+ goto free_constraints; + +pr_debug ("index:%d Name:%s\n" , i, info.name); + +for (j =0 ; j < package_count; ++j) { + union acpi_object *info_obj =&info.package[j];
drivers/acpi/sleep.c +13
-0+union acpi_object *cnstr_pkg; +union acpi_object *obj; +struct lpi_device_constraint dev_info; + +switch (info_obj->type) { +case ACPI_TYPE_INTEGER : +/* version */ +break ; +case ACPI_TYPE_PACKAGE : +if (info_obj->package.count <2 ) +break ; + + cnstr_pkg = info_obj-Quoted 1 line
package.elements;
drivers/acpi/sleep.c +4
-0+ obj = &cnstr_pkg[0 ]; + dev_info.uid = obj->integer.value; + obj = &cnstr_pkg[1 ]; + dev_info.min_dstate = obj-Quoted 1 line
integer.value;
drivers/acpi/sleep.c +5
-0+pr_debug ("uid %d min_dstate %d\n" , + dev_info.uid, + dev_info.min_dstate); + lpi_constraints_table[ + lpi_constraints_table_size].min_dstate =
(quoted diff) +1
-0+ dev_info.min_dstate;
drivers/acpi/sleep.c +31
-0+break ; + } + } + + lpi_constraints_table_size++; + } + +pr_debug ("LPI: constraints dump end\n" ); +free_acpi_buffer: +ACPI_FREE (out_obj); +return ; + +free_constraints: +ACPI_FREE (out_obj); +for (i =0 ; i < lpi_constraints_table_size; ++i) +kfree (lpi_constraints_table[i].name); +kfree (lpi_constraints_table); + lpi_constraints_table_size =0 ; +} + +static void lpi_check_constraints (void ) +{ +int i; + +for (i =0 ; i < lpi_constraints_table_size; ++i) { +acpi_handle handle; +struct acpi_device *adev; +int state, ret; + + if (ACPI_FAILURE(acpi_get_handle(NULL, + lpi_constraints_table[i].name,
Review
Quoted 2 lines
(quoted diff) +2
-0+ &handle))) + continue;So if you store the handle, the above won't be necessary.
Quoted 19 lines
drivers/acpi/sleep.c +7
-0+ +if (acpi_bus_get_device (handle, &adev)) +continue ; + + ret =acpi_device_get_power (adev, &state); +if (ret) + pr_debug("LPI: %s required min power state%d, current power state %d, real power state [ERROR]\n",
(quoted diff) +2
-0+ lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate,
drivers/acpi/sleep.c +3
-0+ adev->power.state); + else + pr_debug("LPI: %s required min power state%d, current power state %d, real power state %d\n",
(quoted diff) +2
-0+ lpi_constraints_table[i].name, + lpi_constraints_table[i].min_dstate,
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 836
Quoted 1 line
drivers/acpi/sleep.c +1
-0+ adev->power.state, state);I'm not convinced about the value of the above TBH.
Quoted 3 lines
Also in theory
_PSCmay go and access things like PCI config spaces of devices
which isn't a good idea for devices inD3_cold, so maybe skip this?
OK.
Quoted 14 lines
Quoted 9 lines
(quoted diff) +2
-0+ + if (adev->flags.power_manageable && adev-Quoted 1 line
power.state <
(quoted diff) +1
-0+ lpi_constraints_table[i].m
in_dstate)(quoted diff) +1
-0+ pr_info("LPI: Constraint [%s] notmatched\n",
"Constrant [%s] not met"?
Also I'd use
acpi_handle_info(adev->handle, ...)to print this.Quoted 1 line
Quoted 8 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 841
Quoted 1 line
drivers/acpi/sleep.c +1
-0+ lpi_constraints_table[i].name);I would print a message if !flags.power_manageable, because it means we
can't get the constraint right in general.Also I would print both power.state and
min_state(possibly usingacpi_power_state_string()) in this message as that is valuable for debugging.
OK.
Thanks,
Srinivas
Rafael J. Wysocki
maintainerQuoted 10 lines · Srinivas Pandruvada
On Sat, 2017-08-12 at 16:27 +0200, Rafael J. Wysocki wrote:
[...]Quoted 6 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 700
Quoted 4 lines
drivers/acpi/sleep.c +4
-0+ +struct lpi_constraints { +char *name; +int min_dstate;If you store the handle here as well, you won't need to look it up every time
_check_constraints()is called.
Quoted 2 lines
The reason I didn't keep handle here, I thought handle can be stale or change for PnP device on plug in and out. Is this not true?
The handles don't go away on hot remove as a rule. That may only happen if tables get unloaded, but basically the constraints should not point to anything in a table that may go away.
Quoted 14 lines · Rafael J. Wysocki
Quoted 12 lines · Srinivas Pandruvada
On Sat, 2017-08-12 at 16:27 +0200, Rafael J. Wysocki wrote:
[...]Quoted 8 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 700
Quoted 6 lines
drivers/acpi/sleep.c +4
-0+ +struct lpi_constraints { + char *name; + int min_dstate;If you store the handle here as well, you won't need to look it up every time
_check_constraints()is called.
Quoted 6 lines
Quoted 3 lines
The reason I didn't keep handle here, I thought handle can be stale or
change for PnP device on plug in and out. Is this not true?The handles don't go away on hot remove as a rule. That may only happen if tables get unloaded, but basically the constraints should not point to anything in a table that may go away.
So we don't need to worry about this case where tables gets unloaded and replaced? This is in a debug path, so additional overhead of path to handle conversion may not be significant.
Thanks,
Srinivas
Rafael J. Wysocki
maintainerQuoted 18 lines · Srinivas Pandruvada
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Srinivas Pandruvada
On Sat, 2017-08-12 at 16:27 +0200, Rafael J. Wysocki wrote:
[...]Quoted 8 lines
drivers/acpi/sleep.c static acpi_handle lps0_device_handle; · line 700
Quoted 6 lines
drivers/acpi/sleep.c +4
-0+ +struct lpi_constraints { +char *name; +int min_dstate;If you store the handle here as well, you won't need to look it up every time
_check_constraints()is called.The reason I didn't keep handle here, I thought handle can be stale or
change for PnP device on plug in and out. Is this not true?
Quoted 6 lines
Quoted 3 lines
The handles don't go away on hot remove as a rule. That may only happen if tables get unloaded, but basically the constraints should not point to anything in a table that may go away.
So we don't need to worry about this case where tables gets unloaded and replaced?
I wouldn't. :-)
We generally don't support that case entirely, so why bother?
Quoted 2 lines
This is in a debug path, so additional overhead of path to handle conversion may not be significant.
Well, it still is wasted cycles ...