Re: [PATCH v2 2/2] cxl/mbox: Use mapped errno to determine command status

From: Alison Schofield

Date: Wed Nov 04 2026 - 23:44:44 EST


On Tue, Nov 03, 2026 at 10:43:05AM +0800, Li Ming wrote:
> cxl_mbox_cmd_rctable already maps all mailbox command return codes to
> errno values. Use the returned errno directly instead of checking
> mailbox return codes separately to determine whether a command succeeded
> or failed.
>
> Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
> ---
> v2:
> - New patch.
> ---
> drivers/cxl/core/mbox.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index 55828a836c01..bd91b03c4d21 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -270,9 +270,9 @@ int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox,
> if (rc)
> return rc;
>
> - if (mbox_cmd->return_code != CXL_MBOX_CMD_RC_SUCCESS &&
> - mbox_cmd->return_code != CXL_MBOX_CMD_RC_BACKGROUND)
> - return cxl_mbox_cmd_rc2errno(mbox_cmd);
> + rc = cxl_mbox_cmd_rc2errno(mbox_cmd);
> + if (rc)
> + return rc;

Hi Ming,

The existing code really seemed to want BACKGROUND as a special case, so
I searched the history on this one, Davidlohr and you discussed this in
2023 around sanitize[1] .

I do think it is confusing and if we can just follow the table codes,
that would be easier.

I'll let Davidlohr dig in on this one.

I read both these patches as cleanups but no bug to be fixed.


[1] https://lore.kernel.org/linux-cxl/mw5bsc5u72fdrgo7qovj6u2npg2asftzp3jeprwtmnvbvg7vet@fayzcxpurjl6/

-- Alison





>
> if (!out_size)
> return 0;
> --
> 2.43.0
>