linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Wu <michael@allwinnertech.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
	ulf.hansson@linaro.org, avri.altman@wdc.com, beanhuo@micron.com,
	porzio@gmail.com
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	allwinner-opensource-support 
	<allwinner-opensource-support@allwinnertech.com>
Subject: Re: [PATCH] mmc: block: enable cache-flushing when mmc cache is on
Date: Mon, 14 Mar 2022 17:20:55 +0800	[thread overview]
Message-ID: <88e53cb9-791f-ee58-9be8-76ae9986e0e2@allwinnertech.com> (raw)
In-Reply-To: <83edf9a1-1712-5388-a3fa-d685f1f581df@intel.com>

On 14/03/2022 14:54, Adrian Hunter wrote:
> 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?
> 

Hi Adrian,
My patch intend to fix the cache problem brought by the following two 
patches:

Fixes: d0c97cfb81ebc ("mmc: core: Use CMD23 for multiblock transfers 
when we can.")
Fixes: e9d5c746246c8 ("mmc/block: switch to using blk_queue_write_cache()")

I'm not sure if this is what you referred to ("Fixes tag"). Please 
correct me if I misunderstood.

>> Signed-off-by: Michael Wu <michael@allwinnertech.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
> 

I saw another mail by Avri Altman, which says few days will be needed to 
ask internally. Shall I wait or make another change here on 'inform 
block layer about SD card cache'?

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

-- 
Best Regards,
Michael Wu

  reply	other threads:[~2022-03-14  9:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12  4:43 [PATCH] mmc: block: enable cache-flushing when mmc cache is on Michael Wu
2022-03-14  6:54 ` Adrian Hunter
2022-03-14  9:20   ` Michael Wu [this message]
2022-03-14  9:37     ` Avri Altman
2022-03-16  9:54       ` Michael Wu
2022-03-16 11:09         ` Avri Altman
2022-03-16 11:28           ` Adrian Hunter
2022-03-16 14:46             ` Christian Löhle
2022-03-16 16:05               ` Adrian Hunter
2022-03-17  9:14                 ` Ulf Hansson
2022-03-24 11:27                   ` Ulf Hansson
2022-03-25  5:45                     ` Michael Wu
2022-03-25 10:13                       ` Ulf Hansson
2022-03-28 10:11                         ` Michael Wu
2022-03-28 11:38                           ` Ulf Hansson
2022-03-29  9:08                             ` Michael Wu
2022-03-29  9:53                               ` Ulf Hansson
2022-03-27  8:09                 ` Avri Altman
2022-03-14 11:10     ` Avri Altman
2022-03-14  7:26 ` Avri Altman
2022-03-14 10:32   ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88e53cb9-791f-ee58-9be8-76ae9986e0e2@allwinnertech.com \
    --to=michael@allwinnertech.com \
    --cc=adrian.hunter@intel.com \
    --cc=allwinner-opensource-support@allwinnertech.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=porzio@gmail.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).