All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: refine non-removable card checking for card detection
@ 2012-04-09 23:14 Daniel Drake
  2012-04-10  8:05 ` Sascha Silbe
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel Drake @ 2012-04-09 23:14 UTC (permalink / raw)
  To: cjb; +Cc: linux-mmc, adrian.hunter

Commit c79396c191bc19703df6eb6bbd0f673ed0df6c9d disables card detection
where the cards are marked as non-removable.

This makes sense, but the implementation detail of calling
mmc_card_is_removable() causes some problems, because
mmc_card_is_removable() is overloaded with CONFIG_MMC_UNSAFE_RESUME
semantics.

In the OLPC XO case, we need CONFIG_MMC_UNSAFE_RESUME because our root
filesystem is stored on SD, but we also have external SD card slots
where we want automatic card detection.

Refine the check to only apply to hosts marked as MMC_CAP_NONREMOVABLE,
which is defined to mean that the card is *really* nonremovable. This
could be revisited in future if we find a way to improve
CONFIG_MMC_UNSAFE_RESUME semantics.

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/mmc/host/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9aa77f3..ccefdeb 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -147,7 +147,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
 	u32 present, irqs;
 
 	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
-	    !mmc_card_is_removable(host->mmc))
+	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
 		return;
 
 	present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
-- 
1.7.7.6


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

* Re: [PATCH] mmc: sdhci: refine non-removable card checking for card detection
  2012-04-09 23:14 [PATCH] mmc: sdhci: refine non-removable card checking for card detection Daniel Drake
@ 2012-04-10  8:05 ` Sascha Silbe
  2012-04-17 14:48   ` Daniel Drake
  2012-04-13  4:53 ` Dong, Chuanxiao
  2012-04-18 23:57 ` Chris Ball
  2 siblings, 1 reply; 5+ messages in thread
From: Sascha Silbe @ 2012-04-10  8:05 UTC (permalink / raw)
  To: Daniel Drake; +Cc: cjb, linux-mmc

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Excerpts from Daniel Drake's message of 2012-04-10 01:14:20 +0200:

> In the OLPC XO case, we need CONFIG_MMC_UNSAFE_RESUME because our root
> filesystem is stored on SD, but we also have external SD card slots
> where we want automatic card detection.
> 
> Refine the check to only apply to hosts marked as MMC_CAP_NONREMOVABLE,
> which is defined to mean that the card is *really* nonremovable. This
> could be revisited in future if we find a way to improve
> CONFIG_MMC_UNSAFE_RESUME semantics.

What exactly is the behaviour after this patch? Will systems running
from SD cards attached to a host controller that's _not_ marked as
MMC_CAP_NONREMOVABLE (e.g. the external SD card slot on XOs) work again?
Or does it only fix running off internal SD cards (which are marked
MMC_CAP_NONREMOVABLE)?

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* RE: [PATCH] mmc: sdhci: refine non-removable card checking for card detection
  2012-04-09 23:14 [PATCH] mmc: sdhci: refine non-removable card checking for card detection Daniel Drake
  2012-04-10  8:05 ` Sascha Silbe
@ 2012-04-13  4:53 ` Dong, Chuanxiao
  2012-04-18 23:57 ` Chris Ball
  2 siblings, 0 replies; 5+ messages in thread
From: Dong, Chuanxiao @ 2012-04-13  4:53 UTC (permalink / raw)
  To: Daniel Drake, cjb; +Cc: linux-mmc, Hunter, Adrian


> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org
> [mailto:linux-mmc-owner@vger.kernel.org] On Behalf Of Daniel Drake
> Sent: Tuesday, April 10, 2012 7:14 AM
> To: cjb@laptop.org
> Cc: linux-mmc@vger.kernel.org; Hunter, Adrian
> Subject: [PATCH] mmc: sdhci: refine non-removable card checking for card detection
> 
> Commit c79396c191bc19703df6eb6bbd0f673ed0df6c9d disables card detection
> where the cards are marked as non-removable.
> 
> This makes sense, but the implementation detail of calling
> mmc_card_is_removable() causes some problems, because
> mmc_card_is_removable() is overloaded with CONFIG_MMC_UNSAFE_RESUME
> semantics.
> 
> In the OLPC XO case, we need CONFIG_MMC_UNSAFE_RESUME because our root
> filesystem is stored on SD, but we also have external SD card slots where we want
> automatic card detection.
> 
> Refine the check to only apply to hosts marked as MMC_CAP_NONREMOVABLE,
> which is defined to mean that the card is *really* nonremovable. This could be
> revisited in future if we find a way to improve CONFIG_MMC_UNSAFE_RESUME
> semantics.
> 
> Signed-off-by: Daniel Drake <dsd@laptop.org>
> ---
>  drivers/mmc/host/sdhci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> 9aa77f3..ccefdeb 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -147,7 +147,7 @@ static void sdhci_set_card_detection(struct sdhci_host
> *host, bool enable)
>  	u32 present, irqs;
> 
>  	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
> -	    !mmc_card_is_removable(host->mmc))
> +	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
>  		return;

If the SD card doesn't have a rootfs but only used to store media files, like the usage in Android, this patch is useful.

Since the Android user doesn't like the SD card (used to store media files only) to be removed by kernel when system entering S3, mmc_assume_removable will set to be 0 to prevent kernel remove SD card in suspending.

But if system is not in S3 state but in S0 state, a removable SD card slot still allow the end user to remove it. In this scenario, when mmc_assume_removable is 0, mmc_card_is_remoable will also return 0, to make SDHCI host disable card detection irqs. And finally, SDHCI host cannot detect SD card insert/removal interrupt. So I think Daniel's patch can help the Android user to fix this issue.

>From the usage of mmc_assume_removable, it is used for the SD cards who cannot be removed during suspending, but they can still be removed when out of suspending, they still have .remove/.detect callbacks.
>From the usage of the cap MMC_CAP_NONREMOVABLE, it is used for the SD cards who cannot be removed from the sd slots.
And for sdhci_set_card_detection(), it only needs to disable the card detection irqs for the SD cards who cannot be removed from the sd slots. So only checking mmc caps is enough here.

It looks good to me. Acked-by: Chuanxiao Dong <chuanxiao.dong@intel.com>

Thanks
Chuanxiao

> 
>  	present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
> --
> 1.7.7.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a
> message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] mmc: sdhci: refine non-removable card checking for card detection
  2012-04-10  8:05 ` Sascha Silbe
@ 2012-04-17 14:48   ` Daniel Drake
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Drake @ 2012-04-17 14:48 UTC (permalink / raw)
  To: Sascha Silbe; +Cc: cjb, linux-mmc

Hi,

On Tue, Apr 10, 2012 at 2:05 AM, Sascha Silbe <silbe@activitycentral.com> wrote:
> What exactly is the behaviour after this patch? Will systems running
> from SD cards attached to a host controller that's _not_ marked as
> MMC_CAP_NONREMOVABLE (e.g. the external SD card slot on XOs) work again?
> Or does it only fix running off internal SD cards (which are marked
> MMC_CAP_NONREMOVABLE)?

Not sure which issue you are referring to but it must be different.
This patch only affects cards that are inserted after boot and it
doesn't change the behaviour w.r.t MMC_CAP_NONREMOVABLE.

Daniel

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

* Re: [PATCH] mmc: sdhci: refine non-removable card checking for card detection
  2012-04-09 23:14 [PATCH] mmc: sdhci: refine non-removable card checking for card detection Daniel Drake
  2012-04-10  8:05 ` Sascha Silbe
  2012-04-13  4:53 ` Dong, Chuanxiao
@ 2012-04-18 23:57 ` Chris Ball
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Ball @ 2012-04-18 23:57 UTC (permalink / raw)
  To: Daniel Drake; +Cc: linux-mmc, Hunter, Adrian

Hi Dan,

On Mon, Apr 09 2012, Daniel Drake wrote:
> Commit c79396c191bc19703df6eb6bbd0f673ed0df6c9d disables card detection
> where the cards are marked as non-removable.
>
> This makes sense, but the implementation detail of calling
> mmc_card_is_removable() causes some problems, because
> mmc_card_is_removable() is overloaded with CONFIG_MMC_UNSAFE_RESUME
> semantics.
>
> In the OLPC XO case, we need CONFIG_MMC_UNSAFE_RESUME because our root
> filesystem is stored on SD, but we also have external SD card slots
> where we want automatic card detection.
>
> Refine the check to only apply to hosts marked as MMC_CAP_NONREMOVABLE,
> which is defined to mean that the card is *really* nonremovable. This
> could be revisited in future if we find a way to improve
> CONFIG_MMC_UNSAFE_RESUME semantics.
>
> Signed-off-by: Daniel Drake <dsd@laptop.org>
> ---
>  drivers/mmc/host/sdhci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 9aa77f3..ccefdeb 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -147,7 +147,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
>  	u32 present, irqs;
>  
>  	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
> -	    !mmc_card_is_removable(host->mmc))
> +	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
>  		return;
>  
>  	present = sdhci_readl(host, SDHCI_PRESENT_STATE) &

Thanks, pushed to mmc-next for 3.4 with Chuanxiao's ACK.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-04-18 23:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09 23:14 [PATCH] mmc: sdhci: refine non-removable card checking for card detection Daniel Drake
2012-04-10  8:05 ` Sascha Silbe
2012-04-17 14:48   ` Daniel Drake
2012-04-13  4:53 ` Dong, Chuanxiao
2012-04-18 23:57 ` Chris Ball

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.