Re: Pressing the power button causes the device to freeze completely
From: Rafael J. Wysocki
Date: Tue Apr 28 2026 - 16:00:08 EST
On Tuesday, April 28, 2026 9:11:34 PM CEST Evgeny Sagatov wrote:
> Yes, the PC froze when I pressed the power button.
Well, in that case, let's try to serialize all accesses to I/O ports
used in the ACPI code.
The patch below replaces the previous one, please give it a go.
---
drivers/acpi/osl.c | 6 ++++++
drivers/cpufreq/acpi-cpufreq.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -664,6 +664,8 @@ u64 acpi_os_get_timer(void)
(ACPI_100NSEC_PER_SEC / HZ);
}
+static DEFINE_RAW_SPINLOCK(acpi_os_port_lock);
+
acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width)
{
u32 dummy;
@@ -682,6 +684,8 @@ acpi_status acpi_os_read_port(acpi_io_ad
else
value = &dummy;
+ guard(raw_spinlock_irqsave)(&acpi_os_port_lock);
+
if (width <= 8) {
*value = inb(port);
} else if (width <= 16) {
@@ -703,6 +707,8 @@ acpi_status acpi_os_write_port(acpi_io_a
if (!IS_ENABLED(CONFIG_HAS_IOPORT))
return AE_NOT_IMPLEMENTED;
+ guard(raw_spinlock_irqsave)(&acpi_os_port_lock);
+
if (width <= 8) {
outb(value, port);
} else if (width <= 16) {
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -913,7 +913,9 @@ static int acpi_cpufreq_cpu_init(struct
data->resume = 1;
policy->fast_switch_possible = !acpi_pstate_strict &&
- !(policy_is_shared(policy) && policy->shared_type != CPUFREQ_SHARED_TYPE_ANY);
+ (!policy_is_shared(policy) ||
+ policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) &&
+ perf->control_register.space_id != ACPI_ADR_SPACE_SYSTEM_IO;
if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
pr_warn(FW_WARN "P-state 0 is not max freq\n");