All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written
@ 2021-04-02  7:59 Avri Altman
  0 siblings, 0 replies; 3+ messages in thread
From: Avri Altman @ 2021-04-02  7:59 UTC (permalink / raw)
  To: adrian.hunter; +Cc: Avri Altman, linux-kernel, linux-mmc, ulf.hansson

>> @@ -571,6 +571,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
>>  		main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
>>  	}
>>  
>> +	/* Make sure to update CACHE_CTRL in case it was changed */

> It might be worth noting that the cache will get turned back
> on if the card is re-initialized, for example suspend/resume or
> hw reset in recovery.
Done.

Thanks,
Avri

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written
  2021-03-22 13:36 ` [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written Avri Altman
@ 2021-03-22 18:59   ` Adrian Hunter
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2021-03-22 18:59 UTC (permalink / raw)
  To: Avri Altman, Ulf Hansson, linux-mmc; +Cc: linux-kernel

On 22/03/21 3:36 pm, Avri Altman wrote:
> The cache function can be turned ON and OFF by writing to the CACHE_CTRL
> byte (EXT_CSD byte [33]).  However,  card->ext_csd.cache_ctrl is only
> set on init if cache size > 0.
> 
> Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write.
> 
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> ---
>  drivers/mmc/core/block.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index a93c66aa91db..4c816d001ac1 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -571,6 +571,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
>  		main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
>  	}
>  
> +	/* Make sure to update CACHE_CTRL in case it was changed */

It might be worth noting that the cache will get turned back
on if the card is re-initialized, for example suspend/resume or
hw reset in recovery.

> +	if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
> +	    (cmd.opcode == MMC_SWITCH)) {
> +		u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1;
> +
> +		card->ext_csd.cache_ctrl = value;
> +	}
> +
>  	/*
>  	 * According to the SD specs, some commands require a delay after
>  	 * issuing the command.
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written
  2021-03-22 13:36 [PATCH 0/2] Do not flush cache when it is disabled Avri Altman
@ 2021-03-22 13:36 ` Avri Altman
  2021-03-22 18:59   ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Avri Altman @ 2021-03-22 13:36 UTC (permalink / raw)
  To: Ulf Hansson, linux-mmc; +Cc: Adrian Hunter, linux-kernel, Avri Altman

The cache function can be turned ON and OFF by writing to the CACHE_CTRL
byte (EXT_CSD byte [33]).  However,  card->ext_csd.cache_ctrl is only
set on init if cache size > 0.

Fix that by explicitly setting ext_csd.cache_ctrl on ext-csd write.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/mmc/core/block.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index a93c66aa91db..4c816d001ac1 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -571,6 +571,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 		main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
 	}
 
+	/* Make sure to update CACHE_CTRL in case it was changed */
+	if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
+	    (cmd.opcode == MMC_SWITCH)) {
+		u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1;
+
+		card->ext_csd.cache_ctrl = value;
+	}
+
 	/*
 	 * According to the SD specs, some commands require a delay after
 	 * issuing the command.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-02  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02  7:59 [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written Avri Altman
  -- strict thread matches above, loose matches on Subject: below --
2021-03-22 13:36 [PATCH 0/2] Do not flush cache when it is disabled Avri Altman
2021-03-22 13:36 ` [PATCH 2/2] mmc: block: Update ext_csd.cache_ctrl if it was written Avri Altman
2021-03-22 18:59   ` Adrian Hunter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.