rockchip: test: emmc: add read/write count for emmc test
Usually, we test the eMMC speed by reading and writing several times and then taking the average. So add parameter count. Change-Id: I0a01804b4b35b4a6d9dc8c96ac2bce6a4607301b Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
This commit is contained in:
parent
5d8287bf26
commit
cb0376d1ac
|
|
@ -4,9 +4,9 @@
|
|||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <cli.h>
|
||||
#include <common.h>
|
||||
#include <linux/compat.h>
|
||||
#include <malloc.h>
|
||||
#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 */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue