Skip to content

Commit b062136

Browse files
ahunter6Ulf Hansson
authored andcommitted
mmc: mmc_test: Add re-tuning test
Add a test to repeatedly re-tune in between random reads. The test is non-destructive of data on the card and runs for 30 seconds. It can be repeated to test for longer durations. If re-tuning is not supported, the test is skipped. Example: # echo 'mmc1:0001' > /sys/bus/mmc/drivers/mmcblk/unbind # echo 'mmc1:0001' > /sys/bus/mmc/drivers/mmc_test/bind [ 36.642257] mmc_test mmc1:0001: Card claimed for testing. # cat /sys/kernel/debug/mmc1/mmc1\:0001/testlist | grep tuning 52: Re-tuning reliability # echo 52 > /sys/kernel/debug/mmc1/mmc1\:0001/test [ 91.522555] mmc1: Starting tests of card mmc1:0001... [ 91.528425] mmc1: Test case 52. Re-tuning reliability... [ 121.536682] mmc1: Result: OK [ 121.539572] mmc1: Tests completed. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20231214090902.43628-1-adrian.hunter@intel.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 84a6be7 commit b062136

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

drivers/mmc/core/mmc_test.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ static unsigned int mmc_test_rnd_num(unsigned int rnd_cnt)
19041904
}
19051905

19061906
static int mmc_test_rnd_perf(struct mmc_test_card *test, int write, int print,
1907-
unsigned long sz)
1907+
unsigned long sz, int secs, int force_retuning)
19081908
{
19091909
unsigned int dev_addr, cnt, rnd_addr, range1, range2, last_ea = 0, ea;
19101910
unsigned int ssz;
@@ -1921,14 +1921,16 @@ static int mmc_test_rnd_perf(struct mmc_test_card *test, int write, int print,
19211921
for (cnt = 0; cnt < UINT_MAX; cnt++) {
19221922
ktime_get_ts64(&ts2);
19231923
ts = timespec64_sub(ts2, ts1);
1924-
if (ts.tv_sec >= 10)
1924+
if (ts.tv_sec >= secs)
19251925
break;
19261926
ea = mmc_test_rnd_num(range1);
19271927
if (ea == last_ea)
19281928
ea -= 1;
19291929
last_ea = ea;
19301930
dev_addr = rnd_addr + test->card->pref_erase * ea +
19311931
ssz * mmc_test_rnd_num(range2);
1932+
if (force_retuning)
1933+
mmc_retune_needed(test->card->host);
19321934
ret = mmc_test_area_io(test, sz, dev_addr, write, 0, 0);
19331935
if (ret)
19341936
return ret;
@@ -1953,24 +1955,35 @@ static int mmc_test_random_perf(struct mmc_test_card *test, int write)
19531955
*/
19541956
if (write) {
19551957
next = rnd_next;
1956-
ret = mmc_test_rnd_perf(test, write, 0, sz);
1958+
ret = mmc_test_rnd_perf(test, write, 0, sz, 10, 0);
19571959
if (ret)
19581960
return ret;
19591961
rnd_next = next;
19601962
}
1961-
ret = mmc_test_rnd_perf(test, write, 1, sz);
1963+
ret = mmc_test_rnd_perf(test, write, 1, sz, 10, 0);
19621964
if (ret)
19631965
return ret;
19641966
}
19651967
sz = t->max_tfr;
19661968
if (write) {
19671969
next = rnd_next;
1968-
ret = mmc_test_rnd_perf(test, write, 0, sz);
1970+
ret = mmc_test_rnd_perf(test, write, 0, sz, 10, 0);
19691971
if (ret)
19701972
return ret;
19711973
rnd_next = next;
19721974
}
1973-
return mmc_test_rnd_perf(test, write, 1, sz);
1975+
return mmc_test_rnd_perf(test, write, 1, sz, 10, 0);
1976+
}
1977+
1978+
static int mmc_test_retuning(struct mmc_test_card *test)
1979+
{
1980+
if (!mmc_can_retune(test->card->host)) {
1981+
pr_info("%s: No retuning - test skipped\n",
1982+
mmc_hostname(test->card->host));
1983+
return RESULT_UNSUP_HOST;
1984+
}
1985+
1986+
return mmc_test_rnd_perf(test, 0, 0, 8192, 30, 1);
19741987
}
19751988

19761989
/*
@@ -2921,6 +2934,14 @@ static const struct mmc_test_case mmc_test_cases[] = {
29212934
.run = mmc_test_cmds_during_write_cmd23_nonblock,
29222935
.cleanup = mmc_test_area_cleanup,
29232936
},
2937+
2938+
{
2939+
.name = "Re-tuning reliability",
2940+
.prepare = mmc_test_area_prepare,
2941+
.run = mmc_test_retuning,
2942+
.cleanup = mmc_test_area_cleanup,
2943+
},
2944+
29242945
};
29252946

29262947
static DEFINE_MUTEX(mmc_test_lock);

0 commit comments

Comments
 (0)