Re: [PATCH] hw/cxl: Support aborting background commands

Jonathan Cameron
2024-10-22T17:00:35Z

On Mon, 21 Oct 2024 20:23:46 -0700
Davidlohr Bueso <dave@stgolabs.net> wrote:

> On Tue, 27 Aug 2024, Jonathan Cameron wrote:\n
> >No comments inline and LGTM. I'll queue it on my tree and push
> >that out on gitlab sometime soonish.
>
> I don't see this picked up, which is a good thing atm. While testing
> the kernel side, I noticed the following is needed, will send a v2
> with it folded in.

Currently just on my cxl-2024-10-15 branch of gitlab.com/jic23/qemu.
I'll pick up your v2 and replace that.
>
> diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c
> index 1a9779ed8201..0d429b59aafc 100644
> --- a/hw/cxl/cxl-device-utils.c
> +++ b/hw/cxl/cxl-device-utils.c
> @@ -94,14 +94,15 @@ static uint64_t mailbox_reg_read(void *opaque, hwaddr offset, unsigned size)
> cxl_dstate->mbox_reg_state64[offset / size] = bg_status_reg;
> }
> if (offset == A_CXL_DEV_MAILBOX_STS) {
> + int bgop;
> uint64_t status_reg = cxl_dstate->mbox_reg_state64[offset / size];
>
> qemu_mutex_lock(&cci->bg.lock);
> - if (cci->bg.complete_pct == 100 || cci->bg.aborted) {
> - status_reg = FIELD_DP64(status_reg, CXL_DEV_MAILBOX_STS, BG_OP,
> - 0);
> - cxl_dstate->mbox_reg_state64[offset / size] = status_reg;
> - }
> + bgop = !(cci->bg.complete_pct == 100 || cci->bg.aborted);
> +
> + status_reg = FIELD_DP64(status_reg, CXL_DEV_MAILBOX_STS, BG_OP,
> + bgop);
> + cxl_dstate->mbox_reg_state64[offset / size] = status_reg;
> qemu_mutex_unlock(&cci->bg.lock);
> }
> return cxl_dstate->mbox_reg_state64[offset / size];
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index d5b084388288..760a8571fda6 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -2731,9 +2731,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = {
> [FIRMWARE_UPDATE][GET_INFO] = { "FIRMWARE_UPDATE_GET_INFO",
> cmd_firmware_update_get_info, 0, 0 },
> [FIRMWARE_UPDATE][TRANSFER] = { "FIRMWARE_UPDATE_TRANSFER",
> - cmd_firmware_update_transfer, ~0, CXL_MBOX_BACKGROUND_OPERATION },
> + cmd_firmware_update_transfer, ~0,
> + CXL_MBOX_BACKGROUND_OPERATION | CXL_MBOX_BACKGROUND_OPERATION_ABORT },
> [FIRMWARE_UPDATE][ACTIVATE] = { "FIRMWARE_UPDATE_ACTIVATE",
> - cmd_firmware_update_activate, 2, CXL_MBOX_BACKGROUND_OPERATION },
> + cmd_firmware_update_activate, 2,
> + CXL_MBOX_BACKGROUND_OPERATION | CXL_MBOX_BACKGROUND_OPERATION_ABORT },
> [TIMESTAMP][GET] = { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 },
> [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set,
> 8, CXL_MBOX_IMMEDIATE_POLICY_CHANGE },
>
> Thanks,
> Davidlohr