hw/cxl: Use runtime for bg cmd running semantics
PATCH 1/1 hw/cxl: Use runtime for bg cmd running semantics
The current check incorrectly misses the 0% case, which semantically can either be not running or one that just started. The runtime is a better way to check for 0%, 100% or aborted. This is currently benign in the kernel equivalent without cancel support.
---
Applies against 'cxl-2025-06-10' from jic23 tree.
hw/cxl/cxl-device-utils.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/cxl/cxl-device-utils.c +1 -4
@@ -95,13 +95,10 @@ static uint64_t mailbox_reg_read(void *opaque, hwaddr offset, unsigned size) }if (offset ==A_CXL_DEV_MAILBOX_STS ) {uint64_t status_reg = cxl_dstate->mbox_reg_state64[offset / size]; -int bgop;qemu_mutex_lock (&cci->bg.lock); - bgop = !(cci->bg.complete_pct ==100 || cci->bg.aborted); - status_reg =FIELD_DP64 (status_reg,CXL_DEV_MAILBOX_STS ,BG_OP , - bgop); + !!cci->bg.runtime); cxl_dstate->mbox_reg_state64[offset / size] = status_reg;qemu_mutex_unlock (&cci->bg.lock); }
Signature · 1 line
2.39.5
Quoted 6 lines · On Tue, 17 Jun 2025 14:48:32 -0700 Davidlohr Bueso <[email protected]> wrote:
The current check incorrectly misses the 0% case, which semantically can either be not running or one that just started. The runtime is a better way to check for 0%, 100% or aborted. This is currently benign in the kernel equivalent without cancel support.
Signed-off-by Davidlohr Bueso <[email protected]>
Looks good to me. I'll carry this on my local tree for now and combine it with some other fixes to send to MST.
Probably push out a new cxl staging tree sometime in next few weeks.
Quoted 26 lines
---
Applies against 'cxl-2025-06-10' from jic23 tree.
hw/cxl/cxl-device-utils.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/cxl/cxl-device-utils.c +1
-4@@ -95,13 +95,10 @@ static uint64_t mailbox_reg_read(void *opaque, hwaddr offset, unsigned size) }if (offset ==A_CXL_DEV_MAILBOX_STS ) {uint64_t status_reg = cxl_dstate->mbox_reg_state64[offset / size]; -int bgop;qemu_mutex_lock (&cci->bg.lock); - bgop = !(cci->bg.complete_pct ==100 || cci->bg.aborted); - status_reg =FIELD_DP64 (status_reg,CXL_DEV_MAILBOX_STS ,BG_OP , - bgop); + !!cci->bg.runtime); cxl_dstate->mbox_reg_state64[offset / size] = status_reg;qemu_mutex_unlock (&cci->bg.lock); }