Re: [PATCH 17/28] mfd: loongson-se: Reinitialise completions and wait uninterruptibly for commands

From: Qunqin Zhao

Date: Mon Oct 26 2026 - 22:43:21 EST



在 2026/10/21 20:09, Lee Jones 写道:
> loongson_se_send_controller_cmd() and loongson_se_send_engine_cmd() wait
> on se->cmd_completion and engine->completion using
> wait_for_completion_interruptible() without reinitialising the
> completion before issuing a new command. Because the hardware has no
> mechanism to abort an in-flight command once accepted by
> loongson_se_poll(), returning early on a signal leaves the controller or
> engine actively processing the shared command registers and DMA buffers
> in the background, and its subsequent completion interrupt leaves a
> stale completion token that causes the next command to return
> prematurely.
>
> Clear any stale pending interrupt status and reinitialise the target
> completion inside loongson_se_poll() while holding se->dev_lock
> immediately before notifying the controller, and wait uninterruptibly
> via wait_for_completion() once loongson_se_poll() confirms the command
> has been accepted by the hardware.
>
> Fixes: e551fa3159e3 ("mfd: Add support for Loongson Security Engine chip controller")
> Closes: https://sashiko.dev/#/bug/linux-4661fb0d-d936-4168-89cd-2f6dec31a7b5
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>

Reviewed-by: Qunqin Zhao <zhaoqunqin@xxxxxxxxxxx>
Tested-by: Qunqin Zhao <zhaoqunqin@xxxxxxxxxxx>

Thanks for fixing this!


Best Regards,

Qunqin.