public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christian Löhle" <CLoehle@hyperstone.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Linux MMC List <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCHv2 1/2] mmc: block: Remove error check of hw_reset on reset
Date: Mon, 10 Oct 2022 08:08:16 +0000	[thread overview]
Message-ID: <27343e2a17d1481f9a62d710480bc041@hyperstone.com> (raw)
In-Reply-To: <e6acc89d-7d17-62ee-d67a-b78b1cdcd085@intel.com>


>
>-----Original Message-----
>From: Adrian Hunter <adrian.hunter@intel.com> 
>Sent: Samstag, 8. Oktober 2022 10:38
>To: Christian Löhle <CLoehle@hyperstone.com>; Ulf Hansson <ulf.hansson@linaro.org>; Linux MMC List <linux-mmc@vger.kernel.org>; linux-kernel@vger.kernel.org
>Subject: Re: [PATCHv2 1/2] mmc: block: Remove error check of hw_reset on reset
>
>On 7/10/22 18:42, Christian Löhle wrote:
>> Before switching back to the right partition in mmc_blk_reset there 
>> used to be a check if hw_reset was even supported.
>> This return value was removed, so there is no reason to check.
>> 
>> Fixes: fefdd3c91e0a ("mmc: core: Drop superfluous validations in 
>> mmc_hw|sw_reset()")
>> Cc: stable@vger.kernel.org
>> 
>> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
>> ---
>> -v2: Do not attempt to switch partitions if reset failed
>> 
>>  drivers/mmc/core/block.c | 28 +++++++++++++---------------
>>  1 file changed, 13 insertions(+), 15 deletions(-)
>> 
>> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 
>> ce89611a136e..8db72cba2bbe 100644
>> --- a/drivers/mmc/core/block.c
>> +++ b/drivers/mmc/core/block.c
>> @@ -991,29 +991,27 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
>>  			 int type)
>>  {
>>  	int err;
>> +	struct mmc_blk_data *main_md = dev_get_drvdata(&host->card->dev);
>> +	int part_err;
>>  
>>  	if (md->reset_done & type)
>>  		return -EEXIST;
>>  
>>  	md->reset_done |= type;
>>  	err = mmc_hw_reset(host->card);
>> +	if (err)
>> +		return err;
> 
> This could be a potential source of data corruption.
> 
> There is no guarantee that a subsequent I/O will fail just because the reset failed.  Reading / writing the wrong partition would be disastrous, so we should always try to get back to the correct partition.
> 
> I haven't looked at the possibility of just flagging the partition as invalid - need to be sure any subsequent I/O attempts still go through a path that switches the partition.

I can see where youre coming from, but similarly a failing mmc_blk_part_switch doesn't imply all subsequent IO will fail.
Flagging the partition as invalid can be seen as rendering the system to a potentially useless state, which is a bit overboard for e.g. one CRC7 failure on the switch.
Not sure yet what the ideal behavior is, but either way I would go with v1 1/2 and v2 2/2 for now? That already fixes imo the most relevant potential data corruptions. (successful reset -> no switch)
Then we can come up with a a good handling for mmc_blk_reset or even around mmc_blk_part_switch.
Or what do you suggest?

Regards,
Christian

Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782

  reply	other threads:[~2022-10-10  8:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 15:42 [PATCHv2 1/2] mmc: block: Remove error check of hw_reset on reset Christian Löhle
2022-10-08  8:38 ` Adrian Hunter
2022-10-10  8:08   ` Christian Löhle [this message]
2022-10-10 12:36     ` Adrian Hunter
2022-10-10 14:01       ` Ulf Hansson

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=27343e2a17d1481f9a62d710480bc041@hyperstone.com \
    --to=cloehle@hyperstone.com \
    --cc=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --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