[PATCH 5/5] platform/x86: dell: dcdbas: Use read_poll_timeout_atomic() for the type 1 SMI

From: Rosen Penev

Date: Sat Nov 14 2026 - 01:19:17 EST


For SMI type 1, host_control_smi() polls the APM status port in a loop
that counts down TIMEOUT_USEC_SHORT_SEMA_BLOCKING iterations and relies
on each inb() taking about a microsecond. Use
read_poll_timeout_atomic() with a 1us delay instead, like the type 2
and 3 path, so the timeout is in microseconds and does not depend on
how long a port read takes. With the delay plus the port read, the
worst-case wait grows from about 10ms to about 20ms, which only matters
when the BIOS never answers.

This removes the last users of num_ticks and EXPIRED_TIMER.

Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/platform/x86/dell/dcdbas.c | 12 +++++-------
drivers/platform/x86/dell/dcdbas.h | 1 -
2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/dell/dcdbas.c b/drivers/platform/x86/dell/dcdbas.c
index af4c1d2fe497..edc210852f2d 100644
--- a/drivers/platform/x86/dell/dcdbas.c
+++ b/drivers/platform/x86/dell/dcdbas.c
@@ -394,7 +394,6 @@ static int host_control_smi(void)
struct apm_cmd *apm_cmd;
u8 *data;
unsigned long flags;
- u32 num_ticks;
s8 cmd_status;
u8 index;

@@ -424,12 +423,11 @@ static int host_control_smi(void)
spin_unlock_irqrestore(&rtc_lock, flags);

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

case HC_SMITYPE_TYPE2:
diff --git a/drivers/platform/x86/dell/dcdbas.h b/drivers/platform/x86/dell/dcdbas.h
index a05d7f667586..d5ad2363dd9e 100644
--- a/drivers/platform/x86/dell/dcdbas.h
+++ b/drivers/platform/x86/dell/dcdbas.h
@@ -42,7 +42,6 @@
#define MAX_SYSMGMT_LONGCMD_SGENTRY_NUM (16)

#define TIMEOUT_USEC_SHORT_SEMA_BLOCKING (10000)
-#define EXPIRED_TIMER (0)

#define SMI_CMD_MAGIC (0x534D4931)
#define SMM_EPS_SIG "$SCB"
--
2.56.0