diff options
author | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
commit | 6c9468e9eb1252eaefd94ce7f06e1be9b0b641b1 (patch) | |
tree | 797676a336b050bfa1ef879377c07e541b9075d6 /drivers/acpi | |
parent | 4cb3ca7cd7e2cae8d1daf5345ec99a1e8502cf3f (diff) | |
parent | c81eddb0e3728661d1585fbc564449c94165cc36 (diff) |
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/acpi')
39 files changed, 1496 insertions, 1352 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 66cc3f36a954..a8d8998dd5c5 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -32,7 +32,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o | |||
32 | # | 32 | # |
33 | acpi-y += bus.o glue.o | 33 | acpi-y += bus.o glue.o |
34 | acpi-y += scan.o | 34 | acpi-y += scan.o |
35 | acpi-y += processor_pdc.o | 35 | acpi-y += processor_core.o |
36 | acpi-y += ec.o | 36 | acpi-y += ec.o |
37 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 37 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
38 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 38 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
@@ -61,7 +61,7 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o | |||
61 | obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o | 61 | obj-$(CONFIG_ACPI_POWER_METER) += power_meter.o |
62 | 62 | ||
63 | # processor has its own "processor." module_param namespace | 63 | # processor has its own "processor." module_param namespace |
64 | processor-y := processor_core.o processor_throttling.o | 64 | processor-y := processor_driver.o processor_throttling.o |
65 | processor-y += processor_idle.o processor_thermal.o | 65 | processor-y += processor_idle.o processor_thermal.o |
66 | processor-$(CONFIG_CPU_FREQ) += processor_perflib.o | 66 | processor-$(CONFIG_CPU_FREQ) += processor_perflib.o |
67 | 67 | ||
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index b6ed60b57b0d..56205a0b85df 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
29 | #include <linux/types.h> | 30 | #include <linux/types.h> |
30 | #ifdef CONFIG_ACPI_PROCFS_POWER | 31 | #ifdef CONFIG_ACPI_PROCFS_POWER |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 3597d73f28f6..d98571385656 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/memory_hotplug.h> | 32 | #include <linux/memory_hotplug.h> |
33 | #include <linux/slab.h> | ||
33 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
34 | 35 | ||
35 | #define ACPI_MEMORY_DEVICE_CLASS "memory" | 36 | #define ACPI_MEMORY_DEVICE_CLASS "memory" |
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 7e52295f1ecc..19dacfd43163 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/freezer.h> | 27 | #include <linux/freezer.h> |
28 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
29 | #include <linux/clockchips.h> | 29 | #include <linux/clockchips.h> |
30 | #include <linux/slab.h> | ||
30 | #include <acpi/acpi_bus.h> | 31 | #include <acpi/acpi_bus.h> |
31 | #include <acpi/acpi_drivers.h> | 32 | #include <acpi/acpi_drivers.h> |
32 | 33 | ||
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index 837de669743a..78c55508aff5 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -117,19 +117,14 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) | |||
117 | if (ACPI_FAILURE(status)) | 117 | if (ACPI_FAILURE(status)) |
118 | return_ACPI_STATUS(status); | 118 | return_ACPI_STATUS(status); |
119 | 119 | ||
120 | /* Mark wake-enabled or HW enable, or both */ | 120 | /* Clear the GPE (of stale events), then enable it */ |
121 | 121 | status = acpi_hw_clear_gpe(gpe_event_info); | |
122 | if (gpe_event_info->runtime_count) { | 122 | if (ACPI_FAILURE(status)) |
123 | /* Clear the GPE (of stale events), then enable it */ | 123 | return_ACPI_STATUS(status); |
124 | status = acpi_hw_clear_gpe(gpe_event_info); | ||
125 | if (ACPI_FAILURE(status)) | ||
126 | return_ACPI_STATUS(status); | ||
127 | |||
128 | /* Enable the requested runtime GPE */ | ||
129 | status = acpi_hw_write_gpe_enable_reg(gpe_event_info); | ||
130 | } | ||
131 | 124 | ||
132 | return_ACPI_STATUS(AE_OK); | 125 | /* Enable the requested GPE */ |
126 | status = acpi_hw_write_gpe_enable_reg(gpe_event_info); | ||
127 | return_ACPI_STATUS(status); | ||
133 | } | 128 | } |
134 | 129 | ||
135 | /******************************************************************************* | 130 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c index cc8a10268f68..7116bc86494d 100644 --- a/drivers/acpi/acpica/exmutex.c +++ b/drivers/acpi/acpica/exmutex.c | |||
@@ -375,8 +375,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
375 | return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); | 375 | return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); |
376 | } | 376 | } |
377 | 377 | ||
378 | /* Must have a valid thread ID */ | 378 | /* Must have a valid thread. */ |
379 | |||
380 | if (!walk_state->thread) { | 379 | if (!walk_state->thread) { |
381 | ACPI_ERROR((AE_INFO, | 380 | ACPI_ERROR((AE_INFO, |
382 | "Cannot release Mutex [%4.4s], null thread info", | 381 | "Cannot release Mutex [%4.4s], null thread info", |
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c index edf62bf5b266..2fbfe51fb141 100644 --- a/drivers/acpi/acpica/exprep.c +++ b/drivers/acpi/acpica/exprep.c | |||
@@ -468,6 +468,23 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) | |||
468 | 468 | ||
469 | acpi_ut_add_reference(obj_desc->field.region_obj); | 469 | acpi_ut_add_reference(obj_desc->field.region_obj); |
470 | 470 | ||
471 | /* allow full data read from EC address space */ | ||
472 | if (obj_desc->field.region_obj->region.space_id == | ||
473 | ACPI_ADR_SPACE_EC) { | ||
474 | if (obj_desc->common_field.bit_length > 8) { | ||
475 | unsigned width = | ||
476 | ACPI_ROUND_BITS_UP_TO_BYTES( | ||
477 | obj_desc->common_field.bit_length); | ||
478 | // access_bit_width is u8, don't overflow it | ||
479 | if (width > 8) | ||
480 | width = 8; | ||
481 | obj_desc->common_field.access_byte_width = | ||
482 | width; | ||
483 | obj_desc->common_field.access_bit_width = | ||
484 | 8 * width; | ||
485 | } | ||
486 | } | ||
487 | |||
471 | ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, | 488 | ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, |
472 | "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", | 489 | "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", |
473 | obj_desc->field.start_field_bit_offset, | 490 | obj_desc->field.start_field_bit_offset, |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 58d2c91ba62b..3026e3fa83ef 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | #include <linux/async.h> | 33 | #include <linux/async.h> |
34 | #include <linux/dmi.h> | 34 | #include <linux/dmi.h> |
35 | #include <linux/slab.h> | ||
35 | 36 | ||
36 | #ifdef CONFIG_ACPI_PROCFS_POWER | 37 | #ifdef CONFIG_ACPI_PROCFS_POWER |
37 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
@@ -54,6 +55,7 @@ | |||
54 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 55 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
55 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | 56 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 |
56 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 | 57 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 |
58 | #define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82 | ||
57 | 59 | ||
58 | #define _COMPONENT ACPI_BATTERY_COMPONENT | 60 | #define _COMPONENT ACPI_BATTERY_COMPONENT |
59 | 61 | ||
@@ -88,10 +90,15 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
88 | 90 | ||
89 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 91 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
90 | 92 | ||
91 | /* For buggy DSDTs that report negative 16-bit values for either charging | 93 | enum { |
92 | * or discharging current and/or report 0 as 65536 due to bad math. | 94 | ACPI_BATTERY_ALARM_PRESENT, |
93 | */ | 95 | ACPI_BATTERY_XINFO_PRESENT, |
94 | #define QUIRK_SIGNED16_CURRENT 0x0001 | 96 | /* For buggy DSDTs that report negative 16-bit values for either |
97 | * charging or discharging current and/or report 0 as 65536 | ||
98 | * due to bad math. | ||
99 | */ | ||
100 | ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, | ||
101 | }; | ||
95 | 102 | ||
96 | struct acpi_battery { | 103 | struct acpi_battery { |
97 | struct mutex lock; | 104 | struct mutex lock; |
@@ -109,6 +116,12 @@ struct acpi_battery { | |||
109 | int design_voltage; | 116 | int design_voltage; |
110 | int design_capacity_warning; | 117 | int design_capacity_warning; |
111 | int design_capacity_low; | 118 | int design_capacity_low; |
119 | int cycle_count; | ||
120 | int measurement_accuracy; | ||
121 | int max_sampling_time; | ||
122 | int min_sampling_time; | ||
123 | int max_averaging_interval; | ||
124 | int min_averaging_interval; | ||
112 | int capacity_granularity_1; | 125 | int capacity_granularity_1; |
113 | int capacity_granularity_2; | 126 | int capacity_granularity_2; |
114 | int alarm; | 127 | int alarm; |
@@ -118,8 +131,7 @@ struct acpi_battery { | |||
118 | char oem_info[32]; | 131 | char oem_info[32]; |
119 | int state; | 132 | int state; |
120 | int power_unit; | 133 | int power_unit; |
121 | u8 alarm_present; | 134 | unsigned long flags; |
122 | long quirks; | ||
123 | }; | 135 | }; |
124 | 136 | ||
125 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 137 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -198,6 +210,9 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
198 | case POWER_SUPPLY_PROP_TECHNOLOGY: | 210 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
199 | val->intval = acpi_battery_technology(battery); | 211 | val->intval = acpi_battery_technology(battery); |
200 | break; | 212 | break; |
213 | case POWER_SUPPLY_PROP_CYCLE_COUNT: | ||
214 | val->intval = battery->cycle_count; | ||
215 | break; | ||
201 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | 216 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
202 | val->intval = battery->design_voltage * 1000; | 217 | val->intval = battery->design_voltage * 1000; |
203 | break; | 218 | break; |
@@ -239,6 +254,7 @@ static enum power_supply_property charge_battery_props[] = { | |||
239 | POWER_SUPPLY_PROP_STATUS, | 254 | POWER_SUPPLY_PROP_STATUS, |
240 | POWER_SUPPLY_PROP_PRESENT, | 255 | POWER_SUPPLY_PROP_PRESENT, |
241 | POWER_SUPPLY_PROP_TECHNOLOGY, | 256 | POWER_SUPPLY_PROP_TECHNOLOGY, |
257 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
242 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 258 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
243 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 259 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
244 | POWER_SUPPLY_PROP_CURRENT_NOW, | 260 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -254,6 +270,7 @@ static enum power_supply_property energy_battery_props[] = { | |||
254 | POWER_SUPPLY_PROP_STATUS, | 270 | POWER_SUPPLY_PROP_STATUS, |
255 | POWER_SUPPLY_PROP_PRESENT, | 271 | POWER_SUPPLY_PROP_PRESENT, |
256 | POWER_SUPPLY_PROP_TECHNOLOGY, | 272 | POWER_SUPPLY_PROP_TECHNOLOGY, |
273 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
257 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 274 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
258 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 275 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
259 | POWER_SUPPLY_PROP_CURRENT_NOW, | 276 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -305,6 +322,28 @@ static struct acpi_offsets info_offsets[] = { | |||
305 | {offsetof(struct acpi_battery, oem_info), 1}, | 322 | {offsetof(struct acpi_battery, oem_info), 1}, |
306 | }; | 323 | }; |
307 | 324 | ||
325 | static struct acpi_offsets extended_info_offsets[] = { | ||
326 | {offsetof(struct acpi_battery, power_unit), 0}, | ||
327 | {offsetof(struct acpi_battery, design_capacity), 0}, | ||
328 | {offsetof(struct acpi_battery, full_charge_capacity), 0}, | ||
329 | {offsetof(struct acpi_battery, technology), 0}, | ||
330 | {offsetof(struct acpi_battery, design_voltage), 0}, | ||
331 | {offsetof(struct acpi_battery, design_capacity_warning), 0}, | ||
332 | {offsetof(struct acpi_battery, design_capacity_low), 0}, | ||
333 | {offsetof(struct acpi_battery, cycle_count), 0}, | ||
334 | {offsetof(struct acpi_battery, measurement_accuracy), 0}, | ||
335 | {offsetof(struct acpi_battery, max_sampling_time), 0}, | ||
336 | {offsetof(struct acpi_battery, min_sampling_time), 0}, | ||
337 | {offsetof(struct acpi_battery, max_averaging_interval), 0}, | ||
338 | {offsetof(struct acpi_battery, min_averaging_interval), 0}, | ||
339 | {offsetof(struct acpi_battery, capacity_granularity_1), 0}, | ||
340 | {offsetof(struct acpi_battery, capacity_granularity_2), 0}, | ||
341 | {offsetof(struct acpi_battery, model_number), 1}, | ||
342 | {offsetof(struct acpi_battery, serial_number), 1}, | ||
343 | {offsetof(struct acpi_battery, type), 1}, | ||
344 | {offsetof(struct acpi_battery, oem_info), 1}, | ||
345 | }; | ||
346 | |||
308 | static int extract_package(struct acpi_battery *battery, | 347 | static int extract_package(struct acpi_battery *battery, |
309 | union acpi_object *package, | 348 | union acpi_object *package, |
310 | struct acpi_offsets *offsets, int num) | 349 | struct acpi_offsets *offsets, int num) |
@@ -350,22 +389,29 @@ static int acpi_battery_get_info(struct acpi_battery *battery) | |||
350 | { | 389 | { |
351 | int result = -EFAULT; | 390 | int result = -EFAULT; |
352 | acpi_status status = 0; | 391 | acpi_status status = 0; |
392 | char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)? | ||
393 | "_BIX" : "_BIF"; | ||
394 | |||
353 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 395 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
354 | 396 | ||
355 | if (!acpi_battery_present(battery)) | 397 | if (!acpi_battery_present(battery)) |
356 | return 0; | 398 | return 0; |
357 | mutex_lock(&battery->lock); | 399 | mutex_lock(&battery->lock); |
358 | status = acpi_evaluate_object(battery->device->handle, "_BIF", | 400 | status = acpi_evaluate_object(battery->device->handle, name, |
359 | NULL, &buffer); | 401 | NULL, &buffer); |
360 | mutex_unlock(&battery->lock); | 402 | mutex_unlock(&battery->lock); |
361 | 403 | ||
362 | if (ACPI_FAILURE(status)) { | 404 | if (ACPI_FAILURE(status)) { |
363 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); | 405 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); |
364 | return -ENODEV; | 406 | return -ENODEV; |
365 | } | 407 | } |
366 | 408 | if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | |
367 | result = extract_package(battery, buffer.pointer, | 409 | result = extract_package(battery, buffer.pointer, |
368 | info_offsets, ARRAY_SIZE(info_offsets)); | 410 | extended_info_offsets, |
411 | ARRAY_SIZE(extended_info_offsets)); | ||
412 | else | ||
413 | result = extract_package(battery, buffer.pointer, | ||
414 | info_offsets, ARRAY_SIZE(info_offsets)); | ||
369 | kfree(buffer.pointer); | 415 | kfree(buffer.pointer); |
370 | return result; | 416 | return result; |
371 | } | 417 | } |
@@ -399,7 +445,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
399 | battery->update_time = jiffies; | 445 | battery->update_time = jiffies; |
400 | kfree(buffer.pointer); | 446 | kfree(buffer.pointer); |
401 | 447 | ||
402 | if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && | 448 | if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) && |
403 | battery->rate_now != -1) | 449 | battery->rate_now != -1) |
404 | battery->rate_now = abs((s16)battery->rate_now); | 450 | battery->rate_now = abs((s16)battery->rate_now); |
405 | 451 | ||
@@ -412,7 +458,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) | |||
412 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; | 458 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; |
413 | struct acpi_object_list arg_list = { 1, &arg0 }; | 459 | struct acpi_object_list arg_list = { 1, &arg0 }; |
414 | 460 | ||
415 | if (!acpi_battery_present(battery)|| !battery->alarm_present) | 461 | if (!acpi_battery_present(battery) || |
462 | !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) | ||
416 | return -ENODEV; | 463 | return -ENODEV; |
417 | 464 | ||
418 | arg0.integer.value = battery->alarm; | 465 | arg0.integer.value = battery->alarm; |
@@ -437,10 +484,10 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) | |||
437 | /* See if alarms are supported, and if so, set default */ | 484 | /* See if alarms are supported, and if so, set default */ |
438 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); | 485 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); |
439 | if (ACPI_FAILURE(status)) { | 486 | if (ACPI_FAILURE(status)) { |
440 | battery->alarm_present = 0; | 487 | clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
441 | return 0; | 488 | return 0; |
442 | } | 489 | } |
443 | battery->alarm_present = 1; | 490 | set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
444 | if (!battery->alarm) | 491 | if (!battery->alarm) |
445 | battery->alarm = battery->design_capacity_warning; | 492 | battery->alarm = battery->design_capacity_warning; |
446 | return acpi_battery_set_alarm(battery); | 493 | return acpi_battery_set_alarm(battery); |
@@ -510,9 +557,8 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
510 | 557 | ||
511 | static void acpi_battery_quirks(struct acpi_battery *battery) | 558 | static void acpi_battery_quirks(struct acpi_battery *battery) |
512 | { | 559 | { |
513 | battery->quirks = 0; | ||
514 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { | 560 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { |
515 | battery->quirks |= QUIRK_SIGNED16_CURRENT; | 561 | set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags); |
516 | } | 562 | } |
517 | } | 563 | } |
518 | 564 | ||
@@ -522,13 +568,13 @@ static int acpi_battery_update(struct acpi_battery *battery) | |||
522 | result = acpi_battery_get_status(battery); | 568 | result = acpi_battery_get_status(battery); |
523 | if (result) | 569 | if (result) |
524 | return result; | 570 | return result; |
525 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
526 | if (!acpi_battery_present(battery)) { | 571 | if (!acpi_battery_present(battery)) { |
572 | #ifdef CONFIG_ACPI_SYSFS_POWER | ||
527 | sysfs_remove_battery(battery); | 573 | sysfs_remove_battery(battery); |
574 | #endif | ||
528 | battery->update_time = 0; | 575 | battery->update_time = 0; |
529 | return 0; | 576 | return 0; |
530 | } | 577 | } |
531 | #endif | ||
532 | if (!battery->update_time || | 578 | if (!battery->update_time || |
533 | old_present != acpi_battery_present(battery)) { | 579 | old_present != acpi_battery_present(battery)) { |
534 | result = acpi_battery_get_info(battery); | 580 | result = acpi_battery_get_info(battery); |
@@ -590,6 +636,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result) | |||
590 | seq_printf(seq, "design capacity low: %d %sh\n", | 636 | seq_printf(seq, "design capacity low: %d %sh\n", |
591 | battery->design_capacity_low, | 637 | battery->design_capacity_low, |
592 | acpi_battery_units(battery)); | 638 | acpi_battery_units(battery)); |
639 | seq_printf(seq, "cycle count: %i\n", battery->cycle_count); | ||
593 | seq_printf(seq, "capacity granularity 1: %d %sh\n", | 640 | seq_printf(seq, "capacity granularity 1: %d %sh\n", |
594 | battery->capacity_granularity_1, | 641 | battery->capacity_granularity_1, |
595 | acpi_battery_units(battery)); | 642 | acpi_battery_units(battery)); |
@@ -833,7 +880,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event) | |||
833 | #ifdef CONFIG_ACPI_SYSFS_POWER | 880 | #ifdef CONFIG_ACPI_SYSFS_POWER |
834 | /* acpi_battery_update could remove power_supply object */ | 881 | /* acpi_battery_update could remove power_supply object */ |
835 | if (battery->bat.dev) | 882 | if (battery->bat.dev) |
836 | kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); | 883 | power_supply_changed(&battery->bat); |
837 | #endif | 884 | #endif |
838 | } | 885 | } |
839 | 886 | ||
@@ -841,6 +888,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
841 | { | 888 | { |
842 | int result = 0; | 889 | int result = 0; |
843 | struct acpi_battery *battery = NULL; | 890 | struct acpi_battery *battery = NULL; |
891 | acpi_handle handle; | ||
844 | if (!device) | 892 | if (!device) |
845 | return -EINVAL; | 893 | return -EINVAL; |
846 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 894 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
@@ -851,6 +899,9 @@ static int acpi_battery_add(struct acpi_device *device) | |||
851 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); | 899 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); |
852 | device->driver_data = battery; | 900 | device->driver_data = battery; |
853 | mutex_init(&battery->lock); | 901 | mutex_init(&battery->lock); |
902 | if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle, | ||
903 | "_BIX", &handle))) | ||
904 | set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); | ||
854 | acpi_battery_update(battery); | 905 | acpi_battery_update(battery); |
855 | #ifdef CONFIG_ACPI_PROCFS_POWER | 906 | #ifdef CONFIG_ACPI_PROCFS_POWER |
856 | result = acpi_battery_add_fs(device); | 907 | result = acpi_battery_add_fs(device); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index a52126e46307..37132dc2da03 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/device.h> | 32 | #include <linux/device.h> |
33 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
34 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
35 | #include <linux/slab.h> | ||
35 | #ifdef CONFIG_X86 | 36 | #ifdef CONFIG_X86 |
36 | #include <asm/mpspec.h> | 37 | #include <asm/mpspec.h> |
37 | #endif | 38 | #endif |
@@ -190,16 +191,16 @@ int acpi_bus_get_power(acpi_handle handle, int *state) | |||
190 | * Get the device's power state either directly (via _PSC) or | 191 | * Get the device's power state either directly (via _PSC) or |
191 | * indirectly (via power resources). | 192 | * indirectly (via power resources). |
192 | */ | 193 | */ |
193 | if (device->power.flags.explicit_get) { | 194 | if (device->power.flags.power_resources) { |
195 | result = acpi_power_get_inferred_state(device); | ||
196 | if (result) | ||
197 | return result; | ||
198 | } else if (device->power.flags.explicit_get) { | ||
194 | status = acpi_evaluate_integer(device->handle, "_PSC", | 199 | status = acpi_evaluate_integer(device->handle, "_PSC", |
195 | NULL, &psc); | 200 | NULL, &psc); |
196 | if (ACPI_FAILURE(status)) | 201 | if (ACPI_FAILURE(status)) |
197 | return -ENODEV; | 202 | return -ENODEV; |
198 | device->power.state = (int)psc; | 203 | device->power.state = (int)psc; |
199 | } else if (device->power.flags.power_resources) { | ||
200 | result = acpi_power_get_inferred_state(device); | ||
201 | if (result) | ||
202 | return result; | ||
203 | } | 204 | } |
204 | 205 | ||
205 | *state = device->power.state; | 206 | *state = device->power.state; |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index f53fbe307c9d..fd51c4ab4829 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/input.h> | 32 | #include <linux/input.h> |
33 | #include <linux/slab.h> | ||
33 | #include <acpi/acpi_bus.h> | 34 | #include <acpi/acpi_bus.h> |
34 | #include <acpi/acpi_drivers.h> | 35 | #include <acpi/acpi_drivers.h> |
35 | 36 | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 5faf6c21257d..45cd03b4630e 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/slab.h> | ||
32 | #include <linux/types.h> | 33 | #include <linux/types.h> |
33 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
34 | #include <acpi/acpi_bus.h> | 35 | #include <acpi/acpi_bus.h> |
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index cc421b7ae166..146135e7a6a1 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/moduleparam.h> | 10 | #include <linux/moduleparam.h> |
11 | #include <linux/debugfs.h> | 11 | #include <linux/debugfs.h> |
12 | #include <linux/slab.h> | ||
12 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
13 | #include <acpi/acpi_drivers.h> | 14 | #include <acpi/acpi_drivers.h> |
14 | 15 | ||
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index d9a85f1ddde6..3fe29e992be8 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/slab.h> | ||
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | #include <linux/types.h> | 29 | #include <linux/types.h> |
29 | #include <linux/notifier.h> | 30 | #include <linux/notifier.h> |
@@ -1025,13 +1026,10 @@ static int dock_remove(struct dock_station *ds) | |||
1025 | static acpi_status | 1026 | static acpi_status |
1026 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) | 1027 | find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) |
1027 | { | 1028 | { |
1028 | acpi_status status = AE_OK; | ||
1029 | |||
1030 | if (is_dock(handle)) | 1029 | if (is_dock(handle)) |
1031 | if (dock_add(handle) >= 0) | 1030 | dock_add(handle); |
1032 | status = AE_CTRL_TERMINATE; | ||
1033 | 1031 | ||
1034 | return status; | 1032 | return AE_OK; |
1035 | } | 1033 | } |
1036 | 1034 | ||
1037 | static acpi_status | 1035 | static acpi_status |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d7a6bbbb834c..f2234db85da0 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/list.h> | 40 | #include <linux/list.h> |
41 | #include <linux/spinlock.h> | 41 | #include <linux/spinlock.h> |
42 | #include <linux/slab.h> | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
43 | #include <acpi/acpi_bus.h> | 44 | #include <acpi/acpi_bus.h> |
44 | #include <acpi/acpi_drivers.h> | 45 | #include <acpi/acpi_drivers.h> |
@@ -76,8 +77,9 @@ enum ec_command { | |||
76 | enum { | 77 | enum { |
77 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ | 78 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ |
78 | EC_FLAGS_GPE_STORM, /* GPE storm detected */ | 79 | EC_FLAGS_GPE_STORM, /* GPE storm detected */ |
79 | EC_FLAGS_HANDLERS_INSTALLED /* Handlers for GPE and | 80 | EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and |
80 | * OpReg are installed */ | 81 | * OpReg are installed */ |
82 | EC_FLAGS_FROZEN, /* Transactions are suspended */ | ||
81 | }; | 83 | }; |
82 | 84 | ||
83 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 85 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
@@ -291,6 +293,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
291 | if (t->rdata) | 293 | if (t->rdata) |
292 | memset(t->rdata, 0, t->rlen); | 294 | memset(t->rdata, 0, t->rlen); |
293 | mutex_lock(&ec->lock); | 295 | mutex_lock(&ec->lock); |
296 | if (test_bit(EC_FLAGS_FROZEN, &ec->flags)) { | ||
297 | status = -EINVAL; | ||
298 | goto unlock; | ||
299 | } | ||
294 | if (ec->global_lock) { | 300 | if (ec->global_lock) { |
295 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 301 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
296 | if (ACPI_FAILURE(status)) { | 302 | if (ACPI_FAILURE(status)) { |
@@ -453,6 +459,32 @@ int ec_transaction(u8 command, | |||
453 | 459 | ||
454 | EXPORT_SYMBOL(ec_transaction); | 460 | EXPORT_SYMBOL(ec_transaction); |
455 | 461 | ||
462 | void acpi_ec_suspend_transactions(void) | ||
463 | { | ||
464 | struct acpi_ec *ec = first_ec; | ||
465 | |||
466 | if (!ec) | ||
467 | return; | ||
468 | |||
469 | mutex_lock(&ec->lock); | ||
470 | /* Prevent transactions from being carried out */ | ||
471 | set_bit(EC_FLAGS_FROZEN, &ec->flags); | ||
472 | mutex_unlock(&ec->lock); | ||
473 | } | ||
474 | |||
475 | void acpi_ec_resume_transactions(void) | ||
476 | { | ||
477 | struct acpi_ec *ec = first_ec; | ||
478 | |||
479 | if (!ec) | ||
480 | return; | ||
481 | |||
482 | mutex_lock(&ec->lock); | ||
483 | /* Allow transactions to be carried out again */ | ||
484 | clear_bit(EC_FLAGS_FROZEN, &ec->flags); | ||
485 | mutex_unlock(&ec->lock); | ||
486 | } | ||
487 | |||
456 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) | 488 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) |
457 | { | 489 | { |
458 | int result; | 490 | int result; |
@@ -597,12 +629,12 @@ static u32 acpi_ec_gpe_handler(void *data) | |||
597 | 629 | ||
598 | static acpi_status | 630 | static acpi_status |
599 | acpi_ec_space_handler(u32 function, acpi_physical_address address, | 631 | acpi_ec_space_handler(u32 function, acpi_physical_address address, |
600 | u32 bits, u64 *value, | 632 | u32 bits, u64 *value64, |
601 | void *handler_context, void *region_context) | 633 | void *handler_context, void *region_context) |
602 | { | 634 | { |
603 | struct acpi_ec *ec = handler_context; | 635 | struct acpi_ec *ec = handler_context; |
604 | int result = 0, i; | 636 | int result = 0, i, bytes = bits / 8; |
605 | u8 temp = 0; | 637 | u8 *value = (u8 *)value64; |
606 | 638 | ||
607 | if ((address > 0xFF) || !value || !handler_context) | 639 | if ((address > 0xFF) || !value || !handler_context) |
608 | return AE_BAD_PARAMETER; | 640 | return AE_BAD_PARAMETER; |
@@ -610,32 +642,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address, | |||
610 | if (function != ACPI_READ && function != ACPI_WRITE) | 642 | if (function != ACPI_READ && function != ACPI_WRITE) |
611 | return AE_BAD_PARAMETER; | 643 | return AE_BAD_PARAMETER; |
612 | 644 | ||
613 | if (bits != 8 && acpi_strict) | 645 | if (EC_FLAGS_MSI || bits > 8) |
614 | return AE_BAD_PARAMETER; | ||
615 | |||
616 | if (EC_FLAGS_MSI) | ||
617 | acpi_ec_burst_enable(ec); | 646 | acpi_ec_burst_enable(ec); |
618 | 647 | ||
619 | if (function == ACPI_READ) { | 648 | for (i = 0; i < bytes; ++i, ++address, ++value) |
620 | result = acpi_ec_read(ec, address, &temp); | 649 | result = (function == ACPI_READ) ? |
621 | *value = temp; | 650 | acpi_ec_read(ec, address, value) : |
622 | } else { | 651 | acpi_ec_write(ec, address, *value); |
623 | temp = 0xff & (*value); | ||
624 | result = acpi_ec_write(ec, address, temp); | ||
625 | } | ||
626 | 652 | ||
627 | for (i = 8; unlikely(bits - i > 0); i += 8) { | 653 | if (EC_FLAGS_MSI || bits > 8) |
628 | ++address; | ||
629 | if (function == ACPI_READ) { | ||
630 | result = acpi_ec_read(ec, address, &temp); | ||
631 | (*value) |= ((u64)temp) << i; | ||
632 | } else { | ||
633 | temp = 0xff & ((*value) >> i); | ||
634 | result = acpi_ec_write(ec, address, temp); | ||
635 | } | ||
636 | } | ||
637 | |||
638 | if (EC_FLAGS_MSI) | ||
639 | acpi_ec_burst_disable(ec); | 654 | acpi_ec_burst_disable(ec); |
640 | 655 | ||
641 | switch (result) { | 656 | switch (result) { |
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index c511071bfd79..d439314a75d8 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/proc_fs.h> | 10 | #include <linux/proc_fs.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/poll.h> | 12 | #include <linux/poll.h> |
13 | #include <linux/gfp.h> | ||
13 | #include <acpi/acpi_drivers.h> | 14 | #include <acpi/acpi_drivers.h> |
14 | #include <net/netlink.h> | 15 | #include <net/netlink.h> |
15 | #include <net/genetlink.h> | 16 | #include <net/genetlink.h> |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 6d5b64b7d526..4af6301601e7 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/list.h> | 10 | #include <linux/list.h> |
11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
12 | #include <linux/slab.h> | ||
12 | #include <linux/rwsem.h> | 13 | #include <linux/rwsem.h> |
13 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
14 | 15 | ||
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 9c4c962e46e3..e28411367239 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -49,6 +49,8 @@ void acpi_early_processor_set_pdc(void); | |||
49 | int acpi_ec_init(void); | 49 | int acpi_ec_init(void); |
50 | int acpi_ec_ecdt_probe(void); | 50 | int acpi_ec_ecdt_probe(void); |
51 | int acpi_boot_ec_enable(void); | 51 | int acpi_boot_ec_enable(void); |
52 | void acpi_ec_suspend_transactions(void); | ||
53 | void acpi_ec_resume_transactions(void); | ||
52 | 54 | ||
53 | /*-------------------------------------------------------------------------- | 55 | /*-------------------------------------------------------------------------- |
54 | Suspend/Resume | 56 | Suspend/Resume |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index b8725461d887..b0337d314604 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -61,8 +61,10 @@ int node_to_pxm(int node) | |||
61 | 61 | ||
62 | void __acpi_map_pxm_to_node(int pxm, int node) | 62 | void __acpi_map_pxm_to_node(int pxm, int node) |
63 | { | 63 | { |
64 | pxm_to_node_map[pxm] = node; | 64 | if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm]) |
65 | node_to_pxm_map[node] = pxm; | 65 | pxm_to_node_map[pxm] = node; |
66 | if (node_to_pxm_map[node] == PXM_INVAL || pxm < node_to_pxm_map[node]) | ||
67 | node_to_pxm_map[node] = pxm; | ||
66 | } | 68 | } |
67 | 69 | ||
68 | int acpi_map_pxm_to_node(int pxm) | 70 | int acpi_map_pxm_to_node(int pxm) |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index f92531fbd501..4bc1c4178f50 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -758,7 +758,14 @@ static acpi_status __acpi_os_execute(acpi_execute_type type, | |||
758 | queue = hp ? kacpi_hotplug_wq : | 758 | queue = hp ? kacpi_hotplug_wq : |
759 | (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); | 759 | (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); |
760 | dpc->wait = hp ? 1 : 0; | 760 | dpc->wait = hp ? 1 : 0; |
761 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | 761 | |
762 | if (queue == kacpi_hotplug_wq) | ||
763 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | ||
764 | else if (queue == kacpi_notify_wq) | ||
765 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | ||
766 | else | ||
767 | INIT_WORK(&dpc->work, acpi_os_execute_deferred); | ||
768 | |||
762 | ret = queue_work(queue, &dpc->work); | 769 | ret = queue_work(queue, &dpc->work); |
763 | 770 | ||
764 | if (!ret) { | 771 | if (!ret) { |
@@ -1151,16 +1158,10 @@ int acpi_check_resource_conflict(const struct resource *res) | |||
1151 | 1158 | ||
1152 | if (clash) { | 1159 | if (clash) { |
1153 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { | 1160 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { |
1154 | printk("%sACPI: %s resource %s [0x%llx-0x%llx]" | 1161 | printk(KERN_WARNING "ACPI: resource %s %pR" |
1155 | " conflicts with ACPI region %s" | 1162 | " conflicts with ACPI region %s %pR\n", |
1156 | " [0x%llx-0x%llx]\n", | 1163 | res->name, res, res_list_elem->name, |
1157 | acpi_enforce_resources == ENFORCE_RESOURCES_LAX | 1164 | res_list_elem); |
1158 | ? KERN_WARNING : KERN_ERR, | ||
1159 | ioport ? "I/O" : "Memory", res->name, | ||
1160 | (long long) res->start, (long long) res->end, | ||
1161 | res_list_elem->name, | ||
1162 | (long long) res_list_elem->start, | ||
1163 | (long long) res_list_elem->end); | ||
1164 | if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) | 1165 | if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) |
1165 | printk(KERN_NOTICE "ACPI: This conflict may" | 1166 | printk(KERN_NOTICE "ACPI: This conflict may" |
1166 | " cause random problems and system" | 1167 | " cause random problems and system" |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 843699ed93f2..b0a71ecee682 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/pm.h> | 37 | #include <linux/pm.h> |
38 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
39 | #include <linux/acpi.h> | 39 | #include <linux/acpi.h> |
40 | #include <linux/slab.h> | ||
40 | #include <acpi/acpi_bus.h> | 41 | #include <acpi/acpi_bus.h> |
41 | #include <acpi/acpi_drivers.h> | 42 | #include <acpi/acpi_drivers.h> |
42 | 43 | ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 04b0f007c9b7..8d47a5846aeb 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/pm.h> | 39 | #include <linux/pm.h> |
40 | #include <linux/pci.h> | 40 | #include <linux/pci.h> |
41 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
42 | #include <linux/slab.h> | ||
42 | 43 | ||
43 | #include <acpi/acpi_bus.h> | 44 | #include <acpi/acpi_bus.h> |
44 | #include <acpi/acpi_drivers.h> | 45 | #include <acpi/acpi_drivers.h> |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index d724736d56c8..aefce33f2a09 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/pci-acpi.h> | 35 | #include <linux/pci-acpi.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/slab.h> | ||
37 | #include <acpi/acpi_bus.h> | 38 | #include <acpi/acpi_bus.h> |
38 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
39 | 40 | ||
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index 11f219743204..07f7fea8a4e2 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/slab.h> | ||
29 | #include <linux/types.h> | 30 | #include <linux/types.h> |
30 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
31 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 8ed24c2fa185..f74d3b31e5c9 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
41 | #include <linux/types.h> | 41 | #include <linux/types.h> |
42 | #include <linux/slab.h> | ||
42 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
43 | #include <linux/seq_file.h> | 44 | #include <linux/seq_file.h> |
44 | #include <acpi/acpi_bus.h> | 45 | #include <acpi/acpi_bus.h> |
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c index 834c5af0de4b..e8c32a49f14e 100644 --- a/drivers/acpi/power_meter.c +++ b/drivers/acpi/power_meter.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/jiffies.h> | 25 | #include <linux/jiffies.h> |
26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/dmi.h> | 27 | #include <linux/dmi.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/kdev_t.h> | 29 | #include <linux/kdev_t.h> |
29 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
30 | #include <linux/time.h> | 31 | #include <linux/time.h> |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index e9b7b402dbfb..51284351418f 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -1,383 +1,63 @@ | |||
1 | /* | 1 | /* |
2 | * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $) | 2 | * Copyright (C) 2005 Intel Corporation |
3 | * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. | ||
3 | * | 4 | * |
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 5 | * Alex Chiang <achiang@hp.com> |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | 6 | * - Unified x86/ia64 implementations |
6 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> | 7 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> |
7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 8 | * - Added _PDC for platforms with Intel CPUs |
8 | * - Added processor hotplug support | ||
9 | * | ||
10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or (at | ||
15 | * your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, but | ||
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License along | ||
23 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
25 | * | ||
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
27 | * TBD: | ||
28 | * 1. Make # power states dynamic. | ||
29 | * 2. Support duty_cycle values that span bit 4. | ||
30 | * 3. Optimize by having scheduler determine business instead of | ||
31 | * having us try to calculate it here. | ||
32 | * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this. | ||
33 | */ | 9 | */ |
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/types.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/pm.h> | ||
41 | #include <linux/cpufreq.h> | ||
42 | #include <linux/cpu.h> | ||
43 | #include <linux/proc_fs.h> | ||
44 | #include <linux/seq_file.h> | ||
45 | #include <linux/dmi.h> | 10 | #include <linux/dmi.h> |
46 | #include <linux/moduleparam.h> | 11 | #include <linux/slab.h> |
47 | #include <linux/cpuidle.h> | ||
48 | 12 | ||
49 | #include <asm/io.h> | ||
50 | #include <asm/system.h> | ||
51 | #include <asm/cpu.h> | ||
52 | #include <asm/delay.h> | ||
53 | #include <asm/uaccess.h> | ||
54 | #include <asm/processor.h> | ||
55 | #include <asm/smp.h> | ||
56 | #include <asm/acpi.h> | ||
57 | |||
58 | #include <acpi/acpi_bus.h> | ||
59 | #include <acpi/acpi_drivers.h> | 13 | #include <acpi/acpi_drivers.h> |
60 | #include <acpi/processor.h> | 14 | #include <acpi/processor.h> |
61 | 15 | ||
62 | #define PREFIX "ACPI: " | 16 | #include "internal.h" |
63 | |||
64 | #define ACPI_PROCESSOR_CLASS "processor" | ||
65 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | ||
66 | #define ACPI_PROCESSOR_FILE_INFO "info" | ||
67 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" | ||
68 | #define ACPI_PROCESSOR_FILE_LIMIT "limit" | ||
69 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 | ||
70 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 | ||
71 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 | ||
72 | |||
73 | #define ACPI_PROCESSOR_LIMIT_USER 0 | ||
74 | #define ACPI_PROCESSOR_LIMIT_THERMAL 1 | ||
75 | 17 | ||
18 | #define PREFIX "ACPI: " | ||
76 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 19 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
77 | ACPI_MODULE_NAME("processor_core"); | 20 | ACPI_MODULE_NAME("processor_core"); |
78 | 21 | ||
79 | MODULE_AUTHOR("Paul Diefenbaugh"); | 22 | static int set_no_mwait(const struct dmi_system_id *id) |
80 | MODULE_DESCRIPTION("ACPI Processor Driver"); | ||
81 | MODULE_LICENSE("GPL"); | ||
82 | |||
83 | static int acpi_processor_add(struct acpi_device *device); | ||
84 | static int acpi_processor_remove(struct acpi_device *device, int type); | ||
85 | #ifdef CONFIG_ACPI_PROCFS | ||
86 | static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); | ||
87 | #endif | ||
88 | static void acpi_processor_notify(struct acpi_device *device, u32 event); | ||
89 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); | ||
90 | static int acpi_processor_handle_eject(struct acpi_processor *pr); | ||
91 | |||
92 | |||
93 | static const struct acpi_device_id processor_device_ids[] = { | ||
94 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | ||
95 | {"ACPI0007", 0}, | ||
96 | {"", 0}, | ||
97 | }; | ||
98 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | ||
99 | |||
100 | static struct acpi_driver acpi_processor_driver = { | ||
101 | .name = "processor", | ||
102 | .class = ACPI_PROCESSOR_CLASS, | ||
103 | .ids = processor_device_ids, | ||
104 | .ops = { | ||
105 | .add = acpi_processor_add, | ||
106 | .remove = acpi_processor_remove, | ||
107 | .suspend = acpi_processor_suspend, | ||
108 | .resume = acpi_processor_resume, | ||
109 | .notify = acpi_processor_notify, | ||
110 | }, | ||
111 | }; | ||
112 | |||
113 | #define INSTALL_NOTIFY_HANDLER 1 | ||
114 | #define UNINSTALL_NOTIFY_HANDLER 2 | ||
115 | #ifdef CONFIG_ACPI_PROCFS | ||
116 | static const struct file_operations acpi_processor_info_fops = { | ||
117 | .owner = THIS_MODULE, | ||
118 | .open = acpi_processor_info_open_fs, | ||
119 | .read = seq_read, | ||
120 | .llseek = seq_lseek, | ||
121 | .release = single_release, | ||
122 | }; | ||
123 | #endif | ||
124 | |||
125 | DEFINE_PER_CPU(struct acpi_processor *, processors); | ||
126 | EXPORT_PER_CPU_SYMBOL(processors); | ||
127 | |||
128 | struct acpi_processor_errata errata __read_mostly; | ||
129 | |||
130 | /* -------------------------------------------------------------------------- | ||
131 | Errata Handling | ||
132 | -------------------------------------------------------------------------- */ | ||
133 | |||
134 | static int acpi_processor_errata_piix4(struct pci_dev *dev) | ||
135 | { | 23 | { |
136 | u8 value1 = 0; | 24 | printk(KERN_NOTICE PREFIX "%s detected - " |
137 | u8 value2 = 0; | 25 | "disabling mwait for CPU C-states\n", id->ident); |
138 | 26 | idle_nomwait = 1; | |
139 | |||
140 | if (!dev) | ||
141 | return -EINVAL; | ||
142 | |||
143 | /* | ||
144 | * Note that 'dev' references the PIIX4 ACPI Controller. | ||
145 | */ | ||
146 | |||
147 | switch (dev->revision) { | ||
148 | case 0: | ||
149 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n")); | ||
150 | break; | ||
151 | case 1: | ||
152 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n")); | ||
153 | break; | ||
154 | case 2: | ||
155 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n")); | ||
156 | break; | ||
157 | case 3: | ||
158 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n")); | ||
159 | break; | ||
160 | default: | ||
161 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n")); | ||
162 | break; | ||
163 | } | ||
164 | |||
165 | switch (dev->revision) { | ||
166 | |||
167 | case 0: /* PIIX4 A-step */ | ||
168 | case 1: /* PIIX4 B-step */ | ||
169 | /* | ||
170 | * See specification changes #13 ("Manual Throttle Duty Cycle") | ||
171 | * and #14 ("Enabling and Disabling Manual Throttle"), plus | ||
172 | * erratum #5 ("STPCLK# Deassertion Time") from the January | ||
173 | * 2002 PIIX4 specification update. Applies to only older | ||
174 | * PIIX4 models. | ||
175 | */ | ||
176 | errata.piix4.throttle = 1; | ||
177 | |||
178 | case 2: /* PIIX4E */ | ||
179 | case 3: /* PIIX4M */ | ||
180 | /* | ||
181 | * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA | ||
182 | * Livelock") from the January 2002 PIIX4 specification update. | ||
183 | * Applies to all PIIX4 models. | ||
184 | */ | ||
185 | |||
186 | /* | ||
187 | * BM-IDE | ||
188 | * ------ | ||
189 | * Find the PIIX4 IDE Controller and get the Bus Master IDE | ||
190 | * Status register address. We'll use this later to read | ||
191 | * each IDE controller's DMA status to make sure we catch all | ||
192 | * DMA activity. | ||
193 | */ | ||
194 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
195 | PCI_DEVICE_ID_INTEL_82371AB, | ||
196 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
197 | if (dev) { | ||
198 | errata.piix4.bmisx = pci_resource_start(dev, 4); | ||
199 | pci_dev_put(dev); | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * Type-F DMA | ||
204 | * ---------- | ||
205 | * Find the PIIX4 ISA Controller and read the Motherboard | ||
206 | * DMA controller's status to see if Type-F (Fast) DMA mode | ||
207 | * is enabled (bit 7) on either channel. Note that we'll | ||
208 | * disable C3 support if this is enabled, as some legacy | ||
209 | * devices won't operate well if fast DMA is disabled. | ||
210 | */ | ||
211 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
212 | PCI_DEVICE_ID_INTEL_82371AB_0, | ||
213 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
214 | if (dev) { | ||
215 | pci_read_config_byte(dev, 0x76, &value1); | ||
216 | pci_read_config_byte(dev, 0x77, &value2); | ||
217 | if ((value1 & 0x80) || (value2 & 0x80)) | ||
218 | errata.piix4.fdma = 1; | ||
219 | pci_dev_put(dev); | ||
220 | } | ||
221 | |||
222 | break; | ||
223 | } | ||
224 | |||
225 | if (errata.piix4.bmisx) | ||
226 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
227 | "Bus master activity detection (BM-IDE) erratum enabled\n")); | ||
228 | if (errata.piix4.fdma) | ||
229 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
230 | "Type-F DMA livelock erratum (C3 disabled)\n")); | ||
231 | |||
232 | return 0; | 27 | return 0; |
233 | } | 28 | } |
234 | 29 | ||
235 | static int acpi_processor_errata(struct acpi_processor *pr) | 30 | static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { |
236 | { | 31 | { |
237 | int result = 0; | 32 | set_no_mwait, "IFL91 board", { |
238 | struct pci_dev *dev = NULL; | 33 | DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), |
239 | 34 | DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"), | |
240 | 35 | DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"), | |
241 | if (!pr) | 36 | DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL}, |
242 | return -EINVAL; | 37 | { |
243 | 38 | set_no_mwait, "Extensa 5220", { | |
244 | /* | 39 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), |
245 | * PIIX4 | 40 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
246 | */ | 41 | DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), |
247 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | 42 | DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, |
248 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | 43 | {}, |
249 | PCI_ANY_ID, NULL); | 44 | }; |
250 | if (dev) { | ||
251 | result = acpi_processor_errata_piix4(dev); | ||
252 | pci_dev_put(dev); | ||
253 | } | ||
254 | |||
255 | return result; | ||
256 | } | ||
257 | |||
258 | /* -------------------------------------------------------------------------- | ||
259 | FS Interface (/proc) | ||
260 | -------------------------------------------------------------------------- */ | ||
261 | |||
262 | #ifdef CONFIG_ACPI_PROCFS | ||
263 | static struct proc_dir_entry *acpi_processor_dir = NULL; | ||
264 | |||
265 | static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) | ||
266 | { | ||
267 | struct acpi_processor *pr = seq->private; | ||
268 | |||
269 | |||
270 | if (!pr) | ||
271 | goto end; | ||
272 | |||
273 | seq_printf(seq, "processor id: %d\n" | ||
274 | "acpi id: %d\n" | ||
275 | "bus mastering control: %s\n" | ||
276 | "power management: %s\n" | ||
277 | "throttling control: %s\n" | ||
278 | "limit interface: %s\n", | ||
279 | pr->id, | ||
280 | pr->acpi_id, | ||
281 | pr->flags.bm_control ? "yes" : "no", | ||
282 | pr->flags.power ? "yes" : "no", | ||
283 | pr->flags.throttling ? "yes" : "no", | ||
284 | pr->flags.limit ? "yes" : "no"); | ||
285 | |||
286 | end: | ||
287 | return 0; | ||
288 | } | ||
289 | |||
290 | static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) | ||
291 | { | ||
292 | return single_open(file, acpi_processor_info_seq_show, | ||
293 | PDE(inode)->data); | ||
294 | } | ||
295 | |||
296 | static int __cpuinit acpi_processor_add_fs(struct acpi_device *device) | ||
297 | { | ||
298 | struct proc_dir_entry *entry = NULL; | ||
299 | |||
300 | |||
301 | if (!acpi_device_dir(device)) { | ||
302 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | ||
303 | acpi_processor_dir); | ||
304 | if (!acpi_device_dir(device)) | ||
305 | return -ENODEV; | ||
306 | } | ||
307 | |||
308 | /* 'info' [R] */ | ||
309 | entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO, | ||
310 | S_IRUGO, acpi_device_dir(device), | ||
311 | &acpi_processor_info_fops, | ||
312 | acpi_driver_data(device)); | ||
313 | if (!entry) | ||
314 | return -EIO; | ||
315 | |||
316 | /* 'throttling' [R/W] */ | ||
317 | entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING, | ||
318 | S_IFREG | S_IRUGO | S_IWUSR, | ||
319 | acpi_device_dir(device), | ||
320 | &acpi_processor_throttling_fops, | ||
321 | acpi_driver_data(device)); | ||
322 | if (!entry) | ||
323 | return -EIO; | ||
324 | |||
325 | /* 'limit' [R/W] */ | ||
326 | entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT, | ||
327 | S_IFREG | S_IRUGO | S_IWUSR, | ||
328 | acpi_device_dir(device), | ||
329 | &acpi_processor_limit_fops, | ||
330 | acpi_driver_data(device)); | ||
331 | if (!entry) | ||
332 | return -EIO; | ||
333 | return 0; | ||
334 | } | ||
335 | static int acpi_processor_remove_fs(struct acpi_device *device) | ||
336 | { | ||
337 | |||
338 | if (acpi_device_dir(device)) { | ||
339 | remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, | ||
340 | acpi_device_dir(device)); | ||
341 | remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, | ||
342 | acpi_device_dir(device)); | ||
343 | remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, | ||
344 | acpi_device_dir(device)); | ||
345 | remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); | ||
346 | acpi_device_dir(device) = NULL; | ||
347 | } | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | #else | ||
352 | static inline int acpi_processor_add_fs(struct acpi_device *device) | ||
353 | { | ||
354 | return 0; | ||
355 | } | ||
356 | static inline int acpi_processor_remove_fs(struct acpi_device *device) | ||
357 | { | ||
358 | return 0; | ||
359 | } | ||
360 | #endif | ||
361 | |||
362 | /* Use the acpiid in MADT to map cpus in case of SMP */ | ||
363 | |||
364 | #ifndef CONFIG_SMP | ||
365 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) { return -1; } | ||
366 | #else | ||
367 | |||
368 | static struct acpi_table_madt *madt; | ||
369 | 45 | ||
46 | #ifdef CONFIG_SMP | ||
370 | static int map_lapic_id(struct acpi_subtable_header *entry, | 47 | static int map_lapic_id(struct acpi_subtable_header *entry, |
371 | u32 acpi_id, int *apic_id) | 48 | u32 acpi_id, int *apic_id) |
372 | { | 49 | { |
373 | struct acpi_madt_local_apic *lapic = | 50 | struct acpi_madt_local_apic *lapic = |
374 | (struct acpi_madt_local_apic *)entry; | 51 | (struct acpi_madt_local_apic *)entry; |
375 | if ((lapic->lapic_flags & ACPI_MADT_ENABLED) && | 52 | |
376 | lapic->processor_id == acpi_id) { | 53 | if (!(lapic->lapic_flags & ACPI_MADT_ENABLED)) |
377 | *apic_id = lapic->id; | 54 | return 0; |
378 | return 1; | 55 | |
379 | } | 56 | if (lapic->processor_id != acpi_id) |
380 | return 0; | 57 | return 0; |
58 | |||
59 | *apic_id = lapic->id; | ||
60 | return 1; | ||
381 | } | 61 | } |
382 | 62 | ||
383 | static int map_x2apic_id(struct acpi_subtable_header *entry, | 63 | static int map_x2apic_id(struct acpi_subtable_header *entry, |
@@ -385,22 +65,16 @@ static int map_x2apic_id(struct acpi_subtable_header *entry, | |||
385 | { | 65 | { |
386 | struct acpi_madt_local_x2apic *apic = | 66 | struct acpi_madt_local_x2apic *apic = |
387 | (struct acpi_madt_local_x2apic *)entry; | 67 | (struct acpi_madt_local_x2apic *)entry; |
388 | u32 tmp = apic->local_apic_id; | ||
389 | 68 | ||
390 | /* Only check enabled APICs*/ | ||
391 | if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) | 69 | if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) |
392 | return 0; | 70 | return 0; |
393 | 71 | ||
394 | /* Device statement declaration type */ | 72 | if (device_declaration && (apic->uid == acpi_id)) { |
395 | if (device_declaration) { | 73 | *apic_id = apic->local_apic_id; |
396 | if (apic->uid == acpi_id) | 74 | return 1; |
397 | goto found; | ||
398 | } | 75 | } |
399 | 76 | ||
400 | return 0; | 77 | return 0; |
401 | found: | ||
402 | *apic_id = tmp; | ||
403 | return 1; | ||
404 | } | 78 | } |
405 | 79 | ||
406 | static int map_lsapic_id(struct acpi_subtable_header *entry, | 80 | static int map_lsapic_id(struct acpi_subtable_header *entry, |
@@ -408,35 +82,34 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, | |||
408 | { | 82 | { |
409 | struct acpi_madt_local_sapic *lsapic = | 83 | struct acpi_madt_local_sapic *lsapic = |
410 | (struct acpi_madt_local_sapic *)entry; | 84 | (struct acpi_madt_local_sapic *)entry; |
411 | u32 tmp = (lsapic->id << 8) | lsapic->eid; | ||
412 | 85 | ||
413 | /* Only check enabled APICs*/ | ||
414 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) | 86 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) |
415 | return 0; | 87 | return 0; |
416 | 88 | ||
417 | /* Device statement declaration type */ | ||
418 | if (device_declaration) { | 89 | if (device_declaration) { |
419 | if (entry->length < 16) | 90 | if ((entry->length < 16) || (lsapic->uid != acpi_id)) |
420 | printk(KERN_ERR PREFIX | 91 | return 0; |
421 | "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", | 92 | } else if (lsapic->processor_id != acpi_id) |
422 | tmp); | 93 | return 0; |
423 | else if (lsapic->uid == acpi_id) | ||
424 | goto found; | ||
425 | /* Processor statement declaration type */ | ||
426 | } else if (lsapic->processor_id == acpi_id) | ||
427 | goto found; | ||
428 | 94 | ||
429 | return 0; | 95 | *apic_id = (lsapic->id << 8) | lsapic->eid; |
430 | found: | ||
431 | *apic_id = tmp; | ||
432 | return 1; | 96 | return 1; |
433 | } | 97 | } |
434 | 98 | ||
435 | static int map_madt_entry(int type, u32 acpi_id) | 99 | static int map_madt_entry(int type, u32 acpi_id) |
436 | { | 100 | { |
437 | unsigned long madt_end, entry; | 101 | unsigned long madt_end, entry; |
102 | static struct acpi_table_madt *madt; | ||
103 | static int read_madt; | ||
438 | int apic_id = -1; | 104 | int apic_id = -1; |
439 | 105 | ||
106 | if (!read_madt) { | ||
107 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | ||
108 | (struct acpi_table_header **)&madt))) | ||
109 | madt = NULL; | ||
110 | read_madt++; | ||
111 | } | ||
112 | |||
440 | if (!madt) | 113 | if (!madt) |
441 | return apic_id; | 114 | return apic_id; |
442 | 115 | ||
@@ -496,7 +169,7 @@ exit: | |||
496 | return apic_id; | 169 | return apic_id; |
497 | } | 170 | } |
498 | 171 | ||
499 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) | 172 | int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) |
500 | { | 173 | { |
501 | int i; | 174 | int i; |
502 | int apic_id = -1; | 175 | int apic_id = -1; |
@@ -513,630 +186,170 @@ static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) | |||
513 | } | 186 | } |
514 | return -1; | 187 | return -1; |
515 | } | 188 | } |
189 | EXPORT_SYMBOL_GPL(acpi_get_cpuid); | ||
516 | #endif | 190 | #endif |
517 | 191 | ||
518 | /* -------------------------------------------------------------------------- | 192 | static bool processor_physically_present(acpi_handle handle) |
519 | Driver Interface | ||
520 | -------------------------------------------------------------------------- */ | ||
521 | |||
522 | static int acpi_processor_get_info(struct acpi_device *device) | ||
523 | { | 193 | { |
524 | acpi_status status = 0; | 194 | int cpuid, type; |
195 | u32 acpi_id; | ||
196 | acpi_status status; | ||
197 | acpi_object_type acpi_type; | ||
198 | unsigned long long tmp; | ||
525 | union acpi_object object = { 0 }; | 199 | union acpi_object object = { 0 }; |
526 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | 200 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; |
527 | struct acpi_processor *pr; | ||
528 | int cpu_index, device_declaration = 0; | ||
529 | static int cpu0_initialized; | ||
530 | |||
531 | pr = acpi_driver_data(device); | ||
532 | if (!pr) | ||
533 | return -EINVAL; | ||
534 | |||
535 | if (num_online_cpus() > 1) | ||
536 | errata.smp = TRUE; | ||
537 | |||
538 | acpi_processor_errata(pr); | ||
539 | |||
540 | /* | ||
541 | * Check to see if we have bus mastering arbitration control. This | ||
542 | * is required for proper C3 usage (to maintain cache coherency). | ||
543 | */ | ||
544 | if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { | ||
545 | pr->flags.bm_control = 1; | ||
546 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
547 | "Bus mastering arbitration control present\n")); | ||
548 | } else | ||
549 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
550 | "No bus mastering arbitration control\n")); | ||
551 | |||
552 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { | ||
553 | /* Declared with "Processor" statement; match ProcessorID */ | ||
554 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | ||
555 | if (ACPI_FAILURE(status)) { | ||
556 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); | ||
557 | return -ENODEV; | ||
558 | } | ||
559 | |||
560 | /* | ||
561 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | ||
562 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in | ||
563 | * arch/xxx/acpi.c | ||
564 | */ | ||
565 | pr->acpi_id = object.processor.proc_id; | ||
566 | } else { | ||
567 | /* | ||
568 | * Declared with "Device" statement; match _UID. | ||
569 | * Note that we don't handle string _UIDs yet. | ||
570 | */ | ||
571 | unsigned long long value; | ||
572 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | ||
573 | NULL, &value); | ||
574 | if (ACPI_FAILURE(status)) { | ||
575 | printk(KERN_ERR PREFIX | ||
576 | "Evaluating processor _UID [%#x]\n", status); | ||
577 | return -ENODEV; | ||
578 | } | ||
579 | device_declaration = 1; | ||
580 | pr->acpi_id = value; | ||
581 | } | ||
582 | cpu_index = get_cpu_id(pr->handle, device_declaration, pr->acpi_id); | ||
583 | |||
584 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
585 | if (!cpu0_initialized && (cpu_index == -1) && | ||
586 | (num_online_cpus() == 1)) { | ||
587 | cpu_index = 0; | ||
588 | } | ||
589 | |||
590 | cpu0_initialized = 1; | ||
591 | |||
592 | pr->id = cpu_index; | ||
593 | |||
594 | /* | ||
595 | * Extra Processor objects may be enumerated on MP systems with | ||
596 | * less than the max # of CPUs. They should be ignored _iff | ||
597 | * they are physically not present. | ||
598 | */ | ||
599 | if (pr->id == -1) { | ||
600 | if (ACPI_FAILURE | ||
601 | (acpi_processor_hotadd_init(pr->handle, &pr->id))) { | ||
602 | return -ENODEV; | ||
603 | } | ||
604 | } | ||
605 | /* | ||
606 | * On some boxes several processors use the same processor bus id. | ||
607 | * But they are located in different scope. For example: | ||
608 | * \_SB.SCK0.CPU0 | ||
609 | * \_SB.SCK1.CPU0 | ||
610 | * Rename the processor device bus id. And the new bus id will be | ||
611 | * generated as the following format: | ||
612 | * CPU+CPU ID. | ||
613 | */ | ||
614 | sprintf(acpi_device_bid(device), "CPU%X", pr->id); | ||
615 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, | ||
616 | pr->acpi_id)); | ||
617 | |||
618 | if (!object.processor.pblk_address) | ||
619 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); | ||
620 | else if (object.processor.pblk_length != 6) | ||
621 | printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", | ||
622 | object.processor.pblk_length); | ||
623 | else { | ||
624 | pr->throttling.address = object.processor.pblk_address; | ||
625 | pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; | ||
626 | pr->throttling.duty_width = acpi_gbl_FADT.duty_width; | ||
627 | |||
628 | pr->pblk = object.processor.pblk_address; | ||
629 | |||
630 | /* | ||
631 | * We don't care about error returns - we just try to mark | ||
632 | * these reserved so that nobody else is confused into thinking | ||
633 | * that this region might be unused.. | ||
634 | * | ||
635 | * (In particular, allocating the IO range for Cardbus) | ||
636 | */ | ||
637 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | ||
638 | } | ||
639 | |||
640 | /* | ||
641 | * If ACPI describes a slot number for this CPU, we can use it | ||
642 | * ensure we get the right value in the "physical id" field | ||
643 | * of /proc/cpuinfo | ||
644 | */ | ||
645 | status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); | ||
646 | if (ACPI_SUCCESS(status)) | ||
647 | arch_fix_phys_package_id(pr->id, object.integer.value); | ||
648 | |||
649 | return 0; | ||
650 | } | ||
651 | |||
652 | static DEFINE_PER_CPU(void *, processor_device_array); | ||
653 | |||
654 | static void acpi_processor_notify(struct acpi_device *device, u32 event) | ||
655 | { | ||
656 | struct acpi_processor *pr = acpi_driver_data(device); | ||
657 | int saved; | ||
658 | |||
659 | if (!pr) | ||
660 | return; | ||
661 | 201 | ||
662 | switch (event) { | 202 | status = acpi_get_type(handle, &acpi_type); |
663 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: | 203 | if (ACPI_FAILURE(status)) |
664 | saved = pr->performance_platform_limit; | 204 | return false; |
665 | acpi_processor_ppc_has_changed(pr, 1); | 205 | |
666 | if (saved == pr->performance_platform_limit) | 206 | switch (acpi_type) { |
667 | break; | 207 | case ACPI_TYPE_PROCESSOR: |
668 | acpi_bus_generate_proc_event(device, event, | 208 | status = acpi_evaluate_object(handle, NULL, NULL, &buffer); |
669 | pr->performance_platform_limit); | 209 | if (ACPI_FAILURE(status)) |
670 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 210 | return false; |
671 | dev_name(&device->dev), event, | 211 | acpi_id = object.processor.proc_id; |
672 | pr->performance_platform_limit); | ||
673 | break; | 212 | break; |
674 | case ACPI_PROCESSOR_NOTIFY_POWER: | 213 | case ACPI_TYPE_DEVICE: |
675 | acpi_processor_cst_has_changed(pr); | 214 | status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp); |
676 | acpi_bus_generate_proc_event(device, event, 0); | 215 | if (ACPI_FAILURE(status)) |
677 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 216 | return false; |
678 | dev_name(&device->dev), event, 0); | 217 | acpi_id = tmp; |
679 | break; | 218 | break; |
680 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: | ||
681 | acpi_processor_tstate_has_changed(pr); | ||
682 | acpi_bus_generate_proc_event(device, event, 0); | ||
683 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
684 | dev_name(&device->dev), event, 0); | ||
685 | default: | 219 | default: |
686 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 220 | return false; |
687 | "Unsupported event [0x%x]\n", event)); | ||
688 | break; | ||
689 | } | 221 | } |
690 | 222 | ||
691 | return; | 223 | type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; |
692 | } | 224 | cpuid = acpi_get_cpuid(handle, type, acpi_id); |
693 | 225 | ||
694 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | 226 | if (cpuid == -1) |
695 | unsigned long action, void *hcpu) | 227 | return false; |
696 | { | ||
697 | unsigned int cpu = (unsigned long)hcpu; | ||
698 | struct acpi_processor *pr = per_cpu(processors, cpu); | ||
699 | 228 | ||
700 | if (action == CPU_ONLINE && pr) { | 229 | return true; |
701 | acpi_processor_ppc_has_changed(pr, 0); | ||
702 | acpi_processor_cst_has_changed(pr); | ||
703 | acpi_processor_tstate_has_changed(pr); | ||
704 | } | ||
705 | return NOTIFY_OK; | ||
706 | } | 230 | } |
707 | 231 | ||
708 | static struct notifier_block acpi_cpu_notifier = | 232 | static void acpi_set_pdc_bits(u32 *buf) |
709 | { | 233 | { |
710 | .notifier_call = acpi_cpu_soft_notify, | 234 | buf[0] = ACPI_PDC_REVISION_ID; |
711 | }; | 235 | buf[1] = 1; |
712 | |||
713 | static int __cpuinit acpi_processor_add(struct acpi_device *device) | ||
714 | { | ||
715 | struct acpi_processor *pr = NULL; | ||
716 | int result = 0; | ||
717 | struct sys_device *sysdev; | ||
718 | |||
719 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); | ||
720 | if (!pr) | ||
721 | return -ENOMEM; | ||
722 | |||
723 | if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
724 | kfree(pr); | ||
725 | return -ENOMEM; | ||
726 | } | ||
727 | |||
728 | pr->handle = device->handle; | ||
729 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | ||
730 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | ||
731 | device->driver_data = pr; | ||
732 | |||
733 | result = acpi_processor_get_info(device); | ||
734 | if (result) { | ||
735 | /* Processor is physically not present */ | ||
736 | return 0; | ||
737 | } | ||
738 | |||
739 | BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); | ||
740 | |||
741 | /* | ||
742 | * Buggy BIOS check | ||
743 | * ACPI id of processors can be reported wrongly by the BIOS. | ||
744 | * Don't trust it blindly | ||
745 | */ | ||
746 | if (per_cpu(processor_device_array, pr->id) != NULL && | ||
747 | per_cpu(processor_device_array, pr->id) != device) { | ||
748 | printk(KERN_WARNING "BIOS reported wrong ACPI id " | ||
749 | "for the processor\n"); | ||
750 | result = -ENODEV; | ||
751 | goto err_free_cpumask; | ||
752 | } | ||
753 | per_cpu(processor_device_array, pr->id) = device; | ||
754 | 236 | ||
755 | per_cpu(processors, pr->id) = pr; | 237 | /* Enable coordination with firmware's _TSD info */ |
238 | buf[2] = ACPI_PDC_SMP_T_SWCOORD; | ||
756 | 239 | ||
757 | result = acpi_processor_add_fs(device); | 240 | /* Twiddle arch-specific bits needed for _PDC */ |
758 | if (result) | 241 | arch_acpi_set_pdc_bits(buf); |
759 | goto err_free_cpumask; | ||
760 | |||
761 | sysdev = get_cpu_sysdev(pr->id); | ||
762 | if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) { | ||
763 | result = -EFAULT; | ||
764 | goto err_remove_fs; | ||
765 | } | ||
766 | |||
767 | /* _PDC call should be done before doing anything else (if reqd.). */ | ||
768 | acpi_processor_set_pdc(pr->handle); | ||
769 | |||
770 | #ifdef CONFIG_CPU_FREQ | ||
771 | acpi_processor_ppc_has_changed(pr, 0); | ||
772 | #endif | ||
773 | acpi_processor_get_throttling_info(pr); | ||
774 | acpi_processor_get_limit_info(pr); | ||
775 | |||
776 | |||
777 | acpi_processor_power_init(pr, device); | ||
778 | |||
779 | pr->cdev = thermal_cooling_device_register("Processor", device, | ||
780 | &processor_cooling_ops); | ||
781 | if (IS_ERR(pr->cdev)) { | ||
782 | result = PTR_ERR(pr->cdev); | ||
783 | goto err_power_exit; | ||
784 | } | ||
785 | |||
786 | dev_dbg(&device->dev, "registered as cooling_device%d\n", | ||
787 | pr->cdev->id); | ||
788 | |||
789 | result = sysfs_create_link(&device->dev.kobj, | ||
790 | &pr->cdev->device.kobj, | ||
791 | "thermal_cooling"); | ||
792 | if (result) { | ||
793 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
794 | goto err_thermal_unregister; | ||
795 | } | ||
796 | result = sysfs_create_link(&pr->cdev->device.kobj, | ||
797 | &device->dev.kobj, | ||
798 | "device"); | ||
799 | if (result) { | ||
800 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
801 | goto err_remove_sysfs; | ||
802 | } | ||
803 | |||
804 | return 0; | ||
805 | |||
806 | err_remove_sysfs: | ||
807 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
808 | err_thermal_unregister: | ||
809 | thermal_cooling_device_unregister(pr->cdev); | ||
810 | err_power_exit: | ||
811 | acpi_processor_power_exit(pr, device); | ||
812 | err_remove_fs: | ||
813 | acpi_processor_remove_fs(device); | ||
814 | err_free_cpumask: | ||
815 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
816 | |||
817 | return result; | ||
818 | } | 242 | } |
819 | 243 | ||
820 | static int acpi_processor_remove(struct acpi_device *device, int type) | 244 | static struct acpi_object_list *acpi_processor_alloc_pdc(void) |
821 | { | 245 | { |
822 | struct acpi_processor *pr = NULL; | 246 | struct acpi_object_list *obj_list; |
823 | 247 | union acpi_object *obj; | |
824 | 248 | u32 *buf; | |
825 | if (!device || !acpi_driver_data(device)) | ||
826 | return -EINVAL; | ||
827 | |||
828 | pr = acpi_driver_data(device); | ||
829 | |||
830 | if (pr->id >= nr_cpu_ids) | ||
831 | goto free; | ||
832 | 249 | ||
833 | if (type == ACPI_BUS_REMOVAL_EJECT) { | 250 | /* allocate and initialize pdc. It will be used later. */ |
834 | if (acpi_processor_handle_eject(pr)) | 251 | obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); |
835 | return -EINVAL; | 252 | if (!obj_list) { |
253 | printk(KERN_ERR "Memory allocation error\n"); | ||
254 | return NULL; | ||
836 | } | 255 | } |
837 | 256 | ||
838 | acpi_processor_power_exit(pr, device); | 257 | obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); |
839 | 258 | if (!obj) { | |
840 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | 259 | printk(KERN_ERR "Memory allocation error\n"); |
841 | 260 | kfree(obj_list); | |
842 | acpi_processor_remove_fs(device); | 261 | return NULL; |
843 | |||
844 | if (pr->cdev) { | ||
845 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
846 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | ||
847 | thermal_cooling_device_unregister(pr->cdev); | ||
848 | pr->cdev = NULL; | ||
849 | } | 262 | } |
850 | 263 | ||
851 | per_cpu(processors, pr->id) = NULL; | 264 | buf = kmalloc(12, GFP_KERNEL); |
852 | per_cpu(processor_device_array, pr->id) = NULL; | 265 | if (!buf) { |
853 | 266 | printk(KERN_ERR "Memory allocation error\n"); | |
854 | free: | 267 | kfree(obj); |
855 | free_cpumask_var(pr->throttling.shared_cpu_map); | 268 | kfree(obj_list); |
856 | kfree(pr); | 269 | return NULL; |
857 | |||
858 | return 0; | ||
859 | } | ||
860 | |||
861 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
862 | /**************************************************************************** | ||
863 | * Acpi processor hotplug support * | ||
864 | ****************************************************************************/ | ||
865 | |||
866 | static int is_processor_present(acpi_handle handle) | ||
867 | { | ||
868 | acpi_status status; | ||
869 | unsigned long long sta = 0; | ||
870 | |||
871 | |||
872 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
873 | |||
874 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT)) | ||
875 | return 1; | ||
876 | |||
877 | /* | ||
878 | * _STA is mandatory for a processor that supports hot plug | ||
879 | */ | ||
880 | if (status == AE_NOT_FOUND) | ||
881 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
882 | "Processor does not support hot plug\n")); | ||
883 | else | ||
884 | ACPI_EXCEPTION((AE_INFO, status, | ||
885 | "Processor Device is not present")); | ||
886 | return 0; | ||
887 | } | ||
888 | |||
889 | static | ||
890 | int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) | ||
891 | { | ||
892 | acpi_handle phandle; | ||
893 | struct acpi_device *pdev; | ||
894 | |||
895 | |||
896 | if (acpi_get_parent(handle, &phandle)) { | ||
897 | return -ENODEV; | ||
898 | } | 270 | } |
899 | 271 | ||
900 | if (acpi_bus_get_device(phandle, &pdev)) { | 272 | acpi_set_pdc_bits(buf); |
901 | return -ENODEV; | ||
902 | } | ||
903 | 273 | ||
904 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { | 274 | obj->type = ACPI_TYPE_BUFFER; |
905 | return -ENODEV; | 275 | obj->buffer.length = 12; |
906 | } | 276 | obj->buffer.pointer = (u8 *) buf; |
277 | obj_list->count = 1; | ||
278 | obj_list->pointer = obj; | ||
907 | 279 | ||
908 | return 0; | 280 | return obj_list; |
909 | } | 281 | } |
910 | 282 | ||
911 | static void __ref acpi_processor_hotplug_notify(acpi_handle handle, | 283 | /* |
912 | u32 event, void *data) | 284 | * _PDC is required for a BIOS-OS handshake for most of the newer |
285 | * ACPI processor features. | ||
286 | */ | ||
287 | static int | ||
288 | acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) | ||
913 | { | 289 | { |
914 | struct acpi_processor *pr; | 290 | acpi_status status = AE_OK; |
915 | struct acpi_device *device = NULL; | ||
916 | int result; | ||
917 | |||
918 | 291 | ||
919 | switch (event) { | 292 | if (idle_nomwait) { |
920 | case ACPI_NOTIFY_BUS_CHECK: | 293 | /* |
921 | case ACPI_NOTIFY_DEVICE_CHECK: | 294 | * If mwait is disabled for CPU C-states, the C2C3_FFH access |
922 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 295 | * mode will be disabled in the parameter of _PDC object. |
923 | "Processor driver received %s event\n", | 296 | * Of course C1_FFH access mode will also be disabled. |
924 | (event == ACPI_NOTIFY_BUS_CHECK) ? | 297 | */ |
925 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK")); | 298 | union acpi_object *obj; |
926 | 299 | u32 *buffer = NULL; | |
927 | if (!is_processor_present(handle)) | ||
928 | break; | ||
929 | 300 | ||
930 | if (acpi_bus_get_device(handle, &device)) { | 301 | obj = pdc_in->pointer; |
931 | result = acpi_processor_device_add(handle, &device); | 302 | buffer = (u32 *)(obj->buffer.pointer); |
932 | if (result) | 303 | buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH); |
933 | printk(KERN_ERR PREFIX | ||
934 | "Unable to add the device\n"); | ||
935 | break; | ||
936 | } | ||
937 | break; | ||
938 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
939 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
940 | "received ACPI_NOTIFY_EJECT_REQUEST\n")); | ||
941 | 304 | ||
942 | if (acpi_bus_get_device(handle, &device)) { | ||
943 | printk(KERN_ERR PREFIX | ||
944 | "Device don't exist, dropping EJECT\n"); | ||
945 | break; | ||
946 | } | ||
947 | pr = acpi_driver_data(device); | ||
948 | if (!pr) { | ||
949 | printk(KERN_ERR PREFIX | ||
950 | "Driver data is NULL, dropping EJECT\n"); | ||
951 | return; | ||
952 | } | ||
953 | break; | ||
954 | default: | ||
955 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
956 | "Unsupported event [0x%x]\n", event)); | ||
957 | break; | ||
958 | } | 305 | } |
306 | status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL); | ||
959 | 307 | ||
960 | return; | ||
961 | } | ||
962 | |||
963 | static acpi_status | ||
964 | processor_walk_namespace_cb(acpi_handle handle, | ||
965 | u32 lvl, void *context, void **rv) | ||
966 | { | ||
967 | acpi_status status; | ||
968 | int *action = context; | ||
969 | acpi_object_type type = 0; | ||
970 | |||
971 | status = acpi_get_type(handle, &type); | ||
972 | if (ACPI_FAILURE(status)) | 308 | if (ACPI_FAILURE(status)) |
973 | return (AE_OK); | 309 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
974 | 310 | "Could not evaluate _PDC, using legacy perf. control.\n")); | |
975 | if (type != ACPI_TYPE_PROCESSOR) | ||
976 | return (AE_OK); | ||
977 | |||
978 | switch (*action) { | ||
979 | case INSTALL_NOTIFY_HANDLER: | ||
980 | acpi_install_notify_handler(handle, | ||
981 | ACPI_SYSTEM_NOTIFY, | ||
982 | acpi_processor_hotplug_notify, | ||
983 | NULL); | ||
984 | break; | ||
985 | case UNINSTALL_NOTIFY_HANDLER: | ||
986 | acpi_remove_notify_handler(handle, | ||
987 | ACPI_SYSTEM_NOTIFY, | ||
988 | acpi_processor_hotplug_notify); | ||
989 | break; | ||
990 | default: | ||
991 | break; | ||
992 | } | ||
993 | 311 | ||
994 | return (AE_OK); | 312 | return status; |
995 | } | 313 | } |
996 | 314 | ||
997 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | 315 | void acpi_processor_set_pdc(acpi_handle handle) |
998 | { | 316 | { |
317 | struct acpi_object_list *obj_list; | ||
999 | 318 | ||
1000 | if (!is_processor_present(handle)) { | 319 | if (arch_has_acpi_pdc() == false) |
1001 | return AE_ERROR; | 320 | return; |
1002 | } | ||
1003 | 321 | ||
1004 | if (acpi_map_lsapic(handle, p_cpu)) | 322 | obj_list = acpi_processor_alloc_pdc(); |
1005 | return AE_ERROR; | 323 | if (!obj_list) |
324 | return; | ||
1006 | 325 | ||
1007 | if (arch_register_cpu(*p_cpu)) { | 326 | acpi_processor_eval_pdc(handle, obj_list); |
1008 | acpi_unmap_lsapic(*p_cpu); | ||
1009 | return AE_ERROR; | ||
1010 | } | ||
1011 | 327 | ||
1012 | return AE_OK; | 328 | kfree(obj_list->pointer->buffer.pointer); |
329 | kfree(obj_list->pointer); | ||
330 | kfree(obj_list); | ||
1013 | } | 331 | } |
332 | EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); | ||
1014 | 333 | ||
1015 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | 334 | static acpi_status |
335 | early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
1016 | { | 336 | { |
1017 | if (cpu_online(pr->id)) | 337 | if (processor_physically_present(handle) == false) |
1018 | cpu_down(pr->id); | 338 | return AE_OK; |
1019 | 339 | ||
1020 | arch_unregister_cpu(pr->id); | 340 | acpi_processor_set_pdc(handle); |
1021 | acpi_unmap_lsapic(pr->id); | 341 | return AE_OK; |
1022 | return (0); | ||
1023 | } | ||
1024 | #else | ||
1025 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | ||
1026 | { | ||
1027 | return AE_ERROR; | ||
1028 | } | ||
1029 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
1030 | { | ||
1031 | return (-EINVAL); | ||
1032 | } | 342 | } |
1033 | #endif | ||
1034 | 343 | ||
1035 | static | 344 | void __init acpi_early_processor_set_pdc(void) |
1036 | void acpi_processor_install_hotplug_notify(void) | ||
1037 | { | 345 | { |
1038 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | 346 | /* |
1039 | int action = INSTALL_NOTIFY_HANDLER; | 347 | * Check whether the system is DMI table. If yes, OSPM |
1040 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | 348 | * should not use mwait for CPU-states. |
1041 | ACPI_ROOT_OBJECT, | 349 | */ |
1042 | ACPI_UINT32_MAX, | 350 | dmi_check_system(processor_idle_dmi_table); |
1043 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
1044 | #endif | ||
1045 | register_hotcpu_notifier(&acpi_cpu_notifier); | ||
1046 | } | ||
1047 | 351 | ||
1048 | static | 352 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, |
1049 | void acpi_processor_uninstall_hotplug_notify(void) | ||
1050 | { | ||
1051 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
1052 | int action = UNINSTALL_NOTIFY_HANDLER; | ||
1053 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | ||
1054 | ACPI_ROOT_OBJECT, | ||
1055 | ACPI_UINT32_MAX, | 353 | ACPI_UINT32_MAX, |
1056 | processor_walk_namespace_cb, NULL, &action, NULL); | 354 | early_init_pdc, NULL, NULL, NULL); |
1057 | #endif | ||
1058 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | ||
1059 | } | 355 | } |
1060 | |||
1061 | /* | ||
1062 | * We keep the driver loaded even when ACPI is not running. | ||
1063 | * This is needed for the powernow-k8 driver, that works even without | ||
1064 | * ACPI, but needs symbols from this driver | ||
1065 | */ | ||
1066 | |||
1067 | static int __init acpi_processor_init(void) | ||
1068 | { | ||
1069 | int result = 0; | ||
1070 | |||
1071 | if (acpi_disabled) | ||
1072 | return 0; | ||
1073 | |||
1074 | memset(&errata, 0, sizeof(errata)); | ||
1075 | |||
1076 | #ifdef CONFIG_SMP | ||
1077 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | ||
1078 | (struct acpi_table_header **)&madt))) | ||
1079 | madt = NULL; | ||
1080 | #endif | ||
1081 | #ifdef CONFIG_ACPI_PROCFS | ||
1082 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
1083 | if (!acpi_processor_dir) | ||
1084 | return -ENOMEM; | ||
1085 | #endif | ||
1086 | result = cpuidle_register_driver(&acpi_idle_driver); | ||
1087 | if (result < 0) | ||
1088 | goto out_proc; | ||
1089 | |||
1090 | result = acpi_bus_register_driver(&acpi_processor_driver); | ||
1091 | if (result < 0) | ||
1092 | goto out_cpuidle; | ||
1093 | |||
1094 | acpi_processor_install_hotplug_notify(); | ||
1095 | |||
1096 | acpi_thermal_cpufreq_init(); | ||
1097 | |||
1098 | acpi_processor_ppc_init(); | ||
1099 | |||
1100 | acpi_processor_throttling_init(); | ||
1101 | |||
1102 | return 0; | ||
1103 | |||
1104 | out_cpuidle: | ||
1105 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
1106 | |||
1107 | out_proc: | ||
1108 | #ifdef CONFIG_ACPI_PROCFS | ||
1109 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
1110 | #endif | ||
1111 | |||
1112 | return result; | ||
1113 | } | ||
1114 | |||
1115 | static void __exit acpi_processor_exit(void) | ||
1116 | { | ||
1117 | if (acpi_disabled) | ||
1118 | return; | ||
1119 | |||
1120 | acpi_processor_ppc_exit(); | ||
1121 | |||
1122 | acpi_thermal_cpufreq_exit(); | ||
1123 | |||
1124 | acpi_processor_uninstall_hotplug_notify(); | ||
1125 | |||
1126 | acpi_bus_unregister_driver(&acpi_processor_driver); | ||
1127 | |||
1128 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
1129 | |||
1130 | #ifdef CONFIG_ACPI_PROCFS | ||
1131 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
1132 | #endif | ||
1133 | |||
1134 | return; | ||
1135 | } | ||
1136 | |||
1137 | module_init(acpi_processor_init); | ||
1138 | module_exit(acpi_processor_exit); | ||
1139 | |||
1140 | EXPORT_SYMBOL(acpi_processor_set_thermal_limit); | ||
1141 | |||
1142 | MODULE_ALIAS("processor"); | ||
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c new file mode 100644 index 000000000000..5675d9747e87 --- /dev/null +++ b/drivers/acpi/processor_driver.c | |||
@@ -0,0 +1,979 @@ | |||
1 | /* | ||
2 | * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $) | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
6 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> | ||
7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
8 | * - Added processor hotplug support | ||
9 | * | ||
10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or (at | ||
15 | * your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, but | ||
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License along | ||
23 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
25 | * | ||
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
27 | * TBD: | ||
28 | * 1. Make # power states dynamic. | ||
29 | * 2. Support duty_cycle values that span bit 4. | ||
30 | * 3. Optimize by having scheduler determine business instead of | ||
31 | * having us try to calculate it here. | ||
32 | * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this. | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/types.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/pm.h> | ||
41 | #include <linux/cpufreq.h> | ||
42 | #include <linux/cpu.h> | ||
43 | #include <linux/proc_fs.h> | ||
44 | #include <linux/seq_file.h> | ||
45 | #include <linux/dmi.h> | ||
46 | #include <linux/moduleparam.h> | ||
47 | #include <linux/cpuidle.h> | ||
48 | #include <linux/slab.h> | ||
49 | |||
50 | #include <asm/io.h> | ||
51 | #include <asm/system.h> | ||
52 | #include <asm/cpu.h> | ||
53 | #include <asm/delay.h> | ||
54 | #include <asm/uaccess.h> | ||
55 | #include <asm/processor.h> | ||
56 | #include <asm/smp.h> | ||
57 | #include <asm/acpi.h> | ||
58 | |||
59 | #include <acpi/acpi_bus.h> | ||
60 | #include <acpi/acpi_drivers.h> | ||
61 | #include <acpi/processor.h> | ||
62 | |||
63 | #define PREFIX "ACPI: " | ||
64 | |||
65 | #define ACPI_PROCESSOR_CLASS "processor" | ||
66 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | ||
67 | #define ACPI_PROCESSOR_FILE_INFO "info" | ||
68 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" | ||
69 | #define ACPI_PROCESSOR_FILE_LIMIT "limit" | ||
70 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 | ||
71 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 | ||
72 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 | ||
73 | |||
74 | #define ACPI_PROCESSOR_LIMIT_USER 0 | ||
75 | #define ACPI_PROCESSOR_LIMIT_THERMAL 1 | ||
76 | |||
77 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | ||
78 | ACPI_MODULE_NAME("processor_driver"); | ||
79 | |||
80 | MODULE_AUTHOR("Paul Diefenbaugh"); | ||
81 | MODULE_DESCRIPTION("ACPI Processor Driver"); | ||
82 | MODULE_LICENSE("GPL"); | ||
83 | |||
84 | static int acpi_processor_add(struct acpi_device *device); | ||
85 | static int acpi_processor_remove(struct acpi_device *device, int type); | ||
86 | #ifdef CONFIG_ACPI_PROCFS | ||
87 | static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); | ||
88 | #endif | ||
89 | static void acpi_processor_notify(struct acpi_device *device, u32 event); | ||
90 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); | ||
91 | static int acpi_processor_handle_eject(struct acpi_processor *pr); | ||
92 | |||
93 | |||
94 | static const struct acpi_device_id processor_device_ids[] = { | ||
95 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | ||
96 | {"ACPI0007", 0}, | ||
97 | {"", 0}, | ||
98 | }; | ||
99 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | ||
100 | |||
101 | static struct acpi_driver acpi_processor_driver = { | ||
102 | .name = "processor", | ||
103 | .class = ACPI_PROCESSOR_CLASS, | ||
104 | .ids = processor_device_ids, | ||
105 | .ops = { | ||
106 | .add = acpi_processor_add, | ||
107 | .remove = acpi_processor_remove, | ||
108 | .suspend = acpi_processor_suspend, | ||
109 | .resume = acpi_processor_resume, | ||
110 | .notify = acpi_processor_notify, | ||
111 | }, | ||
112 | }; | ||
113 | |||
114 | #define INSTALL_NOTIFY_HANDLER 1 | ||
115 | #define UNINSTALL_NOTIFY_HANDLER 2 | ||
116 | #ifdef CONFIG_ACPI_PROCFS | ||
117 | static const struct file_operations acpi_processor_info_fops = { | ||
118 | .owner = THIS_MODULE, | ||
119 | .open = acpi_processor_info_open_fs, | ||
120 | .read = seq_read, | ||
121 | .llseek = seq_lseek, | ||
122 | .release = single_release, | ||
123 | }; | ||
124 | #endif | ||
125 | |||
126 | DEFINE_PER_CPU(struct acpi_processor *, processors); | ||
127 | EXPORT_PER_CPU_SYMBOL(processors); | ||
128 | |||
129 | struct acpi_processor_errata errata __read_mostly; | ||
130 | |||
131 | /* -------------------------------------------------------------------------- | ||
132 | Errata Handling | ||
133 | -------------------------------------------------------------------------- */ | ||
134 | |||
135 | static int acpi_processor_errata_piix4(struct pci_dev *dev) | ||
136 | { | ||
137 | u8 value1 = 0; | ||
138 | u8 value2 = 0; | ||
139 | |||
140 | |||
141 | if (!dev) | ||
142 | return -EINVAL; | ||
143 | |||
144 | /* | ||
145 | * Note that 'dev' references the PIIX4 ACPI Controller. | ||
146 | */ | ||
147 | |||
148 | switch (dev->revision) { | ||
149 | case 0: | ||
150 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n")); | ||
151 | break; | ||
152 | case 1: | ||
153 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n")); | ||
154 | break; | ||
155 | case 2: | ||
156 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n")); | ||
157 | break; | ||
158 | case 3: | ||
159 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n")); | ||
160 | break; | ||
161 | default: | ||
162 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n")); | ||
163 | break; | ||
164 | } | ||
165 | |||
166 | switch (dev->revision) { | ||
167 | |||
168 | case 0: /* PIIX4 A-step */ | ||
169 | case 1: /* PIIX4 B-step */ | ||
170 | /* | ||
171 | * See specification changes #13 ("Manual Throttle Duty Cycle") | ||
172 | * and #14 ("Enabling and Disabling Manual Throttle"), plus | ||
173 | * erratum #5 ("STPCLK# Deassertion Time") from the January | ||
174 | * 2002 PIIX4 specification update. Applies to only older | ||
175 | * PIIX4 models. | ||
176 | */ | ||
177 | errata.piix4.throttle = 1; | ||
178 | |||
179 | case 2: /* PIIX4E */ | ||
180 | case 3: /* PIIX4M */ | ||
181 | /* | ||
182 | * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA | ||
183 | * Livelock") from the January 2002 PIIX4 specification update. | ||
184 | * Applies to all PIIX4 models. | ||
185 | */ | ||
186 | |||
187 | /* | ||
188 | * BM-IDE | ||
189 | * ------ | ||
190 | * Find the PIIX4 IDE Controller and get the Bus Master IDE | ||
191 | * Status register address. We'll use this later to read | ||
192 | * each IDE controller's DMA status to make sure we catch all | ||
193 | * DMA activity. | ||
194 | */ | ||
195 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
196 | PCI_DEVICE_ID_INTEL_82371AB, | ||
197 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
198 | if (dev) { | ||
199 | errata.piix4.bmisx = pci_resource_start(dev, 4); | ||
200 | pci_dev_put(dev); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Type-F DMA | ||
205 | * ---------- | ||
206 | * Find the PIIX4 ISA Controller and read the Motherboard | ||
207 | * DMA controller's status to see if Type-F (Fast) DMA mode | ||
208 | * is enabled (bit 7) on either channel. Note that we'll | ||
209 | * disable C3 support if this is enabled, as some legacy | ||
210 | * devices won't operate well if fast DMA is disabled. | ||
211 | */ | ||
212 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
213 | PCI_DEVICE_ID_INTEL_82371AB_0, | ||
214 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
215 | if (dev) { | ||
216 | pci_read_config_byte(dev, 0x76, &value1); | ||
217 | pci_read_config_byte(dev, 0x77, &value2); | ||
218 | if ((value1 & 0x80) || (value2 & 0x80)) | ||
219 | errata.piix4.fdma = 1; | ||
220 | pci_dev_put(dev); | ||
221 | } | ||
222 | |||
223 | break; | ||
224 | } | ||
225 | |||
226 | if (errata.piix4.bmisx) | ||
227 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
228 | "Bus master activity detection (BM-IDE) erratum enabled\n")); | ||
229 | if (errata.piix4.fdma) | ||
230 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
231 | "Type-F DMA livelock erratum (C3 disabled)\n")); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int acpi_processor_errata(struct acpi_processor *pr) | ||
237 | { | ||
238 | int result = 0; | ||
239 | struct pci_dev *dev = NULL; | ||
240 | |||
241 | |||
242 | if (!pr) | ||
243 | return -EINVAL; | ||
244 | |||
245 | /* | ||
246 | * PIIX4 | ||
247 | */ | ||
248 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
249 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | ||
250 | PCI_ANY_ID, NULL); | ||
251 | if (dev) { | ||
252 | result = acpi_processor_errata_piix4(dev); | ||
253 | pci_dev_put(dev); | ||
254 | } | ||
255 | |||
256 | return result; | ||
257 | } | ||
258 | |||
259 | /* -------------------------------------------------------------------------- | ||
260 | FS Interface (/proc) | ||
261 | -------------------------------------------------------------------------- */ | ||
262 | |||
263 | #ifdef CONFIG_ACPI_PROCFS | ||
264 | static struct proc_dir_entry *acpi_processor_dir = NULL; | ||
265 | |||
266 | static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) | ||
267 | { | ||
268 | struct acpi_processor *pr = seq->private; | ||
269 | |||
270 | |||
271 | if (!pr) | ||
272 | goto end; | ||
273 | |||
274 | seq_printf(seq, "processor id: %d\n" | ||
275 | "acpi id: %d\n" | ||
276 | "bus mastering control: %s\n" | ||
277 | "power management: %s\n" | ||
278 | "throttling control: %s\n" | ||
279 | "limit interface: %s\n", | ||
280 | pr->id, | ||
281 | pr->acpi_id, | ||
282 | pr->flags.bm_control ? "yes" : "no", | ||
283 | pr->flags.power ? "yes" : "no", | ||
284 | pr->flags.throttling ? "yes" : "no", | ||
285 | pr->flags.limit ? "yes" : "no"); | ||
286 | |||
287 | end: | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) | ||
292 | { | ||
293 | return single_open(file, acpi_processor_info_seq_show, | ||
294 | PDE(inode)->data); | ||
295 | } | ||
296 | |||
297 | static int __cpuinit acpi_processor_add_fs(struct acpi_device *device) | ||
298 | { | ||
299 | struct proc_dir_entry *entry = NULL; | ||
300 | |||
301 | |||
302 | if (!acpi_device_dir(device)) { | ||
303 | acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), | ||
304 | acpi_processor_dir); | ||
305 | if (!acpi_device_dir(device)) | ||
306 | return -ENODEV; | ||
307 | } | ||
308 | |||
309 | /* 'info' [R] */ | ||
310 | entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO, | ||
311 | S_IRUGO, acpi_device_dir(device), | ||
312 | &acpi_processor_info_fops, | ||
313 | acpi_driver_data(device)); | ||
314 | if (!entry) | ||
315 | return -EIO; | ||
316 | |||
317 | /* 'throttling' [R/W] */ | ||
318 | entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING, | ||
319 | S_IFREG | S_IRUGO | S_IWUSR, | ||
320 | acpi_device_dir(device), | ||
321 | &acpi_processor_throttling_fops, | ||
322 | acpi_driver_data(device)); | ||
323 | if (!entry) | ||
324 | return -EIO; | ||
325 | |||
326 | /* 'limit' [R/W] */ | ||
327 | entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT, | ||
328 | S_IFREG | S_IRUGO | S_IWUSR, | ||
329 | acpi_device_dir(device), | ||
330 | &acpi_processor_limit_fops, | ||
331 | acpi_driver_data(device)); | ||
332 | if (!entry) | ||
333 | return -EIO; | ||
334 | return 0; | ||
335 | } | ||
336 | static int acpi_processor_remove_fs(struct acpi_device *device) | ||
337 | { | ||
338 | |||
339 | if (acpi_device_dir(device)) { | ||
340 | remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, | ||
341 | acpi_device_dir(device)); | ||
342 | remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, | ||
343 | acpi_device_dir(device)); | ||
344 | remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, | ||
345 | acpi_device_dir(device)); | ||
346 | remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); | ||
347 | acpi_device_dir(device) = NULL; | ||
348 | } | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | #else | ||
353 | static inline int acpi_processor_add_fs(struct acpi_device *device) | ||
354 | { | ||
355 | return 0; | ||
356 | } | ||
357 | static inline int acpi_processor_remove_fs(struct acpi_device *device) | ||
358 | { | ||
359 | return 0; | ||
360 | } | ||
361 | #endif | ||
362 | |||
363 | /* -------------------------------------------------------------------------- | ||
364 | Driver Interface | ||
365 | -------------------------------------------------------------------------- */ | ||
366 | |||
367 | static int acpi_processor_get_info(struct acpi_device *device) | ||
368 | { | ||
369 | acpi_status status = 0; | ||
370 | union acpi_object object = { 0 }; | ||
371 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | ||
372 | struct acpi_processor *pr; | ||
373 | int cpu_index, device_declaration = 0; | ||
374 | static int cpu0_initialized; | ||
375 | |||
376 | pr = acpi_driver_data(device); | ||
377 | if (!pr) | ||
378 | return -EINVAL; | ||
379 | |||
380 | if (num_online_cpus() > 1) | ||
381 | errata.smp = TRUE; | ||
382 | |||
383 | acpi_processor_errata(pr); | ||
384 | |||
385 | /* | ||
386 | * Check to see if we have bus mastering arbitration control. This | ||
387 | * is required for proper C3 usage (to maintain cache coherency). | ||
388 | */ | ||
389 | if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { | ||
390 | pr->flags.bm_control = 1; | ||
391 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
392 | "Bus mastering arbitration control present\n")); | ||
393 | } else | ||
394 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
395 | "No bus mastering arbitration control\n")); | ||
396 | |||
397 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { | ||
398 | /* Declared with "Processor" statement; match ProcessorID */ | ||
399 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | ||
400 | if (ACPI_FAILURE(status)) { | ||
401 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); | ||
402 | return -ENODEV; | ||
403 | } | ||
404 | |||
405 | /* | ||
406 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | ||
407 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in | ||
408 | * arch/xxx/acpi.c | ||
409 | */ | ||
410 | pr->acpi_id = object.processor.proc_id; | ||
411 | } else { | ||
412 | /* | ||
413 | * Declared with "Device" statement; match _UID. | ||
414 | * Note that we don't handle string _UIDs yet. | ||
415 | */ | ||
416 | unsigned long long value; | ||
417 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | ||
418 | NULL, &value); | ||
419 | if (ACPI_FAILURE(status)) { | ||
420 | printk(KERN_ERR PREFIX | ||
421 | "Evaluating processor _UID [%#x]\n", status); | ||
422 | return -ENODEV; | ||
423 | } | ||
424 | device_declaration = 1; | ||
425 | pr->acpi_id = value; | ||
426 | } | ||
427 | cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); | ||
428 | |||
429 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
430 | if (!cpu0_initialized && (cpu_index == -1) && | ||
431 | (num_online_cpus() == 1)) { | ||
432 | cpu_index = 0; | ||
433 | } | ||
434 | |||
435 | cpu0_initialized = 1; | ||
436 | |||
437 | pr->id = cpu_index; | ||
438 | |||
439 | /* | ||
440 | * Extra Processor objects may be enumerated on MP systems with | ||
441 | * less than the max # of CPUs. They should be ignored _iff | ||
442 | * they are physically not present. | ||
443 | */ | ||
444 | if (pr->id == -1) { | ||
445 | if (ACPI_FAILURE | ||
446 | (acpi_processor_hotadd_init(pr->handle, &pr->id))) { | ||
447 | return -ENODEV; | ||
448 | } | ||
449 | } | ||
450 | /* | ||
451 | * On some boxes several processors use the same processor bus id. | ||
452 | * But they are located in different scope. For example: | ||
453 | * \_SB.SCK0.CPU0 | ||
454 | * \_SB.SCK1.CPU0 | ||
455 | * Rename the processor device bus id. And the new bus id will be | ||
456 | * generated as the following format: | ||
457 | * CPU+CPU ID. | ||
458 | */ | ||
459 | sprintf(acpi_device_bid(device), "CPU%X", pr->id); | ||
460 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, | ||
461 | pr->acpi_id)); | ||
462 | |||
463 | if (!object.processor.pblk_address) | ||
464 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); | ||
465 | else if (object.processor.pblk_length != 6) | ||
466 | printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", | ||
467 | object.processor.pblk_length); | ||
468 | else { | ||
469 | pr->throttling.address = object.processor.pblk_address; | ||
470 | pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; | ||
471 | pr->throttling.duty_width = acpi_gbl_FADT.duty_width; | ||
472 | |||
473 | pr->pblk = object.processor.pblk_address; | ||
474 | |||
475 | /* | ||
476 | * We don't care about error returns - we just try to mark | ||
477 | * these reserved so that nobody else is confused into thinking | ||
478 | * that this region might be unused.. | ||
479 | * | ||
480 | * (In particular, allocating the IO range for Cardbus) | ||
481 | */ | ||
482 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | ||
483 | } | ||
484 | |||
485 | /* | ||
486 | * If ACPI describes a slot number for this CPU, we can use it | ||
487 | * ensure we get the right value in the "physical id" field | ||
488 | * of /proc/cpuinfo | ||
489 | */ | ||
490 | status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); | ||
491 | if (ACPI_SUCCESS(status)) | ||
492 | arch_fix_phys_package_id(pr->id, object.integer.value); | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | static DEFINE_PER_CPU(void *, processor_device_array); | ||
498 | |||
499 | static void acpi_processor_notify(struct acpi_device *device, u32 event) | ||
500 | { | ||
501 | struct acpi_processor *pr = acpi_driver_data(device); | ||
502 | int saved; | ||
503 | |||
504 | if (!pr) | ||
505 | return; | ||
506 | |||
507 | switch (event) { | ||
508 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: | ||
509 | saved = pr->performance_platform_limit; | ||
510 | acpi_processor_ppc_has_changed(pr, 1); | ||
511 | if (saved == pr->performance_platform_limit) | ||
512 | break; | ||
513 | acpi_bus_generate_proc_event(device, event, | ||
514 | pr->performance_platform_limit); | ||
515 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
516 | dev_name(&device->dev), event, | ||
517 | pr->performance_platform_limit); | ||
518 | break; | ||
519 | case ACPI_PROCESSOR_NOTIFY_POWER: | ||
520 | acpi_processor_cst_has_changed(pr); | ||
521 | acpi_bus_generate_proc_event(device, event, 0); | ||
522 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
523 | dev_name(&device->dev), event, 0); | ||
524 | break; | ||
525 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: | ||
526 | acpi_processor_tstate_has_changed(pr); | ||
527 | acpi_bus_generate_proc_event(device, event, 0); | ||
528 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
529 | dev_name(&device->dev), event, 0); | ||
530 | default: | ||
531 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
532 | "Unsupported event [0x%x]\n", event)); | ||
533 | break; | ||
534 | } | ||
535 | |||
536 | return; | ||
537 | } | ||
538 | |||
539 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | ||
540 | unsigned long action, void *hcpu) | ||
541 | { | ||
542 | unsigned int cpu = (unsigned long)hcpu; | ||
543 | struct acpi_processor *pr = per_cpu(processors, cpu); | ||
544 | |||
545 | if (action == CPU_ONLINE && pr) { | ||
546 | acpi_processor_ppc_has_changed(pr, 0); | ||
547 | acpi_processor_cst_has_changed(pr); | ||
548 | acpi_processor_tstate_has_changed(pr); | ||
549 | } | ||
550 | return NOTIFY_OK; | ||
551 | } | ||
552 | |||
553 | static struct notifier_block acpi_cpu_notifier = | ||
554 | { | ||
555 | .notifier_call = acpi_cpu_soft_notify, | ||
556 | }; | ||
557 | |||
558 | static int __cpuinit acpi_processor_add(struct acpi_device *device) | ||
559 | { | ||
560 | struct acpi_processor *pr = NULL; | ||
561 | int result = 0; | ||
562 | struct sys_device *sysdev; | ||
563 | |||
564 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); | ||
565 | if (!pr) | ||
566 | return -ENOMEM; | ||
567 | |||
568 | if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
569 | kfree(pr); | ||
570 | return -ENOMEM; | ||
571 | } | ||
572 | |||
573 | pr->handle = device->handle; | ||
574 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | ||
575 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | ||
576 | device->driver_data = pr; | ||
577 | |||
578 | result = acpi_processor_get_info(device); | ||
579 | if (result) { | ||
580 | /* Processor is physically not present */ | ||
581 | return 0; | ||
582 | } | ||
583 | |||
584 | BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); | ||
585 | |||
586 | /* | ||
587 | * Buggy BIOS check | ||
588 | * ACPI id of processors can be reported wrongly by the BIOS. | ||
589 | * Don't trust it blindly | ||
590 | */ | ||
591 | if (per_cpu(processor_device_array, pr->id) != NULL && | ||
592 | per_cpu(processor_device_array, pr->id) != device) { | ||
593 | printk(KERN_WARNING "BIOS reported wrong ACPI id " | ||
594 | "for the processor\n"); | ||
595 | result = -ENODEV; | ||
596 | goto err_free_cpumask; | ||
597 | } | ||
598 | per_cpu(processor_device_array, pr->id) = device; | ||
599 | |||
600 | per_cpu(processors, pr->id) = pr; | ||
601 | |||
602 | result = acpi_processor_add_fs(device); | ||
603 | if (result) | ||
604 | goto err_free_cpumask; | ||
605 | |||
606 | sysdev = get_cpu_sysdev(pr->id); | ||
607 | if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) { | ||
608 | result = -EFAULT; | ||
609 | goto err_remove_fs; | ||
610 | } | ||
611 | |||
612 | #ifdef CONFIG_CPU_FREQ | ||
613 | acpi_processor_ppc_has_changed(pr, 0); | ||
614 | #endif | ||
615 | acpi_processor_get_throttling_info(pr); | ||
616 | acpi_processor_get_limit_info(pr); | ||
617 | |||
618 | |||
619 | acpi_processor_power_init(pr, device); | ||
620 | |||
621 | pr->cdev = thermal_cooling_device_register("Processor", device, | ||
622 | &processor_cooling_ops); | ||
623 | if (IS_ERR(pr->cdev)) { | ||
624 | result = PTR_ERR(pr->cdev); | ||
625 | goto err_power_exit; | ||
626 | } | ||
627 | |||
628 | dev_dbg(&device->dev, "registered as cooling_device%d\n", | ||
629 | pr->cdev->id); | ||
630 | |||
631 | result = sysfs_create_link(&device->dev.kobj, | ||
632 | &pr->cdev->device.kobj, | ||
633 | "thermal_cooling"); | ||
634 | if (result) { | ||
635 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
636 | goto err_thermal_unregister; | ||
637 | } | ||
638 | result = sysfs_create_link(&pr->cdev->device.kobj, | ||
639 | &device->dev.kobj, | ||
640 | "device"); | ||
641 | if (result) { | ||
642 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
643 | goto err_remove_sysfs; | ||
644 | } | ||
645 | |||
646 | return 0; | ||
647 | |||
648 | err_remove_sysfs: | ||
649 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
650 | err_thermal_unregister: | ||
651 | thermal_cooling_device_unregister(pr->cdev); | ||
652 | err_power_exit: | ||
653 | acpi_processor_power_exit(pr, device); | ||
654 | err_remove_fs: | ||
655 | acpi_processor_remove_fs(device); | ||
656 | err_free_cpumask: | ||
657 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
658 | |||
659 | return result; | ||
660 | } | ||
661 | |||
662 | static int acpi_processor_remove(struct acpi_device *device, int type) | ||
663 | { | ||
664 | struct acpi_processor *pr = NULL; | ||
665 | |||
666 | |||
667 | if (!device || !acpi_driver_data(device)) | ||
668 | return -EINVAL; | ||
669 | |||
670 | pr = acpi_driver_data(device); | ||
671 | |||
672 | if (pr->id >= nr_cpu_ids) | ||
673 | goto free; | ||
674 | |||
675 | if (type == ACPI_BUS_REMOVAL_EJECT) { | ||
676 | if (acpi_processor_handle_eject(pr)) | ||
677 | return -EINVAL; | ||
678 | } | ||
679 | |||
680 | acpi_processor_power_exit(pr, device); | ||
681 | |||
682 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | ||
683 | |||
684 | acpi_processor_remove_fs(device); | ||
685 | |||
686 | if (pr->cdev) { | ||
687 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
688 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | ||
689 | thermal_cooling_device_unregister(pr->cdev); | ||
690 | pr->cdev = NULL; | ||
691 | } | ||
692 | |||
693 | per_cpu(processors, pr->id) = NULL; | ||
694 | per_cpu(processor_device_array, pr->id) = NULL; | ||
695 | |||
696 | free: | ||
697 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
698 | kfree(pr); | ||
699 | |||
700 | return 0; | ||
701 | } | ||
702 | |||
703 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
704 | /**************************************************************************** | ||
705 | * Acpi processor hotplug support * | ||
706 | ****************************************************************************/ | ||
707 | |||
708 | static int is_processor_present(acpi_handle handle) | ||
709 | { | ||
710 | acpi_status status; | ||
711 | unsigned long long sta = 0; | ||
712 | |||
713 | |||
714 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
715 | |||
716 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT)) | ||
717 | return 1; | ||
718 | |||
719 | /* | ||
720 | * _STA is mandatory for a processor that supports hot plug | ||
721 | */ | ||
722 | if (status == AE_NOT_FOUND) | ||
723 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
724 | "Processor does not support hot plug\n")); | ||
725 | else | ||
726 | ACPI_EXCEPTION((AE_INFO, status, | ||
727 | "Processor Device is not present")); | ||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | static | ||
732 | int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) | ||
733 | { | ||
734 | acpi_handle phandle; | ||
735 | struct acpi_device *pdev; | ||
736 | |||
737 | |||
738 | if (acpi_get_parent(handle, &phandle)) { | ||
739 | return -ENODEV; | ||
740 | } | ||
741 | |||
742 | if (acpi_bus_get_device(phandle, &pdev)) { | ||
743 | return -ENODEV; | ||
744 | } | ||
745 | |||
746 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { | ||
747 | return -ENODEV; | ||
748 | } | ||
749 | |||
750 | return 0; | ||
751 | } | ||
752 | |||
753 | static void __ref acpi_processor_hotplug_notify(acpi_handle handle, | ||
754 | u32 event, void *data) | ||
755 | { | ||
756 | struct acpi_processor *pr; | ||
757 | struct acpi_device *device = NULL; | ||
758 | int result; | ||
759 | |||
760 | |||
761 | switch (event) { | ||
762 | case ACPI_NOTIFY_BUS_CHECK: | ||
763 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
764 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
765 | "Processor driver received %s event\n", | ||
766 | (event == ACPI_NOTIFY_BUS_CHECK) ? | ||
767 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK")); | ||
768 | |||
769 | if (!is_processor_present(handle)) | ||
770 | break; | ||
771 | |||
772 | if (acpi_bus_get_device(handle, &device)) { | ||
773 | result = acpi_processor_device_add(handle, &device); | ||
774 | if (result) | ||
775 | printk(KERN_ERR PREFIX | ||
776 | "Unable to add the device\n"); | ||
777 | break; | ||
778 | } | ||
779 | break; | ||
780 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
781 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
782 | "received ACPI_NOTIFY_EJECT_REQUEST\n")); | ||
783 | |||
784 | if (acpi_bus_get_device(handle, &device)) { | ||
785 | printk(KERN_ERR PREFIX | ||
786 | "Device don't exist, dropping EJECT\n"); | ||
787 | break; | ||
788 | } | ||
789 | pr = acpi_driver_data(device); | ||
790 | if (!pr) { | ||
791 | printk(KERN_ERR PREFIX | ||
792 | "Driver data is NULL, dropping EJECT\n"); | ||
793 | return; | ||
794 | } | ||
795 | break; | ||
796 | default: | ||
797 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
798 | "Unsupported event [0x%x]\n", event)); | ||
799 | break; | ||
800 | } | ||
801 | |||
802 | return; | ||
803 | } | ||
804 | |||
805 | static acpi_status | ||
806 | processor_walk_namespace_cb(acpi_handle handle, | ||
807 | u32 lvl, void *context, void **rv) | ||
808 | { | ||
809 | acpi_status status; | ||
810 | int *action = context; | ||
811 | acpi_object_type type = 0; | ||
812 | |||
813 | status = acpi_get_type(handle, &type); | ||
814 | if (ACPI_FAILURE(status)) | ||
815 | return (AE_OK); | ||
816 | |||
817 | if (type != ACPI_TYPE_PROCESSOR) | ||
818 | return (AE_OK); | ||
819 | |||
820 | switch (*action) { | ||
821 | case INSTALL_NOTIFY_HANDLER: | ||
822 | acpi_install_notify_handler(handle, | ||
823 | ACPI_SYSTEM_NOTIFY, | ||
824 | acpi_processor_hotplug_notify, | ||
825 | NULL); | ||
826 | break; | ||
827 | case UNINSTALL_NOTIFY_HANDLER: | ||
828 | acpi_remove_notify_handler(handle, | ||
829 | ACPI_SYSTEM_NOTIFY, | ||
830 | acpi_processor_hotplug_notify); | ||
831 | break; | ||
832 | default: | ||
833 | break; | ||
834 | } | ||
835 | |||
836 | return (AE_OK); | ||
837 | } | ||
838 | |||
839 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | ||
840 | { | ||
841 | |||
842 | if (!is_processor_present(handle)) { | ||
843 | return AE_ERROR; | ||
844 | } | ||
845 | |||
846 | if (acpi_map_lsapic(handle, p_cpu)) | ||
847 | return AE_ERROR; | ||
848 | |||
849 | if (arch_register_cpu(*p_cpu)) { | ||
850 | acpi_unmap_lsapic(*p_cpu); | ||
851 | return AE_ERROR; | ||
852 | } | ||
853 | |||
854 | return AE_OK; | ||
855 | } | ||
856 | |||
857 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
858 | { | ||
859 | if (cpu_online(pr->id)) | ||
860 | cpu_down(pr->id); | ||
861 | |||
862 | arch_unregister_cpu(pr->id); | ||
863 | acpi_unmap_lsapic(pr->id); | ||
864 | return (0); | ||
865 | } | ||
866 | #else | ||
867 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | ||
868 | { | ||
869 | return AE_ERROR; | ||
870 | } | ||
871 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
872 | { | ||
873 | return (-EINVAL); | ||
874 | } | ||
875 | #endif | ||
876 | |||
877 | static | ||
878 | void acpi_processor_install_hotplug_notify(void) | ||
879 | { | ||
880 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
881 | int action = INSTALL_NOTIFY_HANDLER; | ||
882 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | ||
883 | ACPI_ROOT_OBJECT, | ||
884 | ACPI_UINT32_MAX, | ||
885 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
886 | #endif | ||
887 | register_hotcpu_notifier(&acpi_cpu_notifier); | ||
888 | } | ||
889 | |||
890 | static | ||
891 | void acpi_processor_uninstall_hotplug_notify(void) | ||
892 | { | ||
893 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
894 | int action = UNINSTALL_NOTIFY_HANDLER; | ||
895 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | ||
896 | ACPI_ROOT_OBJECT, | ||
897 | ACPI_UINT32_MAX, | ||
898 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
899 | #endif | ||
900 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | ||
901 | } | ||
902 | |||
903 | /* | ||
904 | * We keep the driver loaded even when ACPI is not running. | ||
905 | * This is needed for the powernow-k8 driver, that works even without | ||
906 | * ACPI, but needs symbols from this driver | ||
907 | */ | ||
908 | |||
909 | static int __init acpi_processor_init(void) | ||
910 | { | ||
911 | int result = 0; | ||
912 | |||
913 | if (acpi_disabled) | ||
914 | return 0; | ||
915 | |||
916 | memset(&errata, 0, sizeof(errata)); | ||
917 | |||
918 | #ifdef CONFIG_ACPI_PROCFS | ||
919 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
920 | if (!acpi_processor_dir) | ||
921 | return -ENOMEM; | ||
922 | #endif | ||
923 | result = cpuidle_register_driver(&acpi_idle_driver); | ||
924 | if (result < 0) | ||
925 | goto out_proc; | ||
926 | |||
927 | result = acpi_bus_register_driver(&acpi_processor_driver); | ||
928 | if (result < 0) | ||
929 | goto out_cpuidle; | ||
930 | |||
931 | acpi_processor_install_hotplug_notify(); | ||
932 | |||
933 | acpi_thermal_cpufreq_init(); | ||
934 | |||
935 | acpi_processor_ppc_init(); | ||
936 | |||
937 | acpi_processor_throttling_init(); | ||
938 | |||
939 | return 0; | ||
940 | |||
941 | out_cpuidle: | ||
942 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
943 | |||
944 | out_proc: | ||
945 | #ifdef CONFIG_ACPI_PROCFS | ||
946 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
947 | #endif | ||
948 | |||
949 | return result; | ||
950 | } | ||
951 | |||
952 | static void __exit acpi_processor_exit(void) | ||
953 | { | ||
954 | if (acpi_disabled) | ||
955 | return; | ||
956 | |||
957 | acpi_processor_ppc_exit(); | ||
958 | |||
959 | acpi_thermal_cpufreq_exit(); | ||
960 | |||
961 | acpi_processor_uninstall_hotplug_notify(); | ||
962 | |||
963 | acpi_bus_unregister_driver(&acpi_processor_driver); | ||
964 | |||
965 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
966 | |||
967 | #ifdef CONFIG_ACPI_PROCFS | ||
968 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
969 | #endif | ||
970 | |||
971 | return; | ||
972 | } | ||
973 | |||
974 | module_init(acpi_processor_init); | ||
975 | module_exit(acpi_processor_exit); | ||
976 | |||
977 | EXPORT_SYMBOL(acpi_processor_set_thermal_limit); | ||
978 | |||
979 | MODULE_ALIAS("processor"); | ||
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 37dfce749398..5939e7f7d8e9 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/cpufreq.h> | 34 | #include <linux/cpufreq.h> |
35 | #include <linux/slab.h> | ||
35 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
36 | #include <linux/seq_file.h> | 37 | #include <linux/seq_file.h> |
37 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c deleted file mode 100644 index e306ba9aa34e..000000000000 --- a/drivers/acpi/processor_pdc.c +++ /dev/null | |||
@@ -1,209 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005 Intel Corporation | ||
3 | * Copyright (C) 2009 Hewlett-Packard Development Company, L.P. | ||
4 | * | ||
5 | * Alex Chiang <achiang@hp.com> | ||
6 | * - Unified x86/ia64 implementations | ||
7 | * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
8 | * - Added _PDC for platforms with Intel CPUs | ||
9 | */ | ||
10 | #include <linux/dmi.h> | ||
11 | |||
12 | #include <acpi/acpi_drivers.h> | ||
13 | #include <acpi/processor.h> | ||
14 | |||
15 | #include "internal.h" | ||
16 | |||
17 | #define PREFIX "ACPI: " | ||
18 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | ||
19 | ACPI_MODULE_NAME("processor_pdc"); | ||
20 | |||
21 | static int set_no_mwait(const struct dmi_system_id *id) | ||
22 | { | ||
23 | printk(KERN_NOTICE PREFIX "%s detected - " | ||
24 | "disabling mwait for CPU C-states\n", id->ident); | ||
25 | idle_nomwait = 1; | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { | ||
30 | { | ||
31 | set_no_mwait, "IFL91 board", { | ||
32 | DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), | ||
33 | DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"), | ||
34 | DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"), | ||
35 | DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL}, | ||
36 | { | ||
37 | set_no_mwait, "Extensa 5220", { | ||
38 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), | ||
39 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
40 | DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), | ||
41 | DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, | ||
42 | {}, | ||
43 | }; | ||
44 | |||
45 | static void acpi_set_pdc_bits(u32 *buf) | ||
46 | { | ||
47 | buf[0] = ACPI_PDC_REVISION_ID; | ||
48 | buf[1] = 1; | ||
49 | |||
50 | /* Enable coordination with firmware's _TSD info */ | ||
51 | buf[2] = ACPI_PDC_SMP_T_SWCOORD; | ||
52 | |||
53 | /* Twiddle arch-specific bits needed for _PDC */ | ||
54 | arch_acpi_set_pdc_bits(buf); | ||
55 | } | ||
56 | |||
57 | static struct acpi_object_list *acpi_processor_alloc_pdc(void) | ||
58 | { | ||
59 | struct acpi_object_list *obj_list; | ||
60 | union acpi_object *obj; | ||
61 | u32 *buf; | ||
62 | |||
63 | /* allocate and initialize pdc. It will be used later. */ | ||
64 | obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); | ||
65 | if (!obj_list) { | ||
66 | printk(KERN_ERR "Memory allocation error\n"); | ||
67 | return NULL; | ||
68 | } | ||
69 | |||
70 | obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); | ||
71 | if (!obj) { | ||
72 | printk(KERN_ERR "Memory allocation error\n"); | ||
73 | kfree(obj_list); | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | buf = kmalloc(12, GFP_KERNEL); | ||
78 | if (!buf) { | ||
79 | printk(KERN_ERR "Memory allocation error\n"); | ||
80 | kfree(obj); | ||
81 | kfree(obj_list); | ||
82 | return NULL; | ||
83 | } | ||
84 | |||
85 | acpi_set_pdc_bits(buf); | ||
86 | |||
87 | obj->type = ACPI_TYPE_BUFFER; | ||
88 | obj->buffer.length = 12; | ||
89 | obj->buffer.pointer = (u8 *) buf; | ||
90 | obj_list->count = 1; | ||
91 | obj_list->pointer = obj; | ||
92 | |||
93 | return obj_list; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * _PDC is required for a BIOS-OS handshake for most of the newer | ||
98 | * ACPI processor features. | ||
99 | */ | ||
100 | static int | ||
101 | acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) | ||
102 | { | ||
103 | acpi_status status = AE_OK; | ||
104 | |||
105 | if (idle_nomwait) { | ||
106 | /* | ||
107 | * If mwait is disabled for CPU C-states, the C2C3_FFH access | ||
108 | * mode will be disabled in the parameter of _PDC object. | ||
109 | * Of course C1_FFH access mode will also be disabled. | ||
110 | */ | ||
111 | union acpi_object *obj; | ||
112 | u32 *buffer = NULL; | ||
113 | |||
114 | obj = pdc_in->pointer; | ||
115 | buffer = (u32 *)(obj->buffer.pointer); | ||
116 | buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH); | ||
117 | |||
118 | } | ||
119 | status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL); | ||
120 | |||
121 | if (ACPI_FAILURE(status)) | ||
122 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
123 | "Could not evaluate _PDC, using legacy perf. control.\n")); | ||
124 | |||
125 | return status; | ||
126 | } | ||
127 | |||
128 | static int early_pdc_done; | ||
129 | |||
130 | void acpi_processor_set_pdc(acpi_handle handle) | ||
131 | { | ||
132 | struct acpi_object_list *obj_list; | ||
133 | |||
134 | if (arch_has_acpi_pdc() == false) | ||
135 | return; | ||
136 | |||
137 | if (early_pdc_done) | ||
138 | return; | ||
139 | |||
140 | obj_list = acpi_processor_alloc_pdc(); | ||
141 | if (!obj_list) | ||
142 | return; | ||
143 | |||
144 | acpi_processor_eval_pdc(handle, obj_list); | ||
145 | |||
146 | kfree(obj_list->pointer->buffer.pointer); | ||
147 | kfree(obj_list->pointer); | ||
148 | kfree(obj_list); | ||
149 | } | ||
150 | EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); | ||
151 | |||
152 | static int early_pdc_optin; | ||
153 | static int set_early_pdc_optin(const struct dmi_system_id *id) | ||
154 | { | ||
155 | early_pdc_optin = 1; | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int param_early_pdc_optin(char *s) | ||
160 | { | ||
161 | early_pdc_optin = 1; | ||
162 | return 1; | ||
163 | } | ||
164 | __setup("acpi_early_pdc_eval", param_early_pdc_optin); | ||
165 | |||
166 | static struct dmi_system_id __cpuinitdata early_pdc_optin_table[] = { | ||
167 | { | ||
168 | set_early_pdc_optin, "HP Envy", { | ||
169 | DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"), | ||
170 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Envy") }, NULL}, | ||
171 | { | ||
172 | set_early_pdc_optin, "HP Pavilion dv6", { | ||
173 | DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"), | ||
174 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv6") }, NULL}, | ||
175 | { | ||
176 | set_early_pdc_optin, "HP Pavilion dv7", { | ||
177 | DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"), | ||
178 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv7") }, NULL}, | ||
179 | {}, | ||
180 | }; | ||
181 | |||
182 | static acpi_status | ||
183 | early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
184 | { | ||
185 | acpi_processor_set_pdc(handle); | ||
186 | return AE_OK; | ||
187 | } | ||
188 | |||
189 | void __init acpi_early_processor_set_pdc(void) | ||
190 | { | ||
191 | /* | ||
192 | * Check whether the system is DMI table. If yes, OSPM | ||
193 | * should not use mwait for CPU-states. | ||
194 | */ | ||
195 | dmi_check_system(processor_idle_dmi_table); | ||
196 | |||
197 | /* | ||
198 | * Allow systems to opt-in to early _PDC evaluation. | ||
199 | */ | ||
200 | dmi_check_system(early_pdc_optin_table); | ||
201 | if (!early_pdc_optin) | ||
202 | return; | ||
203 | |||
204 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, | ||
205 | ACPI_UINT32_MAX, | ||
206 | early_init_pdc, NULL, NULL, NULL); | ||
207 | |||
208 | early_pdc_done = 1; | ||
209 | } | ||
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index d648a9860b88..ba1bd263d903 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | #include <linux/slab.h> | ||
33 | 34 | ||
34 | #ifdef CONFIG_X86 | 35 | #ifdef CONFIG_X86 |
35 | #include <asm/cpufeature.h> | 36 | #include <asm/cpufeature.h> |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 7ded7542fc9d..9ade1a5b32ed 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/slab.h> | ||
31 | #include <linux/init.h> | 32 | #include <linux/init.h> |
32 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
33 | #include <linux/cpufreq.h> | 34 | #include <linux/cpufreq.h> |
@@ -1133,9 +1134,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
1133 | int result = 0; | 1134 | int result = 0; |
1134 | struct acpi_processor_throttling *pthrottling; | 1135 | struct acpi_processor_throttling *pthrottling; |
1135 | 1136 | ||
1136 | if (!pr) | ||
1137 | return -EINVAL; | ||
1138 | |||
1139 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 1137 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
1140 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", | 1138 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", |
1141 | pr->throttling.address, | 1139 | pr->throttling.address, |
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index b16ddbf23a9c..4ff76e8174eb 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/module.h> | 29 | #include <linux/module.h> |
29 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
30 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
@@ -217,6 +218,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy, | |||
217 | case POWER_SUPPLY_PROP_TECHNOLOGY: | 218 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
218 | val->intval = acpi_battery_technology(battery); | 219 | val->intval = acpi_battery_technology(battery); |
219 | break; | 220 | break; |
221 | case POWER_SUPPLY_PROP_CYCLE_COUNT: | ||
222 | val->intval = battery->cycle_count; | ||
223 | break; | ||
220 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | 224 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
221 | val->intval = battery->design_voltage * | 225 | val->intval = battery->design_voltage * |
222 | acpi_battery_vscale(battery) * 1000; | 226 | acpi_battery_vscale(battery) * 1000; |
@@ -276,6 +280,7 @@ static enum power_supply_property sbs_charge_battery_props[] = { | |||
276 | POWER_SUPPLY_PROP_STATUS, | 280 | POWER_SUPPLY_PROP_STATUS, |
277 | POWER_SUPPLY_PROP_PRESENT, | 281 | POWER_SUPPLY_PROP_PRESENT, |
278 | POWER_SUPPLY_PROP_TECHNOLOGY, | 282 | POWER_SUPPLY_PROP_TECHNOLOGY, |
283 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
279 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 284 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
280 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 285 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
281 | POWER_SUPPLY_PROP_CURRENT_NOW, | 286 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -560,6 +565,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) | |||
560 | battery->design_voltage * acpi_battery_vscale(battery)); | 565 | battery->design_voltage * acpi_battery_vscale(battery)); |
561 | seq_printf(seq, "design capacity warning: unknown\n"); | 566 | seq_printf(seq, "design capacity warning: unknown\n"); |
562 | seq_printf(seq, "design capacity low: unknown\n"); | 567 | seq_printf(seq, "design capacity low: unknown\n"); |
568 | seq_printf(seq, "cycle count: %i\n", battery->cycle_count); | ||
563 | seq_printf(seq, "capacity granularity 1: unknown\n"); | 569 | seq_printf(seq, "capacity granularity 1: unknown\n"); |
564 | seq_printf(seq, "capacity granularity 2: unknown\n"); | 570 | seq_printf(seq, "capacity granularity 2: unknown\n"); |
565 | seq_printf(seq, "model number: %s\n", battery->device_name); | 571 | seq_printf(seq, "model number: %s\n", battery->device_name); |
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index fd09229282ea..36704b887ccf 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <acpi/acpi_bus.h> | 11 | #include <acpi/acpi_bus.h> |
12 | #include <acpi/acpi_drivers.h> | 12 | #include <acpi/acpi_drivers.h> |
13 | #include <linux/wait.h> | 13 | #include <linux/wait.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | #include "sbshc.h" | 17 | #include "sbshc.h" |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fb7fc24fe727..0338f513a010 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -4,10 +4,12 @@ | |||
4 | 4 | ||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/slab.h> | ||
7 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
8 | #include <linux/acpi.h> | 9 | #include <linux/acpi.h> |
9 | #include <linux/signal.h> | 10 | #include <linux/signal.h> |
10 | #include <linux/kthread.h> | 11 | #include <linux/kthread.h> |
12 | #include <linux/dmi.h> | ||
11 | 13 | ||
12 | #include <acpi/acpi_drivers.h> | 14 | #include <acpi/acpi_drivers.h> |
13 | 15 | ||
@@ -1032,6 +1034,41 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
1032 | list_add_tail(&id->list, &device->pnp.ids); | 1034 | list_add_tail(&id->list, &device->pnp.ids); |
1033 | } | 1035 | } |
1034 | 1036 | ||
1037 | /* | ||
1038 | * Old IBM workstations have a DSDT bug wherein the SMBus object | ||
1039 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" | ||
1040 | * prefix. Work around this. | ||
1041 | */ | ||
1042 | static int acpi_ibm_smbus_match(struct acpi_device *device) | ||
1043 | { | ||
1044 | acpi_handle h_dummy; | ||
1045 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
1046 | int result; | ||
1047 | |||
1048 | if (!dmi_name_in_vendors("IBM")) | ||
1049 | return -ENODEV; | ||
1050 | |||
1051 | /* Look for SMBS object */ | ||
1052 | result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path); | ||
1053 | if (result) | ||
1054 | return result; | ||
1055 | |||
1056 | if (strcmp("SMBS", path.pointer)) { | ||
1057 | result = -ENODEV; | ||
1058 | goto out; | ||
1059 | } | ||
1060 | |||
1061 | /* Does it have the necessary (but misnamed) methods? */ | ||
1062 | result = -ENODEV; | ||
1063 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) && | ||
1064 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) && | ||
1065 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy))) | ||
1066 | result = 0; | ||
1067 | out: | ||
1068 | kfree(path.pointer); | ||
1069 | return result; | ||
1070 | } | ||
1071 | |||
1035 | static void acpi_device_set_id(struct acpi_device *device) | 1072 | static void acpi_device_set_id(struct acpi_device *device) |
1036 | { | 1073 | { |
1037 | acpi_status status; | 1074 | acpi_status status; |
@@ -1044,12 +1081,6 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1044 | if (ACPI_IS_ROOT_DEVICE(device)) { | 1081 | if (ACPI_IS_ROOT_DEVICE(device)) { |
1045 | acpi_add_id(device, ACPI_SYSTEM_HID); | 1082 | acpi_add_id(device, ACPI_SYSTEM_HID); |
1046 | break; | 1083 | break; |
1047 | } else if (ACPI_IS_ROOT_DEVICE(device->parent)) { | ||
1048 | /* \_SB_, the only root-level namespace device */ | ||
1049 | acpi_add_id(device, ACPI_BUS_HID); | ||
1050 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); | ||
1051 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); | ||
1052 | break; | ||
1053 | } | 1084 | } |
1054 | 1085 | ||
1055 | status = acpi_get_object_info(device->handle, &info); | 1086 | status = acpi_get_object_info(device->handle, &info); |
@@ -1082,6 +1113,14 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
1082 | acpi_add_id(device, ACPI_BAY_HID); | 1113 | acpi_add_id(device, ACPI_BAY_HID); |
1083 | else if (ACPI_SUCCESS(acpi_dock_match(device))) | 1114 | else if (ACPI_SUCCESS(acpi_dock_match(device))) |
1084 | acpi_add_id(device, ACPI_DOCK_HID); | 1115 | acpi_add_id(device, ACPI_DOCK_HID); |
1116 | else if (!acpi_ibm_smbus_match(device)) | ||
1117 | acpi_add_id(device, ACPI_SMBUS_IBM_HID); | ||
1118 | else if (!acpi_device_hid(device) && | ||
1119 | ACPI_IS_ROOT_DEVICE(device->parent)) { | ||
1120 | acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ | ||
1121 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); | ||
1122 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); | ||
1123 | } | ||
1085 | 1124 | ||
1086 | break; | 1125 | break; |
1087 | case ACPI_BUS_TYPE_POWER: | 1126 | case ACPI_BUS_TYPE_POWER: |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 3bde594a9979..f74834a544fd 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -552,8 +552,17 @@ static void acpi_hibernation_leave(void) | |||
552 | hibernate_nvs_restore(); | 552 | hibernate_nvs_restore(); |
553 | } | 553 | } |
554 | 554 | ||
555 | static void acpi_pm_enable_gpes(void) | 555 | static int acpi_pm_pre_restore(void) |
556 | { | 556 | { |
557 | acpi_disable_all_gpes(); | ||
558 | acpi_os_wait_events_complete(NULL); | ||
559 | acpi_ec_suspend_transactions(); | ||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | static void acpi_pm_restore_cleanup(void) | ||
564 | { | ||
565 | acpi_ec_resume_transactions(); | ||
557 | acpi_enable_all_runtime_gpes(); | 566 | acpi_enable_all_runtime_gpes(); |
558 | } | 567 | } |
559 | 568 | ||
@@ -565,8 +574,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops = { | |||
565 | .prepare = acpi_pm_prepare, | 574 | .prepare = acpi_pm_prepare, |
566 | .enter = acpi_hibernation_enter, | 575 | .enter = acpi_hibernation_enter, |
567 | .leave = acpi_hibernation_leave, | 576 | .leave = acpi_hibernation_leave, |
568 | .pre_restore = acpi_pm_disable_gpes, | 577 | .pre_restore = acpi_pm_pre_restore, |
569 | .restore_cleanup = acpi_pm_enable_gpes, | 578 | .restore_cleanup = acpi_pm_restore_cleanup, |
570 | }; | 579 | }; |
571 | 580 | ||
572 | /** | 581 | /** |
@@ -618,8 +627,8 @@ static struct platform_hibernation_ops acpi_hibernation_ops_old = { | |||
618 | .prepare = acpi_pm_disable_gpes, | 627 | .prepare = acpi_pm_disable_gpes, |
619 | .enter = acpi_hibernation_enter, | 628 | .enter = acpi_hibernation_enter, |
620 | .leave = acpi_hibernation_leave, | 629 | .leave = acpi_hibernation_leave, |
621 | .pre_restore = acpi_pm_disable_gpes, | 630 | .pre_restore = acpi_pm_pre_restore, |
622 | .restore_cleanup = acpi_pm_enable_gpes, | 631 | .restore_cleanup = acpi_pm_restore_cleanup, |
623 | .recover = acpi_pm_finish, | 632 | .recover = acpi_pm_finish, |
624 | }; | 633 | }; |
625 | #endif /* CONFIG_HIBERNATION */ | 634 | #endif /* CONFIG_HIBERNATION */ |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 743f2445e2a1..4aaf24976138 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/proc_fs.h> | 26 | #include <linux/proc_fs.h> |
27 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
29 | #include <linux/string.h> | 30 | #include <linux/string.h> |
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 9073ada88835..efad1f33aeb5 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/dmi.h> | 36 | #include <linux/dmi.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/slab.h> | ||
38 | #include <linux/types.h> | 39 | #include <linux/types.h> |
39 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
40 | #include <linux/jiffies.h> | 41 | #include <linux/jiffies.h> |
@@ -368,7 +369,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
368 | int valid = 0; | 369 | int valid = 0; |
369 | int i; | 370 | int i; |
370 | 371 | ||
371 | /* Critical Shutdown (required) */ | 372 | /* Critical Shutdown */ |
372 | if (flag & ACPI_TRIPS_CRITICAL) { | 373 | if (flag & ACPI_TRIPS_CRITICAL) { |
373 | status = acpi_evaluate_integer(tz->device->handle, | 374 | status = acpi_evaluate_integer(tz->device->handle, |
374 | "_CRT", NULL, &tmp); | 375 | "_CRT", NULL, &tmp); |
@@ -379,17 +380,19 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
379 | * Below zero (Celsius) values clearly aren't right for sure.. | 380 | * Below zero (Celsius) values clearly aren't right for sure.. |
380 | * ... so lets discard those as invalid. | 381 | * ... so lets discard those as invalid. |
381 | */ | 382 | */ |
382 | if (ACPI_FAILURE(status) || | 383 | if (ACPI_FAILURE(status)) { |
383 | tz->trips.critical.temperature <= 2732) { | 384 | tz->trips.critical.flags.valid = 0; |
385 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
386 | "No critical threshold\n")); | ||
387 | } else if (tmp <= 2732) { | ||
388 | printk(KERN_WARNING FW_BUG "Invalid critical threshold " | ||
389 | "(%llu)\n", tmp); | ||
384 | tz->trips.critical.flags.valid = 0; | 390 | tz->trips.critical.flags.valid = 0; |
385 | ACPI_EXCEPTION((AE_INFO, status, | ||
386 | "No or invalid critical threshold")); | ||
387 | return -ENODEV; | ||
388 | } else { | 391 | } else { |
389 | tz->trips.critical.flags.valid = 1; | 392 | tz->trips.critical.flags.valid = 1; |
390 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 393 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
391 | "Found critical threshold [%lu]\n", | 394 | "Found critical threshold [%lu]\n", |
392 | tz->trips.critical.temperature)); | 395 | tz->trips.critical.temperature)); |
393 | } | 396 | } |
394 | if (tz->trips.critical.flags.valid == 1) { | 397 | if (tz->trips.critical.flags.valid == 1) { |
395 | if (crt == -1) { | 398 | if (crt == -1) { |
@@ -575,7 +578,23 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
575 | 578 | ||
576 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) | 579 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) |
577 | { | 580 | { |
578 | return acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); | 581 | int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); |
582 | |||
583 | if (ret) | ||
584 | return ret; | ||
585 | |||
586 | valid = tz->trips.critical.flags.valid | | ||
587 | tz->trips.hot.flags.valid | | ||
588 | tz->trips.passive.flags.valid; | ||
589 | |||
590 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) | ||
591 | valid |= tz->trips.active[i].flags.valid; | ||
592 | |||
593 | if (!valid) { | ||
594 | printk(KERN_WARNING FW_BUG "No valid trip found\n"); | ||
595 | return -ENODEV; | ||
596 | } | ||
597 | return 0; | ||
579 | } | 598 | } |
580 | 599 | ||
581 | static void acpi_thermal_check(void *data) | 600 | static void acpi_thermal_check(void *data) |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 11882dbe2094..b002a471c5d4 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/init.h> | 29 | #include <linux/init.h> |
29 | #include <linux/types.h> | 30 | #include <linux/types.h> |
30 | #include <acpi/acpi_bus.h> | 31 | #include <acpi/acpi_bus.h> |
@@ -289,51 +290,6 @@ acpi_evaluate_integer(acpi_handle handle, | |||
289 | 290 | ||
290 | EXPORT_SYMBOL(acpi_evaluate_integer); | 291 | EXPORT_SYMBOL(acpi_evaluate_integer); |
291 | 292 | ||
292 | #if 0 | ||
293 | acpi_status | ||
294 | acpi_evaluate_string(acpi_handle handle, | ||
295 | acpi_string pathname, | ||
296 | acpi_object_list * arguments, acpi_string * data) | ||
297 | { | ||
298 | acpi_status status = AE_OK; | ||
299 | acpi_object *element = NULL; | ||
300 | acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
301 | |||
302 | |||
303 | if (!data) | ||
304 | return AE_BAD_PARAMETER; | ||
305 | |||
306 | status = acpi_evaluate_object(handle, pathname, arguments, &buffer); | ||
307 | if (ACPI_FAILURE(status)) { | ||
308 | acpi_util_eval_error(handle, pathname, status); | ||
309 | return status; | ||
310 | } | ||
311 | |||
312 | element = (acpi_object *) buffer.pointer; | ||
313 | |||
314 | if ((element->type != ACPI_TYPE_STRING) | ||
315 | || (element->type != ACPI_TYPE_BUFFER) | ||
316 | || !element->string.length) { | ||
317 | acpi_util_eval_error(handle, pathname, AE_BAD_DATA); | ||
318 | return AE_BAD_DATA; | ||
319 | } | ||
320 | |||
321 | *data = kzalloc(element->string.length + 1, GFP_KERNEL); | ||
322 | if (!data) { | ||
323 | printk(KERN_ERR PREFIX "Memory allocation\n"); | ||
324 | return -ENOMEM; | ||
325 | } | ||
326 | |||
327 | memcpy(*data, element->string.pointer, element->string.length); | ||
328 | |||
329 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%s]\n", *data)); | ||
330 | |||
331 | kfree(buffer.pointer); | ||
332 | |||
333 | return AE_OK; | ||
334 | } | ||
335 | #endif | ||
336 | |||
337 | acpi_status | 293 | acpi_status |
338 | acpi_evaluate_reference(acpi_handle handle, | 294 | acpi_evaluate_reference(acpi_handle handle, |
339 | acpi_string pathname, | 295 | acpi_string pathname, |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 6e9b49149fce..a0c93b321482 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -39,10 +39,12 @@ | |||
39 | #include <linux/sort.h> | 39 | #include <linux/sort.h> |
40 | #include <linux/pci.h> | 40 | #include <linux/pci.h> |
41 | #include <linux/pci_ids.h> | 41 | #include <linux/pci_ids.h> |
42 | #include <linux/slab.h> | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <linux/dmi.h> | 44 | #include <linux/dmi.h> |
44 | #include <acpi/acpi_bus.h> | 45 | #include <acpi/acpi_bus.h> |
45 | #include <acpi/acpi_drivers.h> | 46 | #include <acpi/acpi_drivers.h> |
47 | #include <linux/suspend.h> | ||
46 | 48 | ||
47 | #define PREFIX "ACPI: " | 49 | #define PREFIX "ACPI: " |
48 | 50 | ||
@@ -88,7 +90,6 @@ module_param(allow_duplicates, bool, 0644); | |||
88 | static int register_count = 0; | 90 | static int register_count = 0; |
89 | static int acpi_video_bus_add(struct acpi_device *device); | 91 | static int acpi_video_bus_add(struct acpi_device *device); |
90 | static int acpi_video_bus_remove(struct acpi_device *device, int type); | 92 | static int acpi_video_bus_remove(struct acpi_device *device, int type); |
91 | static int acpi_video_resume(struct acpi_device *device); | ||
92 | static void acpi_video_bus_notify(struct acpi_device *device, u32 event); | 93 | static void acpi_video_bus_notify(struct acpi_device *device, u32 event); |
93 | 94 | ||
94 | static const struct acpi_device_id video_device_ids[] = { | 95 | static const struct acpi_device_id video_device_ids[] = { |
@@ -104,7 +105,6 @@ static struct acpi_driver acpi_video_bus = { | |||
104 | .ops = { | 105 | .ops = { |
105 | .add = acpi_video_bus_add, | 106 | .add = acpi_video_bus_add, |
106 | .remove = acpi_video_bus_remove, | 107 | .remove = acpi_video_bus_remove, |
107 | .resume = acpi_video_resume, | ||
108 | .notify = acpi_video_bus_notify, | 108 | .notify = acpi_video_bus_notify, |
109 | }, | 109 | }, |
110 | }; | 110 | }; |
@@ -159,6 +159,7 @@ struct acpi_video_bus { | |||
159 | struct proc_dir_entry *dir; | 159 | struct proc_dir_entry *dir; |
160 | struct input_dev *input; | 160 | struct input_dev *input; |
161 | char phys[32]; /* for input device */ | 161 | char phys[32]; /* for input device */ |
162 | struct notifier_block pm_nb; | ||
162 | }; | 163 | }; |
163 | 164 | ||
164 | struct acpi_video_device_flags { | 165 | struct acpi_video_device_flags { |
@@ -327,7 +328,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, | |||
327 | int level); | 328 | int level); |
328 | static int acpi_video_device_lcd_get_level_current( | 329 | static int acpi_video_device_lcd_get_level_current( |
329 | struct acpi_video_device *device, | 330 | struct acpi_video_device *device, |
330 | unsigned long long *level); | 331 | unsigned long long *level, int init); |
331 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 332 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
332 | u32 level_current, u32 event); | 333 | u32 level_current, u32 event); |
333 | static int acpi_video_switch_brightness(struct acpi_video_device *device, | 334 | static int acpi_video_switch_brightness(struct acpi_video_device *device, |
@@ -345,7 +346,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd) | |||
345 | struct acpi_video_device *vd = | 346 | struct acpi_video_device *vd = |
346 | (struct acpi_video_device *)bl_get_data(bd); | 347 | (struct acpi_video_device *)bl_get_data(bd); |
347 | 348 | ||
348 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level)) | 349 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0)) |
349 | return -EINVAL; | 350 | return -EINVAL; |
350 | for (i = 2; i < vd->brightness->count; i++) { | 351 | for (i = 2; i < vd->brightness->count; i++) { |
351 | if (vd->brightness->levels[i] == cur_level) | 352 | if (vd->brightness->levels[i] == cur_level) |
@@ -414,7 +415,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig | |||
414 | unsigned long long level; | 415 | unsigned long long level; |
415 | int offset; | 416 | int offset; |
416 | 417 | ||
417 | if (acpi_video_device_lcd_get_level_current(video, &level)) | 418 | if (acpi_video_device_lcd_get_level_current(video, &level, 0)) |
418 | return -EINVAL; | 419 | return -EINVAL; |
419 | for (offset = 2; offset < video->brightness->count; offset++) | 420 | for (offset = 2; offset < video->brightness->count; offset++) |
420 | if (level == video->brightness->levels[offset]) { | 421 | if (level == video->brightness->levels[offset]) { |
@@ -609,7 +610,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
609 | 610 | ||
610 | static int | 611 | static int |
611 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 612 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
612 | unsigned long long *level) | 613 | unsigned long long *level, int init) |
613 | { | 614 | { |
614 | acpi_status status = AE_OK; | 615 | acpi_status status = AE_OK; |
615 | int i; | 616 | int i; |
@@ -633,10 +634,16 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | |||
633 | device->brightness->curr = *level; | 634 | device->brightness->curr = *level; |
634 | return 0; | 635 | return 0; |
635 | } | 636 | } |
636 | /* BQC returned an invalid level. Stop using it. */ | 637 | if (!init) { |
637 | ACPI_WARNING((AE_INFO, "%s returned an invalid level", | 638 | /* |
638 | buf)); | 639 | * BQC returned an invalid level. |
639 | device->cap._BQC = device->cap._BCQ = 0; | 640 | * Stop using it. |
641 | */ | ||
642 | ACPI_WARNING((AE_INFO, | ||
643 | "%s returned an invalid level", | ||
644 | buf)); | ||
645 | device->cap._BQC = device->cap._BCQ = 0; | ||
646 | } | ||
640 | } else { | 647 | } else { |
641 | /* Fixme: | 648 | /* Fixme: |
642 | * should we return an error or ignore this failure? | 649 | * should we return an error or ignore this failure? |
@@ -892,7 +899,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
892 | if (!device->cap._BQC) | 899 | if (!device->cap._BQC) |
893 | goto set_level; | 900 | goto set_level; |
894 | 901 | ||
895 | result = acpi_video_device_lcd_get_level_current(device, &level_old); | 902 | result = acpi_video_device_lcd_get_level_current(device, &level_old, 1); |
896 | if (result) | 903 | if (result) |
897 | goto out_free_levels; | 904 | goto out_free_levels; |
898 | 905 | ||
@@ -903,7 +910,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
903 | if (result) | 910 | if (result) |
904 | goto out_free_levels; | 911 | goto out_free_levels; |
905 | 912 | ||
906 | result = acpi_video_device_lcd_get_level_current(device, &level); | 913 | result = acpi_video_device_lcd_get_level_current(device, &level, 0); |
907 | if (result) | 914 | if (result) |
908 | goto out_free_levels; | 915 | goto out_free_levels; |
909 | 916 | ||
@@ -992,6 +999,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
992 | } | 999 | } |
993 | 1000 | ||
994 | if (acpi_video_backlight_support()) { | 1001 | if (acpi_video_backlight_support()) { |
1002 | struct backlight_properties props; | ||
995 | int result; | 1003 | int result; |
996 | static int count = 0; | 1004 | static int count = 0; |
997 | char *name; | 1005 | char *name; |
@@ -1004,12 +1012,21 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
1004 | return; | 1012 | return; |
1005 | 1013 | ||
1006 | sprintf(name, "acpi_video%d", count++); | 1014 | sprintf(name, "acpi_video%d", count++); |
1007 | device->backlight = backlight_device_register(name, | 1015 | memset(&props, 0, sizeof(struct backlight_properties)); |
1008 | NULL, device, &acpi_backlight_ops); | 1016 | props.max_brightness = device->brightness->count - 3; |
1017 | device->backlight = backlight_device_register(name, NULL, device, | ||
1018 | &acpi_backlight_ops, | ||
1019 | &props); | ||
1009 | kfree(name); | 1020 | kfree(name); |
1010 | if (IS_ERR(device->backlight)) | 1021 | if (IS_ERR(device->backlight)) |
1011 | return; | 1022 | return; |
1012 | device->backlight->props.max_brightness = device->brightness->count-3; | 1023 | |
1024 | /* | ||
1025 | * Save current brightness level in case we have to restore it | ||
1026 | * before acpi_video_device_lcd_set_level() is called next time. | ||
1027 | */ | ||
1028 | device->backlight->props.brightness = | ||
1029 | acpi_video_get_brightness(device->backlight); | ||
1013 | 1030 | ||
1014 | result = sysfs_create_link(&device->backlight->dev.kobj, | 1031 | result = sysfs_create_link(&device->backlight->dev.kobj, |
1015 | &device->dev->dev.kobj, "device"); | 1032 | &device->dev->dev.kobj, "device"); |
@@ -1996,7 +2013,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) | |||
1996 | goto out; | 2013 | goto out; |
1997 | 2014 | ||
1998 | result = acpi_video_device_lcd_get_level_current(device, | 2015 | result = acpi_video_device_lcd_get_level_current(device, |
1999 | &level_current); | 2016 | &level_current, 0); |
2000 | if (result) | 2017 | if (result) |
2001 | goto out; | 2018 | goto out; |
2002 | 2019 | ||
@@ -2113,7 +2130,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event) | |||
2113 | { | 2130 | { |
2114 | struct acpi_video_bus *video = acpi_driver_data(device); | 2131 | struct acpi_video_bus *video = acpi_driver_data(device); |
2115 | struct input_dev *input; | 2132 | struct input_dev *input; |
2116 | int keycode; | 2133 | int keycode = 0; |
2117 | 2134 | ||
2118 | if (!video) | 2135 | if (!video) |
2119 | return; | 2136 | return; |
@@ -2149,17 +2166,19 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event) | |||
2149 | break; | 2166 | break; |
2150 | 2167 | ||
2151 | default: | 2168 | default: |
2152 | keycode = KEY_UNKNOWN; | ||
2153 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 2169 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
2154 | "Unsupported event [0x%x]\n", event)); | 2170 | "Unsupported event [0x%x]\n", event)); |
2155 | break; | 2171 | break; |
2156 | } | 2172 | } |
2157 | 2173 | ||
2158 | acpi_notifier_call_chain(device, event, 0); | 2174 | acpi_notifier_call_chain(device, event, 0); |
2159 | input_report_key(input, keycode, 1); | 2175 | |
2160 | input_sync(input); | 2176 | if (keycode) { |
2161 | input_report_key(input, keycode, 0); | 2177 | input_report_key(input, keycode, 1); |
2162 | input_sync(input); | 2178 | input_sync(input); |
2179 | input_report_key(input, keycode, 0); | ||
2180 | input_sync(input); | ||
2181 | } | ||
2163 | 2182 | ||
2164 | return; | 2183 | return; |
2165 | } | 2184 | } |
@@ -2170,7 +2189,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) | |||
2170 | struct acpi_device *device = NULL; | 2189 | struct acpi_device *device = NULL; |
2171 | struct acpi_video_bus *bus; | 2190 | struct acpi_video_bus *bus; |
2172 | struct input_dev *input; | 2191 | struct input_dev *input; |
2173 | int keycode; | 2192 | int keycode = 0; |
2174 | 2193 | ||
2175 | if (!video_device) | 2194 | if (!video_device) |
2176 | return; | 2195 | return; |
@@ -2211,39 +2230,48 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) | |||
2211 | keycode = KEY_DISPLAY_OFF; | 2230 | keycode = KEY_DISPLAY_OFF; |
2212 | break; | 2231 | break; |
2213 | default: | 2232 | default: |
2214 | keycode = KEY_UNKNOWN; | ||
2215 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 2233 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
2216 | "Unsupported event [0x%x]\n", event)); | 2234 | "Unsupported event [0x%x]\n", event)); |
2217 | break; | 2235 | break; |
2218 | } | 2236 | } |
2219 | 2237 | ||
2220 | acpi_notifier_call_chain(device, event, 0); | 2238 | acpi_notifier_call_chain(device, event, 0); |
2221 | input_report_key(input, keycode, 1); | 2239 | |
2222 | input_sync(input); | 2240 | if (keycode) { |
2223 | input_report_key(input, keycode, 0); | 2241 | input_report_key(input, keycode, 1); |
2224 | input_sync(input); | 2242 | input_sync(input); |
2243 | input_report_key(input, keycode, 0); | ||
2244 | input_sync(input); | ||
2245 | } | ||
2225 | 2246 | ||
2226 | return; | 2247 | return; |
2227 | } | 2248 | } |
2228 | 2249 | ||
2229 | static int instance; | 2250 | static int acpi_video_resume(struct notifier_block *nb, |
2230 | static int acpi_video_resume(struct acpi_device *device) | 2251 | unsigned long val, void *ign) |
2231 | { | 2252 | { |
2232 | struct acpi_video_bus *video; | 2253 | struct acpi_video_bus *video; |
2233 | struct acpi_video_device *video_device; | 2254 | struct acpi_video_device *video_device; |
2234 | int i; | 2255 | int i; |
2235 | 2256 | ||
2236 | if (!device || !acpi_driver_data(device)) | 2257 | switch (val) { |
2237 | return -EINVAL; | 2258 | case PM_HIBERNATION_PREPARE: |
2259 | case PM_SUSPEND_PREPARE: | ||
2260 | case PM_RESTORE_PREPARE: | ||
2261 | return NOTIFY_DONE; | ||
2262 | } | ||
2238 | 2263 | ||
2239 | video = acpi_driver_data(device); | 2264 | video = container_of(nb, struct acpi_video_bus, pm_nb); |
2265 | |||
2266 | dev_info(&video->device->dev, "Restoring backlight state\n"); | ||
2240 | 2267 | ||
2241 | for (i = 0; i < video->attached_count; i++) { | 2268 | for (i = 0; i < video->attached_count; i++) { |
2242 | video_device = video->attached_array[i].bind_info; | 2269 | video_device = video->attached_array[i].bind_info; |
2243 | if (video_device && video_device->backlight) | 2270 | if (video_device && video_device->backlight) |
2244 | acpi_video_set_brightness(video_device->backlight); | 2271 | acpi_video_set_brightness(video_device->backlight); |
2245 | } | 2272 | } |
2246 | return AE_OK; | 2273 | |
2274 | return NOTIFY_OK; | ||
2247 | } | 2275 | } |
2248 | 2276 | ||
2249 | static acpi_status | 2277 | static acpi_status |
@@ -2267,6 +2295,8 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context, | |||
2267 | return AE_OK; | 2295 | return AE_OK; |
2268 | } | 2296 | } |
2269 | 2297 | ||
2298 | static int instance; | ||
2299 | |||
2270 | static int acpi_video_bus_add(struct acpi_device *device) | 2300 | static int acpi_video_bus_add(struct acpi_device *device) |
2271 | { | 2301 | { |
2272 | struct acpi_video_bus *video; | 2302 | struct acpi_video_bus *video; |
@@ -2348,7 +2378,6 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2348 | set_bit(KEY_BRIGHTNESSDOWN, input->keybit); | 2378 | set_bit(KEY_BRIGHTNESSDOWN, input->keybit); |
2349 | set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); | 2379 | set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); |
2350 | set_bit(KEY_DISPLAY_OFF, input->keybit); | 2380 | set_bit(KEY_DISPLAY_OFF, input->keybit); |
2351 | set_bit(KEY_UNKNOWN, input->keybit); | ||
2352 | 2381 | ||
2353 | error = input_register_device(input); | 2382 | error = input_register_device(input); |
2354 | if (error) | 2383 | if (error) |
@@ -2360,6 +2389,10 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
2360 | video->flags.rom ? "yes" : "no", | 2389 | video->flags.rom ? "yes" : "no", |
2361 | video->flags.post ? "yes" : "no"); | 2390 | video->flags.post ? "yes" : "no"); |
2362 | 2391 | ||
2392 | video->pm_nb.notifier_call = acpi_video_resume; | ||
2393 | video->pm_nb.priority = 0; | ||
2394 | register_pm_notifier(&video->pm_nb); | ||
2395 | |||
2363 | return 0; | 2396 | return 0; |
2364 | 2397 | ||
2365 | err_free_input_dev: | 2398 | err_free_input_dev: |
@@ -2386,6 +2419,8 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type) | |||
2386 | 2419 | ||
2387 | video = acpi_driver_data(device); | 2420 | video = acpi_driver_data(device); |
2388 | 2421 | ||
2422 | unregister_pm_notifier(&video->pm_nb); | ||
2423 | |||
2389 | acpi_video_bus_stop_devices(video); | 2424 | acpi_video_bus_stop_devices(video); |
2390 | acpi_video_bus_put_devices(video); | 2425 | acpi_video_bus_put_devices(video); |
2391 | acpi_video_bus_remove_fs(device); | 2426 | acpi_video_bus_remove_fs(device); |