linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] mmc: core: add a new property/caps2
@ 2020-07-07 11:58 Yoshihiro Shimoda
  2020-07-07 11:58 ` [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property Yoshihiro Shimoda
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2020-07-07 11:58 UTC (permalink / raw)
  To: ulf.hansson, robh+dt
  Cc: linux-mmc, devicetree, linux-renesas-soc, Yoshihiro Shimoda

Some environment (like r8a77951-salvator-xs) is possible
to perform a full power cycle of the card in suspend via firmware
(PSCI on arm-trusted-firmware). However, the current MMC core
cannot issue Power Off Notification. This patch series can do it.

We discussed on the v3 email thread [1].

[1]
https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#m9c25f35d7126b1c14ea431a773757652ad094341


Changes from v4:
 - Just add a new property/caps2 flag of MMC bindings to fix the issue.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=308795

Changes from v3:
 - Modify regulator subsytem and regulator/fixed driver.
 - Use regulator_is_enabled() instead of firmware API.
 - Update R-Car Gen3 related dts files for the reference.
   But, I have only tested on r8a779{5,61}-salvaltor-xs.dts.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=306281

Changes from v2:
 - Fix typo of function name in patch2.
 - Remove RFC.
 https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=305523

Changes from v1:
 - Use pm_suspend_via_firmware() API instead of pm_suspend_target_state.
 - Modify the psci driver to call pm_set_suspend_via_firmware.
 https://patchwork.kernel.org/patch/11557505/


*** BLURB HERE ***

Yoshihiro Shimoda (2):
  dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
  mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND

 Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 5 +++++
 drivers/mmc/core/host.c                                   | 2 ++
 drivers/mmc/core/mmc.c                                    | 3 ++-
 include/linux/mmc/host.h                                  | 1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

-- 
2.7.4


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

* [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
  2020-07-07 11:58 [PATCH v5 0/2] mmc: core: add a new property/caps2 Yoshihiro Shimoda
@ 2020-07-07 11:58 ` Yoshihiro Shimoda
  2020-07-09 22:52   ` Rob Herring
  2020-07-07 11:58 ` [PATCH v5 2/2] mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Yoshihiro Shimoda @ 2020-07-07 11:58 UTC (permalink / raw)
  To: ulf.hansson, robh+dt
  Cc: linux-mmc, devicetree, linux-renesas-soc, Yoshihiro Shimoda

The commit 5a36d6bcdf23 ("mmc: core: Add DT-bindings for
MMC_CAP2_FULL_PWR_CYCLE") added the "full-pwr-cycle" property which
is possible to perform a full power cycle of the card at any time.

However, some environment (like r8a77951-salvator-xs) is possible
to perform a full power cycle of the card in suspend via firmware
(PSCI on arm-trusted-firmware). So, add a new property for such
environment.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml
index 4931fab..b96da0c 100644
--- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml
+++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml
@@ -169,6 +169,11 @@ properties:
     description:
       Full power cycle of the card is supported.
 
+  full-pwr-cycle-in-suspend:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Full power cycle of the card in suspend is supported.
+
   mmc-ddr-1_2v:
     $ref: /schemas/types.yaml#/definitions/flag
     description:
-- 
2.7.4


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

* [PATCH v5 2/2] mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
  2020-07-07 11:58 [PATCH v5 0/2] mmc: core: add a new property/caps2 Yoshihiro Shimoda
  2020-07-07 11:58 ` [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property Yoshihiro Shimoda
@ 2020-07-07 11:58 ` Yoshihiro Shimoda
  2020-07-07 13:13 ` [PATCH v5 0/2] mmc: core: add a new property/caps2 Ulf Hansson
  2020-07-10  7:56 ` Ulf Hansson
  3 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2020-07-07 11:58 UTC (permalink / raw)
  To: ulf.hansson, robh+dt
  Cc: linux-mmc, devicetree, linux-renesas-soc, Yoshihiro Shimoda

The commit 5a36d6bcdf23 ("mmc: core: Add DT-bindings for
MMC_CAP2_FULL_PWR_CYCLE") added the "full-pwr-cycle" property which
is possible to perform a full power cycle of the card at any time.

However, some environment (like r8a77951-salvator-xs) is possible
to perform a full power cycle of the card in suspend via firmware
(PSCI on arm-trusted-firmware). So, in worst case, since we are
not doing a graceful shutdown of the eMMC device (just cut VCCQ
while the eMMC is "sleeping") in suspend, it could lead to internal
data corruptions. So, add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
to do a graceful shutdown which issues Power Off notification
before entering system suspend.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/mmc/core/host.c  | 2 ++
 drivers/mmc/core/mmc.c   | 3 ++-
 include/linux/mmc/host.h | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6141a85..7f87f44 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -277,6 +277,8 @@ int mmc_of_parse(struct mmc_host *host)
 		host->caps |= MMC_CAP_SDIO_IRQ;
 	if (device_property_read_bool(dev, "full-pwr-cycle"))
 		host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;
+	if (device_property_read_bool(dev, "full-pwr-cycle-in-suspend"))
+		host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND;
 	if (device_property_read_bool(dev, "keep-power-in-suspend"))
 		host->pm_caps |= MMC_PM_KEEP_POWER;
 	if (device_property_read_bool(dev, "wakeup-source") ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 4203303..b3fa193 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2038,7 +2038,8 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
 		goto out;
 
 	if (mmc_can_poweroff_notify(host->card) &&
-		((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend))
+	    ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend ||
+	     (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND)))
 		err = mmc_poweroff_notify(host->card, notify_type);
 	else if (mmc_can_sleep(host->card))
 		err = mmc_sleep(host);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 1fa4fa1..c5b6e97 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -352,6 +352,7 @@ struct mmc_host {
 
 #define MMC_CAP2_BOOTPART_NOACC	(1 << 0)	/* Boot partition no access */
 #define MMC_CAP2_FULL_PWR_CYCLE	(1 << 2)	/* Can do full power cycle */
+#define MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND (1 << 3) /* Can do full power cycle in suspend */
 #define MMC_CAP2_HS200_1_8V_SDR	(1 << 5)        /* can support */
 #define MMC_CAP2_HS200_1_2V_SDR	(1 << 6)        /* can support */
 #define MMC_CAP2_HS200		(MMC_CAP2_HS200_1_8V_SDR | \
-- 
2.7.4


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

* Re: [PATCH v5 0/2] mmc: core: add a new property/caps2
  2020-07-07 11:58 [PATCH v5 0/2] mmc: core: add a new property/caps2 Yoshihiro Shimoda
  2020-07-07 11:58 ` [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property Yoshihiro Shimoda
  2020-07-07 11:58 ` [PATCH v5 2/2] mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND Yoshihiro Shimoda
@ 2020-07-07 13:13 ` Ulf Hansson
  2020-07-10  7:56 ` Ulf Hansson
  3 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2020-07-07 13:13 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: Rob Herring, linux-mmc, DTML, Linux-Renesas

On Tue, 7 Jul 2020 at 13:59, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
>
> Some environment (like r8a77951-salvator-xs) is possible
> to perform a full power cycle of the card in suspend via firmware
> (PSCI on arm-trusted-firmware). However, the current MMC core
> cannot issue Power Off Notification. This patch series can do it.
>
> We discussed on the v3 email thread [1].
>
> [1]
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#m9c25f35d7126b1c14ea431a773757652ad094341
>
>
> Changes from v4:
>  - Just add a new property/caps2 flag of MMC bindings to fix the issue.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=308795
>
> Changes from v3:
>  - Modify regulator subsytem and regulator/fixed driver.
>  - Use regulator_is_enabled() instead of firmware API.
>  - Update R-Car Gen3 related dts files for the reference.
>    But, I have only tested on r8a779{5,61}-salvaltor-xs.dts.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=306281
>
> Changes from v2:
>  - Fix typo of function name in patch2.
>  - Remove RFC.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=305523
>
> Changes from v1:
>  - Use pm_suspend_via_firmware() API instead of pm_suspend_target_state.
>  - Modify the psci driver to call pm_set_suspend_via_firmware.
>  https://patchwork.kernel.org/patch/11557505/
>
>
> *** BLURB HERE ***
>
> Yoshihiro Shimoda (2):
>   dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
>   mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
>
>  Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 5 +++++
>  drivers/mmc/core/host.c                                   | 2 ++
>  drivers/mmc/core/mmc.c                                    | 3 ++-
>  include/linux/mmc/host.h                                  | 1 +
>  4 files changed, 10 insertions(+), 1 deletion(-)
>
> --
> 2.7.4
>

The series looks good to me. However, I am awaiting Rob to comment on
the DT binding for a while, before I queue this up.

Kind regards
Uffe

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

* Re: [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
  2020-07-07 11:58 ` [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property Yoshihiro Shimoda
@ 2020-07-09 22:52   ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2020-07-09 22:52 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: linux-renesas-soc, devicetree, ulf.hansson, robh+dt, linux-mmc

On Tue, 07 Jul 2020 20:58:41 +0900, Yoshihiro Shimoda wrote:
> The commit 5a36d6bcdf23 ("mmc: core: Add DT-bindings for
> MMC_CAP2_FULL_PWR_CYCLE") added the "full-pwr-cycle" property which
> is possible to perform a full power cycle of the card at any time.
> 
> However, some environment (like r8a77951-salvator-xs) is possible
> to perform a full power cycle of the card in suspend via firmware
> (PSCI on arm-trusted-firmware). So, add a new property for such
> environment.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v5 0/2] mmc: core: add a new property/caps2
  2020-07-07 11:58 [PATCH v5 0/2] mmc: core: add a new property/caps2 Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2020-07-07 13:13 ` [PATCH v5 0/2] mmc: core: add a new property/caps2 Ulf Hansson
@ 2020-07-10  7:56 ` Ulf Hansson
  3 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2020-07-10  7:56 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: Rob Herring, linux-mmc, DTML, Linux-Renesas

On Tue, 7 Jul 2020 at 13:59, Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
>
> Some environment (like r8a77951-salvator-xs) is possible
> to perform a full power cycle of the card in suspend via firmware
> (PSCI on arm-trusted-firmware). However, the current MMC core
> cannot issue Power Off Notification. This patch series can do it.
>
> We discussed on the v3 email thread [1].
>
> [1]
> https://lore.kernel.org/linux-renesas-soc/1592792699-24638-1-git-send-email-yoshihiro.shimoda.uh@renesas.com/T/#m9c25f35d7126b1c14ea431a773757652ad094341
>
>
> Changes from v4:
>  - Just add a new property/caps2 flag of MMC bindings to fix the issue.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=308795
>
> Changes from v3:
>  - Modify regulator subsytem and regulator/fixed driver.
>  - Use regulator_is_enabled() instead of firmware API.
>  - Update R-Car Gen3 related dts files for the reference.
>    But, I have only tested on r8a779{5,61}-salvaltor-xs.dts.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=306281
>
> Changes from v2:
>  - Fix typo of function name in patch2.
>  - Remove RFC.
>  https://patchwork.kernel.org/project/linux-renesas-soc/list/?series=305523
>
> Changes from v1:
>  - Use pm_suspend_via_firmware() API instead of pm_suspend_target_state.
>  - Modify the psci driver to call pm_set_suspend_via_firmware.
>  https://patchwork.kernel.org/patch/11557505/
>
>
> *** BLURB HERE ***
>
> Yoshihiro Shimoda (2):
>   dt-bindings: mmc: Add full-pwr-cycle-in-suspend property
>   mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND
>
>  Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 5 +++++
>  drivers/mmc/core/host.c                                   | 2 ++
>  drivers/mmc/core/mmc.c                                    | 3 ++-
>  include/linux/mmc/host.h                                  | 1 +
>  4 files changed, 10 insertions(+), 1 deletion(-)
>
> --
> 2.7.4
>

Applied for next, thanks!

Kind regards
Uffe

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

end of thread, other threads:[~2020-07-10  7:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 11:58 [PATCH v5 0/2] mmc: core: add a new property/caps2 Yoshihiro Shimoda
2020-07-07 11:58 ` [PATCH v5 1/2] dt-bindings: mmc: Add full-pwr-cycle-in-suspend property Yoshihiro Shimoda
2020-07-09 22:52   ` Rob Herring
2020-07-07 11:58 ` [PATCH v5 2/2] mmc: core: Add MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND Yoshihiro Shimoda
2020-07-07 13:13 ` [PATCH v5 0/2] mmc: core: add a new property/caps2 Ulf Hansson
2020-07-10  7:56 ` Ulf Hansson

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