From e38ba404f20c4beb1a5d4547567d2934a5b95843 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 6 Jul 2021 18:09:22 +0200 Subject: ACPI / PMIC: XPower: optimize I2C-bus accesses The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus and while the kernel holds the semaphore the CPU and GPU power-states must not be changed otherwise the system will freeze. This is a complex process, which is quite expensive. This is all done by iosf_mbi_block_punit_i2c_access(). To ensure that no unguarded I2C-bus accesses happen, iosf_mbi_block_punit_i2c_access() gets called by the I2C-bus-driver for every I2C transfer. Because this is so expensive it is allowed to call iosf_mbi_block_punit_i2c_access() in a nested fashion, so that higher-level code which does multiple I2C-transfers can call it once for a group of transfers, turning the calls done by the I2C-bus-driver into no-ops. Add iosf_mbi_block_punit_i2c_access() calls around groups of register accesses, so that the P-Unit semaphore only needs to be taken once for each group of register accesses. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki --- drivers/acpi/pmic/intel_pmic_xpower.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index a091d5a8392c..5750c5e7d4c6 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -178,15 +178,17 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg, { int data, ret; - /* GPIO1 LDO regulator needs special handling */ - if (reg == XPOWER_GPI1_CTRL) - return regmap_update_bits(regmap, reg, GPI1_LDO_MASK, - on ? GPI1_LDO_ON : GPI1_LDO_OFF); - ret = iosf_mbi_block_punit_i2c_access(); if (ret) return ret; + /* GPIO1 LDO regulator needs special handling */ + if (reg == XPOWER_GPI1_CTRL) { + ret = regmap_update_bits(regmap, reg, GPI1_LDO_MASK, + on ? GPI1_LDO_ON : GPI1_LDO_OFF); + goto out; + } + if (regmap_read(regmap, reg, &data)) { ret = -EIO; goto out; @@ -234,6 +236,11 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) return ret; if (adc_ts_pin_ctrl & AXP288_ADC_TS_CURRENT_ON_OFF_MASK) { + /* + * AXP288_ADC_TS_PIN_CTRL reads are cached by the regmap, so + * this does to a single I2C-transfer, and thus there is no + * need to explicitly call iosf_mbi_block_punit_i2c_access(). + */ ret = regmap_update_bits(regmap, AXP288_ADC_TS_PIN_CTRL, AXP288_ADC_TS_CURRENT_ON_OFF_MASK, AXP288_ADC_TS_CURRENT_ON_ONDEMAND); @@ -244,6 +251,10 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) usleep_range(6000, 10000); } + ret = iosf_mbi_block_punit_i2c_access(); + if (ret) + return ret; + ret = regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2); if (ret == 0) ret = (buf[0] << 4) + ((buf[1] >> 4) & 0x0f); @@ -254,6 +265,8 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) AXP288_ADC_TS_CURRENT_ON); } + iosf_mbi_unblock_punit_i2c_access(); + return ret; } -- cgit v1.2.3 From fd080a01ecfc92984cabca6e54c61fe0f70e3984 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 6 Jul 2021 18:09:23 +0200 Subject: ACPI / PMIC: XPower: optimize MIPI PMIQ sequence I2C-bus accesses The I2C-bus to the XPower AXP288 is shared between the Linux kernel and the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock" before it may use the bus and while the kernel holds the semaphore the CPU and GPU power-states must not be changed otherwise the system will freeze. This is a complex process, which is quite expensive. This is all done by iosf_mbi_block_punit_i2c_access(). To ensure that no unguarded I2C-bus accesses happen, iosf_mbi_block_punit_i2c_access() gets called by the I2C-bus-driver for every I2C transfer. Because this is so expensive it is allowed to call iosf_mbi_block_punit_i2c_access() in a nested fashion, so that higher-level code which does multiple I2C-transfers can call it once for a group of transfers, turning the calls done by the I2C-bus-driver into no-ops. The default exec_mipi_pmic_seq_element implementation from drivers/acpi/pmic/intel_pmic.c does a regmap_update_bits() call and the involved registers are typically marked as volatile in the regmap, so this leads to 2 I2C-bus accesses. Add a XPower AXP288 specific implementation of exec_mipi_pmic_seq_element which calls iosf_mbi_block_punit_i2c_access() calls before the regmap_update_bits() call to avoid having to do the whole expensive acquire P-Unit semaphore dance twice. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki --- drivers/acpi/pmic/intel_pmic_xpower.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c index 5750c5e7d4c6..cbe08e600fa3 100644 --- a/drivers/acpi/pmic/intel_pmic_xpower.c +++ b/drivers/acpi/pmic/intel_pmic_xpower.c @@ -270,10 +270,34 @@ static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) return ret; } +static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap, + u16 i2c_address, u32 reg_address, + u32 value, u32 mask) +{ + int ret; + + if (i2c_address != 0x34) { + pr_err("%s: Unexpected i2c-addr: 0x%02x (reg-addr 0x%x value 0x%x mask 0x%x)\n", + __func__, i2c_address, reg_address, value, mask); + return -ENXIO; + } + + ret = iosf_mbi_block_punit_i2c_access(); + if (ret) + return ret; + + ret = regmap_update_bits(regmap, reg_address, mask, value); + + iosf_mbi_unblock_punit_i2c_access(); + + return ret; +} + static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = { .get_power = intel_xpower_pmic_get_power, .update_power = intel_xpower_pmic_update_power, .get_raw_temp = intel_xpower_pmic_get_raw_temp, + .exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element, .power_table = power_table, .power_table_count = ARRAY_SIZE(power_table), .thermal_table = thermal_table, -- cgit v1.2.3 From b1121e2a182dc8f22e7cfa2d8374199505d27ab8 Mon Sep 17 00:00:00 2001 From: Huacai Chen Date: Mon, 5 Jul 2021 20:42:04 +0800 Subject: ACPI: Add LoongArch support for ACPI_PROCESSOR/ACPI_NUMA We are preparing to add new Loongson (based on LoongArch, not MIPS) support. LoongArch use ACPI other than DT as its boot protocol, so add its support for ACPI_PROCESSOR/ACPI_NUMA. Signed-off-by: Huacai Chen Signed-off-by: Rafael J. Wysocki --- drivers/acpi/Kconfig | 4 ++-- drivers/acpi/numa/Kconfig | 2 +- drivers/acpi/numa/srat.c | 2 +- include/linux/acpi.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 9d872ea477a6..9efd27e8af21 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -280,9 +280,9 @@ config ACPI_CPPC_LIB config ACPI_PROCESSOR tristate "Processor" - depends on X86 || IA64 || ARM64 + depends on X86 || IA64 || ARM64 || LOONGARCH select ACPI_PROCESSOR_IDLE - select ACPI_CPU_FREQ_PSS if X86 || IA64 + select ACPI_CPU_FREQ_PSS if X86 || IA64 || LOONGARCH default y help This driver adds support for the ACPI Processor package. It is required diff --git a/drivers/acpi/numa/Kconfig b/drivers/acpi/numa/Kconfig index fcf2e556d69d..39b1f34c21df 100644 --- a/drivers/acpi/numa/Kconfig +++ b/drivers/acpi/numa/Kconfig @@ -2,7 +2,7 @@ config ACPI_NUMA bool "NUMA support" depends on NUMA - depends on (X86 || IA64 || ARM64) + depends on (X86 || IA64 || ARM64 || LOONGARCH) default y if IA64 || ARM64 config ACPI_HMAT diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 6021a1013442..b8795fc49097 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -206,7 +206,7 @@ int __init srat_disabled(void) return acpi_numa < 0; } -#if defined(CONFIG_X86) || defined(CONFIG_ARM64) +#if defined(CONFIG_X86) || defined(CONFIG_ARM64) || defined(CONFIG_LOONGARCH) /* * Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for * I/O localities since SRAT does not list them. I/O localities are diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 72e4f7fd268c..3e4805619fe0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -249,7 +249,7 @@ void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); /* the following numa functions are architecture-dependent */ void acpi_numa_slit_init (struct acpi_table_slit *slit); -#if defined(CONFIG_X86) || defined(CONFIG_IA64) +#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_LOONGARCH) void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa); #else static inline void -- cgit v1.2.3 From 42878a9f0fe0b6bef7fb24d98e161c1216a36926 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:23:32 +0200 Subject: ACPI: glue: Rearrange acpi_device_notify() Make the code flow in acpi_device_notify() more straightforward and make it use dev_dbg() and acpi_handle_debug() for printing debug messages. The only expected functional impact of this change is the content of the debug messages printed by acpi_device_notify(). Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/glue.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index fce3f3bba714..31b6e470c616 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -292,22 +292,21 @@ static int acpi_device_notify(struct device *dev) int ret; ret = acpi_bind_one(dev, NULL); - if (ret && type) { - struct acpi_device *adev; + if (ret) { + if (!type) + goto err; adev = type->find_companion(dev); if (!adev) { - pr_debug("Unable to get handle for %s\n", dev_name(dev)); + dev_dbg(dev, "ACPI companion not found\n"); ret = -ENODEV; - goto out; + goto err; } ret = acpi_bind_one(dev, adev); if (ret) - goto out; + goto err; } adev = ACPI_COMPANION(dev); - if (!adev) - goto out; if (dev_is_platform(dev)) acpi_configure_pmsi_domain(dev); @@ -317,16 +316,13 @@ static int acpi_device_notify(struct device *dev) else if (adev->handler && adev->handler->bind) adev->handler->bind(dev); - out: - if (!ret) { - struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n", + dev_name(dev)); - acpi_get_name(ACPI_HANDLE(dev), ACPI_FULL_PATHNAME, &buffer); - pr_debug("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); - kfree(buffer.pointer); - } else { - pr_debug("Device %s -> No ACPI support\n", dev_name(dev)); - } + return 0; + +err: + dev_dbg(dev, "No ACPI support\n"); return ret; } -- cgit v1.2.3 From 7d625e5b143d07f26c437ede6b18730c2fc4d1b5 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:23:37 +0200 Subject: ACPI: glue: Change return type of two functions to void Since the return values of acpi_device_notify() and acpi_device_notify_remove() are discarded by their only caller, change their return type to void. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/glue.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 31b6e470c616..dbdd86c80793 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -285,7 +285,7 @@ int acpi_unbind_one(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_unbind_one); -static int acpi_device_notify(struct device *dev) +static void acpi_device_notify(struct device *dev) { struct acpi_bus_type *type = acpi_get_bus_type(dev); struct acpi_device *adev; @@ -299,7 +299,6 @@ static int acpi_device_notify(struct device *dev) adev = type->find_companion(dev); if (!adev) { dev_dbg(dev, "ACPI companion not found\n"); - ret = -ENODEV; goto err; } ret = acpi_bind_one(dev, adev); @@ -319,21 +318,19 @@ static int acpi_device_notify(struct device *dev) acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n", dev_name(dev)); - return 0; + return; err: dev_dbg(dev, "No ACPI support\n"); - - return ret; } -static int acpi_device_notify_remove(struct device *dev) +static void acpi_device_notify_remove(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); struct acpi_bus_type *type; if (!adev) - return 0; + return; type = acpi_get_bus_type(dev); if (type && type->cleanup) @@ -342,7 +339,6 @@ static int acpi_device_notify_remove(struct device *dev) adev->handler->unbind(dev); acpi_unbind_one(dev); - return 0; } int acpi_platform_notify(struct device *dev, enum kobject_action action) -- cgit v1.2.3 From 5e557cbac8058bfc79b8a27d319930c5e5d77974 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:24:50 +0200 Subject: ACPI: bus: Rename functions to avoid name collision There is a name collision between acpi_device_notify() defined in bus.c and another static function defined in glue.c. Since the latter is going to be exported from that file, rename the former to acpi_notify_device() and rename acpi_device_notify_fixed() to follow the same naming pattern. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index f854bcb8d010..3abb4373d11b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -498,24 +498,24 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) acpi_evaluate_ost(handle, type, ost_code, NULL); } -static void acpi_device_notify(acpi_handle handle, u32 event, void *data) +static void acpi_notify_device(acpi_handle handle, u32 event, void *data) { struct acpi_device *device = data; device->driver->ops.notify(device, event); } -static void acpi_device_notify_fixed(void *data) +static void acpi_notify_device_fixed(void *data) { struct acpi_device *device = data; /* Fixed hardware devices have no handles */ - acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); + acpi_notify_device(NULL, ACPI_FIXED_HARDWARE_EVENT, device); } static u32 acpi_device_fixed_event(void *data) { - acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data); + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_notify_device_fixed, data); return ACPI_INTERRUPT_HANDLED; } @@ -536,7 +536,7 @@ static int acpi_device_install_notify_handler(struct acpi_device *device) else status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, - acpi_device_notify, + acpi_notify_device, device); if (ACPI_FAILURE(status)) @@ -554,7 +554,7 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) acpi_device_fixed_event); else acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, - acpi_device_notify); + acpi_notify_device); } /* Handle events targeting \_SB device (at present only graceful shutdown) */ -- cgit v1.2.3 From d0b8e398319e5b09f3cb26ee8288ce356646fca6 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:25:55 +0200 Subject: ACPI: glue: Eliminate acpi_platform_notify() Get rid of acpi_platform_notify() which is redundant and make device_platform_notify() in the driver core call acpi_device_notify() and acpi_device_notify_remove() directly. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- drivers/acpi/glue.c | 19 ++----------------- drivers/base/core.c | 7 ++++--- include/linux/acpi.h | 10 ++++------ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index dbdd86c80793..7a33a6d985f8 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -285,7 +285,7 @@ int acpi_unbind_one(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_unbind_one); -static void acpi_device_notify(struct device *dev) +void acpi_device_notify(struct device *dev) { struct acpi_bus_type *type = acpi_get_bus_type(dev); struct acpi_device *adev; @@ -324,7 +324,7 @@ err: dev_dbg(dev, "No ACPI support\n"); } -static void acpi_device_notify_remove(struct device *dev) +void acpi_device_notify_remove(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); struct acpi_bus_type *type; @@ -340,18 +340,3 @@ static void acpi_device_notify_remove(struct device *dev) acpi_unbind_one(dev); } - -int acpi_platform_notify(struct device *dev, enum kobject_action action) -{ - switch (action) { - case KOBJ_ADD: - acpi_device_notify(dev); - break; - case KOBJ_REMOVE: - acpi_device_notify_remove(dev); - break; - default: - break; - } - return 0; -} diff --git a/drivers/base/core.c b/drivers/base/core.c index cadcade65825..1521915c0330 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2005,9 +2005,10 @@ device_platform_notify(struct device *dev, enum kobject_action action) { int ret; - ret = acpi_platform_notify(dev, action); - if (ret) - return ret; + if (action == KOBJ_ADD) + acpi_device_notify(dev); + else if (action == KOBJ_REMOVE) + acpi_device_notify_remove(dev); ret = software_node_notify(dev, action); if (ret) diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 72e4f7fd268c..fdbf6d7d928a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1380,13 +1380,11 @@ static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level) #endif #ifdef CONFIG_ACPI -extern int acpi_platform_notify(struct device *dev, enum kobject_action action); +extern void acpi_device_notify(struct device *dev); +extern void acpi_device_notify_remove(struct device *dev); #else -static inline int -acpi_platform_notify(struct device *dev, enum kobject_action action) -{ - return 0; -} +static inline void acpi_device_notify(struct device *dev) { } +static inline void acpi_device_notify_remove(struct device *dev) { } #endif #endif /*_LINUX_ACPI_H*/ -- cgit v1.2.3 From 384f5a857baeba88cf013b36999a97b471e4bd9c Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:27:12 +0200 Subject: software nodes: Split software_node_notify() Split software_node_notify_remove) out of software_node_notify() and make device_platform_notify() call the latter on device addition and the former on device removal. While at it, put the headers of the above functions into base.h, because they don't need to be present in a global header file. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Greg Kroah-Hartman Reviewed-by: Heikki Krogerus Reviewed-by: Andy Shevchenko --- drivers/base/base.h | 3 +++ drivers/base/core.c | 9 ++++--- drivers/base/swnode.c | 61 +++++++++++++++++++++++++----------------------- include/linux/property.h | 2 -- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 404db83ee5ec..2882af26392a 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -202,3 +202,6 @@ int devtmpfs_delete_node(struct device *dev); static inline int devtmpfs_create_node(struct device *dev) { return 0; } static inline int devtmpfs_delete_node(struct device *dev) { return 0; } #endif + +void software_node_notify(struct device *dev); +void software_node_notify_remove(struct device *dev); diff --git a/drivers/base/core.c b/drivers/base/core.c index 1521915c0330..6cf9c500fe93 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2003,16 +2003,15 @@ static inline int device_is_not_partition(struct device *dev) static int device_platform_notify(struct device *dev, enum kobject_action action) { - int ret; - if (action == KOBJ_ADD) acpi_device_notify(dev); else if (action == KOBJ_REMOVE) acpi_device_notify_remove(dev); - ret = software_node_notify(dev, action); - if (ret) - return ret; + if (action == KOBJ_ADD) + software_node_notify(dev); + else if (action == KOBJ_REMOVE) + software_node_notify_remove(dev); if (platform_notify && action == KOBJ_ADD) platform_notify(dev); diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index d1f1a8240120..7bd0f3cfb7eb 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -11,6 +11,8 @@ #include #include +#include "base.h" + struct swnode { struct kobject kobj; struct fwnode_handle fwnode; @@ -1053,7 +1055,7 @@ int device_add_software_node(struct device *dev, const struct software_node *nod * balance. */ if (device_is_registered(dev)) - software_node_notify(dev, KOBJ_ADD); + software_node_notify(dev); return 0; } @@ -1074,7 +1076,8 @@ void device_remove_software_node(struct device *dev) return; if (device_is_registered(dev)) - software_node_notify(dev, KOBJ_REMOVE); + software_node_notify_remove(dev); + set_secondary_fwnode(dev, NULL); kobject_put(&swnode->kobj); } @@ -1117,44 +1120,44 @@ int device_create_managed_software_node(struct device *dev, } EXPORT_SYMBOL_GPL(device_create_managed_software_node); -int software_node_notify(struct device *dev, unsigned long action) +void software_node_notify(struct device *dev) { struct swnode *swnode; int ret; swnode = dev_to_swnode(dev); if (!swnode) - return 0; + return; - switch (action) { - case KOBJ_ADD: - ret = sysfs_create_link(&dev->kobj, &swnode->kobj, "software_node"); - if (ret) - break; + ret = sysfs_create_link(&dev->kobj, &swnode->kobj, "software_node"); + if (ret) + return; - ret = sysfs_create_link(&swnode->kobj, &dev->kobj, - dev_name(dev)); - if (ret) { - sysfs_remove_link(&dev->kobj, "software_node"); - break; - } - kobject_get(&swnode->kobj); - break; - case KOBJ_REMOVE: - sysfs_remove_link(&swnode->kobj, dev_name(dev)); + ret = sysfs_create_link(&swnode->kobj, &dev->kobj, dev_name(dev)); + if (ret) { sysfs_remove_link(&dev->kobj, "software_node"); - kobject_put(&swnode->kobj); - - if (swnode->managed) { - set_secondary_fwnode(dev, NULL); - kobject_put(&swnode->kobj); - } - break; - default: - break; + return; } - return 0; + kobject_get(&swnode->kobj); +} + +void software_node_notify_remove(struct device *dev) +{ + struct swnode *swnode; + + swnode = dev_to_swnode(dev); + if (!swnode) + return; + + sysfs_remove_link(&swnode->kobj, dev_name(dev)); + sysfs_remove_link(&dev->kobj, "software_node"); + kobject_put(&swnode->kobj); + + if (swnode->managed) { + set_secondary_fwnode(dev, NULL); + kobject_put(&swnode->kobj); + } } static int __init software_node_init(void) diff --git a/include/linux/property.h b/include/linux/property.h index 073e680c35e2..357513a977e5 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -484,8 +484,6 @@ void software_node_unregister_node_group(const struct software_node **node_group int software_node_register(const struct software_node *node); void software_node_unregister(const struct software_node *node); -int software_node_notify(struct device *dev, unsigned long action); - struct fwnode_handle * fwnode_create_software_node(const struct property_entry *properties, const struct fwnode_handle *parent); -- cgit v1.2.3 From b2ebd9dd52670a931e8f1bd77d70c57f9aa186a5 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 12 Jul 2021 19:28:16 +0200 Subject: driver core: Split device_platform_notify() Split device_platform_notify_remove) out of device_platform_notify() and call the latter on device addition and the former on device removal. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Greg Kroah-Hartman Reviewed-by: Andy Shevchenko --- drivers/base/core.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 6cf9c500fe93..70ef0ed710b8 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2000,24 +2000,24 @@ static inline int device_is_not_partition(struct device *dev) } #endif -static int -device_platform_notify(struct device *dev, enum kobject_action action) +static void device_platform_notify(struct device *dev) { - if (action == KOBJ_ADD) - acpi_device_notify(dev); - else if (action == KOBJ_REMOVE) - acpi_device_notify_remove(dev); + acpi_device_notify(dev); - if (action == KOBJ_ADD) - software_node_notify(dev); - else if (action == KOBJ_REMOVE) - software_node_notify_remove(dev); + software_node_notify(dev); - if (platform_notify && action == KOBJ_ADD) + if (platform_notify) platform_notify(dev); - else if (platform_notify_remove && action == KOBJ_REMOVE) +} + +static void device_platform_notify_remove(struct device *dev) +{ + acpi_device_notify_remove(dev); + + software_node_notify_remove(dev); + + if (platform_notify_remove) platform_notify_remove(dev); - return 0; } /** @@ -3289,9 +3289,7 @@ int device_add(struct device *dev) } /* notify platform of device entry */ - error = device_platform_notify(dev, KOBJ_ADD); - if (error) - goto platform_error; + device_platform_notify(dev); error = device_create_file(dev, &dev_attr_uevent); if (error) @@ -3394,8 +3392,7 @@ done: SymlinkError: device_remove_file(dev, &dev_attr_uevent); attrError: - device_platform_notify(dev, KOBJ_REMOVE); -platform_error: + device_platform_notify_remove(dev); kobject_uevent(&dev->kobj, KOBJ_REMOVE); glue_dir = get_glue_dir(dev); kobject_del(&dev->kobj); @@ -3540,7 +3537,7 @@ void device_del(struct device *dev) bus_remove_device(dev); device_pm_remove(dev); driver_deferred_probe_del(dev); - device_platform_notify(dev, KOBJ_REMOVE); + device_platform_notify_remove(dev); device_remove_properties(dev); device_links_purge(dev); -- cgit v1.2.3 From ae57338716ce2e230514be54a06c9bfaa84433a7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 15 Jul 2021 17:16:50 +0300 Subject: ACPI: configfs: Use sysfs_emit() in "show" functions The sysfs_emit() function was introduced to make it less ambiguous which function is preferred when writing to the output buffer in a "show" callback [1]. Convert the GPIO library sysfs interface from sprintf() to sysfs_emit() accordingly, as the latter is aware of the PAGE_SIZE buffer and correctly returns the number of bytes written into the buffer. No functional change intended. [1] Documentation/filesystems/sysfs.rst Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_configfs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c index 76b83b181356..6e6ef8a1f447 100644 --- a/drivers/acpi/acpi_configfs.c +++ b/drivers/acpi/acpi_configfs.c @@ -103,7 +103,7 @@ static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature); + return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature); } static ssize_t acpi_table_length_show(struct config_item *cfg, char *str) @@ -113,7 +113,7 @@ static ssize_t acpi_table_length_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%d\n", h->length); + return sysfs_emit(str, "%d\n", h->length); } static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str) @@ -123,7 +123,7 @@ static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%d\n", h->revision); + return sysfs_emit(str, "%d\n", h->revision); } static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str) @@ -133,7 +133,7 @@ static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id); + return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id); } static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str) @@ -143,7 +143,7 @@ static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id); + return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id); } static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str) @@ -153,7 +153,7 @@ static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str) if (!h) return -EINVAL; - return sprintf(str, "%d\n", h->oem_revision); + return sysfs_emit(str, "%d\n", h->oem_revision); } static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, @@ -164,7 +164,7 @@ static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, if (!h) return -EINVAL; - return sprintf(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id); + return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id); } static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg, @@ -175,7 +175,7 @@ static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg, if (!h) return -EINVAL; - return sprintf(str, "%d\n", h->asl_compiler_revision); + return sysfs_emit(str, "%d\n", h->asl_compiler_revision); } CONFIGFS_ATTR_RO(acpi_table_, signature); -- cgit v1.2.3 From 45c16fe1d1283bdd3e32bd869bf5aa177fcd50f7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 15 Jul 2021 17:16:51 +0300 Subject: ACPI: configfs: Make get_header() to return error pointer Instead of duplicating error codes here and there, make get_header() to return error pointer. Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_configfs.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c index 6e6ef8a1f447..c970792b11a4 100644 --- a/drivers/acpi/acpi_configfs.c +++ b/drivers/acpi/acpi_configfs.c @@ -70,7 +70,7 @@ static inline struct acpi_table_header *get_header(struct config_item *cfg) if (!table->header) pr_err("table not loaded\n"); - return table->header; + return table->header ?: ERR_PTR(-EINVAL); } static ssize_t acpi_table_aml_read(struct config_item *cfg, @@ -78,8 +78,8 @@ static ssize_t acpi_table_aml_read(struct config_item *cfg, { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); if (data) memcpy(data, h, h->length); @@ -100,8 +100,8 @@ static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature); } @@ -110,8 +110,8 @@ static ssize_t acpi_table_length_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%d\n", h->length); } @@ -120,8 +120,8 @@ static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%d\n", h->revision); } @@ -130,8 +130,8 @@ static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id); } @@ -140,8 +140,8 @@ static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id); } @@ -150,8 +150,8 @@ static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str) { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%d\n", h->oem_revision); } @@ -161,8 +161,8 @@ static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg, { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id); } @@ -172,8 +172,8 @@ static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg, { struct acpi_table_header *h = get_header(cfg); - if (!h) - return -EINVAL; + if (IS_ERR(h)) + return PTR_ERR(h); return sysfs_emit(str, "%d\n", h->asl_compiler_revision); } -- cgit v1.2.3 From 7a6226db072beeb63d4c3aaa844b0676ef7a027f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 27 Jul 2021 09:22:40 -0700 Subject: ACPI: DPTF: Add new PCH FIVR methods Some additional information is required for updating PCH FIVR values upon WiFi channel changes. New attributes added to the existing sysfs: fivr_switching_freq_mhz : Get the FIVR switching control frequency. Uses ACPI method GFCS. fivr_switching_fault_status: Read the FIVR switching frequency control fault status. Uses ACPI method GFFS. ssc_clock_info : Presents SSC (spread spectrum clock) information for EMI (Electro magnetic interference) control. Use ACPI method GEMI (refer to the description of GEMI method below). GFFS This ACPI method is used to read the FIVR switching frequency control fault status. Bits Description [0:0] Fault status when set to 1 [31:1] Reserved GFCS This ACPI method is used to read the FIVR switching control frequency. Bits Description [11:0] Actual Frequency = value * XTAL_FREQ / 128 [31:12] Reserved GEMI This ACPI method is used to read the programmed register value for EMI (Electro magnetic interference) control. Bits Description [7:0] Sets clock spectrum spread percentage: 0x00=0.2% , 0x3F=10% 1 LSB = 0.1% increase in spread (for settings 0x01 thru 0x1C) 1 LSB = 0.2% increase in spread (for settings 0x1E thru 0x3F) [8] When set to 1, enables spread spectrum clock [9] 0: Triangle mode. FFC frequency walks around the Fcenter in a linear fashion 1: Random walk mode. FFC frequency changes randomly within the SSC (Spread spectrum clock) range [10] 0: No white noise. 1: Add white noise to spread waveform [11] When 1, future writes are ignored. Signed-off-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki --- Documentation/ABI/testing/sysfs-platform-dptf | 40 +++++++++++++++++++++++++++ drivers/acpi/dptf/dptf_pch_fivr.c | 9 ++++++ 2 files changed, 49 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-dptf b/Documentation/ABI/testing/sysfs-platform-dptf index 141834342a4d..53c6b1000320 100644 --- a/Documentation/ABI/testing/sysfs-platform-dptf +++ b/Documentation/ABI/testing/sysfs-platform-dptf @@ -111,3 +111,43 @@ Contact: linux-acpi@vger.kernel.org Description: (RW) The PCH FIVR (Fully Integrated Voltage Regulator) switching frequency in MHz, when FIVR clock is 38.4MHz. + +What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/fivr_switching_freq_mhz +Date: September, 2021 +KernelVersion: v5.15 +Contact: linux-acpi@vger.kernel.org +Description: + (RO) Get the FIVR switching control frequency in MHz. + +What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/fivr_switching_fault_status +Date: September, 2021 +KernelVersion: v5.15 +Contact: linux-acpi@vger.kernel.org +Description: + (RO) Read the FIVR switching frequency control fault status. + +What: /sys/bus/platform/devices/INTC1045:00/pch_fivr_switch_frequency/ssc_clock_info +Date: September, 2021 +KernelVersion: v5.15 +Contact: linux-acpi@vger.kernel.org +Description: + (RO) Presents SSC (spread spectrum clock) information for EMI + (Electro magnetic interference) control. This is a bit mask. + Bits Description + [7:0] Sets clock spectrum spread percentage: + 0x00=0.2% , 0x3F=10% + 1 LSB = 0.1% increase in spread (for + settings 0x01 thru 0x1C) + 1 LSB = 0.2% increase in spread (for + settings 0x1E thru 0x3F) + [8] When set to 1, enables spread + spectrum clock + [9] 0: Triangle mode. FFC frequency + walks around the Fcenter in a linear + fashion + 1: Random walk mode. FFC frequency + changes randomly within the SSC + (Spread spectrum clock) range + [10] 0: No white noise. 1: Add white noise + to spread waveform + [11] When 1, future writes are ignored. diff --git a/drivers/acpi/dptf/dptf_pch_fivr.c b/drivers/acpi/dptf/dptf_pch_fivr.c index 550b9081fcbc..f4e9c2ef2f88 100644 --- a/drivers/acpi/dptf/dptf_pch_fivr.c +++ b/drivers/acpi/dptf/dptf_pch_fivr.c @@ -90,15 +90,24 @@ static ssize_t name##_store(struct device *dev,\ PCH_FIVR_SHOW(freq_mhz_low_clock, GFC0) PCH_FIVR_SHOW(freq_mhz_high_clock, GFC1) +PCH_FIVR_SHOW(ssc_clock_info, GEMI) +PCH_FIVR_SHOW(fivr_switching_freq_mhz, GFCS) +PCH_FIVR_SHOW(fivr_switching_fault_status, GFFS) PCH_FIVR_STORE(freq_mhz_low_clock, RFC0) PCH_FIVR_STORE(freq_mhz_high_clock, RFC1) static DEVICE_ATTR_RW(freq_mhz_low_clock); static DEVICE_ATTR_RW(freq_mhz_high_clock); +static DEVICE_ATTR_RO(ssc_clock_info); +static DEVICE_ATTR_RO(fivr_switching_freq_mhz); +static DEVICE_ATTR_RO(fivr_switching_fault_status); static struct attribute *fivr_attrs[] = { &dev_attr_freq_mhz_low_clock.attr, &dev_attr_freq_mhz_high_clock.attr, + &dev_attr_ssc_clock_info.attr, + &dev_attr_fivr_switching_freq_mhz.attr, + &dev_attr_fivr_switching_fault_status.attr, NULL }; -- cgit v1.2.3 From 95ac706744de78a93a7ec98d603c35fb21de8400 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 3 Aug 2021 16:16:12 +0200 Subject: ACPI: processor: Replace deprecated CPU-hotplug functions The functions cpu_hotplug_begin, cpu_hotplug_done, get_online_cpus() and put_online_cpus() have been deprecated during the CPU hotplug rework. They map directly to cpus_write_lock(), cpus_write_unlock, cpus_read_lock() and cpus_read_unlock(). Replace deprecated CPU-hotplug functions with the official version. The behavior remains unchanged. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_pad.c | 4 ++-- drivers/acpi/acpi_processor.c | 8 ++++---- drivers/acpi/processor_idle.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index df4adeb335b2..f45979aa2d64 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -249,12 +249,12 @@ static void set_power_saving_task_num(unsigned int num) static void acpi_pad_idle_cpus(unsigned int num_cpus) { - get_online_cpus(); + cpus_read_lock(); num_cpus = min_t(unsigned int, num_cpus, num_online_cpus()); set_power_saving_task_num(num_cpus); - put_online_cpus(); + cpus_read_unlock(); } static uint32_t acpi_pad_idle_cpus_num(void) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 2d5bd2a6ddce..6737b1cbf6d6 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -182,7 +182,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) return -ENODEV; cpu_maps_update_begin(); - cpu_hotplug_begin(); + cpus_write_lock(); ret = acpi_map_cpu(pr->handle, pr->phys_id, pr->acpi_id, &pr->id); if (ret) @@ -203,7 +203,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) pr->flags.need_hotplug_init = 1; out: - cpu_hotplug_done(); + cpus_write_unlock(); cpu_maps_update_done(); return ret; } @@ -454,13 +454,13 @@ static void acpi_processor_remove(struct acpi_device *device) per_cpu(processors, pr->id) = NULL; cpu_maps_update_begin(); - cpu_hotplug_begin(); + cpus_write_lock(); /* Remove the CPU. */ arch_unregister_cpu(pr->id); acpi_unmap_cpu(pr->id); - cpu_hotplug_done(); + cpus_write_unlock(); cpu_maps_update_done(); try_offline_node(cpu_to_node(pr->id)); diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 095c8aca141e..f37fba9e5ba0 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1301,7 +1301,7 @@ int acpi_processor_power_state_has_changed(struct acpi_processor *pr) if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) { /* Protect against cpu-hotplug */ - get_online_cpus(); + cpus_read_lock(); cpuidle_pause_and_lock(); /* Disable all cpuidle devices */ @@ -1330,7 +1330,7 @@ int acpi_processor_power_state_has_changed(struct acpi_processor *pr) } } cpuidle_resume_and_unlock(); - put_online_cpus(); + cpus_read_unlock(); } return 0; -- cgit v1.2.3 From e692fa1353609a3cd22f4b415c9d1f014e769ecd Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:07:53 +0200 Subject: ACPICA: iASL: Add support for the AEST table (data compiler) Includes support in the table compiler and the disassembler. ACPICA commit e75074d84d1207339a048486c2d06ecb935d0092 Link: https://github.com/acpica/acpica/commit/e75074d8 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/actbl1.h | 1 + include/acpi/actbl2.h | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index ef2872dea01c..a7ea179b2089 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -24,6 +24,7 @@ * file. Useful because they make it more difficult to inadvertently type in * the wrong signature. */ +#define ACPI_SIG_AEST "AEST" /* Arm Error Source Table */ #define ACPI_SIG_ASF "ASF!" /* Alert Standard Format table */ #define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ #define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 2069ac38a4e2..a47b32a5cbde 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -67,6 +67,176 @@ * See http://stackoverflow.com/a/1053662/41661 */ +/******************************************************************************* + * + * AEST - Arm Error Source Table + * + * Conforms to: ACPI for the Armv8 RAS Extensions 1.1 Platform Design Document + * September 2020. + * + ******************************************************************************/ + +struct acpi_table_aest { + struct acpi_table_header header; + void *node_array[]; +}; + +/* Common Subtable header - one per Node Structure (Subtable) */ + +struct acpi_aest_hdr { + u8 type; + u16 length; + u8 reserved; + u32 node_specific_offset; + u32 node_interface_offset; + u32 node_interrupt_offset; + u32 node_interrupt_count; + u64 timestamp_rate; + u64 reserved1; + u64 error_injection_rate; +}; + +/* Values for Type above */ + +#define ACPI_AEST_PROCESSOR_ERROR_NODE 0 +#define ACPI_AEST_MEMORY_ERROR_NODE 1 +#define ACPI_AEST_SMMU_ERROR_NODE 2 +#define ACPI_AEST_VENDOR_ERROR_NODE 3 +#define ACPI_AEST_GIC_ERROR_NODE 4 +#define ACPI_AEST_NODE_TYPE_RESERVED 5 /* 5 and above are reserved */ + +/* + * AEST subtables (Error nodes) + */ + +/* 0: Processor Error */ + +typedef struct acpi_aest_processor { + u32 processor_id; + u8 resource_type; + u8 reserved; + u8 flags; + u8 revision; + u64 processor_affinity; + +} acpi_aest_processor; + +/* Values for resource_type above, related structs below */ + +#define ACPI_AEST_CACHE_RESOURCE 0 +#define ACPI_AEST_TLB_RESOURCE 1 +#define ACPI_AEST_GENERIC_RESOURCE 2 +#define ACPI_AEST_RESOURCE_RESERVED 3 /* 3 and above are reserved */ + +/* 0R: Processor Cache Resource Substructure */ + +typedef struct acpi_aest_processor_cache { + u32 cache_reference; + u32 reserved; + +} acpi_aest_processor_cache; + +/* Values for cache_type above */ + +#define ACPI_AEST_CACHE_DATA 0 +#define ACPI_AEST_CACHE_INSTRUCTION 1 +#define ACPI_AEST_CACHE_UNIFIED 2 +#define ACPI_AEST_CACHE_RESERVED 3 /* 3 and above are reserved */ + +/* 1R: Processor TLB Resource Substructure */ + +typedef struct acpi_aest_processor_tlb { + u32 tlb_level; + u32 reserved; + +} acpi_aest_processor_tlb; + +/* 2R: Processor Generic Resource Substructure */ + +typedef struct acpi_aest_processor_generic { + u8 *resource; + +} acpi_aest_processor_generic; + +/* 1: Memory Error */ + +typedef struct acpi_aest_memory { + u32 srat_proximity_domain; + +} acpi_aest_memory; + +/* 2: Smmu Error */ + +typedef struct acpi_aest_smmu { + u32 iort_node_reference; + u32 subcomponent_reference; + +} acpi_aest_smmu; + +/* 3: Vendor Defined */ + +typedef struct acpi_aest_vendor { + u32 acpi_hid; + u32 acpi_uid; + u8 vendor_specific_data[16]; + +} acpi_aest_vendor; + +/* 4: Gic Error */ + +typedef struct acpi_aest_gic { + u32 interface_type; + u32 instance_id; + +} acpi_aest_gic; + +/* Values for interface_type above */ + +#define ACPI_AEST_GIC_CPU 0 +#define ACPI_AEST_GIC_DISTRIBUTOR 1 +#define ACPI_AEST_GIC_REDISTRIBUTOR 2 +#define ACPI_AEST_GIC_ITS 3 +#define ACPI_AEST_GIC_RESERVED 4 /* 4 and above are reserved */ + +/* Node Interface Structure */ + +typedef struct acpi_aest_node_interface { + u8 type; + u8 reserved[3]; + u32 flags; + u64 address; + u32 error_record_index; + u32 error_record_count; + u64 error_record_implemented; + u64 error_status_reporting; + u64 addressing_mode; + +} acpi_aest_node_interface; + +/* Values for Type field above */ + +#define ACPI_AEST_NODE_SYSTEM_REGISTER 0 +#define ACPI_AEST_NODE_MEMORY_MAPPED 1 +#define ACPI_AEST_XFACE_RESERVED 2 /* 2 and above are reserved */ + +/* Node Interrupt Structure */ + +typedef struct acpi_aest_node_interrupt { + u8 type; + u8 reserved[2]; + u8 flags; + u32 gsiv; + u8 iort_id; + u8 reserved1[3]; + +} acpi_aest_node_interrupt; + +/* Values for Type field above */ + +#define ACPI_AEST_NODE_FAULT_HANDLING 0 +#define ACPI_AEST_NODE_ERROR_RECOVERY 1 +#define ACPI_AEST_XRUPT_RESERVED 2 /* 2 and above are reserved */ + /******************************************************************************* * * BDAT - BIOS Data ACPI Table -- cgit v1.2.3 From 5ecce804da24c0587a52597e608f81ad982862d6 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:08:45 +0200 Subject: ACPICA: Fix an if statement (add parens) ACPICA commit 4dbe4b9a0c203b04918705f022e0db997aa55696 Link: https://github.com/acpica/acpica/commit/4dbe4b9a Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/dswexec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c index 41ba7773fd10..f2d2267054af 100644 --- a/drivers/acpi/acpica/dswexec.c +++ b/drivers/acpi/acpica/dswexec.c @@ -561,11 +561,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) op->common. node->object, NULL); - if ACPI_FAILURE - (status) { + if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "While writing to buffer field")); - } + } } ACPI_FREE(namepath); status = AE_OK; -- cgit v1.2.3 From 78df71b3a640e7b0197ed9cc19a39b8f236d805e Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:09:18 +0200 Subject: ACPICA: Macros should not use a trailing semicolon ACPICA commit 8d49c0b2b78b8a8c5dae4d5ff28432729f4d59f2 Link: https://github.com/acpica/acpica/commit/8d49c0b2 Signed-off-by: Huilong Deng Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/acoutput.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 1b4c45815695..5a3875744678 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h @@ -415,7 +415,7 @@ /* Conditional execution */ #define ACPI_DEBUG_EXEC(a) a -#define ACPI_DEBUG_ONLY_MEMBERS(a) a; +#define ACPI_DEBUG_ONLY_MEMBERS(a) a #define _VERBOSE_STRUCTURES /* Various object display routines for debug */ -- cgit v1.2.3 From 200950b615d5d788dfd8b12d73568e420735bfb0 Mon Sep 17 00:00:00 2001 From: Marcin Wojtas Date: Tue, 3 Aug 2021 20:10:02 +0200 Subject: ACPICA: Headers: Add new DBG2 Serial Port Subtypes The Microsoft Debug Port Table 2 (DBG2) specification revision September 21, 2020 comprises additional Serial Port Subtypes [1]. Reflect that in the actbl1.h header file. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table ACPICA commit d95c7d206b5836c7770e8e9cd613859887fded8f Link: https://github.com/acpica/acpica/commit/d95c7d20 Signed-off-by: Marcin Wojtas Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/actbl1.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index a7ea179b2089..159070edd031 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h @@ -483,7 +483,7 @@ struct acpi_csrt_descriptor { * DBG2 - Debug Port Table 2 * Version 0 (Both main table and subtables) * - * Conforms to "Microsoft Debug Port Table 2 (DBG2)", December 10, 2015 + * Conforms to "Microsoft Debug Port Table 2 (DBG2)", September 21, 2020 * ******************************************************************************/ @@ -533,11 +533,24 @@ struct acpi_dbg2_device { #define ACPI_DBG2_16550_COMPATIBLE 0x0000 #define ACPI_DBG2_16550_SUBSET 0x0001 +#define ACPI_DBG2_MAX311XE_SPI 0x0002 #define ACPI_DBG2_ARM_PL011 0x0003 +#define ACPI_DBG2_MSM8X60 0x0004 +#define ACPI_DBG2_16550_NVIDIA 0x0005 +#define ACPI_DBG2_TI_OMAP 0x0006 +#define ACPI_DBG2_APM88XXXX 0x0008 +#define ACPI_DBG2_MSM8974 0x0009 +#define ACPI_DBG2_SAM5250 0x000A +#define ACPI_DBG2_INTEL_USIF 0x000B +#define ACPI_DBG2_IMX6 0x000C #define ACPI_DBG2_ARM_SBSA_32BIT 0x000D #define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E #define ACPI_DBG2_ARM_DCC 0x000F #define ACPI_DBG2_BCM2835 0x0010 +#define ACPI_DBG2_SDM845_1_8432MHZ 0x0011 +#define ACPI_DBG2_16550_WITH_GAS 0x0012 +#define ACPI_DBG2_SDM845_7_372MHZ 0x0013 +#define ACPI_DBG2_INTEL_LPSS 0x0014 #define ACPI_DBG2_1394_STANDARD 0x0000 -- cgit v1.2.3 From 87b8ec5846cb81747088d1729acaf55a1155a267 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:10:46 +0200 Subject: ACPICA: iASL: Fix for WPBT table with no command-line arguments Handle the case where the Command-line Arguments table field does not exist. ACPICA commit d6487164497fda170a1b1453c5d58f2be7c873d6 Link: https://github.com/acpica/acpica/commit/d6487164 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/actbl3.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index 86903ac5bbc5..9125e2f16329 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h @@ -723,6 +723,10 @@ struct acpi_table_wpbt { u16 arguments_length; }; +struct acpi_wpbt_unicode { + u16 *unicode_string; +}; + /******************************************************************************* * * WSMT - Windows SMM Security Mitigations Table -- cgit v1.2.3 From 89ceb98ac1184e7c28b7f6feb877986f77591103 Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:11:21 +0200 Subject: ACPICA: Add method name "_DIS" For use with aslmethod.c ACPICA commit 5acc6818c537888be147d9da6b280a0b8c241a1d Link: https://github.com/acpica/acpica/commit/5acc6818 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/acnames.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h index a2bc381c7ce7..30869ab77fba 100644 --- a/include/acpi/acnames.h +++ b/include/acpi/acnames.h @@ -20,6 +20,7 @@ #define METHOD_NAME__CLS "_CLS" #define METHOD_NAME__CRS "_CRS" #define METHOD_NAME__DDN "_DDN" +#define METHOD_NAME__DIS "_DIS" #define METHOD_NAME__DMA "_DMA" #define METHOD_NAME__HID "_HID" #define METHOD_NAME__INI "_INI" -- cgit v1.2.3 From 696e0c937d07a79341d6e5da23fb6abc1d2f842b Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Tue, 3 Aug 2021 20:11:57 +0200 Subject: ACPICA: Update version to 20210730 Version 20210730. ACPICA commit 2195f614e79442beb4d24d7a29a6347493e444e5 Link: https://github.com/acpica/acpica/commit/2195f614 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/acpixf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index a43335961e30..fa02e3ff0faf 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -12,7 +12,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20210604 +#define ACPI_CA_VERSION 0x20210730 #include #include -- cgit v1.2.3 From b25d5a1cd19896bb87b399d6e24896cf6f854d44 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 16 Aug 2021 13:30:07 +0200 Subject: ACPI: platform-profile: call sysfs_notify() from platform_profile_store() Drivers like thinkpad_acpi and ideapad_laptop call the platform_profile_notify() helper when the profile is changed by hardware (the embedded-controller/EC) in response to an EC handled hotkey. This allows userspace to monitor for such changes by polling for POLLPRI on the platform_profile sysfs file. But the profile can also be changed underneath a userspace program monitoring it by anonther userspace program storing a new value. Add a sysfs_notify() call to platform_profile_store(), so that userspace programs monitoring for changes also get notified in this case. Also update the documentation to document that POLLPRI polling can be used to watch for changes. Signed-off-by: Hans de Goede Signed-off-by: Rafael J. Wysocki --- Documentation/ABI/testing/sysfs-platform_profile | 7 +++++++ drivers/acpi/platform_profile.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile index dae9c8941905..baf1d125f9f8 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -26,3 +26,10 @@ Contact: Hans de Goede Description: Reading this file gives the current selected profile for this device. Writing this file with one of the strings from platform_profile_choices changes the profile to the new value. + + This file can be monitored for changes by polling for POLLPRI, + POLLPRI will be signalled on any changes, independent of those + changes coming from a userspace write; or coming from another + source such as e.g. a hotkey triggered profile change handled + either directly by the embedded-controller or fully handled + inside the kernel. diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index dd2fbf38e414..d418462ab791 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -106,6 +106,9 @@ static ssize_t platform_profile_store(struct device *dev, } err = cur_profile->profile_set(cur_profile, i); + if (!err) + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + mutex_unlock(&profile_lock); if (err) return err; -- cgit v1.2.3 From 2aaea6a1647e887fe91ce3e0324e6be4362e5388 Mon Sep 17 00:00:00 2001 From: Marcin Wojtas Date: Wed, 14 Jul 2021 23:43:46 +0200 Subject: ACPI: SPCR: Add support for the new 16550-compatible Serial Port Subtype The Microsoft Debug Port Table 2 (DBG2) specification revision May 31, 2017 added definition of the 16550-compatible Serial Port Subtype with parameters defined in Generic Address Structure (GAS) [1] Add its support in the SPCR table parsing routine. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table Signed-off-by: Marcin Wojtas Signed-off-by: Rafael J. Wysocki --- drivers/acpi/spcr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index 88460bacd5ae..25c2d0be953e 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c @@ -136,6 +136,7 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console) break; case ACPI_DBG2_16550_COMPATIBLE: case ACPI_DBG2_16550_SUBSET: + case ACPI_DBG2_16550_WITH_GAS: uart = "uart"; break; default: -- cgit v1.2.3 From 437b38c51162f8b87beb28a833c4d5dc85fa864e Mon Sep 17 00:00:00 2001 From: Lorenzo Pieralisi Date: Mon, 23 Aug 2021 11:46:18 +0100 Subject: ACPI: Add memory semantics to acpi_os_map_memory() The memory attributes attached to memory regions depend on architecture specific mappings. For some memory regions, the attributes specified by firmware (eg uncached) are not sufficient to determine how a memory region should be mapped by an OS (for instance a region that is define as uncached in firmware can be mapped as Normal or Device memory on arm64) and therefore the OS must be given control on how to map the region to match the expected mapping behaviour (eg if a mapping is requested with memory semantics, it must allow unaligned accesses). Rework acpi_os_map_memory() and acpi_os_ioremap() back-end to split them into two separate code paths: acpi_os_memmap() -> memory semantics acpi_os_ioremap() -> MMIO semantics The split allows the architectural implementation back-ends to detect the default memory attributes required by the mapping in question (ie the mapping API defines the semantics memory vs MMIO) and map the memory accordingly. Link: https://lore.kernel.org/linux-arm-kernel/31ffe8fc-f5ee-2858-26c5-0fd8bdd68702@arm.com Tested-by: Hanjun Guo Signed-off-by: Lorenzo Pieralisi Acked-by: Ard Biesheuvel Acked-by: Catalin Marinas Signed-off-by: Rafael J. Wysocki --- arch/arm64/include/asm/acpi.h | 3 +++ arch/arm64/kernel/acpi.c | 19 ++++++++++++++++--- drivers/acpi/osl.c | 23 ++++++++++++++++------- include/acpi/acpi_io.h | 8 ++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index bd68e1b7f29f..7535dc7cc5aa 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -50,6 +50,9 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); #define acpi_os_ioremap acpi_os_ioremap +void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size); +#define acpi_os_memmap acpi_os_memmap + typedef u64 phys_cpuid_t; #define PHYS_CPUID_INVALID INVALID_HWID diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index f3851724fe35..1c9c2f7a1c04 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -273,7 +273,8 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) return __pgprot(PROT_DEVICE_nGnRnE); } -void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) +static void __iomem *__acpi_os_ioremap(acpi_physical_address phys, + acpi_size size, bool memory) { efi_memory_desc_t *md, *region = NULL; pgprot_t prot; @@ -299,9 +300,11 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) * It is fine for AML to remap regions that are not represented in the * EFI memory map at all, as it only describes normal memory, and MMIO * regions that require a virtual mapping to make them accessible to - * the EFI runtime services. + * the EFI runtime services. Determine the region default + * attributes by checking the requested memory semantics. */ - prot = __pgprot(PROT_DEVICE_nGnRnE); + prot = memory ? __pgprot(PROT_NORMAL_NC) : + __pgprot(PROT_DEVICE_nGnRnE); if (region) { switch (region->type) { case EFI_LOADER_CODE: @@ -361,6 +364,16 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) return __ioremap(phys, size, prot); } +void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) +{ + return __acpi_os_ioremap(phys, size, false); +} + +void __iomem *acpi_os_memmap(acpi_physical_address phys, acpi_size size) +{ + return __acpi_os_ioremap(phys, size, true); +} + /* * Claim Synchronous External Aborts as a firmware first notification. * diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 45c5c0e45e33..a43f1521efe6 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -284,7 +284,8 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size) #define should_use_kmap(pfn) page_is_ram(pfn) #endif -static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) +static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz, + bool memory) { unsigned long pfn; @@ -294,7 +295,8 @@ static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) return NULL; return (void __iomem __force *)kmap(pfn_to_page(pfn)); } else - return acpi_os_ioremap(pg_off, pg_sz); + return memory ? acpi_os_memmap(pg_off, pg_sz) : + acpi_os_ioremap(pg_off, pg_sz); } static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr) @@ -309,9 +311,10 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr) } /** - * acpi_os_map_iomem - Get a virtual address for a given physical address range. + * __acpi_os_map_iomem - Get a virtual address for a given physical address range. * @phys: Start of the physical address range to map. * @size: Size of the physical address range to map. + * @memory: true if remapping memory, false if IO * * Look up the given physical address range in the list of existing ACPI memory * mappings. If found, get a reference to it and return a pointer to it (its @@ -321,8 +324,8 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr) * During early init (when acpi_permanent_mmap has not been set yet) this * routine simply calls __acpi_map_table() to get the job done. */ -void __iomem __ref -*acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) +static void __iomem __ref +*__acpi_os_map_iomem(acpi_physical_address phys, acpi_size size, bool memory) { struct acpi_ioremap *map; void __iomem *virt; @@ -353,7 +356,7 @@ void __iomem __ref pg_off = round_down(phys, PAGE_SIZE); pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; - virt = acpi_map(phys, size); + virt = acpi_map(phys, size, memory); if (!virt) { mutex_unlock(&acpi_ioremap_lock); kfree(map); @@ -372,11 +375,17 @@ out: mutex_unlock(&acpi_ioremap_lock); return map->virt + (phys - map->phys); } + +void __iomem *__ref +acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) +{ + return __acpi_os_map_iomem(phys, size, false); +} EXPORT_SYMBOL_GPL(acpi_os_map_iomem); void *__ref acpi_os_map_memory(acpi_physical_address phys, acpi_size size) { - return (void *)acpi_os_map_iomem(phys, size); + return (void *)__acpi_os_map_iomem(phys, size, true); } EXPORT_SYMBOL_GPL(acpi_os_map_memory); diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h index 027faa8883aa..a0212e67d6f4 100644 --- a/include/acpi/acpi_io.h +++ b/include/acpi/acpi_io.h @@ -14,6 +14,14 @@ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, } #endif +#ifndef acpi_os_memmap +static inline void __iomem *acpi_os_memmap(acpi_physical_address phys, + acpi_size size) +{ + return ioremap_cache(phys, size); +} +#endif + extern bool acpi_permanent_mmap; void __iomem __ref -- cgit v1.2.3 From 1a20d409c874255086e2f42a729826d490294c91 Mon Sep 17 00:00:00 2001 From: Ulrich Huber Date: Tue, 24 Aug 2021 14:57:44 +0200 Subject: ACPI: button: Add DMI quirk for Lenovo Yoga 9 (14INTL5) The Lenovo Yoga 9 (14INTL5)'s ACPI _LID is bugged: After hibernation the lid is initially reported as closed. Once closing and then reopening the lid reports the lid as open again. This leads to the conclusion that the initial notification of the lid is missing but subsequent notifications are correct. In order fo the Linux LID code to handle this device properly the lid_init_state must be set to ACPI_BUTTON_LID_INIT_OPEN. Signed-off-by: Ulrich Huber Signed-off-by: Rafael J. Wysocki --- drivers/acpi/button.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index f25bd336113b..1f9b9a4c38c7 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -77,6 +77,17 @@ static const struct dmi_system_id dmi_lid_quirks[] = { }, .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED, }, + { + /* + * Lenovo Yoga 9 14ITL5, initial notification of the LID device + * never happens. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "82BG"), + }, + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, + }, { /* * Medion Akoya E2215T, notification of the LID device only -- cgit v1.2.3 From 97e03410bc5f6a20d46b15740c2eae240f766e39 Mon Sep 17 00:00:00 2001 From: Adrian Huang Date: Thu, 19 Aug 2021 15:14:16 +0800 Subject: ACPI: tables: FPDT: Do not print FW_BUG message if record types are reserved In ACPI 6.4 spec, record types "0x0002-0xffff" of FPDT Performance Record Types [1] and record types "0x0003-0xffff" of Runtime Performance Record Types [2] are reserved. Users might be confused with the FW_BUG message, and they think this is the FW issue. Here is the example in a Lenovo box: ACPI: FPDT 0x00000000A820A000 000044 (v01 LENOVO THINKSYS 00000100 01000013) ACPI: Reserving FPDT table memory at [mem 0xa820a000-0xa820a043] ACPI FPDT: [Firmware Bug]: Invalid record 4113 found So, remove the FW_BUG message to avoid confusion since those types are reserved in ACPI 6.4 spec. [1] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#fpdt-performance-record-types-table [2] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#runtime-performance-record-types-table Signed-off-by: Adrian Huang Acked-by: Zhang Rui Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_fpdt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_fpdt.c b/drivers/acpi/acpi_fpdt.c index 4ee2ad234e3d..6922a44b3ce7 100644 --- a/drivers/acpi/acpi_fpdt.c +++ b/drivers/acpi/acpi_fpdt.c @@ -220,8 +220,8 @@ static int fpdt_process_subtable(u64 address, u32 subtable_type) break; default: - pr_err(FW_BUG "Invalid record %d found.\n", record_header->type); - return -EINVAL; + /* Other types are reserved in ACPI 6.4 spec. */ + break; } } return 0; @@ -254,8 +254,7 @@ static int __init acpi_init_fpdt(void) subtable->type); break; default: - pr_info(FW_BUG "Invalid subtable type %d found.\n", - subtable->type); + /* Other types are reserved in ACPI 6.4 spec. */ break; } offset += sizeof(*subtable); -- cgit v1.2.3 From fad40a624854ad14a88ee0277b9e8207bfc6d95a Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 27 Aug 2021 21:07:58 +0200 Subject: ACPI: power: Use acpi_handle_debug() to print debug messages Use acpi_handle_debug() to print diagnostic messages regarding ACPI power resources so as to make it easier to correlate the kernel messages with the power resource objects in the ACPI namespace that they are about. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/power.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index eba7785047ca..21d42804b2c1 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -356,10 +356,11 @@ void acpi_device_power_remove_dependent(struct acpi_device *adev, static int __acpi_power_on(struct acpi_power_resource *resource) { + acpi_handle handle = resource->device.handle; struct acpi_power_dependent_device *dep; acpi_status status = AE_OK; - status = acpi_evaluate_object(resource->device.handle, "_ON", NULL, NULL); + status = acpi_evaluate_object(handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) { resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; return -ENODEV; @@ -367,7 +368,7 @@ static int __acpi_power_on(struct acpi_power_resource *resource) resource->state = ACPI_POWER_RESOURCE_STATE_ON; - pr_debug("Power resource [%s] turned on\n", resource->name); + acpi_handle_debug(handle, "Power resource turned on\n"); /* * If there are other dependents on this power resource we need to @@ -392,7 +393,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource) int result = 0; if (resource->ref_count++) { - pr_debug("Power resource [%s] already on\n", resource->name); + acpi_handle_debug(resource->device.handle, + "Power resource already on\n"); } else { result = __acpi_power_on(resource); if (result) @@ -413,10 +415,10 @@ static int acpi_power_on(struct acpi_power_resource *resource) static int __acpi_power_off(struct acpi_power_resource *resource) { + acpi_handle handle = resource->device.handle; acpi_status status; - status = acpi_evaluate_object(resource->device.handle, "_OFF", - NULL, NULL); + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; return -ENODEV; @@ -424,7 +426,7 @@ static int __acpi_power_off(struct acpi_power_resource *resource) resource->state = ACPI_POWER_RESOURCE_STATE_OFF; - pr_debug("Power resource [%s] turned off\n", resource->name); + acpi_handle_debug(handle, "Power resource turned off\n"); return 0; } @@ -434,12 +436,14 @@ static int acpi_power_off_unlocked(struct acpi_power_resource *resource) int result = 0; if (!resource->ref_count) { - pr_debug("Power resource [%s] already off\n", resource->name); + acpi_handle_debug(resource->device.handle, + "Power resource already off\n"); return 0; } if (--resource->ref_count) { - pr_debug("Power resource [%s] still in use\n", resource->name); + acpi_handle_debug(resource->device.handle, + "Power resource still in use\n"); } else { result = __acpi_power_off(resource); if (result) @@ -1004,7 +1008,7 @@ void acpi_resume_power_resources(void) if (state == ACPI_POWER_RESOURCE_STATE_OFF && resource->ref_count) { - dev_dbg(&resource->device.dev, "Turning ON\n"); + acpi_handle_debug(resource->device.handle, "Turning ON\n"); __acpi_power_on(resource); } @@ -1034,7 +1038,7 @@ void acpi_turn_off_unused_power_resources(void) */ if (!resource->ref_count && resource->state != ACPI_POWER_RESOURCE_STATE_OFF) { - dev_dbg(&resource->device.dev, "Turning OFF\n"); + acpi_handle_debug(resource->device.handle, "Turning OFF\n"); __acpi_power_off(resource); } -- cgit v1.2.3 From 2bc4eb943b1b27606cd6d63be69f2197cad15173 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 25 Aug 2021 20:31:10 +0200 Subject: ACPI: power: Drop name from struct acpi_power_resource Drop the name field (that only is used in diagnostic messages) from struct acpi_power_resource and use the name of the power resource device object instead of it. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/power.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 21d42804b2c1..b9863e22b952 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -48,7 +48,6 @@ struct acpi_power_dependent_device { struct acpi_power_resource { struct acpi_device device; struct list_head list_node; - char *name; u32 system_level; u32 order; unsigned int ref_count; @@ -70,6 +69,11 @@ static DEFINE_MUTEX(power_resource_list_lock); Power Resource Management -------------------------------------------------------------------------- */ +static inline const char *resource_dev_name(struct acpi_power_resource *pr) +{ + return dev_name(&pr->device.dev); +} + static inline struct acpi_power_resource *to_power_resource(struct acpi_device *device) { @@ -264,7 +268,8 @@ acpi_power_resource_add_dependent(struct acpi_power_resource *resource, dep->dev = dev; list_add_tail(&dep->node, &resource->dependents); - dev_dbg(dev, "added power dependency to [%s]\n", resource->name); + dev_dbg(dev, "added power dependency to [%s]\n", + resource_dev_name(resource)); unlock: mutex_unlock(&resource->resource_lock); @@ -283,7 +288,7 @@ acpi_power_resource_remove_dependent(struct acpi_power_resource *resource, list_del(&dep->node); kfree(dep); dev_dbg(dev, "removed power dependency to [%s]\n", - resource->name); + resource_dev_name(resource)); break; } } @@ -381,7 +386,7 @@ static int __acpi_power_on(struct acpi_power_resource *resource) list_for_each_entry(dep, &resource->dependents, node) { dev_dbg(dep->dev, "runtime resuming because [%s] turned on\n", - resource->name); + resource_dev_name(resource)); pm_request_resume(dep->dev); } @@ -953,7 +958,6 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle) mutex_init(&resource->resource_lock); INIT_LIST_HEAD(&resource->list_node); INIT_LIST_HEAD(&resource->dependents); - resource->name = device->pnp.bus_id; strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_POWER_CLASS); device->power.state = ACPI_STATE_UNKNOWN; -- cgit v1.2.3