All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: mxs: fix card detection in case of 'broken-cd' flag set
@ 2014-06-10 14:57 ` Roman Pen
  0 siblings, 0 replies; 4+ messages in thread
From: Roman Pen @ 2014-06-10 14:57 UTC (permalink / raw)
  Cc: Roman Pen, Chris Ball, Sascha Hauer, Fabio Estevam, Shawn Guo,
	Ulf Hansson, linux-mmc, linux-kernel

In case of reboot my olinuxino imx23 board does not see
mmc card any more. mmc_rescan is being called by delayed
work in loop, but mxs_mmc_get_cd always returns 0, so we
will never pass the card detection check and will not do
further card inition.

This patch is just an attempt to partially revert the patch
a91fe279ae of Sascha Hauer, where it is claimed that upper
layer will handle broken card detection using the polling
logic and MMC_CAP_NEEDS_POLL capability, but seems it is not
true, because upper logic still expects 1 from 'get_cd'.

So, here we always return 1 (card present) in case of
MMC_CAP_NEEDS_POLL capability set.

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
CC: Chris Ball <chris@printf.net>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
CC: Shawn Guo <shawn.guo@linaro.org>
CC: Ulf Hansson <ulf.hansson@linaro.org>
CC: linux-mmc@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 drivers/mmc/host/mxs-mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 073e871..9187ce1 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -82,7 +82,8 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
 	if (ret >= 0)
 		return ret;
 
-	present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
+	present = mmc->caps & MMC_CAP_NEEDS_POLL ||
+		!(readl(ssp->base + HW_SSP_STATUS(ssp)) &
 			BM_SSP_STATUS_CARD_DETECT);
 
 	if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
-- 
1.9.1


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

* [PATCH] mmc: mxs: fix card detection in case of 'broken-cd' flag set
@ 2014-06-10 14:57 ` Roman Pen
  0 siblings, 0 replies; 4+ messages in thread
From: Roman Pen @ 2014-06-10 14:57 UTC (permalink / raw)
  Cc: Roman Pen, Chris Ball, Sascha Hauer, Fabio Estevam, Shawn Guo,
	Ulf Hansson, linux-mmc, linux-kernel

In case of reboot my olinuxino imx23 board does not see
mmc card any more. mmc_rescan is being called by delayed
work in loop, but mxs_mmc_get_cd always returns 0, so we
will never pass the card detection check and will not do
further card inition.

This patch is just an attempt to partially revert the patch
a91fe279ae of Sascha Hauer, where it is claimed that upper
layer will handle broken card detection using the polling
logic and MMC_CAP_NEEDS_POLL capability, but seems it is not
true, because upper logic still expects 1 from 'get_cd'.

So, here we always return 1 (card present) in case of
MMC_CAP_NEEDS_POLL capability set.

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
CC: Chris Ball <chris@printf.net>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
CC: Shawn Guo <shawn.guo@linaro.org>
CC: Ulf Hansson <ulf.hansson@linaro.org>
CC: linux-mmc@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
 drivers/mmc/host/mxs-mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 073e871..9187ce1 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -82,7 +82,8 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
 	if (ret >= 0)
 		return ret;
 
-	present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
+	present = mmc->caps & MMC_CAP_NEEDS_POLL ||
+		!(readl(ssp->base + HW_SSP_STATUS(ssp)) &
 			BM_SSP_STATUS_CARD_DETECT);
 
 	if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
-- 
1.9.1


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

* Re: [PATCH] mmc: mxs: fix card detection in case of 'broken-cd' flag set
  2014-06-10 14:57 ` Roman Pen
  (?)
@ 2014-07-07  6:27 ` Sascha Hauer
  -1 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-07-07  6:27 UTC (permalink / raw)
  To: Roman Pen
  Cc: Chris Ball, Fabio Estevam, Shawn Guo, Ulf Hansson, linux-mmc,
	linux-kernel

On Tue, Jun 10, 2014 at 11:57:02PM +0900, Roman Pen wrote:
> In case of reboot my olinuxino imx23 board does not see
> mmc card any more. mmc_rescan is being called by delayed
> work in loop, but mxs_mmc_get_cd always returns 0, so we
> will never pass the card detection check and will not do
> further card inition.
> 
> This patch is just an attempt to partially revert the patch
> a91fe279ae of Sascha Hauer, where it is claimed that upper
> layer will handle broken card detection using the polling
> logic and MMC_CAP_NEEDS_POLL capability, but seems it is not
> true, because upper logic still expects 1 from 'get_cd'.
> 
> So, here we always return 1 (card present) in case of
> MMC_CAP_NEEDS_POLL capability set.
> 
> Signed-off-by: Roman Pen <r.peniaev@gmail.com>
> CC: Chris Ball <chris@printf.net>
> CC: Sascha Hauer <s.hauer@pengutronix.de>
> CC: Fabio Estevam <fabio.estevam@freescale.com>
> CC: Shawn Guo <shawn.guo@linaro.org>
> CC: Ulf Hansson <ulf.hansson@linaro.org>
> CC: linux-mmc@vger.kernel.org
> CC: linux-kernel@vger.kernel.org

I still didn't find the time to take a proper look at it. Since this
fixes a bug for you:

Acked-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> ---
>  drivers/mmc/host/mxs-mmc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 073e871..9187ce1 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -82,7 +82,8 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
>  	if (ret >= 0)
>  		return ret;
>  
> -	present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
> +	present = mmc->caps & MMC_CAP_NEEDS_POLL ||
> +		!(readl(ssp->base + HW_SSP_STATUS(ssp)) &
>  			BM_SSP_STATUS_CARD_DETECT);
>  
>  	if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
> -- 
> 1.9.1
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH] mmc: mxs: fix card detection in case of 'broken-cd' flag set
  2014-06-10 14:57 ` Roman Pen
  (?)
  (?)
@ 2014-07-08 12:41 ` Ulf Hansson
  -1 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2014-07-08 12:41 UTC (permalink / raw)
  To: Roman Pen
  Cc: Chris Ball, Sascha Hauer, Fabio Estevam, Shawn Guo, linux-mmc,
	linux-kernel

On 10 June 2014 16:57, Roman Pen <r.peniaev@gmail.com> wrote:
> In case of reboot my olinuxino imx23 board does not see
> mmc card any more. mmc_rescan is being called by delayed
> work in loop, but mxs_mmc_get_cd always returns 0, so we
> will never pass the card detection check and will not do
> further card inition.
>
> This patch is just an attempt to partially revert the patch
> a91fe279ae of Sascha Hauer, where it is claimed that upper
> layer will handle broken card detection using the polling
> logic and MMC_CAP_NEEDS_POLL capability, but seems it is not
> true, because upper logic still expects 1 from 'get_cd'.
>
> So, here we always return 1 (card present) in case of
> MMC_CAP_NEEDS_POLL capability set.
>
> Signed-off-by: Roman Pen <r.peniaev@gmail.com>
> CC: Chris Ball <chris@printf.net>
> CC: Sascha Hauer <s.hauer@pengutronix.de>
> CC: Fabio Estevam <fabio.estevam@freescale.com>
> CC: Shawn Guo <shawn.guo@linaro.org>
> CC: Ulf Hansson <ulf.hansson@linaro.org>
> CC: linux-mmc@vger.kernel.org
> CC: linux-kernel@vger.kernel.org

Thanks! Applied for next.

Kind regards
Uffe

> ---
>  drivers/mmc/host/mxs-mmc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 073e871..9187ce1 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -82,7 +82,8 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
>         if (ret >= 0)
>                 return ret;
>
> -       present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
> +       present = mmc->caps & MMC_CAP_NEEDS_POLL ||
> +               !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
>                         BM_SSP_STATUS_CARD_DETECT);
>
>         if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
> --
> 1.9.1
>

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

end of thread, other threads:[~2014-07-08 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-10 14:57 [PATCH] mmc: mxs: fix card detection in case of 'broken-cd' flag set Roman Pen
2014-06-10 14:57 ` Roman Pen
2014-07-07  6:27 ` Sascha Hauer
2014-07-08 12:41 ` Ulf Hansson

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.