1. 内核选项配置
(a) CONFIG_MMC_BLOCK=n,CONFIG_MMC_TEST=y。或者CONFIG_MMC_BLOCK=y, CONFIG_MMC_TEST=y。如果选用后一种配置,需要再系统起来后,在总线driver中手动bind和unbind,见后面;
(b) CONFIG_DEBUG_FS=y,CONFIG_DEBUG_KERNEL=y,这两项在我们项目的kernel的defconfig中已经配置,所以不需要进行改动;
接下来,编译kernel并启动系统。
2. 挂载debugfs
mount -t debugfs none /sys/kernel/debug
3. 手动unbind和bind
如果在步骤1中CONFIG_MMC_BLOCK=y,那么需要先执行执行如下操作:
/sys/bus/mmc/drivers/mmcblk # echo mmc:0001 > unbind
/sys/bus/mmc/drivers/mmc_test # echo mmc:0001 > bind
mmc_test mmc0:0001: Card claimed for testing.
/sys/kernel/debug/mmc0/mmc0:0001 # ls
state status test testlist
/sys/kernel/debug/mmc0/mmc0:0001 # cat testlist
0: Run all tests
1: Basic write (no data verification)
2: Basic read (no data verification)
3: Basic write (with data verification)
4: Basic read (with data verification)
5: Multi-block write
6: Multi-block read
7: Power of two block writes
8: Power of two block reads
9: Weird sized block writes
10: Weird sized block reads
11: Badly aligned write
12: Badly aligned read
13: Badly aligned multi-block write
14: Badly aligned multi-block read
15: Correct xfer_size at write (start failure)
16: Correct xfer_size at read (start failure)
17: Correct xfer_size at write (midway failure)
18: Correct xfer_size at read (midway failure)
19: Highmem write
20: Highmem read
21: Multi-block highmem write
22: Multi-block highmem read
23: Best-case read performance
24: Best-case write performance
25: Best-case read performance into scattered pages
26: Best-case write performance from scattered pages
27: Single read performance by transfer size
28: Single write performance by transfer size
29: Single trim performance by transfer size
30: Consecutive read performance by transfer size
31: Consecutive write performance by transfer size
32: Consecutive trim performance by transfer size
33: Random read performance by transfer size
34: Random write performance by transfer size
35: Large sequential read into scattered pages
36: Large sequential write from scattered pages
37: Write performance with blocking req 4k to 4MB
38: Write performance with non-blocking req 4k to 4MB
39: Read performance with blocking req 4k to 4MB
40: Read performance with non-blocking req 4k to 4MB
41: Write performance blocking req 1 to 512 sg elems
42: Write performance non-blocking req 1 to 512 sg elems
43: Read performance blocking req 1 to 512 sg elems
44: Read performance non-blocking req 1 to 512 sg elems
45: Reset test
46: Commands during read - no Set Block Count (CMD23)
47: Commands during write - no Set Block Count (CMD23)
48: Commands during read - use Set Block Count (CMD23)
49: Commands during write - use Set Block Count (CMD23)
50: Commands during non-blocking read - use Set Block Count (CMD23)
51: Commands during non-blocking write - use Set Block Count (CMD23)
4. 启动测试
/sys/kernel/debug/mmc0/mmc0:0001 # echo 24 > test
mmc0: Starting tests of card mmc0:0001...
mmc0: Test case 24. Best-case write performance...
[mmc_can_erase][2421]: caps:0x42f, cmdclass:0x5b5, erase_size:0x1
[mmc_erase][2395]: from:0x3a44000, to:0x3a45fff
[mmc_erase][2413]: mmc_do_erase start
[mmc_do_erase][2202]: SD_ERASE_WR_BLK_START start
[mmc_do_erase][2218]: SD_ERASE_WR_BLK_END start
[mmc_do_erase][2246]: MMC_ERASE start
[mmc_do_erase][2271]: MMC_SEND_STATUS start
mmc0: Transfer of 1 x 1024 sectors (1 x 512 KiB) took 0.076557166 seconds (6848 kB/s, 6687 KiB/s, 13.06 IOPS, sg_len 1)
mmc0: Result: OK
mmc0: Tests completed.