From: Rosen Penev <rosenp@gmail.com>
To: "Stuart Hayes" <stuart.w.hayes@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Doug Warzecha" <Douglas_Warzecha@dell.com>,
"Andrew Morton" <akpm@osdl.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] platform/x86: dell: dcdbas: Actually wait for the host control SMI
Date: Fri, 13 Nov 2026 22:17:54 -0800 [thread overview]
Message-ID: <c35b26234163789f1fc37ba09a48de58d475629a.1794633178.git.rosenp@gmail.com> (raw)
In-Reply-To: <cover.1794633178.git.rosenp@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2026-11-14 6:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 6:17 [PATCH 0/5] platform/x86: dell: dcdbas: Fix SMI completion wait and buffer handling Rosen Penev
2026-11-14 6:17 ` Rosen Penev [this message]
2026-11-14 6:17 ` [PATCH 2/5] platform/x86: dell: dcdbas: Suppress bind attributes of the platform driver Rosen Penev
2026-11-14 6:17 ` [PATCH 3/5] platform/x86: dell: dcdbas: Release the SMI buffer in remove Rosen Penev
2026-11-14 6:17 ` [PATCH 4/5] platform/x86: dell: dcdbas: Validate the WSMT buffer description Rosen Penev
2026-11-14 6:17 ` [PATCH 5/5] platform/x86: dell: dcdbas: Use read_poll_timeout_atomic() for the type 1 SMI Rosen Penev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c35b26234163789f1fc37ba09a48de58d475629a.1794633178.git.rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=Douglas_Warzecha@dell.com \
--cc=akpm@osdl.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stuart.w.hayes@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®