Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'pm+acpi-3.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI and power management fixes from Rafael Wysocki:
"These are regression fixes (ACPI hotplug, cpufreq, hibernation, ACPI
LPSS driver), fixes for stuff that never worked correctly (ACPI GPIO
support in some cases and a wrong sign of an error code in the ACPI
core in one place), and one blacklist item for ACPI backlight
handling.

Specifics:

- Revert of a recent hibernation core commit that introduced a NULL
pointer dereference during resume for at least one user (Rafael J
Wysocki).

- Fix for the ACPI LPSS (Low-Power Subsystem) driver to disable
asynchronous PM callback execution for LPSS devices during system
suspend/resume (introduced in 3.16) which turns out to break
ordering expectations on some systems. From Fu Zhonghui.

- cpufreq core fix related to the handling of sysfs nodes during
system suspend/resume that has been broken for intel_pstate since
3.15 from Lan Tianyu.

- Restore the generation of "online" uevents for ACPI container
devices that was removed in 3.14, but some user space utilities
turn out to need them (Rafael J Wysocki).

- The cpufreq core fails to release a lock in an error code path
after changes made in 3.14. Fix from Prarit Bhargava.

- ACPICA and ACPI/GPIO fixes to make the handling of ACPI GPIO
operation regions (which means AML using GPIOs) work correctly in
all cases from Bob Moore and Srinivas Pandruvada.

- Fix for a wrong sign of the ACPI core's create_modalias() return
value in case of an error from Mika Westerberg.

- ACPI backlight blacklist entry for ThinkPad X201s from Aaron Lu"

* tag 'pm+acpi-3.17-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
Revert "PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free()"
gpio / ACPI: Use pin index and bit length
ACPICA: Update to GPIO region handler interface.
ACPI / platform / LPSS: disable async suspend/resume of LPSS devices
cpufreq: release policy->rwsem on error
cpufreq: fix cpufreq suspend/resume for intel_pstate
ACPI / scan: Correct error return value of create_modalias()
ACPI / video: disable native backlight for ThinkPad X201s
ACPI / hotplug: Generate online uevents for ACPI containers

+149 -57
-1
drivers/acpi/acpi_lpss.c
··· 419 419 adev->driver_data = pdata; 420 420 pdev = acpi_create_platform_device(adev); 421 421 if (!IS_ERR_OR_NULL(pdev)) { 422 - device_enable_async_suspend(&pdev->dev); 423 422 return 1; 424 423 } 425 424
+1
drivers/acpi/acpica/aclocal.h
··· 254 254 u32 field_bit_position; 255 255 u32 field_bit_length; 256 256 u16 resource_length; 257 + u16 pin_number_index; 257 258 u8 field_flags; 258 259 u8 attribute; 259 260 u8 field_type;
+1
drivers/acpi/acpica/acobject.h
··· 264 264 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO u16 resource_length; 265 265 union acpi_operand_object *region_obj; /* Containing op_region object */ 266 266 u8 *resource_buffer; /* resource_template for serial regions/fields */ 267 + u16 pin_number_index; /* Index relative to previous Connection/Template */ 267 268 }; 268 269 269 270 struct acpi_object_bank_field {
+2
drivers/acpi/acpica/dsfield.c
··· 360 360 */ 361 361 info->resource_buffer = NULL; 362 362 info->connection_node = NULL; 363 + info->pin_number_index = 0; 363 364 364 365 /* 365 366 * A Connection() is either an actual resource descriptor (buffer) ··· 438 437 } 439 438 440 439 info->field_bit_position += info->field_bit_length; 440 + info->pin_number_index++; /* Index relative to previous Connection() */ 441 441 break; 442 442 443 443 default:
+31 -16
drivers/acpi/acpica/evregion.c
··· 142 142 union acpi_operand_object *region_obj2; 143 143 void *region_context = NULL; 144 144 struct acpi_connection_info *context; 145 + acpi_physical_address address; 145 146 146 147 ACPI_FUNCTION_TRACE(ev_address_space_dispatch); 147 148 ··· 232 231 /* We have everything we need, we can invoke the address space handler */ 233 232 234 233 handler = handler_desc->address_space.handler; 235 - 236 - ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 237 - "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", 238 - &region_obj->region.handler->address_space, handler, 239 - ACPI_FORMAT_NATIVE_UINT(region_obj->region.address + 240 - region_offset), 241 - acpi_ut_get_region_name(region_obj->region. 242 - space_id))); 234 + address = (region_obj->region.address + region_offset); 243 235 244 236 /* 245 237 * Special handling for generic_serial_bus and general_purpose_io: 246 238 * There are three extra parameters that must be passed to the 247 239 * handler via the context: 248 - * 1) Connection buffer, a resource template from Connection() op. 249 - * 2) Length of the above buffer. 250 - * 3) Actual access length from the access_as() op. 240 + * 1) Connection buffer, a resource template from Connection() op 241 + * 2) Length of the above buffer 242 + * 3) Actual access length from the access_as() op 243 + * 244 + * In addition, for general_purpose_io, the Address and bit_width fields 245 + * are defined as follows: 246 + * 1) Address is the pin number index of the field (bit offset from 247 + * the previous Connection) 248 + * 2) bit_width is the actual bit length of the field (number of pins) 251 249 */ 252 - if (((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) || 253 - (region_obj->region.space_id == ACPI_ADR_SPACE_GPIO)) && 250 + if ((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) && 254 251 context && field_obj) { 255 252 256 253 /* Get the Connection (resource_template) buffer */ ··· 257 258 context->length = field_obj->field.resource_length; 258 259 context->access_length = field_obj->field.access_length; 259 260 } 261 + if ((region_obj->region.space_id == ACPI_ADR_SPACE_GPIO) && 262 + context && field_obj) { 263 + 264 + /* Get the Connection (resource_template) buffer */ 265 + 266 + context->connection = field_obj->field.resource_buffer; 267 + context->length = field_obj->field.resource_length; 268 + context->access_length = field_obj->field.access_length; 269 + address = field_obj->field.pin_number_index; 270 + bit_width = field_obj->field.bit_length; 271 + } 272 + 273 + ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 274 + "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", 275 + &region_obj->region.handler->address_space, handler, 276 + ACPI_FORMAT_NATIVE_UINT(address), 277 + acpi_ut_get_region_name(region_obj->region. 278 + space_id))); 260 279 261 280 if (!(handler_desc->address_space.handler_flags & 262 281 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { ··· 288 271 289 272 /* Call the handler */ 290 273 291 - status = handler(function, 292 - (region_obj->region.address + region_offset), 293 - bit_width, value, context, 274 + status = handler(function, address, bit_width, value, context, 294 275 region_obj2->extra.region_context); 295 276 296 277 if (ACPI_FAILURE(status)) {
+67
drivers/acpi/acpica/exfield.c
··· 253 253 buffer = &buffer_desc->integer.value; 254 254 } 255 255 256 + if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && 257 + (obj_desc->field.region_obj->region.space_id == 258 + ACPI_ADR_SPACE_GPIO)) { 259 + /* 260 + * For GPIO (general_purpose_io), the Address will be the bit offset 261 + * from the previous Connection() operator, making it effectively a 262 + * pin number index. The bit_length is the length of the field, which 263 + * is thus the number of pins. 264 + */ 265 + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 266 + "GPIO FieldRead [FROM]: Pin %u Bits %u\n", 267 + obj_desc->field.pin_number_index, 268 + obj_desc->field.bit_length)); 269 + 270 + /* Lock entire transaction if requested */ 271 + 272 + acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); 273 + 274 + /* Perform the write */ 275 + 276 + status = acpi_ex_access_region(obj_desc, 0, 277 + (u64 *)buffer, ACPI_READ); 278 + acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 279 + if (ACPI_FAILURE(status)) { 280 + acpi_ut_remove_reference(buffer_desc); 281 + } else { 282 + *ret_buffer_desc = buffer_desc; 283 + } 284 + return_ACPI_STATUS(status); 285 + } 286 + 256 287 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 257 288 "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", 258 289 obj_desc, obj_desc->common.type, buffer, ··· 443 412 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 444 413 445 414 *result_desc = buffer_desc; 415 + return_ACPI_STATUS(status); 416 + } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && 417 + (obj_desc->field.region_obj->region.space_id == 418 + ACPI_ADR_SPACE_GPIO)) { 419 + /* 420 + * For GPIO (general_purpose_io), we will bypass the entire field 421 + * mechanism and handoff the bit address and bit width directly to 422 + * the handler. The Address will be the bit offset 423 + * from the previous Connection() operator, making it effectively a 424 + * pin number index. The bit_length is the length of the field, which 425 + * is thus the number of pins. 426 + */ 427 + if (source_desc->common.type != ACPI_TYPE_INTEGER) { 428 + return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 429 + } 430 + 431 + ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 432 + "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n", 433 + acpi_ut_get_type_name(source_desc->common. 434 + type), 435 + source_desc->common.type, 436 + (u32)source_desc->integer.value, 437 + obj_desc->field.pin_number_index, 438 + obj_desc->field.bit_length)); 439 + 440 + buffer = &source_desc->integer.value; 441 + 442 + /* Lock entire transaction if requested */ 443 + 444 + acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); 445 + 446 + /* Perform the write */ 447 + 448 + status = acpi_ex_access_region(obj_desc, 0, 449 + (u64 *)buffer, ACPI_WRITE); 450 + acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 446 451 return_ACPI_STATUS(status); 447 452 } 448 453
+2
drivers/acpi/acpica/exprep.c
··· 484 484 obj_desc->field.resource_length = info->resource_length; 485 485 } 486 486 487 + obj_desc->field.pin_number_index = info->pin_number_index; 488 + 487 489 /* Allow full data read from EC address space */ 488 490 489 491 if ((obj_desc->field.region_obj->region.space_id ==
+8
drivers/acpi/container.c
··· 99 99 device_unregister(dev); 100 100 } 101 101 102 + static void container_device_online(struct acpi_device *adev) 103 + { 104 + struct device *dev = acpi_driver_data(adev); 105 + 106 + kobject_uevent(&dev->kobj, KOBJ_ONLINE); 107 + } 108 + 102 109 static struct acpi_scan_handler container_handler = { 103 110 .ids = container_device_ids, 104 111 .attach = container_device_attach, ··· 113 106 .hotplug = { 114 107 .enabled = true, 115 108 .demand_offline = true, 109 + .notify_online = container_device_online, 116 110 }, 117 111 }; 118 112
+4 -1
drivers/acpi/scan.c
··· 130 130 list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 131 131 count = snprintf(&modalias[len], size, "%s:", id->id); 132 132 if (count < 0) 133 - return EINVAL; 133 + return -EINVAL; 134 134 if (count >= size) 135 135 return -ENOMEM; 136 136 len += count; ··· 2189 2189 ok: 2190 2190 list_for_each_entry(child, &device->children, node) 2191 2191 acpi_bus_attach(child); 2192 + 2193 + if (device->handler && device->handler->hotplug.notify_online) 2194 + device->handler->hotplug.notify_online(device); 2192 2195 } 2193 2196 2194 2197 /**
+8
drivers/acpi/video.c
··· 750 750 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"), 751 751 }, 752 752 }, 753 + { 754 + .callback = video_disable_native_backlight, 755 + .ident = "ThinkPad X201s", 756 + .matches = { 757 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 758 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"), 759 + }, 760 + }, 753 761 754 762 /* The native backlight controls do not work on some older machines */ 755 763 {
+6 -4
drivers/cpufreq/cpufreq.c
··· 1289 1289 per_cpu(cpufreq_cpu_data, j) = NULL; 1290 1290 write_unlock_irqrestore(&cpufreq_driver_lock, flags); 1291 1291 1292 + up_write(&policy->rwsem); 1293 + 1292 1294 if (cpufreq_driver->exit) 1293 1295 cpufreq_driver->exit(policy); 1294 1296 err_set_policy_cpu: ··· 1658 1656 if (!cpufreq_driver) 1659 1657 return; 1660 1658 1659 + cpufreq_suspended = true; 1660 + 1661 1661 if (!has_target()) 1662 1662 return; 1663 1663 ··· 1674 1670 pr_err("%s: Failed to suspend driver: %p\n", __func__, 1675 1671 policy); 1676 1672 } 1677 - 1678 - cpufreq_suspended = true; 1679 1673 } 1680 1674 1681 1675 /** ··· 1689 1687 if (!cpufreq_driver) 1690 1688 return; 1691 1689 1690 + cpufreq_suspended = false; 1691 + 1692 1692 if (!has_target()) 1693 1693 return; 1694 1694 1695 1695 pr_debug("%s: Resuming Governors\n", __func__); 1696 - 1697 - cpufreq_suspended = false; 1698 1696 1699 1697 list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { 1700 1698 if (cpufreq_driver->resume && cpufreq_driver->resume(policy))
+4 -1
drivers/gpio/gpiolib-acpi.c
··· 377 377 struct gpio_chip *chip = achip->chip; 378 378 struct acpi_resource_gpio *agpio; 379 379 struct acpi_resource *ares; 380 + int pin_index = (int)address; 380 381 acpi_status status; 381 382 bool pull_up; 383 + int length; 382 384 int i; 383 385 384 386 status = acpi_buffer_to_resource(achip->conn_info.connection, ··· 402 400 return AE_BAD_PARAMETER; 403 401 } 404 402 405 - for (i = 0; i < agpio->pin_table_length; i++) { 403 + length = min(agpio->pin_table_length, (u16)(pin_index + bits)); 404 + for (i = pin_index; i < length; ++i) { 406 405 unsigned pin = agpio->pin_table[i]; 407 406 struct acpi_gpio_connection *conn; 408 407 struct gpio_desc *desc;
+1
include/acpi/acpi_bus.h
··· 118 118 struct acpi_hotplug_profile { 119 119 struct kobject kobj; 120 120 int (*scan_dependent)(struct acpi_device *adev); 121 + void (*notify_online)(struct acpi_device *adev); 121 122 bool enabled:1; 122 123 bool demand_offline:1; 123 124 };
+14 -34
kernel/power/snapshot.c
··· 725 725 clear_bit(bit, addr); 726 726 } 727 727 728 - static void memory_bm_clear_current(struct memory_bitmap *bm) 729 - { 730 - int bit; 731 - 732 - bit = max(bm->cur.node_bit - 1, 0); 733 - clear_bit(bit, bm->cur.node->data); 734 - } 735 - 736 728 static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn) 737 729 { 738 730 void *addr; ··· 1333 1341 1334 1342 void swsusp_free(void) 1335 1343 { 1336 - unsigned long fb_pfn, fr_pfn; 1344 + struct zone *zone; 1345 + unsigned long pfn, max_zone_pfn; 1337 1346 1338 - memory_bm_position_reset(forbidden_pages_map); 1339 - memory_bm_position_reset(free_pages_map); 1347 + for_each_populated_zone(zone) { 1348 + max_zone_pfn = zone_end_pfn(zone); 1349 + for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 1350 + if (pfn_valid(pfn)) { 1351 + struct page *page = pfn_to_page(pfn); 1340 1352 1341 - loop: 1342 - fr_pfn = memory_bm_next_pfn(free_pages_map); 1343 - fb_pfn = memory_bm_next_pfn(forbidden_pages_map); 1344 - 1345 - /* 1346 - * Find the next bit set in both bitmaps. This is guaranteed to 1347 - * terminate when fb_pfn == fr_pfn == BM_END_OF_MAP. 1348 - */ 1349 - do { 1350 - if (fb_pfn < fr_pfn) 1351 - fb_pfn = memory_bm_next_pfn(forbidden_pages_map); 1352 - if (fr_pfn < fb_pfn) 1353 - fr_pfn = memory_bm_next_pfn(free_pages_map); 1354 - } while (fb_pfn != fr_pfn); 1355 - 1356 - if (fr_pfn != BM_END_OF_MAP && pfn_valid(fr_pfn)) { 1357 - struct page *page = pfn_to_page(fr_pfn); 1358 - 1359 - memory_bm_clear_current(forbidden_pages_map); 1360 - memory_bm_clear_current(free_pages_map); 1361 - __free_page(page); 1362 - goto loop; 1353 + if (swsusp_page_is_forbidden(page) && 1354 + swsusp_page_is_free(page)) { 1355 + swsusp_unset_page_forbidden(page); 1356 + swsusp_unset_page_free(page); 1357 + __free_page(page); 1358 + } 1359 + } 1363 1360 } 1364 - 1365 1361 nr_copy_pages = 0; 1366 1362 nr_meta_pages = 0; 1367 1363 restore_pblist = NULL;