Merge additional ACPI EC driver fixes for 6.2-rc1: - Fix EC address space handler unregistration (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). * acpi-ec: ACPI: EC: Fix ECDT probe ordering issues ACPI: EC: Fix EC address space handler unregistration
Unified · Split
| @@ -94,6 +94,7 @@ enum { · 93 unmodified lines | |||
| 94 | EC_FLAGS_QUERY_ENABLED, /* Query is enabled */ | 94 | EC_FLAGS_QUERY_ENABLED, /* Query is enabled */ |
| 95 | EC_FLAGS_EVENT_HANDLER_INSTALLED, /* Event handler installed */ | 95 | EC_FLAGS_EVENT_HANDLER_INSTALLED, /* Event handler installed */ |
| 96 | EC_FLAGS_EC_HANDLER_INSTALLED, /* OpReg handler installed */ | 96 | EC_FLAGS_EC_HANDLER_INSTALLED, /* OpReg handler installed */ |
| 97 | EC_FLAGS_EC_REG_CALLED, /* OpReg ACPI _REG method called */ | ||
| 97 | EC_FLAGS_QUERY_METHODS_INSTALLED, /* _Qxx handlers installed */ | 98 | EC_FLAGS_QUERY_METHODS_INSTALLED, /* _Qxx handlers installed */ |
| 98 | EC_FLAGS_STARTED, /* Driver is started */ | 99 | EC_FLAGS_STARTED, /* Driver is started */ |
| 99 | EC_FLAGS_STOPPED, /* Driver is stopped */ | 100 | EC_FLAGS_STOPPED, /* Driver is stopped */ |
| @@ -1446,6 +1447,7 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec) · 1346 unmodified lines | |||
| 1446 | * ec_install_handlers - Install service callbacks and register query methods. | 1447 | * ec_install_handlers - Install service callbacks and register query methods. |
| 1447 | * @ec: Target EC. | 1448 | * @ec: Target EC. |
| 1448 | * @device: ACPI device object corresponding to @ec. | 1449 | * @device: ACPI device object corresponding to @ec. |
| 1450 | * @call_reg: If _REG should be called to notify OpRegion availability | ||
| 1449 | * | 1451 | * |
| 1450 | * Install a handler for the EC address space type unless it has been installed | 1452 | * Install a handler for the EC address space type unless it has been installed |
| 1451 | * already. If @device is not NULL, also look for EC query methods in the | 1453 | * already. If @device is not NULL, also look for EC query methods in the |
| @@ -1458,7 +1460,8 @@ static bool install_gpio_irq_event_handler(struct acpi_ec *ec) · 6 unmodified lines | |||
| 1458 | * -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred, | 1460 | * -EPROBE_DEFER if GPIO IRQ acquisition needs to be deferred, |
| 1459 | * or 0 (success) otherwise. | 1461 | * or 0 (success) otherwise. |
| 1460 | */ | 1462 | */ |
| 1461 | static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device) | 1463 | static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, |
| 1464 | bool call_reg) | ||
| 1462 | { | 1465 | { |
| 1463 | acpi_status status; | 1466 | acpi_status status; |
| 1464 | 1467 | ||
| @@ -1466,15 +1469,21 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device) · 1 unmodified line | |||
| 1466 | 1469 | ||
| 1467 | if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { | 1470 | if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { |
| 1468 | acpi_ec_enter_noirq(ec); | 1471 | acpi_ec_enter_noirq(ec); |
| 1469 | status = acpi_install_address_space_handler(ec->handle, | 1472 | status = acpi_install_address_space_handler_no_reg(ec->handle, |
| 1470 | ACPI_ADR_SPACE_EC, | 1473 | ACPI_ADR_SPACE_EC, |
| 1471 | &acpi_ec_space_handler, | 1474 | &acpi_ec_space_handler, |
| 1472 | NULL, ec); | 1475 | NULL, ec); |
| 1473 | if (ACPI_FAILURE(status)) { | 1476 | if (ACPI_FAILURE(status)) { |
| 1474 | acpi_ec_stop(ec, false); | 1477 | acpi_ec_stop(ec, false); |
| 1475 | return -ENODEV; | 1478 | return -ENODEV; |
| 1476 | } | 1479 | } |
| 1477 | set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); | 1480 | set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); |
| 1481 | ec->address_space_handler_holder = ec->handle; | ||
| 1482 | } | ||
| 1483 | |||
| 1484 | if (call_reg && !test_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags)) { | ||
| 1485 | acpi_execute_reg_methods(ec->handle, ACPI_ADR_SPACE_EC); | ||
| 1486 | set_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags); | ||
| 1478 | } | 1487 | } |
| 1479 | 1488 | ||
| 1480 | if (!device) | 1489 | if (!device) |
| @@ -1526,7 +1535,8 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device) · 45 unmodified lines | |||
| 1526 | static void ec_remove_handlers(struct acpi_ec *ec) | 1535 | static void ec_remove_handlers(struct acpi_ec *ec) |
| 1527 | { | 1536 | { |
| 1528 | if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { | 1537 | if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { |
| 1529 | if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle, | 1538 | if (ACPI_FAILURE(acpi_remove_address_space_handler( |
| 1539 | ec->address_space_handler_holder, | ||
| 1530 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) | 1540 | ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) |
| 1531 | pr_err("failed to remove space handler\n"); | 1541 | pr_err("failed to remove space handler\n"); |
| 1532 | clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); | 1542 | clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); |
| @@ -1562,11 +1572,11 @@ static void ec_remove_handlers(struct acpi_ec *ec) · 29 unmodified lines | |||
| 1562 | } | 1572 | } |
| 1563 | } | 1573 | } |
| 1564 | 1574 | ||
| 1565 | static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device) | 1575 | static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device, bool call_reg) |
| 1566 | { | 1576 | { |
| 1567 | int ret; | 1577 | int ret; |
| 1568 | 1578 | ||
| 1569 | ret = ec_install_handlers(ec, device); | 1579 | ret = ec_install_handlers(ec, device, call_reg); |
| 1570 | if (ret) | 1580 | if (ret) |
| 1571 | return ret; | 1581 | return ret; |
| 1572 | 1582 | ||
| @@ -1631,7 +1641,7 @@ static int acpi_ec_add(struct acpi_device *device) · 58 unmodified lines | |||
| 1631 | } | 1641 | } |
| 1632 | } | 1642 | } |
| 1633 | 1643 | ||
| 1634 | ret = acpi_ec_setup(ec, device); | 1644 | ret = acpi_ec_setup(ec, device, true); |
| 1635 | if (ret) | 1645 | if (ret) |
| 1636 | goto err; | 1646 | goto err; |
| 1637 | 1647 | ||
| @@ -1750,7 +1760,7 @@ void __init acpi_ec_dsdt_probe(void) · 112 unmodified lines | |||
| 1750 | * At this point, the GPE is not fully initialized, so do not to | 1760 | * At this point, the GPE is not fully initialized, so do not to |
| 1751 | * handle the events. | 1761 | * handle the events. |
| 1752 | */ | 1762 | */ |
| 1753 | ret = acpi_ec_setup(ec, NULL); | 1763 | ret = acpi_ec_setup(ec, NULL, true); |
| 1754 | if (ret) { | 1764 | if (ret) { |
| 1755 | acpi_ec_free(ec); | 1765 | acpi_ec_free(ec); |
| 1756 | return; | 1766 | return; |
| @@ -1944,7 +1954,7 @@ void __init acpi_ec_ecdt_probe(void) · 187 unmodified lines | |||
| 1944 | * At this point, the namespace is not initialized, so do not find | 1954 | * At this point, the namespace is not initialized, so do not find |
| 1945 | * the namespace objects, or handle the events. | 1955 | * the namespace objects, or handle the events. |
| 1946 | */ | 1956 | */ |
| 1947 | ret = acpi_ec_setup(ec, NULL); | 1957 | ret = acpi_ec_setup(ec, NULL, false); |
| 1948 | if (ret) { | 1958 | if (ret) { |
| 1949 | acpi_ec_free(ec); | 1959 | acpi_ec_free(ec); |
| 1950 | goto out; | 1960 | goto out; |
| @@ -173,6 +173,7 @@ enum acpi_ec_event_state { · 172 unmodified lines | |||
| 173 | 173 | ||
| 174 | struct acpi_ec { | 174 | struct acpi_ec { |
| 175 | acpi_handle handle; | 175 | acpi_handle handle; |
| 176 | acpi_handle address_space_handler_holder; | ||
| 176 | int gpe; | 177 | int gpe; |
| 177 | int irq; | 178 | int irq; |
| 178 | unsigned long command_addr; | 179 | unsigned long command_addr; |