[PATCH] cmd: mtd: benchmark: use lldiv() instead of 64-bit division
    Michael Nazzareno Trimarchi 
    michael at amarulasolutions.com
       
    Fri Oct 10 19:38:55 CEST 2025
    
    
  
Hi
On Fri, Oct 10, 2025 at 7:28 PM Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 10/10/25 18:51, Mikhail Kshevetskiy wrote:
> > As was noted by Heinrich Schuchardt, some SoCs may not support 64-bit
> > divisions. Fix an issue by using lldiv() instead.
>
> Thank you for the patch.
>
> It is on top of
> cmd: mtd: fix speed measurement in the speed benchmark
> https://patchwork.ozlabs.org/project/uboot/patch/20251010124115.1545865-5-mikhail.kshevetskiy@iopsys.eu/
>
> Adding it to the series might make Tom's life easier.
>
> >
> > Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at iopsys.eu>
> > ---
> >   cmd/mtd.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/mtd.c b/cmd/mtd.c
> > index acd886da6da..2bc9fea697c 100644
> > --- a/cmd/mtd.c
> > +++ b/cmd/mtd.c
> > @@ -10,6 +10,7 @@
> >
> >   #include <command.h>
> >   #include <console.h>
> > +#include <div64.h>
> >   #include <led.h>
> >   #if CONFIG_IS_ENABLED(CMD_MTD_OTP)
> >   #include <hexdump.h>
> > @@ -595,7 +596,7 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
> >
> >       if (benchmark && bench_start) {
> >               bench_end = timer_get_us();
> > -             speed = (len * 1000000) / (bench_end - bench_start);
> > +             speed = lldiv(len * 1000000, bench_end - bench_start);
>
> Here you assume that the benchmark never takes more than 4294 seconds
> and thus the difference will be less than U32_MAX. This looks reasonable
> to me.
>
> >               printf("%s speed: %lukiB/s\n",
> >                      read ? "Read" : "Write",
> >                      (unsigned long)(speed / 1024));
>
> You further assume that the compiler implements this u64 division
> as >> 10. You could be explicit about this.
The series is taken already, so it means apply now on top of tom tree
Michael
>
> Best regards
>
> Heinrich
-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael at amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info at amarulasolutions.com
www.amarulasolutions.com
    
    
More information about the U-Boot
mailing list