aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card/mmc_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/card/mmc_test.c')
-rw-r--r--drivers/mmc/card/mmc_test.c65
1 files changed, 48 insertions, 17 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 2bf229acd3b8..b038c4a9468b 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -22,6 +22,7 @@
22#include <linux/debugfs.h> 22#include <linux/debugfs.h>
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/module.h>
25 26
26#define RESULT_OK 0 27#define RESULT_OK 0
27#define RESULT_FAIL 1 28#define RESULT_FAIL 1
@@ -250,7 +251,7 @@ static int mmc_test_wait_busy(struct mmc_test_card *test)
250 if (!busy && mmc_test_busy(&cmd)) { 251 if (!busy && mmc_test_busy(&cmd)) {
251 busy = 1; 252 busy = 1;
252 if (test->card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) 253 if (test->card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)
253 printk(KERN_INFO "%s: Warning: Host did not " 254 pr_info("%s: Warning: Host did not "
254 "wait for busy state to end.\n", 255 "wait for busy state to end.\n",
255 mmc_hostname(test->card->host)); 256 mmc_hostname(test->card->host));
256 } 257 }
@@ -552,7 +553,7 @@ static void mmc_test_print_rate(struct mmc_test_card *test, uint64_t bytes,
552 rate = mmc_test_rate(bytes, &ts); 553 rate = mmc_test_rate(bytes, &ts);
553 iops = mmc_test_rate(100, &ts); /* I/O ops per sec x 100 */ 554 iops = mmc_test_rate(100, &ts); /* I/O ops per sec x 100 */
554 555
555 printk(KERN_INFO "%s: Transfer of %u sectors (%u%s KiB) took %lu.%09lu " 556 pr_info("%s: Transfer of %u sectors (%u%s KiB) took %lu.%09lu "
556 "seconds (%u kB/s, %u KiB/s, %u.%02u IOPS)\n", 557 "seconds (%u kB/s, %u KiB/s, %u.%02u IOPS)\n",
557 mmc_hostname(test->card->host), sectors, sectors >> 1, 558 mmc_hostname(test->card->host), sectors, sectors >> 1,
558 (sectors & 1 ? ".5" : ""), (unsigned long)ts.tv_sec, 559 (sectors & 1 ? ".5" : ""), (unsigned long)ts.tv_sec,
@@ -578,7 +579,7 @@ static void mmc_test_print_avg_rate(struct mmc_test_card *test, uint64_t bytes,
578 rate = mmc_test_rate(tot, &ts); 579 rate = mmc_test_rate(tot, &ts);
579 iops = mmc_test_rate(count * 100, &ts); /* I/O ops per sec x 100 */ 580 iops = mmc_test_rate(count * 100, &ts); /* I/O ops per sec x 100 */
580 581
581 printk(KERN_INFO "%s: Transfer of %u x %u sectors (%u x %u%s KiB) took " 582 pr_info("%s: Transfer of %u x %u sectors (%u x %u%s KiB) took "
582 "%lu.%09lu seconds (%u kB/s, %u KiB/s, " 583 "%lu.%09lu seconds (%u kB/s, %u KiB/s, "
583 "%u.%02u IOPS, sg_len %d)\n", 584 "%u.%02u IOPS, sg_len %d)\n",
584 mmc_hostname(test->card->host), count, sectors, count, 585 mmc_hostname(test->card->host), count, sectors, count,
@@ -1408,7 +1409,7 @@ static int mmc_test_multi_read_high(struct mmc_test_card *test)
1408 1409
1409static int mmc_test_no_highmem(struct mmc_test_card *test) 1410static int mmc_test_no_highmem(struct mmc_test_card *test)
1410{ 1411{
1411 printk(KERN_INFO "%s: Highmem not configured - test skipped\n", 1412 pr_info("%s: Highmem not configured - test skipped\n",
1412 mmc_hostname(test->card->host)); 1413 mmc_hostname(test->card->host));
1413 return 0; 1414 return 0;
1414} 1415}
@@ -1435,7 +1436,7 @@ static int mmc_test_area_map(struct mmc_test_card *test, unsigned long sz,
1435 t->max_seg_sz, &t->sg_len, min_sg_len); 1436 t->max_seg_sz, &t->sg_len, min_sg_len);
1436 } 1437 }
1437 if (err) 1438 if (err)
1438 printk(KERN_INFO "%s: Failed to map sg list\n", 1439 pr_info("%s: Failed to map sg list\n",
1439 mmc_hostname(test->card->host)); 1440 mmc_hostname(test->card->host));
1440 return err; 1441 return err;
1441} 1442}
@@ -2135,7 +2136,7 @@ static int mmc_test_rw_multiple(struct mmc_test_card *test,
2135 2136
2136 return ret; 2137 return ret;
2137 err: 2138 err:
2138 printk(KERN_INFO "[%s] error\n", __func__); 2139 pr_info("[%s] error\n", __func__);
2139 return ret; 2140 return ret;
2140} 2141}
2141 2142
@@ -2149,7 +2150,7 @@ static int mmc_test_rw_multiple_size(struct mmc_test_card *test,
2149 2150
2150 if (rw->do_nonblock_req && 2151 if (rw->do_nonblock_req &&
2151 ((!pre_req && post_req) || (pre_req && !post_req))) { 2152 ((!pre_req && post_req) || (pre_req && !post_req))) {
2152 printk(KERN_INFO "error: only one of pre/post is defined\n"); 2153 pr_info("error: only one of pre/post is defined\n");
2153 return -EINVAL; 2154 return -EINVAL;
2154 } 2155 }
2155 2156
@@ -2328,6 +2329,31 @@ static int mmc_test_profile_sglen_r_nonblock_perf(struct mmc_test_card *test)
2328 return mmc_test_rw_multiple_sg_len(test, &test_data); 2329 return mmc_test_rw_multiple_sg_len(test, &test_data);
2329} 2330}
2330 2331
2332/*
2333 * eMMC hardware reset.
2334 */
2335static int mmc_test_hw_reset(struct mmc_test_card *test)
2336{
2337 struct mmc_card *card = test->card;
2338 struct mmc_host *host = card->host;
2339 int err;
2340
2341 err = mmc_hw_reset_check(host);
2342 if (!err)
2343 return RESULT_OK;
2344
2345 if (err == -ENOSYS)
2346 return RESULT_FAIL;
2347
2348 if (err != -EOPNOTSUPP)
2349 return err;
2350
2351 if (!mmc_can_reset(card))
2352 return RESULT_UNSUP_CARD;
2353
2354 return RESULT_UNSUP_HOST;
2355}
2356
2331static const struct mmc_test_case mmc_test_cases[] = { 2357static const struct mmc_test_case mmc_test_cases[] = {
2332 { 2358 {
2333 .name = "Basic write (no data verification)", 2359 .name = "Basic write (no data verification)",
@@ -2650,6 +2676,11 @@ static const struct mmc_test_case mmc_test_cases[] = {
2650 .run = mmc_test_profile_sglen_r_nonblock_perf, 2676 .run = mmc_test_profile_sglen_r_nonblock_perf,
2651 .cleanup = mmc_test_area_cleanup, 2677 .cleanup = mmc_test_area_cleanup,
2652 }, 2678 },
2679
2680 {
2681 .name = "eMMC hardware reset",
2682 .run = mmc_test_hw_reset,
2683 },
2653}; 2684};
2654 2685
2655static DEFINE_MUTEX(mmc_test_lock); 2686static DEFINE_MUTEX(mmc_test_lock);
@@ -2660,7 +2691,7 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
2660{ 2691{
2661 int i, ret; 2692 int i, ret;
2662 2693
2663 printk(KERN_INFO "%s: Starting tests of card %s...\n", 2694 pr_info("%s: Starting tests of card %s...\n",
2664 mmc_hostname(test->card->host), mmc_card_id(test->card)); 2695 mmc_hostname(test->card->host), mmc_card_id(test->card));
2665 2696
2666 mmc_claim_host(test->card->host); 2697 mmc_claim_host(test->card->host);
@@ -2671,14 +2702,14 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
2671 if (testcase && ((i + 1) != testcase)) 2702 if (testcase && ((i + 1) != testcase))
2672 continue; 2703 continue;
2673 2704
2674 printk(KERN_INFO "%s: Test case %d. %s...\n", 2705 pr_info("%s: Test case %d. %s...\n",
2675 mmc_hostname(test->card->host), i + 1, 2706 mmc_hostname(test->card->host), i + 1,
2676 mmc_test_cases[i].name); 2707 mmc_test_cases[i].name);
2677 2708
2678 if (mmc_test_cases[i].prepare) { 2709 if (mmc_test_cases[i].prepare) {
2679 ret = mmc_test_cases[i].prepare(test); 2710 ret = mmc_test_cases[i].prepare(test);
2680 if (ret) { 2711 if (ret) {
2681 printk(KERN_INFO "%s: Result: Prepare " 2712 pr_info("%s: Result: Prepare "
2682 "stage failed! (%d)\n", 2713 "stage failed! (%d)\n",
2683 mmc_hostname(test->card->host), 2714 mmc_hostname(test->card->host),
2684 ret); 2715 ret);
@@ -2708,25 +2739,25 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
2708 ret = mmc_test_cases[i].run(test); 2739 ret = mmc_test_cases[i].run(test);
2709 switch (ret) { 2740 switch (ret) {
2710 case RESULT_OK: 2741 case RESULT_OK:
2711 printk(KERN_INFO "%s: Result: OK\n", 2742 pr_info("%s: Result: OK\n",
2712 mmc_hostname(test->card->host)); 2743 mmc_hostname(test->card->host));
2713 break; 2744 break;
2714 case RESULT_FAIL: 2745 case RESULT_FAIL:
2715 printk(KERN_INFO "%s: Result: FAILED\n", 2746 pr_info("%s: Result: FAILED\n",
2716 mmc_hostname(test->card->host)); 2747 mmc_hostname(test->card->host));
2717 break; 2748 break;
2718 case RESULT_UNSUP_HOST: 2749 case RESULT_UNSUP_HOST:
2719 printk(KERN_INFO "%s: Result: UNSUPPORTED " 2750 pr_info("%s: Result: UNSUPPORTED "
2720 "(by host)\n", 2751 "(by host)\n",
2721 mmc_hostname(test->card->host)); 2752 mmc_hostname(test->card->host));
2722 break; 2753 break;
2723 case RESULT_UNSUP_CARD: 2754 case RESULT_UNSUP_CARD:
2724 printk(KERN_INFO "%s: Result: UNSUPPORTED " 2755 pr_info("%s: Result: UNSUPPORTED "
2725 "(by card)\n", 2756 "(by card)\n",
2726 mmc_hostname(test->card->host)); 2757 mmc_hostname(test->card->host));
2727 break; 2758 break;
2728 default: 2759 default:
2729 printk(KERN_INFO "%s: Result: ERROR (%d)\n", 2760 pr_info("%s: Result: ERROR (%d)\n",
2730 mmc_hostname(test->card->host), ret); 2761 mmc_hostname(test->card->host), ret);
2731 } 2762 }
2732 2763
@@ -2737,7 +2768,7 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
2737 if (mmc_test_cases[i].cleanup) { 2768 if (mmc_test_cases[i].cleanup) {
2738 ret = mmc_test_cases[i].cleanup(test); 2769 ret = mmc_test_cases[i].cleanup(test);
2739 if (ret) { 2770 if (ret) {
2740 printk(KERN_INFO "%s: Warning: Cleanup " 2771 pr_info("%s: Warning: Cleanup "
2741 "stage failed! (%d)\n", 2772 "stage failed! (%d)\n",
2742 mmc_hostname(test->card->host), 2773 mmc_hostname(test->card->host),
2743 ret); 2774 ret);
@@ -2747,7 +2778,7 @@ static void mmc_test_run(struct mmc_test_card *test, int testcase)
2747 2778
2748 mmc_release_host(test->card->host); 2779 mmc_release_host(test->card->host);
2749 2780
2750 printk(KERN_INFO "%s: Tests completed.\n", 2781 pr_info("%s: Tests completed.\n",
2751 mmc_hostname(test->card->host)); 2782 mmc_hostname(test->card->host));
2752} 2783}
2753 2784