Lines Matching full:test

38  * Limit the test area size to the maximum MMC HC erase group size.  Note that
65 * @max_sz: test area size (in bytes)
110 * @card: card under test
111 * @testcase: number of test case
112 * @result: result of test run
126 * @card: card under test
136 * struct mmc_test_card - test information.
137 * @card: card under test
179 static int mmc_test_set_blksize(struct mmc_test_card *test, unsigned size) in mmc_test_set_blksize() argument
181 return mmc_set_blocklen(test->card, size); in mmc_test_set_blksize()
190 static void mmc_test_prepare_sbc(struct mmc_test_card *test, in mmc_test_prepare_sbc() argument
193 struct mmc_card *card = test->card; in mmc_test_prepare_sbc()
210 static void mmc_test_prepare_mrq(struct mmc_test_card *test, in mmc_test_prepare_mrq() argument
226 if (!mmc_card_blockaddr(test->card)) in mmc_test_prepare_mrq()
245 mmc_test_prepare_sbc(test, mrq, blocks); in mmc_test_prepare_mrq()
247 mmc_set_data_timeout(mrq->data, test->card); in mmc_test_prepare_mrq()
259 static int mmc_test_wait_busy(struct mmc_test_card *test) in mmc_test_wait_busy() argument
269 cmd.arg = test->card->rca << 16; in mmc_test_wait_busy()
272 ret = mmc_wait_for_cmd(test->card->host, &cmd, 0); in mmc_test_wait_busy()
278 if (test->card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) in mmc_test_wait_busy()
280 mmc_hostname(test->card->host)); in mmc_test_wait_busy()
290 static int mmc_test_buffer_transfer(struct mmc_test_card *test, in mmc_test_buffer_transfer() argument
306 mmc_test_prepare_mrq(test, &mrq, &sg, 1, addr, 1, blksz, write); in mmc_test_buffer_transfer()
308 mmc_wait_for_req(test->card->host, &mrq); in mmc_test_buffer_transfer()
315 return mmc_test_wait_busy(test); in mmc_test_buffer_transfer()
534 static void mmc_test_save_transfer_result(struct mmc_test_card *test, in mmc_test_save_transfer_result() argument
540 if (!test->gr) in mmc_test_save_transfer_result()
553 list_add_tail(&tr->link, &test->gr->tr_lst); in mmc_test_save_transfer_result()
559 static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes, in mmc_test_print_rate() argument
572 mmc_hostname(test->card->host), sectors, sectors >> 1, in mmc_test_print_rate()
577 mmc_test_save_transfer_result(test, 1, sectors, ts, rate, iops); in mmc_test_print_rate()
583 static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes, in mmc_test_print_avg_rate() argument
599 mmc_hostname(test->card->host), count, sectors, count, in mmc_test_print_avg_rate()
603 test->area.sg_len); in mmc_test_print_avg_rate()
605 mmc_test_save_transfer_result(test, count, sectors, ts, rate, iops); in mmc_test_print_avg_rate()
620 /* Test preparation and cleanup */
627 static int __mmc_test_prepare(struct mmc_test_card *test, int write, int val) in __mmc_test_prepare() argument
631 ret = mmc_test_set_blksize(test, 512); in __mmc_test_prepare()
636 memset(test->buffer, val, 512); in __mmc_test_prepare()
639 test->buffer[i] = i; in __mmc_test_prepare()
643 ret = mmc_test_buffer_transfer(test, test->buffer, i, 512, 1); in __mmc_test_prepare()
651 static int mmc_test_prepare_write(struct mmc_test_card *test) in mmc_test_prepare_write() argument
653 return __mmc_test_prepare(test, 1, 0xDF); in mmc_test_prepare_write()
656 static int mmc_test_prepare_read(struct mmc_test_card *test) in mmc_test_prepare_read() argument
658 return __mmc_test_prepare(test, 0, 0); in mmc_test_prepare_read()
661 static int mmc_test_cleanup(struct mmc_test_card *test) in mmc_test_cleanup() argument
663 return __mmc_test_prepare(test, 1, 0); in mmc_test_cleanup()
667 /* Test execution helpers */
673 static void mmc_test_prepare_broken_mrq(struct mmc_test_card *test, in mmc_test_prepare_broken_mrq() argument
685 mrq->cmd->arg = test->card->rca << 16; in mmc_test_prepare_broken_mrq()
692 static int mmc_test_check_result(struct mmc_test_card *test, in mmc_test_check_result() argument
723 static int mmc_test_check_broken_result(struct mmc_test_card *test, in mmc_test_check_broken_result() argument
791 static int mmc_test_start_areq(struct mmc_test_card *test, in mmc_test_start_areq() argument
795 struct mmc_host *host = test->card->host; in mmc_test_start_areq()
806 err = mmc_test_wait_busy(test); in mmc_test_start_areq()
808 err = mmc_test_check_result(test, prev_mrq); in mmc_test_start_areq()
826 static int mmc_test_nonblock_transfer(struct mmc_test_card *test, in mmc_test_nonblock_transfer() argument
834 struct mmc_test_area *t = &test->area; in mmc_test_nonblock_transfer()
850 mmc_test_prepare_mrq(test, mrq, sg, t->sg_len, dev_addr, in mmc_test_nonblock_transfer()
852 ret = mmc_test_start_areq(test, mrq, prev_mrq); in mmc_test_nonblock_transfer()
864 ret = mmc_test_start_areq(test, NULL, prev_mrq); in mmc_test_nonblock_transfer()
874 static int mmc_test_simple_transfer(struct mmc_test_card *test, in mmc_test_simple_transfer() argument
887 mmc_test_prepare_mrq(test, &mrq, sg, sg_len, dev_addr, in mmc_test_simple_transfer()
890 mmc_wait_for_req(test->card->host, &mrq); in mmc_test_simple_transfer()
892 mmc_test_wait_busy(test); in mmc_test_simple_transfer()
894 return mmc_test_check_result(test, &mrq); in mmc_test_simple_transfer()
900 static int mmc_test_broken_transfer(struct mmc_test_card *test, in mmc_test_broken_transfer() argument
914 sg_init_one(&sg, test->buffer, blocks * blksz); in mmc_test_broken_transfer()
916 mmc_test_prepare_mrq(test, &mrq, &sg, 1, 0, blocks, blksz, write); in mmc_test_broken_transfer()
917 mmc_test_prepare_broken_mrq(test, &mrq, write); in mmc_test_broken_transfer()
919 mmc_wait_for_req(test->card->host, &mrq); in mmc_test_broken_transfer()
921 mmc_test_wait_busy(test); in mmc_test_broken_transfer()
923 return mmc_test_check_broken_result(test, &mrq); in mmc_test_broken_transfer()
927 * Does a complete transfer test where data is also validated
931 static int mmc_test_transfer(struct mmc_test_card *test, in mmc_test_transfer() argument
940 test->scratch[i] = i; in mmc_test_transfer()
942 memset(test->scratch, 0, BUFFER_SIZE); in mmc_test_transfer()
945 sg_copy_from_buffer(sg, sg_len, test->scratch, BUFFER_SIZE); in mmc_test_transfer()
948 ret = mmc_test_set_blksize(test, blksz); in mmc_test_transfer()
952 ret = mmc_test_simple_transfer(test, sg, sg_len, dev_addr, in mmc_test_transfer()
960 ret = mmc_test_set_blksize(test, 512); in mmc_test_transfer()
971 memset(test->buffer, 0, sectors * 512); in mmc_test_transfer()
974 ret = mmc_test_buffer_transfer(test, in mmc_test_transfer()
975 test->buffer + i * 512, in mmc_test_transfer()
982 if (test->buffer[i] != (u8)i) in mmc_test_transfer()
987 if (test->buffer[i] != 0xDF) in mmc_test_transfer()
992 sg_copy_to_buffer(sg, sg_len, test->scratch, BUFFER_SIZE); in mmc_test_transfer()
995 if (test->scratch[i] != (u8)i) in mmc_test_transfer()
1015 static int mmc_test_basic_write(struct mmc_test_card *test) in mmc_test_basic_write() argument
1020 ret = mmc_test_set_blksize(test, 512); in mmc_test_basic_write()
1024 sg_init_one(&sg, test->buffer, 512); in mmc_test_basic_write()
1026 return mmc_test_simple_transfer(test, &sg, 1, 0, 1, 512, 1); in mmc_test_basic_write()
1029 static int mmc_test_basic_read(struct mmc_test_card *test) in mmc_test_basic_read() argument
1034 ret = mmc_test_set_blksize(test, 512); in mmc_test_basic_read()
1038 sg_init_one(&sg, test->buffer, 512); in mmc_test_basic_read()
1040 return mmc_test_simple_transfer(test, &sg, 1, 0, 1, 512, 0); in mmc_test_basic_read()
1043 static int mmc_test_verify_write(struct mmc_test_card *test) in mmc_test_verify_write() argument
1047 sg_init_one(&sg, test->buffer, 512); in mmc_test_verify_write()
1049 return mmc_test_transfer(test, &sg, 1, 0, 1, 512, 1); in mmc_test_verify_write()
1052 static int mmc_test_verify_read(struct mmc_test_card *test) in mmc_test_verify_read() argument
1056 sg_init_one(&sg, test->buffer, 512); in mmc_test_verify_read()
1058 return mmc_test_transfer(test, &sg, 1, 0, 1, 512, 0); in mmc_test_verify_read()
1061 static int mmc_test_multi_write(struct mmc_test_card *test) in mmc_test_multi_write() argument
1066 if (test->card->host->max_blk_count == 1) in mmc_test_multi_write()
1070 size = min(size, test->card->host->max_req_size); in mmc_test_multi_write()
1071 size = min(size, test->card->host->max_seg_size); in mmc_test_multi_write()
1072 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_multi_write()
1077 sg_init_one(&sg, test->buffer, size); in mmc_test_multi_write()
1079 return mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 1); in mmc_test_multi_write()
1082 static int mmc_test_multi_read(struct mmc_test_card *test) in mmc_test_multi_read() argument
1087 if (test->card->host->max_blk_count == 1) in mmc_test_multi_read()
1091 size = min(size, test->card->host->max_req_size); in mmc_test_multi_read()
1092 size = min(size, test->card->host->max_seg_size); in mmc_test_multi_read()
1093 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_multi_read()
1098 sg_init_one(&sg, test->buffer, size); in mmc_test_multi_read()
1100 return mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 0); in mmc_test_multi_read()
1103 static int mmc_test_pow2_write(struct mmc_test_card *test) in mmc_test_pow2_write() argument
1108 if (!test->card->csd.write_partial) in mmc_test_pow2_write()
1112 sg_init_one(&sg, test->buffer, i); in mmc_test_pow2_write()
1113 ret = mmc_test_transfer(test, &sg, 1, 0, 1, i, 1); in mmc_test_pow2_write()
1121 static int mmc_test_pow2_read(struct mmc_test_card *test) in mmc_test_pow2_read() argument
1126 if (!test->card->csd.read_partial) in mmc_test_pow2_read()
1130 sg_init_one(&sg, test->buffer, i); in mmc_test_pow2_read()
1131 ret = mmc_test_transfer(test, &sg, 1, 0, 1, i, 0); in mmc_test_pow2_read()
1139 static int mmc_test_weird_write(struct mmc_test_card *test) in mmc_test_weird_write() argument
1144 if (!test->card->csd.write_partial) in mmc_test_weird_write()
1148 sg_init_one(&sg, test->buffer, i); in mmc_test_weird_write()
1149 ret = mmc_test_transfer(test, &sg, 1, 0, 1, i, 1); in mmc_test_weird_write()
1157 static int mmc_test_weird_read(struct mmc_test_card *test) in mmc_test_weird_read() argument
1162 if (!test->card->csd.read_partial) in mmc_test_weird_read()
1166 sg_init_one(&sg, test->buffer, i); in mmc_test_weird_read()
1167 ret = mmc_test_transfer(test, &sg, 1, 0, 1, i, 0); in mmc_test_weird_read()
1175 static int mmc_test_align_write(struct mmc_test_card *test) in mmc_test_align_write() argument
1181 sg_init_one(&sg, test->buffer + i, 512); in mmc_test_align_write()
1182 ret = mmc_test_transfer(test, &sg, 1, 0, 1, 512, 1); in mmc_test_align_write()
1190 static int mmc_test_align_read(struct mmc_test_card *test) in mmc_test_align_read() argument
1196 sg_init_one(&sg, test->buffer + i, 512); in mmc_test_align_read()
1197 ret = mmc_test_transfer(test, &sg, 1, 0, 1, 512, 0); in mmc_test_align_read()
1205 static int mmc_test_align_multi_write(struct mmc_test_card *test) in mmc_test_align_multi_write() argument
1211 if (test->card->host->max_blk_count == 1) in mmc_test_align_multi_write()
1215 size = min(size, test->card->host->max_req_size); in mmc_test_align_multi_write()
1216 size = min(size, test->card->host->max_seg_size); in mmc_test_align_multi_write()
1217 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_align_multi_write()
1223 sg_init_one(&sg, test->buffer + i, size); in mmc_test_align_multi_write()
1224 ret = mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 1); in mmc_test_align_multi_write()
1232 static int mmc_test_align_multi_read(struct mmc_test_card *test) in mmc_test_align_multi_read() argument
1238 if (test->card->host->max_blk_count == 1) in mmc_test_align_multi_read()
1242 size = min(size, test->card->host->max_req_size); in mmc_test_align_multi_read()
1243 size = min(size, test->card->host->max_seg_size); in mmc_test_align_multi_read()
1244 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_align_multi_read()
1250 sg_init_one(&sg, test->buffer + i, size); in mmc_test_align_multi_read()
1251 ret = mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 0); in mmc_test_align_multi_read()
1259 static int mmc_test_xfersize_write(struct mmc_test_card *test) in mmc_test_xfersize_write() argument
1263 ret = mmc_test_set_blksize(test, 512); in mmc_test_xfersize_write()
1267 return mmc_test_broken_transfer(test, 1, 512, 1); in mmc_test_xfersize_write()
1270 static int mmc_test_xfersize_read(struct mmc_test_card *test) in mmc_test_xfersize_read() argument
1274 ret = mmc_test_set_blksize(test, 512); in mmc_test_xfersize_read()
1278 return mmc_test_broken_transfer(test, 1, 512, 0); in mmc_test_xfersize_read()
1281 static int mmc_test_multi_xfersize_write(struct mmc_test_card *test) in mmc_test_multi_xfersize_write() argument
1285 if (test->card->host->max_blk_count == 1) in mmc_test_multi_xfersize_write()
1288 ret = mmc_test_set_blksize(test, 512); in mmc_test_multi_xfersize_write()
1292 return mmc_test_broken_transfer(test, 2, 512, 1); in mmc_test_multi_xfersize_write()
1295 static int mmc_test_multi_xfersize_read(struct mmc_test_card *test) in mmc_test_multi_xfersize_read() argument
1299 if (test->card->host->max_blk_count == 1) in mmc_test_multi_xfersize_read()
1302 ret = mmc_test_set_blksize(test, 512); in mmc_test_multi_xfersize_read()
1306 return mmc_test_broken_transfer(test, 2, 512, 0); in mmc_test_multi_xfersize_read()
1311 static int mmc_test_write_high(struct mmc_test_card *test) in mmc_test_write_high() argument
1316 sg_set_page(&sg, test->highmem, 512, 0); in mmc_test_write_high()
1318 return mmc_test_transfer(test, &sg, 1, 0, 1, 512, 1); in mmc_test_write_high()
1321 static int mmc_test_read_high(struct mmc_test_card *test) in mmc_test_read_high() argument
1326 sg_set_page(&sg, test->highmem, 512, 0); in mmc_test_read_high()
1328 return mmc_test_transfer(test, &sg, 1, 0, 1, 512, 0); in mmc_test_read_high()
1331 static int mmc_test_multi_write_high(struct mmc_test_card *test) in mmc_test_multi_write_high() argument
1336 if (test->card->host->max_blk_count == 1) in mmc_test_multi_write_high()
1340 size = min(size, test->card->host->max_req_size); in mmc_test_multi_write_high()
1341 size = min(size, test->card->host->max_seg_size); in mmc_test_multi_write_high()
1342 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_multi_write_high()
1348 sg_set_page(&sg, test->highmem, size, 0); in mmc_test_multi_write_high()
1350 return mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 1); in mmc_test_multi_write_high()
1353 static int mmc_test_multi_read_high(struct mmc_test_card *test) in mmc_test_multi_read_high() argument
1358 if (test->card->host->max_blk_count == 1) in mmc_test_multi_read_high()
1362 size = min(size, test->card->host->max_req_size); in mmc_test_multi_read_high()
1363 size = min(size, test->card->host->max_seg_size); in mmc_test_multi_read_high()
1364 size = min(size, test->card->host->max_blk_count * 512); in mmc_test_multi_read_high()
1370 sg_set_page(&sg, test->highmem, size, 0); in mmc_test_multi_read_high()
1372 return mmc_test_transfer(test, &sg, 1, 0, size / 512, 512, 0); in mmc_test_multi_read_high()
1377 static int mmc_test_no_highmem(struct mmc_test_card *test) in mmc_test_no_highmem() argument
1379 pr_info("%s: Highmem not configured - test skipped\n", in mmc_test_no_highmem()
1380 mmc_hostname(test->card->host)); in mmc_test_no_highmem()
1389 static int mmc_test_area_map(struct mmc_test_card *test, unsigned long sz, in mmc_test_area_map() argument
1392 struct mmc_test_area *t = &test->area; in mmc_test_area_map()
1424 mmc_hostname(test->card->host)); in mmc_test_area_map()
1431 static int mmc_test_area_transfer(struct mmc_test_card *test, in mmc_test_area_transfer() argument
1434 struct mmc_test_area *t = &test->area; in mmc_test_area_transfer()
1436 return mmc_test_simple_transfer(test, t->sg, t->sg_len, dev_addr, in mmc_test_area_transfer()
1443 static int mmc_test_area_io_seq(struct mmc_test_card *test, unsigned long sz, in mmc_test_area_io_seq() argument
1457 struct mmc_test_area *t = &test->area; in mmc_test_area_io_seq()
1468 ret = mmc_test_area_map(test, sz, max_scatter, min_sg_len, nonblock); in mmc_test_area_io_seq()
1475 ret = mmc_test_nonblock_transfer(test, dev_addr, write, count); in mmc_test_area_io_seq()
1478 ret = mmc_test_area_transfer(test, dev_addr, write); in mmc_test_area_io_seq()
1489 mmc_test_print_avg_rate(test, sz, count, &ts1, &ts2); in mmc_test_area_io_seq()
1494 static int mmc_test_area_io(struct mmc_test_card *test, unsigned long sz, in mmc_test_area_io() argument
1498 return mmc_test_area_io_seq(test, sz, dev_addr, write, max_scatter, in mmc_test_area_io()
1503 * Write the test area entirely.
1505 static int mmc_test_area_fill(struct mmc_test_card *test) in mmc_test_area_fill() argument
1507 struct mmc_test_area *t = &test->area; in mmc_test_area_fill()
1509 return mmc_test_area_io(test, t->max_tfr, t->dev_addr, 1, 0, 0); in mmc_test_area_fill()
1513 * Erase the test area entirely.
1515 static int mmc_test_area_erase(struct mmc_test_card *test) in mmc_test_area_erase() argument
1517 struct mmc_test_area *t = &test->area; in mmc_test_area_erase()
1519 if (!mmc_can_erase(test->card)) in mmc_test_area_erase()
1522 return mmc_erase(test->card, t->dev_addr, t->max_sz >> 9, in mmc_test_area_erase()
1529 static int mmc_test_area_cleanup(struct mmc_test_card *test) in mmc_test_area_cleanup() argument
1531 struct mmc_test_area *t = &test->area; in mmc_test_area_cleanup()
1541 * Initialize an area for testing large transfers. The test area is set to the
1547 static int mmc_test_area_init(struct mmc_test_card *test, int erase, int fill) in mmc_test_area_init() argument
1549 struct mmc_test_area *t = &test->area; in mmc_test_area_init()
1553 ret = mmc_test_set_blksize(test, 512); in mmc_test_area_init()
1557 /* Make the test area size about 4MiB */ in mmc_test_area_init()
1558 sz = (unsigned long)test->card->pref_erase << 9; in mmc_test_area_init()
1565 t->max_segs = test->card->host->max_segs; in mmc_test_area_init()
1566 t->max_seg_sz = test->card->host->max_seg_size; in mmc_test_area_init()
1570 if (t->max_tfr >> 9 > test->card->host->max_blk_count) in mmc_test_area_init()
1571 t->max_tfr = test->card->host->max_blk_count << 9; in mmc_test_area_init()
1572 if (t->max_tfr > test->card->host->max_req_size) in mmc_test_area_init()
1573 t->max_tfr = test->card->host->max_req_size; in mmc_test_area_init()
1601 t->dev_addr = mmc_test_capacity(test->card) / 2; in mmc_test_area_init()
1605 ret = mmc_test_area_erase(test); in mmc_test_area_init()
1611 ret = mmc_test_area_fill(test); in mmc_test_area_init()
1619 mmc_test_area_cleanup(test); in mmc_test_area_init()
1624 * Prepare for large transfers. Do not erase the test area.
1626 static int mmc_test_area_prepare(struct mmc_test_card *test) in mmc_test_area_prepare() argument
1628 return mmc_test_area_init(test, 0, 0); in mmc_test_area_prepare()
1632 * Prepare for large transfers. Do erase the test area.
1634 static int mmc_test_area_prepare_erase(struct mmc_test_card *test) in mmc_test_area_prepare_erase() argument
1636 return mmc_test_area_init(test, 1, 0); in mmc_test_area_prepare_erase()
1640 * Prepare for large transfers. Erase and fill the test area.
1642 static int mmc_test_area_prepare_fill(struct mmc_test_card *test) in mmc_test_area_prepare_fill() argument
1644 return mmc_test_area_init(test, 1, 1); in mmc_test_area_prepare_fill()
1648 * Test best-case performance. Best-case performance is expected from
1655 static int mmc_test_best_performance(struct mmc_test_card *test, int write, in mmc_test_best_performance() argument
1658 struct mmc_test_area *t = &test->area; in mmc_test_best_performance()
1660 return mmc_test_area_io(test, t->max_tfr, t->dev_addr, write, in mmc_test_best_performance()
1667 static int mmc_test_best_read_performance(struct mmc_test_card *test) in mmc_test_best_read_performance() argument
1669 return mmc_test_best_performance(test, 0, 0); in mmc_test_best_read_performance()
1675 static int mmc_test_best_write_performance(struct mmc_test_card *test) in mmc_test_best_write_performance() argument
1677 return mmc_test_best_performance(test, 1, 0); in mmc_test_best_write_performance()
1683 static int mmc_test_best_read_perf_max_scatter(struct mmc_test_card *test) in mmc_test_best_read_perf_max_scatter() argument
1685 return mmc_test_best_performance(test, 0, 1); in mmc_test_best_read_perf_max_scatter()
1691 static int mmc_test_best_write_perf_max_scatter(struct mmc_test_card *test) in mmc_test_best_write_perf_max_scatter() argument
1693 return mmc_test_best_performance(test, 1, 1); in mmc_test_best_write_perf_max_scatter()
1699 static int mmc_test_profile_read_perf(struct mmc_test_card *test) in mmc_test_profile_read_perf() argument
1701 struct mmc_test_area *t = &test->area; in mmc_test_profile_read_perf()
1708 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); in mmc_test_profile_read_perf()
1714 return mmc_test_area_io(test, sz, dev_addr, 0, 0, 1); in mmc_test_profile_read_perf()
1720 static int mmc_test_profile_write_perf(struct mmc_test_card *test) in mmc_test_profile_write_perf() argument
1722 struct mmc_test_area *t = &test->area; in mmc_test_profile_write_perf()
1727 ret = mmc_test_area_erase(test); in mmc_test_profile_write_perf()
1732 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); in mmc_test_profile_write_perf()
1736 ret = mmc_test_area_erase(test); in mmc_test_profile_write_perf()
1741 return mmc_test_area_io(test, sz, dev_addr, 1, 0, 1); in mmc_test_profile_write_perf()
1747 static int mmc_test_profile_trim_perf(struct mmc_test_card *test) in mmc_test_profile_trim_perf() argument
1749 struct mmc_test_area *t = &test->area; in mmc_test_profile_trim_perf()
1755 if (!mmc_can_trim(test->card)) in mmc_test_profile_trim_perf()
1758 if (!mmc_can_erase(test->card)) in mmc_test_profile_trim_perf()
1764 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); in mmc_test_profile_trim_perf()
1768 mmc_test_print_rate(test, sz, &ts1, &ts2); in mmc_test_profile_trim_perf()
1772 ret = mmc_erase(test->card, dev_addr, sz >> 9, MMC_TRIM_ARG); in mmc_test_profile_trim_perf()
1776 mmc_test_print_rate(test, sz, &ts1, &ts2); in mmc_test_profile_trim_perf()
1780 static int mmc_test_seq_read_perf(struct mmc_test_card *test, unsigned long sz) in mmc_test_seq_read_perf() argument
1782 struct mmc_test_area *t = &test->area; in mmc_test_seq_read_perf()
1791 ret = mmc_test_area_io(test, sz, dev_addr, 0, 0, 0); in mmc_test_seq_read_perf()
1797 mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); in mmc_test_seq_read_perf()
1804 static int mmc_test_profile_seq_read_perf(struct mmc_test_card *test) in mmc_test_profile_seq_read_perf() argument
1806 struct mmc_test_area *t = &test->area; in mmc_test_profile_seq_read_perf()
1811 ret = mmc_test_seq_read_perf(test, sz); in mmc_test_profile_seq_read_perf()
1816 return mmc_test_seq_read_perf(test, sz); in mmc_test_profile_seq_read_perf()
1819 static int mmc_test_seq_write_perf(struct mmc_test_card *test, unsigned long sz) in mmc_test_seq_write_perf() argument
1821 struct mmc_test_area *t = &test->area; in mmc_test_seq_write_perf()
1826 ret = mmc_test_area_erase(test); in mmc_test_seq_write_perf()
1833 ret = mmc_test_area_io(test, sz, dev_addr, 1, 0, 0); in mmc_test_seq_write_perf()
1839 mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); in mmc_test_seq_write_perf()
1846 static int mmc_test_profile_seq_write_perf(struct mmc_test_card *test) in mmc_test_profile_seq_write_perf() argument
1848 struct mmc_test_area *t = &test->area; in mmc_test_profile_seq_write_perf()
1853 ret = mmc_test_seq_write_perf(test, sz); in mmc_test_profile_seq_write_perf()
1858 return mmc_test_seq_write_perf(test, sz); in mmc_test_profile_seq_write_perf()
1864 static int mmc_test_profile_seq_trim_perf(struct mmc_test_card *test) in mmc_test_profile_seq_trim_perf() argument
1866 struct mmc_test_area *t = &test->area; in mmc_test_profile_seq_trim_perf()
1872 if (!mmc_can_trim(test->card)) in mmc_test_profile_seq_trim_perf()
1875 if (!mmc_can_erase(test->card)) in mmc_test_profile_seq_trim_perf()
1879 ret = mmc_test_area_erase(test); in mmc_test_profile_seq_trim_perf()
1882 ret = mmc_test_area_fill(test); in mmc_test_profile_seq_trim_perf()
1889 ret = mmc_erase(test->card, dev_addr, sz >> 9, in mmc_test_profile_seq_trim_perf()
1896 mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); in mmc_test_profile_seq_trim_perf()
1912 static int mmc_test_rnd_perf(struct mmc_test_card *test, int write, int print, in mmc_test_rnd_perf() argument
1922 rnd_addr = mmc_test_capacity(test->card) / 4; in mmc_test_rnd_perf()
1923 range1 = rnd_addr / test->card->pref_erase; in mmc_test_rnd_perf()
1936 dev_addr = rnd_addr + test->card->pref_erase * ea + in mmc_test_rnd_perf()
1938 ret = mmc_test_area_io(test, sz, dev_addr, write, 0, 0); in mmc_test_rnd_perf()
1943 mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); in mmc_test_rnd_perf()
1947 static int mmc_test_random_perf(struct mmc_test_card *test, int write) in mmc_test_random_perf() argument
1949 struct mmc_test_area *t = &test->area; in mmc_test_random_perf()
1957 * the test twice with exactly the same I/O but outputting the in mmc_test_random_perf()
1962 ret = mmc_test_rnd_perf(test, write, 0, sz); in mmc_test_random_perf()
1967 ret = mmc_test_rnd_perf(test, write, 1, sz); in mmc_test_random_perf()
1974 ret = mmc_test_rnd_perf(test, write, 0, sz); in mmc_test_random_perf()
1979 return mmc_test_rnd_perf(test, write, 1, sz); in mmc_test_random_perf()
1985 static int mmc_test_random_read_perf(struct mmc_test_card *test) in mmc_test_random_read_perf() argument
1987 return mmc_test_random_perf(test, 0); in mmc_test_random_read_perf()
1993 static int mmc_test_random_write_perf(struct mmc_test_card *test) in mmc_test_random_write_perf() argument
1995 return mmc_test_random_perf(test, 1); in mmc_test_random_write_perf()
1998 static int mmc_test_seq_perf(struct mmc_test_card *test, int write, in mmc_test_seq_perf() argument
2001 struct mmc_test_area *t = &test->area; in mmc_test_seq_perf()
2024 dev_addr = mmc_test_capacity(test->card) / 4; in mmc_test_seq_perf()
2032 ret = mmc_test_area_io(test, sz, dev_addr, write, in mmc_test_seq_perf()
2040 mmc_test_print_avg_rate(test, sz, cnt, &ts1, &ts2); in mmc_test_seq_perf()
2045 static int mmc_test_large_seq_perf(struct mmc_test_card *test, int write) in mmc_test_large_seq_perf() argument
2050 ret = mmc_test_seq_perf(test, write, 10 * 1024 * 1024, 1); in mmc_test_large_seq_perf()
2055 ret = mmc_test_seq_perf(test, write, 100 * 1024 * 1024, 1); in mmc_test_large_seq_perf()
2060 ret = mmc_test_seq_perf(test, write, 1000 * 1024 * 1024, 1); in mmc_test_large_seq_perf()
2071 static int mmc_test_large_seq_read_perf(struct mmc_test_card *test) in mmc_test_large_seq_read_perf() argument
2073 return mmc_test_large_seq_perf(test, 0); in mmc_test_large_seq_read_perf()
2079 static int mmc_test_large_seq_write_perf(struct mmc_test_card *test) in mmc_test_large_seq_write_perf() argument
2081 return mmc_test_large_seq_perf(test, 1); in mmc_test_large_seq_write_perf()
2084 static int mmc_test_rw_multiple(struct mmc_test_card *test, in mmc_test_rw_multiple() argument
2090 struct mmc_test_area *t = &test->area; in mmc_test_rw_multiple()
2093 /* Set up test area */ in mmc_test_rw_multiple()
2094 if (size > mmc_test_capacity(test->card) / 2 * 512) in mmc_test_rw_multiple()
2095 size = mmc_test_capacity(test->card) / 2 * 512; in mmc_test_rw_multiple()
2098 dev_addr = mmc_test_capacity(test->card) / 4; in mmc_test_rw_multiple()
2109 /* prepare test area */ in mmc_test_rw_multiple()
2110 if (mmc_can_erase(test->card) && in mmc_test_rw_multiple()
2112 ret = mmc_erase(test->card, dev_addr, in mmc_test_rw_multiple()
2113 size / 512, test->card->erase_arg); in mmc_test_rw_multiple()
2115 ret = mmc_erase(test->card, dev_addr, in mmc_test_rw_multiple()
2121 /* Run test */ in mmc_test_rw_multiple()
2122 ret = mmc_test_area_io_seq(test, reqsize, dev_addr, in mmc_test_rw_multiple()
2134 static int mmc_test_rw_multiple_size(struct mmc_test_card *test, in mmc_test_rw_multiple_size() argument
2139 void *pre_req = test->card->host->ops->pre_req; in mmc_test_rw_multiple_size()
2140 void *post_req = test->card->host->ops->post_req; in mmc_test_rw_multiple_size()
2149 ret = mmc_test_rw_multiple(test, rw, rw->bs[i], rw->size, 0); in mmc_test_rw_multiple_size()
2156 static int mmc_test_rw_multiple_sg_len(struct mmc_test_card *test, in mmc_test_rw_multiple_sg_len() argument
2163 ret = mmc_test_rw_multiple(test, rw, 512 * 1024, rw->size, in mmc_test_rw_multiple_sg_len()
2174 static int mmc_test_profile_mult_write_blocking_perf(struct mmc_test_card *test) in mmc_test_profile_mult_write_blocking_perf() argument
2187 return mmc_test_rw_multiple_size(test, &test_data); in mmc_test_profile_mult_write_blocking_perf()
2193 static int mmc_test_profile_mult_write_nonblock_perf(struct mmc_test_card *test) in mmc_test_profile_mult_write_nonblock_perf() argument
2206 return mmc_test_rw_multiple_size(test, &test_data); in mmc_test_profile_mult_write_nonblock_perf()
2212 static int mmc_test_profile_mult_read_blocking_perf(struct mmc_test_card *test) in mmc_test_profile_mult_read_blocking_perf() argument
2225 return mmc_test_rw_multiple_size(test, &test_data); in mmc_test_profile_mult_read_blocking_perf()
2231 static int mmc_test_profile_mult_read_nonblock_perf(struct mmc_test_card *test) in mmc_test_profile_mult_read_nonblock_perf() argument
2244 return mmc_test_rw_multiple_size(test, &test_data); in mmc_test_profile_mult_read_nonblock_perf()
2250 static int mmc_test_profile_sglen_wr_blocking_perf(struct mmc_test_card *test) in mmc_test_profile_sglen_wr_blocking_perf() argument
2263 return mmc_test_rw_multiple_sg_len(test, &test_data); in mmc_test_profile_sglen_wr_blocking_perf()
2269 static int mmc_test_profile_sglen_wr_nonblock_perf(struct mmc_test_card *test) in mmc_test_profile_sglen_wr_nonblock_perf() argument
2282 return mmc_test_rw_multiple_sg_len(test, &test_data); in mmc_test_profile_sglen_wr_nonblock_perf()
2288 static int mmc_test_profile_sglen_r_blocking_perf(struct mmc_test_card *test) in mmc_test_profile_sglen_r_blocking_perf() argument
2301 return mmc_test_rw_multiple_sg_len(test, &test_data); in mmc_test_profile_sglen_r_blocking_perf()
2307 static int mmc_test_profile_sglen_r_nonblock_perf(struct mmc_test_card *test) in mmc_test_profile_sglen_r_nonblock_perf() argument
2320 return mmc_test_rw_multiple_sg_len(test, &test_data); in mmc_test_profile_sglen_r_nonblock_perf()
2326 static int mmc_test_reset(struct mmc_test_card *test) in mmc_test_reset() argument
2328 struct mmc_card *card = test->card; in mmc_test_reset()
2348 static int mmc_test_send_status(struct mmc_test_card *test, in mmc_test_send_status() argument
2354 if (!mmc_host_is_spi(test->card->host)) in mmc_test_send_status()
2355 cmd->arg = test->card->rca << 16; in mmc_test_send_status()
2358 return mmc_wait_for_cmd(test->card->host, cmd, 0); in mmc_test_send_status()
2361 static int mmc_test_ongoing_transfer(struct mmc_test_card *test, in mmc_test_ongoing_transfer() argument
2366 struct mmc_host *host = test->card->host; in mmc_test_ongoing_transfer()
2367 struct mmc_test_area *t = &test->area; in mmc_test_ongoing_transfer()
2383 mmc_test_prepare_mrq(test, mrq, t->sg, t->sg_len, dev_addr, t->blocks, in mmc_test_ongoing_transfer()
2395 ret = mmc_test_start_areq(test, mrq, NULL); in mmc_test_ongoing_transfer()
2407 cmd_ret = mmc_test_send_status(test, &rq->status); in mmc_test_ongoing_transfer()
2431 ret = mmc_test_start_areq(test, NULL, mrq); in mmc_test_ongoing_transfer()
2433 mmc_wait_for_req_done(test->card->host, mrq); in mmc_test_ongoing_transfer()
2452 mmc_hostname(test->card->host), status, cmd_ret); in mmc_test_ongoing_transfer()
2455 ret = mmc_test_check_result(test, mrq); in mmc_test_ongoing_transfer()
2459 ret = mmc_test_wait_busy(test); in mmc_test_ongoing_transfer()
2465 mmc_hostname(test->card->host), count, t->blocks); in mmc_test_ongoing_transfer()
2475 static int __mmc_test_cmds_during_tfr(struct mmc_test_card *test, in __mmc_test_cmds_during_tfr() argument
2479 struct mmc_test_area *t = &test->area; in __mmc_test_cmds_during_tfr()
2482 if (!(test->card->host->caps & MMC_CAP_CMD_DURING_TFR)) in __mmc_test_cmds_during_tfr()
2485 ret = mmc_test_area_map(test, sz, 0, 0, use_areq); in __mmc_test_cmds_during_tfr()
2489 ret = mmc_test_ongoing_transfer(test, t->dev_addr, use_sbc, 0, write, in __mmc_test_cmds_during_tfr()
2494 return mmc_test_ongoing_transfer(test, t->dev_addr, use_sbc, 1, write, in __mmc_test_cmds_during_tfr()
2498 static int mmc_test_cmds_during_tfr(struct mmc_test_card *test, int use_sbc, in mmc_test_cmds_during_tfr() argument
2501 struct mmc_test_area *t = &test->area; in mmc_test_cmds_during_tfr()
2506 ret = __mmc_test_cmds_during_tfr(test, sz, use_sbc, write, in mmc_test_cmds_during_tfr()
2517 static int mmc_test_cmds_during_read(struct mmc_test_card *test) in mmc_test_cmds_during_read() argument
2519 return mmc_test_cmds_during_tfr(test, 0, 0, 0); in mmc_test_cmds_during_read()
2525 static int mmc_test_cmds_during_write(struct mmc_test_card *test) in mmc_test_cmds_during_write() argument
2527 return mmc_test_cmds_during_tfr(test, 0, 1, 0); in mmc_test_cmds_during_write()
2533 static int mmc_test_cmds_during_read_cmd23(struct mmc_test_card *test) in mmc_test_cmds_during_read_cmd23() argument
2535 return mmc_test_cmds_during_tfr(test, 1, 0, 0); in mmc_test_cmds_during_read_cmd23()
2541 static int mmc_test_cmds_during_write_cmd23(struct mmc_test_card *test) in mmc_test_cmds_during_write_cmd23() argument
2543 return mmc_test_cmds_during_tfr(test, 1, 1, 0); in mmc_test_cmds_during_write_cmd23()
2549 static int mmc_test_cmds_during_read_cmd23_nonblock(struct mmc_test_card *test) in mmc_test_cmds_during_read_cmd23_nonblock() argument
2551 return mmc_test_cmds_during_tfr(test, 1, 0, 1); in mmc_test_cmds_during_read_cmd23_nonblock()
2557 static int mmc_test_cmds_during_write_cmd23_nonblock(struct mmc_test_card *test) in mmc_test_cmds_during_write_cmd23_nonblock() argument
2559 return mmc_test_cmds_during_tfr(test, 1, 1, 1); in mmc_test_cmds_during_write_cmd23_nonblock()
2886 .name = "Reset test",
2937 static void mmc_test_run(struct mmc_test_card *test, int testcase) in mmc_test_run() argument
2942 mmc_hostname(test->card->host), mmc_card_id(test->card)); in mmc_test_run()
2944 mmc_claim_host(test->card->host); in mmc_test_run()
2952 pr_info("%s: Test case %d. %s...\n", in mmc_test_run()
2953 mmc_hostname(test->card->host), i + 1, in mmc_test_run()
2957 ret = mmc_test_cases[i].prepare(test); in mmc_test_run()
2960 mmc_hostname(test->card->host), in mmc_test_run()
2971 gr->card = test->card; in mmc_test_run()
2981 test->gr = gr; in mmc_test_run()
2984 ret = mmc_test_cases[i].run(test); in mmc_test_run()
2988 mmc_hostname(test->card->host)); in mmc_test_run()
2992 mmc_hostname(test->card->host)); in mmc_test_run()
2996 mmc_hostname(test->card->host)); in mmc_test_run()
3000 mmc_hostname(test->card->host)); in mmc_test_run()
3004 mmc_hostname(test->card->host), ret); in mmc_test_run()
3012 ret = mmc_test_cases[i].cleanup(test); in mmc_test_run()
3015 mmc_hostname(test->card->host), in mmc_test_run()
3021 mmc_release_host(test->card->host); in mmc_test_run()
3024 mmc_hostname(test->card->host)); in mmc_test_run()
3066 seq_printf(sf, "Test %d: %d\n", gr->testcase + 1, gr->result); in mtf_test_show()
3091 struct mmc_test_card *test; local
3099 test = kzalloc(sizeof(*test), GFP_KERNEL);
3100 if (!test)
3104 * Remove all test cases associated with given card. Thus we have only
3109 test->card = card;
3111 test->buffer = kzalloc(BUFFER_SIZE, GFP_KERNEL);
3113 test->highmem = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, BUFFER_ORDER);
3117 if (test->buffer && test->highmem) {
3119 if (test->buffer) {
3122 mmc_test_run(test, testcase);
3127 __free_pages(test->highmem, BUFFER_ORDER);
3129 kfree(test->buffer);
3130 kfree(test);
3205 ret = __mmc_test_register_dbgfs_file(card, "test", S_IWUSR | S_IRUGO,
3282 MODULE_DESCRIPTION("Multimedia Card (MMC) host test driver");