[PATCH -qemu] hw/cxl: Use runtime for bg cmd running semantics

Davidlohr Bueso posted 1 patch 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250617214832.579960-1-dave@stgolabs.net
Maintainers: Jonathan Cameron <jonathan.cameron@huawei.com>, Fan Ni <fan.ni@samsung.com>
hw/cxl/cxl-device-utils.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH -qemu] hw/cxl: Use runtime for bg cmd running semantics
Posted by Davidlohr Bueso 5 months ago
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 <dave@stgolabs.net>
---

Applies against 'cxl-2025-06-10' from jic23 tree.

 hw/cxl/cxl-device-utils.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c
index e150d7445762..add0ab615976 100644
--- a/hw/cxl/cxl-device-utils.c
+++ b/hw/cxl/cxl-device-utils.c
@@ -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);
         }
-- 
2.39.5
Re: [PATCH -qemu] hw/cxl: Use runtime for bg cmd running semantics
Posted by Jonathan Cameron via 4 months, 3 weeks ago
On Tue, 17 Jun 2025 14:48:32 -0700
Davidlohr Bueso <dave@stgolabs.net> 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 <dave@stgolabs.net>
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.
> ---
> 
> Applies against 'cxl-2025-06-10' from jic23 tree.
> 
>  hw/cxl/cxl-device-utils.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c
> index e150d7445762..add0ab615976 100644
> --- a/hw/cxl/cxl-device-utils.c
> +++ b/hw/cxl/cxl-device-utils.c
> @@ -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);
>          }