linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
@ 2022-03-14  9:52 Yann Gautier
  2022-03-14 11:17 ` Ulf Hansson
  2022-03-14 12:55 ` [PATCH v2] " Yann Gautier
  0 siblings, 2 replies; 14+ messages in thread
From: Yann Gautier @ 2022-03-14  9:52 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek,
	Yann Gautier

Add a disable_keep_power field in variant_data struct. The
MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
It is only set to true for stm32_sdmmc variants.

The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
It doesn't correctly support low power, and we need to unbind the wifi
driver before a suspend sequence. But the wifi chip firmware is then
lost, and the communication with SDIO fails if MMC_PM_KEEP_POWER is
enabled.
The flag can still be enabled through DT property: keep-power-in-suspend.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
---
Resend the patch alone. It was previoulsy in a series [1] for which the
other patches will be reworked.

[1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/

 drivers/mmc/host/mmci.c | 5 ++++-
 drivers/mmc/host/mmci.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 45b8608c935c..0e2f2f5d6a52 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
 	.busy_detect		= true,
 	.busy_detect_flag	= MCI_STM32_BUSYD0,
 	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.disable_keep_power	= true,
 	.init			= sdmmc_variant_init,
 };
 
@@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
 	.busy_detect		= true,
 	.busy_detect_flag	= MCI_STM32_BUSYD0,
 	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.disable_keep_power	= true,
 	.init			= sdmmc_variant_init,
 };
 
@@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
 	host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
 
 	/* We support these PM capabilities. */
-	mmc->pm_caps |= MMC_PM_KEEP_POWER;
+	if (!variant->disable_keep_power)
+		mmc->pm_caps |= MMC_PM_KEEP_POWER;
 
 	/*
 	 * We can do SGIO
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index e1a9b96a3396..2cad1ef9766a 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -361,6 +361,7 @@ struct variant_data {
 	u32			opendrain;
 	u8			dma_lli:1;
 	u32			stm32_idmabsize_mask;
+	u8			disable_keep_power:1;
 	void (*init)(struct mmci_host *host);
 };
 
-- 
2.25.1


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

* Re: [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14  9:52 [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config Yann Gautier
@ 2022-03-14 11:17 ` Ulf Hansson
  2022-03-14 12:20   ` Yann Gautier
  2022-03-14 12:55 ` [PATCH v2] " Yann Gautier
  1 sibling, 1 reply; 14+ messages in thread
From: Ulf Hansson @ 2022-03-14 11:17 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On Mon, 14 Mar 2022 at 10:53, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> Add a disable_keep_power field in variant_data struct. The
> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> It is only set to true for stm32_sdmmc variants.
>
> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> It doesn't correctly support low power, and we need to unbind the wifi
> driver before a suspend sequence. But the wifi chip firmware is then
> lost, and the communication with SDIO fails if MMC_PM_KEEP_POWER is
> enabled.

So the platform supports to maintain the power for the embedded wifi
chip during system suspend, but the SDIO func driver (for the WiFi
chip) doesn't implement its part correctly. Did I get that right?

In that case, it sounds to me like we should try to fix the support
for power management in the SDIO func driver instead, no?
I am happy to help with guidance/review if that is needed. What SDIO
func driver is this about?

Kind regards
Uffe

> The flag can still be enabled through DT property: keep-power-in-suspend.
>
> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> ---
> Resend the patch alone. It was previoulsy in a series [1] for which the
> other patches will be reworked.
>
> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>
>  drivers/mmc/host/mmci.c | 5 ++++-
>  drivers/mmc/host/mmci.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 45b8608c935c..0e2f2f5d6a52 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>
> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>
> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>         host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>
>         /* We support these PM capabilities. */
> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
> +       if (!variant->disable_keep_power)
> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>
>         /*
>          * We can do SGIO
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index e1a9b96a3396..2cad1ef9766a 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -361,6 +361,7 @@ struct variant_data {
>         u32                     opendrain;
>         u8                      dma_lli:1;
>         u32                     stm32_idmabsize_mask;
> +       u8                      disable_keep_power:1;
>         void (*init)(struct mmci_host *host);
>  };
>
> --
> 2.25.1
>

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

* Re: [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 11:17 ` Ulf Hansson
@ 2022-03-14 12:20   ` Yann Gautier
  2022-03-14 12:53     ` Ulf Hansson
  0 siblings, 1 reply; 14+ messages in thread
From: Yann Gautier @ 2022-03-14 12:20 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On 3/14/22 12:17, Ulf Hansson wrote:
> On Mon, 14 Mar 2022 at 10:53, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>
>> Add a disable_keep_power field in variant_data struct. The
>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
>> It is only set to true for stm32_sdmmc variants.
>>
>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
>> It doesn't correctly support low power, and we need to unbind the wifi
>> driver before a suspend sequence. But the wifi chip firmware is then
>> lost, and the communication with SDIO fails if MMC_PM_KEEP_POWER is
>> enabled.
> 
> So the platform supports to maintain the power for the embedded wifi
> chip during system suspend, but the SDIO func driver (for the WiFi
> chip) doesn't implement its part correctly. Did I get that right?
> 
> In that case, it sounds to me like we should try to fix the support
> for power management in the SDIO func driver instead, no?
> I am happy to help with guidance/review if that is needed. What SDIO
> func driver is this about?
> 
> Kind regards
> Uffe
> 

Hi Ulf,

I blindly pushed the patch without rechecking it.
I rephrased it in our downstream to better explain the issue:

The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
It doesn't correctly support low power on this board. The Wifi chip
awaits an always-on regulator, but it was connected to v3v3 which is off
in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.

If it's OK for you, I'll resend the patch with the updated commit message.

Best regards,
Yann

>> The flag can still be enabled through DT property: keep-power-in-suspend.
>>
>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
>> ---
>> Resend the patch alone. It was previoulsy in a series [1] for which the
>> other patches will be reworked.
>>
>> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>>
>>   drivers/mmc/host/mmci.c | 5 ++++-
>>   drivers/mmc/host/mmci.h | 1 +
>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 45b8608c935c..0e2f2f5d6a52 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>
>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>
>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>>          host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>>
>>          /* We support these PM capabilities. */
>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
>> +       if (!variant->disable_keep_power)
>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>
>>          /*
>>           * We can do SGIO
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index e1a9b96a3396..2cad1ef9766a 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -361,6 +361,7 @@ struct variant_data {
>>          u32                     opendrain;
>>          u8                      dma_lli:1;
>>          u32                     stm32_idmabsize_mask;
>> +       u8                      disable_keep_power:1;
>>          void (*init)(struct mmci_host *host);
>>   };
>>
>> --
>> 2.25.1
>>


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

* Re: [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 12:20   ` Yann Gautier
@ 2022-03-14 12:53     ` Ulf Hansson
  0 siblings, 0 replies; 14+ messages in thread
From: Ulf Hansson @ 2022-03-14 12:53 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On Mon, 14 Mar 2022 at 13:20, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> On 3/14/22 12:17, Ulf Hansson wrote:
> > On Mon, 14 Mar 2022 at 10:53, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>
> >> Add a disable_keep_power field in variant_data struct. The
> >> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> >> It is only set to true for stm32_sdmmc variants.
> >>
> >> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> >> It doesn't correctly support low power, and we need to unbind the wifi
> >> driver before a suspend sequence. But the wifi chip firmware is then
> >> lost, and the communication with SDIO fails if MMC_PM_KEEP_POWER is
> >> enabled.
> >
> > So the platform supports to maintain the power for the embedded wifi
> > chip during system suspend, but the SDIO func driver (for the WiFi
> > chip) doesn't implement its part correctly. Did I get that right?
> >
> > In that case, it sounds to me like we should try to fix the support
> > for power management in the SDIO func driver instead, no?
> > I am happy to help with guidance/review if that is needed. What SDIO
> > func driver is this about?
> >
> > Kind regards
> > Uffe
> >
>
> Hi Ulf,
>
> I blindly pushed the patch without rechecking it.
> I rephrased it in our downstream to better explain the issue:
>
> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> It doesn't correctly support low power on this board. The Wifi chip
> awaits an always-on regulator, but it was connected to v3v3 which is off
> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
>
> If it's OK for you, I'll resend the patch with the updated commit message.

Yes, that works fine for me!

[...]

Kind regards
Uffe

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

* [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14  9:52 [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config Yann Gautier
  2022-03-14 11:17 ` Ulf Hansson
@ 2022-03-14 12:55 ` Yann Gautier
  2022-03-14 13:03   ` Ulf Hansson
  2022-03-14 13:05   ` Philipp Zabel
  1 sibling, 2 replies; 14+ messages in thread
From: Yann Gautier @ 2022-03-14 12:55 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek,
	Yann Gautier

Add a disable_keep_power field in variant_data struct. The
MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
It is only set to true for stm32_sdmmc variants.

The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
It doesn't correctly support low power on this board. The Wifi chip
awaits an always-on regulator, but it was connected to v3v3 which is off
in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.

The flag can still be enabled through DT property:
keep-power-in-suspend.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
---
Update in v2:
Reword commit message to better explain the issue.

Resend the patch alone. It was previoulsy in a series [1] for which the
other patches will be reworked.

[1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/

 drivers/mmc/host/mmci.c | 5 ++++-
 drivers/mmc/host/mmci.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 45b8608c935c..0e2f2f5d6a52 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
 	.busy_detect		= true,
 	.busy_detect_flag	= MCI_STM32_BUSYD0,
 	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.disable_keep_power	= true,
 	.init			= sdmmc_variant_init,
 };
 
@@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
 	.busy_detect		= true,
 	.busy_detect_flag	= MCI_STM32_BUSYD0,
 	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.disable_keep_power	= true,
 	.init			= sdmmc_variant_init,
 };
 
@@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
 	host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
 
 	/* We support these PM capabilities. */
-	mmc->pm_caps |= MMC_PM_KEEP_POWER;
+	if (!variant->disable_keep_power)
+		mmc->pm_caps |= MMC_PM_KEEP_POWER;
 
 	/*
 	 * We can do SGIO
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index e1a9b96a3396..2cad1ef9766a 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -361,6 +361,7 @@ struct variant_data {
 	u32			opendrain;
 	u8			dma_lli:1;
 	u32			stm32_idmabsize_mask;
+	u8			disable_keep_power:1;
 	void (*init)(struct mmci_host *host);
 };
 
-- 
2.25.1


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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 12:55 ` [PATCH v2] " Yann Gautier
@ 2022-03-14 13:03   ` Ulf Hansson
  2022-03-14 14:34     ` Yann Gautier
  2022-03-14 13:05   ` Philipp Zabel
  1 sibling, 1 reply; 14+ messages in thread
From: Ulf Hansson @ 2022-03-14 13:03 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> Add a disable_keep_power field in variant_data struct. The
> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> It is only set to true for stm32_sdmmc variants.
>
> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> It doesn't correctly support low power on this board. The Wifi chip
> awaits an always-on regulator, but it was connected to v3v3 which is off
> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.

Just to make sure I get this correct.

Why can't the regulator stay on during system suspend? The point is,
we don't need an always on regulator to cope with this.

Kind regards
Uffe

>
> The flag can still be enabled through DT property:
> keep-power-in-suspend.
>
> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> ---
> Update in v2:
> Reword commit message to better explain the issue.
>
> Resend the patch alone. It was previoulsy in a series [1] for which the
> other patches will be reworked.
>
> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>
>  drivers/mmc/host/mmci.c | 5 ++++-
>  drivers/mmc/host/mmci.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 45b8608c935c..0e2f2f5d6a52 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>
> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>
> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>         host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>
>         /* We support these PM capabilities. */
> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
> +       if (!variant->disable_keep_power)
> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>
>         /*
>          * We can do SGIO
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index e1a9b96a3396..2cad1ef9766a 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -361,6 +361,7 @@ struct variant_data {
>         u32                     opendrain;
>         u8                      dma_lli:1;
>         u32                     stm32_idmabsize_mask;
> +       u8                      disable_keep_power:1;
>         void (*init)(struct mmci_host *host);
>  };
>
> --
> 2.25.1
>

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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 12:55 ` [PATCH v2] " Yann Gautier
  2022-03-14 13:03   ` Ulf Hansson
@ 2022-03-14 13:05   ` Philipp Zabel
  2022-03-14 13:45     ` Yann Gautier
  1 sibling, 1 reply; 14+ messages in thread
From: Philipp Zabel @ 2022-03-14 13:05 UTC (permalink / raw)
  To: Yann Gautier, Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Russell King, Marek Vasut, kernel,
	Manivannan Sadhasivam, Grzegorz Szymaszek

Hi Yann,

On Mo, 2022-03-14 at 13:55 +0100, Yann Gautier wrote:
> Add a disable_keep_power field in variant_data struct. The
> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not
> set.
> It is only set to true for stm32_sdmmc variants.
> 
> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi
> chip.
> It doesn't correctly support low power on this board. The Wifi chip
> awaits an always-on regulator, but it was connected to v3v3 which is
> off
> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
> 
> The flag can still be enabled through DT property:
> keep-power-in-suspend.
> 
> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> ---
> Update in v2:
> Reword commit message to better explain the issue.
> 
> Resend the patch alone. It was previoulsy in a series [1] for which
> the
> other patches will be reworked.
> 
> [1] 
> https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
> 
>  drivers/mmc/host/mmci.c | 5 ++++-
>  drivers/mmc/host/mmci.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 45b8608c935c..0e2f2f5d6a52 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc =
> {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>  
> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2
> = {
>         .busy_detect            = true,
>         .busy_detect_flag       = MCI_STM32_BUSYD0,
>         .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> +       .disable_keep_power     = true,
>         .init                   = sdmmc_variant_init,
>  };
>  
> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>         host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>  
>         /* We support these PM capabilities. */
> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
> +       if (!variant->disable_keep_power)
> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>  
>         /*
>          * We can do SGIO
> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> index e1a9b96a3396..2cad1ef9766a 100644
> --- a/drivers/mmc/host/mmci.h
> +++ b/drivers/mmc/host/mmci.h
> @@ -361,6 +361,7 @@ struct variant_data {
>         u32                     opendrain;
>         u8                      dma_lli:1;
>         u32                     stm32_idmabsize_mask;
> +       u8                      disable_keep_power:1;

There are already four separate bitfields in struct variant_data, why
not move this up into one of them?

regards
Philipp

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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 13:05   ` Philipp Zabel
@ 2022-03-14 13:45     ` Yann Gautier
  0 siblings, 0 replies; 14+ messages in thread
From: Yann Gautier @ 2022-03-14 13:45 UTC (permalink / raw)
  To: Philipp Zabel, Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Russell King, Marek Vasut, kernel,
	Manivannan Sadhasivam, Grzegorz Szymaszek

On 3/14/22 14:05, Philipp Zabel wrote:
> Hi Yann,
> 
> On Mo, 2022-03-14 at 13:55 +0100, Yann Gautier wrote:
>> Add a disable_keep_power field in variant_data struct. The
>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not
>> set.
>> It is only set to true for stm32_sdmmc variants.
>>
>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi
>> chip.
>> It doesn't correctly support low power on this board. The Wifi chip
>> awaits an always-on regulator, but it was connected to v3v3 which is
>> off
>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
>>
>> The flag can still be enabled through DT property:
>> keep-power-in-suspend.
>>
>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
>> ---
>> Update in v2:
>> Reword commit message to better explain the issue.
>>
>> Resend the patch alone. It was previoulsy in a series [1] for which
>> the
>> other patches will be reworked.
>>
>> [1]
>> https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>>
>>   drivers/mmc/host/mmci.c | 5 ++++-
>>   drivers/mmc/host/mmci.h | 1 +
>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 45b8608c935c..0e2f2f5d6a52 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc =
>> {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>   
>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2
>> = {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>   
>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>>          host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>>   
>>          /* We support these PM capabilities. */
>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
>> +       if (!variant->disable_keep_power)
>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>   
>>          /*
>>           * We can do SGIO
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index e1a9b96a3396..2cad1ef9766a 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -361,6 +361,7 @@ struct variant_data {
>>          u32                     opendrain;
>>          u8                      dma_lli:1;
>>          u32                     stm32_idmabsize_mask;
>> +       u8                      disable_keep_power:1;
> 
> There are already four separate bitfields in struct variant_data, why
> not move this up into one of them?
> 
> regards
> Philipp

Hi Philipp,

You're right, I'll put it with the previous bitfiled in v3.

Best regards,
Yann

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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 13:03   ` Ulf Hansson
@ 2022-03-14 14:34     ` Yann Gautier
  2022-03-14 16:18       ` Ulf Hansson
  0 siblings, 1 reply; 14+ messages in thread
From: Yann Gautier @ 2022-03-14 14:34 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On 3/14/22 14:03, Ulf Hansson wrote:
> On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>
>> Add a disable_keep_power field in variant_data struct. The
>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
>> It is only set to true for stm32_sdmmc variants.
>>
>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
>> It doesn't correctly support low power on this board. The Wifi chip
>> awaits an always-on regulator, but it was connected to v3v3 which is off
>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
> 
> Just to make sure I get this correct.
> 
> Why can't the regulator stay on during system suspend? The point is,
> we don't need an always on regulator to cope with this.
> 
> Kind regards
> Uffe

Hi Ulf,

This v3v3 regulator powers most of the devices on this board. So we need 
to switch it off to gain power in suspend mode.


Yann

> 
>>
>> The flag can still be enabled through DT property:
>> keep-power-in-suspend.
>>
>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
>> ---
>> Update in v2:
>> Reword commit message to better explain the issue.
>>
>> Resend the patch alone. It was previoulsy in a series [1] for which the
>> other patches will be reworked.
>>
>> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>>
>>   drivers/mmc/host/mmci.c | 5 ++++-
>>   drivers/mmc/host/mmci.h | 1 +
>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index 45b8608c935c..0e2f2f5d6a52 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>
>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>>          .busy_detect            = true,
>>          .busy_detect_flag       = MCI_STM32_BUSYD0,
>>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>> +       .disable_keep_power     = true,
>>          .init                   = sdmmc_variant_init,
>>   };
>>
>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>>          host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>>
>>          /* We support these PM capabilities. */
>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
>> +       if (!variant->disable_keep_power)
>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>
>>          /*
>>           * We can do SGIO
>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>> index e1a9b96a3396..2cad1ef9766a 100644
>> --- a/drivers/mmc/host/mmci.h
>> +++ b/drivers/mmc/host/mmci.h
>> @@ -361,6 +361,7 @@ struct variant_data {
>>          u32                     opendrain;
>>          u8                      dma_lli:1;
>>          u32                     stm32_idmabsize_mask;
>> +       u8                      disable_keep_power:1;
>>          void (*init)(struct mmci_host *host);
>>   };
>>
>> --
>> 2.25.1
>>


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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 14:34     ` Yann Gautier
@ 2022-03-14 16:18       ` Ulf Hansson
  2022-03-14 16:51         ` Yann Gautier
  0 siblings, 1 reply; 14+ messages in thread
From: Ulf Hansson @ 2022-03-14 16:18 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On Mon, 14 Mar 2022 at 15:34, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> On 3/14/22 14:03, Ulf Hansson wrote:
> > On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>
> >> Add a disable_keep_power field in variant_data struct. The
> >> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> >> It is only set to true for stm32_sdmmc variants.
> >>
> >> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> >> It doesn't correctly support low power on this board. The Wifi chip
> >> awaits an always-on regulator, but it was connected to v3v3 which is off
> >> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
> >
> > Just to make sure I get this correct.
> >
> > Why can't the regulator stay on during system suspend? The point is,
> > we don't need an always on regulator to cope with this.
> >
> > Kind regards
> > Uffe
>
> Hi Ulf,
>
> This v3v3 regulator powers most of the devices on this board. So we need
> to switch it off to gain power in suspend mode.

I see. Thanks for sharing that information.

The MMC_PM_KEEP_POWER flag is there to describe what is supported by
the platform/host. It doesn't mean that the card *must* stay powered
on during system suspend. Instead that depends on whether system
wakeup for the SDIO/WiFi is supported too - and if that is enabled by
userspace. If not, the regulator will be turned off for the SDIO card
during system suspend.

Assuming the regulator is implemented as a proper regulator and can
remain on during system suspend, the right thing would be to keep the
MMC_PM_KEEP_POWER flag around.

Kind regards
Uffe

>
>
> Yann
>
> >
> >>
> >> The flag can still be enabled through DT property:
> >> keep-power-in-suspend.
> >>
> >> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> >> ---
> >> Update in v2:
> >> Reword commit message to better explain the issue.
> >>
> >> Resend the patch alone. It was previoulsy in a series [1] for which the
> >> other patches will be reworked.
> >>
> >> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
> >>
> >>   drivers/mmc/host/mmci.c | 5 ++++-
> >>   drivers/mmc/host/mmci.h | 1 +
> >>   2 files changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> >> index 45b8608c935c..0e2f2f5d6a52 100644
> >> --- a/drivers/mmc/host/mmci.c
> >> +++ b/drivers/mmc/host/mmci.c
> >> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
> >>          .busy_detect            = true,
> >>          .busy_detect_flag       = MCI_STM32_BUSYD0,
> >>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> >> +       .disable_keep_power     = true,
> >>          .init                   = sdmmc_variant_init,
> >>   };
> >>
> >> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
> >>          .busy_detect            = true,
> >>          .busy_detect_flag       = MCI_STM32_BUSYD0,
> >>          .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> >> +       .disable_keep_power     = true,
> >>          .init                   = sdmmc_variant_init,
> >>   };
> >>
> >> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
> >>          host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
> >>
> >>          /* We support these PM capabilities. */
> >> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
> >> +       if (!variant->disable_keep_power)
> >> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
> >>
> >>          /*
> >>           * We can do SGIO
> >> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> >> index e1a9b96a3396..2cad1ef9766a 100644
> >> --- a/drivers/mmc/host/mmci.h
> >> +++ b/drivers/mmc/host/mmci.h
> >> @@ -361,6 +361,7 @@ struct variant_data {
> >>          u32                     opendrain;
> >>          u8                      dma_lli:1;
> >>          u32                     stm32_idmabsize_mask;
> >> +       u8                      disable_keep_power:1;
> >>          void (*init)(struct mmci_host *host);
> >>   };
> >>
> >> --
> >> 2.25.1
> >>
>

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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 16:18       ` Ulf Hansson
@ 2022-03-14 16:51         ` Yann Gautier
  2022-03-15  9:07           ` Ulf Hansson
  0 siblings, 1 reply; 14+ messages in thread
From: Yann Gautier @ 2022-03-14 16:51 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On 3/14/22 17:18, Ulf Hansson wrote:
> On Mon, 14 Mar 2022 at 15:34, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>
>> On 3/14/22 14:03, Ulf Hansson wrote:
>>> On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>>>
>>>> Add a disable_keep_power field in variant_data struct. The
>>>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
>>>> It is only set to true for stm32_sdmmc variants.
>>>>
>>>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
>>>> It doesn't correctly support low power on this board. The Wifi chip
>>>> awaits an always-on regulator, but it was connected to v3v3 which is off
>>>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
>>>
>>> Just to make sure I get this correct.
>>>
>>> Why can't the regulator stay on during system suspend? The point is,
>>> we don't need an always on regulator to cope with this.
>>>
>>> Kind regards
>>> Uffe
>>
>> Hi Ulf,
>>
>> This v3v3 regulator powers most of the devices on this board. So we need
>> to switch it off to gain power in suspend mode.
> 
> I see. Thanks for sharing that information.
> 
> The MMC_PM_KEEP_POWER flag is there to describe what is supported by
> the platform/host. It doesn't mean that the card *must* stay powered
> on during system suspend. Instead that depends on whether system
> wakeup for the SDIO/WiFi is supported too - and if that is enabled by
> userspace. If not, the regulator will be turned off for the SDIO card
> during system suspend.
> 
> Assuming the regulator is implemented as a proper regulator and can
> remain on during system suspend, the right thing would be to keep the
> MMC_PM_KEEP_POWER flag around.
> 
> Kind regards
> Uffe
> 

OK, but in the wifi driver we use on this platform (brcmfmac), the 
suspend/resume functions (brcmf_ops_sdio_suspend/brcmf_ops_sdio_resume) 
use the flag to check regu was off, and then call probe function during 
resume, to re-init Wifi chip and reload its firmware.


Best regards,
Yann

>>
>>
>> Yann
>>
>>>
>>>>
>>>> The flag can still be enabled through DT property:
>>>> keep-power-in-suspend.
>>>>
>>>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
>>>> ---
>>>> Update in v2:
>>>> Reword commit message to better explain the issue.
>>>>
>>>> Resend the patch alone. It was previoulsy in a series [1] for which the
>>>> other patches will be reworked.
>>>>
>>>> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>>>>
>>>>    drivers/mmc/host/mmci.c | 5 ++++-
>>>>    drivers/mmc/host/mmci.h | 1 +
>>>>    2 files changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>>>> index 45b8608c935c..0e2f2f5d6a52 100644
>>>> --- a/drivers/mmc/host/mmci.c
>>>> +++ b/drivers/mmc/host/mmci.c
>>>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>>>>           .busy_detect            = true,
>>>>           .busy_detect_flag       = MCI_STM32_BUSYD0,
>>>>           .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>>>> +       .disable_keep_power     = true,
>>>>           .init                   = sdmmc_variant_init,
>>>>    };
>>>>
>>>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>>>>           .busy_detect            = true,
>>>>           .busy_detect_flag       = MCI_STM32_BUSYD0,
>>>>           .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>>>> +       .disable_keep_power     = true,
>>>>           .init                   = sdmmc_variant_init,
>>>>    };
>>>>
>>>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>>>>           host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>>>>
>>>>           /* We support these PM capabilities. */
>>>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>>> +       if (!variant->disable_keep_power)
>>>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>>>
>>>>           /*
>>>>            * We can do SGIO
>>>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>>>> index e1a9b96a3396..2cad1ef9766a 100644
>>>> --- a/drivers/mmc/host/mmci.h
>>>> +++ b/drivers/mmc/host/mmci.h
>>>> @@ -361,6 +361,7 @@ struct variant_data {
>>>>           u32                     opendrain;
>>>>           u8                      dma_lli:1;
>>>>           u32                     stm32_idmabsize_mask;
>>>> +       u8                      disable_keep_power:1;
>>>>           void (*init)(struct mmci_host *host);
>>>>    };
>>>>
>>>> --
>>>> 2.25.1
>>>>
>>


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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-14 16:51         ` Yann Gautier
@ 2022-03-15  9:07           ` Ulf Hansson
  2022-03-15 10:07             ` Yann Gautier
  0 siblings, 1 reply; 14+ messages in thread
From: Ulf Hansson @ 2022-03-15  9:07 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek

On Mon, 14 Mar 2022 at 17:52, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> On 3/14/22 17:18, Ulf Hansson wrote:
> > On Mon, 14 Mar 2022 at 15:34, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>
> >> On 3/14/22 14:03, Ulf Hansson wrote:
> >>> On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>>>
> >>>> Add a disable_keep_power field in variant_data struct. The
> >>>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> >>>> It is only set to true for stm32_sdmmc variants.
> >>>>
> >>>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> >>>> It doesn't correctly support low power on this board. The Wifi chip
> >>>> awaits an always-on regulator, but it was connected to v3v3 which is off
> >>>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
> >>>
> >>> Just to make sure I get this correct.
> >>>
> >>> Why can't the regulator stay on during system suspend? The point is,
> >>> we don't need an always on regulator to cope with this.
> >>>
> >>> Kind regards
> >>> Uffe
> >>
> >> Hi Ulf,
> >>
> >> This v3v3 regulator powers most of the devices on this board. So we need
> >> to switch it off to gain power in suspend mode.
> >
> > I see. Thanks for sharing that information.
> >
> > The MMC_PM_KEEP_POWER flag is there to describe what is supported by
> > the platform/host. It doesn't mean that the card *must* stay powered
> > on during system suspend. Instead that depends on whether system
> > wakeup for the SDIO/WiFi is supported too - and if that is enabled by
> > userspace. If not, the regulator will be turned off for the SDIO card
> > during system suspend.
> >
> > Assuming the regulator is implemented as a proper regulator and can
> > remain on during system suspend, the right thing would be to keep the
> > MMC_PM_KEEP_POWER flag around.
> >
> > Kind regards
> > Uffe
> >
>
> OK, but in the wifi driver we use on this platform (brcmfmac), the
> suspend/resume functions (brcmf_ops_sdio_suspend/brcmf_ops_sdio_resume)
> use the flag to check regu was off, and then call probe function during
> resume, to re-init Wifi chip and reload its firmware.

I had a closer look at the brcmfmac driver, thanks for the pointers.

In my opinion, I think we should change the brcmfmac driver, so it
decides to power off the SDIO card, unless the WiFi chip is configured
to serve us with system wakeups.

I can send a patch for brcmfmac that we can try, unless you want to
send it yourself?

>
>
> Best regards,
> Yann

Kind regards
Uffe

>
> >>
> >>
> >> Yann
> >>
> >>>
> >>>>
> >>>> The flag can still be enabled through DT property:
> >>>> keep-power-in-suspend.
> >>>>
> >>>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
> >>>> ---
> >>>> Update in v2:
> >>>> Reword commit message to better explain the issue.
> >>>>
> >>>> Resend the patch alone. It was previoulsy in a series [1] for which the
> >>>> other patches will be reworked.
> >>>>
> >>>> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
> >>>>
> >>>>    drivers/mmc/host/mmci.c | 5 ++++-
> >>>>    drivers/mmc/host/mmci.h | 1 +
> >>>>    2 files changed, 5 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> >>>> index 45b8608c935c..0e2f2f5d6a52 100644
> >>>> --- a/drivers/mmc/host/mmci.c
> >>>> +++ b/drivers/mmc/host/mmci.c
> >>>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
> >>>>           .busy_detect            = true,
> >>>>           .busy_detect_flag       = MCI_STM32_BUSYD0,
> >>>>           .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> >>>> +       .disable_keep_power     = true,
> >>>>           .init                   = sdmmc_variant_init,
> >>>>    };
> >>>>
> >>>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
> >>>>           .busy_detect            = true,
> >>>>           .busy_detect_flag       = MCI_STM32_BUSYD0,
> >>>>           .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
> >>>> +       .disable_keep_power     = true,
> >>>>           .init                   = sdmmc_variant_init,
> >>>>    };
> >>>>
> >>>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
> >>>>           host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
> >>>>
> >>>>           /* We support these PM capabilities. */
> >>>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
> >>>> +       if (!variant->disable_keep_power)
> >>>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
> >>>>
> >>>>           /*
> >>>>            * We can do SGIO
> >>>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
> >>>> index e1a9b96a3396..2cad1ef9766a 100644
> >>>> --- a/drivers/mmc/host/mmci.h
> >>>> +++ b/drivers/mmc/host/mmci.h
> >>>> @@ -361,6 +361,7 @@ struct variant_data {
> >>>>           u32                     opendrain;
> >>>>           u8                      dma_lli:1;
> >>>>           u32                     stm32_idmabsize_mask;
> >>>> +       u8                      disable_keep_power:1;
> >>>>           void (*init)(struct mmci_host *host);
> >>>>    };
> >>>>
> >>>> --
> >>>> 2.25.1
> >>>>
> >>
>

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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-15  9:07           ` Ulf Hansson
@ 2022-03-15 10:07             ` Yann Gautier
  2022-03-15 12:30               ` Ulf Hansson
  0 siblings, 1 reply; 14+ messages in thread
From: Yann Gautier @ 2022-03-15 10:07 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek,
	Christophe ROULLIER-SCND-02

On 3/15/22 10:07, Ulf Hansson wrote:
> On Mon, 14 Mar 2022 at 17:52, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>
>> On 3/14/22 17:18, Ulf Hansson wrote:
>>> On Mon, 14 Mar 2022 at 15:34, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>>>
>>>> On 3/14/22 14:03, Ulf Hansson wrote:
>>>>> On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
>>>>>>
>>>>>> Add a disable_keep_power field in variant_data struct. The
>>>>>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
>>>>>> It is only set to true for stm32_sdmmc variants.
>>>>>>
>>>>>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
>>>>>> It doesn't correctly support low power on this board. The Wifi chip
>>>>>> awaits an always-on regulator, but it was connected to v3v3 which is off
>>>>>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
>>>>>
>>>>> Just to make sure I get this correct.
>>>>>
>>>>> Why can't the regulator stay on during system suspend? The point is,
>>>>> we don't need an always on regulator to cope with this.
>>>>>
>>>>> Kind regards
>>>>> Uffe
>>>>
>>>> Hi Ulf,
>>>>
>>>> This v3v3 regulator powers most of the devices on this board. So we need
>>>> to switch it off to gain power in suspend mode.
>>>
>>> I see. Thanks for sharing that information.
>>>
>>> The MMC_PM_KEEP_POWER flag is there to describe what is supported by
>>> the platform/host. It doesn't mean that the card *must* stay powered
>>> on during system suspend. Instead that depends on whether system
>>> wakeup for the SDIO/WiFi is supported too - and if that is enabled by
>>> userspace. If not, the regulator will be turned off for the SDIO card
>>> during system suspend.
>>>
>>> Assuming the regulator is implemented as a proper regulator and can
>>> remain on during system suspend, the right thing would be to keep the
>>> MMC_PM_KEEP_POWER flag around.
>>>
>>> Kind regards
>>> Uffe
>>>
>>
>> OK, but in the wifi driver we use on this platform (brcmfmac), the
>> suspend/resume functions (brcmf_ops_sdio_suspend/brcmf_ops_sdio_resume)
>> use the flag to check regu was off, and then call probe function during
>> resume, to re-init Wifi chip and reload its firmware.
> 
> I had a closer look at the brcmfmac driver, thanks for the pointers.
> 
> In my opinion, I think we should change the brcmfmac driver, so it
> decides to power off the SDIO card, unless the WiFi chip is configured
> to serve us with system wakeups.
> 
> I can send a patch for brcmfmac that we can try, unless you want to
> send it yourself?
> 

Hi Ulf,
If you already have an idea of the patch in the brcmfmac driver, can you 
propose something?
We'll be able to test it at our side.

Thanks,
Yann

>>
>>
>> Best regards,
>> Yann
> 
> Kind regards
> Uffe
> >>
>>>>
>>>>
>>>> Yann
>>>>
>>>>>
>>>>>>
>>>>>> The flag can still be enabled through DT property:
>>>>>> keep-power-in-suspend.
>>>>>>
>>>>>> Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
>>>>>> ---
>>>>>> Update in v2:
>>>>>> Reword commit message to better explain the issue.
>>>>>>
>>>>>> Resend the patch alone. It was previoulsy in a series [1] for which the
>>>>>> other patches will be reworked.
>>>>>>
>>>>>> [1] https://lore.kernel.org/lkml/20220304135134.47827-1-yann.gautier@foss.st.com/
>>>>>>
>>>>>>     drivers/mmc/host/mmci.c | 5 ++++-
>>>>>>     drivers/mmc/host/mmci.h | 1 +
>>>>>>     2 files changed, 5 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>>>>>> index 45b8608c935c..0e2f2f5d6a52 100644
>>>>>> --- a/drivers/mmc/host/mmci.c
>>>>>> +++ b/drivers/mmc/host/mmci.c
>>>>>> @@ -274,6 +274,7 @@ static struct variant_data variant_stm32_sdmmc = {
>>>>>>            .busy_detect            = true,
>>>>>>            .busy_detect_flag       = MCI_STM32_BUSYD0,
>>>>>>            .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>>>>>> +       .disable_keep_power     = true,
>>>>>>            .init                   = sdmmc_variant_init,
>>>>>>     };
>>>>>>
>>>>>> @@ -301,6 +302,7 @@ static struct variant_data variant_stm32_sdmmcv2 = {
>>>>>>            .busy_detect            = true,
>>>>>>            .busy_detect_flag       = MCI_STM32_BUSYD0,
>>>>>>            .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
>>>>>> +       .disable_keep_power     = true,
>>>>>>            .init                   = sdmmc_variant_init,
>>>>>>     };
>>>>>>
>>>>>> @@ -2172,7 +2174,8 @@ static int mmci_probe(struct amba_device *dev,
>>>>>>            host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
>>>>>>
>>>>>>            /* We support these PM capabilities. */
>>>>>> -       mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>>>>> +       if (!variant->disable_keep_power)
>>>>>> +               mmc->pm_caps |= MMC_PM_KEEP_POWER;
>>>>>>
>>>>>>            /*
>>>>>>             * We can do SGIO
>>>>>> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
>>>>>> index e1a9b96a3396..2cad1ef9766a 100644
>>>>>> --- a/drivers/mmc/host/mmci.h
>>>>>> +++ b/drivers/mmc/host/mmci.h
>>>>>> @@ -361,6 +361,7 @@ struct variant_data {
>>>>>>            u32                     opendrain;
>>>>>>            u8                      dma_lli:1;
>>>>>>            u32                     stm32_idmabsize_mask;
>>>>>> +       u8                      disable_keep_power:1;
>>>>>>            void (*init)(struct mmci_host *host);
>>>>>>     };
>>>>>>
>>>>>> --
>>>>>> 2.25.1
>>>>>>
>>>>
>>


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

* Re: [PATCH v2] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config
  2022-03-15 10:07             ` Yann Gautier
@ 2022-03-15 12:30               ` Ulf Hansson
  0 siblings, 0 replies; 14+ messages in thread
From: Ulf Hansson @ 2022-03-15 12:30 UTC (permalink / raw)
  To: Yann Gautier
  Cc: linux-kernel, linux-mmc, linux-stm32, Christophe Kerello,
	Linus Walleij, Ludovic Barre, Philipp Zabel, Russell King,
	Marek Vasut, kernel, Manivannan Sadhasivam, Grzegorz Szymaszek,
	Christophe ROULLIER-SCND-02

On Tue, 15 Mar 2022 at 11:08, Yann Gautier <yann.gautier@foss.st.com> wrote:
>
> On 3/15/22 10:07, Ulf Hansson wrote:
> > On Mon, 14 Mar 2022 at 17:52, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>
> >> On 3/14/22 17:18, Ulf Hansson wrote:
> >>> On Mon, 14 Mar 2022 at 15:34, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>>>
> >>>> On 3/14/22 14:03, Ulf Hansson wrote:
> >>>>> On Mon, 14 Mar 2022 at 13:56, Yann Gautier <yann.gautier@foss.st.com> wrote:
> >>>>>>
> >>>>>> Add a disable_keep_power field in variant_data struct. The
> >>>>>> MMC_PM_KEEP_POWER flag will be enabled if disable_keep_power is not set.
> >>>>>> It is only set to true for stm32_sdmmc variants.
> >>>>>>
> >>>>>> The issue was seen on STM32MP157C-DK2 board, which embeds a wifi chip.
> >>>>>> It doesn't correctly support low power on this board. The Wifi chip
> >>>>>> awaits an always-on regulator, but it was connected to v3v3 which is off
> >>>>>> in low-power sequence. MMC_PM_KEEP_POWER should then be disabled.
> >>>>>
> >>>>> Just to make sure I get this correct.
> >>>>>
> >>>>> Why can't the regulator stay on during system suspend? The point is,
> >>>>> we don't need an always on regulator to cope with this.
> >>>>>
> >>>>> Kind regards
> >>>>> Uffe
> >>>>
> >>>> Hi Ulf,
> >>>>
> >>>> This v3v3 regulator powers most of the devices on this board. So we need
> >>>> to switch it off to gain power in suspend mode.
> >>>
> >>> I see. Thanks for sharing that information.
> >>>
> >>> The MMC_PM_KEEP_POWER flag is there to describe what is supported by
> >>> the platform/host. It doesn't mean that the card *must* stay powered
> >>> on during system suspend. Instead that depends on whether system
> >>> wakeup for the SDIO/WiFi is supported too - and if that is enabled by
> >>> userspace. If not, the regulator will be turned off for the SDIO card
> >>> during system suspend.
> >>>
> >>> Assuming the regulator is implemented as a proper regulator and can
> >>> remain on during system suspend, the right thing would be to keep the
> >>> MMC_PM_KEEP_POWER flag around.
> >>>
> >>> Kind regards
> >>> Uffe
> >>>
> >>
> >> OK, but in the wifi driver we use on this platform (brcmfmac), the
> >> suspend/resume functions (brcmf_ops_sdio_suspend/brcmf_ops_sdio_resume)
> >> use the flag to check regu was off, and then call probe function during
> >> resume, to re-init Wifi chip and reload its firmware.
> >
> > I had a closer look at the brcmfmac driver, thanks for the pointers.
> >
> > In my opinion, I think we should change the brcmfmac driver, so it
> > decides to power off the SDIO card, unless the WiFi chip is configured
> > to serve us with system wakeups.
> >
> > I can send a patch for brcmfmac that we can try, unless you want to
> > send it yourself?
> >
>
> Hi Ulf,
> If you already have an idea of the patch in the brcmfmac driver, can you
> propose something?

Sure, I will post a patch as soon as I can.

> We'll be able to test it at our side.

Great, I will keep you posted!

[...]

Kind regards
Uffe

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

end of thread, other threads:[~2022-03-15 12:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14  9:52 [PATCH RESEND] mmc: mmci: manage MMC_PM_KEEP_POWER per variant config Yann Gautier
2022-03-14 11:17 ` Ulf Hansson
2022-03-14 12:20   ` Yann Gautier
2022-03-14 12:53     ` Ulf Hansson
2022-03-14 12:55 ` [PATCH v2] " Yann Gautier
2022-03-14 13:03   ` Ulf Hansson
2022-03-14 14:34     ` Yann Gautier
2022-03-14 16:18       ` Ulf Hansson
2022-03-14 16:51         ` Yann Gautier
2022-03-15  9:07           ` Ulf Hansson
2022-03-15 10:07             ` Yann Gautier
2022-03-15 12:30               ` Ulf Hansson
2022-03-14 13:05   ` Philipp Zabel
2022-03-14 13:45     ` Yann Gautier

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