History

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

Linus Torvalds committed 3 years ago

Commit 057b40f2 parents 601c1aa 3d031405 files · +181 −80Browse files

Unified · Split

5 files
  1. drivers/acpi/acpica/dswexec.c +4 −2
  2. drivers/acpi/acpica/evxfregn.c +85 −7
  3. drivers/acpi/ec.c +21 −11
  4. drivers/acpi/internal.h +1 −0
  5. include/acpi/acpixf.h +70 −60
drivers/acpi/acpica/dswexec.c+4−2
@@ -389,9 +389,11 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) · 388 unmodified lines
389 389
390 /*390 /*
391 * All opcodes require operand resolution, with the only exceptions391 * 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 /* Resolve all operands */398 /* Resolve all operands */
397 399
drivers/acpi/acpica/evxfregn.c+85−7
@@ -20,13 +20,14 @@ ACPI_MODULE_NAME("evxfregn") · 19 unmodified lines
20 20
21/*******************************************************************************21/*******************************************************************************
22 *22 *
23 * FUNCTION: acpi_install_address_space_handler23 * FUNCTION: acpi_install_address_space_handler_internal
24 *24 *
25 * PARAMETERS: device - Handle for the device25 * PARAMETERS: device - Handle for the device
26 * space_id - The address space ID26 * space_id - The address space ID
27 * handler - Address of the handler27 * handler - Address of the handler
28 * setup - Address of the setup function28 * setup - Address of the setup function
29 * context - Value passed to the handler on each access29 * context - Value passed to the handler on each access
30 * Run_reg - Run _REG methods for this address space?
30 *31 *
31 * RETURN: Status32 * RETURN: Status
32 *33 *
@@ -37,13 +38,16 @@ ACPI_MODULE_NAME("evxfregn") · 4 unmodified lines
37 * are executed here, and these methods can only be safely executed after38 * are executed here, and these methods can only be safely executed after
38 * the default handlers have been installed and the hardware has been39 * the default handlers have been installed and the hardware has been
39 * initialized (via acpi_enable_subsystem.)40 * initialized (via acpi_enable_subsystem.)
41 * To avoid this problem pass FALSE for Run_Reg and later on call
42 * acpi_execute_reg_methods() to execute _REG.
40 *43 *
41 ******************************************************************************/44 ******************************************************************************/
42acpi_status45static acpi_status
43acpi_install_address_space_handler(acpi_handle device,46acpi_install_address_space_handler_internal(acpi_handle device,
44 acpi_adr_space_type space_id,47 acpi_adr_space_type space_id,
45 acpi_adr_space_handler handler,48 acpi_adr_space_handler handler,
46 acpi_adr_space_setup setup, void *context)49 acpi_adr_space_setup setup,
50 void *context, u8 run_reg)
47{51{
48 struct acpi_namespace_node *node;52 struct acpi_namespace_node *node;
49 acpi_status status;53 acpi_status status;
@@ -80,14 +84,40 @@ acpi_install_address_space_handler(acpi_handle device, · 30 unmodified lines
80 84
81 /* Run all _REG methods for this address space */85 /* Run all _REG methods for this address space */
82 86
83 acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT);87 if (run_reg) {
88 acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT);
89 }
84 90
85unlock_and_exit:91unlock_and_exit:
86 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);92 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
87 return_ACPI_STATUS(status);93 return_ACPI_STATUS(status);
88}94}
89 95
96acpi_status
97acpi_install_address_space_handler(acpi_handle device,
98 acpi_adr_space_type space_id,
99 acpi_adr_space_handler handler,
100 acpi_adr_space_setup setup, void *context)
101{
102 return acpi_install_address_space_handler_internal(device, space_id,
103 handler, setup,
104 context, TRUE);
105}
106
90ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler)107ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler)
108acpi_status
109acpi_install_address_space_handler_no_reg(acpi_handle device,
110 acpi_adr_space_type space_id,
111 acpi_adr_space_handler handler,
112 acpi_adr_space_setup setup,
113 void *context)
114{
115 return acpi_install_address_space_handler_internal(device, space_id,
116 handler, setup,
117 context, FALSE);
118}
119
120ACPI_EXPORT_SYMBOL(acpi_install_address_space_handler_no_reg)
91 121
92/*******************************************************************************122/*******************************************************************************
93 *123 *
@@ -228,3 +258,51 @@ unlock_and_exit: · 134 unmodified lines
228}258}
229 259
230ACPI_EXPORT_SYMBOL(acpi_remove_address_space_handler)260ACPI_EXPORT_SYMBOL(acpi_remove_address_space_handler)
261/*******************************************************************************
262 *
263 * FUNCTION: acpi_execute_reg_methods
264 *
265 * PARAMETERS: device - Handle for the device
266 * space_id - The address space ID
267 *
268 * RETURN: Status
269 *
270 * DESCRIPTION: Execute _REG for all op_regions of a given space_id.
271 *
272 ******************************************************************************/
273acpi_status
274acpi_execute_reg_methods(acpi_handle device, acpi_adr_space_type space_id)
275{
276 struct acpi_namespace_node *node;
277 acpi_status status;
278
279 ACPI_FUNCTION_TRACE(acpi_execute_reg_methods);
280
281 /* Parameter validation */
282
283 if (!device) {
284 return_ACPI_STATUS(AE_BAD_PARAMETER);
285 }
286
287 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
290 }
291
292 /* Convert and validate the device handle */
293
294 node = acpi_ns_validate_handle(device);
295 if (node) {
296
297 /* Run all _REG methods for this address space */
298
299 acpi_ev_execute_reg_methods(node, space_id, ACPI_REG_CONNECT);
300 } else {
301 status = AE_BAD_PARAMETER;
302 }
303
304 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
305 return_ACPI_STATUS(status);
306}
307
308ACPI_EXPORT_SYMBOL(acpi_execute_reg_methods)
drivers/acpi/ec.c+21−11
@@ -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 installed1452 * 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 the1453 * 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 */
1461static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)1463static 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
1526static void ec_remove_handlers(struct acpi_ec *ec)1535static 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
1565static int acpi_ec_setup(struct acpi_ec *ec, struct acpi_device *device)1575static 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 to1760 * 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 find1954 * 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;
drivers/acpi/internal.h+1−0
@@ -173,6 +173,7 @@ enum acpi_ec_event_state { · 172 unmodified lines
173 173
174struct acpi_ec {174struct 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;
include/acpi/acpixf.h+70−60
@@ -589,82 +589,92 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status · 588 unmodified lines
589 acpi_install_initialization_handler589 acpi_install_initialization_handler
590 (acpi_init_handler handler, u32 function))590 (acpi_init_handler handler, u32 function))
591ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status591ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
592 acpi_install_sci_handler(acpi_sci_handler592 acpi_install_sci_handler(acpi_sci_handler
593 address,593 address,
594 void *context))594 void *context))
595ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
596 acpi_remove_sci_handler(acpi_sci_handler
597 address))
598ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status595ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
599 acpi_install_global_event_handler596 acpi_remove_sci_handler(acpi_sci_handler
600 (acpi_gbl_event_handler handler,597 address))
601 void *context))
602ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status598ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
603 acpi_install_fixed_event_handler(u32599 acpi_install_global_event_handler
604 acpi_event,600 (acpi_gbl_event_handler handler,
605 acpi_event_handler601 void *context))
606 handler,
607 void
608 *context))
609ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status602ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
610 acpi_remove_fixed_event_handler(u32 acpi_event,603 acpi_install_fixed_event_handler(u32
604 acpi_event,
611 acpi_event_handler605 acpi_event_handler
612 handler))606 handler,
613ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status607 void
614 acpi_install_gpe_handler(acpi_handle608 *context))
615 gpe_device,
616 u32 gpe_number,
617 u32 type,
618 acpi_gpe_handler
619 address,
620 void *context))
621ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status609ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
622 acpi_install_gpe_raw_handler(acpi_handle610 acpi_remove_fixed_event_handler(u32 acpi_event,
623 gpe_device,611 acpi_event_handler
624 u32 gpe_number,612 handler))
625 u32 type,
626 acpi_gpe_handler
627 address,
628 void *context))
629ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status613ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
630 acpi_remove_gpe_handler(acpi_handle gpe_device,614 acpi_install_gpe_handler(acpi_handle
615 gpe_device,
631 u32 gpe_number,616 u32 gpe_number,
617 u32 type,
632 acpi_gpe_handler618 acpi_gpe_handler
633 address))619 address,
634ACPI_EXTERNAL_RETURN_STATUS(acpi_status
635 acpi_install_notify_handler(acpi_handle device,
636 u32 handler_type,
637 acpi_notify_handler
638 handler,
639 void *context))620 void *context))
621ACPI_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))
629ACPI_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))
640ACPI_EXTERNAL_RETURN_STATUS(acpi_status634ACPI_EXTERNAL_RETURN_STATUS(acpi_status
641 acpi_remove_notify_handler(acpi_handle device,635 acpi_install_notify_handler(acpi_handle device,
642 u32 handler_type,636 u32 handler_type,
643 acpi_notify_handler637 acpi_notify_handler
644 handler))638 handler,
645ACPI_EXTERNAL_RETURN_STATUS(acpi_status639 void *context))
646 acpi_install_address_space_handler(acpi_handle640ACPI_EXTERNAL_RETURN_STATUS(acpi_status
647 device,641 acpi_remove_notify_handler(acpi_handle device,
648 acpi_adr_space_type642 u32 handler_type,
649 space_id,643 acpi_notify_handler
650 acpi_adr_space_handler644 handler))
651 handler,645ACPI_EXTERNAL_RETURN_STATUS(acpi_status
652 acpi_adr_space_setup646 acpi_install_address_space_handler(acpi_handle
653 setup,
654 void *context))
655ACPI_EXTERNAL_RETURN_STATUS(acpi_status
656 acpi_remove_address_space_handler(acpi_handle
657 device,647 device,
658 acpi_adr_space_type648 acpi_adr_space_type
659 space_id,649 space_id,
660 acpi_adr_space_handler650 acpi_adr_space_handler
661 handler))651 handler,
662ACPI_EXTERNAL_RETURN_STATUS(acpi_status652 acpi_adr_space_setup
663 acpi_install_exception_handler653 setup,
664 (acpi_exception_handler handler))654 void *context))
665ACPI_EXTERNAL_RETURN_STATUS(acpi_status655ACPI_EXTERNAL_RETURN_STATUS(acpi_status
666 acpi_install_interface_handler656 acpi_install_address_space_handler_no_reg
667 (acpi_interface_handler handler))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))
661ACPI_EXTERNAL_RETURN_STATUS(acpi_status
662 acpi_execute_reg_methods(acpi_handle device,
663 acpi_adr_space_type
664 space_id))
665ACPI_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))
672ACPI_EXTERNAL_RETURN_STATUS(acpi_status
673 acpi_install_exception_handler
674 (acpi_exception_handler handler))
675ACPI_EXTERNAL_RETURN_STATUS(acpi_status
676 acpi_install_interface_handler
677 (acpi_interface_handler handler))
668 678
669/*679/*
670 * Global Lock interfaces680 * Global Lock interfaces

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t