linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mmc: block: Remove error check of hw_reset on reset
@ 2022-10-06 13:38 Christian Löhle
  2022-10-07 13:05 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Löhle @ 2022-10-06 13:38 UTC (permalink / raw)
  To: Adrian Hunter, ulf.hansson, Linux MMC List, linux-kernel,
	Christian Löhle

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>
---
 drivers/mmc/core/block.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index ce89611a136e..8531f92fd0cb 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -991,6 +991,8 @@ 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;
@@ -998,20 +1000,14 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
 	md->reset_done |= type;
 	err = mmc_hw_reset(host->card);
 	/* 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;
-		}
+	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;
 	}
 	return err;
 }
-- 
2.37.3

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


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

* Re: [PATCH 1/2] mmc: block: Remove error check of hw_reset on reset
  2022-10-06 13:38 [PATCH 1/2] mmc: block: Remove error check of hw_reset on reset Christian Löhle
@ 2022-10-07 13:05 ` Ulf Hansson
  2022-10-07 15:00   ` Christian Löhle
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2022-10-07 13:05 UTC (permalink / raw)
  To: Christian Löhle; +Cc: Adrian Hunter, Linux MMC List, linux-kernel

On Thu, 6 Oct 2022 at 15:38, Christian Löhle <CLoehle@hyperstone.com> 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>
> ---
>  drivers/mmc/core/block.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index ce89611a136e..8531f92fd0cb 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -991,6 +991,8 @@ 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;
> @@ -998,20 +1000,14 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
>         md->reset_done |= type;
>         err = mmc_hw_reset(host->card);
>         /* 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;
> -               }

Yes, this is certainly restoring the behaviour and fixing a bug. Thanks!

However, I do wonder about what's the point of trying to switch back
to the correct partition if the mmc_hw_reset() failed (returned a
negative error code). It looks like that shouldn't matter, if the
reset failed we are screwed anyway, right?

> +       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;
>         }
>         return err;
>  }

Kind regards
Uffe

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

* RE: [PATCH 1/2] mmc: block: Remove error check of hw_reset on reset
  2022-10-07 13:05 ` Ulf Hansson
@ 2022-10-07 15:00   ` Christian Löhle
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Löhle @ 2022-10-07 15:00 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Adrian Hunter, Linux MMC List, linux-kernel

> Yes, this is certainly restoring the behaviour and fixing a bug. Thanks!
> 
> However, I do wonder about what's the point of trying to switch back to the correct partition if the mmc_hw_reset() > failed (returned a negative error code). It looks like that shouldn't matter, if the reset failed we are screwed anyway, > right?

I agree with you, the only reason for it is to keep behavior in line with err != -EOPNOTSUPP,
For the case that neither of you remembers the original intent, I'll send a v2.

Regards,
Christian

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

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

end of thread, other threads:[~2022-10-07 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 13:38 [PATCH 1/2] mmc: block: Remove error check of hw_reset on reset Christian Löhle
2022-10-07 13:05 ` Ulf Hansson
2022-10-07 15:00   ` Christian Löhle

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).