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

From: Andy Shevchenko

Date: Mon Nov 16 2026 - 06:31:15 EST


On Fri, Nov 13, 2026 at 10:17:54PM -0800, Rosen Penev wrote:
> 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.

...

> #include <linux/io.h>
> +#include <linux/iopoll.h>

You may replace io.h with iopoll.h.

...

> - 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;

Find the difference between -ETIME and -ETIMEDOUT. Besides that, you
effectively ignored the return value of the call. Why?

And on top, this is an inconsistent change, the function AFACS has two of a
such that may be replaced at once.

--
With Best Regards,
Andy Shevchenko