diff options
author | Adrian Hunter <adrian.hunter@nokia.com> | 2010-08-11 17:17:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-12 11:43:30 -0400 |
commit | dfe86cba7676d58db8de7e623f5e72f1b0d3ca35 (patch) | |
tree | ed7e6a267c50e0ba2374dc6895515d7a100961a3 /include/linux/mmc/mmc.h | |
parent | 81d73a32d775ae9674ea6edf0b5b721fc3bc57d9 (diff) |
mmc: add erase, secure erase, trim and secure trim operations
SD/MMC cards tend to support an erase operation. In addition, eMMC v4.4
cards can support secure erase, trim and secure trim operations that are
all variants of the basic erase command.
SD/MMC device attributes "erase_size" and "preferred_erase_size" have been
added.
"erase_size" is the minimum size, in bytes, of an erase operation. For
MMC, "erase_size" is the erase group size reported by the card. Note that
"erase_size" does not apply to trim or secure trim operations where the
minimum size is always one 512 byte sector. For SD, "erase_size" is 512
if the card is block-addressed, 0 otherwise.
SD/MMC cards can erase an arbitrarily large area up to and
including the whole card. When erasing a large area it may
be desirable to do it in smaller chunks for three reasons:
1. A single erase command will make all other I/O on the card
wait. This is not a problem if the whole card is being erased, but
erasing one partition will make I/O for another partition on the
same card wait for the duration of the erase - which could be a
several minutes.
2. To be able to inform the user of erase progress.
3. The erase timeout becomes too large to be very useful.
Because the erase timeout contains a margin which is multiplied by
the size of the erase area, the value can end up being several
minutes for large areas.
"erase_size" is not the most efficient unit to erase (especially for SD
where it is just one sector), hence "preferred_erase_size" provides a good
chunk size for erasing large areas.
For MMC, "preferred_erase_size" is the high-capacity erase size if a card
specifies one, otherwise it is based on the capacity of the card.
For SD, "preferred_erase_size" is the allocation unit size specified by
the card.
"preferred_erase_size" is in bytes.
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Cc: Kyungmin Park <kmpark@infradead.org>
Cc: Madhusudhan Chikkature <madhu.cr@ti.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mmc/mmc.h')
-rw-r--r-- | include/linux/mmc/mmc.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 52ce98866287..dd11ae51fb68 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h | |||
@@ -251,13 +251,21 @@ struct _mmc_csd { | |||
251 | * EXT_CSD fields | 251 | * EXT_CSD fields |
252 | */ | 252 | */ |
253 | 253 | ||
254 | #define EXT_CSD_BUS_WIDTH 183 /* R/W */ | 254 | #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ |
255 | #define EXT_CSD_HS_TIMING 185 /* R/W */ | 255 | #define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ |
256 | #define EXT_CSD_CARD_TYPE 196 /* RO */ | 256 | #define EXT_CSD_BUS_WIDTH 183 /* R/W */ |
257 | #define EXT_CSD_STRUCTURE 194 /* RO */ | 257 | #define EXT_CSD_HS_TIMING 185 /* R/W */ |
258 | #define EXT_CSD_REV 192 /* RO */ | 258 | #define EXT_CSD_REV 192 /* RO */ |
259 | #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ | 259 | #define EXT_CSD_STRUCTURE 194 /* RO */ |
260 | #define EXT_CSD_S_A_TIMEOUT 217 | 260 | #define EXT_CSD_CARD_TYPE 196 /* RO */ |
261 | #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ | ||
262 | #define EXT_CSD_S_A_TIMEOUT 217 /* RO */ | ||
263 | #define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ | ||
264 | #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ | ||
265 | #define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ | ||
266 | #define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ | ||
267 | #define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ | ||
268 | #define EXT_CSD_TRIM_MULT 232 /* RO */ | ||
261 | 269 | ||
262 | /* | 270 | /* |
263 | * EXT_CSD field definitions | 271 | * EXT_CSD field definitions |
@@ -275,6 +283,10 @@ struct _mmc_csd { | |||
275 | #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ | 283 | #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ |
276 | #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ | 284 | #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ |
277 | 285 | ||
286 | #define EXT_CSD_SEC_ER_EN BIT(0) | ||
287 | #define EXT_CSD_SEC_BD_BLK_EN BIT(2) | ||
288 | #define EXT_CSD_SEC_GB_CL_EN BIT(4) | ||
289 | |||
278 | /* | 290 | /* |
279 | * MMC_SWITCH access modes | 291 | * MMC_SWITCH access modes |
280 | */ | 292 | */ |