From: Adrian Hunter <adrian.hunter@intel.com>
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" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv3 1/2] mmc: block: Remove error check of hw_reset on reset
Date: Tue, 11 Oct 2022 13:15:12 +0300 [thread overview]
Message-ID: <65d813c6-65c0-fb5b-2709-8068e1dc89c1@intel.com> (raw)
In-Reply-To: <0d0ef6651ed44fc780e95c8797294708@hyperstone.com>
On 10/10/22 17:03, 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.
> Furthermore ensure part_curr is not falsely set to a valid value
> on reset or partition switch error.
>
> 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>
> ---
> -v3: Ensure invalid part_curr on error
> -v2: Do not attempt to switch partitions if reset failed
>
> drivers/mmc/core/block.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index ce89611a136e..45a44edcc31a 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -134,6 +134,7 @@ struct mmc_blk_data {
> * track of the current selected device partition.
> */
> unsigned int part_curr;
> +#define MMC_BLK_PART_INVALID UINT_MAX /* Unknown partition active */
> int area_type;
>
> /* debugfs files (only in main mmc_blk_data) */
> @@ -991,29 +992,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;
> + main_md->part_curr = MMC_BLK_PART_INVALID;
This forces a partition switch even if it is not necessary.
> err = mmc_hw_reset(host->card);
This would be better:
/*
* A successful reset will leave the card in the main partition, but
* upon failure it might not be, so set it to MMC_BLK_PART_INVALID
* in that case.
*/
main_md->part_curr = err ? MMC_BLK_PART_INVALID : main_md->part_type;
> + if (err)
> + return err;
There was a time when mmc requests would be retried directly without
going back through the block layer. I don't think that can happen
anymore after a failed reset. However, if you are going to skip the
partition switch, the commit message needs to explain that you have
checked the code paths and we never retry a request directly after a
failed reset. Also a comment is needed to say the same.
> /* Ensure we switch back to the correct partition */
> - if (err) {
> - struct mmc_blk_data *main_md =
> - dev_get_drvdata(&host->card->dev);
> - int part_err;
> -
> - main_md->part_curr = main_md->part_type;
> - part_err = mmc_blk_part_switch(host->card, md->part_type);
> - if (part_err) {
> - /*
> - * We have failed to get back into the correct
> - * partition, so we need to abort the whole request.
> - */
> - return -ENODEV;
> - }
> + part_err = mmc_blk_part_switch(host->card, md->part_type);
> + if (part_err) {
Don't really need part_err. i.e. could be
if (mmc_blk_part_switch(host->card, md->part_type) {
> + /*
> + * We have failed to get back into the correct
> + * partition, so we need to abort the whole request.
> + */
> + return -ENODEV;
> }
> - return err;
> + return 0;
> }
>
> static inline void mmc_blk_reset_success(struct mmc_blk_data *md, int type)
next prev parent reply other threads:[~2022-10-11 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 14:03 Christian Löhle
2022-10-10 14:17 ` Ulf Hansson
2022-10-11 10:15 ` Adrian Hunter [this message]
2022-10-11 10:24 ` 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=65d813c6-65c0-fb5b-2709-8068e1dc89c1@intel.com \
--to=adrian.hunter@intel.com \
--cc=CLoehle@hyperstone.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
all inboxes | Powered by JetHome®