diff --git a/test/rockchip/test-emmc.c b/test/rockchip/test-emmc.c index 383998b663..82d9cd2349 100644 --- a/test/rockchip/test-emmc.c +++ b/test/rockchip/test-emmc.c @@ -4,9 +4,9 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include -#include #include #include #include "test-rockchip.h" @@ -14,13 +14,13 @@ int board_emmc_test(int argc, char * const argv[]) { u8 *write_buffer, *read_buffer; - u32 i, blocks = 0, lba; + u32 i, blocks = 0, count = 0, lba; unsigned long ts; int err = 0; char cmd_mmc[512] = {0}; - if (argc < 4) { - printf("Usage: rktest emmc start_lba blocks\n"); + if (argc < 5) { + printf("Usage: rktest emmc start_lba blocks count\n"); printf("blocks should be from 8129 to 30000\n"); err = -EINVAL; goto err_wb; @@ -28,23 +28,13 @@ int board_emmc_test(int argc, char * const argv[]) lba = simple_strtoul(argv[2], NULL, 0); blocks = simple_strtoul(argv[3], NULL, 0); + count = simple_strtoul(argv[4], NULL, 0); if (blocks % 2) /* Round up */ blocks += 1; - if (blocks < 8192) { - printf("Round up to 8192 blocks compulsively\n"); - blocks = 8192; - } - - if (blocks > 30000) { - printf("Round down to 30000 blocks compulsively\n"); - blocks = 30000; - } - /* 1. Prepare memory */ - write_buffer = (u8 *)kmalloc(sizeof(u8) * blocks * 512, GFP_KERNEL); if (!write_buffer) { printf("No memory for write_buffer!\n"); @@ -64,29 +54,31 @@ int board_emmc_test(int argc, char * const argv[]) read_buffer[i] = 0; } - /* 2. Prepare and start cli command */ - + /* 2. Prepare and start mmc write/read */ snprintf(cmd_mmc, sizeof(cmd_mmc), "mmc write 0x%x 0x%x 0x%x", (u32)(ulong)write_buffer, lba, blocks); ts = get_timer(0); - err = cli_simple_run_command(cmd_mmc, 0); - ts = get_timer(0) - ts; - if (!err) - goto err_mw; + for (i = 0; i < count; i++) { + err = cli_simple_run_command(cmd_mmc, 0); + if (!err) + goto err_mw; + } + ts = get_timer(0) - ts; printf("eMMC write: size %dMB, used %ldms, speed %ldMB/s\n", - blocks / 2048, ts, (blocks >> 1) / ts); + blocks * count / 2048, ts, (blocks * count >> 1) / ts); snprintf(cmd_mmc, sizeof(cmd_mmc), "mmc read 0x%x 0x%x 0x%x", (u32)(ulong)read_buffer, lba, blocks); ts = get_timer(0); - err = cli_simple_run_command(cmd_mmc, 0); + for (i = 0; i < count; i++) { + err = cli_simple_run_command(cmd_mmc, 0); + if (!err) + goto err_mw; + } ts = get_timer(0) - ts; - if (!err) - goto err_mw; - printf("eMMC read: size %dMB, used %ldms, speed %ldMB/s\n", - blocks / 2048, ts, (blocks >> 1) / ts); + blocks * count / 2048, ts, (blocks * count >> 1) / ts); /* 3. Verify the context */