762
* Tests nonblock transfer with certain parameters
764
static void mmc_test_nonblock_reset(struct mmc_request *mrq,
765
struct mmc_command *cmd,
766
struct mmc_command *stop,
767
struct mmc_data *data)
769
memset(mrq, 0, sizeof(struct mmc_request));
770
memset(cmd, 0, sizeof(struct mmc_command));
771
memset(data, 0, sizeof(struct mmc_data));
772
memset(stop, 0, sizeof(struct mmc_command));
778
static int mmc_test_nonblock_transfer(struct mmc_test_card *test,
779
struct scatterlist *sg, unsigned sg_len,
780
unsigned dev_addr, unsigned blocks,
781
unsigned blksz, int write, int count)
783
struct mmc_request mrq1;
784
struct mmc_command cmd1;
785
struct mmc_command stop1;
786
struct mmc_data data1;
788
struct mmc_request mrq2;
789
struct mmc_command cmd2;
790
struct mmc_command stop2;
791
struct mmc_data data2;
793
struct mmc_test_async_req test_areq[2];
794
struct mmc_async_req *done_areq;
795
struct mmc_async_req *cur_areq = &test_areq[0].areq;
796
struct mmc_async_req *other_areq = &test_areq[1].areq;
800
test_areq[0].test = test;
801
test_areq[1].test = test;
803
mmc_test_nonblock_reset(&mrq1, &cmd1, &stop1, &data1);
804
mmc_test_nonblock_reset(&mrq2, &cmd2, &stop2, &data2);
806
cur_areq->mrq = &mrq1;
807
cur_areq->err_check = mmc_test_check_result_async;
808
other_areq->mrq = &mrq2;
809
other_areq->err_check = mmc_test_check_result_async;
811
for (i = 0; i < count; i++) {
812
mmc_test_prepare_mrq(test, cur_areq->mrq, sg, sg_len, dev_addr,
813
blocks, blksz, write);
814
done_areq = mmc_start_req(test->card->host, cur_areq, &ret);
816
if (ret || (!done_areq && i > 0))
820
if (done_areq->mrq == &mrq2)
821
mmc_test_nonblock_reset(&mrq2, &cmd2,
824
mmc_test_nonblock_reset(&mrq1, &cmd1,
827
done_areq = cur_areq;
828
cur_areq = other_areq;
829
other_areq = done_areq;
833
done_areq = mmc_start_req(test->card->host, NULL, &ret);
723
841
* Tests a basic transfer with certain parameters
725
843
static int mmc_test_simple_transfer(struct mmc_test_card *test,
1339
* Map and transfer bytes.
1457
* Map and transfer bytes for multiple transfers.
1459
static int mmc_test_area_io_seq(struct mmc_test_card *test, unsigned long sz,
1460
unsigned int dev_addr, int write,
1461
int max_scatter, int timed, int count,
1462
bool nonblock, int min_sg_len)
1464
struct timespec ts1, ts2;
1467
struct mmc_test_area *t = &test->area;
1470
* In the case of a maximally scattered transfer, the maximum transfer
1471
* size is further limited by using PAGE_SIZE segments.
1474
struct mmc_test_area *t = &test->area;
1475
unsigned long max_tfr;
1477
if (t->max_seg_sz >= PAGE_SIZE)
1478
max_tfr = t->max_segs * PAGE_SIZE;
1480
max_tfr = t->max_segs * t->max_seg_sz;
1485
ret = mmc_test_area_map(test, sz, max_scatter, min_sg_len);
1490
getnstimeofday(&ts1);
1492
ret = mmc_test_nonblock_transfer(test, t->sg, t->sg_len,
1493
dev_addr, t->blocks, 512, write, count);
1495
for (i = 0; i < count && ret == 0; i++) {
1496
ret = mmc_test_area_transfer(test, dev_addr, write);
1497
dev_addr += sz >> 9;
1504
getnstimeofday(&ts2);
1507
mmc_test_print_avg_rate(test, sz, count, &ts1, &ts2);
1341
1512
static int mmc_test_area_io(struct mmc_test_card *test, unsigned long sz,
1342
1513
unsigned int dev_addr, int write, int max_scatter,
1345
struct timespec ts1, ts2;
1349
* In the case of a maximally scattered transfer, the maximum transfer
1350
* size is further limited by using PAGE_SIZE segments.
1353
struct mmc_test_area *t = &test->area;
1354
unsigned long max_tfr;
1356
if (t->max_seg_sz >= PAGE_SIZE)
1357
max_tfr = t->max_segs * PAGE_SIZE;
1359
max_tfr = t->max_segs * t->max_seg_sz;
1364
ret = mmc_test_area_map(test, sz, max_scatter);
1369
getnstimeofday(&ts1);
1371
ret = mmc_test_area_transfer(test, dev_addr, write);
1376
getnstimeofday(&ts2);
1379
mmc_test_print_rate(test, sz, &ts1, &ts2);
1516
return mmc_test_area_io_seq(test, sz, dev_addr, write, max_scatter,
1517
timed, 1, false, 0);
1954
2090
return mmc_test_large_seq_perf(test, 1);
2093
static int mmc_test_rw_multiple(struct mmc_test_card *test,
2094
struct mmc_test_multiple_rw *tdata,
2095
unsigned int reqsize, unsigned int size,
2098
unsigned int dev_addr;
2099
struct mmc_test_area *t = &test->area;
2102
/* Set up test area */
2103
if (size > mmc_test_capacity(test->card) / 2 * 512)
2104
size = mmc_test_capacity(test->card) / 2 * 512;
2105
if (reqsize > t->max_tfr)
2106
reqsize = t->max_tfr;
2107
dev_addr = mmc_test_capacity(test->card) / 4;
2108
if ((dev_addr & 0xffff0000))
2109
dev_addr &= 0xffff0000; /* Round to 64MiB boundary */
2111
dev_addr &= 0xfffff800; /* Round to 1MiB boundary */
2118
/* prepare test area */
2119
if (mmc_can_erase(test->card) &&
2120
tdata->prepare & MMC_TEST_PREP_ERASE) {
2121
ret = mmc_erase(test->card, dev_addr,
2122
size / 512, MMC_SECURE_ERASE_ARG);
2124
ret = mmc_erase(test->card, dev_addr,
2125
size / 512, MMC_ERASE_ARG);
2131
ret = mmc_test_area_io_seq(test, reqsize, dev_addr,
2132
tdata->do_write, 0, 1, size / reqsize,
2133
tdata->do_nonblock_req, min_sg_len);
2139
pr_info("[%s] error\n", __func__);
2143
static int mmc_test_rw_multiple_size(struct mmc_test_card *test,
2144
struct mmc_test_multiple_rw *rw)
2148
void *pre_req = test->card->host->ops->pre_req;
2149
void *post_req = test->card->host->ops->post_req;
2151
if (rw->do_nonblock_req &&
2152
((!pre_req && post_req) || (pre_req && !post_req))) {
2153
pr_info("error: only one of pre/post is defined\n");
2157
for (i = 0 ; i < rw->len && ret == 0; i++) {
2158
ret = mmc_test_rw_multiple(test, rw, rw->bs[i], rw->size, 0);
2165
static int mmc_test_rw_multiple_sg_len(struct mmc_test_card *test,
2166
struct mmc_test_multiple_rw *rw)
2171
for (i = 0 ; i < rw->len && ret == 0; i++) {
2172
ret = mmc_test_rw_multiple(test, rw, 512*1024, rw->size,
2181
* Multiple blocking write 4k to 4 MB chunks
2183
static int mmc_test_profile_mult_write_blocking_perf(struct mmc_test_card *test)
2185
unsigned int bs[] = {1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16,
2186
1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 22};
2187
struct mmc_test_multiple_rw test_data = {
2189
.size = TEST_AREA_MAX_SIZE,
2190
.len = ARRAY_SIZE(bs),
2192
.do_nonblock_req = false,
2193
.prepare = MMC_TEST_PREP_ERASE,
2196
return mmc_test_rw_multiple_size(test, &test_data);
2200
* Multiple non-blocking write 4k to 4 MB chunks
2202
static int mmc_test_profile_mult_write_nonblock_perf(struct mmc_test_card *test)
2204
unsigned int bs[] = {1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16,
2205
1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 22};
2206
struct mmc_test_multiple_rw test_data = {
2208
.size = TEST_AREA_MAX_SIZE,
2209
.len = ARRAY_SIZE(bs),
2211
.do_nonblock_req = true,
2212
.prepare = MMC_TEST_PREP_ERASE,
2215
return mmc_test_rw_multiple_size(test, &test_data);
2219
* Multiple blocking read 4k to 4 MB chunks
2221
static int mmc_test_profile_mult_read_blocking_perf(struct mmc_test_card *test)
2223
unsigned int bs[] = {1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16,
2224
1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 22};
2225
struct mmc_test_multiple_rw test_data = {
2227
.size = TEST_AREA_MAX_SIZE,
2228
.len = ARRAY_SIZE(bs),
2230
.do_nonblock_req = false,
2231
.prepare = MMC_TEST_PREP_NONE,
2234
return mmc_test_rw_multiple_size(test, &test_data);
2238
* Multiple non-blocking read 4k to 4 MB chunks
2240
static int mmc_test_profile_mult_read_nonblock_perf(struct mmc_test_card *test)
2242
unsigned int bs[] = {1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16,
2243
1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 22};
2244
struct mmc_test_multiple_rw test_data = {
2246
.size = TEST_AREA_MAX_SIZE,
2247
.len = ARRAY_SIZE(bs),
2249
.do_nonblock_req = true,
2250
.prepare = MMC_TEST_PREP_NONE,
2253
return mmc_test_rw_multiple_size(test, &test_data);
2257
* Multiple blocking write 1 to 512 sg elements
2259
static int mmc_test_profile_sglen_wr_blocking_perf(struct mmc_test_card *test)
2261
unsigned int sg_len[] = {1, 1 << 3, 1 << 4, 1 << 5, 1 << 6,
2262
1 << 7, 1 << 8, 1 << 9};
2263
struct mmc_test_multiple_rw test_data = {
2265
.size = TEST_AREA_MAX_SIZE,
2266
.len = ARRAY_SIZE(sg_len),
2268
.do_nonblock_req = false,
2269
.prepare = MMC_TEST_PREP_ERASE,
2272
return mmc_test_rw_multiple_sg_len(test, &test_data);
2276
* Multiple non-blocking write 1 to 512 sg elements
2278
static int mmc_test_profile_sglen_wr_nonblock_perf(struct mmc_test_card *test)
2280
unsigned int sg_len[] = {1, 1 << 3, 1 << 4, 1 << 5, 1 << 6,
2281
1 << 7, 1 << 8, 1 << 9};
2282
struct mmc_test_multiple_rw test_data = {
2284
.size = TEST_AREA_MAX_SIZE,
2285
.len = ARRAY_SIZE(sg_len),
2287
.do_nonblock_req = true,
2288
.prepare = MMC_TEST_PREP_ERASE,
2291
return mmc_test_rw_multiple_sg_len(test, &test_data);
2295
* Multiple blocking read 1 to 512 sg elements
2297
static int mmc_test_profile_sglen_r_blocking_perf(struct mmc_test_card *test)
2299
unsigned int sg_len[] = {1, 1 << 3, 1 << 4, 1 << 5, 1 << 6,
2300
1 << 7, 1 << 8, 1 << 9};
2301
struct mmc_test_multiple_rw test_data = {
2303
.size = TEST_AREA_MAX_SIZE,
2304
.len = ARRAY_SIZE(sg_len),
2306
.do_nonblock_req = false,
2307
.prepare = MMC_TEST_PREP_NONE,
2310
return mmc_test_rw_multiple_sg_len(test, &test_data);
2314
* Multiple non-blocking read 1 to 512 sg elements
2316
static int mmc_test_profile_sglen_r_nonblock_perf(struct mmc_test_card *test)
2318
unsigned int sg_len[] = {1, 1 << 3, 1 << 4, 1 << 5, 1 << 6,
2319
1 << 7, 1 << 8, 1 << 9};
2320
struct mmc_test_multiple_rw test_data = {
2322
.size = TEST_AREA_MAX_SIZE,
2323
.len = ARRAY_SIZE(sg_len),
2325
.do_nonblock_req = true,
2326
.prepare = MMC_TEST_PREP_NONE,
2329
return mmc_test_rw_multiple_sg_len(test, &test_data);
2333
* eMMC hardware reset.
2335
static int mmc_test_hw_reset(struct mmc_test_card *test)
2337
struct mmc_card *card = test->card;
2338
struct mmc_host *host = card->host;
2341
err = mmc_hw_reset_check(host);
2348
if (err != -EOPNOTSUPP)
2351
if (!mmc_can_reset(card))
2352
return RESULT_UNSUP_CARD;
2354
return RESULT_UNSUP_HOST;
1957
2357
static const struct mmc_test_case mmc_test_cases[] = {
1959
2359
.name = "Basic write (no data verification)",
2221
2621
.cleanup = mmc_test_area_cleanup,
2625
.name = "Write performance with blocking req 4k to 4MB",
2626
.prepare = mmc_test_area_prepare,
2627
.run = mmc_test_profile_mult_write_blocking_perf,
2628
.cleanup = mmc_test_area_cleanup,
2632
.name = "Write performance with non-blocking req 4k to 4MB",
2633
.prepare = mmc_test_area_prepare,
2634
.run = mmc_test_profile_mult_write_nonblock_perf,
2635
.cleanup = mmc_test_area_cleanup,
2639
.name = "Read performance with blocking req 4k to 4MB",
2640
.prepare = mmc_test_area_prepare,
2641
.run = mmc_test_profile_mult_read_blocking_perf,
2642
.cleanup = mmc_test_area_cleanup,
2646
.name = "Read performance with non-blocking req 4k to 4MB",
2647
.prepare = mmc_test_area_prepare,
2648
.run = mmc_test_profile_mult_read_nonblock_perf,
2649
.cleanup = mmc_test_area_cleanup,
2653
.name = "Write performance blocking req 1 to 512 sg elems",
2654
.prepare = mmc_test_area_prepare,
2655
.run = mmc_test_profile_sglen_wr_blocking_perf,
2656
.cleanup = mmc_test_area_cleanup,
2660
.name = "Write performance non-blocking req 1 to 512 sg elems",
2661
.prepare = mmc_test_area_prepare,
2662
.run = mmc_test_profile_sglen_wr_nonblock_perf,
2663
.cleanup = mmc_test_area_cleanup,
2667
.name = "Read performance blocking req 1 to 512 sg elems",
2668
.prepare = mmc_test_area_prepare,
2669
.run = mmc_test_profile_sglen_r_blocking_perf,
2670
.cleanup = mmc_test_area_cleanup,
2674
.name = "Read performance non-blocking req 1 to 512 sg elems",
2675
.prepare = mmc_test_area_prepare,
2676
.run = mmc_test_profile_sglen_r_nonblock_perf,
2677
.cleanup = mmc_test_area_cleanup,
2681
.name = "eMMC hardware reset",
2682
.run = mmc_test_hw_reset,
2226
2686
static DEFINE_MUTEX(mmc_test_lock);