diff options
31 files changed, 1502 insertions, 1434 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index a5cc0db63d7a..ed511af0f79a 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -582,3 +582,10 @@ Why: The paravirt mmu host support is slower than non-paravirt mmu, both | |||
582 | Who: Avi Kivity <avi@redhat.com> | 582 | Who: Avi Kivity <avi@redhat.com> |
583 | 583 | ||
584 | ---------------------------- | 584 | ---------------------------- |
585 | |||
586 | What: "acpi=ht" boot option | ||
587 | When: 2.6.35 | ||
588 | Why: Useful in 2003, implementation is a hack. | ||
589 | Generally invoked by accident today. | ||
590 | Seen as doing more harm than good. | ||
591 | Who: Len Brown <len.brown@intel.com> | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3bc48b0bd3a9..e4cbca58536c 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -200,10 +200,6 @@ and is between 256 and 4096 characters. It is defined in the file | |||
200 | acpi_display_output=video | 200 | acpi_display_output=video |
201 | See above. | 201 | See above. |
202 | 202 | ||
203 | acpi_early_pdc_eval [HW,ACPI] Evaluate processor _PDC methods | ||
204 | early. Needed on some platforms to properly | ||
205 | initialize the EC. | ||
206 | |||
207 | acpi_irq_balance [HW,ACPI] | 203 | acpi_irq_balance [HW,ACPI] |
208 | ACPI will balance active IRQs | 204 | ACPI will balance active IRQs |
209 | default in APIC mode | 205 | default in APIC mode |
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index a7ca07f3754e..f1c9f70b4e45 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/efi.h> | 44 | #include <linux/efi.h> |
45 | #include <linux/mmzone.h> | 45 | #include <linux/mmzone.h> |
46 | #include <linux/nodemask.h> | 46 | #include <linux/nodemask.h> |
47 | #include <acpi/processor.h> | ||
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
48 | #include <asm/iosapic.h> | 49 | #include <asm/iosapic.h> |
49 | #include <asm/machvec.h> | 50 | #include <asm/machvec.h> |
@@ -907,6 +908,8 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu) | |||
907 | cpu_set(cpu, cpu_present_map); | 908 | cpu_set(cpu, cpu_present_map); |
908 | ia64_cpu_to_sapicid[cpu] = physid; | 909 | ia64_cpu_to_sapicid[cpu] = physid; |
909 | 910 | ||
911 | acpi_processor_set_pdc(handle); | ||
912 | |||
910 | *pcpu = cpu; | 913 | *pcpu = cpu; |
911 | return (0); | 914 | return (0); |
912 | } | 915 | } |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index a54d714545ff..0061ea263061 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -490,6 +490,7 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity) | |||
490 | * ACPI based hotplug support for CPU | 490 | * ACPI based hotplug support for CPU |
491 | */ | 491 | */ |
492 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | 492 | #ifdef CONFIG_ACPI_HOTPLUG_CPU |
493 | #include <acpi/processor.h> | ||
493 | 494 | ||
494 | static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) | 495 | static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) |
495 | { | 496 | { |
@@ -567,6 +568,8 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu) | |||
567 | goto free_new_map; | 568 | goto free_new_map; |
568 | } | 569 | } |
569 | 570 | ||
571 | acpi_processor_set_pdc(handle); | ||
572 | |||
570 | cpu = cpumask_first(new_map); | 573 | cpu = cpumask_first(new_map); |
571 | acpi_map_cpu2node(handle, cpu, physid); | 574 | acpi_map_cpu2node(handle, cpu, physid); |
572 | 575 | ||
@@ -1293,23 +1296,6 @@ static int __init dmi_disable_acpi(const struct dmi_system_id *d) | |||
1293 | } | 1296 | } |
1294 | 1297 | ||
1295 | /* | 1298 | /* |
1296 | * Limit ACPI to CPU enumeration for HT | ||
1297 | */ | ||
1298 | static int __init force_acpi_ht(const struct dmi_system_id *d) | ||
1299 | { | ||
1300 | if (!acpi_force) { | ||
1301 | printk(KERN_NOTICE "%s detected: force use of acpi=ht\n", | ||
1302 | d->ident); | ||
1303 | disable_acpi(); | ||
1304 | acpi_ht = 1; | ||
1305 | } else { | ||
1306 | printk(KERN_NOTICE | ||
1307 | "Warning: acpi=force overrules DMI blacklist: acpi=ht\n"); | ||
1308 | } | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | /* | ||
1313 | * Force ignoring BIOS IRQ0 pin2 override | 1299 | * Force ignoring BIOS IRQ0 pin2 override |
1314 | */ | 1300 | */ |
1315 | static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) | 1301 | static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d) |
@@ -1345,82 +1331,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = { | |||
1345 | }, | 1331 | }, |
1346 | 1332 | ||
1347 | /* | 1333 | /* |
1348 | * Boxes that need acpi=ht | ||
1349 | */ | ||
1350 | { | ||
1351 | .callback = force_acpi_ht, | ||
1352 | .ident = "FSC Primergy T850", | ||
1353 | .matches = { | ||
1354 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
1355 | DMI_MATCH(DMI_PRODUCT_NAME, "PRIMERGY T850"), | ||
1356 | }, | ||
1357 | }, | ||
1358 | { | ||
1359 | .callback = force_acpi_ht, | ||
1360 | .ident = "HP VISUALIZE NT Workstation", | ||
1361 | .matches = { | ||
1362 | DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), | ||
1363 | DMI_MATCH(DMI_PRODUCT_NAME, "HP VISUALIZE NT Workstation"), | ||
1364 | }, | ||
1365 | }, | ||
1366 | { | ||
1367 | .callback = force_acpi_ht, | ||
1368 | .ident = "Compaq Workstation W8000", | ||
1369 | .matches = { | ||
1370 | DMI_MATCH(DMI_SYS_VENDOR, "Compaq"), | ||
1371 | DMI_MATCH(DMI_PRODUCT_NAME, "Workstation W8000"), | ||
1372 | }, | ||
1373 | }, | ||
1374 | { | ||
1375 | .callback = force_acpi_ht, | ||
1376 | .ident = "ASUS CUR-DLS", | ||
1377 | .matches = { | ||
1378 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | ||
1379 | DMI_MATCH(DMI_BOARD_NAME, "CUR-DLS"), | ||
1380 | }, | ||
1381 | }, | ||
1382 | { | ||
1383 | .callback = force_acpi_ht, | ||
1384 | .ident = "ABIT i440BX-W83977", | ||
1385 | .matches = { | ||
1386 | DMI_MATCH(DMI_BOARD_VENDOR, "ABIT <http://www.abit.com>"), | ||
1387 | DMI_MATCH(DMI_BOARD_NAME, "i440BX-W83977 (BP6)"), | ||
1388 | }, | ||
1389 | }, | ||
1390 | { | ||
1391 | .callback = force_acpi_ht, | ||
1392 | .ident = "IBM Bladecenter", | ||
1393 | .matches = { | ||
1394 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | ||
1395 | DMI_MATCH(DMI_BOARD_NAME, "IBM eServer BladeCenter HS20"), | ||
1396 | }, | ||
1397 | }, | ||
1398 | { | ||
1399 | .callback = force_acpi_ht, | ||
1400 | .ident = "IBM eServer xSeries 360", | ||
1401 | .matches = { | ||
1402 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | ||
1403 | DMI_MATCH(DMI_BOARD_NAME, "eServer xSeries 360"), | ||
1404 | }, | ||
1405 | }, | ||
1406 | { | ||
1407 | .callback = force_acpi_ht, | ||
1408 | .ident = "IBM eserver xSeries 330", | ||
1409 | .matches = { | ||
1410 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | ||
1411 | DMI_MATCH(DMI_BOARD_NAME, "eserver xSeries 330"), | ||
1412 | }, | ||
1413 | }, | ||
1414 | { | ||
1415 | .callback = force_acpi_ht, | ||
1416 | .ident = "IBM eserver xSeries 440", | ||
1417 | .matches = { | ||
1418 | DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), | ||
1419 | DMI_MATCH(DMI_PRODUCT_NAME, "eserver xSeries 440"), | ||
1420 | }, | ||
1421 | }, | ||
1422 | |||
1423 | /* | ||
1424 | * Boxes that need ACPI PCI IRQ routing disabled | 1334 | * Boxes that need ACPI PCI IRQ routing disabled |
1425 | */ | 1335 | */ |
1426 | { | 1336 | { |
@@ -1652,8 +1562,10 @@ static int __init parse_acpi(char *arg) | |||
1652 | } | 1562 | } |
1653 | /* Limit ACPI just to boot-time to enable HT */ | 1563 | /* Limit ACPI just to boot-time to enable HT */ |
1654 | else if (strcmp(arg, "ht") == 0) { | 1564 | else if (strcmp(arg, "ht") == 0) { |
1655 | if (!acpi_force) | 1565 | if (!acpi_force) { |
1566 | printk(KERN_WARNING "acpi=ht will be removed in Linux-2.6.35\n"); | ||
1656 | disable_acpi(); | 1567 | disable_acpi(); |
1568 | } | ||
1657 | acpi_ht = 1; | 1569 | acpi_ht = 1; |
1658 | } | 1570 | } |
1659 | /* acpi=rsdt use RSDT instead of XSDT */ | 1571 | /* acpi=rsdt use RSDT instead of XSDT */ |
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/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/battery.c b/drivers/acpi/battery.c index 58d2c91ba62b..75f39f2c166d 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 54 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
55 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | 55 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 |
56 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 | 56 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 |
57 | #define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82 | ||
57 | 58 | ||
58 | #define _COMPONENT ACPI_BATTERY_COMPONENT | 59 | #define _COMPONENT ACPI_BATTERY_COMPONENT |
59 | 60 | ||
@@ -88,10 +89,15 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
88 | 89 | ||
89 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 90 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
90 | 91 | ||
91 | /* For buggy DSDTs that report negative 16-bit values for either charging | 92 | enum { |
92 | * or discharging current and/or report 0 as 65536 due to bad math. | 93 | ACPI_BATTERY_ALARM_PRESENT, |
93 | */ | 94 | ACPI_BATTERY_XINFO_PRESENT, |
94 | #define QUIRK_SIGNED16_CURRENT 0x0001 | 95 | /* For buggy DSDTs that report negative 16-bit values for either |
96 | * charging or discharging current and/or report 0 as 65536 | ||
97 | * due to bad math. | ||
98 | */ | ||
99 | ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, | ||
100 | }; | ||
95 | 101 | ||
96 | struct acpi_battery { | 102 | struct acpi_battery { |
97 | struct mutex lock; | 103 | struct mutex lock; |
@@ -109,6 +115,12 @@ struct acpi_battery { | |||
109 | int design_voltage; | 115 | int design_voltage; |
110 | int design_capacity_warning; | 116 | int design_capacity_warning; |
111 | int design_capacity_low; | 117 | int design_capacity_low; |
118 | int cycle_count; | ||
119 | int measurement_accuracy; | ||
120 | int max_sampling_time; | ||
121 | int min_sampling_time; | ||
122 | int max_averaging_interval; | ||
123 | int min_averaging_interval; | ||
112 | int capacity_granularity_1; | 124 | int capacity_granularity_1; |
113 | int capacity_granularity_2; | 125 | int capacity_granularity_2; |
114 | int alarm; | 126 | int alarm; |
@@ -118,8 +130,7 @@ struct acpi_battery { | |||
118 | char oem_info[32]; | 130 | char oem_info[32]; |
119 | int state; | 131 | int state; |
120 | int power_unit; | 132 | int power_unit; |
121 | u8 alarm_present; | 133 | unsigned long flags; |
122 | long quirks; | ||
123 | }; | 134 | }; |
124 | 135 | ||
125 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); | 136 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); |
@@ -198,6 +209,9 @@ static int acpi_battery_get_property(struct power_supply *psy, | |||
198 | case POWER_SUPPLY_PROP_TECHNOLOGY: | 209 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
199 | val->intval = acpi_battery_technology(battery); | 210 | val->intval = acpi_battery_technology(battery); |
200 | break; | 211 | break; |
212 | case POWER_SUPPLY_PROP_CYCLE_COUNT: | ||
213 | val->intval = battery->cycle_count; | ||
214 | break; | ||
201 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | 215 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
202 | val->intval = battery->design_voltage * 1000; | 216 | val->intval = battery->design_voltage * 1000; |
203 | break; | 217 | break; |
@@ -239,6 +253,7 @@ static enum power_supply_property charge_battery_props[] = { | |||
239 | POWER_SUPPLY_PROP_STATUS, | 253 | POWER_SUPPLY_PROP_STATUS, |
240 | POWER_SUPPLY_PROP_PRESENT, | 254 | POWER_SUPPLY_PROP_PRESENT, |
241 | POWER_SUPPLY_PROP_TECHNOLOGY, | 255 | POWER_SUPPLY_PROP_TECHNOLOGY, |
256 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
242 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 257 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
243 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 258 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
244 | POWER_SUPPLY_PROP_CURRENT_NOW, | 259 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -254,6 +269,7 @@ static enum power_supply_property energy_battery_props[] = { | |||
254 | POWER_SUPPLY_PROP_STATUS, | 269 | POWER_SUPPLY_PROP_STATUS, |
255 | POWER_SUPPLY_PROP_PRESENT, | 270 | POWER_SUPPLY_PROP_PRESENT, |
256 | POWER_SUPPLY_PROP_TECHNOLOGY, | 271 | POWER_SUPPLY_PROP_TECHNOLOGY, |
272 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
257 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 273 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
258 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 274 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
259 | POWER_SUPPLY_PROP_CURRENT_NOW, | 275 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -305,6 +321,28 @@ static struct acpi_offsets info_offsets[] = { | |||
305 | {offsetof(struct acpi_battery, oem_info), 1}, | 321 | {offsetof(struct acpi_battery, oem_info), 1}, |
306 | }; | 322 | }; |
307 | 323 | ||
324 | static struct acpi_offsets extended_info_offsets[] = { | ||
325 | {offsetof(struct acpi_battery, power_unit), 0}, | ||
326 | {offsetof(struct acpi_battery, design_capacity), 0}, | ||
327 | {offsetof(struct acpi_battery, full_charge_capacity), 0}, | ||
328 | {offsetof(struct acpi_battery, technology), 0}, | ||
329 | {offsetof(struct acpi_battery, design_voltage), 0}, | ||
330 | {offsetof(struct acpi_battery, design_capacity_warning), 0}, | ||
331 | {offsetof(struct acpi_battery, design_capacity_low), 0}, | ||
332 | {offsetof(struct acpi_battery, cycle_count), 0}, | ||
333 | {offsetof(struct acpi_battery, measurement_accuracy), 0}, | ||
334 | {offsetof(struct acpi_battery, max_sampling_time), 0}, | ||
335 | {offsetof(struct acpi_battery, min_sampling_time), 0}, | ||
336 | {offsetof(struct acpi_battery, max_averaging_interval), 0}, | ||
337 | {offsetof(struct acpi_battery, min_averaging_interval), 0}, | ||
338 | {offsetof(struct acpi_battery, capacity_granularity_1), 0}, | ||
339 | {offsetof(struct acpi_battery, capacity_granularity_2), 0}, | ||
340 | {offsetof(struct acpi_battery, model_number), 1}, | ||
341 | {offsetof(struct acpi_battery, serial_number), 1}, | ||
342 | {offsetof(struct acpi_battery, type), 1}, | ||
343 | {offsetof(struct acpi_battery, oem_info), 1}, | ||
344 | }; | ||
345 | |||
308 | static int extract_package(struct acpi_battery *battery, | 346 | static int extract_package(struct acpi_battery *battery, |
309 | union acpi_object *package, | 347 | union acpi_object *package, |
310 | struct acpi_offsets *offsets, int num) | 348 | struct acpi_offsets *offsets, int num) |
@@ -350,22 +388,29 @@ static int acpi_battery_get_info(struct acpi_battery *battery) | |||
350 | { | 388 | { |
351 | int result = -EFAULT; | 389 | int result = -EFAULT; |
352 | acpi_status status = 0; | 390 | acpi_status status = 0; |
391 | char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)? | ||
392 | "_BIX" : "_BIF"; | ||
393 | |||
353 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 394 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
354 | 395 | ||
355 | if (!acpi_battery_present(battery)) | 396 | if (!acpi_battery_present(battery)) |
356 | return 0; | 397 | return 0; |
357 | mutex_lock(&battery->lock); | 398 | mutex_lock(&battery->lock); |
358 | status = acpi_evaluate_object(battery->device->handle, "_BIF", | 399 | status = acpi_evaluate_object(battery->device->handle, name, |
359 | NULL, &buffer); | 400 | NULL, &buffer); |
360 | mutex_unlock(&battery->lock); | 401 | mutex_unlock(&battery->lock); |
361 | 402 | ||
362 | if (ACPI_FAILURE(status)) { | 403 | if (ACPI_FAILURE(status)) { |
363 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); | 404 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); |
364 | return -ENODEV; | 405 | return -ENODEV; |
365 | } | 406 | } |
366 | 407 | if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | |
367 | result = extract_package(battery, buffer.pointer, | 408 | result = extract_package(battery, buffer.pointer, |
368 | info_offsets, ARRAY_SIZE(info_offsets)); | 409 | extended_info_offsets, |
410 | ARRAY_SIZE(extended_info_offsets)); | ||
411 | else | ||
412 | result = extract_package(battery, buffer.pointer, | ||
413 | info_offsets, ARRAY_SIZE(info_offsets)); | ||
369 | kfree(buffer.pointer); | 414 | kfree(buffer.pointer); |
370 | return result; | 415 | return result; |
371 | } | 416 | } |
@@ -399,7 +444,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
399 | battery->update_time = jiffies; | 444 | battery->update_time = jiffies; |
400 | kfree(buffer.pointer); | 445 | kfree(buffer.pointer); |
401 | 446 | ||
402 | if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && | 447 | if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) && |
403 | battery->rate_now != -1) | 448 | battery->rate_now != -1) |
404 | battery->rate_now = abs((s16)battery->rate_now); | 449 | battery->rate_now = abs((s16)battery->rate_now); |
405 | 450 | ||
@@ -412,7 +457,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) | |||
412 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; | 457 | union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; |
413 | struct acpi_object_list arg_list = { 1, &arg0 }; | 458 | struct acpi_object_list arg_list = { 1, &arg0 }; |
414 | 459 | ||
415 | if (!acpi_battery_present(battery)|| !battery->alarm_present) | 460 | if (!acpi_battery_present(battery) || |
461 | !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) | ||
416 | return -ENODEV; | 462 | return -ENODEV; |
417 | 463 | ||
418 | arg0.integer.value = battery->alarm; | 464 | arg0.integer.value = battery->alarm; |
@@ -437,10 +483,10 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) | |||
437 | /* See if alarms are supported, and if so, set default */ | 483 | /* See if alarms are supported, and if so, set default */ |
438 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); | 484 | status = acpi_get_handle(battery->device->handle, "_BTP", &handle); |
439 | if (ACPI_FAILURE(status)) { | 485 | if (ACPI_FAILURE(status)) { |
440 | battery->alarm_present = 0; | 486 | clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
441 | return 0; | 487 | return 0; |
442 | } | 488 | } |
443 | battery->alarm_present = 1; | 489 | set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); |
444 | if (!battery->alarm) | 490 | if (!battery->alarm) |
445 | battery->alarm = battery->design_capacity_warning; | 491 | battery->alarm = battery->design_capacity_warning; |
446 | return acpi_battery_set_alarm(battery); | 492 | return acpi_battery_set_alarm(battery); |
@@ -510,9 +556,8 @@ static void sysfs_remove_battery(struct acpi_battery *battery) | |||
510 | 556 | ||
511 | static void acpi_battery_quirks(struct acpi_battery *battery) | 557 | static void acpi_battery_quirks(struct acpi_battery *battery) |
512 | { | 558 | { |
513 | battery->quirks = 0; | ||
514 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { | 559 | if (dmi_name_in_vendors("Acer") && battery->power_unit) { |
515 | battery->quirks |= QUIRK_SIGNED16_CURRENT; | 560 | set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags); |
516 | } | 561 | } |
517 | } | 562 | } |
518 | 563 | ||
@@ -590,6 +635,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result) | |||
590 | seq_printf(seq, "design capacity low: %d %sh\n", | 635 | seq_printf(seq, "design capacity low: %d %sh\n", |
591 | battery->design_capacity_low, | 636 | battery->design_capacity_low, |
592 | acpi_battery_units(battery)); | 637 | acpi_battery_units(battery)); |
638 | seq_printf(seq, "cycle count: %i\n", battery->cycle_count); | ||
593 | seq_printf(seq, "capacity granularity 1: %d %sh\n", | 639 | seq_printf(seq, "capacity granularity 1: %d %sh\n", |
594 | battery->capacity_granularity_1, | 640 | battery->capacity_granularity_1, |
595 | acpi_battery_units(battery)); | 641 | acpi_battery_units(battery)); |
@@ -841,6 +887,7 @@ static int acpi_battery_add(struct acpi_device *device) | |||
841 | { | 887 | { |
842 | int result = 0; | 888 | int result = 0; |
843 | struct acpi_battery *battery = NULL; | 889 | struct acpi_battery *battery = NULL; |
890 | acpi_handle handle; | ||
844 | if (!device) | 891 | if (!device) |
845 | return -EINVAL; | 892 | return -EINVAL; |
846 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 893 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
@@ -851,6 +898,9 @@ static int acpi_battery_add(struct acpi_device *device) | |||
851 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); | 898 | strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); |
852 | device->driver_data = battery; | 899 | device->driver_data = battery; |
853 | mutex_init(&battery->lock); | 900 | mutex_init(&battery->lock); |
901 | if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle, | ||
902 | "_BIX", &handle))) | ||
903 | set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); | ||
854 | acpi_battery_update(battery); | 904 | acpi_battery_update(battery); |
855 | #ifdef CONFIG_ACPI_PROCFS_POWER | 905 | #ifdef CONFIG_ACPI_PROCFS_POWER |
856 | result = acpi_battery_add_fs(device); | 906 | result = acpi_battery_add_fs(device); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index a52126e46307..b70cd3756142 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -190,16 +190,16 @@ int acpi_bus_get_power(acpi_handle handle, int *state) | |||
190 | * Get the device's power state either directly (via _PSC) or | 190 | * Get the device's power state either directly (via _PSC) or |
191 | * indirectly (via power resources). | 191 | * indirectly (via power resources). |
192 | */ | 192 | */ |
193 | if (device->power.flags.explicit_get) { | 193 | if (device->power.flags.power_resources) { |
194 | result = acpi_power_get_inferred_state(device); | ||
195 | if (result) | ||
196 | return result; | ||
197 | } else if (device->power.flags.explicit_get) { | ||
194 | status = acpi_evaluate_integer(device->handle, "_PSC", | 198 | status = acpi_evaluate_integer(device->handle, "_PSC", |
195 | NULL, &psc); | 199 | NULL, &psc); |
196 | if (ACPI_FAILURE(status)) | 200 | if (ACPI_FAILURE(status)) |
197 | return -ENODEV; | 201 | return -ENODEV; |
198 | device->power.state = (int)psc; | 202 | 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 | } | 203 | } |
204 | 204 | ||
205 | *state = device->power.state; | 205 | *state = device->power.state; |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d7a6bbbb834c..1ac28c6a672e 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -76,8 +76,9 @@ enum ec_command { | |||
76 | enum { | 76 | enum { |
77 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ | 77 | EC_FLAGS_QUERY_PENDING, /* Query is pending */ |
78 | EC_FLAGS_GPE_STORM, /* GPE storm detected */ | 78 | EC_FLAGS_GPE_STORM, /* GPE storm detected */ |
79 | EC_FLAGS_HANDLERS_INSTALLED /* Handlers for GPE and | 79 | EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and |
80 | * OpReg are installed */ | 80 | * OpReg are installed */ |
81 | EC_FLAGS_FROZEN, /* Transactions are suspended */ | ||
81 | }; | 82 | }; |
82 | 83 | ||
83 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 84 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
@@ -291,6 +292,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
291 | if (t->rdata) | 292 | if (t->rdata) |
292 | memset(t->rdata, 0, t->rlen); | 293 | memset(t->rdata, 0, t->rlen); |
293 | mutex_lock(&ec->lock); | 294 | mutex_lock(&ec->lock); |
295 | if (test_bit(EC_FLAGS_FROZEN, &ec->flags)) { | ||
296 | status = -EINVAL; | ||
297 | goto unlock; | ||
298 | } | ||
294 | if (ec->global_lock) { | 299 | if (ec->global_lock) { |
295 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 300 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
296 | if (ACPI_FAILURE(status)) { | 301 | if (ACPI_FAILURE(status)) { |
@@ -453,6 +458,32 @@ int ec_transaction(u8 command, | |||
453 | 458 | ||
454 | EXPORT_SYMBOL(ec_transaction); | 459 | EXPORT_SYMBOL(ec_transaction); |
455 | 460 | ||
461 | void acpi_ec_suspend_transactions(void) | ||
462 | { | ||
463 | struct acpi_ec *ec = first_ec; | ||
464 | |||
465 | if (!ec) | ||
466 | return; | ||
467 | |||
468 | mutex_lock(&ec->lock); | ||
469 | /* Prevent transactions from being carried out */ | ||
470 | set_bit(EC_FLAGS_FROZEN, &ec->flags); | ||
471 | mutex_unlock(&ec->lock); | ||
472 | } | ||
473 | |||
474 | void acpi_ec_resume_transactions(void) | ||
475 | { | ||
476 | struct acpi_ec *ec = first_ec; | ||
477 | |||
478 | if (!ec) | ||
479 | return; | ||
480 | |||
481 | mutex_lock(&ec->lock); | ||
482 | /* Allow transactions to be carried out again */ | ||
483 | clear_bit(EC_FLAGS_FROZEN, &ec->flags); | ||
484 | mutex_unlock(&ec->lock); | ||
485 | } | ||
486 | |||
456 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) | 487 | static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 * data) |
457 | { | 488 | { |
458 | int result; | 489 | int result; |
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/processor_core.c b/drivers/acpi/processor_core.c index e9b7b402dbfb..791ac7b0f8df 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -1,383 +1,62 @@ | |||
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> | ||
47 | #include <linux/cpuidle.h> | ||
48 | 11 | ||
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> | 12 | #include <acpi/acpi_drivers.h> |
60 | #include <acpi/processor.h> | 13 | #include <acpi/processor.h> |
61 | 14 | ||
62 | #define PREFIX "ACPI: " | 15 | #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 | 16 | ||
17 | #define PREFIX "ACPI: " | ||
76 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 18 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
77 | ACPI_MODULE_NAME("processor_core"); | 19 | ACPI_MODULE_NAME("processor_core"); |
78 | 20 | ||
79 | MODULE_AUTHOR("Paul Diefenbaugh"); | 21 | 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 | { | 22 | { |
136 | u8 value1 = 0; | 23 | printk(KERN_NOTICE PREFIX "%s detected - " |
137 | u8 value2 = 0; | 24 | "disabling mwait for CPU C-states\n", id->ident); |
138 | 25 | 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; | 26 | return 0; |
233 | } | 27 | } |
234 | 28 | ||
235 | static int acpi_processor_errata(struct acpi_processor *pr) | 29 | static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { |
236 | { | 30 | { |
237 | int result = 0; | 31 | set_no_mwait, "IFL91 board", { |
238 | struct pci_dev *dev = NULL; | 32 | DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), |
239 | 33 | DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"), | |
240 | 34 | DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"), | |
241 | if (!pr) | 35 | DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL}, |
242 | return -EINVAL; | 36 | { |
243 | 37 | set_no_mwait, "Extensa 5220", { | |
244 | /* | 38 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), |
245 | * PIIX4 | 39 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
246 | */ | 40 | DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), |
247 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | 41 | DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, |
248 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | 42 | {}, |
249 | PCI_ANY_ID, NULL); | 43 | }; |
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 | 44 | ||
45 | #ifdef CONFIG_SMP | ||
370 | static int map_lapic_id(struct acpi_subtable_header *entry, | 46 | static int map_lapic_id(struct acpi_subtable_header *entry, |
371 | u32 acpi_id, int *apic_id) | 47 | u32 acpi_id, int *apic_id) |
372 | { | 48 | { |
373 | struct acpi_madt_local_apic *lapic = | 49 | struct acpi_madt_local_apic *lapic = |
374 | (struct acpi_madt_local_apic *)entry; | 50 | (struct acpi_madt_local_apic *)entry; |
375 | if ((lapic->lapic_flags & ACPI_MADT_ENABLED) && | 51 | |
376 | lapic->processor_id == acpi_id) { | 52 | if (!(lapic->lapic_flags & ACPI_MADT_ENABLED)) |
377 | *apic_id = lapic->id; | 53 | return 0; |
378 | return 1; | 54 | |
379 | } | 55 | if (lapic->processor_id != acpi_id) |
380 | return 0; | 56 | return 0; |
57 | |||
58 | *apic_id = lapic->id; | ||
59 | return 1; | ||
381 | } | 60 | } |
382 | 61 | ||
383 | static int map_x2apic_id(struct acpi_subtable_header *entry, | 62 | static int map_x2apic_id(struct acpi_subtable_header *entry, |
@@ -385,22 +64,16 @@ static int map_x2apic_id(struct acpi_subtable_header *entry, | |||
385 | { | 64 | { |
386 | struct acpi_madt_local_x2apic *apic = | 65 | struct acpi_madt_local_x2apic *apic = |
387 | (struct acpi_madt_local_x2apic *)entry; | 66 | (struct acpi_madt_local_x2apic *)entry; |
388 | u32 tmp = apic->local_apic_id; | ||
389 | 67 | ||
390 | /* Only check enabled APICs*/ | ||
391 | if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) | 68 | if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) |
392 | return 0; | 69 | return 0; |
393 | 70 | ||
394 | /* Device statement declaration type */ | 71 | if (device_declaration && (apic->uid == acpi_id)) { |
395 | if (device_declaration) { | 72 | *apic_id = apic->local_apic_id; |
396 | if (apic->uid == acpi_id) | 73 | return 1; |
397 | goto found; | ||
398 | } | 74 | } |
399 | 75 | ||
400 | return 0; | 76 | return 0; |
401 | found: | ||
402 | *apic_id = tmp; | ||
403 | return 1; | ||
404 | } | 77 | } |
405 | 78 | ||
406 | static int map_lsapic_id(struct acpi_subtable_header *entry, | 79 | static int map_lsapic_id(struct acpi_subtable_header *entry, |
@@ -408,35 +81,34 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, | |||
408 | { | 81 | { |
409 | struct acpi_madt_local_sapic *lsapic = | 82 | struct acpi_madt_local_sapic *lsapic = |
410 | (struct acpi_madt_local_sapic *)entry; | 83 | (struct acpi_madt_local_sapic *)entry; |
411 | u32 tmp = (lsapic->id << 8) | lsapic->eid; | ||
412 | 84 | ||
413 | /* Only check enabled APICs*/ | ||
414 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) | 85 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) |
415 | return 0; | 86 | return 0; |
416 | 87 | ||
417 | /* Device statement declaration type */ | ||
418 | if (device_declaration) { | 88 | if (device_declaration) { |
419 | if (entry->length < 16) | 89 | if ((entry->length < 16) || (lsapic->uid != acpi_id)) |
420 | printk(KERN_ERR PREFIX | 90 | return 0; |
421 | "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", | 91 | } else if (lsapic->processor_id != acpi_id) |
422 | tmp); | 92 | 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 | 93 | ||
429 | return 0; | 94 | *apic_id = (lsapic->id << 8) | lsapic->eid; |
430 | found: | ||
431 | *apic_id = tmp; | ||
432 | return 1; | 95 | return 1; |
433 | } | 96 | } |
434 | 97 | ||
435 | static int map_madt_entry(int type, u32 acpi_id) | 98 | static int map_madt_entry(int type, u32 acpi_id) |
436 | { | 99 | { |
437 | unsigned long madt_end, entry; | 100 | unsigned long madt_end, entry; |
101 | static struct acpi_table_madt *madt; | ||
102 | static int read_madt; | ||
438 | int apic_id = -1; | 103 | int apic_id = -1; |
439 | 104 | ||
105 | if (!read_madt) { | ||
106 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | ||
107 | (struct acpi_table_header **)&madt))) | ||
108 | madt = NULL; | ||
109 | read_madt++; | ||
110 | } | ||
111 | |||
440 | if (!madt) | 112 | if (!madt) |
441 | return apic_id; | 113 | return apic_id; |
442 | 114 | ||
@@ -496,7 +168,7 @@ exit: | |||
496 | return apic_id; | 168 | return apic_id; |
497 | } | 169 | } |
498 | 170 | ||
499 | static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) | 171 | int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) |
500 | { | 172 | { |
501 | int i; | 173 | int i; |
502 | int apic_id = -1; | 174 | int apic_id = -1; |
@@ -513,630 +185,170 @@ static int get_cpu_id(acpi_handle handle, int type, u32 acpi_id) | |||
513 | } | 185 | } |
514 | return -1; | 186 | return -1; |
515 | } | 187 | } |
188 | EXPORT_SYMBOL_GPL(acpi_get_cpuid); | ||
516 | #endif | 189 | #endif |
517 | 190 | ||
518 | /* -------------------------------------------------------------------------- | 191 | 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 | { | 192 | { |
524 | acpi_status status = 0; | 193 | int cpuid, type; |
194 | u32 acpi_id; | ||
195 | acpi_status status; | ||
196 | acpi_object_type acpi_type; | ||
197 | unsigned long long tmp; | ||
525 | union acpi_object object = { 0 }; | 198 | union acpi_object object = { 0 }; |
526 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | 199 | 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 | 200 | ||
662 | switch (event) { | 201 | status = acpi_get_type(handle, &acpi_type); |
663 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: | 202 | if (ACPI_FAILURE(status)) |
664 | saved = pr->performance_platform_limit; | 203 | return false; |
665 | acpi_processor_ppc_has_changed(pr, 1); | 204 | |
666 | if (saved == pr->performance_platform_limit) | 205 | switch (acpi_type) { |
667 | break; | 206 | case ACPI_TYPE_PROCESSOR: |
668 | acpi_bus_generate_proc_event(device, event, | 207 | status = acpi_evaluate_object(handle, NULL, NULL, &buffer); |
669 | pr->performance_platform_limit); | 208 | if (ACPI_FAILURE(status)) |
670 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 209 | return false; |
671 | dev_name(&device->dev), event, | 210 | acpi_id = object.processor.proc_id; |
672 | pr->performance_platform_limit); | ||
673 | break; | 211 | break; |
674 | case ACPI_PROCESSOR_NOTIFY_POWER: | 212 | case ACPI_TYPE_DEVICE: |
675 | acpi_processor_cst_has_changed(pr); | 213 | status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp); |
676 | acpi_bus_generate_proc_event(device, event, 0); | 214 | if (ACPI_FAILURE(status)) |
677 | acpi_bus_generate_netlink_event(device->pnp.device_class, | 215 | return false; |
678 | dev_name(&device->dev), event, 0); | 216 | acpi_id = tmp; |
679 | break; | 217 | 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: | 218 | default: |
686 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 219 | return false; |
687 | "Unsupported event [0x%x]\n", event)); | ||
688 | break; | ||
689 | } | 220 | } |
690 | 221 | ||
691 | return; | 222 | type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; |
692 | } | 223 | cpuid = acpi_get_cpuid(handle, type, acpi_id); |
693 | 224 | ||
694 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | 225 | if (cpuid == -1) |
695 | unsigned long action, void *hcpu) | 226 | return false; |
696 | { | ||
697 | unsigned int cpu = (unsigned long)hcpu; | ||
698 | struct acpi_processor *pr = per_cpu(processors, cpu); | ||
699 | 227 | ||
700 | if (action == CPU_ONLINE && pr) { | 228 | 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 | } | 229 | } |
707 | 230 | ||
708 | static struct notifier_block acpi_cpu_notifier = | 231 | static void acpi_set_pdc_bits(u32 *buf) |
709 | { | 232 | { |
710 | .notifier_call = acpi_cpu_soft_notify, | 233 | buf[0] = ACPI_PDC_REVISION_ID; |
711 | }; | 234 | 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 | 235 | ||
755 | per_cpu(processors, pr->id) = pr; | 236 | /* Enable coordination with firmware's _TSD info */ |
237 | buf[2] = ACPI_PDC_SMP_T_SWCOORD; | ||
756 | 238 | ||
757 | result = acpi_processor_add_fs(device); | 239 | /* Twiddle arch-specific bits needed for _PDC */ |
758 | if (result) | 240 | 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 | } | 241 | } |
819 | 242 | ||
820 | static int acpi_processor_remove(struct acpi_device *device, int type) | 243 | static struct acpi_object_list *acpi_processor_alloc_pdc(void) |
821 | { | 244 | { |
822 | struct acpi_processor *pr = NULL; | 245 | struct acpi_object_list *obj_list; |
823 | 246 | union acpi_object *obj; | |
824 | 247 | 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 | 248 | ||
833 | if (type == ACPI_BUS_REMOVAL_EJECT) { | 249 | /* allocate and initialize pdc. It will be used later. */ |
834 | if (acpi_processor_handle_eject(pr)) | 250 | obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL); |
835 | return -EINVAL; | 251 | if (!obj_list) { |
252 | printk(KERN_ERR "Memory allocation error\n"); | ||
253 | return NULL; | ||
836 | } | 254 | } |
837 | 255 | ||
838 | acpi_processor_power_exit(pr, device); | 256 | obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL); |
839 | 257 | if (!obj) { | |
840 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | 258 | printk(KERN_ERR "Memory allocation error\n"); |
841 | 259 | kfree(obj_list); | |
842 | acpi_processor_remove_fs(device); | 260 | 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 | } | 261 | } |
850 | 262 | ||
851 | per_cpu(processors, pr->id) = NULL; | 263 | buf = kmalloc(12, GFP_KERNEL); |
852 | per_cpu(processor_device_array, pr->id) = NULL; | 264 | if (!buf) { |
853 | 265 | printk(KERN_ERR "Memory allocation error\n"); | |
854 | free: | 266 | kfree(obj); |
855 | free_cpumask_var(pr->throttling.shared_cpu_map); | 267 | kfree(obj_list); |
856 | kfree(pr); | 268 | 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 | } | 269 | } |
899 | 270 | ||
900 | if (acpi_bus_get_device(phandle, &pdev)) { | 271 | acpi_set_pdc_bits(buf); |
901 | return -ENODEV; | ||
902 | } | ||
903 | 272 | ||
904 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { | 273 | obj->type = ACPI_TYPE_BUFFER; |
905 | return -ENODEV; | 274 | obj->buffer.length = 12; |
906 | } | 275 | obj->buffer.pointer = (u8 *) buf; |
276 | obj_list->count = 1; | ||
277 | obj_list->pointer = obj; | ||
907 | 278 | ||
908 | return 0; | 279 | return obj_list; |
909 | } | 280 | } |
910 | 281 | ||
911 | static void __ref acpi_processor_hotplug_notify(acpi_handle handle, | 282 | /* |
912 | u32 event, void *data) | 283 | * _PDC is required for a BIOS-OS handshake for most of the newer |
284 | * ACPI processor features. | ||
285 | */ | ||
286 | static int | ||
287 | acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) | ||
913 | { | 288 | { |
914 | struct acpi_processor *pr; | 289 | acpi_status status = AE_OK; |
915 | struct acpi_device *device = NULL; | ||
916 | int result; | ||
917 | |||
918 | 290 | ||
919 | switch (event) { | 291 | if (idle_nomwait) { |
920 | case ACPI_NOTIFY_BUS_CHECK: | 292 | /* |
921 | case ACPI_NOTIFY_DEVICE_CHECK: | 293 | * If mwait is disabled for CPU C-states, the C2C3_FFH access |
922 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 294 | * mode will be disabled in the parameter of _PDC object. |
923 | "Processor driver received %s event\n", | 295 | * Of course C1_FFH access mode will also be disabled. |
924 | (event == ACPI_NOTIFY_BUS_CHECK) ? | 296 | */ |
925 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK")); | 297 | union acpi_object *obj; |
926 | 298 | u32 *buffer = NULL; | |
927 | if (!is_processor_present(handle)) | ||
928 | break; | ||
929 | 299 | ||
930 | if (acpi_bus_get_device(handle, &device)) { | 300 | obj = pdc_in->pointer; |
931 | result = acpi_processor_device_add(handle, &device); | 301 | buffer = (u32 *)(obj->buffer.pointer); |
932 | if (result) | 302 | 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 | 303 | ||
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 | } | 304 | } |
305 | status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL); | ||
959 | 306 | ||
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)) | 307 | if (ACPI_FAILURE(status)) |
973 | return (AE_OK); | 308 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
974 | 309 | "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 | 310 | ||
994 | return (AE_OK); | 311 | return status; |
995 | } | 312 | } |
996 | 313 | ||
997 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | 314 | void acpi_processor_set_pdc(acpi_handle handle) |
998 | { | 315 | { |
316 | struct acpi_object_list *obj_list; | ||
999 | 317 | ||
1000 | if (!is_processor_present(handle)) { | 318 | if (arch_has_acpi_pdc() == false) |
1001 | return AE_ERROR; | 319 | return; |
1002 | } | ||
1003 | 320 | ||
1004 | if (acpi_map_lsapic(handle, p_cpu)) | 321 | obj_list = acpi_processor_alloc_pdc(); |
1005 | return AE_ERROR; | 322 | if (!obj_list) |
323 | return; | ||
1006 | 324 | ||
1007 | if (arch_register_cpu(*p_cpu)) { | 325 | acpi_processor_eval_pdc(handle, obj_list); |
1008 | acpi_unmap_lsapic(*p_cpu); | ||
1009 | return AE_ERROR; | ||
1010 | } | ||
1011 | 326 | ||
1012 | return AE_OK; | 327 | kfree(obj_list->pointer->buffer.pointer); |
328 | kfree(obj_list->pointer); | ||
329 | kfree(obj_list); | ||
1013 | } | 330 | } |
331 | EXPORT_SYMBOL_GPL(acpi_processor_set_pdc); | ||
1014 | 332 | ||
1015 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | 333 | static acpi_status |
334 | early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
1016 | { | 335 | { |
1017 | if (cpu_online(pr->id)) | 336 | if (processor_physically_present(handle) == false) |
1018 | cpu_down(pr->id); | 337 | return AE_OK; |
1019 | 338 | ||
1020 | arch_unregister_cpu(pr->id); | 339 | acpi_processor_set_pdc(handle); |
1021 | acpi_unmap_lsapic(pr->id); | 340 | 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 | } | 341 | } |
1033 | #endif | ||
1034 | 342 | ||
1035 | static | 343 | void __init acpi_early_processor_set_pdc(void) |
1036 | void acpi_processor_install_hotplug_notify(void) | ||
1037 | { | 344 | { |
1038 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | 345 | /* |
1039 | int action = INSTALL_NOTIFY_HANDLER; | 346 | * Check whether the system is DMI table. If yes, OSPM |
1040 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | 347 | * should not use mwait for CPU-states. |
1041 | ACPI_ROOT_OBJECT, | 348 | */ |
1042 | ACPI_UINT32_MAX, | 349 | 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 | 350 | ||
1048 | static | 351 | 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, | 352 | ACPI_UINT32_MAX, |
1056 | processor_walk_namespace_cb, NULL, &action, NULL); | 353 | early_init_pdc, NULL, NULL, NULL); |
1057 | #endif | ||
1058 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | ||
1059 | } | 354 | } |
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..b5658cdce27f --- /dev/null +++ b/drivers/acpi/processor_driver.c | |||
@@ -0,0 +1,978 @@ | |||
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 | |||
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> | ||
60 | #include <acpi/processor.h> | ||
61 | |||
62 | #define PREFIX "ACPI: " | ||
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 | |||
76 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | ||
77 | ACPI_MODULE_NAME("processor_driver"); | ||
78 | |||
79 | MODULE_AUTHOR("Paul Diefenbaugh"); | ||
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 | { | ||
136 | u8 value1 = 0; | ||
137 | u8 value2 = 0; | ||
138 | |||
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; | ||
233 | } | ||
234 | |||
235 | static int acpi_processor_errata(struct acpi_processor *pr) | ||
236 | { | ||
237 | int result = 0; | ||
238 | struct pci_dev *dev = NULL; | ||
239 | |||
240 | |||
241 | if (!pr) | ||
242 | return -EINVAL; | ||
243 | |||
244 | /* | ||
245 | * PIIX4 | ||
246 | */ | ||
247 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
248 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | ||
249 | PCI_ANY_ID, NULL); | ||
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 | /* -------------------------------------------------------------------------- | ||
363 | Driver Interface | ||
364 | -------------------------------------------------------------------------- */ | ||
365 | |||
366 | static int acpi_processor_get_info(struct acpi_device *device) | ||
367 | { | ||
368 | acpi_status status = 0; | ||
369 | union acpi_object object = { 0 }; | ||
370 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | ||
371 | struct acpi_processor *pr; | ||
372 | int cpu_index, device_declaration = 0; | ||
373 | static int cpu0_initialized; | ||
374 | |||
375 | pr = acpi_driver_data(device); | ||
376 | if (!pr) | ||
377 | return -EINVAL; | ||
378 | |||
379 | if (num_online_cpus() > 1) | ||
380 | errata.smp = TRUE; | ||
381 | |||
382 | acpi_processor_errata(pr); | ||
383 | |||
384 | /* | ||
385 | * Check to see if we have bus mastering arbitration control. This | ||
386 | * is required for proper C3 usage (to maintain cache coherency). | ||
387 | */ | ||
388 | if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { | ||
389 | pr->flags.bm_control = 1; | ||
390 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
391 | "Bus mastering arbitration control present\n")); | ||
392 | } else | ||
393 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
394 | "No bus mastering arbitration control\n")); | ||
395 | |||
396 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { | ||
397 | /* Declared with "Processor" statement; match ProcessorID */ | ||
398 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | ||
399 | if (ACPI_FAILURE(status)) { | ||
400 | printk(KERN_ERR PREFIX "Evaluating processor object\n"); | ||
401 | return -ENODEV; | ||
402 | } | ||
403 | |||
404 | /* | ||
405 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | ||
406 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in | ||
407 | * arch/xxx/acpi.c | ||
408 | */ | ||
409 | pr->acpi_id = object.processor.proc_id; | ||
410 | } else { | ||
411 | /* | ||
412 | * Declared with "Device" statement; match _UID. | ||
413 | * Note that we don't handle string _UIDs yet. | ||
414 | */ | ||
415 | unsigned long long value; | ||
416 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | ||
417 | NULL, &value); | ||
418 | if (ACPI_FAILURE(status)) { | ||
419 | printk(KERN_ERR PREFIX | ||
420 | "Evaluating processor _UID [%#x]\n", status); | ||
421 | return -ENODEV; | ||
422 | } | ||
423 | device_declaration = 1; | ||
424 | pr->acpi_id = value; | ||
425 | } | ||
426 | cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); | ||
427 | |||
428 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
429 | if (!cpu0_initialized && (cpu_index == -1) && | ||
430 | (num_online_cpus() == 1)) { | ||
431 | cpu_index = 0; | ||
432 | } | ||
433 | |||
434 | cpu0_initialized = 1; | ||
435 | |||
436 | pr->id = cpu_index; | ||
437 | |||
438 | /* | ||
439 | * Extra Processor objects may be enumerated on MP systems with | ||
440 | * less than the max # of CPUs. They should be ignored _iff | ||
441 | * they are physically not present. | ||
442 | */ | ||
443 | if (pr->id == -1) { | ||
444 | if (ACPI_FAILURE | ||
445 | (acpi_processor_hotadd_init(pr->handle, &pr->id))) { | ||
446 | return -ENODEV; | ||
447 | } | ||
448 | } | ||
449 | /* | ||
450 | * On some boxes several processors use the same processor bus id. | ||
451 | * But they are located in different scope. For example: | ||
452 | * \_SB.SCK0.CPU0 | ||
453 | * \_SB.SCK1.CPU0 | ||
454 | * Rename the processor device bus id. And the new bus id will be | ||
455 | * generated as the following format: | ||
456 | * CPU+CPU ID. | ||
457 | */ | ||
458 | sprintf(acpi_device_bid(device), "CPU%X", pr->id); | ||
459 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, | ||
460 | pr->acpi_id)); | ||
461 | |||
462 | if (!object.processor.pblk_address) | ||
463 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); | ||
464 | else if (object.processor.pblk_length != 6) | ||
465 | printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", | ||
466 | object.processor.pblk_length); | ||
467 | else { | ||
468 | pr->throttling.address = object.processor.pblk_address; | ||
469 | pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; | ||
470 | pr->throttling.duty_width = acpi_gbl_FADT.duty_width; | ||
471 | |||
472 | pr->pblk = object.processor.pblk_address; | ||
473 | |||
474 | /* | ||
475 | * We don't care about error returns - we just try to mark | ||
476 | * these reserved so that nobody else is confused into thinking | ||
477 | * that this region might be unused.. | ||
478 | * | ||
479 | * (In particular, allocating the IO range for Cardbus) | ||
480 | */ | ||
481 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | ||
482 | } | ||
483 | |||
484 | /* | ||
485 | * If ACPI describes a slot number for this CPU, we can use it | ||
486 | * ensure we get the right value in the "physical id" field | ||
487 | * of /proc/cpuinfo | ||
488 | */ | ||
489 | status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); | ||
490 | if (ACPI_SUCCESS(status)) | ||
491 | arch_fix_phys_package_id(pr->id, object.integer.value); | ||
492 | |||
493 | return 0; | ||
494 | } | ||
495 | |||
496 | static DEFINE_PER_CPU(void *, processor_device_array); | ||
497 | |||
498 | static void acpi_processor_notify(struct acpi_device *device, u32 event) | ||
499 | { | ||
500 | struct acpi_processor *pr = acpi_driver_data(device); | ||
501 | int saved; | ||
502 | |||
503 | if (!pr) | ||
504 | return; | ||
505 | |||
506 | switch (event) { | ||
507 | case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: | ||
508 | saved = pr->performance_platform_limit; | ||
509 | acpi_processor_ppc_has_changed(pr, 1); | ||
510 | if (saved == pr->performance_platform_limit) | ||
511 | break; | ||
512 | acpi_bus_generate_proc_event(device, event, | ||
513 | pr->performance_platform_limit); | ||
514 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
515 | dev_name(&device->dev), event, | ||
516 | pr->performance_platform_limit); | ||
517 | break; | ||
518 | case ACPI_PROCESSOR_NOTIFY_POWER: | ||
519 | acpi_processor_cst_has_changed(pr); | ||
520 | acpi_bus_generate_proc_event(device, event, 0); | ||
521 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
522 | dev_name(&device->dev), event, 0); | ||
523 | break; | ||
524 | case ACPI_PROCESSOR_NOTIFY_THROTTLING: | ||
525 | acpi_processor_tstate_has_changed(pr); | ||
526 | acpi_bus_generate_proc_event(device, event, 0); | ||
527 | acpi_bus_generate_netlink_event(device->pnp.device_class, | ||
528 | dev_name(&device->dev), event, 0); | ||
529 | default: | ||
530 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
531 | "Unsupported event [0x%x]\n", event)); | ||
532 | break; | ||
533 | } | ||
534 | |||
535 | return; | ||
536 | } | ||
537 | |||
538 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | ||
539 | unsigned long action, void *hcpu) | ||
540 | { | ||
541 | unsigned int cpu = (unsigned long)hcpu; | ||
542 | struct acpi_processor *pr = per_cpu(processors, cpu); | ||
543 | |||
544 | if (action == CPU_ONLINE && pr) { | ||
545 | acpi_processor_ppc_has_changed(pr, 0); | ||
546 | acpi_processor_cst_has_changed(pr); | ||
547 | acpi_processor_tstate_has_changed(pr); | ||
548 | } | ||
549 | return NOTIFY_OK; | ||
550 | } | ||
551 | |||
552 | static struct notifier_block acpi_cpu_notifier = | ||
553 | { | ||
554 | .notifier_call = acpi_cpu_soft_notify, | ||
555 | }; | ||
556 | |||
557 | static int __cpuinit acpi_processor_add(struct acpi_device *device) | ||
558 | { | ||
559 | struct acpi_processor *pr = NULL; | ||
560 | int result = 0; | ||
561 | struct sys_device *sysdev; | ||
562 | |||
563 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); | ||
564 | if (!pr) | ||
565 | return -ENOMEM; | ||
566 | |||
567 | if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
568 | kfree(pr); | ||
569 | return -ENOMEM; | ||
570 | } | ||
571 | |||
572 | pr->handle = device->handle; | ||
573 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | ||
574 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | ||
575 | device->driver_data = pr; | ||
576 | |||
577 | result = acpi_processor_get_info(device); | ||
578 | if (result) { | ||
579 | /* Processor is physically not present */ | ||
580 | return 0; | ||
581 | } | ||
582 | |||
583 | BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); | ||
584 | |||
585 | /* | ||
586 | * Buggy BIOS check | ||
587 | * ACPI id of processors can be reported wrongly by the BIOS. | ||
588 | * Don't trust it blindly | ||
589 | */ | ||
590 | if (per_cpu(processor_device_array, pr->id) != NULL && | ||
591 | per_cpu(processor_device_array, pr->id) != device) { | ||
592 | printk(KERN_WARNING "BIOS reported wrong ACPI id " | ||
593 | "for the processor\n"); | ||
594 | result = -ENODEV; | ||
595 | goto err_free_cpumask; | ||
596 | } | ||
597 | per_cpu(processor_device_array, pr->id) = device; | ||
598 | |||
599 | per_cpu(processors, pr->id) = pr; | ||
600 | |||
601 | result = acpi_processor_add_fs(device); | ||
602 | if (result) | ||
603 | goto err_free_cpumask; | ||
604 | |||
605 | sysdev = get_cpu_sysdev(pr->id); | ||
606 | if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) { | ||
607 | result = -EFAULT; | ||
608 | goto err_remove_fs; | ||
609 | } | ||
610 | |||
611 | #ifdef CONFIG_CPU_FREQ | ||
612 | acpi_processor_ppc_has_changed(pr, 0); | ||
613 | #endif | ||
614 | acpi_processor_get_throttling_info(pr); | ||
615 | acpi_processor_get_limit_info(pr); | ||
616 | |||
617 | |||
618 | acpi_processor_power_init(pr, device); | ||
619 | |||
620 | pr->cdev = thermal_cooling_device_register("Processor", device, | ||
621 | &processor_cooling_ops); | ||
622 | if (IS_ERR(pr->cdev)) { | ||
623 | result = PTR_ERR(pr->cdev); | ||
624 | goto err_power_exit; | ||
625 | } | ||
626 | |||
627 | dev_dbg(&device->dev, "registered as cooling_device%d\n", | ||
628 | pr->cdev->id); | ||
629 | |||
630 | result = sysfs_create_link(&device->dev.kobj, | ||
631 | &pr->cdev->device.kobj, | ||
632 | "thermal_cooling"); | ||
633 | if (result) { | ||
634 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
635 | goto err_thermal_unregister; | ||
636 | } | ||
637 | result = sysfs_create_link(&pr->cdev->device.kobj, | ||
638 | &device->dev.kobj, | ||
639 | "device"); | ||
640 | if (result) { | ||
641 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
642 | goto err_remove_sysfs; | ||
643 | } | ||
644 | |||
645 | return 0; | ||
646 | |||
647 | err_remove_sysfs: | ||
648 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
649 | err_thermal_unregister: | ||
650 | thermal_cooling_device_unregister(pr->cdev); | ||
651 | err_power_exit: | ||
652 | acpi_processor_power_exit(pr, device); | ||
653 | err_remove_fs: | ||
654 | acpi_processor_remove_fs(device); | ||
655 | err_free_cpumask: | ||
656 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
657 | |||
658 | return result; | ||
659 | } | ||
660 | |||
661 | static int acpi_processor_remove(struct acpi_device *device, int type) | ||
662 | { | ||
663 | struct acpi_processor *pr = NULL; | ||
664 | |||
665 | |||
666 | if (!device || !acpi_driver_data(device)) | ||
667 | return -EINVAL; | ||
668 | |||
669 | pr = acpi_driver_data(device); | ||
670 | |||
671 | if (pr->id >= nr_cpu_ids) | ||
672 | goto free; | ||
673 | |||
674 | if (type == ACPI_BUS_REMOVAL_EJECT) { | ||
675 | if (acpi_processor_handle_eject(pr)) | ||
676 | return -EINVAL; | ||
677 | } | ||
678 | |||
679 | acpi_processor_power_exit(pr, device); | ||
680 | |||
681 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | ||
682 | |||
683 | acpi_processor_remove_fs(device); | ||
684 | |||
685 | if (pr->cdev) { | ||
686 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | ||
687 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | ||
688 | thermal_cooling_device_unregister(pr->cdev); | ||
689 | pr->cdev = NULL; | ||
690 | } | ||
691 | |||
692 | per_cpu(processors, pr->id) = NULL; | ||
693 | per_cpu(processor_device_array, pr->id) = NULL; | ||
694 | |||
695 | free: | ||
696 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
697 | kfree(pr); | ||
698 | |||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
703 | /**************************************************************************** | ||
704 | * Acpi processor hotplug support * | ||
705 | ****************************************************************************/ | ||
706 | |||
707 | static int is_processor_present(acpi_handle handle) | ||
708 | { | ||
709 | acpi_status status; | ||
710 | unsigned long long sta = 0; | ||
711 | |||
712 | |||
713 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
714 | |||
715 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT)) | ||
716 | return 1; | ||
717 | |||
718 | /* | ||
719 | * _STA is mandatory for a processor that supports hot plug | ||
720 | */ | ||
721 | if (status == AE_NOT_FOUND) | ||
722 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
723 | "Processor does not support hot plug\n")); | ||
724 | else | ||
725 | ACPI_EXCEPTION((AE_INFO, status, | ||
726 | "Processor Device is not present")); | ||
727 | return 0; | ||
728 | } | ||
729 | |||
730 | static | ||
731 | int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) | ||
732 | { | ||
733 | acpi_handle phandle; | ||
734 | struct acpi_device *pdev; | ||
735 | |||
736 | |||
737 | if (acpi_get_parent(handle, &phandle)) { | ||
738 | return -ENODEV; | ||
739 | } | ||
740 | |||
741 | if (acpi_bus_get_device(phandle, &pdev)) { | ||
742 | return -ENODEV; | ||
743 | } | ||
744 | |||
745 | if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { | ||
746 | return -ENODEV; | ||
747 | } | ||
748 | |||
749 | return 0; | ||
750 | } | ||
751 | |||
752 | static void __ref acpi_processor_hotplug_notify(acpi_handle handle, | ||
753 | u32 event, void *data) | ||
754 | { | ||
755 | struct acpi_processor *pr; | ||
756 | struct acpi_device *device = NULL; | ||
757 | int result; | ||
758 | |||
759 | |||
760 | switch (event) { | ||
761 | case ACPI_NOTIFY_BUS_CHECK: | ||
762 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
763 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
764 | "Processor driver received %s event\n", | ||
765 | (event == ACPI_NOTIFY_BUS_CHECK) ? | ||
766 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK")); | ||
767 | |||
768 | if (!is_processor_present(handle)) | ||
769 | break; | ||
770 | |||
771 | if (acpi_bus_get_device(handle, &device)) { | ||
772 | result = acpi_processor_device_add(handle, &device); | ||
773 | if (result) | ||
774 | printk(KERN_ERR PREFIX | ||
775 | "Unable to add the device\n"); | ||
776 | break; | ||
777 | } | ||
778 | break; | ||
779 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
780 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
781 | "received ACPI_NOTIFY_EJECT_REQUEST\n")); | ||
782 | |||
783 | if (acpi_bus_get_device(handle, &device)) { | ||
784 | printk(KERN_ERR PREFIX | ||
785 | "Device don't exist, dropping EJECT\n"); | ||
786 | break; | ||
787 | } | ||
788 | pr = acpi_driver_data(device); | ||
789 | if (!pr) { | ||
790 | printk(KERN_ERR PREFIX | ||
791 | "Driver data is NULL, dropping EJECT\n"); | ||
792 | return; | ||
793 | } | ||
794 | break; | ||
795 | default: | ||
796 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
797 | "Unsupported event [0x%x]\n", event)); | ||
798 | break; | ||
799 | } | ||
800 | |||
801 | return; | ||
802 | } | ||
803 | |||
804 | static acpi_status | ||
805 | processor_walk_namespace_cb(acpi_handle handle, | ||
806 | u32 lvl, void *context, void **rv) | ||
807 | { | ||
808 | acpi_status status; | ||
809 | int *action = context; | ||
810 | acpi_object_type type = 0; | ||
811 | |||
812 | status = acpi_get_type(handle, &type); | ||
813 | if (ACPI_FAILURE(status)) | ||
814 | return (AE_OK); | ||
815 | |||
816 | if (type != ACPI_TYPE_PROCESSOR) | ||
817 | return (AE_OK); | ||
818 | |||
819 | switch (*action) { | ||
820 | case INSTALL_NOTIFY_HANDLER: | ||
821 | acpi_install_notify_handler(handle, | ||
822 | ACPI_SYSTEM_NOTIFY, | ||
823 | acpi_processor_hotplug_notify, | ||
824 | NULL); | ||
825 | break; | ||
826 | case UNINSTALL_NOTIFY_HANDLER: | ||
827 | acpi_remove_notify_handler(handle, | ||
828 | ACPI_SYSTEM_NOTIFY, | ||
829 | acpi_processor_hotplug_notify); | ||
830 | break; | ||
831 | default: | ||
832 | break; | ||
833 | } | ||
834 | |||
835 | return (AE_OK); | ||
836 | } | ||
837 | |||
838 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | ||
839 | { | ||
840 | |||
841 | if (!is_processor_present(handle)) { | ||
842 | return AE_ERROR; | ||
843 | } | ||
844 | |||
845 | if (acpi_map_lsapic(handle, p_cpu)) | ||
846 | return AE_ERROR; | ||
847 | |||
848 | if (arch_register_cpu(*p_cpu)) { | ||
849 | acpi_unmap_lsapic(*p_cpu); | ||
850 | return AE_ERROR; | ||
851 | } | ||
852 | |||
853 | return AE_OK; | ||
854 | } | ||
855 | |||
856 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
857 | { | ||
858 | if (cpu_online(pr->id)) | ||
859 | cpu_down(pr->id); | ||
860 | |||
861 | arch_unregister_cpu(pr->id); | ||
862 | acpi_unmap_lsapic(pr->id); | ||
863 | return (0); | ||
864 | } | ||
865 | #else | ||
866 | static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) | ||
867 | { | ||
868 | return AE_ERROR; | ||
869 | } | ||
870 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
871 | { | ||
872 | return (-EINVAL); | ||
873 | } | ||
874 | #endif | ||
875 | |||
876 | static | ||
877 | void acpi_processor_install_hotplug_notify(void) | ||
878 | { | ||
879 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
880 | int action = INSTALL_NOTIFY_HANDLER; | ||
881 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | ||
882 | ACPI_ROOT_OBJECT, | ||
883 | ACPI_UINT32_MAX, | ||
884 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
885 | #endif | ||
886 | register_hotcpu_notifier(&acpi_cpu_notifier); | ||
887 | } | ||
888 | |||
889 | static | ||
890 | void acpi_processor_uninstall_hotplug_notify(void) | ||
891 | { | ||
892 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
893 | int action = UNINSTALL_NOTIFY_HANDLER; | ||
894 | acpi_walk_namespace(ACPI_TYPE_PROCESSOR, | ||
895 | ACPI_ROOT_OBJECT, | ||
896 | ACPI_UINT32_MAX, | ||
897 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
898 | #endif | ||
899 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | ||
900 | } | ||
901 | |||
902 | /* | ||
903 | * We keep the driver loaded even when ACPI is not running. | ||
904 | * This is needed for the powernow-k8 driver, that works even without | ||
905 | * ACPI, but needs symbols from this driver | ||
906 | */ | ||
907 | |||
908 | static int __init acpi_processor_init(void) | ||
909 | { | ||
910 | int result = 0; | ||
911 | |||
912 | if (acpi_disabled) | ||
913 | return 0; | ||
914 | |||
915 | memset(&errata, 0, sizeof(errata)); | ||
916 | |||
917 | #ifdef CONFIG_ACPI_PROCFS | ||
918 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
919 | if (!acpi_processor_dir) | ||
920 | return -ENOMEM; | ||
921 | #endif | ||
922 | result = cpuidle_register_driver(&acpi_idle_driver); | ||
923 | if (result < 0) | ||
924 | goto out_proc; | ||
925 | |||
926 | result = acpi_bus_register_driver(&acpi_processor_driver); | ||
927 | if (result < 0) | ||
928 | goto out_cpuidle; | ||
929 | |||
930 | acpi_processor_install_hotplug_notify(); | ||
931 | |||
932 | acpi_thermal_cpufreq_init(); | ||
933 | |||
934 | acpi_processor_ppc_init(); | ||
935 | |||
936 | acpi_processor_throttling_init(); | ||
937 | |||
938 | return 0; | ||
939 | |||
940 | out_cpuidle: | ||
941 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
942 | |||
943 | out_proc: | ||
944 | #ifdef CONFIG_ACPI_PROCFS | ||
945 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
946 | #endif | ||
947 | |||
948 | return result; | ||
949 | } | ||
950 | |||
951 | static void __exit acpi_processor_exit(void) | ||
952 | { | ||
953 | if (acpi_disabled) | ||
954 | return; | ||
955 | |||
956 | acpi_processor_ppc_exit(); | ||
957 | |||
958 | acpi_thermal_cpufreq_exit(); | ||
959 | |||
960 | acpi_processor_uninstall_hotplug_notify(); | ||
961 | |||
962 | acpi_bus_unregister_driver(&acpi_processor_driver); | ||
963 | |||
964 | cpuidle_unregister_driver(&acpi_idle_driver); | ||
965 | |||
966 | #ifdef CONFIG_ACPI_PROCFS | ||
967 | remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); | ||
968 | #endif | ||
969 | |||
970 | return; | ||
971 | } | ||
972 | |||
973 | module_init(acpi_processor_init); | ||
974 | module_exit(acpi_processor_exit); | ||
975 | |||
976 | EXPORT_SYMBOL(acpi_processor_set_thermal_limit); | ||
977 | |||
978 | MODULE_ALIAS("processor"); | ||
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_throttling.c b/drivers/acpi/processor_throttling.c index 7ded7542fc9d..29c6f5766dcf 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -1133,9 +1133,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr) | |||
1133 | int result = 0; | 1133 | int result = 0; |
1134 | struct acpi_processor_throttling *pthrottling; | 1134 | struct acpi_processor_throttling *pthrottling; |
1135 | 1135 | ||
1136 | if (!pr) | ||
1137 | return -EINVAL; | ||
1138 | |||
1139 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 1136 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
1140 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", | 1137 | "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", |
1141 | pr->throttling.address, | 1138 | pr->throttling.address, |
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index b16ddbf23a9c..89ad11138e48 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -217,6 +217,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy, | |||
217 | case POWER_SUPPLY_PROP_TECHNOLOGY: | 217 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
218 | val->intval = acpi_battery_technology(battery); | 218 | val->intval = acpi_battery_technology(battery); |
219 | break; | 219 | break; |
220 | case POWER_SUPPLY_PROP_CYCLE_COUNT: | ||
221 | val->intval = battery->cycle_count; | ||
222 | break; | ||
220 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | 223 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
221 | val->intval = battery->design_voltage * | 224 | val->intval = battery->design_voltage * |
222 | acpi_battery_vscale(battery) * 1000; | 225 | acpi_battery_vscale(battery) * 1000; |
@@ -276,6 +279,7 @@ static enum power_supply_property sbs_charge_battery_props[] = { | |||
276 | POWER_SUPPLY_PROP_STATUS, | 279 | POWER_SUPPLY_PROP_STATUS, |
277 | POWER_SUPPLY_PROP_PRESENT, | 280 | POWER_SUPPLY_PROP_PRESENT, |
278 | POWER_SUPPLY_PROP_TECHNOLOGY, | 281 | POWER_SUPPLY_PROP_TECHNOLOGY, |
282 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
279 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | 283 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
280 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | 284 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
281 | POWER_SUPPLY_PROP_CURRENT_NOW, | 285 | POWER_SUPPLY_PROP_CURRENT_NOW, |
@@ -560,6 +564,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset) | |||
560 | battery->design_voltage * acpi_battery_vscale(battery)); | 564 | battery->design_voltage * acpi_battery_vscale(battery)); |
561 | seq_printf(seq, "design capacity warning: unknown\n"); | 565 | seq_printf(seq, "design capacity warning: unknown\n"); |
562 | seq_printf(seq, "design capacity low: unknown\n"); | 566 | seq_printf(seq, "design capacity low: unknown\n"); |
567 | seq_printf(seq, "cycle count: %i\n", battery->cycle_count); | ||
563 | seq_printf(seq, "capacity granularity 1: unknown\n"); | 568 | seq_printf(seq, "capacity granularity 1: unknown\n"); |
564 | seq_printf(seq, "capacity granularity 2: unknown\n"); | 569 | seq_printf(seq, "capacity granularity 2: unknown\n"); |
565 | seq_printf(seq, "model number: %s\n", battery->device_name); | 570 | seq_printf(seq, "model number: %s\n", battery->device_name); |
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/thermal.c b/drivers/acpi/thermal.c index 9073ada88835..5d3893558cf7 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -368,7 +368,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
368 | int valid = 0; | 368 | int valid = 0; |
369 | int i; | 369 | int i; |
370 | 370 | ||
371 | /* Critical Shutdown (required) */ | 371 | /* Critical Shutdown */ |
372 | if (flag & ACPI_TRIPS_CRITICAL) { | 372 | if (flag & ACPI_TRIPS_CRITICAL) { |
373 | status = acpi_evaluate_integer(tz->device->handle, | 373 | status = acpi_evaluate_integer(tz->device->handle, |
374 | "_CRT", NULL, &tmp); | 374 | "_CRT", NULL, &tmp); |
@@ -379,17 +379,19 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
379 | * Below zero (Celsius) values clearly aren't right for sure.. | 379 | * Below zero (Celsius) values clearly aren't right for sure.. |
380 | * ... so lets discard those as invalid. | 380 | * ... so lets discard those as invalid. |
381 | */ | 381 | */ |
382 | if (ACPI_FAILURE(status) || | 382 | if (ACPI_FAILURE(status)) { |
383 | tz->trips.critical.temperature <= 2732) { | 383 | tz->trips.critical.flags.valid = 0; |
384 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
385 | "No critical threshold\n")); | ||
386 | } else if (tmp <= 2732) { | ||
387 | printk(KERN_WARNING FW_BUG "Invalid critical threshold " | ||
388 | "(%llu)\n", tmp); | ||
384 | tz->trips.critical.flags.valid = 0; | 389 | tz->trips.critical.flags.valid = 0; |
385 | ACPI_EXCEPTION((AE_INFO, status, | ||
386 | "No or invalid critical threshold")); | ||
387 | return -ENODEV; | ||
388 | } else { | 390 | } else { |
389 | tz->trips.critical.flags.valid = 1; | 391 | tz->trips.critical.flags.valid = 1; |
390 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 392 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
391 | "Found critical threshold [%lu]\n", | 393 | "Found critical threshold [%lu]\n", |
392 | tz->trips.critical.temperature)); | 394 | tz->trips.critical.temperature)); |
393 | } | 395 | } |
394 | if (tz->trips.critical.flags.valid == 1) { | 396 | if (tz->trips.critical.flags.valid == 1) { |
395 | if (crt == -1) { | 397 | if (crt == -1) { |
@@ -575,7 +577,23 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) | |||
575 | 577 | ||
576 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) | 578 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) |
577 | { | 579 | { |
578 | return acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); | 580 | int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); |
581 | |||
582 | if (ret) | ||
583 | return ret; | ||
584 | |||
585 | valid = tz->trips.critical.flags.valid | | ||
586 | tz->trips.hot.flags.valid | | ||
587 | tz->trips.passive.flags.valid; | ||
588 | |||
589 | for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) | ||
590 | valid |= tz->trips.active[i].flags.valid; | ||
591 | |||
592 | if (!valid) { | ||
593 | printk(KERN_WARNING FW_BUG "No valid trip found\n"); | ||
594 | return -ENODEV; | ||
595 | } | ||
596 | return 0; | ||
579 | } | 597 | } |
580 | 598 | ||
581 | static void acpi_thermal_check(void *data) | 599 | static void acpi_thermal_check(void *data) |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 11882dbe2094..c9a49f4747e6 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -289,51 +289,6 @@ acpi_evaluate_integer(acpi_handle handle, | |||
289 | 289 | ||
290 | EXPORT_SYMBOL(acpi_evaluate_integer); | 290 | EXPORT_SYMBOL(acpi_evaluate_integer); |
291 | 291 | ||
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 | 292 | acpi_status |
338 | acpi_evaluate_reference(acpi_handle handle, | 293 | acpi_evaluate_reference(acpi_handle handle, |
339 | acpi_string pathname, | 294 | acpi_string pathname, |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 6e9b49149fce..2ff2b6ab5b6c 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -327,7 +327,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, | |||
327 | int level); | 327 | int level); |
328 | static int acpi_video_device_lcd_get_level_current( | 328 | static int acpi_video_device_lcd_get_level_current( |
329 | struct acpi_video_device *device, | 329 | struct acpi_video_device *device, |
330 | unsigned long long *level); | 330 | unsigned long long *level, int init); |
331 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 331 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
332 | u32 level_current, u32 event); | 332 | u32 level_current, u32 event); |
333 | static int acpi_video_switch_brightness(struct acpi_video_device *device, | 333 | static int acpi_video_switch_brightness(struct acpi_video_device *device, |
@@ -345,7 +345,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd) | |||
345 | struct acpi_video_device *vd = | 345 | struct acpi_video_device *vd = |
346 | (struct acpi_video_device *)bl_get_data(bd); | 346 | (struct acpi_video_device *)bl_get_data(bd); |
347 | 347 | ||
348 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level)) | 348 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0)) |
349 | return -EINVAL; | 349 | return -EINVAL; |
350 | for (i = 2; i < vd->brightness->count; i++) { | 350 | for (i = 2; i < vd->brightness->count; i++) { |
351 | if (vd->brightness->levels[i] == cur_level) | 351 | if (vd->brightness->levels[i] == cur_level) |
@@ -414,7 +414,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig | |||
414 | unsigned long long level; | 414 | unsigned long long level; |
415 | int offset; | 415 | int offset; |
416 | 416 | ||
417 | if (acpi_video_device_lcd_get_level_current(video, &level)) | 417 | if (acpi_video_device_lcd_get_level_current(video, &level, 0)) |
418 | return -EINVAL; | 418 | return -EINVAL; |
419 | for (offset = 2; offset < video->brightness->count; offset++) | 419 | for (offset = 2; offset < video->brightness->count; offset++) |
420 | if (level == video->brightness->levels[offset]) { | 420 | if (level == video->brightness->levels[offset]) { |
@@ -609,7 +609,7 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
609 | 609 | ||
610 | static int | 610 | static int |
611 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 611 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
612 | unsigned long long *level) | 612 | unsigned long long *level, int init) |
613 | { | 613 | { |
614 | acpi_status status = AE_OK; | 614 | acpi_status status = AE_OK; |
615 | int i; | 615 | int i; |
@@ -633,10 +633,16 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | |||
633 | device->brightness->curr = *level; | 633 | device->brightness->curr = *level; |
634 | return 0; | 634 | return 0; |
635 | } | 635 | } |
636 | /* BQC returned an invalid level. Stop using it. */ | 636 | if (!init) { |
637 | ACPI_WARNING((AE_INFO, "%s returned an invalid level", | 637 | /* |
638 | buf)); | 638 | * BQC returned an invalid level. |
639 | device->cap._BQC = device->cap._BCQ = 0; | 639 | * Stop using it. |
640 | */ | ||
641 | ACPI_WARNING((AE_INFO, | ||
642 | "%s returned an invalid level", | ||
643 | buf)); | ||
644 | device->cap._BQC = device->cap._BCQ = 0; | ||
645 | } | ||
640 | } else { | 646 | } else { |
641 | /* Fixme: | 647 | /* Fixme: |
642 | * should we return an error or ignore this failure? | 648 | * should we return an error or ignore this failure? |
@@ -892,7 +898,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
892 | if (!device->cap._BQC) | 898 | if (!device->cap._BQC) |
893 | goto set_level; | 899 | goto set_level; |
894 | 900 | ||
895 | result = acpi_video_device_lcd_get_level_current(device, &level_old); | 901 | result = acpi_video_device_lcd_get_level_current(device, &level_old, 1); |
896 | if (result) | 902 | if (result) |
897 | goto out_free_levels; | 903 | goto out_free_levels; |
898 | 904 | ||
@@ -903,7 +909,7 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
903 | if (result) | 909 | if (result) |
904 | goto out_free_levels; | 910 | goto out_free_levels; |
905 | 911 | ||
906 | result = acpi_video_device_lcd_get_level_current(device, &level); | 912 | result = acpi_video_device_lcd_get_level_current(device, &level, 0); |
907 | if (result) | 913 | if (result) |
908 | goto out_free_levels; | 914 | goto out_free_levels; |
909 | 915 | ||
@@ -1996,7 +2002,7 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) | |||
1996 | goto out; | 2002 | goto out; |
1997 | 2003 | ||
1998 | result = acpi_video_device_lcd_get_level_current(device, | 2004 | result = acpi_video_device_lcd_get_level_current(device, |
1999 | &level_current); | 2005 | &level_current, 0); |
2000 | if (result) | 2006 | if (result) |
2001 | goto out; | 2007 | goto out; |
2002 | 2008 | ||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index cb2fd01eddae..b5dad9f37453 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -749,6 +749,24 @@ static int acpiphp_bus_trim(acpi_handle handle) | |||
749 | return retval; | 749 | return retval; |
750 | } | 750 | } |
751 | 751 | ||
752 | static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) | ||
753 | { | ||
754 | struct acpiphp_func *func; | ||
755 | union acpi_object params[2]; | ||
756 | struct acpi_object_list arg_list; | ||
757 | |||
758 | list_for_each_entry(func, &slot->funcs, sibling) { | ||
759 | arg_list.count = 2; | ||
760 | arg_list.pointer = params; | ||
761 | params[0].type = ACPI_TYPE_INTEGER; | ||
762 | params[0].integer.value = ACPI_ADR_SPACE_PCI_CONFIG; | ||
763 | params[1].type = ACPI_TYPE_INTEGER; | ||
764 | params[1].integer.value = 1; | ||
765 | /* _REG is optional, we don't care about if there is failure */ | ||
766 | acpi_evaluate_object(func->handle, "_REG", &arg_list, NULL); | ||
767 | } | ||
768 | } | ||
769 | |||
752 | /** | 770 | /** |
753 | * enable_device - enable, configure a slot | 771 | * enable_device - enable, configure a slot |
754 | * @slot: slot to be enabled | 772 | * @slot: slot to be enabled |
@@ -805,6 +823,7 @@ static int __ref enable_device(struct acpiphp_slot *slot) | |||
805 | pci_bus_assign_resources(bus); | 823 | pci_bus_assign_resources(bus); |
806 | acpiphp_sanitize_bus(bus); | 824 | acpiphp_sanitize_bus(bus); |
807 | acpiphp_set_hpp_values(bus); | 825 | acpiphp_set_hpp_values(bus); |
826 | acpiphp_set_acpi_region(slot); | ||
808 | pci_enable_bridges(bus); | 827 | pci_enable_bridges(bus); |
809 | pci_bus_add_devices(bus); | 828 | pci_bus_add_devices(bus); |
810 | 829 | ||
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 3f71a605a492..5a3d8514c66d 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
@@ -145,7 +145,7 @@ struct sony_laptop_input_s { | |||
145 | struct input_dev *key_dev; | 145 | struct input_dev *key_dev; |
146 | struct kfifo fifo; | 146 | struct kfifo fifo; |
147 | spinlock_t fifo_lock; | 147 | spinlock_t fifo_lock; |
148 | struct workqueue_struct *wq; | 148 | struct timer_list release_key_timer; |
149 | }; | 149 | }; |
150 | 150 | ||
151 | static struct sony_laptop_input_s sony_laptop_input = { | 151 | static struct sony_laptop_input_s sony_laptop_input = { |
@@ -299,20 +299,26 @@ static int sony_laptop_input_keycode_map[] = { | |||
299 | }; | 299 | }; |
300 | 300 | ||
301 | /* release buttons after a short delay if pressed */ | 301 | /* release buttons after a short delay if pressed */ |
302 | static void do_sony_laptop_release_key(struct work_struct *work) | 302 | static void do_sony_laptop_release_key(unsigned long unused) |
303 | { | 303 | { |
304 | struct sony_laptop_keypress kp; | 304 | struct sony_laptop_keypress kp; |
305 | unsigned long flags; | ||
306 | |||
307 | spin_lock_irqsave(&sony_laptop_input.fifo_lock, flags); | ||
305 | 308 | ||
306 | while (kfifo_out_locked(&sony_laptop_input.fifo, (unsigned char *)&kp, | 309 | if (kfifo_out(&sony_laptop_input.fifo, |
307 | sizeof(kp), &sony_laptop_input.fifo_lock) | 310 | (unsigned char *)&kp, sizeof(kp)) == sizeof(kp)) { |
308 | == sizeof(kp)) { | ||
309 | msleep(10); | ||
310 | input_report_key(kp.dev, kp.key, 0); | 311 | input_report_key(kp.dev, kp.key, 0); |
311 | input_sync(kp.dev); | 312 | input_sync(kp.dev); |
312 | } | 313 | } |
314 | |||
315 | /* If there is something in the fifo schedule next release. */ | ||
316 | if (kfifo_len(&sony_laptop_input.fifo) != 0) | ||
317 | mod_timer(&sony_laptop_input.release_key_timer, | ||
318 | jiffies + msecs_to_jiffies(10)); | ||
319 | |||
320 | spin_unlock_irqrestore(&sony_laptop_input.fifo_lock, flags); | ||
313 | } | 321 | } |
314 | static DECLARE_WORK(sony_laptop_release_key_work, | ||
315 | do_sony_laptop_release_key); | ||
316 | 322 | ||
317 | /* forward event to the input subsystem */ | 323 | /* forward event to the input subsystem */ |
318 | static void sony_laptop_report_input_event(u8 event) | 324 | static void sony_laptop_report_input_event(u8 event) |
@@ -366,13 +372,13 @@ static void sony_laptop_report_input_event(u8 event) | |||
366 | /* we emit the scancode so we can always remap the key */ | 372 | /* we emit the scancode so we can always remap the key */ |
367 | input_event(kp.dev, EV_MSC, MSC_SCAN, event); | 373 | input_event(kp.dev, EV_MSC, MSC_SCAN, event); |
368 | input_sync(kp.dev); | 374 | input_sync(kp.dev); |
369 | kfifo_in_locked(&sony_laptop_input.fifo, | ||
370 | (unsigned char *)&kp, sizeof(kp), | ||
371 | &sony_laptop_input.fifo_lock); | ||
372 | 375 | ||
373 | if (!work_pending(&sony_laptop_release_key_work)) | 376 | /* schedule key release */ |
374 | queue_work(sony_laptop_input.wq, | 377 | kfifo_in_locked(&sony_laptop_input.fifo, |
375 | &sony_laptop_release_key_work); | 378 | (unsigned char *)&kp, sizeof(kp), |
379 | &sony_laptop_input.fifo_lock); | ||
380 | mod_timer(&sony_laptop_input.release_key_timer, | ||
381 | jiffies + msecs_to_jiffies(10)); | ||
376 | } else | 382 | } else |
377 | dprintk("unknown input event %.2x\n", event); | 383 | dprintk("unknown input event %.2x\n", event); |
378 | } | 384 | } |
@@ -390,27 +396,21 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) | |||
390 | 396 | ||
391 | /* kfifo */ | 397 | /* kfifo */ |
392 | spin_lock_init(&sony_laptop_input.fifo_lock); | 398 | spin_lock_init(&sony_laptop_input.fifo_lock); |
393 | error = | 399 | error = kfifo_alloc(&sony_laptop_input.fifo, |
394 | kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL); | 400 | SONY_LAPTOP_BUF_SIZE, GFP_KERNEL); |
395 | if (error) { | 401 | if (error) { |
396 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); | 402 | printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n"); |
397 | goto err_dec_users; | 403 | goto err_dec_users; |
398 | } | 404 | } |
399 | 405 | ||
400 | /* init workqueue */ | 406 | setup_timer(&sony_laptop_input.release_key_timer, |
401 | sony_laptop_input.wq = create_singlethread_workqueue("sony-laptop"); | 407 | do_sony_laptop_release_key, 0); |
402 | if (!sony_laptop_input.wq) { | ||
403 | printk(KERN_ERR DRV_PFX | ||
404 | "Unable to create workqueue.\n"); | ||
405 | error = -ENXIO; | ||
406 | goto err_free_kfifo; | ||
407 | } | ||
408 | 408 | ||
409 | /* input keys */ | 409 | /* input keys */ |
410 | key_dev = input_allocate_device(); | 410 | key_dev = input_allocate_device(); |
411 | if (!key_dev) { | 411 | if (!key_dev) { |
412 | error = -ENOMEM; | 412 | error = -ENOMEM; |
413 | goto err_destroy_wq; | 413 | goto err_free_kfifo; |
414 | } | 414 | } |
415 | 415 | ||
416 | key_dev->name = "Sony Vaio Keys"; | 416 | key_dev->name = "Sony Vaio Keys"; |
@@ -419,18 +419,15 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) | |||
419 | key_dev->dev.parent = &acpi_device->dev; | 419 | key_dev->dev.parent = &acpi_device->dev; |
420 | 420 | ||
421 | /* Initialize the Input Drivers: special keys */ | 421 | /* Initialize the Input Drivers: special keys */ |
422 | set_bit(EV_KEY, key_dev->evbit); | 422 | input_set_capability(key_dev, EV_MSC, MSC_SCAN); |
423 | set_bit(EV_MSC, key_dev->evbit); | 423 | |
424 | set_bit(MSC_SCAN, key_dev->mscbit); | 424 | __set_bit(EV_KEY, key_dev->evbit); |
425 | key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]); | 425 | key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]); |
426 | key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map); | 426 | key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map); |
427 | key_dev->keycode = &sony_laptop_input_keycode_map; | 427 | key_dev->keycode = &sony_laptop_input_keycode_map; |
428 | for (i = 0; i < ARRAY_SIZE(sony_laptop_input_keycode_map); i++) { | 428 | for (i = 0; i < ARRAY_SIZE(sony_laptop_input_keycode_map); i++) |
429 | if (sony_laptop_input_keycode_map[i] != KEY_RESERVED) { | 429 | __set_bit(sony_laptop_input_keycode_map[i], key_dev->keybit); |
430 | set_bit(sony_laptop_input_keycode_map[i], | 430 | __clear_bit(KEY_RESERVED, key_dev->keybit); |
431 | key_dev->keybit); | ||
432 | } | ||
433 | } | ||
434 | 431 | ||
435 | error = input_register_device(key_dev); | 432 | error = input_register_device(key_dev); |
436 | if (error) | 433 | if (error) |
@@ -450,9 +447,8 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device) | |||
450 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; | 447 | jog_dev->id.vendor = PCI_VENDOR_ID_SONY; |
451 | key_dev->dev.parent = &acpi_device->dev; | 448 | key_dev->dev.parent = &acpi_device->dev; |
452 | 449 | ||
453 | jog_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); | 450 | input_set_capability(jog_dev, EV_KEY, BTN_MIDDLE); |
454 | jog_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_MIDDLE); | 451 | input_set_capability(jog_dev, EV_REL, REL_WHEEL); |
455 | jog_dev->relbit[0] = BIT_MASK(REL_WHEEL); | ||
456 | 452 | ||
457 | error = input_register_device(jog_dev); | 453 | error = input_register_device(jog_dev); |
458 | if (error) | 454 | if (error) |
@@ -473,9 +469,6 @@ err_unregister_keydev: | |||
473 | err_free_keydev: | 469 | err_free_keydev: |
474 | input_free_device(key_dev); | 470 | input_free_device(key_dev); |
475 | 471 | ||
476 | err_destroy_wq: | ||
477 | destroy_workqueue(sony_laptop_input.wq); | ||
478 | |||
479 | err_free_kfifo: | 472 | err_free_kfifo: |
480 | kfifo_free(&sony_laptop_input.fifo); | 473 | kfifo_free(&sony_laptop_input.fifo); |
481 | 474 | ||
@@ -486,12 +479,23 @@ err_dec_users: | |||
486 | 479 | ||
487 | static void sony_laptop_remove_input(void) | 480 | static void sony_laptop_remove_input(void) |
488 | { | 481 | { |
489 | /* cleanup only after the last user has gone */ | 482 | struct sony_laptop_keypress kp = { NULL }; |
483 | |||
484 | /* Cleanup only after the last user has gone */ | ||
490 | if (!atomic_dec_and_test(&sony_laptop_input.users)) | 485 | if (!atomic_dec_and_test(&sony_laptop_input.users)) |
491 | return; | 486 | return; |
492 | 487 | ||
493 | /* flush workqueue first */ | 488 | del_timer_sync(&sony_laptop_input.release_key_timer); |
494 | flush_workqueue(sony_laptop_input.wq); | 489 | |
490 | /* | ||
491 | * Generate key-up events for remaining keys. Note that we don't | ||
492 | * need locking since nobody is adding new events to the kfifo. | ||
493 | */ | ||
494 | while (kfifo_out(&sony_laptop_input.fifo, | ||
495 | (unsigned char *)&kp, sizeof(kp)) == sizeof(kp)) { | ||
496 | input_report_key(kp.dev, kp.key, 0); | ||
497 | input_sync(kp.dev); | ||
498 | } | ||
495 | 499 | ||
496 | /* destroy input devs */ | 500 | /* destroy input devs */ |
497 | input_unregister_device(sony_laptop_input.key_dev); | 501 | input_unregister_device(sony_laptop_input.key_dev); |
@@ -502,7 +506,6 @@ static void sony_laptop_remove_input(void) | |||
502 | sony_laptop_input.jog_dev = NULL; | 506 | sony_laptop_input.jog_dev = NULL; |
503 | } | 507 | } |
504 | 508 | ||
505 | destroy_workqueue(sony_laptop_input.wq); | ||
506 | kfifo_free(&sony_laptop_input.fifo); | 509 | kfifo_free(&sony_laptop_input.fifo); |
507 | } | 510 | } |
508 | 511 | ||
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 0b8d14050efa..0bab84ebb15d 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h | |||
@@ -166,6 +166,9 @@ struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, | |||
166 | struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, | 166 | struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, |
167 | resource_size_t start, | 167 | resource_size_t start, |
168 | resource_size_t end, int flags); | 168 | resource_size_t end, int flags); |
169 | struct pnp_resource *pnp_add_bus_resource(struct pnp_dev *dev, | ||
170 | resource_size_t start, | ||
171 | resource_size_t end); | ||
169 | 172 | ||
170 | extern int pnp_debug; | 173 | extern int pnp_debug; |
171 | 174 | ||
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 68b0c04987e4..cfaf5b73540b 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -278,9 +278,12 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, | |||
278 | switch (pnp_resource_type(res)) { | 278 | switch (pnp_resource_type(res)) { |
279 | case IORESOURCE_IO: | 279 | case IORESOURCE_IO: |
280 | case IORESOURCE_MEM: | 280 | case IORESOURCE_MEM: |
281 | pnp_printf(buffer, " %#llx-%#llx\n", | 281 | case IORESOURCE_BUS: |
282 | pnp_printf(buffer, " %#llx-%#llx%s\n", | ||
282 | (unsigned long long) res->start, | 283 | (unsigned long long) res->start, |
283 | (unsigned long long) res->end); | 284 | (unsigned long long) res->end, |
285 | res->flags & IORESOURCE_WINDOW ? | ||
286 | " window" : ""); | ||
284 | break; | 287 | break; |
285 | case IORESOURCE_IRQ: | 288 | case IORESOURCE_IRQ: |
286 | case IORESOURCE_DMA: | 289 | case IORESOURCE_DMA: |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 5702b2c8691f..54514aa35b09 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -177,7 +177,8 @@ static int dma_flags(struct pnp_dev *dev, int type, int bus_master, | |||
177 | } | 177 | } |
178 | 178 | ||
179 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, | 179 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, |
180 | u64 len, int io_decode) | 180 | u64 len, int io_decode, |
181 | int window) | ||
181 | { | 182 | { |
182 | int flags = 0; | 183 | int flags = 0; |
183 | u64 end = start + len - 1; | 184 | u64 end = start + len - 1; |
@@ -186,6 +187,8 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, | |||
186 | flags |= IORESOURCE_IO_16BIT_ADDR; | 187 | flags |= IORESOURCE_IO_16BIT_ADDR; |
187 | if (len == 0 || end >= 0x10003) | 188 | if (len == 0 || end >= 0x10003) |
188 | flags |= IORESOURCE_DISABLED; | 189 | flags |= IORESOURCE_DISABLED; |
190 | if (window) | ||
191 | flags |= IORESOURCE_WINDOW; | ||
189 | 192 | ||
190 | pnp_add_io_resource(dev, start, end, flags); | 193 | pnp_add_io_resource(dev, start, end, flags); |
191 | } | 194 | } |
@@ -247,7 +250,7 @@ static void pnpacpi_parse_allocated_vendor(struct pnp_dev *dev, | |||
247 | 250 | ||
248 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, | 251 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, |
249 | u64 start, u64 len, | 252 | u64 start, u64 len, |
250 | int write_protect) | 253 | int write_protect, int window) |
251 | { | 254 | { |
252 | int flags = 0; | 255 | int flags = 0; |
253 | u64 end = start + len - 1; | 256 | u64 end = start + len - 1; |
@@ -256,15 +259,26 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, | |||
256 | flags |= IORESOURCE_DISABLED; | 259 | flags |= IORESOURCE_DISABLED; |
257 | if (write_protect == ACPI_READ_WRITE_MEMORY) | 260 | if (write_protect == ACPI_READ_WRITE_MEMORY) |
258 | flags |= IORESOURCE_MEM_WRITEABLE; | 261 | flags |= IORESOURCE_MEM_WRITEABLE; |
262 | if (window) | ||
263 | flags |= IORESOURCE_WINDOW; | ||
259 | 264 | ||
260 | pnp_add_mem_resource(dev, start, end, flags); | 265 | pnp_add_mem_resource(dev, start, end, flags); |
261 | } | 266 | } |
262 | 267 | ||
268 | static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev, | ||
269 | u64 start, u64 len) | ||
270 | { | ||
271 | u64 end = start + len - 1; | ||
272 | |||
273 | pnp_add_bus_resource(dev, start, end); | ||
274 | } | ||
275 | |||
263 | static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, | 276 | static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, |
264 | struct acpi_resource *res) | 277 | struct acpi_resource *res) |
265 | { | 278 | { |
266 | struct acpi_resource_address64 addr, *p = &addr; | 279 | struct acpi_resource_address64 addr, *p = &addr; |
267 | acpi_status status; | 280 | acpi_status status; |
281 | int window; | ||
268 | 282 | ||
269 | status = acpi_resource_to_address64(res, p); | 283 | status = acpi_resource_to_address64(res, p); |
270 | if (!ACPI_SUCCESS(status)) { | 284 | if (!ACPI_SUCCESS(status)) { |
@@ -273,37 +287,42 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, | |||
273 | return; | 287 | return; |
274 | } | 288 | } |
275 | 289 | ||
276 | if (p->producer_consumer == ACPI_PRODUCER) | 290 | window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; |
277 | return; | ||
278 | 291 | ||
279 | if (p->resource_type == ACPI_MEMORY_RANGE) | 292 | if (p->resource_type == ACPI_MEMORY_RANGE) |
280 | pnpacpi_parse_allocated_memresource(dev, | 293 | pnpacpi_parse_allocated_memresource(dev, |
281 | p->minimum, p->address_length, | 294 | p->minimum, p->address_length, |
282 | p->info.mem.write_protect); | 295 | p->info.mem.write_protect, window); |
283 | else if (p->resource_type == ACPI_IO_RANGE) | 296 | else if (p->resource_type == ACPI_IO_RANGE) |
284 | pnpacpi_parse_allocated_ioresource(dev, | 297 | pnpacpi_parse_allocated_ioresource(dev, |
285 | p->minimum, p->address_length, | 298 | p->minimum, p->address_length, |
286 | p->granularity == 0xfff ? ACPI_DECODE_10 : | 299 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
287 | ACPI_DECODE_16); | 300 | ACPI_DECODE_16, window); |
301 | else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) | ||
302 | pnpacpi_parse_allocated_busresource(dev, p->minimum, | ||
303 | p->address_length); | ||
288 | } | 304 | } |
289 | 305 | ||
290 | static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev, | 306 | static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev, |
291 | struct acpi_resource *res) | 307 | struct acpi_resource *res) |
292 | { | 308 | { |
293 | struct acpi_resource_extended_address64 *p = &res->data.ext_address64; | 309 | struct acpi_resource_extended_address64 *p = &res->data.ext_address64; |
310 | int window; | ||
294 | 311 | ||
295 | if (p->producer_consumer == ACPI_PRODUCER) | 312 | window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; |
296 | return; | ||
297 | 313 | ||
298 | if (p->resource_type == ACPI_MEMORY_RANGE) | 314 | if (p->resource_type == ACPI_MEMORY_RANGE) |
299 | pnpacpi_parse_allocated_memresource(dev, | 315 | pnpacpi_parse_allocated_memresource(dev, |
300 | p->minimum, p->address_length, | 316 | p->minimum, p->address_length, |
301 | p->info.mem.write_protect); | 317 | p->info.mem.write_protect, window); |
302 | else if (p->resource_type == ACPI_IO_RANGE) | 318 | else if (p->resource_type == ACPI_IO_RANGE) |
303 | pnpacpi_parse_allocated_ioresource(dev, | 319 | pnpacpi_parse_allocated_ioresource(dev, |
304 | p->minimum, p->address_length, | 320 | p->minimum, p->address_length, |
305 | p->granularity == 0xfff ? ACPI_DECODE_10 : | 321 | p->granularity == 0xfff ? ACPI_DECODE_10 : |
306 | ACPI_DECODE_16); | 322 | ACPI_DECODE_16, window); |
323 | else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) | ||
324 | pnpacpi_parse_allocated_busresource(dev, p->minimum, | ||
325 | p->address_length); | ||
307 | } | 326 | } |
308 | 327 | ||
309 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | 328 | static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, |
@@ -368,7 +387,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
368 | pnpacpi_parse_allocated_ioresource(dev, | 387 | pnpacpi_parse_allocated_ioresource(dev, |
369 | io->minimum, | 388 | io->minimum, |
370 | io->address_length, | 389 | io->address_length, |
371 | io->io_decode); | 390 | io->io_decode, 0); |
372 | break; | 391 | break; |
373 | 392 | ||
374 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: | 393 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
@@ -380,7 +399,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
380 | pnpacpi_parse_allocated_ioresource(dev, | 399 | pnpacpi_parse_allocated_ioresource(dev, |
381 | fixed_io->address, | 400 | fixed_io->address, |
382 | fixed_io->address_length, | 401 | fixed_io->address_length, |
383 | ACPI_DECODE_10); | 402 | ACPI_DECODE_10, 0); |
384 | break; | 403 | break; |
385 | 404 | ||
386 | case ACPI_RESOURCE_TYPE_VENDOR: | 405 | case ACPI_RESOURCE_TYPE_VENDOR: |
@@ -396,21 +415,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
396 | pnpacpi_parse_allocated_memresource(dev, | 415 | pnpacpi_parse_allocated_memresource(dev, |
397 | memory24->minimum, | 416 | memory24->minimum, |
398 | memory24->address_length, | 417 | memory24->address_length, |
399 | memory24->write_protect); | 418 | memory24->write_protect, 0); |
400 | break; | 419 | break; |
401 | case ACPI_RESOURCE_TYPE_MEMORY32: | 420 | case ACPI_RESOURCE_TYPE_MEMORY32: |
402 | memory32 = &res->data.memory32; | 421 | memory32 = &res->data.memory32; |
403 | pnpacpi_parse_allocated_memresource(dev, | 422 | pnpacpi_parse_allocated_memresource(dev, |
404 | memory32->minimum, | 423 | memory32->minimum, |
405 | memory32->address_length, | 424 | memory32->address_length, |
406 | memory32->write_protect); | 425 | memory32->write_protect, 0); |
407 | break; | 426 | break; |
408 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 427 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
409 | fixed_memory32 = &res->data.fixed_memory32; | 428 | fixed_memory32 = &res->data.fixed_memory32; |
410 | pnpacpi_parse_allocated_memresource(dev, | 429 | pnpacpi_parse_allocated_memresource(dev, |
411 | fixed_memory32->address, | 430 | fixed_memory32->address, |
412 | fixed_memory32->address_length, | 431 | fixed_memory32->address_length, |
413 | fixed_memory32->write_protect); | 432 | fixed_memory32->write_protect, 0); |
414 | break; | 433 | break; |
415 | case ACPI_RESOURCE_TYPE_ADDRESS16: | 434 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
416 | case ACPI_RESOURCE_TYPE_ADDRESS32: | 435 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 64d0596bafb5..5b277dbaacde 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c | |||
@@ -470,7 +470,8 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res) | |||
470 | unsigned long pnp_resource_type(struct resource *res) | 470 | unsigned long pnp_resource_type(struct resource *res) |
471 | { | 471 | { |
472 | return res->flags & (IORESOURCE_IO | IORESOURCE_MEM | | 472 | return res->flags & (IORESOURCE_IO | IORESOURCE_MEM | |
473 | IORESOURCE_IRQ | IORESOURCE_DMA); | 473 | IORESOURCE_IRQ | IORESOURCE_DMA | |
474 | IORESOURCE_BUS); | ||
474 | } | 475 | } |
475 | 476 | ||
476 | struct resource *pnp_get_resource(struct pnp_dev *dev, | 477 | struct resource *pnp_get_resource(struct pnp_dev *dev, |
@@ -590,6 +591,30 @@ struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, | |||
590 | return pnp_res; | 591 | return pnp_res; |
591 | } | 592 | } |
592 | 593 | ||
594 | struct pnp_resource *pnp_add_bus_resource(struct pnp_dev *dev, | ||
595 | resource_size_t start, | ||
596 | resource_size_t end) | ||
597 | { | ||
598 | struct pnp_resource *pnp_res; | ||
599 | struct resource *res; | ||
600 | |||
601 | pnp_res = pnp_new_resource(dev); | ||
602 | if (!pnp_res) { | ||
603 | dev_err(&dev->dev, "can't add resource for BUS %#llx-%#llx\n", | ||
604 | (unsigned long long) start, | ||
605 | (unsigned long long) end); | ||
606 | return NULL; | ||
607 | } | ||
608 | |||
609 | res = &pnp_res->res; | ||
610 | res->flags = IORESOURCE_BUS; | ||
611 | res->start = start; | ||
612 | res->end = end; | ||
613 | |||
614 | pnp_dbg(&dev->dev, " add %pr\n", res); | ||
615 | return pnp_res; | ||
616 | } | ||
617 | |||
593 | /* | 618 | /* |
594 | * Determine whether the specified resource is a possible configuration | 619 | * Determine whether the specified resource is a possible configuration |
595 | * for this device. | 620 | * for this device. |
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index 9585c1c1cc36..f5beb24d036a 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c | |||
@@ -69,8 +69,10 @@ char *pnp_resource_type_name(struct resource *res) | |||
69 | return "irq"; | 69 | return "irq"; |
70 | case IORESOURCE_DMA: | 70 | case IORESOURCE_DMA: |
71 | return "dma"; | 71 | return "dma"; |
72 | case IORESOURCE_BUS: | ||
73 | return "bus"; | ||
72 | } | 74 | } |
73 | return NULL; | 75 | return "unknown"; |
74 | } | 76 | } |
75 | 77 | ||
76 | void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) | 78 | void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) |
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index c790e0c77d4b..ff05e6189768 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c | |||
@@ -99,6 +99,7 @@ static struct device_attribute power_supply_attrs[] = { | |||
99 | POWER_SUPPLY_ATTR(present), | 99 | POWER_SUPPLY_ATTR(present), |
100 | POWER_SUPPLY_ATTR(online), | 100 | POWER_SUPPLY_ATTR(online), |
101 | POWER_SUPPLY_ATTR(technology), | 101 | POWER_SUPPLY_ATTR(technology), |
102 | POWER_SUPPLY_ATTR(cycle_count), | ||
102 | POWER_SUPPLY_ATTR(voltage_max), | 103 | POWER_SUPPLY_ATTR(voltage_max), |
103 | POWER_SUPPLY_ATTR(voltage_min), | 104 | POWER_SUPPLY_ATTR(voltage_min), |
104 | POWER_SUPPLY_ATTR(voltage_max_design), | 105 | POWER_SUPPLY_ATTR(voltage_max_design), |
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 1172c27adadf..86825ddbe14e 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
@@ -320,8 +320,16 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) | |||
320 | 320 | ||
321 | #endif /* CONFIG_CPU_FREQ */ | 321 | #endif /* CONFIG_CPU_FREQ */ |
322 | 322 | ||
323 | /* in processor_pdc.c */ | 323 | /* in processor_core.c */ |
324 | void acpi_processor_set_pdc(acpi_handle handle); | 324 | void acpi_processor_set_pdc(acpi_handle handle); |
325 | #ifdef CONFIG_SMP | ||
326 | int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); | ||
327 | #else | ||
328 | static inline int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) | ||
329 | { | ||
330 | return -1; | ||
331 | } | ||
332 | #endif | ||
325 | 333 | ||
326 | /* in processor_throttling.c */ | 334 | /* in processor_throttling.c */ |
327 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr); | 335 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr); |
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index dda98410d588..71ab79da7e7f 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -34,22 +34,24 @@ struct resource_list { | |||
34 | */ | 34 | */ |
35 | #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ | 35 | #define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ |
36 | 36 | ||
37 | #define IORESOURCE_TYPE_BITS 0x00000f00 /* Resource type */ | 37 | #define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */ |
38 | #define IORESOURCE_IO 0x00000100 | 38 | #define IORESOURCE_IO 0x00000100 |
39 | #define IORESOURCE_MEM 0x00000200 | 39 | #define IORESOURCE_MEM 0x00000200 |
40 | #define IORESOURCE_IRQ 0x00000400 | 40 | #define IORESOURCE_IRQ 0x00000400 |
41 | #define IORESOURCE_DMA 0x00000800 | 41 | #define IORESOURCE_DMA 0x00000800 |
42 | #define IORESOURCE_BUS 0x00001000 | ||
42 | 43 | ||
43 | #define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ | 44 | #define IORESOURCE_PREFETCH 0x00002000 /* No side effects */ |
44 | #define IORESOURCE_READONLY 0x00002000 | 45 | #define IORESOURCE_READONLY 0x00004000 |
45 | #define IORESOURCE_CACHEABLE 0x00004000 | 46 | #define IORESOURCE_CACHEABLE 0x00008000 |
46 | #define IORESOURCE_RANGELENGTH 0x00008000 | 47 | #define IORESOURCE_RANGELENGTH 0x00010000 |
47 | #define IORESOURCE_SHADOWABLE 0x00010000 | 48 | #define IORESOURCE_SHADOWABLE 0x00020000 |
48 | 49 | ||
49 | #define IORESOURCE_SIZEALIGN 0x00020000 /* size indicates alignment */ | 50 | #define IORESOURCE_SIZEALIGN 0x00040000 /* size indicates alignment */ |
50 | #define IORESOURCE_STARTALIGN 0x00040000 /* start field is alignment */ | 51 | #define IORESOURCE_STARTALIGN 0x00080000 /* start field is alignment */ |
51 | 52 | ||
52 | #define IORESOURCE_MEM_64 0x00100000 | 53 | #define IORESOURCE_MEM_64 0x00100000 |
54 | #define IORESOURCE_WINDOW 0x00200000 /* forwarded by bridge */ | ||
53 | 55 | ||
54 | #define IORESOURCE_EXCLUSIVE 0x08000000 /* Userland may not map this resource */ | 56 | #define IORESOURCE_EXCLUSIVE 0x08000000 /* Userland may not map this resource */ |
55 | #define IORESOURCE_DISABLED 0x10000000 | 57 | #define IORESOURCE_DISABLED 0x10000000 |
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b5d096d3a9be..ebd2b8fb00d0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h | |||
@@ -82,6 +82,7 @@ enum power_supply_property { | |||
82 | POWER_SUPPLY_PROP_PRESENT, | 82 | POWER_SUPPLY_PROP_PRESENT, |
83 | POWER_SUPPLY_PROP_ONLINE, | 83 | POWER_SUPPLY_PROP_ONLINE, |
84 | POWER_SUPPLY_PROP_TECHNOLOGY, | 84 | POWER_SUPPLY_PROP_TECHNOLOGY, |
85 | POWER_SUPPLY_PROP_CYCLE_COUNT, | ||
85 | POWER_SUPPLY_PROP_VOLTAGE_MAX, | 86 | POWER_SUPPLY_PROP_VOLTAGE_MAX, |
86 | POWER_SUPPLY_PROP_VOLTAGE_MIN, | 87 | POWER_SUPPLY_PROP_VOLTAGE_MIN, |
87 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, | 88 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 0d461c7c14db..24112e5a5780 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -609,6 +609,12 @@ static char *resource_string(char *buf, char *end, struct resource *res, | |||
609 | .precision = -1, | 609 | .precision = -1, |
610 | .flags = SPECIAL | SMALL | ZEROPAD, | 610 | .flags = SPECIAL | SMALL | ZEROPAD, |
611 | }; | 611 | }; |
612 | static const struct printf_spec bus_spec = { | ||
613 | .base = 16, | ||
614 | .field_width = 2, | ||
615 | .precision = -1, | ||
616 | .flags = SMALL | ZEROPAD, | ||
617 | }; | ||
612 | static const struct printf_spec dec_spec = { | 618 | static const struct printf_spec dec_spec = { |
613 | .base = 10, | 619 | .base = 10, |
614 | .precision = -1, | 620 | .precision = -1, |
@@ -629,7 +635,7 @@ static char *resource_string(char *buf, char *end, struct resource *res, | |||
629 | * 64-bit res (sizeof==8): 20 chars in dec, 18 in hex ("0x" + 16) */ | 635 | * 64-bit res (sizeof==8): 20 chars in dec, 18 in hex ("0x" + 16) */ |
630 | #define RSRC_BUF_SIZE ((2 * sizeof(resource_size_t)) + 4) | 636 | #define RSRC_BUF_SIZE ((2 * sizeof(resource_size_t)) + 4) |
631 | #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) | 637 | #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) |
632 | #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref disabled]") | 638 | #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") |
633 | #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") | 639 | #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") |
634 | char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, | 640 | char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, |
635 | 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; | 641 | 2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; |
@@ -651,6 +657,9 @@ static char *resource_string(char *buf, char *end, struct resource *res, | |||
651 | } else if (res->flags & IORESOURCE_DMA) { | 657 | } else if (res->flags & IORESOURCE_DMA) { |
652 | p = string(p, pend, "dma ", str_spec); | 658 | p = string(p, pend, "dma ", str_spec); |
653 | specp = &dec_spec; | 659 | specp = &dec_spec; |
660 | } else if (res->flags & IORESOURCE_BUS) { | ||
661 | p = string(p, pend, "bus ", str_spec); | ||
662 | specp = &bus_spec; | ||
654 | } else { | 663 | } else { |
655 | p = string(p, pend, "??? ", str_spec); | 664 | p = string(p, pend, "??? ", str_spec); |
656 | specp = &mem_spec; | 665 | specp = &mem_spec; |
@@ -666,6 +675,8 @@ static char *resource_string(char *buf, char *end, struct resource *res, | |||
666 | p = string(p, pend, " 64bit", str_spec); | 675 | p = string(p, pend, " 64bit", str_spec); |
667 | if (res->flags & IORESOURCE_PREFETCH) | 676 | if (res->flags & IORESOURCE_PREFETCH) |
668 | p = string(p, pend, " pref", str_spec); | 677 | p = string(p, pend, " pref", str_spec); |
678 | if (res->flags & IORESOURCE_WINDOW) | ||
679 | p = string(p, pend, " window", str_spec); | ||
669 | if (res->flags & IORESOURCE_DISABLED) | 680 | if (res->flags & IORESOURCE_DISABLED) |
670 | p = string(p, pend, " disabled", str_spec); | 681 | p = string(p, pend, " disabled", str_spec); |
671 | } else { | 682 | } else { |