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

Merge tag 'acpi-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI updates from Rafael Wysocki:
"These fix an AML byte code execution issue in ACPICA and two issues in
the ACPI EC driver which requires rearranging ACPICA code.

Specifics:

- Avoid trying to resolve operands in AML when there are none
(Amadeusz Sławiński)

- Fix indentation in include/acpi/acpixf.h to help applying patches
from the upstream ACPICA git (Hans de Goede)

- Make it possible to install an address space handler without
evaluating _REG for Operation Regions in the given address space
(Hans de Goede)

- Defer the evaluation of _REG for ECDT described ECs till the
matching EC device in the DSDT gets parsed and acpi_ec_add() gets
called for it (Hans de Goede)

- Fix EC address space handler unregistration (Hans de Goede)"

* tag 'acpi-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPI: EC: Fix ECDT probe ordering issues
ACPI: EC: Fix EC address space handler unregistration
ACPICA: Allow address_space_handler Install and _REG execution as 2 separate steps
ACPICA: include/acpi/acpixf.h: Fix indentation
ACPICA: Fix operand resolution

+185 -84
+4 -2
drivers/acpi/acpica/dswexec.c
··· 389 389 390 390 /* 391 391 * All opcodes require operand resolution, with the only exceptions 392 - * being the object_type and size_of operators. 392 + * being the object_type and size_of operators as well as opcodes that 393 + * take no arguments. 393 394 */ 394 - if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) { 395 + if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE) && 396 + (walk_state->op_info->flags & AML_HAS_ARGS)) { 395 397 396 398 /* Resolve all operands */ 397 399
+85 -7
drivers/acpi/acpica/evxfregn.c
··· 20 20 21 21 /******************************************************************************* 22 22 * 23 - * FUNCTION: acpi_install_address_space_handler 23 + * FUNCTION: acpi_install_address_space_handler_internal 24 24 * 25 25 * PARAMETERS: device - Handle for the device 26 26 * space_id - The address space ID 27 27 * handler - Address of the handler 28 28 * setup - Address of the setup function 29 29 * context - Value passed to the handler on each access 30 + * Run_reg - Run _REG methods for this address space? 30 31 * 31 32 * RETURN: Status 32 33 * ··· 38 37 * are executed here, and these methods can only be safely executed after 39 38 * the default handlers have been installed and the hardware has been 40 39 * initialized (via acpi_enable_subsystem.) 40 + * To avoid this problem pass FALSE for Run_Reg and later on call 41 + * acpi_execute_reg_methods() to execute _REG. 41 42 * 42 43 ******************************************************************************/ 43 - acpi_status 44 - acpi_install_address_space_handler(acpi_handle device, 45 - acpi_adr_space_type space_id, 46 - acpi_adr_space_handler handler, 47 - acpi_adr_space_setup setup, void *context) 44 + static acpi_status 45 + acpi_install_address_space_handler_internal(acpi_handle device, 46 + acpi_adr_space_type space_id, 47 + acpi_adr_space_handler handler, 48 + acpi_adr_space_setup setup, 49 + void *context, u8 run_reg) 48 50 { 49 51 struct acpi_namespace_node *node; 50 52 acpi_status status; ··· 84 80 85 81 /* Run all _REG methods for this address space */ 86 82 87 - acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT); 83 + if (run_reg) { 84 + acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT); 85 + } 88 86 89 87 unlock_and_exit: 90 88 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 91 89 return_ACPI_STATUS(status); 92 90 } 93 91 92 + acpi_status 93 + acpi_install_address_space_handler(acpi_handle device, 94 + acpi_adr_space_type space_id, 95 + acpi_adr_space_handler handler, 96 + acpi_adr_space_setup setup, void *context) 97 + { 98 + return acpi_install_address_space_handler_internal(device, space_id, 99 + handler, setup, 100 + context, TRUE); 101 + } 102 + 94 103 ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler) 104 + acpi_status 105 + acpi_install_address_space_handler_no_reg(acpi_handle device, 106 + acpi_adr_space_type space_id, 107 + acpi_adr_space_handler handler, 108 + acpi_adr_space_setup setup, 109 + void *context) 110 + { 111 + return acpi_install_address_space_handler_internal(device, space_id, 112 + handler, setup, 113 + context, FALSE); 114 + } 115 + 116 + ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler_no_reg) 95 117 96 118 /******************************************************************************* 97 119 * ··· 258 228 } 259 229 260 230 ACPI_EXPORT_SYMBOL(acpi_remove_address_space_handler) 231 + /******************************************************************************* 232 + * 233 + * FUNCTION: acpi_execute_reg_methods 234 + * 235 + * PARAMETERS: device - Handle for the device 236 + * space_id - The address space ID 237 + * 238 + * RETURN: Status 239 + * 240 + * DESCRIPTION: Execute _REG for all op_regions of a given space_id. 241 + * 242 + ******************************************************************************/ 243 + acpi_status 244 + acpi_execute_reg_methods(acpi_handle device, acpi_adr_space_type space_id) 245 + { 246 + struct acpi_namespace_node *node; 247 + acpi_status status; 248 + 249 + ACPI_FUNCTION_TRACE(acpi_execute_reg_methods); 250 + 251 + /* Parameter validation */ 252 + 253 + if (!device) { 254 + return_ACPI_STATUS(AE_BAD_PARAMETER); 255 + } 256 + 257 + status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 258 + if (ACPI_FAILURE(status)) { 259 + return_ACPI_STATUS(status); 260 + } 261 + 262 + /* Convert and validate the device handle */ 263 + 264 + node = acpi_ns_validate_handle(device); 265 + if (node) { 266 + 267 + /* Run all _REG methods for this address space */ 268 + 269 + acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT); 270 + } else { 271 + status = AE_BAD_PARAMETER; 272 + } 273 + 274 + (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 275 + return_ACPI_STATUS(status); 276 + } 277 + 278 + ACPI_EXPORT_SYMBOL(acpi_execute_reg_methods)
+21 -11
drivers/acpi/ec.c
··· 94 94 EC_FLAGS_QUERY_ENABLED, /* Query is enabled */ 95 95 EC_FLAGS_EVENT_HANDLER_INSTALLED, /* Event handler installed */ 96 96 EC_FLAGS_EC_HANDLER_INSTALLED, /* OpReg handler installed */ 97 + EC_FLAGS_EC_REG_CALLED, /* OpReg ACPI _REG method called */ 97 98 EC_FLAGS_QUERY_METHODS_INSTALLED, /* _Qxx handlers installed */ 98 99 EC_FLAGS_STARTED, /* Driver is started */ 99 100 EC_FLAGS_STOPPED, /* Driver is stopped */ ··· 1447 1446 * ec_install_handlers - Install service callbacks and register query methods. 1448 1447 * @ec: Target EC. 1449 1448 * @device: ACPI device object corresponding to @ec. 1449 + * @call_reg: If _REG should be called to notify OpRegion availability 1450 1450 * 1451 1451 * Install a handler for the EC address space type unless it has been installed 1452 1452 * already. If @device is not NULL, also look for EC query methods in the ··· 1460 1458 * -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred, 1461 1459 * or 0 (success) otherwise. 1462 1460 */ 1463 - static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device) 1461 + static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, 1462 + bool call_reg) 1464 1463 { 1465 1464 acpi_status status; 1466 1465 ··· 1469 1466 1470 1467 if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { 1471 1468 acpi_ec_enter_noirq(ec); 1472 - status = acpi_install_address_space_handler(ec->handle, 1473 - ACPI_ADR_SPACE_EC, 1474 - &acpi_ec_space_handler, 1475 - NULL, ec); 1469 + status = acpi_install_address_space_handler_no_reg(ec->handle, 1470 + ACPI_ADR_SPACE_EC, 1471 + &acpi_ec_space_handler, 1472 + NULL, ec); 1476 1473 if (ACPI_FAILURE(status)) { 1477 1474 acpi_ec_stop(ec, false); 1478 1475 return -ENODEV; 1479 1476 } 1480 1477 set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); 1478 + ec->address_space_handler_holder = ec->handle; 1479 + } 1480 + 1481 + if (call_reg && !test_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags)) { 1482 + acpi_execute_reg_methods(ec->handle, ACPI_ADR_SPACE_EC); 1483 + set_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags); 1481 1484 } 1482 1485 1483 1486 if (!device) ··· 1535 1526 static void ec_remove_handlers(struct acpi_ec *ec) 1536 1527 { 1537 1528 if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { 1538 - if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, 1529 + if (ACPI_FAILURE(acpi_remove_address_space_handler( 1530 + ec->address_space_handler_holder, 1539 1531 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 1540 1532 pr_err("failed to remove space handler\n"); 1541 1533 clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); ··· 1572 1562 } 1573 1563 } 1574 1564 1575 - static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device) 1565 + static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool call_reg) 1576 1566 { 1577 1567 int ret; 1578 1568 1579 - ret = ec_install_handlers(ec, device); 1569 + ret = ec_install_handlers(ec, device, call_reg); 1580 1570 if (ret) 1581 1571 return ret; 1582 1572 ··· 1641 1631 } 1642 1632 } 1643 1633 1644 - ret = acpi_ec_setup(ec, device); 1634 + ret = acpi_ec_setup(ec, device, true); 1645 1635 if (ret) 1646 1636 goto err; 1647 1637 ··· 1760 1750 * At this point, the GPE is not fully initialized, so do not to 1761 1751 * handle the events. 1762 1752 */ 1763 - ret = acpi_ec_setup(ec, NULL); 1753 + ret = acpi_ec_setup(ec, NULL, true); 1764 1754 if (ret) { 1765 1755 acpi_ec_free(ec); 1766 1756 return; ··· 1954 1944 * At this point, the namespace is not initialized, so do not find 1955 1945 * the namespace objects, or handle the events. 1956 1946 */ 1957 - ret = acpi_ec_setup(ec, NULL); 1947 + ret = acpi_ec_setup(ec, NULL, false); 1958 1948 if (ret) { 1959 1949 acpi_ec_free(ec); 1960 1950 goto out;
+1
drivers/acpi/internal.h
··· 173 173 174 174 struct acpi_ec { 175 175 acpi_handle handle; 176 + acpi_handle address_space_handler_holder; 176 177 int gpe; 177 178 int irq; 178 179 unsigned long command_addr;
+74 -64
include/acpi/acpixf.h
··· 589 589 acpi_install_initialization_handler 590 590 (acpi_init_handler handler, u32 function)) 591 591 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 592 - acpi_install_sci_handler(acpi_sci_handler 593 - address, 594 - void *context)) 595 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 596 - acpi_remove_sci_handler(acpi_sci_handler 597 - address)) 598 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 599 - acpi_install_global_event_handler 600 - (acpi_gbl_event_handler handler, 601 - void *context)) 602 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 603 - acpi_install_fixed_event_handler(u32 604 - acpi_event, 605 - acpi_event_handler 606 - handler, 607 - void 608 - *context)) 609 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 610 - acpi_remove_fixed_event_handler(u32 acpi_event, 611 - acpi_event_handler 612 - handler)) 613 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 614 - acpi_install_gpe_handler(acpi_handle 615 - gpe_device, 616 - u32 gpe_number, 617 - u32 type, 618 - acpi_gpe_handler 619 - address, 620 - void *context)) 621 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 622 - acpi_install_gpe_raw_handler(acpi_handle 623 - gpe_device, 624 - u32 gpe_number, 625 - u32 type, 626 - acpi_gpe_handler 627 - address, 628 - void *context)) 629 - ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 630 - acpi_remove_gpe_handler(acpi_handle gpe_device, 631 - u32 gpe_number, 632 - acpi_gpe_handler 633 - address)) 634 - ACPI_EXTERNAL_RETURN_STATUS(acpi_status 635 - acpi_install_notify_handler(acpi_handle device, 636 - u32 handler_type, 637 - acpi_notify_handler 638 - handler, 592 + acpi_install_sci_handler(acpi_sci_handler 593 + address, 639 594 void *context)) 595 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 596 + acpi_remove_sci_handler(acpi_sci_handler 597 + address)) 598 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 599 + acpi_install_global_event_handler 600 + (acpi_gbl_event_handler handler, 601 + void *context)) 602 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 603 + acpi_install_fixed_event_handler(u32 604 + acpi_event, 605 + acpi_event_handler 606 + handler, 607 + void 608 + *context)) 609 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 610 + acpi_remove_fixed_event_handler(u32 acpi_event, 611 + acpi_event_handler 612 + handler)) 613 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 614 + acpi_install_gpe_handler(acpi_handle 615 + gpe_device, 616 + u32 gpe_number, 617 + u32 type, 618 + acpi_gpe_handler 619 + address, 620 + void *context)) 621 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 622 + acpi_install_gpe_raw_handler(acpi_handle 623 + gpe_device, 624 + u32 gpe_number, 625 + u32 type, 626 + acpi_gpe_handler 627 + address, 628 + void *context)) 629 + ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 630 + acpi_remove_gpe_handler(acpi_handle gpe_device, 631 + u32 gpe_number, 632 + acpi_gpe_handler 633 + address)) 640 634 ACPI_EXTERNAL_RETURN_STATUS(acpi_status 641 - acpi_remove_notify_handler(acpi_handle device, 635 + acpi_install_notify_handler(acpi_handle device, 642 636 u32 handler_type, 643 637 acpi_notify_handler 644 - handler)) 638 + handler, 639 + void *context)) 645 640 ACPI_EXTERNAL_RETURN_STATUS(acpi_status 646 - acpi_install_address_space_handler(acpi_handle 647 - device, 648 - acpi_adr_space_type 649 - space_id, 650 - acpi_adr_space_handler 651 - handler, 652 - acpi_adr_space_setup 653 - setup, 654 - void *context)) 641 + acpi_remove_notify_handler(acpi_handle device, 642 + u32 handler_type, 643 + acpi_notify_handler 644 + handler)) 655 645 ACPI_EXTERNAL_RETURN_STATUS(acpi_status 656 - acpi_remove_address_space_handler(acpi_handle 646 + acpi_install_address_space_handler(acpi_handle 657 647 device, 658 648 acpi_adr_space_type 659 649 space_id, 660 650 acpi_adr_space_handler 661 - handler)) 651 + handler, 652 + acpi_adr_space_setup 653 + setup, 654 + void *context)) 662 655 ACPI_EXTERNAL_RETURN_STATUS(acpi_status 663 - acpi_install_exception_handler 664 - (acpi_exception_handler handler)) 656 + acpi_install_address_space_handler_no_reg 657 + (acpi_handle device, acpi_adr_space_type space_id, 658 + acpi_adr_space_handler handler, 659 + acpi_adr_space_setup setup, 660 + void *context)) 665 661 ACPI_EXTERNAL_RETURN_STATUS(acpi_status 666 - acpi_install_interface_handler 667 - (acpi_interface_handler handler)) 662 + acpi_execute_reg_methods(acpi_handle device, 663 + acpi_adr_space_type 664 + space_id)) 665 + ACPI_EXTERNAL_RETURN_STATUS(acpi_status 666 + acpi_remove_address_space_handler(acpi_handle 667 + device, 668 + acpi_adr_space_type 669 + space_id, 670 + acpi_adr_space_handler 671 + handler)) 672 + ACPI_EXTERNAL_RETURN_STATUS(acpi_status 673 + acpi_install_exception_handler 674 + (acpi_exception_handler handler)) 675 + ACPI_EXTERNAL_RETURN_STATUS(acpi_status 676 + acpi_install_interface_handler 677 + (acpi_interface_handler handler)) 668 678 669 679 /* 670 680 * Global Lock interfaces