[PATCH] cmd: mtd: benchmark: use lldiv() instead of 64-bit division
Heinrich Schuchardt
xypron.glpk at gmx.de
Fri Oct 10 19:28:46 CEST 2025
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.
Best regards
Heinrich
More information about the U-Boot
mailing list