public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event()
@ 2013-06-09 11:49 Shawn Guo
  2013-06-14 12:43 ` Shawn Guo
  2013-06-27 15:37 ` Chris Ball
  0 siblings, 2 replies; 3+ messages in thread
From: Shawn Guo @ 2013-06-09 11:49 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball, kernel, Shawn Guo

The following error randomly appears on an imx6q board where gpio is
used to implement card-detection when mounting EXT4 rootfs during boot.

mmc1: Card removed during transfer!
mmc1: Resetting controller.
mmcblk0: unknown error -123 sending read/write command, card status 0x900
end_request: I/O error, dev mmcblk0, sector 106744
EXT4-fs error (device mmcblk0p2): ext4_find_entry:1312: inode #5011: comm swapper/0: reading directory lblock 0

It turns out that the error message comes from the card removal check
in function sdhci_card_event().  While we have a well implemented
function sdhci_do_get_cd() handling all the possible cases of
CD, the current code only checks controller internal CD case.  That
causes problem for other CD cases like gpio on above imx6q board.

Improve the check by using sdhci_do_get_cd() to cover all possible CD
cases, so that above error on the imx6q board gets fixed.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c81c2a2..eadb3ad 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2066,8 +2066,7 @@ static void sdhci_card_event(struct mmc_host *mmc)
 	spin_lock_irqsave(&host->lock, flags);
 
 	/* Check host->mrq first in case we are runtime suspended */
-	if (host->mrq &&
-	    !(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
+	if (host->mrq && !sdhci_do_get_cd(host)) {
 		pr_err("%s: Card removed during transfer!\n",
 			mmc_hostname(host->mmc));
 		pr_err("%s: Resetting controller.\n",
-- 
1.7.9.5



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

* Re: [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event()
  2013-06-09 11:49 [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event() Shawn Guo
@ 2013-06-14 12:43 ` Shawn Guo
  2013-06-27 15:37 ` Chris Ball
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2013-06-14 12:43 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball, kernel

On Sun, Jun 09, 2013 at 07:49:24PM +0800, Shawn Guo wrote:
> The following error randomly appears on an imx6q board where gpio is
> used to implement card-detection when mounting EXT4 rootfs during boot.
> 
> mmc1: Card removed during transfer!
> mmc1: Resetting controller.
> mmcblk0: unknown error -123 sending read/write command, card status 0x900
> end_request: I/O error, dev mmcblk0, sector 106744
> EXT4-fs error (device mmcblk0p2): ext4_find_entry:1312: inode #5011: comm swapper/0: reading directory lblock 0
> 
> It turns out that the error message comes from the card removal check
> in function sdhci_card_event().  While we have a well implemented
> function sdhci_do_get_cd() handling all the possible cases of
> CD, the current code only checks controller internal CD case.  That
> causes problem for other CD cases like gpio on above imx6q board.
> 
> Improve the check by using sdhci_do_get_cd() to cover all possible CD
> cases, so that above error on the imx6q board gets fixed.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Chris,

Are you fine with the patch?

Shawn


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

* Re: [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event()
  2013-06-09 11:49 [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event() Shawn Guo
  2013-06-14 12:43 ` Shawn Guo
@ 2013-06-27 15:37 ` Chris Ball
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Ball @ 2013-06-27 15:37 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, kernel

Hi Shawn,

On Sun, Jun 09 2013, Shawn Guo wrote:
> The following error randomly appears on an imx6q board where gpio is
> used to implement card-detection when mounting EXT4 rootfs during boot.
>
> mmc1: Card removed during transfer!
> mmc1: Resetting controller.
> mmcblk0: unknown error -123 sending read/write command, card status 0x900
> end_request: I/O error, dev mmcblk0, sector 106744
> EXT4-fs error (device mmcblk0p2): ext4_find_entry:1312: inode #5011: comm swapper/0: reading directory lblock 0
>
> It turns out that the error message comes from the card removal check
> in function sdhci_card_event().  While we have a well implemented
> function sdhci_do_get_cd() handling all the possible cases of
> CD, the current code only checks controller internal CD case.  That
> causes problem for other CD cases like gpio on above imx6q board.
>
> Improve the check by using sdhci_do_get_cd() to cover all possible CD
> cases, so that above error on the imx6q board gets fixed.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index c81c2a2..eadb3ad 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2066,8 +2066,7 @@ static void sdhci_card_event(struct mmc_host *mmc)
>  	spin_lock_irqsave(&host->lock, flags);
>  
>  	/* Check host->mrq first in case we are runtime suspended */
> -	if (host->mrq &&
> -	    !(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
> +	if (host->mrq && !sdhci_do_get_cd(host)) {
>  		pr_err("%s: Card removed during transfer!\n",
>  			mmc_hostname(host->mmc));
>  		pr_err("%s: Resetting controller.\n",

Thanks, pushed to mmc-next for 3.11, sorry for the delay.

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

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

end of thread, other threads:[~2013-06-27 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09 11:49 [PATCH] mmc: sdhci: improve card removal check in sdhci_card_event() Shawn Guo
2013-06-14 12:43 ` Shawn Guo
2013-06-27 15:37 ` Chris Ball

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