diff options
Diffstat (limited to 'Documentation/driver-api/mmc')
-rw-r--r-- | Documentation/driver-api/mmc/index.rst | 13 | ||||
-rw-r--r-- | Documentation/driver-api/mmc/mmc-async-req.rst | 98 | ||||
-rw-r--r-- | Documentation/driver-api/mmc/mmc-dev-attrs.rst | 91 | ||||
-rw-r--r-- | Documentation/driver-api/mmc/mmc-dev-parts.rst | 41 | ||||
-rw-r--r-- | Documentation/driver-api/mmc/mmc-tools.rst | 37 |
5 files changed, 280 insertions, 0 deletions
diff --git a/Documentation/driver-api/mmc/index.rst b/Documentation/driver-api/mmc/index.rst new file mode 100644 index 000000000000..7339736ac774 --- /dev/null +++ b/Documentation/driver-api/mmc/index.rst | |||
@@ -0,0 +1,13 @@ | |||
1 | .. SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
3 | ======================== | ||
4 | MMC/SD/SDIO card support | ||
5 | ======================== | ||
6 | |||
7 | .. toctree:: | ||
8 | :maxdepth: 1 | ||
9 | |||
10 | mmc-dev-attrs | ||
11 | mmc-dev-parts | ||
12 | mmc-async-req | ||
13 | mmc-tools | ||
diff --git a/Documentation/driver-api/mmc/mmc-async-req.rst b/Documentation/driver-api/mmc/mmc-async-req.rst new file mode 100644 index 000000000000..0f7197c9c3b5 --- /dev/null +++ b/Documentation/driver-api/mmc/mmc-async-req.rst | |||
@@ -0,0 +1,98 @@ | |||
1 | ======================== | ||
2 | MMC Asynchronous Request | ||
3 | ======================== | ||
4 | |||
5 | Rationale | ||
6 | ========= | ||
7 | |||
8 | How significant is the cache maintenance overhead? | ||
9 | |||
10 | It depends. Fast eMMC and multiple cache levels with speculative cache | ||
11 | pre-fetch makes the cache overhead relatively significant. If the DMA | ||
12 | preparations for the next request are done in parallel with the current | ||
13 | transfer, the DMA preparation overhead would not affect the MMC performance. | ||
14 | |||
15 | The intention of non-blocking (asynchronous) MMC requests is to minimize the | ||
16 | time between when an MMC request ends and another MMC request begins. | ||
17 | |||
18 | Using mmc_wait_for_req(), the MMC controller is idle while dma_map_sg and | ||
19 | dma_unmap_sg are processing. Using non-blocking MMC requests makes it | ||
20 | possible to prepare the caches for next job in parallel with an active | ||
21 | MMC request. | ||
22 | |||
23 | MMC block driver | ||
24 | ================ | ||
25 | |||
26 | The mmc_blk_issue_rw_rq() in the MMC block driver is made non-blocking. | ||
27 | |||
28 | The increase in throughput is proportional to the time it takes to | ||
29 | prepare (major part of preparations are dma_map_sg() and dma_unmap_sg()) | ||
30 | a request and how fast the memory is. The faster the MMC/SD is the | ||
31 | more significant the prepare request time becomes. Roughly the expected | ||
32 | performance gain is 5% for large writes and 10% on large reads on a L2 cache | ||
33 | platform. In power save mode, when clocks run on a lower frequency, the DMA | ||
34 | preparation may cost even more. As long as these slower preparations are run | ||
35 | in parallel with the transfer performance won't be affected. | ||
36 | |||
37 | Details on measurements from IOZone and mmc_test | ||
38 | ================================================ | ||
39 | |||
40 | https://wiki.linaro.org/WorkingGroups/Kernel/Specs/StoragePerfMMC-async-req | ||
41 | |||
42 | MMC core API extension | ||
43 | ====================== | ||
44 | |||
45 | There is one new public function mmc_start_req(). | ||
46 | |||
47 | It starts a new MMC command request for a host. The function isn't | ||
48 | truly non-blocking. If there is an ongoing async request it waits | ||
49 | for completion of that request and starts the new one and returns. It | ||
50 | doesn't wait for the new request to complete. If there is no ongoing | ||
51 | request it starts the new request and returns immediately. | ||
52 | |||
53 | MMC host extensions | ||
54 | =================== | ||
55 | |||
56 | There are two optional members in the mmc_host_ops -- pre_req() and | ||
57 | post_req() -- that the host driver may implement in order to move work | ||
58 | to before and after the actual mmc_host_ops.request() function is called. | ||
59 | |||
60 | In the DMA case pre_req() may do dma_map_sg() and prepare the DMA | ||
61 | descriptor, and post_req() runs the dma_unmap_sg(). | ||
62 | |||
63 | Optimize for the first request | ||
64 | ============================== | ||
65 | |||
66 | The first request in a series of requests can't be prepared in parallel | ||
67 | with the previous transfer, since there is no previous request. | ||
68 | |||
69 | The argument is_first_req in pre_req() indicates that there is no previous | ||
70 | request. The host driver may optimize for this scenario to minimize | ||
71 | the performance loss. A way to optimize for this is to split the current | ||
72 | request in two chunks, prepare the first chunk and start the request, | ||
73 | and finally prepare the second chunk and start the transfer. | ||
74 | |||
75 | Pseudocode to handle is_first_req scenario with minimal prepare overhead:: | ||
76 | |||
77 | if (is_first_req && req->size > threshold) | ||
78 | /* start MMC transfer for the complete transfer size */ | ||
79 | mmc_start_command(MMC_CMD_TRANSFER_FULL_SIZE); | ||
80 | |||
81 | /* | ||
82 | * Begin to prepare DMA while cmd is being processed by MMC. | ||
83 | * The first chunk of the request should take the same time | ||
84 | * to prepare as the "MMC process command time". | ||
85 | * If prepare time exceeds MMC cmd time | ||
86 | * the transfer is delayed, guesstimate max 4k as first chunk size. | ||
87 | */ | ||
88 | prepare_1st_chunk_for_dma(req); | ||
89 | /* flush pending desc to the DMAC (dmaengine.h) */ | ||
90 | dma_issue_pending(req->dma_desc); | ||
91 | |||
92 | prepare_2nd_chunk_for_dma(req); | ||
93 | /* | ||
94 | * The second issue_pending should be called before MMC runs out | ||
95 | * of the first chunk. If the MMC runs out of the first data chunk | ||
96 | * before this call, the transfer is delayed. | ||
97 | */ | ||
98 | dma_issue_pending(req->dma_desc); | ||
diff --git a/Documentation/driver-api/mmc/mmc-dev-attrs.rst b/Documentation/driver-api/mmc/mmc-dev-attrs.rst new file mode 100644 index 000000000000..4f44b1b730d6 --- /dev/null +++ b/Documentation/driver-api/mmc/mmc-dev-attrs.rst | |||
@@ -0,0 +1,91 @@ | |||
1 | ================================== | ||
2 | SD and MMC Block Device Attributes | ||
3 | ================================== | ||
4 | |||
5 | These attributes are defined for the block devices associated with the | ||
6 | SD or MMC device. | ||
7 | |||
8 | The following attributes are read/write. | ||
9 | |||
10 | ======== =============================================== | ||
11 | force_ro Enforce read-only access even if write protect switch is off. | ||
12 | ======== =============================================== | ||
13 | |||
14 | SD and MMC Device Attributes | ||
15 | ============================ | ||
16 | |||
17 | All attributes are read-only. | ||
18 | |||
19 | ====================== =============================================== | ||
20 | cid Card Identification Register | ||
21 | csd Card Specific Data Register | ||
22 | scr SD Card Configuration Register (SD only) | ||
23 | date Manufacturing Date (from CID Register) | ||
24 | fwrev Firmware/Product Revision (from CID Register) | ||
25 | (SD and MMCv1 only) | ||
26 | hwrev Hardware/Product Revision (from CID Register) | ||
27 | (SD and MMCv1 only) | ||
28 | manfid Manufacturer ID (from CID Register) | ||
29 | name Product Name (from CID Register) | ||
30 | oemid OEM/Application ID (from CID Register) | ||
31 | prv Product Revision (from CID Register) | ||
32 | (SD and MMCv4 only) | ||
33 | serial Product Serial Number (from CID Register) | ||
34 | erase_size Erase group size | ||
35 | preferred_erase_size Preferred erase size | ||
36 | raw_rpmb_size_mult RPMB partition size | ||
37 | rel_sectors Reliable write sector count | ||
38 | ocr Operation Conditions Register | ||
39 | dsr Driver Stage Register | ||
40 | cmdq_en Command Queue enabled: | ||
41 | |||
42 | 1 => enabled, 0 => not enabled | ||
43 | ====================== =============================================== | ||
44 | |||
45 | Note on Erase Size and Preferred Erase Size: | ||
46 | |||
47 | "erase_size" is the minimum size, in bytes, of an erase | ||
48 | operation. For MMC, "erase_size" is the erase group size | ||
49 | reported by the card. Note that "erase_size" does not apply | ||
50 | to trim or secure trim operations where the minimum size is | ||
51 | always one 512 byte sector. For SD, "erase_size" is 512 | ||
52 | if the card is block-addressed, 0 otherwise. | ||
53 | |||
54 | SD/MMC cards can erase an arbitrarily large area up to and | ||
55 | including the whole card. When erasing a large area it may | ||
56 | be desirable to do it in smaller chunks for three reasons: | ||
57 | |||
58 | 1. A single erase command will make all other I/O on | ||
59 | the card wait. This is not a problem if the whole card | ||
60 | is being erased, but erasing one partition will make | ||
61 | I/O for another partition on the same card wait for the | ||
62 | duration of the erase - which could be a several | ||
63 | minutes. | ||
64 | 2. To be able to inform the user of erase progress. | ||
65 | 3. The erase timeout becomes too large to be very | ||
66 | useful. Because the erase timeout contains a margin | ||
67 | which is multiplied by the size of the erase area, | ||
68 | the value can end up being several minutes for large | ||
69 | areas. | ||
70 | |||
71 | "erase_size" is not the most efficient unit to erase | ||
72 | (especially for SD where it is just one sector), | ||
73 | hence "preferred_erase_size" provides a good chunk | ||
74 | size for erasing large areas. | ||
75 | |||
76 | For MMC, "preferred_erase_size" is the high-capacity | ||
77 | erase size if a card specifies one, otherwise it is | ||
78 | based on the capacity of the card. | ||
79 | |||
80 | For SD, "preferred_erase_size" is the allocation unit | ||
81 | size specified by the card. | ||
82 | |||
83 | "preferred_erase_size" is in bytes. | ||
84 | |||
85 | Note on raw_rpmb_size_mult: | ||
86 | |||
87 | "raw_rpmb_size_mult" is a multiple of 128kB block. | ||
88 | |||
89 | RPMB size in byte is calculated by using the following equation: | ||
90 | |||
91 | RPMB partition size = 128kB x raw_rpmb_size_mult | ||
diff --git a/Documentation/driver-api/mmc/mmc-dev-parts.rst b/Documentation/driver-api/mmc/mmc-dev-parts.rst new file mode 100644 index 000000000000..995922f1f744 --- /dev/null +++ b/Documentation/driver-api/mmc/mmc-dev-parts.rst | |||
@@ -0,0 +1,41 @@ | |||
1 | ============================ | ||
2 | SD and MMC Device Partitions | ||
3 | ============================ | ||
4 | |||
5 | Device partitions are additional logical block devices present on the | ||
6 | SD/MMC device. | ||
7 | |||
8 | As of this writing, MMC boot partitions as supported and exposed as | ||
9 | /dev/mmcblkXboot0 and /dev/mmcblkXboot1, where X is the index of the | ||
10 | parent /dev/mmcblkX. | ||
11 | |||
12 | MMC Boot Partitions | ||
13 | =================== | ||
14 | |||
15 | Read and write access is provided to the two MMC boot partitions. Due to | ||
16 | the sensitive nature of the boot partition contents, which often store | ||
17 | a bootloader or bootloader configuration tables crucial to booting the | ||
18 | platform, write access is disabled by default to reduce the chance of | ||
19 | accidental bricking. | ||
20 | |||
21 | To enable write access to /dev/mmcblkXbootY, disable the forced read-only | ||
22 | access with:: | ||
23 | |||
24 | echo 0 > /sys/block/mmcblkXbootY/force_ro | ||
25 | |||
26 | To re-enable read-only access:: | ||
27 | |||
28 | echo 1 > /sys/block/mmcblkXbootY/force_ro | ||
29 | |||
30 | The boot partitions can also be locked read only until the next power on, | ||
31 | with:: | ||
32 | |||
33 | echo 1 > /sys/block/mmcblkXbootY/ro_lock_until_next_power_on | ||
34 | |||
35 | This is a feature of the card and not of the kernel. If the card does | ||
36 | not support boot partition locking, the file will not exist. If the | ||
37 | feature has been disabled on the card, the file will be read-only. | ||
38 | |||
39 | The boot partitions can also be locked permanently, but this feature is | ||
40 | not accessible through sysfs in order to avoid accidental or malicious | ||
41 | bricking. | ||
diff --git a/Documentation/driver-api/mmc/mmc-tools.rst b/Documentation/driver-api/mmc/mmc-tools.rst new file mode 100644 index 000000000000..54406093768b --- /dev/null +++ b/Documentation/driver-api/mmc/mmc-tools.rst | |||
@@ -0,0 +1,37 @@ | |||
1 | ====================== | ||
2 | MMC tools introduction | ||
3 | ====================== | ||
4 | |||
5 | There is one MMC test tools called mmc-utils, which is maintained by Chris Ball, | ||
6 | you can find it at the below public git repository: | ||
7 | |||
8 | http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/ | ||
9 | |||
10 | Functions | ||
11 | ========= | ||
12 | |||
13 | The mmc-utils tools can do the following: | ||
14 | |||
15 | - Print and parse extcsd data. | ||
16 | - Determine the eMMC writeprotect status. | ||
17 | - Set the eMMC writeprotect status. | ||
18 | - Set the eMMC data sector size to 4KB by disabling emulation. | ||
19 | - Create general purpose partition. | ||
20 | - Enable the enhanced user area. | ||
21 | - Enable write reliability per partition. | ||
22 | - Print the response to STATUS_SEND (CMD13). | ||
23 | - Enable the boot partition. | ||
24 | - Set Boot Bus Conditions. | ||
25 | - Enable the eMMC BKOPS feature. | ||
26 | - Permanently enable the eMMC H/W Reset feature. | ||
27 | - Permanently disable the eMMC H/W Reset feature. | ||
28 | - Send Sanitize command. | ||
29 | - Program authentication key for the device. | ||
30 | - Counter value for the rpmb device will be read to stdout. | ||
31 | - Read from rpmb device to output. | ||
32 | - Write to rpmb device from data file. | ||
33 | - Enable the eMMC cache feature. | ||
34 | - Disable the eMMC cache feature. | ||
35 | - Print and parse CID data. | ||
36 | - Print and parse CSD data. | ||
37 | - Print and parse SCR data. | ||