[U-Boot] [PATCH V3 2/2] mmc: sd: optimize erase

Jaehoon Chung jh80.chung at samsung.com
Tue Aug 30 11:34:40 CEST 2016


Hi Peng,

On 08/23/2016 05:12 PM, Peng Fan wrote:
> To SD, there is no erase group, then the value erase_grp_size
> will be default 1. When erasing SD blocks, the blocks will be
> erased one by one, which is time consuming.
> 
> We use AU_SIZE as a group to speed up the erasing.
> 
> Erasing 4MB with a SD2.0 Card with AU_SIZE 4MB.
> `time mmc erase 0x100000 0x2000`
> time: 44.856 seconds (before optimization)
> time: 0.335 seconds  (after optimization)
> 
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> Cc: Jaehoon Chung <jh80.chung at samsung.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Cc: Stefan Wahren <stefan.wahren at i2se.com>
> Cc: Clemens Gruber <clemens.gruber at pqgruber.com>
> Cc: Kever Yang <kever.yang at rock-chips.com>
> Cc: Eric Nelson <eric at nelint.com>
> Cc: Stephen Warren <swarren at nvidia.com>

Applied on u-boot-mmc.
Thanks!

Best Regards,
Jaehoon Chung

> ---
> 
> V3:
>  No change.
> 
> V2:
>  Add test results.
> 
>  drivers/mmc/mmc_write.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
> index 0f8b5c7..2289640 100644
> --- a/drivers/mmc/mmc_write.c
> +++ b/drivers/mmc/mmc_write.c
> @@ -100,8 +100,13 @@ unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
>  		       & ~(mmc->erase_grp_size - 1)) - 1);
>  
>  	while (blk < blkcnt) {
> -		blk_r = ((blkcnt - blk) > mmc->erase_grp_size) ?
> -			mmc->erase_grp_size : (blkcnt - blk);
> +		if (IS_SD(mmc) && mmc->ssr.au) {
> +			blk_r = ((blkcnt - blk) > mmc->ssr.au) ?
> +				mmc->ssr.au : (blkcnt - blk);
> +		} else {
> +			blk_r = ((blkcnt - blk) > mmc->erase_grp_size) ?
> +				mmc->erase_grp_size : (blkcnt - blk);
> +		}
>  		err = mmc_erase_t(mmc, start + blk, blk_r);
>  		if (err)
>  			break;
> 



More information about the U-Boot mailing list