lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <83edf9a1-1712-5388-a3fa-d685f1f581df@intel.com>
Date:   Mon, 14 Mar 2022 08:54:11 +0200
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Michael Wu <michael@...winnertech.com>, ulf.hansson@...aro.org,
        avri.altman@....com, beanhuo@...ron.com, porzio@...il.com
Cc:     lixiang <lixiang@...winnertech.com>, linux-mmc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mmc: block: enable cache-flushing when mmc cache is on

On 12/03/2022 06:43, Michael Wu wrote:
> The mmc core enable cache on default. But it only enables cache-flushing
> when host supports cmd23 and eMMC supports reliable write.
> For hosts which do not support cmd23 or eMMCs which do not support
> reliable write, the cache can not be flushed by `sync` command.
> This may leads to cache data lost.
> This patch enables cache-flushing as long as cache is enabled, no
> matter host supports cmd23 and/or eMMC supports reliable write or not.
> 

Fixes tag?

> Signed-off-by: Michael Wu <michael@...winnertech.com>
> ---
>  drivers/mmc/core/block.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 689eb9afeeed..1e508c079c1e 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -2279,6 +2279,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
>  	struct mmc_blk_data *md;
>  	int devidx, ret;
>  	char cap_str[10];
> +	bool enable_cache = false;
> +	bool enable_fua = false;
>  
>  	devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
>  	if (devidx < 0) {
> @@ -2375,12 +2377,18 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
>  			md->flags |= MMC_BLK_CMD23;
>  	}
>  
> -	if (mmc_card_mmc(card) &&
> -	    md->flags & MMC_BLK_CMD23 &&
> -	    ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
> -	     card->ext_csd.rel_sectors)) {
> -		md->flags |= MMC_BLK_REL_WR;
> -		blk_queue_write_cache(md->queue.queue, true, true);
> +	if (mmc_card_mmc(card)) {
> +		if (md->flags & MMC_BLK_CMD23 &&
> +			((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
> +			card->ext_csd.rel_sectors)) {
> +			md->flags |= MMC_BLK_REL_WR;
> +			enable_fua = true;
> +		}
> +
> +		if (mmc_cache_enabled(card->host))
> +			enable_cache = true;
> +
> +		blk_queue_write_cache(md->queue.queue, enable_cache, enable_fua);
>  	}

Seems like we should inform block layer about SD card cache also

>  
>  	string_get_size((u64)size, 512, STRING_UNITS_2,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ