diff mbox series

hw/cxl: Fix background completion percentage calculation

Message ID 20240729102338.22337-1-ajay.opensrc@micron.com
State New
Headers show
Series hw/cxl: Fix background completion percentage calculation | expand

Commit Message

ajay.opensrc July 29, 2024, 10:23 a.m. UTC
From: Ajay Joshi <ajayjoshi@micron.com>

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: 221d2cfbdb ("hw/cxl/mbox: Add support for background operations")

Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>
---
 hw/cxl/cxl-mailbox-utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Davidlohr Bueso July 30, 2024, 5:24 a.m. UTC | #1
On Mon, 29 Jul 2024, ajay.opensrc@micron.com wrote:\n
>From: Ajay Joshi <ajayjoshi@micron.com>
>
>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: 221d2cfbdb ("hw/cxl/mbox: Add support for background operations")
>
>Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>

Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
ajay.opensrc Aug. 27, 2024, 4:01 p.m. UTC | #2
> From: Davidlohr Bueso <dave@stgolabs.net>
> 
> On Mon, 29 Jul 2024, ajay.opensrc@micron.com wrote:\n
> >From: Ajay Joshi <ajayjoshi@micron.com>
> >
> >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: 221d2cfbdb ("hw/cxl/mbox: Add support for background
> >operations")
> >
> >Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>
> 
> Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>

Ping.
Jonathan, this patch was reviewed by Dave already.
Do you have any comments on this patch?

Ajay
Jonathan Cameron Aug. 27, 2024, 4:38 p.m. UTC | #3
On Tue, 27 Aug 2024 16:01:54 +0000
ajay.opensrc <ajay.opensrc@micron.com> wrote:

> > From: Davidlohr Bueso <dave@stgolabs.net>
> > 
> > On Mon, 29 Jul 2024, ajay.opensrc@micron.com wrote:\n  
> > >From: Ajay Joshi <ajayjoshi@micron.com>
> > >
> > >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: 221d2cfbdb ("hw/cxl/mbox: Add support for background
> > >operations")
> > >
> > >Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>  
> > 
> > Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>  
> 
> Ping.
> Jonathan, this patch was reviewed by Dave already.
> Do you have any comments on this patch?

Sorry bit behind. Seems fine to me.   I'll queue it up, but not sure
when I'll get a fixes series out (hopefully soon!)

+CC Michael in meantime.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
in case Michael wants to pick it up directly.

Thanks,

Jonathan

> 
> Ajay
Michael S. Tsirkin Sept. 10, 2024, 5:07 p.m. UTC | #4
On Mon, Jul 29, 2024 at 03:53:38PM +0530, ajay.opensrc@micron.com wrote:
> From: Ajay Joshi <ajayjoshi@micron.com>
> 
> 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: 221d2cfbdb ("hw/cxl/mbox: Add support for background operations")
> 
> Signed-off-by: Ajay Joshi <ajay.opensrc@micron.com>

Keep all tags together with no empty lines pls.

> ---
>  hw/cxl/cxl-mailbox-utils.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index c2ed251bb3..873d60c069 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -2708,7 +2708,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);
>      }
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index c2ed251bb3..873d60c069 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -2708,7 +2708,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);
     }