public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: allow rescan of non-removable hosts on resume
@ 2017-12-06 10:57 Daniel Drake
  2017-12-11 13:11 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2017-12-06 10:57 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, linux, matthew.leeds

The Weibu F3C MiniPC has an onboard AP6255 module, presenting
two SDIO functions on a single MMC host (Bluetooth/btsdio and
WiFi/brcmfmac), and the mmc layer correctly detects this as
non-removable.

After suspend/resume, the wifi and bluetooth interfaces disappear
and do not get probed again.

The conditions here are:

 1. During suspend, we reach mmc_pm_notify()

 2. mmc_pm_notify() calls mmc_sdio_pre_suspend() to see if we can
    suspend the SDIO host. However, mmc_sdio_pre_suspend() returns
    -ENOSYS because btsdio_driver does not have a suspend method.

 3. mmc_pm_notify() proceeds to remove the card

 4. Upon resume, mmc_rescan() does nothing with this host, because of
    the rescan_entered check which aims to only scan a non-removable
    device a single time (i.e. during boot).

Fix the loss of functionality by permitting another rescan of
non-removable devices when we forcefully remove a card under these
conditions.

Signed-off-by: Daniel Drake <drake@endlessm.com>
---
 drivers/mmc/core/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 1f0f44f4dd5f..e436cde50bc4 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2966,6 +2966,10 @@ static int mmc_pm_notify(struct notifier_block *notify_block,
 		mmc_power_off(host);
 		mmc_release_host(host);
 		host->pm_flags = 0;
+
+		/* Force a rescan on resume, even for non-removable cards */
+		host->rescan_entered = 0;
+
 		break;
 
 	case PM_POST_SUSPEND:
-- 
2.14.1


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

* Re: [PATCH] mmc: allow rescan of non-removable hosts on resume
  2017-12-06 10:57 [PATCH] mmc: allow rescan of non-removable hosts on resume Daniel Drake
@ 2017-12-11 13:11 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2017-12-11 13:11 UTC (permalink / raw)
  To: Daniel Drake; +Cc: linux-mmc@vger.kernel.org, linux, matthew.leeds

On 6 December 2017 at 11:57, Daniel Drake <drake@endlessm.com> wrote:
> The Weibu F3C MiniPC has an onboard AP6255 module, presenting
> two SDIO functions on a single MMC host (Bluetooth/btsdio and
> WiFi/brcmfmac), and the mmc layer correctly detects this as
> non-removable.
>
> After suspend/resume, the wifi and bluetooth interfaces disappear
> and do not get probed again.
>
> The conditions here are:
>
>  1. During suspend, we reach mmc_pm_notify()
>
>  2. mmc_pm_notify() calls mmc_sdio_pre_suspend() to see if we can
>     suspend the SDIO host. However, mmc_sdio_pre_suspend() returns
>     -ENOSYS because btsdio_driver does not have a suspend method.
>
>  3. mmc_pm_notify() proceeds to remove the card
>
>  4. Upon resume, mmc_rescan() does nothing with this host, because of
>     the rescan_entered check which aims to only scan a non-removable
>     device a single time (i.e. during boot).

Thanks for detailed description of the problem, it really helps!

>
> Fix the loss of functionality by permitting another rescan of
> non-removable devices when we forcefully remove a card under these
> conditions.

No, I don't like this solution, simply because I think it's a
workaround rather than a proper fix.

I think the SDIO func drivers should implement the suspend/resume
callbacks instead.

One may argue that the mmc_pm_notify() then shouldn't have removed the
card in first place if the cards are non-removable. Maybe we should
just print a warning in that case instead.

>
> Signed-off-by: Daniel Drake <drake@endlessm.com>
> ---
>  drivers/mmc/core/core.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 1f0f44f4dd5f..e436cde50bc4 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2966,6 +2966,10 @@ static int mmc_pm_notify(struct notifier_block *notify_block,
>                 mmc_power_off(host);
>                 mmc_release_host(host);
>                 host->pm_flags = 0;
> +
> +               /* Force a rescan on resume, even for non-removable cards */
> +               host->rescan_entered = 0;
> +
>                 break;
>
>         case PM_POST_SUSPEND:
> --
> 2.14.1
>

Kind regards
Uffe

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

end of thread, other threads:[~2017-12-11 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 10:57 [PATCH] mmc: allow rescan of non-removable hosts on resume Daniel Drake
2017-12-11 13:11 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox