ACPI & driver patches for 2.6.30-rc0
Subsystems (11)
Len Brown
reviewerPATCH 81/98 thermal: support forcing support for passive cooling
In reply to Len BrownFrom: Matthew Garrett <[email protected]>
Due to poor thermal design or Linux driving hardware outside its thermal envelope, some systems will reach critical temperature and shut down under high load. This patch adds support for forcing a polling-based passive trip point if the firmware doesn't provide one. The assumption is made that the processor is the most practical means to reduce the dynamic heat generation, so hitting the passive thermal limit will cause the CPU to be throttled until the temperature stabalises around the defined value.
UI is provided via a "passive" sysfs entry in the thermal zone directory. It accepts a decimal value in millidegrees celsius, or "0" to disable the functionality. Default behaviour is for this functionality to be disabled.
--- drivers/thermal/thermal_sys.c | 77 +++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 78 insertions(+), 0 deletions(-)
drivers/thermal/thermal_sys.c +77 -0
@@ -214,9 +214,69 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%ld\n" , temperature); } +static ssize_t +passive_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +struct thermal_cooling_device *cdev =NULL ; +int state; + +if (!sscanf (buf,"%d\n" , &state)) +return -EINVAL ; + +if (state && !tz->forced_passive) { +mutex_lock (&thermal_list_lock); +list_for_each_entry (cdev, &thermal_cdev_list, node) { +if (!strncmp ("Processor" , cdev->type, +sizeof ("Processor" ))) +thermal_zone_bind_cooling_device (tz, +THERMAL_TRIPS_NONE , + cdev); + } +mutex_unlock (&thermal_list_lock); + }else if (!state && tz->forced_passive) { +mutex_lock (&thermal_list_lock); +list_for_each_entry (cdev, &thermal_cdev_list, node) { +if (!strncmp ("Processor" , cdev->type, +sizeof ("Processor" ))) +thermal_zone_unbind_cooling_device (tz, +THERMAL_TRIPS_NONE , + cdev); + } +mutex_unlock (&thermal_list_lock); + } + + tz->tc1 =1 ; + tz->tc2 =1 ; + +if (!tz->passive_delay) + tz->passive_delay =1000 ; + +if (!tz->polling_delay) + tz->polling_delay =10000 ; + + tz->forced_passive = state; + +thermal_zone_device_update (tz); + +return count; +} + +static ssize_t +passive_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); + +return sprintf (buf,"%d\n" , tz->forced_passive); +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); +static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, \ + passive_store);static struct device_attribute trip_point_attrs[] = {__ATTR (trip_point_0_type,0444 , trip_point_type_show,NULL ),
@@ -939,6 +999,11 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)break ; } } + +if (tz->forced_passive) +thermal_zone_device_passive (tz, temp, tz->forced_passive, +THERMAL_TRIPS_NONE ); + tz->last_temperature = temp;if (tz->passive)thermal_zone_device_set_polling (tz, tz->passive_delay);
@@ -977,8 +1042,10 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, {struct thermal_zone_device *tz;struct thermal_cooling_device *pos; +enum thermal_trip_type trip_type;int result;int count; +int passive =0 ;if (strlen (type) >=THERMAL_NAME_LENGTH )return ERR_PTR (-EINVAL );
@@ -1041,8 +1108,18 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,TRIP_POINT_ATTR_ADD (&tz->device, count, result);if (result) goto unregister; + tz->ops->get_trip_type (tz, count, &trip_type); +if (trip_type ==THERMAL_TRIP_PASSIVE ) + passive =1 ; } +if (!passive) + result =device_create_file (&tz->device, + &dev_attr_passive); + +if (result) + goto unregister; + result =thermal_add_hwmon_sysfs (tz);if (result) goto unregister;
include/linux/thermal.h +1 -0
@@ -113,6 +113,7 @@ struct thermal_zone_device {int polling_delay;int last_temperature;bool passive; +unsigned int forced_passive;struct thermal_zone_device_ops *ops;struct list_head cooling_devices;struct idr idr;
Signature · 1 line
1.6.0.6
Re: [PATCH 81/98] thermal: support forcing support for passive cooling
Quoted 11 lines · On Saturday 28 March 2009 05:31:56 Len Brown wrote:
From: Matthew Garrett <[email protected]>
Due to poor thermal design or Linux driving hardware outside its thermal envelope, some systems will reach critical temperature and shut down under high load. This patch adds support for forcing a polling-based passive trip point if the firmware doesn't provide one. The assumption is made that the processor is the most practical means to reduce the dynamic heat generation, so hitting the passive thermal limit will cause the CPU to be throttled until the temperature stabalises around the defined value.
Quoted 4 lines
UI is provided via a "passive" sysfs entry in the thermal zone directory. It accepts a decimal value in millidegrees celsius, or "0" to disable the functionality. Default behaviour is for this functionality to be disabled.
Isn't the last paragraph worth adding to:Documentation/thermal/sysfs-api.txt
or have I missed this part?
Thomas
Quoted 144 lines
Signed-off-by Matthew Garrett <[email protected]>Signed-off-by Len Brown <[email protected]>--- drivers/thermal/thermal_sys.c | 77 +++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 78 insertions(+), 0 deletions(-)drivers/thermal/thermal_sys.c +77
-0@@ -214,9 +214,69 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%ld\n" , temperature); } +static ssize_t +passive_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +struct thermal_cooling_device *cdev =NULL ; +int state; + +if (!sscanf (buf,"%d\n" , &state)) +return -EINVAL ; + +if (state && !tz->forced_passive) { +mutex_lock (&thermal_list_lock); +list_for_each_entry (cdev, &thermal_cdev_list, node) { +if (!strncmp ("Processor" , cdev->type, +sizeof ("Processor" ))) +thermal_zone_bind_cooling_device (tz, +THERMAL_TRIPS_NONE , + cdev); + } +mutex_unlock (&thermal_list_lock); + }else if (!state && tz->forced_passive) { +mutex_lock (&thermal_list_lock); +list_for_each_entry (cdev, &thermal_cdev_list, node) { +if (!strncmp ("Processor" , cdev->type, +sizeof ("Processor" ))) +thermal_zone_unbind_cooling_device (tz, +THERMAL_TRIPS_NONE , + cdev); + } +mutex_unlock (&thermal_list_lock); + } + + tz->tc1 =1 ; + tz->tc2 =1 ; + +if (!tz->passive_delay) + tz->passive_delay =1000 ; + +if (!tz->polling_delay) + tz->polling_delay =10000 ; + + tz->forced_passive = state; + +thermal_zone_device_update (tz); + +return count; +} + +static ssize_t +passive_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); + +return sprintf (buf,"%d\n" , tz->forced_passive); +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); +static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, \ + passive_store);static struct device_attribute trip_point_attrs[] = {__ATTR (trip_point_0_type,0444 , trip_point_type_show,NULL ),@@ -939,6 +999,11 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)break ; } } + +if (tz->forced_passive) +thermal_zone_device_passive (tz, temp, tz->forced_passive, +THERMAL_TRIPS_NONE ); + tz->last_temperature = temp;if (tz->passive)thermal_zone_device_set_polling (tz, tz->passive_delay);@@ -977,8 +1042,10 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, {struct thermal_zone_device *tz;struct thermal_cooling_device *pos; +enum thermal_trip_type trip_type;int result;int count; +int passive =0 ;if (strlen (type) >=THERMAL_NAME_LENGTH )return ERR_PTR (-EINVAL );@@ -1041,8 +1108,18 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,TRIP_POINT_ATTR_ADD (&tz->device, count, result);if (result) goto unregister; + tz->ops->get_trip_type (tz, count, &trip_type); +if (trip_type ==THERMAL_TRIP_PASSIVE ) + passive =1 ; } +if (!passive) + result =device_create_file (&tz->device, + &dev_attr_passive); + +if (result) + goto unregister; + result =thermal_add_hwmon_sysfs (tz);if (result) goto unregister;include/linux/thermal.h +1
-0@@ -113,6 +113,7 @@ struct thermal_zone_device {int polling_delay;int last_temperature;bool passive; +unsigned int forced_passive;struct thermal_zone_device_ops *ops;struct list_head cooling_devices;struct idr idr;Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Len Brown
reviewerRe: [PATCH 81/98] thermal: support forcing support for passive cooling
Quoted 12 lines
Quoted 12 lines
From: Matthew Garrett <[email protected]>
Due to poor thermal design or Linux driving hardware outside its thermal envelope, some systems will reach critical temperature and shut down under high load. This patch adds support for forcing a polling-based passive trip point if the firmware doesn't provide one. The assumption is made that the processor is the most practical means to reduce the dynamic heat generation, so hitting the passive thermal limit will cause the CPU to be throttled until the temperature stabalises around the defined value.
Quoted 8 lines
Quoted 4 lines
UI is provided via a "passive" sysfs entry in the thermal zone directory. It accepts a decimal value in millidegrees celsius, or "0" to disable the functionality. Default behaviour is for this functionality to be disabled.
Isn't the last paragraph worth adding to:
Documentation/thermal/sysfs-api.txt
or have I missed this part?
I think you're right, Thomas.
Matthew -- can you update the doc to reflect this change?
thanks,
-Len
Len Brown
reviewerPATCH 82/98 ACPI: remove unused acpi_device_ops .lock and .scan methods
In reply to Len BrownFrom: Bjorn Helgaas <[email protected]>
No drivers use the .lock and .scan methods, and the Linux/ACPI code doesn't even provide a way to invoke them, so remove them.
--- include/acpi/acpi_bus.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
include/acpi/acpi_bus.h +0 -4
@@ -88,13 +88,11 @@ struct acpi_device;typedef int (*acpi_op_add ) (struct acpi_device * device);typedef int (*acpi_op_remove ) (struct acpi_device * device,int type); -typedef int (*acpi_op_lock ) (struct acpi_device * device,int type);typedef int (*acpi_op_start ) (struct acpi_device * device);typedef int (*acpi_op_stop ) (struct acpi_device * device,int type);typedef int (*acpi_op_suspend ) (struct acpi_device * device,pm_message_t state);typedef int (*acpi_op_resume ) (struct acpi_device * device); -typedef int (*acpi_op_scan ) (struct acpi_device * device);typedef int (*acpi_op_bind ) (struct acpi_device * device);typedef int (*acpi_op_unbind ) (struct acpi_device * device);typedef int (*acpi_op_shutdown ) (struct acpi_device * device);
@@ -117,12 +115,10 @@ struct acpi_bus_ops {struct acpi_device_ops {acpi_op_add add;acpi_op_remove remove; -acpi_op_lock lock;acpi_op_start start;acpi_op_stop stop;acpi_op_suspend suspend;acpi_op_resume resume; -acpi_op_scan scan;acpi_op_bind bind;acpi_op_unbind unbind;acpi_op_shutdown shutdown;
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 83/98 ACPI: remove unused acpi_device_ops .shutdown method
In reply to Len BrownFrom: Bjorn Helgaas <[email protected]>
No drivers use the .shutdown method, so remove it.
--- drivers/acpi/scan.c | 12 ------------ include/acpi/acpi_bus.h | 2 -- 2 files changed, 0 insertions(+), 14 deletions(-)
drivers/acpi/scan.c +0 -12
@@ -395,22 +395,10 @@ static int acpi_device_remove(struct device * dev)return 0 ; } -static void acpi_device_shutdown (struct device *dev) -{ -struct acpi_device *acpi_dev =to_acpi_device (dev); -struct acpi_driver *acpi_drv = acpi_dev->driver; - -if (acpi_drv && acpi_drv->ops.shutdown) - acpi_drv->ops.shutdown (acpi_dev); - -return ; -} -struct bus_type acpi_bus_type = { .name ="acpi" , .suspend = acpi_device_suspend, .resume = acpi_device_resume, - .shutdown = acpi_device_shutdown, .match = acpi_bus_match, .probe = acpi_device_probe, .remove = acpi_device_remove,
include/acpi/acpi_bus.h +0 -2
@@ -95,7 +95,6 @@ typedef int (*acpi_op_suspend) (struct acpi_device * device,typedef int (*acpi_op_resume ) (struct acpi_device * device);typedef int (*acpi_op_bind ) (struct acpi_device * device);typedef int (*acpi_op_unbind ) (struct acpi_device * device); -typedef int (*acpi_op_shutdown ) (struct acpi_device * device);struct acpi_bus_ops {u32 acpi_op_add:1 ;
@@ -121,7 +120,6 @@ struct acpi_device_ops {acpi_op_resume resume;acpi_op_bind bind;acpi_op_unbind unbind; -acpi_op_shutdown shutdown; };struct acpi_driver {
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 84/98 ACPI: remove unused acpi_bus_ops flags
In reply to Len BrownFrom: Bjorn Helgaas <[email protected]>
In acpi_bus_ops, only the acpi_op_add and acpi_op_start flags are used, so remove all the rest.
--- include/acpi/acpi_bus.h | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-)
include/acpi/acpi_bus.h +0 -10
@@ -98,17 +98,7 @@ typedef int (*acpi_op_unbind) (struct acpi_device * device);struct acpi_bus_ops {u32 acpi_op_add:1 ; -u32 acpi_op_remove:1 ; -u32 acpi_op_lock:1 ;u32 acpi_op_start:1 ; -u32 acpi_op_stop:1 ; -u32 acpi_op_suspend:1 ; -u32 acpi_op_resume:1 ; -u32 acpi_op_scan:1 ; -u32 acpi_op_bind:1 ; -u32 acpi_op_unbind:1 ; -u32 acpi_op_shutdown:1 ; -u32 reserved:21 ; };struct acpi_device_ops {
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 85/98 ACPI: Avoid wiping out pr->performance during preregistering
In reply to Len BrownFrom: Stanislaw Gruszka <[email protected]>
When cpufreq driver call acpi_processor_preregister_performance() , function will clean up pr->performance even if there is possibly already registered other cpufreq driver. The patch fix this potential problem. It also remove double checks in P domain basic validity code and move these checks to function where _PSD data is captured.
--- drivers/acpi/processor_perflib.c | 46 +++++++++++++++++-------------------- 1 files changed, 21 insertions(+), 25 deletions(-)
drivers/acpi/processor_perflib.c +21 -25
@@ -479,6 +479,13 @@ static int acpi_processor_get_psd(struct acpi_processor *pr) goto end; } +if (pdomain->coord_type !=DOMAIN_COORD_TYPE_SW_ALL && + pdomain->coord_type !=DOMAIN_COORD_TYPE_SW_ANY && + pdomain->coord_type !=DOMAIN_COORD_TYPE_HW_ALL ) { + printk(KERN_ERR PREFIX "Invalid _PSD:coord_type\n"); + result = -EFAULT ; + goto end; + } end:kfree (buffer.pointer);return result;
@@ -501,9 +508,10 @@ int acpi_processor_preregister_performance(mutex_lock (&performance_mutex); - retval =0 ; - -/* Call _PSD for all CPUs */ +/* +* Check if another driver has already registered, and abort before +* changing pr->performance if it has. Check input data as well. +*/ for_each_possible_cpu (i) { pr =per_cpu (processors, i);if (!pr) {
@@ -513,13 +521,20 @@ int acpi_processor_preregister_performance(if (pr->performance) { retval = -EBUSY ; -continue ; + goto err_out; }if (!performance || !percpu_ptr (performance, i)) { retval = -EINVAL ; -continue ; + goto err_out; } + } + +/* Call _PSD for all CPUs */ +for_each_possible_cpu (i) { + pr =per_cpu (processors, i); +if (!pr) +continue ; pr->performance =percpu_ptr (performance, i);cpumask_set_cpu (i, pr->performance->shared_cpu_map);
@@ -535,26 +550,6 @@ int acpi_processor_preregister_performance(* Now that we have _PSD data from all CPUs, lets setup P-state * domain info. */ -for_each_possible_cpu (i) { - pr =per_cpu (processors, i); -if (!pr) -continue ; - -/* Basic validity check for domain info */ - pdomain = &(pr->performance->domain_info); -if ((pdomain->revision !=ACPI_PSD_REV0_REVISION ) || - (pdomain->num_entries !=ACPI_PSD_REV0_ENTRIES )) { - retval = -EINVAL ; - goto err_ret; - } -if (pdomain->coord_type !=DOMAIN_COORD_TYPE_SW_ALL && - pdomain->coord_type !=DOMAIN_COORD_TYPE_SW_ANY && - pdomain->coord_type !=DOMAIN_COORD_TYPE_HW_ALL ) { - retval = -EINVAL ; - goto err_ret; - } - } -cpumask_clear (covered_cpus);for_each_possible_cpu (i) { pr =per_cpu (processors, i);
@@ -643,6 +638,7 @@ err_ret: pr->performance =NULL ;/* Will be set for real in register */ } +err_out:mutex_unlock (&performance_mutex);free_cpumask_var (covered_cpus);return retval;
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 86/98 ACPI: cap off P-state transition latency from buggy BIOSes
In reply to Len BrownFrom: Pallipadi, Venkatesh <[email protected]>
Some BIOSes report very high frequency transition latency which are plainly wrong on CPus that can change frequency using native MSR interface.
One such system is IBM T42 (2327-8ZU) as reported by Owen Taylor and Rik van Riel.
cpufreq_ondemand driver uses this transition latency to come up with a reasonable sampling interval to sample CPU usage and with such high latency value, ondemand sampling interval ends up being very high (0.5 sec, in this particular case), resulting in performance impact due to slow response to increasing frequency.
Fix it by capping-off the transition latency to 20uS for native MSR based frequency transitions.
mjg: We've confirmed that this also helps on the X31
--- arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +12 -0
@@ -680,6 +680,18 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) perf->states[i].transition_latency *1000 ; } +/* Check for high latency (>20uS) from buggy BIOSes, like on T42 */ +if (perf->control_register.space_id ==ACPI_ADR_SPACE_FIXED_HARDWARE && + policy->cpuinfo.transition_latency >20 *1000 ) { +static int print_once; + policy->cpuinfo.transition_latency =20 *1000 ; +if (!print_once) { + print_once =1 ; +printk (KERN_INFO "Capping off P-state tranision latency" +" at 20 uS\n" ); + } + } + data->max_freq = perf->states[0 ].core_frequency *1000 ;/* table init */ for (i=0 ; i<perf->state_count; i++) {
Signature · 1 line
1.6.0.6
A message that is not in the archive (sent off-list or not yet received): [email protected]
Len Brown
reviewerRe: [PATCH 86/98] ACPI: cap off P-state transition latency from buggy BIOSes
Quoted 3 lines
Whatabout:
I've added this to my .stable list, thanks for pointing it out. Note that I don't send patches to stable until after they are upstream.
thanks,
-Len
Quoted 16 lines
This is a bug fix also existing in older kernels.
I remember even much newer HW (Intel and AMD) based have higher values
exported through ACPI
_PSStables as latency.I remember values around (50-70us Core 2 Duo?) and 37us on K10.
I doubt this patch will cause much pain, but being close to values exported
via ACPI tables on similar HW sounds like a good idea.
In 2.6.30 (as soon as cpufreq branch is merged) you get that easily from here:
cat
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency
Quoted 7 lines
109000
I expect my machine's (K8 Dual core) ACPI exported value will be cut down to:
20000
now?
Does your AMD box run acpi-cpufreq and use native MSR access to change P-states?
Quoted 3 lines
I don't want to veto this one, but IMO the 20us second value
should get 100us...
Where does 100us come from?
thanks,
-Len Brown, Intel Open Source Technology Center
Re: [PATCH 86/98] ACPI: cap off P-state transition latency from buggy BIOSes
Quoted 6 lines · Len Brown
Quoted 3 lines
Whatabout:
I've added this to my .stable list, thanks for pointing it out. Note that I don't send patches to stable until after they are upstream.
Thanks.
There are generally two kind of patches that should go to stable:
1) The simple NULL pointer fixes (and similar safe ones) which can/ should go directly to stable, at least if they hit the mainline kernel
2) Bug fixes which potentially could harm others (as you mentioned in the other one).
For the latter these should go to stable if they survived a full mainline kernel round (and eventually together with add-on patches) or at least some RCs. Looks like every maintainer has his own way (and overhead) to queue and take care of them?
I wonder how things could get automated and patches could get tagged, not only with CC: <[email protected]>, but to consider both cases. Or you always add CC: <[email protected]>, the stable team will ask again before adding them and you can tell them to still hold them off for a while, so that they get more testing.
Quoted 16 lines
thanks,
-LenQuoted 13 lines
This is a bug fix also existing in older kernels.
I remember even much newer HW (Intel and AMD) based have higher values exported through ACPI_PSStables as latency.I remember values around (50-70us Core 2 Duo?) and 37us on K10. I doubt this patch will cause much pain, but being close to values exported via ACPI tables on similar HW sounds like a good idea.
In 2.6.30 (as soon as cpufreq branch is merged) you get that easily from here:
cat/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency109000
Quoted 7 lines
Quoted 4 lines
I expect my machine's (K8 Dual core) ACPI exported value will be cut down to:
20000
now?Does your AMD box run acpi-cpufreq and use native MSR access to change P-states?
Argh, now I see it. It's done in acpi-cpufreq, it looked like generic code in drivers/acpi/processor_*
But it still looks rather low. I've seen higher values exported via ACPI tables even for newer Intel based laptops. But Venki should know better than myself. Just a heads up.
Capping off the sampling rate generally (this is the value calculated from the latency which causes the performance regression) in ondemand governor to e.g. 100ms sampling rate is probably also a good idea. I'll suggest that on the cpufreq list...
Thanks,
Thomas
Len Brown
reviewerRe: [PATCH 86/98] ACPI: cap off P-state transition latency from buggy BIOSes
thanks,
Len Brown, Intel Open Source Technology Center
Quoted 7 lines · Thomas Renninger
Quoted 6 lines · Len Brown
Quoted 3 lines
Whatabout:
I've added this to my .stable list, thanks for pointing it out. Note that I don't send patches to stable until after they are upstream.
Quoted 15 lines
Thanks.
There are generally two kind of patches that should go to stable:
1) The simple NULL pointer fixes (and similar safe ones) which can/ should go directly to stable, at least if they hit the mainline kernel
2) Bug fixes which potentially could harm others (as you mentioned in the other one).
For the latter these should go to stable if they survived a full mainline kernel round (and eventually together with add-on patches) or at least some RCs. Looks like every maintainer has his own way (and overhead) to queue and take care of them?
I wonder how things could get automated and patches could get tagged, not only with CC: <[email protected]>, but to consider both cases. Or you always add CC: <[email protected]>, the stable team will ask again before adding them and you can tell them to still hold them off for a while, so that they get more testing.
I send patches to stable manually,
and I manually make sure it applies to the targeted .y release first.
As you know, I'm not super aggressive in what I send back, but I do keep a list for this in my notes.
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines
This is a bug fix also existing in older kernels.
I remember even much newer HW (Intel and AMD) based have higher values exported through ACPI_PSStables as latency.I remember values around (50-70us Core 2 Duo?) and 37us on K10. I doubt this patch will cause much pain, but being close to values exported via ACPI tables on similar HW sounds like a good idea.
In 2.6.30 (as soon as cpufreq branch is merged) you get that easily from here:
cat/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency109000Quoted 7 lines
Quoted 4 lines
I expect my machine's (K8 Dual core) ACPI exported value will be cut down to:
20000
now?Does your AMD box run acpi-cpufreq and use native MSR access to change P-states?
Quoted 6 lines
Argh, now I see it. It's done in acpi-cpufreq, it looked like generic code in
drivers/acpi/processor_*But it still looks rather low. I've seen higher values exported via ACPI tables even for newer Intel based laptops. But Venki should know better than myself. Just a heads up.
We (Intel Linux team) are acutely aware of Intel's actual P-state latencies and how BIOS writers are more often wrong than right.
note that this cap applies only to the systems that support MSR transitions -- which is the newer stuff.
Quoted 3 lines
Capping off the sampling rate generally (this is the value calculated from the latency which causes the performance regression) in ondemand governor to e.g. 100ms sampling rate is probably also a good idea. I'll suggest that on the cpufreq list...
yeah, that does sound like a good idea.
all it needs is a real example of the failure to justify the patch.
cheers,
Len Brown, Intel Open Source Technology Center
Len Brown
reviewerPATCH 87/98 Fix state reporting in tc1100-wmi
In reply to Len BrownFrom: Krzysztof Kosiński <[email protected]>
The tc1100-wmi driver should print the current states of wireless LAN and jogdial brightness control when "cat /sys/devices/platform/tc1100-wmi/wireless" and "cat /sys/devices/platform/tc1100-wmi/jogdial" are executed, respectively. What actually happens is that both of those commands print 0 regardless of the hardware state. The cause is that wmi_query_block returns an ACPI_TYPE_INTEGER rather than ACPI_TYPE_BUFFER as the driver assumes. Additionally, the driver intends to return a jogdial state that is inverted with respect to the commands required to set it (e.g. it intends to return 1 after the jogdial file was written with 0).
This patch fixes both of those issues - the commands to query the state now work, and should return the same state that was written.
http://bugzilla.kernel.org/show_bug.cgi?id=12286
--- drivers/platform/x86/tc1100-wmi.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/tc1100-wmi.c +3 -4
@@ -94,9 +94,8 @@ static int get_state(u32 *out, u8 instance)return -ENODEV ; obj = (union acpi_object *) result.pointer; -if (obj && obj->type ==ACPI_TYPE_BUFFER && - obj->buffer.length ==sizeof (u32)) { - tmp = *((u32 *) obj->buffer.pointer); +if (obj && obj->type ==ACPI_TYPE_INTEGER ) { + tmp = obj->integer.value; }else { tmp =0 ; }
@@ -109,7 +108,7 @@ static int get_state(u32 *out, u8 instance) *out = (tmp ==3 ) ?1 :0 ;return 0 ;case TC1100_INSTANCE_JOGDIAL : - *out = (tmp ==1 ) ?1 :0 ; + *out = (tmp ==1 ) ?0 :1 ;return 0 ;default :return -ENODEV ;
Signature · 6 lines
1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 87/98] Fix state reporting in tc1100-wmi
Quoted 13 lines · On Saturday 28 March 2009 04:32:02 Len Brown wrote:
From: Krzysztof Kosiński <[email protected]>
The tc1100-wmi driver should print the current states of wireless LAN and jogdial brightness control when "cat
/sys/devices/platform/tc1100-wmi/wireless" and "cat/sys/devices/platform/tc1100-wmi/jogdial" are executed, respectively. What actually happens is that both of those commands print 0 regardless of the hardware state. The cause is thatwmi_query_blockreturns anACPI_TYPE_INTEGERrather thanACPI_TYPE_BUFFERas the driver assumes. Additionally, the driver intends to return a jogdial state that is inverted with respect to the commands required to set it (e.g. it intends to return 1 after the jogdial file was written with 0).
Quoted 6 lines
This patch fixes both of those issues - the commands to query the state now work, and should return the same state that was written.
http://bugzilla.kernel.org/show_bug.cgi?id=12286
Signed-off-by Krzysztof Kosiński <[email protected]>
Quoted 30 lines
Signed-off-by Len Brown <[email protected]>--- drivers/platform/x86/tc1100-wmi.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/platform/x86/tc1100-wmi.cindex b4a4aa9..4416600 100644drivers/platform/x86/tc1100-wmi.c +3
-4@@ -94,9 +94,8 @@ static int get_state(u32 *out, u8 instance)return -ENODEV ; obj = (union acpi_object *) result.pointer; -if (obj && obj->type ==ACPI_TYPE_BUFFER && - obj->buffer.length ==sizeof (u32)) { - tmp = *((u32 *) obj->buffer.pointer); +if (obj && obj->type ==ACPI_TYPE_INTEGER ) { + tmp = obj->integer.value; }else { tmp =0 ; }@@ -109,7 +108,7 @@ static int get_state(u32 *out, u8 instance) *out = (tmp ==3 ) ?1 :0 ;return 0 ;case TC1100_INSTANCE_JOGDIAL : - *out = (tmp ==1 ) ?1 :0 ; + *out = (tmp ==1 ) ?0 :1 ;return 0 ;default :return -ENODEV ;
Signature · 7 lines
E-Mail: [email protected] Web: strangeworlds.co.uk GPG Key ID: 0x23EE722D -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Len Brown
reviewerPATCH 88/98 ACPI video: check the return value of acpi_video_device_lcd_get_level_current
In reply to Len BrownFrom: Zhang Rui <[email protected]>
--- drivers/acpi/video.c | 55 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 45 insertions(+), 10 deletions(-)
drivers/acpi/video.c +45 -10
@@ -294,7 +294,7 @@ static int acpi_video_device_lcd_get_level_current( unsigned long long *level);static int acpi_video_get_next_level (struct acpi_video_device *device,u32 level_current,u32 event); -static void acpi_video_switch_brightness (struct acpi_video_device *device, +static int acpi_video_switch_brightness (struct acpi_video_device *device,int event);static int acpi_video_device_get_state (struct acpi_video_device *device,unsigned long long *state);
@@ -308,7 +308,9 @@ static int acpi_video_get_brightness(struct backlight_device *bd)int i;struct acpi_video_device *vd = (struct acpi_video_device *)bl_get_data (bd); -acpi_video_device_lcd_get_level_current (vd, &cur_level); + +if (acpi_video_device_lcd_get_level_current (vd, &cur_level)) +return -EINVAL ;for (i =2 ; i < vd->brightness->count; i++) {if (vd->brightness->levels[i] == cur_level)/* The first two entries are special - see page 575
@@ -373,7 +375,8 @@ static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf)unsigned long long level;int state; -acpi_video_device_lcd_get_level_current (video, &level); +if (acpi_video_device_lcd_get_level_current (video, &level)) +return -EINVAL ;for (state =2 ; state < video->brightness->count; state++)if (level == video->brightness->levels[state]) return sprintf(buf, "%d\n",
@@ -502,11 +505,29 @@ static int acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, unsigned long long *level) { - if (device->cap._BQC) - return acpi_evaluate_integer(device->dev->handle, "_BQC", NULL, - level); + acpi_status status = AE_OK; + +if (device->cap._BQC) { + status =acpi_evaluate_integer (device->dev->handle,"_BQC" , +NULL , level); +if (ACPI_SUCCESS (status)) { + device->brightness->curr = *level; +return 0 ; + }else { +/* Fixme: +* should we return an error or ignore this failure? +* dev->brightness->curr is a cached value which stores +* the correct current backlight level in most cases. +* ACPI video backlight still works w/ buggy _BQC. +* http://bugzilla.kernel.org/show_bug.cgi?id=12233 +*/ +ACPI_WARNING ((AE_INFO ,"Evaluating _BQC failed" )); + device->cap._BQC =0 ; + } + } + *level = device->brightness->curr; -return AE_OK ; +return 0 ; } static int
@@ -1749,15 +1770,29 @@ acpi_video_get_next_level(struct acpi_video_device *device, } } -static void +static int acpi_video_switch_brightness (struct acpi_video_device *device,int event) {unsigned long long level_current, level_next; +int result = -EINVAL ; +if (!device->brightness) -return ; -acpi_video_device_lcd_get_level_current (device, &level_current); + goto out; + + result =acpi_video_device_lcd_get_level_current (device, + &level_current); +if (result) + goto out; + level_next =acpi_video_get_next_level (device, level_current, event); +acpi_video_device_lcd_set_level (device, level_next); + +out: +if (result) + printk(KERN_ERR PREFIX "Failed to switch the brightness\n"); + +return result; } static int
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 89/98 ACPI video: check the return value of acpi_video_device_lcd_set_level
In reply to Len BrownFrom: Zhang Rui <[email protected]>
--- drivers/acpi/video.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-)
drivers/acpi/video.c +21 -16
@@ -322,12 +322,12 @@ static int acpi_video_get_brightness(struct backlight_device *bd)static int acpi_video_set_brightness (struct backlight_device *bd) { -int request_level = bd->props.brightness+2 ; +int request_level = bd->props.brightness +2 ;struct acpi_video_device *vd = (struct acpi_video_device *)bl_get_data (bd); -acpi_video_device_lcd_set_level (vd, - vd->brightness->levels[request_level]); -return 0 ; + +return acpi_video_device_lcd_set_level (vd, + vd->brightness->levels[request_level]); }static struct backlight_ops acpi_backlight_ops = {
@@ -482,23 +482,29 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,static int acpi_video_device_lcd_set_level (struct acpi_video_device *device,int level) { -int status =AE_OK ; +int status;union acpi_object arg0 = {ACPI_TYPE_INTEGER };struct acpi_object_list args = {1 , &arg0 };int state; - arg0.integer.value = level; -if (device->cap._BCM) - status =acpi_evaluate_object (device->dev->handle,"_BCM" , - &args,NULL ); + status =acpi_evaluate_object (device->dev->handle,"_BCM" , + &args,NULL ); +if (ACPI_FAILURE (status)) { +ACPI_ERROR ((AE_INFO ,"Evaluating _BCM failed" )); +return -EIO ; + } + device->brightness->curr = level;for (state =2 ; state < device->brightness->count; state++) -if (level == device->brightness->levels[state]) +if (level == device->brightness->levels[state]) { device->backlight->props.brightness = state -2 ; +return 0 ; + } -return status; +ACPI_ERROR ((AE_INFO ,"Current brightness invalid" )); +return -EINVAL ; } static int
@@ -1082,13 +1088,12 @@ acpi_video_device_write_brightness(struct file *file,/* validate through the list of available levels */ for (i =2 ; i < dev->brightness->count; i++)if (level == dev->brightness->levels[i]) { -if (ACPI_SUCCESS - (acpi_video_device_lcd_set_level (dev, level))) - dev->brightness->curr = level; +if (!acpi_video_device_lcd_set_level (dev, level)) +return count;break ; } -return count; +return -EINVAL ; }static int acpi_video_device_EDID_seq_show (struct seq_file *seq,void *offset)
@@ -1786,7 +1791,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) level_next =acpi_video_get_next_level (device, level_current, event); -acpi_video_device_lcd_set_level (device, level_next); + result =acpi_video_device_lcd_set_level (device, level_next); out:if (result)
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 90/98 ACPI video: support _BCL packages that don't export brightness levels when machine is on AC/Battery
In reply to Len BrownFrom: Zhang Rui <[email protected]>
Many buggy BIOSes don't export the brightness levels when machine is on AC/Battery in the _BCL method.
Reformat the _BCL package for these laptops:
now the elements in device->brightness->levels[] are like:
levels[0]: brightness level when on AC power. levels[1]: brightness level when on Battery power. levels[2]: supported brightness level 1.
levels[3]: supported brightness level 2.
...
levels[n]: supported brightness level n-1.
levels[n + 1]: supported brightness level n.
So if there are n supported brightness levels on this laptop, we will have n+2 entries in device->brightnes->levels[].
level[0] and level[1] are invalid on the laptops that don't export the brightness levels on AC/Battery. Fortunately, we never use these two values at all, even for the valid ones.
http://bugzilla.kernel.org/show_bug.cgi?id=12249
--- drivers/acpi/video.c | 37 ++++++++++++++++++++++++++++++------- 1 files changed, 30 insertions(+), 7 deletions(-)
drivers/acpi/video.c +30 -7
@@ -168,10 +168,15 @@ struct acpi_video_device_cap { u8 _DSS:1; /*Device state set */ }; +struct acpi_video_brightness_flags { +u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ +}; +struct acpi_video_device_brightness {int curr;int count;int *levels; +struct acpi_video_brightness_flags flags; };struct acpi_video_device {
@@ -682,7 +687,7 @@ static int acpi_video_init_brightness(struct acpi_video_device *device) {union acpi_object *obj =NULL ; -int i, max_level =0 , count =0 ; +int i, max_level =0 , count =0 , level_ac_battery =0 ;union acpi_object *o;struct acpi_video_device_brightness *br =NULL ;
@@ -701,7 +706,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) goto out; } - br->levels =kmalloc (obj->package.count *sizeof *(br->levels), + br->levels =kmalloc ((obj->package.count +2 ) *sizeof *(br->levels),GFP_KERNEL );if (!br->levels) goto out_free;
@@ -719,16 +724,34 @@ acpi_video_init_brightness(struct acpi_video_device *device) count++; } -/* don't sort the first two brightness levels */ +/* +* some buggy BIOS don't export the levels +* when machine is on AC/Battery in _BCL package. +* In this case, the first two elements in _BCL packages +* are also supported brightness levels that OS should take care of. +*/ +for (i =2 ; i < count; i++) +if (br->levels[i] == br->levels[0 ] || + br->levels[i] == br->levels[1 ]) + level_ac_battery++; + +if (level_ac_battery <2 ) { + level_ac_battery =2 - level_ac_battery; + br->flags._BCL_no_ac_battery_levels =1 ; +for (i = (count -1 + level_ac_battery); i >=2 ; i--) + br->levels[i] = br->levels[i - level_ac_battery]; + count += level_ac_battery; + }else if (level_ac_battery >2 ) +ACPI_ERROR ((AE_INFO ,"Too many duplicates in _BCL package\n" )); + +/* sort all the supported brightness levels */ sort (&br->levels[2 ], count -2 ,sizeof (br->levels[2 ]), acpi_video_cmp_level,NULL ); -if (count <2 ) - goto out_free_levels; - br->count = count; device->brightness = br; -ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"found %d brightness levels\n" , count)); +ACPI_DEBUG_PRINT ((ACPI_DB_INFO , +"found %d brightness levels\n" , count -2 ));kfree (obj);return max_level;
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 91/98 ACPI video: support reversed _BCL method in ACPI video driver
In reply to Len BrownFrom: Zhang Rui <[email protected]>
The brightness levels returned by _BCL package are in a reversed order on some laptops.
http://bugzilla.kernel.org/show_bug.cgi?id=12037
http://bugzilla.kernel.org/show_bug.cgi?id=12302
http://bugzilla.kernel.org/show_bug.cgi?id=12235
sort the _BCL packge in case it's reversed.
--- drivers/acpi/video.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/acpi/video.c +9 -3
@@ -170,6 +170,7 @@ struct acpi_video_device_cap {struct acpi_video_brightness_flags {u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ +u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order*/ };struct acpi_video_device_brightness {
@@ -744,9 +745,14 @@ acpi_video_init_brightness(struct acpi_video_device *device) }else if (level_ac_battery >2 )ACPI_ERROR ((AE_INFO ,"Too many duplicates in _BCL package\n" )); -/* sort all the supported brightness levels */ -sort (&br->levels[2 ], count -2 ,sizeof (br->levels[2 ]), - acpi_video_cmp_level,NULL ); +/* Check if the _BCL package is in a reversed order */ +if (max_level == br->levels[2 ]) { + br->flags._BCL_reversed =1 ; +sort (&br->levels[2 ], count -2 ,sizeof (br->levels[2 ]), + acpi_video_cmp_level,NULL ); + }else if (max_level != br->levels[count -1 ]) +ACPI_ERROR ((AE_INFO , +"Found unordered _BCL package\n" )); br->count = count; device->brightness = br;
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 92/98 ACPI video: support _BQC/_BCL/_BCM methods that use index values
In reply to Len BrownFrom: Zhang Rui <[email protected]>
The input/output of _BQC/_BCL/_BCM control methods should be represented by a number between 0 and 100, and can be thought of as a percentage. But some buggy _BQC/_BCL/_BCM methods use the index values instead.
http://bugzilla.kernel.org/show_bug.cgi?id=12302
http://bugzilla.kernel.org/show_bug.cgi?id=12249
http://bugzilla.kernel.org/show_bug.cgi?id=12037
Add the functionality to support such kind of BIOSes in ACPI video driver.
--- drivers/acpi/video.c | 91 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 70 insertions(+), 21 deletions(-)
drivers/acpi/video.c +70 -21
@@ -171,6 +171,9 @@ struct acpi_video_device_cap {struct acpi_video_brightness_flags {u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order*/ +u8 _BCL_use_index:1 ;/* levels in _BCL are index values */ +u8 _BCM_use_index:1 ;/* input of _BCM is an index value */ +u8 _BQC_use_index:1 ;/* _BQC returns an index value */ };struct acpi_video_device_brightness {
@@ -505,7 +508,8 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) device->brightness->curr = level;for (state =2 ; state < device->brightness->count; state++)if (level == device->brightness->levels[state]) { - device->backlight->props.brightness = state -2 ; +if (device->backlight) + device->backlight->props.brightness = state -2 ;return 0 ; }
@@ -523,6 +527,13 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, status =acpi_evaluate_integer (device->dev->handle,"_BQC" ,NULL , level);if (ACPI_SUCCESS (status)) { +if (device->brightness->flags._BQC_use_index) { +if (device->brightness->flags._BCL_reversed) + *level = device->brightness->count + -3 - (*level); + *level = device->brightness->levels[*level +2 ]; + + } device->brightness->curr = *level;return 0 ; }else {
@@ -689,8 +700,10 @@ acpi_video_init_brightness(struct acpi_video_device *device) {union acpi_object *obj =NULL ;int i, max_level =0 , count =0 , level_ac_battery =0 ; +unsigned long long level, level_old;union acpi_object *o;struct acpi_video_device_brightness *br =NULL ; +int result = -EINVAL ;if (!ACPI_SUCCESS (acpi_video_device_lcd_query_levels (device, &obj))) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
@@ -704,13 +717,16 @@ acpi_video_init_brightness(struct acpi_video_device *device) br =kzalloc (sizeof (*br),GFP_KERNEL );if (!br) {printk (KERN_ERR "can't allocate memory\n" ); + result = -ENOMEM ; goto out; } br->levels =kmalloc ((obj->package.count +2 ) *sizeof *(br->levels),GFP_KERNEL ); -if (!br->levels) +if (!br->levels) { + result = -ENOMEM ; goto out_free; + }for (i =0 ; i < obj->package.count; i++) { o = (union acpi_object *)&obj->package.elements[i];
@@ -756,10 +772,55 @@ acpi_video_init_brightness(struct acpi_video_device *device) br->count = count; device->brightness = br; + +/* Check the input/output of _BQC/_BCL/_BCM */ +if ((max_level <100 ) && (max_level <= (count -2 ))) + br->flags._BCL_use_index =1 ; + +/* +* _BCM is always consistent with _BCL, +* at least for all the laptops we have ever seen. +*/ + br->flags._BCM_use_index = br->flags._BCL_use_index; + +/* _BQC uses INDEX while _BCL uses VALUE in some laptops */ + br->curr = max_level; + result =acpi_video_device_lcd_get_level_current (device, &level_old); +if (result) + goto out_free_levels; + + result =acpi_video_device_lcd_set_level (device, br->curr); +if (result) + goto out_free_levels; + + result =acpi_video_device_lcd_get_level_current (device, &level); +if (result) + goto out_free_levels; + +if ((level != level_old) && !br->flags._BCM_use_index) { +/* Note: +* This piece of code does not work correctly if the current +* brightness levels is 0. +* But I guess boxes that boot with such a dark screen are rare +* and no more code is needed to cover this specifial case. +*/ + +if (level_ac_battery !=2 ) { +/* +* For now, we don't support the _BCL like this: +* 16, 15, 0, 1, 2, 3, ..., 14, 15, 16 +* because we may mess up the index returned by _BQC. +* Plus: we have not got a box like this. +*/ +ACPI_ERROR ((AE_INFO ,"_BCL not supported\n" )); + } + br->flags._BQC_use_index =1 ; + } +ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"found %d brightness levels\n" , count -2 ));kfree (obj); -return max_level; +return result; out_free_levels:kfree (br->levels);
@@ -768,7 +829,7 @@ out_free: out: device->brightness =NULL ;kfree (obj); -return 0 ; +return result; }/*
@@ -785,7 +846,6 @@ out:static void acpi_video_device_find_cap (struct acpi_video_device *device) {acpi_handle h_dummy1; -u32 max_level =0 ;memset (&device->cap,0 ,sizeof (device->cap));
@@ -814,13 +874,14 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) device->cap._DSS =1 ; } -if (acpi_video_backlight_support ()) - max_level =acpi_video_init_brightness (device); - -if (device->cap._BCL && device->cap._BCM && max_level >0 ) { +if (acpi_video_backlight_support ()) {int result;static int count =0 ;char *name; + + result =acpi_video_init_brightness (device); +if (result) +return ; name =kzalloc (MAX_NAME_LEN ,GFP_KERNEL );if (!name)return ;
@@ -829,18 +890,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) device->backlight =backlight_device_register (name,NULL , device, &acpi_backlight_ops); device->backlight->props.max_brightness = device->brightness->count-3 ; -/* -* If there exists the _BQC object, the _BQC object will be -* called to get the current backlight brightness. Otherwise -* the brightness will be set to the maximum. -*/ -if (device->cap._BQC) - device->backlight->props.brightness = -acpi_video_get_brightness (device->backlight); -else - device->backlight->props.brightness = - device->backlight->props.max_brightness; -backlight_update_status (device->backlight);kfree (name); device->cdev = thermal_cooling_device_register("LCD",
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 93/98 ACPI video: support buggy BIOSes with _BCQ implemented
In reply to Len BrownFrom: Zhang Rui <[email protected]>
Some buggy BIOSes implements _BCQ instead of _BQC. Male ACPI video driver support these buggy BIOS.
--- drivers/acpi/video.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-)
drivers/acpi/video.c +13 -4
@@ -162,6 +162,7 @@ struct acpi_video_device_cap { u8 _BCL:1; /*Query list of brightness control levels supported */ u8 _BCM:1; /*Set the brightness level */ u8 _BQC:1; /* Get current brightness level */ + u8 _BCQ:1; /* Some buggy BIOS uses _BCQ instead of _BQC */ u8 _DDC:1; /*Return the EDID for this device */ u8 _DCS:1; /*Return status of output device */ u8 _DGS:1; /*Query graphics state */
@@ -523,8 +524,10 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, {acpi_status status =AE_OK ; -if (device->cap._BQC) { - status =acpi_evaluate_integer (device->dev->handle,"_BQC" , +if (device->cap._BQC || device->cap._BCQ) { +char *buf = device->cap._BQC ?"_BQC" :"_BCQ" ; + + status =acpi_evaluate_integer (device->dev->handle, buf,NULL , level);if (ACPI_SUCCESS (status)) {if (device->brightness->flags._BQC_use_index) {
@@ -544,8 +547,8 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,* ACPI video backlight still works w/ buggy _BQC. * http://bugzilla.kernel.org/show_bug.cgi?id=12233 */ -ACPI_WARNING ((AE_INFO ,"Evaluating _BQC failed" )); - device->cap._BQC =0 ; +ACPI_WARNING ((AE_INFO ,"Evaluating %s failed" , buf)); + device->cap._BQC = device->cap._BCQ =0 ; } }
@@ -861,6 +864,12 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) }if (ACPI_SUCCESS (acpi_get_handle (device->dev->handle,"_BQC" ,&h_dummy1))) device->cap._BQC =1 ; +else if (ACPI_SUCCESS (acpi_get_handle (device->dev->handle,"_BCQ" , + &h_dummy1))) { + printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n"); + device->cap._BCQ =1 ; + } +if (ACPI_SUCCESS (acpi_get_handle (device->dev->handle,"_DDC" , &h_dummy1))) { device->cap._DDC =1 ; }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 94/98 ACPI: Populate DIDL before registering ACPI video device on Intel
In reply to Len BrownFrom: Matthew Garrett <[email protected]>
Intel graphics hardware that implements the ACPI IGD OpRegion spec requires that the list of display devices be populated before any ACPI video methods are called. Detect when this is the case and defer registration until the opregion code calls it. Fixes crashes on HP laptops.
http://bugzilla.kernel.org/show_bug.cgi?id=11259
--- drivers/acpi/video.c | 40 ++++++++++++++++++++- drivers/gpu/drm/i915/i915_dma.c | 5 ++- drivers/gpu/drm/i915/i915_drv.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_opregion.c | 65 +++++++++++++++++++++++++++++++++- include/acpi/video.h | 11 ++++++ 6 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 include/acpi/video.h
drivers/acpi/video.c +39 -1
@@ -37,6 +37,8 @@#include <linux/thermal.h> #include <linux/video_output.h> #include <linux/sort.h> +#include <linux/pci.h> +#include <linux/pci_ids.h> #include <asm/uaccess.h> #include <acpi/acpi_bus.h>
@@ -2251,7 +2253,27 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)return 0 ; } -static int __init acpi_video_init (void ) +static int __init intel_opregion_present (void ) +{ +#if defined(CONFIG_DRM_I915 ) || defined(CONFIG_DRM_I915_MODULE ) +struct pci_dev *dev =NULL ; +u32 address; + +for_each_pci_dev (dev) { +if ((dev->class >>8 ) !=PCI_CLASS_DISPLAY_VGA ) +continue ; +if (dev->vendor !=PCI_VENDOR_ID_INTEL ) +continue ; +pci_read_config_dword (dev,0xfc , &address); +if (!address) +continue ; +return 1 ; + } +#endif +return 0 ; +} + +int acpi_video_register (void ) {int result =0 ;
@@ -2268,6 +2290,22 @@ static int __init acpi_video_init(void)return 0 ; } +EXPORT_SYMBOL (acpi_video_register); + +/* +* This is kind of nasty. Hardware using Intel chipsets may require +* the video opregion code to be run first in order to initialise +* state before any ACPI video calls are made. To handle this we defer +* registration of the video class until the opregion code has run. +*/ + +static int __init acpi_video_init (void ) +{ +if (intel_opregion_present ()) +return 0 ; + +return acpi_video_register (); +} static void __exit acpi_video_exit(void) {
drivers/gpu/drm/i915/i915_dma.c +3 -2
@@ -1144,8 +1144,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)if (!IS_I945G (dev) && !IS_I945GM (dev))pci_enable_msi (dev->pdev); -intel_opregion_init (dev); -spin_lock_init (&dev_priv->user_irq_lock); dev_priv->user_irq_refcount =0 ;
@@ -1164,6 +1162,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) } } +/* Must be done after probing outputs */ +intel_opregion_init (dev,0 ); +return 0 ; out_iomapfree:
drivers/gpu/drm/i915/i915_drv.c +1 -1
@@ -99,7 +99,7 @@ static int i915_resume(struct drm_device *dev)i915_restore_state (dev); -intel_opregion_init (dev); +intel_opregion_init (dev,1 );/* KMS EnterVT equivalent */ if (drm_core_check_feature (dev,DRIVER_MODESET )) {
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -659,7 +659,7 @@ extern int i915_restore_state(struct drm_device *dev);#ifdef CONFIG_ACPI /* i915_opregion.c */ -extern int intel_opregion_init (struct drm_device *dev); +extern int intel_opregion_init (struct drm_device *dev,int resume);extern void intel_opregion_free (struct drm_device *dev);extern void opregion_asle_intr (struct drm_device *dev);extern void opregion_enable_asle (struct drm_device *dev);
drivers/gpu/drm/i915/i915_opregion.c +64 -1
89 lines not on this page · raw message
include/acpi/video.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef __ACPI_VIDEO_H +#define __ACPI_VIDEO_H + +#if (definedCONFIG_ACPI_VIDEO || definedCONFIG_ACPI_VIDEO_MODULE ) +extern int acpi_video_register (void ); +#else +static inline int acpi_video_register (void ) {return 0 ; } +#endif + +#endif +
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 95/98 ACPI: suspend: Add the Pansonic CF51 box to the dmi check table
In reply to Len BrownFrom: Zhao Yakui <[email protected]>
The Pansonic CF51-2L box can't be resumed if the boot option of "acpi_sleep=old_ordering" is not added.
Add the Pansonic CF51-2L to the dmi check table so that the old suspend order is used.
http://bugzilla.kernel.org/show_bug.cgi?id=12561
--- drivers/acpi/sleep.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
drivers/acpi/sleep.c +18 -0
@@ -394,6 +394,24 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"), }, }, + { + .callback = init_old_suspend_ordering, + .ident = "Pansonic CF51-2L", + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR , +"Matsushita Electric Industrial Co.,Ltd." ), + DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), + }, + }, + { + .callback = init_old_suspend_ordering, + .ident = "Pansonic CF51-2L", + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR , +"Matsushita Electric Industrial Co.,Ltd." ), + DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), + }, + }, {}, };#endif /* CONFIG_SUSPEND */
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 96/98 ACPI: battery: add power_{now,avg} properties to power_class
In reply to Len BrownFrom: Alexey Starikovskiy <[email protected]>
ACPI has smart batteries, which work in units of energy and measure rate of (dis)charge as power, thus it is not appropriate to export it as a current_now. Current_now will still be exported to allow for userland applications to match.
--- drivers/acpi/battery.c | 12 +++++++----- drivers/acpi/sbs.c | 27 ++++++++++++++++----------- drivers/power/power_supply_sysfs.c | 2 ++ include/linux/power_supply.h | 2 ++ 4 files changed, 27 insertions(+), 16 deletions(-)
drivers/acpi/battery.c +7 -5
@@ -92,7 +92,7 @@ struct acpi_battery {#endif struct acpi_device *device;unsigned long update_time; -int current_now; +int rate_now;int capacity_now;int voltage_now;int design_capacity;
@@ -196,7 +196,8 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = battery->voltage_now *1000 ;break ;case POWER_SUPPLY_PROP_CURRENT_NOW : - val->intval = battery->current_now *1000 ; +case POWER_SUPPLY_PROP_POWER_NOW : + val->intval = battery->rate_now *1000 ;break ;case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN :case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN :
@@ -247,6 +248,7 @@ static enum power_supply_property energy_battery_props[] = {POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN ,POWER_SUPPLY_PROP_VOLTAGE_NOW ,POWER_SUPPLY_PROP_CURRENT_NOW , +POWER_SUPPLY_PROP_POWER_NOW ,POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN ,POWER_SUPPLY_PROP_ENERGY_FULL , POWER_SUPPLY_PROP_ENERGY_NOW,
@@ -273,7 +275,7 @@ struct acpi_offsets {static struct acpi_offsets state_offsets[] = { {offsetof(struct acpi_battery , state),0 }, - {offsetof(struct acpi_battery , current_now),0 }, + {offsetof(struct acpi_battery , rate_now),0 }, {offsetof(struct acpi_battery , capacity_now),0 }, {offsetof(struct acpi_battery , voltage_now),0 }, };
@@ -605,11 +607,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)else seq_printf (seq,"charging state: charged\n" ); -if (battery->current_now ==ACPI_BATTERY_VALUE_UNKNOWN ) +if (battery->rate_now ==ACPI_BATTERY_VALUE_UNKNOWN )seq_printf (seq,"present rate: unknown\n" );else seq_printf (seq,"present rate: %d %s\n" , - battery->current_now,acpi_battery_units (battery)); + battery->rate_now,acpi_battery_units (battery));if (battery->capacity_now ==ACPI_BATTERY_VALUE_UNKNOWN )seq_printf (seq,"remaining capacity: unknown\n" );
drivers/acpi/sbs.c +16 -11
@@ -102,8 +102,8 @@ struct acpi_battery {u16 cycle_count;u16 temp_now;u16 voltage_now; -s16 current_now; -s16 current_avg; +s16 rate_now; +s16 rate_avg;u16 capacity_now;u16 state_of_charge;u16 state;
@@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,return -ENODEV ;switch (psp) {case POWER_SUPPLY_PROP_STATUS : -if (battery->current_now <0 ) +if (battery->rate_now <0 ) val->intval =POWER_SUPPLY_STATUS_DISCHARGING ; -else if (battery->current_now >0 ) +else if (battery->rate_now >0 ) val->intval =POWER_SUPPLY_STATUS_CHARGING ;else val->intval =POWER_SUPPLY_STATUS_FULL ;
@@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,acpi_battery_vscale (battery) *1000 ;break ;case POWER_SUPPLY_PROP_CURRENT_NOW : - val->intval =abs (battery->current_now) * +case POWER_SUPPLY_PROP_POWER_NOW : + val->intval =abs (battery->rate_now) *acpi_battery_ipscale (battery) *1000 ;break ;case POWER_SUPPLY_PROP_CURRENT_AVG : - val->intval =abs (battery->current_avg) * +case POWER_SUPPLY_PROP_POWER_AVG : + val->intval =abs (battery->rate_avg) *acpi_battery_ipscale (battery) *1000 ;break ;case POWER_SUPPLY_PROP_CAPACITY :
@@ -293,6 +295,8 @@ static enum power_supply_property sbs_energy_battery_props[] = {POWER_SUPPLY_PROP_VOLTAGE_NOW ,POWER_SUPPLY_PROP_CURRENT_NOW ,POWER_SUPPLY_PROP_CURRENT_AVG , +POWER_SUPPLY_PROP_POWER_NOW , +POWER_SUPPLY_PROP_POWER_AVG ,POWER_SUPPLY_PROP_CAPACITY ,POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN , POWER_SUPPLY_PROP_ENERGY_FULL,
@@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {POWER_SUPPLY_PROP_MODEL_NAME , POWER_SUPPLY_PROP_MANUFACTURER, }; +#endif /* --------------------------------------------------------------------------
@@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {static struct acpi_battery_reader state_readers[] = { {0x08 ,SMBUS_READ_WORD , offsetof(struct acpi_battery , temp_now)}, {0x09 ,SMBUS_READ_WORD , offsetof(struct acpi_battery , voltage_now)}, - {0x0a ,SMBUS_READ_WORD , offsetof(struct acpi_battery , current_now)}, - {0x0b ,SMBUS_READ_WORD , offsetof(struct acpi_battery , current_avg)}, + {0x0a ,SMBUS_READ_WORD , offsetof(struct acpi_battery , rate_now)}, + {0x0b ,SMBUS_READ_WORD , offsetof(struct acpi_battery , rate_avg)}, {0x0f ,SMBUS_READ_WORD , offsetof(struct acpi_battery , capacity_now)}, {0x0e ,SMBUS_READ_WORD , offsetof(struct acpi_battery , state_of_charge)}, {0x16 ,SMBUS_READ_WORD , offsetof(struct acpi_battery , state)},
@@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)seq_printf (seq,"capacity state: %s\n" , (battery->state &0x0010 ) ?"critical" :"ok" );seq_printf (seq,"charging state: %s\n" , - (battery->current_now <0 ) ?"discharging" : - ((battery->current_now >0 ) ?"charging" :"charged" )); - rate =abs (battery->current_now) *acpi_battery_ipscale (battery); + (battery->rate_now <0 ) ?"discharging" : + ((battery->rate_now >0 ) ?"charging" :"charged" )); + rate =abs (battery->rate_now) *acpi_battery_ipscale (battery); rate *= (acpi_battery_mode (battery))?(battery->voltage_now *acpi_battery_vscale (battery)/1000 ):1 ; seq_printf(seq, "present rate: %d%s\n", rate,
drivers/power/power_supply_sysfs.c +2 -0
@@ -93,6 +93,8 @@ static struct device_attribute power_supply_attrs[] = {POWER_SUPPLY_ATTR (voltage_avg),POWER_SUPPLY_ATTR (current_now),POWER_SUPPLY_ATTR (current_avg), +POWER_SUPPLY_ATTR (power_now), +POWER_SUPPLY_ATTR (power_avg),POWER_SUPPLY_ATTR (charge_full_design),POWER_SUPPLY_ATTR (charge_empty_design), POWER_SUPPLY_ATTR(charge_full),
include/linux/power_supply.h +2 -0
@@ -73,6 +73,8 @@ enum power_supply_property {POWER_SUPPLY_PROP_VOLTAGE_AVG ,POWER_SUPPLY_PROP_CURRENT_NOW ,POWER_SUPPLY_PROP_CURRENT_AVG , +POWER_SUPPLY_PROP_POWER_NOW , +POWER_SUPPLY_PROP_POWER_AVG ,POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN ,POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN , POWER_SUPPLY_PROP_CHARGE_FULL,
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 97/98 ACPI video: add a warning message if _BQC is not found
In reply to Len BrownFrom: Zhang Rui <[email protected]>
ACPI backlight control w/o _BQC support is kinda firmware bug. Add a warning if _BQC is not implemented.
--- drivers/acpi/video_detect.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/acpi/video_detect.c +3 -0
@@ -55,6 +55,9 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Found generic backlight " "support\n" )); *cap |=ACPI_VIDEO_BACKLIGHT ; +if (ACPI_FAILURE (acpi_get_handle (handle,"_BQC" , &h_dummy))) + printk(KERN_WARNING FW_BUG PREFIX "ACPI brightness " +"control misses _BQC function\n" );/* We have backlight support, no need to scan further */ return AE_CTRL_TERMINATE ; }
Signature · 1 line
1.6.0.6
Len Brown
reviewerPATCH 98/98 ACPI: get_throttling_state() cannot be larger than state_count
In reply to Len Brown--- drivers/acpi/processor_throttling.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/acpi/processor_throttling.c +2 -4
@@ -783,11 +783,9 @@ static int acpi_get_throttling_state(struct acpi_processor *pr, (struct acpi_processor_tx_tss *)&(pr->throttling. states_tss[i]);if (tx->control == value) -break ; +return i; } -if (i > pr->throttling.state_count) - i =-1 ; -return i; +return -1 ; } static int acpi_get_throttling_value(struct acpi_processor *pr,
Signature · 1 line
1.6.0.6