[PATCH 1/5] platform/x86: dell: dcdbas: Actually wait for the host control SMI

From: Rosen Penev

Date: Sat Nov 14 2026 - 01:18:41 EST


For SMI types 2 and 3, host_control_smi() writes the command status as
-1, raises the SMI and then waits for the BIOS to change the status:

while (apm_cmd->status == ESM_STATUS_CMD_UNSUCCESSFUL) {

apm_cmd->status is a plain memory read, and neither outb() nor inb()
tells the compiler that memory may have changed, so the compiler
assumes status is still -1. The loop then has no side effects and its
return value is not used, so it is removed entirely: in the generated
code, the read of the control port is followed directly by the return.
The kernel goes on to power off right after raising the host control
SMI, without waiting for the BIOS to accept it.

Poll the status with read_poll_timeout_atomic() and READ_ONCE(), 1us
apart, for up to TIMEOUT_USEC_SHORT_SEMA_BLOCKING microseconds as the
name suggests. The type 1 loop polls an I/O port, which already takes
about a microsecond per read, and is left alone.

Fixes: 90563ec4129f ("[PATCH] dcdbas: add Dell Systems Management Base Driver with sysfs support")
Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/platform/x86/dell/dcdbas.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/dell/dcdbas.c b/drivers/platform/x86/dell/dcdbas.c
index 678f44252a45..a5917093d539 100644
--- a/drivers/platform/x86/dell/dcdbas.c
+++ b/drivers/platform/x86/dell/dcdbas.c
@@ -21,6 +21,7 @@
#include <linux/gfp.h>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mc146818rtc.h>
#include <linux/module.h>
@@ -441,12 +442,11 @@ static int host_control_smi(void)
cmd_status = inb(PE1400_APM_CONTROL_PORT);

/* wait a few to see if it executed */
- num_ticks = TIMEOUT_USEC_SHORT_SEMA_BLOCKING;
- while (apm_cmd->status == ESM_STATUS_CMD_UNSUCCESSFUL) {
- num_ticks--;
- if (num_ticks == EXPIRED_TIMER)
- return -ETIME;
- }
+ if (read_poll_timeout_atomic(READ_ONCE, cmd_status,
+ cmd_status != ESM_STATUS_CMD_UNSUCCESSFUL,
+ 1, TIMEOUT_USEC_SHORT_SEMA_BLOCKING,
+ false, apm_cmd->status))
+ return -ETIME;
break;

default:
--
2.56.0