mmc: erase: Use TRIM erase when available
authorLoic Poulain <loic.poulain@linaro.org>
Thu, 26 Jan 2023 09:24:18 +0000 (10:24 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 10 Apr 2023 03:17:24 +0000 (12:17 +0900)
commit67642c1254fc7b1392c2745ead609255345f2d25
treeab1570d07f5f0c373400b57202f44ca1ed235a4c
parenteeb739a6fde6e926b389b253668b2a8fd09a58c7
mmc: erase: Use TRIM erase when available

The default erase command applies on erase group unit, and
simply round down to erase group size. When the start block
is not aligned to erase group size (e.g. erasing partition)
it causes unwanted erasing of the previous blocks, part of
the same erase group (e.g. owned by other logical partition,
or by the partition table itself).

To prevent this issue, a simple solution is to use TRIM as
argument of the Erase command, which is usually supported
with eMMC > 4.0, and allow to apply erase operation to write
blocks instead of erase group

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/mmc/mmc_write.c