All of lore.kernel.org
 help / color / mirror / Atom feed
* [v3 0/3] Auto BKOPS PM suspend
@ 2017-02-07 15:59 Uri Yanai
  2017-02-07 16:00 ` [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic Uri Yanai
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Uri Yanai @ 2017-02-07 15:59 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, Alex.Lemberg, Uri Yanai

Flash based storage devices might need to perform the internal
Background Operations (BKOPS) in order to insure better performance
for the next coming IO.
Following the discussion in the mmc thread:
www.spinics.net/lists/linux-mmc/msg37779.html
To let the device complete its BKOPS during Runtime Suspend,
we suggest to check the BKOPS level.
In case the device need to complete its BKOPS, reschedule the Runtime
Suspend.

This patches replaces original patches submitted by Alex Lemberg <alex.lemberg@sandisk.com>
[1/3] mmc: replacing hardcoded value for runtime PM suspend(patch removed)
[2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support(made changes)
[3/3] mmc: Checking BKOPS status prior to Suspend(made changes)

Uri Yanai (3):
  mmc: MAN_BKOPS_EN inverse debug message logic
  mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support
  mmc: Checking BKOPS status prior to Suspend

 drivers/mmc/core/mmc.c   | 40 +++++++++++++++++++++++++++++++++-------
 include/linux/mmc/card.h |  1 +
 include/linux/mmc/mmc.h  |  1 +
 3 files changed, 35 insertions(+), 7 deletions(-)

-- 
1.9.1


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

* [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic
  2017-02-07 15:59 [v3 0/3] Auto BKOPS PM suspend Uri Yanai
@ 2017-02-07 16:00 ` Uri Yanai
  2017-02-08 11:54   ` Ulf Hansson
  2017-02-07 16:00 ` [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support Uri Yanai
  2017-02-07 16:00 ` [v3 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
  2 siblings, 1 reply; 9+ messages in thread
From: Uri Yanai @ 2017-02-07 16:00 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, Alex.Lemberg, Uri Yanai, Alex Lemberg

Inverse the logic for printing the debug message.
In mmc_decode_ext_csd() print message when MAN_BKOPS_EN is set

Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
---
 drivers/mmc/core/mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index c0e2507..9d1c149 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -530,8 +530,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 						EXT_CSD_MANUAL_BKOPS_MASK);
 			card->ext_csd.raw_bkops_status =
 				ext_csd[EXT_CSD_BKOPS_STATUS];
-			if (!card->ext_csd.man_bkops_en)
-				pr_debug("%s: MAN_BKOPS_EN bit is not set\n",
+			if (card->ext_csd.man_bkops_en)
+				pr_debug("%s: MAN_BKOPS_EN bit is set\n",
 					mmc_hostname(card->host));
 		}
 
-- 
1.9.1


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

* [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support
  2017-02-07 15:59 [v3 0/3] Auto BKOPS PM suspend Uri Yanai
  2017-02-07 16:00 ` [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic Uri Yanai
@ 2017-02-07 16:00 ` Uri Yanai
  2017-02-08 11:55   ` Ulf Hansson
  2017-02-07 16:00 ` [v3 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
  2 siblings, 1 reply; 9+ messages in thread
From: Uri Yanai @ 2017-02-07 16:00 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, Alex.Lemberg, Uri Yanai, Alex Lemberg

Adding dedicated flag for AUTO_BKOPS in card->ext_csd structure.
Read AUTO_BKOPS bit value from the device EXT_CSD and set to the
card->ext_csd structure.
In mmc_decode_ext_csd() add a print message in case the AUTO_BKOPS
is enabled

Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
---

Changes in v3:
- move the code inversing manual bkops to a separate patch

Changes in v2:
- inverse the logic for printing the debug message.
  only print when bits are set.

---
 drivers/mmc/core/mmc.c   | 6 ++++++
 include/linux/mmc/card.h | 1 +
 include/linux/mmc/mmc.h  | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 9d1c149..f70f6a1 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -533,6 +533,12 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 			if (card->ext_csd.man_bkops_en)
 				pr_debug("%s: MAN_BKOPS_EN bit is set\n",
 					mmc_hostname(card->host));
+			card->ext_csd.auto_bkops_en =
+					(ext_csd[EXT_CSD_BKOPS_EN] &
+						EXT_CSD_AUTO_BKOPS_MASK);
+			if (card->ext_csd.auto_bkops_en)
+				pr_debug("%s: AUTO_BKOPS_EN bit is set\n",
+					mmc_hostname(card->host));
 		}
 
 		/* check whether the eMMC card supports HPI */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 00449e5..e3f1031 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -84,6 +84,7 @@ struct mmc_ext_csd {
 	unsigned int		hpi_cmd;		/* cmd used as HPI */
 	bool			bkops;		/* background support bit */
 	bool			man_bkops_en;	/* manual bkops enable bit */
+	bool			auto_bkops_en;	/* auto bkops enable bit */
 	unsigned int            data_sector_size;       /* 512 bytes or 4KB */
 	unsigned int            data_tag_unit_size;     /* DATA TAG UNIT size */
 	unsigned int		boot_ro_lock;		/* ro lock support */
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index a074082..126b8d5 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -449,6 +449,7 @@ struct _mmc_csd {
  * BKOPS modes
  */
 #define EXT_CSD_MANUAL_BKOPS_MASK	0x01
+#define EXT_CSD_AUTO_BKOPS_MASK		0x02
 
 /*
  * Command Queue
-- 
1.9.1


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

* [v3 3/3] mmc: Checking BKOPS status prior to Suspend
  2017-02-07 15:59 [v3 0/3] Auto BKOPS PM suspend Uri Yanai
  2017-02-07 16:00 ` [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic Uri Yanai
  2017-02-07 16:00 ` [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support Uri Yanai
@ 2017-02-07 16:00 ` Uri Yanai
  2017-02-08 11:59   ` Ulf Hansson
  2017-06-09 14:28   ` Ulf Hansson
  2 siblings, 2 replies; 9+ messages in thread
From: Uri Yanai @ 2017-02-07 16:00 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, Alex.Lemberg, Uri Yanai, Alex Lemberg

In case of Runtime Suspend, check the device BKOPS level.
Return –EBUSY if device need more time to complete its internal BKOPS.

Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
---

Changes in v3:
- start with checking if *auto* BKOPS is enabled

Changes in v2:
- return –EBUSY instead of delaying suspend
- remove define EXT_CSD_BKOPS_LEVEL_1

---
 drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f70f6a1..4888609 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1942,7 +1942,8 @@ static void mmc_detect(struct mmc_host *host)
 	}
 }
 
-static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
+static int _mmc_suspend(struct mmc_host *host, bool is_suspend,
+	bool is_runtime_pm)
 {
 	int err = 0;
 	unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT :
@@ -1953,7 +1954,26 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
 	if (mmc_card_suspended(host->card))
 		goto out;
 
-	if (mmc_card_doing_bkops(host->card)) {
+	if (mmc_card_doing_bkops(host->card) ||
+			host->card->ext_csd.auto_bkops_en) {
+		if (is_runtime_pm) {
+			err = mmc_read_bkops_status(host->card);
+			if (err) {
+				pr_err("%s: error %d reading BKOPS Status\n",
+						mmc_hostname(host), err);
+				goto out;
+			}
+
+			if (host->card->ext_csd.raw_bkops_status >=
+					EXT_CSD_BKOPS_LEVEL_2) {
+				/*
+				 * Device still needs time to complete
+				 * internal BKOPS
+				 */
+				err = -EBUSY;
+				goto out;
+			}
+		}
 		err = mmc_stop_bkops(host->card);
 		if (err)
 			goto out;
@@ -1987,7 +2007,7 @@ static int mmc_suspend(struct mmc_host *host)
 {
 	int err;
 
-	err = _mmc_suspend(host, true);
+	err = _mmc_suspend(host, true, false);
 	if (!err) {
 		pm_runtime_disable(&host->card->dev);
 		pm_runtime_set_suspended(&host->card->dev);
@@ -2034,7 +2054,7 @@ static int mmc_shutdown(struct mmc_host *host)
 		err = _mmc_resume(host);
 
 	if (!err)
-		err = _mmc_suspend(host, false);
+		err = _mmc_suspend(host, false, false);
 
 	return err;
 }
@@ -2058,7 +2078,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
 	if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
 		return 0;
 
-	err = _mmc_suspend(host, true);
+	err = _mmc_suspend(host, true, true);
 	if (err)
 		pr_err("%s: error %d doing aggressive suspend\n",
 			mmc_hostname(host), err);
-- 
1.9.1


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

* Re: [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic
  2017-02-07 16:00 ` [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic Uri Yanai
@ 2017-02-08 11:54   ` Ulf Hansson
  0 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2017-02-08 11:54 UTC (permalink / raw)
  To: Uri Yanai; +Cc: linux-mmc, Alex Lemberg

On 7 February 2017 at 17:00, Uri Yanai <uri.yanai@sandisk.com> wrote:
> Inverse the logic for printing the debug message.
> In mmc_decode_ext_csd() print message when MAN_BKOPS_EN is set
>
> Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
> Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>

Thanks, applied for next!

Kind regards
Uffe

> ---
>  drivers/mmc/core/mmc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index c0e2507..9d1c149 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -530,8 +530,8 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>                                                 EXT_CSD_MANUAL_BKOPS_MASK);
>                         card->ext_csd.raw_bkops_status =
>                                 ext_csd[EXT_CSD_BKOPS_STATUS];
> -                       if (!card->ext_csd.man_bkops_en)
> -                               pr_debug("%s: MAN_BKOPS_EN bit is not set\n",
> +                       if (card->ext_csd.man_bkops_en)
> +                               pr_debug("%s: MAN_BKOPS_EN bit is set\n",
>                                         mmc_hostname(card->host));
>                 }
>
> --
> 1.9.1
>
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
>
> This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
>

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

* Re: [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support
  2017-02-07 16:00 ` [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support Uri Yanai
@ 2017-02-08 11:55   ` Ulf Hansson
  0 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2017-02-08 11:55 UTC (permalink / raw)
  To: Uri Yanai; +Cc: linux-mmc, Alex Lemberg

On 7 February 2017 at 17:00, Uri Yanai <uri.yanai@sandisk.com> wrote:
> Adding dedicated flag for AUTO_BKOPS in card->ext_csd structure.
> Read AUTO_BKOPS bit value from the device EXT_CSD and set to the
> card->ext_csd structure.
> In mmc_decode_ext_csd() add a print message in case the AUTO_BKOPS
> is enabled
>
> Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
> Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>

Thanks, applied for next!

Kind regards
Uffe


> ---
>
> Changes in v3:
> - move the code inversing manual bkops to a separate patch
>
> Changes in v2:
> - inverse the logic for printing the debug message.
>   only print when bits are set.
>
> ---
>  drivers/mmc/core/mmc.c   | 6 ++++++
>  include/linux/mmc/card.h | 1 +
>  include/linux/mmc/mmc.h  | 1 +
>  3 files changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 9d1c149..f70f6a1 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -533,6 +533,12 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
>                         if (card->ext_csd.man_bkops_en)
>                                 pr_debug("%s: MAN_BKOPS_EN bit is set\n",
>                                         mmc_hostname(card->host));
> +                       card->ext_csd.auto_bkops_en =
> +                                       (ext_csd[EXT_CSD_BKOPS_EN] &
> +                                               EXT_CSD_AUTO_BKOPS_MASK);
> +                       if (card->ext_csd.auto_bkops_en)
> +                               pr_debug("%s: AUTO_BKOPS_EN bit is set\n",
> +                                       mmc_hostname(card->host));
>                 }
>
>                 /* check whether the eMMC card supports HPI */
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index 00449e5..e3f1031 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -84,6 +84,7 @@ struct mmc_ext_csd {
>         unsigned int            hpi_cmd;                /* cmd used as HPI */
>         bool                    bkops;          /* background support bit */
>         bool                    man_bkops_en;   /* manual bkops enable bit */
> +       bool                    auto_bkops_en;  /* auto bkops enable bit */
>         unsigned int            data_sector_size;       /* 512 bytes or 4KB */
>         unsigned int            data_tag_unit_size;     /* DATA TAG UNIT size */
>         unsigned int            boot_ro_lock;           /* ro lock support */
> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> index a074082..126b8d5 100644
> --- a/include/linux/mmc/mmc.h
> +++ b/include/linux/mmc/mmc.h
> @@ -449,6 +449,7 @@ struct _mmc_csd {
>   * BKOPS modes
>   */
>  #define EXT_CSD_MANUAL_BKOPS_MASK      0x01
> +#define EXT_CSD_AUTO_BKOPS_MASK                0x02
>
>  /*
>   * Command Queue
> --
> 1.9.1
>
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
>
> This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
>

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

* Re: [v3 3/3] mmc: Checking BKOPS status prior to Suspend
  2017-02-07 16:00 ` [v3 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
@ 2017-02-08 11:59   ` Ulf Hansson
  2017-05-28 10:11     ` Alex Lemberg
  2017-06-09 14:28   ` Ulf Hansson
  1 sibling, 1 reply; 9+ messages in thread
From: Ulf Hansson @ 2017-02-08 11:59 UTC (permalink / raw)
  To: Uri Yanai; +Cc: linux-mmc, Alex Lemberg

On 7 February 2017 at 17:00, Uri Yanai <uri.yanai@sandisk.com> wrote:
> In case of Runtime Suspend, check the device BKOPS level.
> Return –EBUSY if device need more time to complete its internal BKOPS.
>
> Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
> Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>

This change needs some more extensive testing in linux-next, but that
won't be possible as it's getting closer to the merge window for 4.11.

Therefore, I leave it open for more discussions until 4.11 rc1 is out.

Kind regards
Uffe

> ---
>
> Changes in v3:
> - start with checking if *auto* BKOPS is enabled
>
> Changes in v2:
> - return –EBUSY instead of delaying suspend
> - remove define EXT_CSD_BKOPS_LEVEL_1
>
> ---
>  drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f70f6a1..4888609 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1942,7 +1942,8 @@ static void mmc_detect(struct mmc_host *host)
>         }
>  }
>
> -static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
> +static int _mmc_suspend(struct mmc_host *host, bool is_suspend,
> +       bool is_runtime_pm)
>  {
>         int err = 0;
>         unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT :
> @@ -1953,7 +1954,26 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
>         if (mmc_card_suspended(host->card))
>                 goto out;
>
> -       if (mmc_card_doing_bkops(host->card)) {
> +       if (mmc_card_doing_bkops(host->card) ||
> +                       host->card->ext_csd.auto_bkops_en) {
> +               if (is_runtime_pm) {
> +                       err = mmc_read_bkops_status(host->card);
> +                       if (err) {
> +                               pr_err("%s: error %d reading BKOPS Status\n",
> +                                               mmc_hostname(host), err);
> +                               goto out;
> +                       }
> +
> +                       if (host->card->ext_csd.raw_bkops_status >=
> +                                       EXT_CSD_BKOPS_LEVEL_2) {
> +                               /*
> +                                * Device still needs time to complete
> +                                * internal BKOPS
> +                                */
> +                               err = -EBUSY;
> +                               goto out;
> +                       }
> +               }
>                 err = mmc_stop_bkops(host->card);
>                 if (err)
>                         goto out;
> @@ -1987,7 +2007,7 @@ static int mmc_suspend(struct mmc_host *host)
>  {
>         int err;
>
> -       err = _mmc_suspend(host, true);
> +       err = _mmc_suspend(host, true, false);
>         if (!err) {
>                 pm_runtime_disable(&host->card->dev);
>                 pm_runtime_set_suspended(&host->card->dev);
> @@ -2034,7 +2054,7 @@ static int mmc_shutdown(struct mmc_host *host)
>                 err = _mmc_resume(host);
>
>         if (!err)
> -               err = _mmc_suspend(host, false);
> +               err = _mmc_suspend(host, false, false);
>
>         return err;
>  }
> @@ -2058,7 +2078,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
>         if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
>                 return 0;
>
> -       err = _mmc_suspend(host, true);
> +       err = _mmc_suspend(host, true, true);
>         if (err)
>                 pr_err("%s: error %d doing aggressive suspend\n",
>                         mmc_hostname(host), err);
> --
> 1.9.1
>
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
>
> This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.

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

* Re: [v3 3/3] mmc: Checking BKOPS status prior to Suspend
  2017-02-08 11:59   ` Ulf Hansson
@ 2017-05-28 10:11     ` Alex Lemberg
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Lemberg @ 2017-05-28 10:11 UTC (permalink / raw)
  To: Ulf Hansson, Uri Yanai; +Cc: linux-mmc

Hi Ulf,

Just a friendly reminder – could you please add this change?
Please let me know if you want us to rebase this change to
the linux-next?

Thanks,
Alex

On 2/8/17, 1:59 PM, "Ulf Hansson" <ulf.hansson@linaro.org> wrote:

    On 7 February 2017 at 17:00, Uri Yanai <uri.yanai@sandisk.com> wrote:
    > In case of Runtime Suspend, check the device BKOPS level.
    > Return –EBUSY if device need more time to complete its internal BKOPS.
    >
    > Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
    > Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
    
    This change needs some more extensive testing in linux-next, but that
    won't be possible as it's getting closer to the merge window for 4.11.
    
    Therefore, I leave it open for more discussions until 4.11 rc1 is out.
    
    Kind regards
    Uffe
    
    > ---
    >
    > Changes in v3:
    > - start with checking if *auto* BKOPS is enabled
    >
    > Changes in v2:
    > - return –EBUSY instead of delaying suspend
    > - remove define EXT_CSD_BKOPS_LEVEL_1
    >
    > ---
    >  drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++++-----
    >  1 file changed, 25 insertions(+), 5 deletions(-)
    >
    > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
    > index f70f6a1..4888609 100644
    > --- a/drivers/mmc/core/mmc.c
    > +++ b/drivers/mmc/core/mmc.c
    > @@ -1942,7 +1942,8 @@ static void mmc_detect(struct mmc_host *host)
    >         }
    >  }
    >
    > -static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
    > +static int _mmc_suspend(struct mmc_host *host, bool is_suspend,
    > +       bool is_runtime_pm)
    >  {
    >         int err = 0;
    >         unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT :
    > @@ -1953,7 +1954,26 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
    >         if (mmc_card_suspended(host->card))
    >                 goto out;
    >
    > -       if (mmc_card_doing_bkops(host->card)) {
    > +       if (mmc_card_doing_bkops(host->card) ||
    > +                       host->card->ext_csd.auto_bkops_en) {
    > +               if (is_runtime_pm) {
    > +                       err = mmc_read_bkops_status(host->card);
    > +                       if (err) {
    > +                               pr_err("%s: error %d reading BKOPS Status\n",
    > +                                               mmc_hostname(host), err);
    > +                               goto out;
    > +                       }
    > +
    > +                       if (host->card->ext_csd.raw_bkops_status >=
    > +                                       EXT_CSD_BKOPS_LEVEL_2) {
    > +                               /*
    > +                                * Device still needs time to complete
    > +                                * internal BKOPS
    > +                                */
    > +                               err = -EBUSY;
    > +                               goto out;
    > +                       }
    > +               }
    >                 err = mmc_stop_bkops(host->card);
    >                 if (err)
    >                         goto out;
    > @@ -1987,7 +2007,7 @@ static int mmc_suspend(struct mmc_host *host)
    >  {
    >         int err;
    >
    > -       err = _mmc_suspend(host, true);
    > +       err = _mmc_suspend(host, true, false);
    >         if (!err) {
    >                 pm_runtime_disable(&host->card->dev);
    >                 pm_runtime_set_suspended(&host->card->dev);
    > @@ -2034,7 +2054,7 @@ static int mmc_shutdown(struct mmc_host *host)
    >                 err = _mmc_resume(host);
    >
    >         if (!err)
    > -               err = _mmc_suspend(host, false);
    > +               err = _mmc_suspend(host, false, false);
    >
    >         return err;
    >  }
    > @@ -2058,7 +2078,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
    >         if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
    >                 return 0;
    >
    > -       err = _mmc_suspend(host, true);
    > +       err = _mmc_suspend(host, true, true);
    >         if (err)
    >                 pr_err("%s: error %d doing aggressive suspend\n",
    >                         mmc_hostname(host), err);
    > --
    > 1.9.1
    >
    > Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
    >
    > This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
    


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

* Re: [v3 3/3] mmc: Checking BKOPS status prior to Suspend
  2017-02-07 16:00 ` [v3 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
  2017-02-08 11:59   ` Ulf Hansson
@ 2017-06-09 14:28   ` Ulf Hansson
  1 sibling, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2017-06-09 14:28 UTC (permalink / raw)
  To: Uri Yanai, Alex Lemberg; +Cc: linux-mmc

Hi Uri/Alex,

Apologize for the long delay, I have simply forgot about this.

On 7 February 2017 at 17:00, Uri Yanai <uri.yanai@sandisk.com> wrote:
> In case of Runtime Suspend, check the device BKOPS level.
> Return –EBUSY if device need more time to complete its internal BKOPS.
>
> Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
> Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
> ---
>
> Changes in v3:
> - start with checking if *auto* BKOPS is enabled
>
> Changes in v2:
> - return –EBUSY instead of delaying suspend
> - remove define EXT_CSD_BKOPS_LEVEL_1
>
> ---
>  drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f70f6a1..4888609 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1942,7 +1942,8 @@ static void mmc_detect(struct mmc_host *host)
>         }
>  }
>
> -static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
> +static int _mmc_suspend(struct mmc_host *host, bool is_suspend,
> +       bool is_runtime_pm)
>  {
>         int err = 0;
>         unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT :
> @@ -1953,7 +1954,26 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
>         if (mmc_card_suspended(host->card))
>                 goto out;
>
> -       if (mmc_card_doing_bkops(host->card)) {
> +       if (mmc_card_doing_bkops(host->card) ||
> +                       host->card->ext_csd.auto_bkops_en) {
> +               if (is_runtime_pm) {
> +                       err = mmc_read_bkops_status(host->card);
> +                       if (err) {
> +                               pr_err("%s: error %d reading BKOPS Status\n",
> +                                               mmc_hostname(host), err);
> +                               goto out;
> +                       }
> +
> +                       if (host->card->ext_csd.raw_bkops_status >=
> +                                       EXT_CSD_BKOPS_LEVEL_2) {
> +                               /*
> +                                * Device still needs time to complete
> +                                * internal BKOPS
> +                                */
> +                               err = -EBUSY;
> +                               goto out;
> +                       }
> +               }

As the above path becomes executed only from mmc_runtime_suspend() and
when the host cap MMC_CAP_AGGRESSIVE_PM is set, I think it would be
better to make this it a part of mmc_runtime_suspend().

Moreover, on those platforms where autosleep (or opportunistic sleep)
is enabled for system suspend, perhaps we should also return -EBUSY
and take a wakeup source for a certain timeout, to avoid system
suspend being re-tried for a while.

>                 err = mmc_stop_bkops(host->card);
>                 if (err)
>                         goto out;
> @@ -1987,7 +2007,7 @@ static int mmc_suspend(struct mmc_host *host)
>  {
>         int err;
>
> -       err = _mmc_suspend(host, true);
> +       err = _mmc_suspend(host, true, false);
>         if (!err) {
>                 pm_runtime_disable(&host->card->dev);
>                 pm_runtime_set_suspended(&host->card->dev);
> @@ -2034,7 +2054,7 @@ static int mmc_shutdown(struct mmc_host *host)
>                 err = _mmc_resume(host);
>
>         if (!err)
> -               err = _mmc_suspend(host, false);
> +               err = _mmc_suspend(host, false, false);
>
>         return err;
>  }
> @@ -2058,7 +2078,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
>         if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
>                 return 0;
>
> -       err = _mmc_suspend(host, true);
> +       err = _mmc_suspend(host, true, true);
>         if (err)
>                 pr_err("%s: error %d doing aggressive suspend\n",
>                         mmc_hostname(host), err);
> --
> 1.9.1
>

Kind regards
Uffe

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

end of thread, other threads:[~2017-06-09 14:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 15:59 [v3 0/3] Auto BKOPS PM suspend Uri Yanai
2017-02-07 16:00 ` [v3 1/3] mmc: MAN_BKOPS_EN inverse debug message logic Uri Yanai
2017-02-08 11:54   ` Ulf Hansson
2017-02-07 16:00 ` [v3 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support Uri Yanai
2017-02-08 11:55   ` Ulf Hansson
2017-02-07 16:00 ` [v3 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
2017-02-08 11:59   ` Ulf Hansson
2017-05-28 10:11     ` Alex Lemberg
2017-06-09 14:28   ` Ulf Hansson

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.