aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAjay Joshi <ajayjoshi@micron.com>2024-10-14 13:18:57 +0100
committerMichael S. Tsirkin <mst@redhat.com>2024-11-04 16:03:24 -0500
commit8352756ffa72668773d6904bc76dfc0bf2619e5a (patch)
tree927ea65c7fe4b1d52956cd19da90e8112c4aa867 /hw
parentdf66b85f357f9669457906ece865d6183cf12580 (diff)
downloadqemu-8352756ffa72668773d6904bc76dfc0bf2619e5a.zip
qemu-8352756ffa72668773d6904bc76dfc0bf2619e5a.tar.gz
qemu-8352756ffa72668773d6904bc76dfc0bf2619e5a.tar.bz2
hw/cxl: Fix background completion percentage calculation
The current completion percentage calculation does not account for the relative time since the start of the background activity, this leads to showing incorrect start percentage vs what has actually been completed. This patch calculates the percentage based on the actual elapsed time since the start of the operation. Fixes: 221d2cfbdb53 ("hw/cxl/mbox: Add support for background operations") Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net> Link: https://lore.kernel.org/r/20240729102338.22337-1-ajay.opensrc@micron.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Message-Id: <20241014121902.2146424-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/cxl/cxl-mailbox-utils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 9f794e4..3a93966 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -2879,7 +2879,8 @@ static void bg_timercb(void *opaque)
}
} else {
/* estimate only */
- cci->bg.complete_pct = 100 * now / total_time;
+ cci->bg.complete_pct =
+ 100 * (now - cci->bg.starttime) / cci->bg.runtime;
timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ);
}