aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig10
-rw-r--r--drivers/acpi/acpi_dbg.c30
-rw-r--r--drivers/acpi/apei/einj.c86
-rw-r--r--drivers/acpi/custom_method.c6
-rw-r--r--drivers/acpi/dptf/Makefile2
-rw-r--r--drivers/acpi/dptf/int340x_thermal.c2
-rw-r--r--drivers/acpi/ec.c208
-rw-r--r--drivers/acpi/ec_sys.c36
-rw-r--r--drivers/acpi/internal.h4
-rw-r--r--drivers/acpi/pptt.c13
-rw-r--r--drivers/acpi/tables.c12
11 files changed, 183 insertions, 226 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 90ff0a47c12e..4e015c77e48e 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -357,6 +357,16 @@ config ACPI_TABLE_UPGRADE
357 initrd, therefore it's safe to say Y. 357 initrd, therefore it's safe to say Y.
358 See Documentation/acpi/initrd_table_override.txt for details 358 See Documentation/acpi/initrd_table_override.txt for details
359 359
360config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
361 bool "Override ACPI tables from built-in initrd"
362 depends on ACPI_TABLE_UPGRADE
363 depends on INITRAMFS_SOURCE!="" && INITRAMFS_COMPRESSION=""
364 help
365 This option provides functionality to override arbitrary ACPI tables
366 from built-in uncompressed initrd.
367
368 See Documentation/acpi/initrd_table_override.txt for details
369
360config ACPI_DEBUG 370config ACPI_DEBUG
361 bool "Debug Statements" 371 bool "Debug Statements"
362 help 372 help
diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index a2dcd62ea32f..4a434c23a196 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -750,48 +750,36 @@ static const struct acpi_debugger_ops acpi_aml_debugger = {
750 750
751int __init acpi_aml_init(void) 751int __init acpi_aml_init(void)
752{ 752{
753 int ret = 0; 753 int ret;
754
755 if (!acpi_debugfs_dir) {
756 ret = -ENOENT;
757 goto err_exit;
758 }
759 754
760 /* Initialize AML IO interface */ 755 /* Initialize AML IO interface */
761 mutex_init(&acpi_aml_io.lock); 756 mutex_init(&acpi_aml_io.lock);
762 init_waitqueue_head(&acpi_aml_io.wait); 757 init_waitqueue_head(&acpi_aml_io.wait);
763 acpi_aml_io.out_crc.buf = acpi_aml_io.out_buf; 758 acpi_aml_io.out_crc.buf = acpi_aml_io.out_buf;
764 acpi_aml_io.in_crc.buf = acpi_aml_io.in_buf; 759 acpi_aml_io.in_crc.buf = acpi_aml_io.in_buf;
760
765 acpi_aml_dentry = debugfs_create_file("acpidbg", 761 acpi_aml_dentry = debugfs_create_file("acpidbg",
766 S_IFREG | S_IRUGO | S_IWUSR, 762 S_IFREG | S_IRUGO | S_IWUSR,
767 acpi_debugfs_dir, NULL, 763 acpi_debugfs_dir, NULL,
768 &acpi_aml_operations); 764 &acpi_aml_operations);
769 if (acpi_aml_dentry == NULL) {
770 ret = -ENODEV;
771 goto err_exit;
772 }
773 ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
774 if (ret)
775 goto err_fs;
776 acpi_aml_initialized = true;
777 765
778err_fs: 766 ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
779 if (ret) { 767 if (ret) {
780 debugfs_remove(acpi_aml_dentry); 768 debugfs_remove(acpi_aml_dentry);
781 acpi_aml_dentry = NULL; 769 acpi_aml_dentry = NULL;
770 return ret;
782 } 771 }
783err_exit: 772
784 return ret; 773 acpi_aml_initialized = true;
774 return 0;
785} 775}
786 776
787void __exit acpi_aml_exit(void) 777void __exit acpi_aml_exit(void)
788{ 778{
789 if (acpi_aml_initialized) { 779 if (acpi_aml_initialized) {
790 acpi_unregister_debugger(&acpi_aml_debugger); 780 acpi_unregister_debugger(&acpi_aml_debugger);
791 if (acpi_aml_dentry) { 781 debugfs_remove(acpi_aml_dentry);
792 debugfs_remove(acpi_aml_dentry); 782 acpi_aml_dentry = NULL;
793 acpi_aml_dentry = NULL;
794 }
795 acpi_aml_initialized = false; 783 acpi_aml_initialized = false;
796 } 784 }
797} 785}
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index fcccbfdbdd1a..c42299e048e4 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -679,7 +679,6 @@ static int __init einj_init(void)
679{ 679{
680 int rc; 680 int rc;
681 acpi_status status; 681 acpi_status status;
682 struct dentry *fentry;
683 struct apei_exec_context ctx; 682 struct apei_exec_context ctx;
684 683
685 if (acpi_disabled) { 684 if (acpi_disabled) {
@@ -707,25 +706,13 @@ static int __init einj_init(void)
707 706
708 rc = -ENOMEM; 707 rc = -ENOMEM;
709 einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir()); 708 einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
710 if (!einj_debug_dir) {
711 pr_err("Error creating debugfs node.\n");
712 goto err_cleanup;
713 }
714 709
715 fentry = debugfs_create_file("available_error_type", S_IRUSR, 710 debugfs_create_file("available_error_type", S_IRUSR, einj_debug_dir,
716 einj_debug_dir, NULL, 711 NULL, &available_error_type_fops);
717 &available_error_type_fops); 712 debugfs_create_file("error_type", S_IRUSR | S_IWUSR, einj_debug_dir,
718 if (!fentry) 713 NULL, &error_type_fops);
719 goto err_cleanup; 714 debugfs_create_file("error_inject", S_IWUSR, einj_debug_dir,
720 715 NULL, &error_inject_fops);
721 fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
722 einj_debug_dir, NULL, &error_type_fops);
723 if (!fentry)
724 goto err_cleanup;
725 fentry = debugfs_create_file("error_inject", S_IWUSR,
726 einj_debug_dir, NULL, &error_inject_fops);
727 if (!fentry)
728 goto err_cleanup;
729 716
730 apei_resources_init(&einj_resources); 717 apei_resources_init(&einj_resources);
731 einj_exec_ctx_init(&ctx); 718 einj_exec_ctx_init(&ctx);
@@ -750,66 +737,37 @@ static int __init einj_init(void)
750 rc = -ENOMEM; 737 rc = -ENOMEM;
751 einj_param = einj_get_parameter_address(); 738 einj_param = einj_get_parameter_address();
752 if ((param_extension || acpi5) && einj_param) { 739 if ((param_extension || acpi5) && einj_param) {
753 fentry = debugfs_create_x32("flags", S_IRUSR | S_IWUSR, 740 debugfs_create_x32("flags", S_IRUSR | S_IWUSR, einj_debug_dir,
754 einj_debug_dir, &error_flags); 741 &error_flags);
755 if (!fentry) 742 debugfs_create_x64("param1", S_IRUSR | S_IWUSR, einj_debug_dir,
756 goto err_unmap; 743 &error_param1);
757 fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, 744 debugfs_create_x64("param2", S_IRUSR | S_IWUSR, einj_debug_dir,
758 einj_debug_dir, &error_param1); 745 &error_param2);
759 if (!fentry) 746 debugfs_create_x64("param3", S_IRUSR | S_IWUSR, einj_debug_dir,
760 goto err_unmap; 747 &error_param3);
761 fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, 748 debugfs_create_x64("param4", S_IRUSR | S_IWUSR, einj_debug_dir,
762 einj_debug_dir, &error_param2); 749 &error_param4);
763 if (!fentry) 750 debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
764 goto err_unmap; 751 einj_debug_dir, &notrigger);
765 fentry = debugfs_create_x64("param3", S_IRUSR | S_IWUSR,
766 einj_debug_dir, &error_param3);
767 if (!fentry)
768 goto err_unmap;
769 fentry = debugfs_create_x64("param4", S_IRUSR | S_IWUSR,
770 einj_debug_dir, &error_param4);
771 if (!fentry)
772 goto err_unmap;
773
774 fentry = debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
775 einj_debug_dir, &notrigger);
776 if (!fentry)
777 goto err_unmap;
778 } 752 }
779 753
780 if (vendor_dev[0]) { 754 if (vendor_dev[0]) {
781 vendor_blob.data = vendor_dev; 755 vendor_blob.data = vendor_dev;
782 vendor_blob.size = strlen(vendor_dev); 756 vendor_blob.size = strlen(vendor_dev);
783 fentry = debugfs_create_blob("vendor", S_IRUSR, 757 debugfs_create_blob("vendor", S_IRUSR, einj_debug_dir,
784 einj_debug_dir, &vendor_blob); 758 &vendor_blob);
785 if (!fentry) 759 debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
786 goto err_unmap; 760 einj_debug_dir, &vendor_flags);
787 fentry = debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
788 einj_debug_dir, &vendor_flags);
789 if (!fentry)
790 goto err_unmap;
791 } 761 }
792 762
793 pr_info("Error INJection is initialized.\n"); 763 pr_info("Error INJection is initialized.\n");
794 764
795 return 0; 765 return 0;
796 766
797err_unmap:
798 if (einj_param) {
799 acpi_size size = (acpi5) ?
800 sizeof(struct set_error_type_with_address) :
801 sizeof(struct einj_parameter);
802
803 acpi_os_unmap_iomem(einj_param, size);
804 pr_err("Error creating param extension debugfs nodes.\n");
805 }
806 apei_exec_post_unmap_gars(&ctx);
807err_release: 767err_release:
808 apei_resources_release(&einj_resources); 768 apei_resources_release(&einj_resources);
809err_fini: 769err_fini:
810 apei_resources_fini(&einj_resources); 770 apei_resources_fini(&einj_resources);
811err_cleanup:
812 pr_err("Error creating primary debugfs nodes.\n");
813 debugfs_remove_recursive(einj_debug_dir); 771 debugfs_remove_recursive(einj_debug_dir);
814 772
815 return rc; 773 return rc;
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 4451877f83b6..aa972dc5cb7e 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -79,14 +79,8 @@ static const struct file_operations cm_fops = {
79 79
80static int __init acpi_custom_method_init(void) 80static int __init acpi_custom_method_init(void)
81{ 81{
82 if (acpi_debugfs_dir == NULL)
83 return -ENOENT;
84
85 cm_dentry = debugfs_create_file("custom_method", S_IWUSR, 82 cm_dentry = debugfs_create_file("custom_method", S_IWUSR,
86 acpi_debugfs_dir, NULL, &cm_fops); 83 acpi_debugfs_dir, NULL, &cm_fops);
87 if (cm_dentry == NULL)
88 return -ENODEV;
89
90 return 0; 84 return 0;
91} 85}
92 86
diff --git a/drivers/acpi/dptf/Makefile b/drivers/acpi/dptf/Makefile
index 06ea8809583d..e6032e47e83f 100644
--- a/drivers/acpi/dptf/Makefile
+++ b/drivers/acpi/dptf/Makefile
@@ -1,4 +1,2 @@
1obj-$(CONFIG_ACPI) += int340x_thermal.o 1obj-$(CONFIG_ACPI) += int340x_thermal.o
2obj-$(CONFIG_DPTF_POWER) += dptf_power.o 2obj-$(CONFIG_DPTF_POWER) += dptf_power.o
3
4ccflags-y += -Idrivers/acpi
diff --git a/drivers/acpi/dptf/int340x_thermal.c b/drivers/acpi/dptf/int340x_thermal.c
index 86364097e236..0aa7c2e62e95 100644
--- a/drivers/acpi/dptf/int340x_thermal.c
+++ b/drivers/acpi/dptf/int340x_thermal.c
@@ -12,7 +12,7 @@
12#include <linux/acpi.h> 12#include <linux/acpi.h>
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15#include "internal.h" 15#include "../internal.h"
16 16
17#define INT3401_DEVICE 0X01 17#define INT3401_DEVICE 0X01
18static const struct acpi_device_id int340x_thermal_device_ids[] = { 18static const struct acpi_device_id int340x_thermal_device_ids[] = {
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 9d66a47d32fb..48d4815603e5 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -186,14 +186,17 @@ static void advance_transaction(struct acpi_ec *ec);
186static void acpi_ec_event_handler(struct work_struct *work); 186static void acpi_ec_event_handler(struct work_struct *work);
187static void acpi_ec_event_processor(struct work_struct *work); 187static void acpi_ec_event_processor(struct work_struct *work);
188 188
189struct acpi_ec *boot_ec, *first_ec; 189struct acpi_ec *first_ec;
190EXPORT_SYMBOL(first_ec); 190EXPORT_SYMBOL(first_ec);
191
192static struct acpi_ec *boot_ec;
191static bool boot_ec_is_ecdt = false; 193static bool boot_ec_is_ecdt = false;
192static struct workqueue_struct *ec_query_wq; 194static struct workqueue_struct *ec_query_wq;
193 195
194static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ 196static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
195static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */ 197static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */
196static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */ 198static int EC_FLAGS_IGNORE_DSDT_GPE; /* Needs ECDT GPE as correction setting */
199static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
197 200
198/* -------------------------------------------------------------------------- 201/* --------------------------------------------------------------------------
199 * Logging/Debugging 202 * Logging/Debugging
@@ -499,6 +502,26 @@ static inline void __acpi_ec_disable_event(struct acpi_ec *ec)
499 ec_log_drv("event blocked"); 502 ec_log_drv("event blocked");
500} 503}
501 504
505/*
506 * Process _Q events that might have accumulated in the EC.
507 * Run with locked ec mutex.
508 */
509static void acpi_ec_clear(struct acpi_ec *ec)
510{
511 int i, status;
512 u8 value = 0;
513
514 for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) {
515 status = acpi_ec_query(ec, &value);
516 if (status || !value)
517 break;
518 }
519 if (unlikely(i == ACPI_EC_CLEAR_MAX))
520 pr_warn("Warning: Maximum of %d stale EC events cleared\n", i);
521 else
522 pr_info("%d stale EC events cleared\n", i);
523}
524
502static void acpi_ec_enable_event(struct acpi_ec *ec) 525static void acpi_ec_enable_event(struct acpi_ec *ec)
503{ 526{
504 unsigned long flags; 527 unsigned long flags;
@@ -507,6 +530,10 @@ static void acpi_ec_enable_event(struct acpi_ec *ec)
507 if (acpi_ec_started(ec)) 530 if (acpi_ec_started(ec))
508 __acpi_ec_enable_event(ec); 531 __acpi_ec_enable_event(ec);
509 spin_unlock_irqrestore(&ec->lock, flags); 532 spin_unlock_irqrestore(&ec->lock, flags);
533
534 /* Drain additional events if hardware requires that */
535 if (EC_FLAGS_CLEAR_ON_RESUME)
536 acpi_ec_clear(ec);
510} 537}
511 538
512#ifdef CONFIG_PM_SLEEP 539#ifdef CONFIG_PM_SLEEP
@@ -1539,49 +1566,6 @@ static int acpi_ec_setup(struct acpi_ec *ec, bool handle_events)
1539 return ret; 1566 return ret;
1540} 1567}
1541 1568
1542static int acpi_config_boot_ec(struct acpi_ec *ec, acpi_handle handle,
1543 bool handle_events, bool is_ecdt)
1544{
1545 int ret;
1546
1547 /*
1548 * Changing the ACPI handle results in a re-configuration of the
1549 * boot EC. And if it happens after the namespace initialization,
1550 * it causes _REG evaluations.
1551 */
1552 if (boot_ec && boot_ec->handle != handle)
1553 ec_remove_handlers(boot_ec);
1554
1555 /* Unset old boot EC */
1556 if (boot_ec != ec)
1557 acpi_ec_free(boot_ec);
1558
1559 /*
1560 * ECDT device creation is split into acpi_ec_ecdt_probe() and
1561 * acpi_ec_ecdt_start(). This function takes care of completing the
1562 * ECDT parsing logic as the handle update should be performed
1563 * between the installation/uninstallation of the handlers.
1564 */
1565 if (ec->handle != handle)
1566 ec->handle = handle;
1567
1568 ret = acpi_ec_setup(ec, handle_events);
1569 if (ret)
1570 return ret;
1571
1572 /* Set new boot EC */
1573 if (!boot_ec) {
1574 boot_ec = ec;
1575 boot_ec_is_ecdt = is_ecdt;
1576 }
1577
1578 acpi_handle_info(boot_ec->handle,
1579 "Used as boot %s EC to handle transactions%s\n",
1580 is_ecdt ? "ECDT" : "DSDT",
1581 handle_events ? " and events" : "");
1582 return ret;
1583}
1584
1585static bool acpi_ec_ecdt_get_handle(acpi_handle *phandle) 1569static bool acpi_ec_ecdt_get_handle(acpi_handle *phandle)
1586{ 1570{
1587 struct acpi_table_ecdt *ecdt_ptr; 1571 struct acpi_table_ecdt *ecdt_ptr;
@@ -1601,43 +1585,34 @@ static bool acpi_ec_ecdt_get_handle(acpi_handle *phandle)
1601 return true; 1585 return true;
1602} 1586}
1603 1587
1604static bool acpi_is_boot_ec(struct acpi_ec *ec)
1605{
1606 if (!boot_ec)
1607 return false;
1608 if (ec->command_addr == boot_ec->command_addr &&
1609 ec->data_addr == boot_ec->data_addr)
1610 return true;
1611 return false;
1612}
1613
1614static int acpi_ec_add(struct acpi_device *device) 1588static int acpi_ec_add(struct acpi_device *device)
1615{ 1589{
1616 struct acpi_ec *ec = NULL; 1590 struct acpi_ec *ec = NULL;
1617 int ret; 1591 bool dep_update = true;
1618 bool is_ecdt = false;
1619 acpi_status status; 1592 acpi_status status;
1593 int ret;
1620 1594
1621 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1595 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1622 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1596 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1623 1597
1624 if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) { 1598 if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) {
1625 is_ecdt = true; 1599 boot_ec_is_ecdt = true;
1626 ec = boot_ec; 1600 ec = boot_ec;
1601 dep_update = false;
1627 } else { 1602 } else {
1628 ec = acpi_ec_alloc(); 1603 ec = acpi_ec_alloc();
1629 if (!ec) 1604 if (!ec)
1630 return -ENOMEM; 1605 return -ENOMEM;
1606
1631 status = ec_parse_device(device->handle, 0, ec, NULL); 1607 status = ec_parse_device(device->handle, 0, ec, NULL);
1632 if (status != AE_CTRL_TERMINATE) { 1608 if (status != AE_CTRL_TERMINATE) {
1633 ret = -EINVAL; 1609 ret = -EINVAL;
1634 goto err_alloc; 1610 goto err_alloc;
1635 } 1611 }
1636 }
1637 1612
1638 if (acpi_is_boot_ec(ec)) { 1613 if (boot_ec && ec->command_addr == boot_ec->command_addr &&
1639 boot_ec_is_ecdt = is_ecdt; 1614 ec->data_addr == boot_ec->data_addr) {
1640 if (!is_ecdt) { 1615 boot_ec_is_ecdt = false;
1641 /* 1616 /*
1642 * Trust PNP0C09 namespace location rather than 1617 * Trust PNP0C09 namespace location rather than
1643 * ECDT ID. But trust ECDT GPE rather than _GPE 1618 * ECDT ID. But trust ECDT GPE rather than _GPE
@@ -1649,12 +1624,17 @@ static int acpi_ec_add(struct acpi_device *device)
1649 acpi_ec_free(ec); 1624 acpi_ec_free(ec);
1650 ec = boot_ec; 1625 ec = boot_ec;
1651 } 1626 }
1652 ret = acpi_config_boot_ec(ec, ec->handle, true, is_ecdt); 1627 }
1653 } else 1628
1654 ret = acpi_ec_setup(ec, true); 1629 ret = acpi_ec_setup(ec, true);
1655 if (ret) 1630 if (ret)
1656 goto err_query; 1631 goto err_query;
1657 1632
1633 if (ec == boot_ec)
1634 acpi_handle_info(boot_ec->handle,
1635 "Boot %s EC used to handle transactions and events\n",
1636 boot_ec_is_ecdt ? "ECDT" : "DSDT");
1637
1658 device->driver_data = ec; 1638 device->driver_data = ec;
1659 1639
1660 ret = !!request_region(ec->data_addr, 1, "EC data"); 1640 ret = !!request_region(ec->data_addr, 1, "EC data");
@@ -1662,7 +1642,7 @@ static int acpi_ec_add(struct acpi_device *device)
1662 ret = !!request_region(ec->command_addr, 1, "EC cmd"); 1642 ret = !!request_region(ec->command_addr, 1, "EC cmd");
1663 WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr); 1643 WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
1664 1644
1665 if (!is_ecdt) { 1645 if (dep_update) {
1666 /* Reprobe devices depending on the EC */ 1646 /* Reprobe devices depending on the EC */
1667 acpi_walk_dep_device_list(ec->handle); 1647 acpi_walk_dep_device_list(ec->handle);
1668 } 1648 }
@@ -1730,10 +1710,10 @@ static const struct acpi_device_id ec_device_ids[] = {
1730 * namespace EC before the main ACPI device enumeration process. It is 1710 * namespace EC before the main ACPI device enumeration process. It is
1731 * retained for historical reason and will be deprecated in the future. 1711 * retained for historical reason and will be deprecated in the future.
1732 */ 1712 */
1733int __init acpi_ec_dsdt_probe(void) 1713void __init acpi_ec_dsdt_probe(void)
1734{ 1714{
1735 acpi_status status;
1736 struct acpi_ec *ec; 1715 struct acpi_ec *ec;
1716 acpi_status status;
1737 int ret; 1717 int ret;
1738 1718
1739 /* 1719 /*
@@ -1743,21 +1723,22 @@ int __init acpi_ec_dsdt_probe(void)
1743 * picking up an invalid EC device. 1723 * picking up an invalid EC device.
1744 */ 1724 */
1745 if (boot_ec) 1725 if (boot_ec)
1746 return -ENODEV; 1726 return;
1747 1727
1748 ec = acpi_ec_alloc(); 1728 ec = acpi_ec_alloc();
1749 if (!ec) 1729 if (!ec)
1750 return -ENOMEM; 1730 return;
1731
1751 /* 1732 /*
1752 * At this point, the namespace is initialized, so start to find 1733 * At this point, the namespace is initialized, so start to find
1753 * the namespace objects. 1734 * the namespace objects.
1754 */ 1735 */
1755 status = acpi_get_devices(ec_device_ids[0].id, 1736 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device, ec, NULL);
1756 ec_parse_device, ec, NULL);
1757 if (ACPI_FAILURE(status) || !ec->handle) { 1737 if (ACPI_FAILURE(status) || !ec->handle) {
1758 ret = -ENODEV; 1738 acpi_ec_free(ec);
1759 goto error; 1739 return;
1760 } 1740 }
1741
1761 /* 1742 /*
1762 * When the DSDT EC is available, always re-configure boot EC to 1743 * When the DSDT EC is available, always re-configure boot EC to
1763 * have _REG evaluated. _REG can only be evaluated after the 1744 * have _REG evaluated. _REG can only be evaluated after the
@@ -1765,11 +1746,16 @@ int __init acpi_ec_dsdt_probe(void)
1765 * At this point, the GPE is not fully initialized, so do not to 1746 * At this point, the GPE is not fully initialized, so do not to
1766 * handle the events. 1747 * handle the events.
1767 */ 1748 */
1768 ret = acpi_config_boot_ec(ec, ec->handle, false, false); 1749 ret = acpi_ec_setup(ec, false);
1769error: 1750 if (ret) {
1770 if (ret)
1771 acpi_ec_free(ec); 1751 acpi_ec_free(ec);
1772 return ret; 1752 return;
1753 }
1754
1755 boot_ec = ec;
1756
1757 acpi_handle_info(ec->handle,
1758 "Boot DSDT EC used to handle transactions\n");
1773} 1759}
1774 1760
1775/* 1761/*
@@ -1821,6 +1807,31 @@ static int ec_flag_query_handshake(const struct dmi_system_id *id)
1821#endif 1807#endif
1822 1808
1823/* 1809/*
1810 * On some hardware it is necessary to clear events accumulated by the EC during
1811 * sleep. These ECs stop reporting GPEs until they are manually polled, if too
1812 * many events are accumulated. (e.g. Samsung Series 5/9 notebooks)
1813 *
1814 * https://bugzilla.kernel.org/show_bug.cgi?id=44161
1815 *
1816 * Ideally, the EC should also be instructed NOT to accumulate events during
1817 * sleep (which Windows seems to do somehow), but the interface to control this
1818 * behaviour is not known at this time.
1819 *
1820 * Models known to be affected are Samsung 530Uxx/535Uxx/540Uxx/550Pxx/900Xxx,
1821 * however it is very likely that other Samsung models are affected.
1822 *
1823 * On systems which don't accumulate _Q events during sleep, this extra check
1824 * should be harmless.
1825 */
1826static int ec_clear_on_resume(const struct dmi_system_id *id)
1827{
1828 pr_debug("Detected system needing EC poll on resume.\n");
1829 EC_FLAGS_CLEAR_ON_RESUME = 1;
1830 ec_event_clearing = ACPI_EC_EVT_TIMING_STATUS;
1831 return 0;
1832}
1833
1834/*
1824 * Some ECDTs contain wrong register addresses. 1835 * Some ECDTs contain wrong register addresses.
1825 * MSI MS-171F 1836 * MSI MS-171F
1826 * https://bugzilla.kernel.org/show_bug.cgi?id=12461 1837 * https://bugzilla.kernel.org/show_bug.cgi?id=12461
@@ -1869,39 +1880,38 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = {
1869 ec_honor_ecdt_gpe, "ASUS X580VD", { 1880 ec_honor_ecdt_gpe, "ASUS X580VD", {
1870 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 1881 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
1871 DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL}, 1882 DMI_MATCH(DMI_PRODUCT_NAME, "X580VD"),}, NULL},
1883 {
1884 ec_clear_on_resume, "Samsung hardware", {
1885 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
1872 {}, 1886 {},
1873}; 1887};
1874 1888
1875int __init acpi_ec_ecdt_probe(void) 1889void __init acpi_ec_ecdt_probe(void)
1876{ 1890{
1877 int ret;
1878 acpi_status status;
1879 struct acpi_table_ecdt *ecdt_ptr; 1891 struct acpi_table_ecdt *ecdt_ptr;
1880 struct acpi_ec *ec; 1892 struct acpi_ec *ec;
1893 acpi_status status;
1894 int ret;
1881 1895
1882 ec = acpi_ec_alloc(); 1896 /* Generate a boot ec context. */
1883 if (!ec)
1884 return -ENOMEM;
1885 /*
1886 * Generate a boot ec context
1887 */
1888 dmi_check_system(ec_dmi_table); 1897 dmi_check_system(ec_dmi_table);
1889 status = acpi_get_table(ACPI_SIG_ECDT, 1, 1898 status = acpi_get_table(ACPI_SIG_ECDT, 1,
1890 (struct acpi_table_header **)&ecdt_ptr); 1899 (struct acpi_table_header **)&ecdt_ptr);
1891 if (ACPI_FAILURE(status)) { 1900 if (ACPI_FAILURE(status))
1892 ret = -ENODEV; 1901 return;
1893 goto error;
1894 }
1895 1902
1896 if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) { 1903 if (!ecdt_ptr->control.address || !ecdt_ptr->data.address) {
1897 /* 1904 /*
1898 * Asus X50GL: 1905 * Asus X50GL:
1899 * https://bugzilla.kernel.org/show_bug.cgi?id=11880 1906 * https://bugzilla.kernel.org/show_bug.cgi?id=11880
1900 */ 1907 */
1901 ret = -ENODEV; 1908 return;
1902 goto error;
1903 } 1909 }
1904 1910
1911 ec = acpi_ec_alloc();
1912 if (!ec)
1913 return;
1914
1905 if (EC_FLAGS_CORRECT_ECDT) { 1915 if (EC_FLAGS_CORRECT_ECDT) {
1906 ec->command_addr = ecdt_ptr->data.address; 1916 ec->command_addr = ecdt_ptr->data.address;
1907 ec->data_addr = ecdt_ptr->control.address; 1917 ec->data_addr = ecdt_ptr->control.address;
@@ -1910,16 +1920,22 @@ int __init acpi_ec_ecdt_probe(void)
1910 ec->data_addr = ecdt_ptr->data.address; 1920 ec->data_addr = ecdt_ptr->data.address;
1911 } 1921 }
1912 ec->gpe = ecdt_ptr->gpe; 1922 ec->gpe = ecdt_ptr->gpe;
1923 ec->handle = ACPI_ROOT_OBJECT;
1913 1924
1914 /* 1925 /*
1915 * At this point, the namespace is not initialized, so do not find 1926 * At this point, the namespace is not initialized, so do not find
1916 * the namespace objects, or handle the events. 1927 * the namespace objects, or handle the events.
1917 */ 1928 */
1918 ret = acpi_config_boot_ec(ec, ACPI_ROOT_OBJECT, false, true); 1929 ret = acpi_ec_setup(ec, false);
1919error: 1930 if (ret) {
1920 if (ret)
1921 acpi_ec_free(ec); 1931 acpi_ec_free(ec);
1922 return ret; 1932 return;
1933 }
1934
1935 boot_ec = ec;
1936 boot_ec_is_ecdt = true;
1937
1938 pr_info("Boot ECDT EC used to handle transactions\n");
1923} 1939}
1924 1940
1925#ifdef CONFIG_PM_SLEEP 1941#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index dd70d6c2bca0..23faa66ea772 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -108,52 +108,32 @@ static const struct file_operations acpi_ec_io_ops = {
108 .llseek = default_llseek, 108 .llseek = default_llseek,
109}; 109};
110 110
111static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) 111static void acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
112{ 112{
113 struct dentry *dev_dir; 113 struct dentry *dev_dir;
114 char name[64]; 114 char name[64];
115 umode_t mode = 0400; 115 umode_t mode = 0400;
116 116
117 if (ec_device_count == 0) { 117 if (ec_device_count == 0)
118 acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL); 118 acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL);
119 if (!acpi_ec_debugfs_dir)
120 return -ENOMEM;
121 }
122 119
123 sprintf(name, "ec%u", ec_device_count); 120 sprintf(name, "ec%u", ec_device_count);
124 dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir); 121 dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir);
125 if (!dev_dir) {
126 if (ec_device_count != 0)
127 goto error;
128 return -ENOMEM;
129 }
130 122
131 if (!debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe)) 123 debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe);
132 goto error; 124 debugfs_create_bool("use_global_lock", 0444, dev_dir,
133 if (!debugfs_create_bool("use_global_lock", 0444, dev_dir, 125 &first_ec->global_lock);
134 &first_ec->global_lock))
135 goto error;
136 126
137 if (write_support) 127 if (write_support)
138 mode = 0600; 128 mode = 0600;
139 if (!debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops)) 129 debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops);
140 goto error;
141
142 return 0;
143
144error:
145 debugfs_remove_recursive(acpi_ec_debugfs_dir);
146 return -ENOMEM;
147} 130}
148 131
149static int __init acpi_ec_sys_init(void) 132static int __init acpi_ec_sys_init(void)
150{ 133{
151 int err = 0;
152 if (first_ec) 134 if (first_ec)
153 err = acpi_ec_add_debugfs(first_ec, 0); 135 acpi_ec_add_debugfs(first_ec, 0);
154 else 136 return 0;
155 err = -ENODEV;
156 return err;
157} 137}
158 138
159static void __exit acpi_ec_sys_exit(void) 139static void __exit acpi_ec_sys_exit(void)
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 6a9e1fb8913a..6eaf06db7752 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -192,8 +192,8 @@ extern struct acpi_ec *first_ec;
192typedef int (*acpi_ec_query_func) (void *data); 192typedef int (*acpi_ec_query_func) (void *data);
193 193
194int acpi_ec_init(void); 194int acpi_ec_init(void);
195int acpi_ec_ecdt_probe(void); 195void acpi_ec_ecdt_probe(void);
196int acpi_ec_dsdt_probe(void); 196void acpi_ec_dsdt_probe(void);
197void acpi_ec_block_transactions(void); 197void acpi_ec_block_transactions(void);
198void acpi_ec_unblock_transactions(void); 198void acpi_ec_unblock_transactions(void);
199void acpi_ec_mark_gpe_for_wake(void); 199void acpi_ec_mark_gpe_for_wake(void);
diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index da031b1df6f5..ad31c50de3be 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -451,6 +451,11 @@ static struct acpi_pptt_processor *acpi_find_processor_package_id(struct acpi_ta
451 return cpu; 451 return cpu;
452} 452}
453 453
454static void acpi_pptt_warn_missing(void)
455{
456 pr_warn_once("No PPTT table found, cpu and cache topology may be inaccurate\n");
457}
458
454/** 459/**
455 * topology_get_acpi_cpu_tag() - Find a unique topology value for a feature 460 * topology_get_acpi_cpu_tag() - Find a unique topology value for a feature
456 * @table: Pointer to the head of the PPTT table 461 * @table: Pointer to the head of the PPTT table
@@ -498,7 +503,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
498 503
499 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 504 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
500 if (ACPI_FAILURE(status)) { 505 if (ACPI_FAILURE(status)) {
501 pr_warn_once("No PPTT table found, cpu topology may be inaccurate\n"); 506 acpi_pptt_warn_missing();
502 return -ENOENT; 507 return -ENOENT;
503 } 508 }
504 retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); 509 retval = topology_get_acpi_cpu_tag(table, cpu, level, flag);
@@ -531,7 +536,7 @@ int acpi_find_last_cache_level(unsigned int cpu)
531 acpi_cpu_id = get_acpi_id_for_cpu(cpu); 536 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
532 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 537 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
533 if (ACPI_FAILURE(status)) { 538 if (ACPI_FAILURE(status)) {
534 pr_warn_once("No PPTT table found, cache topology may be inaccurate\n"); 539 acpi_pptt_warn_missing();
535 } else { 540 } else {
536 number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id); 541 number_of_levels = acpi_find_cache_levels(table, acpi_cpu_id);
537 acpi_put_table(table); 542 acpi_put_table(table);
@@ -563,7 +568,7 @@ int cache_setup_acpi(unsigned int cpu)
563 568
564 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 569 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
565 if (ACPI_FAILURE(status)) { 570 if (ACPI_FAILURE(status)) {
566 pr_warn_once("No PPTT table found, cache topology may be inaccurate\n"); 571 acpi_pptt_warn_missing();
567 return -ENOENT; 572 return -ENOENT;
568 } 573 }
569 574
@@ -617,7 +622,7 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
617 622
618 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); 623 status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
619 if (ACPI_FAILURE(status)) { 624 if (ACPI_FAILURE(status)) {
620 pr_warn_once("No PPTT table found, topology may be inaccurate\n"); 625 acpi_pptt_warn_missing();
621 return -ENOENT; 626 return -ENOENT;
622 } 627 }
623 628
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 48eabb6c2d4f..8fccbe49612a 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -473,14 +473,22 @@ static DECLARE_BITMAP(acpi_initrd_installed, NR_ACPI_INITRD_TABLES);
473 473
474void __init acpi_table_upgrade(void) 474void __init acpi_table_upgrade(void)
475{ 475{
476 void *data = (void *)initrd_start; 476 void *data;
477 size_t size = initrd_end - initrd_start; 477 size_t size;
478 int sig, no, table_nr = 0, total_offset = 0; 478 int sig, no, table_nr = 0, total_offset = 0;
479 long offset = 0; 479 long offset = 0;
480 struct acpi_table_header *table; 480 struct acpi_table_header *table;
481 char cpio_path[32] = "kernel/firmware/acpi/"; 481 char cpio_path[32] = "kernel/firmware/acpi/";
482 struct cpio_data file; 482 struct cpio_data file;
483 483
484 if (IS_ENABLED(CONFIG_ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD)) {
485 data = __initramfs_start;
486 size = __initramfs_size;
487 } else {
488 data = (void *)initrd_start;
489 size = initrd_end - initrd_start;
490 }
491
484 if (data == NULL || size == 0) 492 if (data == NULL || size == 0)
485 return; 493 return;
486 494