All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
@ 2012-10-30  8:12 r66093
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
  2012-10-30 23:08 ` [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() Ulf Hansson
  0 siblings, 2 replies; 36+ messages in thread
From: r66093 @ 2012-10-30  8:12 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Anton Vorontsov, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

When f_init is zero, the SDHC can't work correctly. So f_min will replace
f_init, when f_init is zero.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- add the CC
changes for v3:
	- enalbe the controller clock in platform, instead of core

 drivers/mmc/core/core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 06c42cf..9c162cd 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1319,7 +1319,10 @@ static void mmc_power_up(struct mmc_host *host)
 	 */
 	mmc_delay(10);
 
-	host->ios.clock = host->f_init;
+	if (host->f_init)
+		host->ios.clock = host->f_init;
+	else
+		host->ios.clock = host->f_min;
 
 	host->ios.power_mode = MMC_POWER_ON;
 	mmc_set_ios(host);
-- 
1.7.9.5



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

* [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-30  8:12 [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() r66093
@ 2012-10-30  8:12 ` r66093
  2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
                     ` (3 more replies)
  2012-10-30 23:08 ` [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() Ulf Hansson
  1 sibling, 4 replies; 36+ messages in thread
From: r66093 @ 2012-10-30  8:12 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Anton Vorontsov, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

In order to check whether the card has been removed, the function
mmc_send_status() will send command CMD13 to card and ask the card
to send its status register to sdhc driver, which will generate
many interrupts repeatedly and make the system performance bad.

Therefore, add callback function get_cd() to check whether
the card has been removed when the driver has this callback function.

If the card is present, 1 will return, if the card is absent, 0 will return.
If the controller will not support this feature, -ENOSYS will return.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
        - when controller don't support get_cd, return -ENOSYS
        - add the CC
changes for v3:
        - enalbe the controller clock in platform, instead of core
changes for v4:
	- move the detect code to core.c according to the new structure

 drivers/mmc/core/core.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 9c162cd..6412355 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2073,7 +2073,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 
 int _mmc_detect_card_removed(struct mmc_host *host)
 {
-	int ret;
+	int ret = -ENOSYS;
 
 	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
 		return 0;
@@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
 	if (!host->card || mmc_card_removed(host->card))
 		return 1;
 
-	ret = host->bus_ops->alive(host);
+	if (host->ops->get_cd) {
+		ret = host->ops->get_cd(host);
+		if (ret >= 0)
+			ret = !ret;
+	}
+	if (ret < 0)
+		ret = host->bus_ops->alive(host);
 	if (ret) {
 		mmc_card_set_removed(host->card);
 		pr_debug("%s: card remove detected\n", mmc_hostname(host));
-- 
1.7.9.5



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

* [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
@ 2012-10-30  8:12   ` r66093
  2012-10-30  8:12     ` [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card r66093
  2012-11-19  2:50     ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card Huang Changming-R66093
  2012-10-30 11:34   ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card Girish K S
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 36+ messages in thread
From: r66093 @ 2012-10-30  8:12 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Anton Vorontsov, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

Add callback function sdhci_get_cd to detect the card.
And one new callback added to implement the card detect in sdhci struncture.
If special platform has the card detect callback, it will return the card
state, the value zero is for absent cardi and one is for present card.
If the controller don't support card detect, sdhci_get_cd will return -ENOSYS.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- when controller don't support get_cd, return -ENOSYS
	- add new callback for sdhci to detect the card
	- add the CC
changes for v3:
	- use pin_lock only when get_cd defined
changes for v4:
	- enalbe the controller clock in platform, instead of core
changes for v5:
	- remove the copyright

 drivers/mmc/host/sdhci.c |   21 +++++++++++++++++++++
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f05a377..cc9c8a6 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
 	return ret;
 }
 
+/* Return values for the sdjco_get_cd callback:
+ *   0 for a absent card
+ *   1 for a present card
+ *   -ENOSYS when not supported (equal to NULL callback)
+ */
+static int sdhci_get_cd(struct mmc_host *mmc)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+	int present = -ENOSYS;
+
+	if (host->ops->get_cd) {
+		spin_lock_irqsave(&host->lock, flags);
+		present = host->ops->get_cd(host);
+		spin_unlock_irqrestore(&host->lock, flags);
+	}
+
+	return present;
+}
+
 static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable)
 {
 	if (host->flags & SDHCI_DEVICE_DEAD)
@@ -1995,6 +2015,7 @@ static const struct mmc_host_ops sdhci_ops = {
 	.request	= sdhci_request,
 	.set_ios	= sdhci_set_ios,
 	.get_ro		= sdhci_get_ro,
+	.get_cd		= sdhci_get_cd,
 	.hw_reset	= sdhci_hw_reset,
 	.enable_sdio_irq = sdhci_enable_sdio_irq,
 	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 71a4a7e..7c8f08d 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -69,6 +69,7 @@
 #define  SDHCI_SPACE_AVAILABLE	0x00000400
 #define  SDHCI_DATA_AVAILABLE	0x00000800
 #define  SDHCI_CARD_PRESENT	0x00010000
+#define  SDHCI_CARD_CDPL	0x00040000
 #define  SDHCI_WRITE_PROTECT	0x00080000
 #define  SDHCI_DATA_LVL_MASK	0x00F00000
 #define   SDHCI_DATA_LVL_SHIFT	20
@@ -263,6 +264,7 @@ struct sdhci_ops {
 
 	void	(*set_clock)(struct sdhci_host *host, unsigned int clock);
 
+	int		(*get_cd)(struct sdhci_host *host);
 	int		(*enable_dma)(struct sdhci_host *host);
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
-- 
1.7.9.5



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

* [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card
  2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
@ 2012-10-30  8:12     ` r66093
  2012-11-19  2:50       ` Huang Changming-R66093
  2012-11-19  2:50     ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card Huang Changming-R66093
  1 sibling, 1 reply; 36+ messages in thread
From: r66093 @ 2012-10-30  8:12 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Anton Vorontsov, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

In order to check if the card is present, we will read the PRESENT STATE
register and check the bit13(Card detect pin level) and bit15(CINS).

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Anton Vorontsov <cbouatmailru@gmail.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- add new callback for esdhc to detect the card state
	- add the CC
changes for v3:
	- enable the controller clock when detect the card state, not core
changes for v4:
	- based on the latest version

 drivers/mmc/host/sdhci-of-esdhc.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 63d219f..7053218 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -179,6 +179,28 @@ static void esdhc_of_platform_init(struct sdhci_host *host)
 		host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
 }
 
+/* Return: none zero - the card is presetn; 0 - card is absent */
+static int esdhc_of_get_cd(struct sdhci_host *host)
+{
+	int present;
+
+	if (host->flags & SDHCI_DEVICE_DEAD)
+		present = 0;
+	else {
+		int sysctl = sdhci_be32bs_readl(host, SDHCI_CLOCK_CONTROL);
+		/* Enable the controller clock to update the present state */
+		sdhci_be32bs_writel(host, sysctl | SDHCI_CLOCK_INT_EN,
+				SDHCI_CLOCK_CONTROL);
+		/* Detect the card present or absent */
+		present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE);
+		present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL);
+		/* Resve the previous to System control register */
+		sdhci_be32bs_writel(host, sysctl, SDHCI_CLOCK_CONTROL);
+	}
+
+	return present;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = esdhc_readl,
 	.read_w = esdhc_readw,
@@ -191,6 +213,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.get_max_clock = esdhc_of_get_max_clock,
 	.get_min_clock = esdhc_of_get_min_clock,
 	.platform_init = esdhc_of_platform_init,
+	.get_cd = esdhc_of_get_cd,
 #ifdef CONFIG_PM
 	.platform_suspend = esdhc_of_suspend,
 	.platform_resume = esdhc_of_resume,
-- 
1.7.9.5



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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
  2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
@ 2012-10-30 11:34   ` Girish K S
  2012-10-31  2:23     ` Huang Changming-R66093
  2012-11-01 15:57   ` Johan Rudholm
  2012-11-19  3:05   ` Anton Vorontsov
  3 siblings, 1 reply; 36+ messages in thread
From: Girish K S @ 2012-10-30 11:34 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Anton Vorontsov, Chris Ball

On 30 October 2012 13:42,  <r66093@freescale.com> wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> In order to check whether the card has been removed, the function
> mmc_send_status() will send command CMD13 to card and ask the card
> to send its status register to sdhc driver, which will generate
> many interrupts repeatedly and make the system performance bad.
>
> Therefore, add callback function get_cd() to check whether
> the card has been removed when the driver has this callback function.
>
> If the card is present, 1 will return, if the card is absent, 0 will return.
> If the controller will not support this feature, -ENOSYS will return.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
>         - when controller don't support get_cd, return -ENOSYS
>         - add the CC
> changes for v3:
>         - enalbe the controller clock in platform, instead of core
> changes for v4:
>         - move the detect code to core.c according to the new structure
>
>  drivers/mmc/core/core.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 9c162cd..6412355 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2073,7 +2073,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
>
>  int _mmc_detect_card_removed(struct mmc_host *host)
>  {
> -       int ret;
> +       int ret = -ENOSYS;
>
>         if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
>                 return 0;
> @@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
>         if (!host->card || mmc_card_removed(host->card))
>                 return 1;
>
> -       ret = host->bus_ops->alive(host);
> +       if (host->ops->get_cd) {
> +               ret = host->ops->get_cd(host);
> +               if (ret >= 0)
> +                       ret = !ret;
> +       }
> +       if (ret < 0)
> +               ret = host->bus_ops->alive(host);
why should we check for negative here? can move this code into else
path of   if (host->ops->get_cd).
>         if (ret) {
>                 mmc_card_set_removed(host->card);
>                 pr_debug("%s: card remove detected\n", mmc_hostname(host));
> --
> 1.7.9.5
>
>
> --
> 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] 36+ messages in thread

* Re: [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
  2012-10-30  8:12 [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() r66093
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
@ 2012-10-30 23:08 ` Ulf Hansson
  2012-10-31  2:23   ` Huang Changming-R66093
  2012-10-31  4:21   ` Jaehoon Chung
  1 sibling, 2 replies; 36+ messages in thread
From: Ulf Hansson @ 2012-10-30 23:08 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Anton Vorontsov, Chris Ball

On 30 October 2012 09:12,  <r66093@freescale.com> wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> When f_init is zero, the SDHC can't work correctly. So f_min will replace
> f_init, when f_init is zero.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
>         - add the CC
> changes for v3:
>         - enalbe the controller clock in platform, instead of core
>
>  drivers/mmc/core/core.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 06c42cf..9c162cd 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1319,7 +1319,10 @@ static void mmc_power_up(struct mmc_host *host)
>          */
>         mmc_delay(10);
>
> -       host->ios.clock = host->f_init;
> +       if (host->f_init)
> +               host->ios.clock = host->f_init;
> +       else
> +               host->ios.clock = host->f_min;

This should not be needed. host->f_init should never become zero, I believe.

>
>         host->ios.power_mode = MMC_POWER_ON;
>         mmc_set_ios(host);
> --
> 1.7.9.5
>
>
> --
> 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

Kind regards
Ulf Hansson

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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-30 11:34   ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card Girish K S
@ 2012-10-31  2:23     ` Huang Changming-R66093
  2012-10-31  4:29       ` Jaehoon Chung
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-10-31  2:23 UTC (permalink / raw)
  To: Girish K S; +Cc: linux-mmc, Anton Vorontsov, Chris Ball



Best Regards
Jerry Huang


> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Girish K S
> Sent: Tuesday, October 30, 2012 7:35 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Anton Vorontsov;
> Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> On 30 October 2012 13:42,  <r66093@freescale.com> wrote:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > In order to check whether the card has been removed, the function
> > mmc_send_status() will send command CMD13 to card and ask the card
> > to send its status register to sdhc driver, which will generate
> > many interrupts repeatedly and make the system performance bad.
> >
> > Therefore, add callback function get_cd() to check whether
> > the card has been removed when the driver has this callback function.
> >
> > If the card is present, 1 will return, if the card is absent, 0 will
> return.
> > If the controller will not support this feature, -ENOSYS will return.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Anton Vorontsov <cbouatmailru@gmail.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> > changes for v2:
> >         - when controller don't support get_cd, return -ENOSYS
> >         - add the CC
> > changes for v3:
> >         - enalbe the controller clock in platform, instead of core
> > changes for v4:
> >         - move the detect code to core.c according to the new structure
> >
> >  drivers/mmc/core/core.c |   10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > index 9c162cd..6412355 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -2073,7 +2073,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> *host, unsigned freq)
> >
> >  int _mmc_detect_card_removed(struct mmc_host *host)
> >  {
> > -       int ret;
> > +       int ret = -ENOSYS;
> >
> >         if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops-
> >alive)
> >                 return 0;
> > @@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host
> *host)
> >         if (!host->card || mmc_card_removed(host->card))
> >                 return 1;
> >
> > -       ret = host->bus_ops->alive(host);
> > +       if (host->ops->get_cd) {
> > +               ret = host->ops->get_cd(host);
> > +               if (ret >= 0)
> > +                       ret = !ret;
> > +       }
> > +       if (ret < 0)
> > +               ret = host->bus_ops->alive(host);
> why should we check for negative here? can move this code into else
> path of   if (host->ops->get_cd).
> >         if (ret) {

I did this comment:
If the card is present, 1 will return, if the card is absent, 0 will return.
If the controller will not support this feature, -ENOSYS will return.

Can't move to other address, because these codes check the card present state.



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

* RE: [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
  2012-10-30 23:08 ` [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() Ulf Hansson
@ 2012-10-31  2:23   ` Huang Changming-R66093
  2012-10-31  4:21   ` Jaehoon Chung
  1 sibling, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-10-31  2:23 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Anton Vorontsov, Chris Ball



Best Regards
Jerry Huang


> -----Original Message-----
> From: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> Sent: Wednesday, October 31, 2012 7:09 AM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Anton Vorontsov;
> Chris Ball
> Subject: Re: [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
> 
> On 30 October 2012 09:12,  <r66093@freescale.com> wrote:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > When f_init is zero, the SDHC can't work correctly. So f_min will
> replace
> > f_init, when f_init is zero.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Anton Vorontsov <cbouatmailru@gmail.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> > changes for v2:
> >         - add the CC
> > changes for v3:
> >         - enalbe the controller clock in platform, instead of core
> >
> >  drivers/mmc/core/core.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > index 06c42cf..9c162cd 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -1319,7 +1319,10 @@ static void mmc_power_up(struct mmc_host *host)
> >          */
> >         mmc_delay(10);
> >
> > -       host->ios.clock = host->f_init;
> > +       if (host->f_init)
> > +               host->ios.clock = host->f_init;
> > +       else
> > +               host->ios.clock = host->f_min;
> 
> This should not be needed. host->f_init should never become zero, I
> believe.
> 
Uh, this patch can be removed.


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

* Re: [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on()
  2012-10-30 23:08 ` [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() Ulf Hansson
  2012-10-31  2:23   ` Huang Changming-R66093
@ 2012-10-31  4:21   ` Jaehoon Chung
  1 sibling, 0 replies; 36+ messages in thread
From: Jaehoon Chung @ 2012-10-31  4:21 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: r66093, linux-mmc, Jerry Huang, Anton Vorontsov, Chris Ball

On 10/31/2012 08:08 AM, Ulf Hansson wrote:
> On 30 October 2012 09:12,  <r66093@freescale.com> wrote:
>> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>
>> When f_init is zero, the SDHC can't work correctly. So f_min will replace
>> f_init, when f_init is zero.
>>
>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>> CC: Anton Vorontsov <cbouatmailru@gmail.com>
>> CC: Chris Ball <cjb@laptop.org>
>> ---
>> changes for v2:
>>         - add the CC
>> changes for v3:
>>         - enalbe the controller clock in platform, instead of core
>>
>>  drivers/mmc/core/core.c |    5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index 06c42cf..9c162cd 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -1319,7 +1319,10 @@ static void mmc_power_up(struct mmc_host *host)
>>          */
>>         mmc_delay(10);
>>
>> -       host->ios.clock = host->f_init;
>> +       if (host->f_init)
>> +               host->ios.clock = host->f_init;
>> +       else
>> +               host->ios.clock = host->f_min;
> 
> This should not be needed. host->f_init should never become zero, I believe.
I agree for Ulf's comment.
> 
>>
>>         host->ios.power_mode = MMC_POWER_ON;
>>         mmc_set_ios(host);
>> --
>> 1.7.9.5
>>
>>
>> --
>> 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
> 
> Kind regards
> Ulf Hansson
> --
> 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] 36+ messages in thread

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-31  2:23     ` Huang Changming-R66093
@ 2012-10-31  4:29       ` Jaehoon Chung
  2012-10-31  5:52         ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Jaehoon Chung @ 2012-10-31  4:29 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Girish K S, linux-mmc, Anton Vorontsov, Chris Ball

Hi,

>> *host)
>>>         if (!host->card || mmc_card_removed(host->card))
>>>                 return 1;
>>>
>>> -       ret = host->bus_ops->alive(host);
>>> +       if (host->ops->get_cd) {
>>> +               ret = host->ops->get_cd(host);
>>> +               if (ret >= 0)
>>> +                       ret = !ret;
>>> +       }
>>> +       if (ret < 0)
>>> +               ret = host->bus_ops->alive(host);
>> why should we check for negative here? can move this code into else
>> path of   if (host->ops->get_cd).
>>>         if (ret) {
> 
> I did this comment:
> If the card is present, 1 will return, if the card is absent, 0 will return.
> If the controller will not support this feature, -ENOSYS will return.
If checked whether card is absent or not with get_cd(), need to check the host->bus_ops->alive?
> 
> Can't move to other address, because these codes check the card present state.
> 
> 
> --
> 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] 36+ messages in thread

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-31  4:29       ` Jaehoon Chung
@ 2012-10-31  5:52         ` Huang Changming-R66093
  0 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-10-31  5:52 UTC (permalink / raw)
  To: Jaehoon Chung; +Cc: Girish K S, linux-mmc, Anton Vorontsov, Chris Ball



Best Regards
Jerry Huang


> -----Original Message-----
> From: Jaehoon Chung [mailto:jh80.chung@samsung.com]
> Sent: Wednesday, October 31, 2012 12:29 PM
> To: Huang Changming-R66093
> Cc: Girish K S; linux-mmc@vger.kernel.org; Anton Vorontsov; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> >> *host)
> >>>         if (!host->card || mmc_card_removed(host->card))
> >>>                 return 1;
> >>>
> >>> -       ret = host->bus_ops->alive(host);
> >>> +       if (host->ops->get_cd) {
> >>> +               ret = host->ops->get_cd(host);
> >>> +               if (ret >= 0)
> >>> +                       ret = !ret;
> >>> +       }
> >>> +       if (ret < 0)
> >>> +               ret = host->bus_ops->alive(host);
> >> why should we check for negative here? can move this code into else
> >> path of   if (host->ops->get_cd).
> >>>         if (ret) {
> >
> > I did this comment:
> > If the card is present, 1 will return, if the card is absent, 0 will
> return.
> > If the controller will not support this feature, -ENOSYS will return.
> If checked whether card is absent or not with get_cd(), need to check the
> host->bus_ops->alive?

When get_cd is not supported, need to check it.


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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
  2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
  2012-10-30 11:34   ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card Girish K S
@ 2012-11-01 15:57   ` Johan Rudholm
  2012-11-02  1:37     ` Huang Changming-R66093
  2012-11-19  3:05   ` Anton Vorontsov
  3 siblings, 1 reply; 36+ messages in thread
From: Johan Rudholm @ 2012-11-01 15:57 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Anton Vorontsov, Chris Ball

Hi Jerry,

2012/10/30  <r66093@freescale.com>:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> In order to check whether the card has been removed, the function
> mmc_send_status() will send command CMD13 to card and ask the card
> to send its status register to sdhc driver, which will generate
> many interrupts repeatedly and make the system performance bad.
>
> Therefore, add callback function get_cd() to check whether
> the card has been removed when the driver has this callback function.
>
> If the card is present, 1 will return, if the card is absent, 0 will return.
> If the controller will not support this feature, -ENOSYS will return.

In what cases is the performance affected by this? I believe this
function is called only on some errors and on detect?

Also, we've seen cases where the card detect GPIO cannot be trusted to
tell wether the card is present or not, for instance in the corner
case when an SD-card is removed very slowly...

Kind regards, Johan

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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-01 15:57   ` Johan Rudholm
@ 2012-11-02  1:37     ` Huang Changming-R66093
  2012-11-02 10:33       ` Johan Rudholm
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-02  1:37 UTC (permalink / raw)
  To: Johan Rudholm; +Cc: linux-mmc, Anton Vorontsov, Chris Ball

Hi, Johan,
When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver will poll the card status with the command CMD13 periodically, then many interrupts will be generated, which affect the performance.

Yes, some cases to detect GPIO can't be trusted, so I only just implement this callback in eSDHC-of driver. that is to say, just when the platform support it, this callback can be implement, if not, continue to send the command CMD13.  

> Hi Jerry,
> 
> 2012/10/30  <r66093@freescale.com>:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > In order to check whether the card has been removed, the function
> > mmc_send_status() will send command CMD13 to card and ask the card to
> > send its status register to sdhc driver, which will generate many
> > interrupts repeatedly and make the system performance bad.
> >
> > Therefore, add callback function get_cd() to check whether the card
> > has been removed when the driver has this callback function.
> >
> > If the card is present, 1 will return, if the card is absent, 0 will
> return.
> > If the controller will not support this feature, -ENOSYS will return.
> 
> In what cases is the performance affected by this? I believe this
> function is called only on some errors and on detect?
> 
> Also, we've seen cases where the card detect GPIO cannot be trusted to
> tell wether the card is present or not, for instance in the corner case
> when an SD-card is removed very slowly...
> 
> Kind regards, Johan



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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-02  1:37     ` Huang Changming-R66093
@ 2012-11-02 10:33       ` Johan Rudholm
  2012-11-05  3:17         ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Johan Rudholm @ 2012-11-02 10:33 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linux-mmc, Anton Vorontsov, Chris Ball

Hi Jerry,

2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> Hi, Johan,
> When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver will poll the card status with the command CMD13 periodically, then many interrupts will be generated, which affect the performance.

Ok, just to see if I understand the scenario correctly:
SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to
be set, which will cause mmc_rescan to be run at a one second
interval. mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in
turn calls _mmc_detect_card_removed, which will do the bus_ops->alive
and send CMD13. So in this case, one CMD13 is sent per second, right?
Is this the cause of the performance issue?

A thought: if the host hardware does have a GPIO card detect pin
hooked up, would it not be possible to make this pin generate an IRQ
whenever a card is inserted or removed? This is what we do in the MMCI
driver, for instance (mmci_cd_irq).

> Yes, some cases to detect GPIO can't be trusted, so I only just implement this callback in eSDHC-of driver. that is to say, just when the platform support it, this callback can be implement, if not, continue to send the command CMD13.

I'm just wondering how this will affect our system, where we use the
cd GPIO to generate detect jobs on card insert/remove, but where the
cd pin is not 100% synchronized with the electrical connection of the
power and cmd line of the SD-card. So if I remember correctly, the cd
pin may report that the card has been removed, but there is still an
electric connection and the card is alive...

Kind regards, Johan

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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-02 10:33       ` Johan Rudholm
@ 2012-11-05  3:17         ` Huang Changming-R66093
  2012-11-05 14:07           ` Johan Rudholm
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-05  3:17 UTC (permalink / raw)
  To: Johan Rudholm; +Cc: linux-mmc, Anton Vorontsov, Chris Ball

> 
> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> > Hi, Johan,
> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver will
> poll the card status with the command CMD13 periodically, then many
> interrupts will be generated, which affect the performance.
> 
> Ok, just to see if I understand the scenario correctly:
> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to be
> set, which will cause mmc_rescan to be run at a one second interval.
> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn calls
> _mmc_detect_card_removed, which will do the bus_ops->alive and send CMD13.
> So in this case, one CMD13 is sent per second, right?
> Is this the cause of the performance issue?

Yes, You are right.

> 
> A thought: if the host hardware does have a GPIO card detect pin hooked
> up, would it not be possible to make this pin generate an IRQ whenever a
> card is inserted or removed? This is what we do in the MMCI driver, for
> instance (mmci_cd_irq).

Our silicones has this pin to do card detect, but some boards don't generate the interrupt when card is inserted or removed. So I have to use the poll mode.

> > Yes, some cases to detect GPIO can't be trusted, so I only just
> implement this callback in eSDHC-of driver. that is to say, just when the
> platform support it, this callback can be implement, if not, continue to
> send the command CMD13.
> 
> I'm just wondering how this will affect our system, where we use the cd
> GPIO to generate detect jobs on card insert/remove, but where the cd pin
> is not 100% synchronized with the electrical connection of the power and
> cmd line of the SD-card. So if I remember correctly, the cd pin may
> report that the card has been removed, but there is still an electric
> connection and the card is alive...
> 
I don't see this on our board, when card is inserted or removed, the register field can reflect this state correctly.



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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-05  3:17         ` Huang Changming-R66093
@ 2012-11-05 14:07           ` Johan Rudholm
  2012-11-06  1:55             ` Huang Changming-R66093
                               ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Johan Rudholm @ 2012-11-05 14:07 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linux-mmc, Anton Vorontsov, Chris Ball

Hi,

2012/11/5 Huang Changming-R66093 <r66093@freescale.com>:
>>
>> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
>> > Hi, Johan,
>> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver will
>> poll the card status with the command CMD13 periodically, then many
>> interrupts will be generated, which affect the performance.
>>
>> Ok, just to see if I understand the scenario correctly:
>> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to be
>> set, which will cause mmc_rescan to be run at a one second interval.
>> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn calls
>> _mmc_detect_card_removed, which will do the bus_ops->alive and send CMD13.
>> So in this case, one CMD13 is sent per second, right?
>> Is this the cause of the performance issue?
>
> Yes, You are right.

Ok, it's a bit hard to understand how this can lead to a noticeable
performance impact, but OK. :)

>> A thought: if the host hardware does have a GPIO card detect pin hooked
>> up, would it not be possible to make this pin generate an IRQ whenever a
>> card is inserted or removed? This is what we do in the MMCI driver, for
>> instance (mmci_cd_irq).
>
> Our silicones has this pin to do card detect, but some boards don't generate the interrupt when card is inserted or removed. So I have to use the poll mode.
>
>> > Yes, some cases to detect GPIO can't be trusted, so I only just
>> implement this callback in eSDHC-of driver. that is to say, just when the
>> platform support it, this callback can be implement, if not, continue to
>> send the command CMD13.
>>
>> I'm just wondering how this will affect our system, where we use the cd
>> GPIO to generate detect jobs on card insert/remove, but where the cd pin
>> is not 100% synchronized with the electrical connection of the power and
>> cmd line of the SD-card. So if I remember correctly, the cd pin may
>> report that the card has been removed, but there is still an electric
>> connection and the card is alive...
>>
> I don't see this on our board, when card is inserted or removed, the register field can reflect this state correctly.

We see a difference on our boards with this patch, but no functional
change (actually a removed card is detected earlier now), so from my
perspective:

Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>

//Johan

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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-05 14:07           ` Johan Rudholm
@ 2012-11-06  1:55             ` Huang Changming-R66093
  2012-11-06  1:55             ` Huang Changming-R66093
  2012-11-19  2:48             ` Huang Changming-R66093
  2 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-06  1:55 UTC (permalink / raw)
  To: Johan Rudholm; +Cc: linux-mmc, Anton Vorontsov, Chris Ball

Thanks a lot, Johan.

Best Regards
Jerry Huang


> -----Original Message-----
> From: Johan Rudholm [mailto:jrudholm@gmail.com]
> Sent: Monday, November 05, 2012 10:08 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Anton Vorontsov; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> 2012/11/5 Huang Changming-R66093 <r66093@freescale.com>:
> >>
> >> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> >> > Hi, Johan,
> >> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver
> will
> >> poll the card status with the command CMD13 periodically, then many
> >> interrupts will be generated, which affect the performance.
> >>
> >> Ok, just to see if I understand the scenario correctly:
> >> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to
> be
> >> set, which will cause mmc_rescan to be run at a one second interval.
> >> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn
> calls
> >> _mmc_detect_card_removed, which will do the bus_ops->alive and send
> CMD13.
> >> So in this case, one CMD13 is sent per second, right?
> >> Is this the cause of the performance issue?
> >
> > Yes, You are right.
> 
> Ok, it's a bit hard to understand how this can lead to a noticeable
> performance impact, but OK. :)
> 
> >> A thought: if the host hardware does have a GPIO card detect pin
> hooked
> >> up, would it not be possible to make this pin generate an IRQ whenever
> a
> >> card is inserted or removed? This is what we do in the MMCI driver,
> for
> >> instance (mmci_cd_irq).
> >
> > Our silicones has this pin to do card detect, but some boards don't
> generate the interrupt when card is inserted or removed. So I have to use
> the poll mode.
> >
> >> > Yes, some cases to detect GPIO can't be trusted, so I only just
> >> implement this callback in eSDHC-of driver. that is to say, just when
> the
> >> platform support it, this callback can be implement, if not, continue
> to
> >> send the command CMD13.
> >>
> >> I'm just wondering how this will affect our system, where we use the
> cd
> >> GPIO to generate detect jobs on card insert/remove, but where the cd
> pin
> >> is not 100% synchronized with the electrical connection of the power
> and
> >> cmd line of the SD-card. So if I remember correctly, the cd pin may
> >> report that the card has been removed, but there is still an electric
> >> connection and the card is alive...
> >>
> > I don't see this on our board, when card is inserted or removed, the
> register field can reflect this state correctly.
> 
> We see a difference on our boards with this patch, but no functional
> change (actually a removed card is detected earlier now), so from my
> perspective:
> 
> Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>
> 
> //Johan



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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-05 14:07           ` Johan Rudholm
  2012-11-06  1:55             ` Huang Changming-R66093
@ 2012-11-06  1:55             ` Huang Changming-R66093
  2012-11-13  7:50               ` Huang Changming-R66093
  2012-11-19  2:48             ` Huang Changming-R66093
  2 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-06  1:55 UTC (permalink / raw)
  To: Anton Vorontsov, Chris Ball; +Cc: linux-mmc, Johan Rudholm

Hi, Anton and Chris
Have you any comment about the serial patch [patch 2/3/4, please ignore patch1]?
Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>

Best Regards
Jerry Huang


> -----Original Message-----
> From: Johan Rudholm [mailto:jrudholm@gmail.com]
> Sent: Monday, November 05, 2012 10:08 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Anton Vorontsov; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> 2012/11/5 Huang Changming-R66093 <r66093@freescale.com>:
> >>
> >> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> >> > Hi, Johan,
> >> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver
> will
> >> poll the card status with the command CMD13 periodically, then many
> >> interrupts will be generated, which affect the performance.
> >>
> >> Ok, just to see if I understand the scenario correctly:
> >> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to
> be
> >> set, which will cause mmc_rescan to be run at a one second interval.
> >> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn
> calls
> >> _mmc_detect_card_removed, which will do the bus_ops->alive and send
> CMD13.
> >> So in this case, one CMD13 is sent per second, right?
> >> Is this the cause of the performance issue?
> >
> > Yes, You are right.
> 
> Ok, it's a bit hard to understand how this can lead to a noticeable
> performance impact, but OK. :)
> 
> >> A thought: if the host hardware does have a GPIO card detect pin
> hooked
> >> up, would it not be possible to make this pin generate an IRQ whenever
> a
> >> card is inserted or removed? This is what we do in the MMCI driver,
> for
> >> instance (mmci_cd_irq).
> >
> > Our silicones has this pin to do card detect, but some boards don't
> generate the interrupt when card is inserted or removed. So I have to use
> the poll mode.
> >
> >> > Yes, some cases to detect GPIO can't be trusted, so I only just
> >> implement this callback in eSDHC-of driver. that is to say, just when
> the
> >> platform support it, this callback can be implement, if not, continue
> to
> >> send the command CMD13.
> >>
> >> I'm just wondering how this will affect our system, where we use the
> cd
> >> GPIO to generate detect jobs on card insert/remove, but where the cd
> pin
> >> is not 100% synchronized with the electrical connection of the power
> and
> >> cmd line of the SD-card. So if I remember correctly, the cd pin may
> >> report that the card has been removed, but there is still an electric
> >> connection and the card is alive...
> >>
> > I don't see this on our board, when card is inserted or removed, the
> register field can reflect this state correctly.
> 
> We see a difference on our boards with this patch, but no functional
> change (actually a removed card is detected earlier now), so from my
> perspective:
> 
> Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>
> 
> //Johan



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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-06  1:55             ` Huang Changming-R66093
@ 2012-11-13  7:50               ` Huang Changming-R66093
  0 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-13  7:50 UTC (permalink / raw)
  To: Anton Vorontsov, Chris Ball; +Cc: linux-mmc, Johan Rudholm

Hi, Anton and Chris
Have you any comment about this serial patches[patch 2/3/4, except 1]?

Best Regards
Jerry Huang


> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Huang Changming-R66093
> Sent: Tuesday, November 06, 2012 9:56 AM
> To: Anton Vorontsov; Chris Ball
> Cc: linux-mmc@vger.kernel.org; Johan Rudholm
> Subject: RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi, Anton and Chris
> Have you any comment about the serial patch [patch 2/3/4, please ignore
> patch1]?
> Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>
> 
> Best Regards
> Jerry Huang
> 
> 
> > -----Original Message-----
> > From: Johan Rudholm [mailto:jrudholm@gmail.com]
> > Sent: Monday, November 05, 2012 10:08 PM
> > To: Huang Changming-R66093
> > Cc: linux-mmc@vger.kernel.org; Anton Vorontsov; Chris Ball
> > Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect
> > card
> >
> > Hi,
> >
> > 2012/11/5 Huang Changming-R66093 <r66093@freescale.com>:
> > >>
> > >> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> > >> > Hi, Johan,
> > >> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver
> > will
> > >> poll the card status with the command CMD13 periodically, then many
> > >> interrupts will be generated, which affect the performance.
> > >>
> > >> Ok, just to see if I understand the scenario correctly:
> > >> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap
> > >> to
> > be
> > >> set, which will cause mmc_rescan to be run at a one second interval.
> > >> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn
> > calls
> > >> _mmc_detect_card_removed, which will do the bus_ops->alive and send
> > CMD13.
> > >> So in this case, one CMD13 is sent per second, right?
> > >> Is this the cause of the performance issue?
> > >
> > > Yes, You are right.
> >
> > Ok, it's a bit hard to understand how this can lead to a noticeable
> > performance impact, but OK. :)
> >
> > >> A thought: if the host hardware does have a GPIO card detect pin
> > hooked
> > >> up, would it not be possible to make this pin generate an IRQ
> > >> whenever
> > a
> > >> card is inserted or removed? This is what we do in the MMCI driver,
> > for
> > >> instance (mmci_cd_irq).
> > >
> > > Our silicones has this pin to do card detect, but some boards don't
> > generate the interrupt when card is inserted or removed. So I have to
> > use the poll mode.
> > >
> > >> > Yes, some cases to detect GPIO can't be trusted, so I only just
> > >> implement this callback in eSDHC-of driver. that is to say, just
> > >> when
> > the
> > >> platform support it, this callback can be implement, if not,
> > >> continue
> > to
> > >> send the command CMD13.
> > >>
> > >> I'm just wondering how this will affect our system, where we use
> > >> the
> > cd
> > >> GPIO to generate detect jobs on card insert/remove, but where the
> > >> cd
> > pin
> > >> is not 100% synchronized with the electrical connection of the
> > >> power
> > and
> > >> cmd line of the SD-card. So if I remember correctly, the cd pin may
> > >> report that the card has been removed, but there is still an
> > >> electric connection and the card is alive...
> > >>
> > > I don't see this on our board, when card is inserted or removed, the
> > register field can reflect this state correctly.
> >
> > We see a difference on our boards with this patch, but no functional
> > change (actually a removed card is detected earlier now), so from my
> > perspective:
> >
> > Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>
> >
> > //Johan
> 
> 
> --
> 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] 36+ messages in thread

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-05 14:07           ` Johan Rudholm
  2012-11-06  1:55             ` Huang Changming-R66093
  2012-11-06  1:55             ` Huang Changming-R66093
@ 2012-11-19  2:48             ` Huang Changming-R66093
  2 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  2:48 UTC (permalink / raw)
  To: Anton Vorontsov, Chris Ball; +Cc: linux-mmc, Johan Rudholm

Hi, Anton and Chris
This patch has been Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com> on Nov 05.
Could you give some comment about it?

Best Regards
Jerry Huang

> -----Original Message-----
> From: Johan Rudholm [mailto:jrudholm@gmail.com]
> Sent: Monday, November 05, 2012 10:08 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Anton Vorontsov; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> 2012/11/5 Huang Changming-R66093 <r66093@freescale.com>:
> >>
> >> 2012/11/2 Huang Changming-R66093 <r66093@freescale.com>:
> >> > Hi, Johan,
> >> > When quicks SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, the driver
> will
> >> poll the card status with the command CMD13 periodically, then many
> >> interrupts will be generated, which affect the performance.
> >>
> >> Ok, just to see if I understand the scenario correctly:
> >> SDHCI_QUIRK_BROKEN_CARD_DETECTION causes the MMC_CAP_NEEDS_POLL cap to
> be
> >> set, which will cause mmc_rescan to be run at a one second interval.
> >> mmc_rescan calls bus_ops->detect (mmc_sd_detect) and this in turn
> calls
> >> _mmc_detect_card_removed, which will do the bus_ops->alive and send
> CMD13.
> >> So in this case, one CMD13 is sent per second, right?
> >> Is this the cause of the performance issue?
> >
> > Yes, You are right.
> 
> Ok, it's a bit hard to understand how this can lead to a noticeable
> performance impact, but OK. :)
> 
> >> A thought: if the host hardware does have a GPIO card detect pin
> hooked
> >> up, would it not be possible to make this pin generate an IRQ whenever
> a
> >> card is inserted or removed? This is what we do in the MMCI driver,
> for
> >> instance (mmci_cd_irq).
> >
> > Our silicones has this pin to do card detect, but some boards don't
> generate the interrupt when card is inserted or removed. So I have to use
> the poll mode.
> >
> >> > Yes, some cases to detect GPIO can't be trusted, so I only just
> >> implement this callback in eSDHC-of driver. that is to say, just when
> the
> >> platform support it, this callback can be implement, if not, continue
> to
> >> send the command CMD13.
> >>
> >> I'm just wondering how this will affect our system, where we use the
> cd
> >> GPIO to generate detect jobs on card insert/remove, but where the cd
> pin
> >> is not 100% synchronized with the electrical connection of the power
> and
> >> cmd line of the SD-card. So if I remember correctly, the cd pin may
> >> report that the card has been removed, but there is still an electric
> >> connection and the card is alive...
> >>
> > I don't see this on our board, when card is inserted or removed, the
> register field can reflect this state correctly.
> 
> We see a difference on our boards with this patch, but no functional
> change (actually a removed card is detected earlier now), so from my
> perspective:
> 
> Reviewed-By: Johan Rudholm <johan.rudholm@stericsson.com>
> 
> //Johan



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

* RE: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
  2012-10-30  8:12     ` [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card r66093
@ 2012-11-19  2:50     ` Huang Changming-R66093
  2012-11-19  2:58       ` Anton Vorontsov
  1 sibling, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  2:50 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Anton,
No any feedback since posted.
Could you give some comment about it?

Best Regards
Jerry Huang


> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Tuesday, October 30, 2012 4:13 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Anton Vorontsov; Chris Ball
> Subject: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the
> card
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> Add callback function sdhci_get_cd to detect the card.
> And one new callback added to implement the card detect in sdhci
> struncture.
> If special platform has the card detect callback, it will return the card
> state, the value zero is for absent cardi and one is for present card.
> If the controller don't support card detect, sdhci_get_cd will return -
> ENOSYS.
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- when controller don't support get_cd, return -ENOSYS
> 	- add new callback for sdhci to detect the card
> 	- add the CC
> changes for v3:
> 	- use pin_lock only when get_cd defined changes for v4:
> 	- enalbe the controller clock in platform, instead of core changes
> for v5:
> 	- remove the copyright
> 
>  drivers/mmc/host/sdhci.c |   21 +++++++++++++++++++++
>  drivers/mmc/host/sdhci.h |    2 ++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> f05a377..cc9c8a6 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
>  	return ret;
>  }
> 
> +/* Return values for the sdjco_get_cd callback:
> + *   0 for a absent card
> + *   1 for a present card
> + *   -ENOSYS when not supported (equal to NULL callback)
> + */
> +static int sdhci_get_cd(struct mmc_host *mmc) {
> +	struct sdhci_host *host = mmc_priv(mmc);
> +	unsigned long flags;
> +	int present = -ENOSYS;
> +
> +	if (host->ops->get_cd) {
> +		spin_lock_irqsave(&host->lock, flags);
> +		present = host->ops->get_cd(host);
> +		spin_unlock_irqrestore(&host->lock, flags);
> +	}
> +
> +	return present;
> +}
> +
>  static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int
> enable)  {
>  	if (host->flags & SDHCI_DEVICE_DEAD)
> @@ -1995,6 +2015,7 @@ static const struct mmc_host_ops sdhci_ops = {
>  	.request	= sdhci_request,
>  	.set_ios	= sdhci_set_ios,
>  	.get_ro		= sdhci_get_ro,
> +	.get_cd		= sdhci_get_cd,
>  	.hw_reset	= sdhci_hw_reset,
>  	.enable_sdio_irq = sdhci_enable_sdio_irq,
>  	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index
> 71a4a7e..7c8f08d 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -69,6 +69,7 @@
>  #define  SDHCI_SPACE_AVAILABLE	0x00000400
>  #define  SDHCI_DATA_AVAILABLE	0x00000800
>  #define  SDHCI_CARD_PRESENT	0x00010000
> +#define  SDHCI_CARD_CDPL	0x00040000
>  #define  SDHCI_WRITE_PROTECT	0x00080000
>  #define  SDHCI_DATA_LVL_MASK	0x00F00000
>  #define   SDHCI_DATA_LVL_SHIFT	20
> @@ -263,6 +264,7 @@ struct sdhci_ops {
> 
>  	void	(*set_clock)(struct sdhci_host *host, unsigned int clock);
> 
> +	int		(*get_cd)(struct sdhci_host *host);
>  	int		(*enable_dma)(struct sdhci_host *host);
>  	unsigned int	(*get_max_clock)(struct sdhci_host *host);
>  	unsigned int	(*get_min_clock)(struct sdhci_host *host);
> --
> 1.7.9.5



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

* RE: [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card
  2012-10-30  8:12     ` [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card r66093
@ 2012-11-19  2:50       ` Huang Changming-R66093
  2012-11-19  2:54         ` Anton Vorontsov
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  2:50 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Hi, Anton,
No any feedback since posted.
Could you give some comment about it?

Best Regards
Jerry Huang


> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Tuesday, October 30, 2012 4:13 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Anton Vorontsov; Chris Ball
> Subject: [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect
> card
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> In order to check if the card is present, we will read the PRESENT STATE
> register and check the bit13(Card detect pin level) and bit15(CINS).
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- add new callback for esdhc to detect the card state
> 	- add the CC
> changes for v3:
> 	- enable the controller clock when detect the card state, not core
> changes for v4:
> 	- based on the latest version
> 
>  drivers/mmc/host/sdhci-of-esdhc.c |   23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-
> of-esdhc.c
> index 63d219f..7053218 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -179,6 +179,28 @@ static void esdhc_of_platform_init(struct sdhci_host
> *host)
>  		host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
>  }
> 
> +/* Return: none zero - the card is presetn; 0 - card is absent */
> +static int esdhc_of_get_cd(struct sdhci_host *host)
> +{
> +	int present;
> +
> +	if (host->flags & SDHCI_DEVICE_DEAD)
> +		present = 0;
> +	else {
> +		int sysctl = sdhci_be32bs_readl(host, SDHCI_CLOCK_CONTROL);
> +		/* Enable the controller clock to update the present state */
> +		sdhci_be32bs_writel(host, sysctl | SDHCI_CLOCK_INT_EN,
> +				SDHCI_CLOCK_CONTROL);
> +		/* Detect the card present or absent */
> +		present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE);
> +		present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL);
> +		/* Resve the previous to System control register */
> +		sdhci_be32bs_writel(host, sysctl, SDHCI_CLOCK_CONTROL);
> +	}
> +
> +	return present;
> +}
> +
>  static struct sdhci_ops sdhci_esdhc_ops = {
>  	.read_l = esdhc_readl,
>  	.read_w = esdhc_readw,
> @@ -191,6 +213,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
>  	.get_max_clock = esdhc_of_get_max_clock,
>  	.get_min_clock = esdhc_of_get_min_clock,
>  	.platform_init = esdhc_of_platform_init,
> +	.get_cd = esdhc_of_get_cd,
>  #ifdef CONFIG_PM
>  	.platform_suspend = esdhc_of_suspend,
>  	.platform_resume = esdhc_of_resume,
> --
> 1.7.9.5



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

* Re: [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card
  2012-11-19  2:50       ` Huang Changming-R66093
@ 2012-11-19  2:54         ` Anton Vorontsov
  0 siblings, 0 replies; 36+ messages in thread
From: Anton Vorontsov @ 2012-11-19  2:54 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Mon, Nov 19, 2012 at 02:50:49AM +0000, Huang Changming-R66093 wrote:
[...]
> > --- a/drivers/mmc/host/sdhci-of-esdhc.c
> > +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> > @@ -179,6 +179,28 @@ static void esdhc_of_platform_init(struct sdhci_host
> > *host)
> >  		host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
> >  }
> > 
> > +/* Return: none zero - the card is presetn; 0 - card is absent */
> > +static int esdhc_of_get_cd(struct sdhci_host *host)
> > +{
> > +	int present;
> > +
> > +	if (host->flags & SDHCI_DEVICE_DEAD)
> > +		present = 0;

return 0;

> > +	else {

then you don't need the 'else', which reduces indentation level.

> > +		int sysctl = sdhci_be32bs_readl(host, SDHCI_CLOCK_CONTROL);

empty line is needed here.

> > +		/* Enable the controller clock to update the present state */
> > +		sdhci_be32bs_writel(host, sysctl | SDHCI_CLOCK_INT_EN,
> > +				SDHCI_CLOCK_CONTROL);

empty line for better readability.

> > +		/* Detect the card present or absent */
> > +		present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE);
> > +		present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL);

ditto here.

> > +		/* Resve the previous to System control register */
> > +		sdhci_be32bs_writel(host, sysctl, SDHCI_CLOCK_CONTROL);
> > +	}
> > +
> > +	return present;
> > +}
> > +
> >  static struct sdhci_ops sdhci_esdhc_ops = {
> >  	.read_l = esdhc_readl,
> >  	.read_w = esdhc_readw,
> > @@ -191,6 +213,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
> >  	.get_max_clock = esdhc_of_get_max_clock,
> >  	.get_min_clock = esdhc_of_get_min_clock,
> >  	.platform_init = esdhc_of_platform_init,
> > +	.get_cd = esdhc_of_get_cd,
> >  #ifdef CONFIG_PM
> >  	.platform_suspend = esdhc_of_suspend,
> >  	.platform_resume = esdhc_of_resume,
> > --
> > 1.7.9.5

Otherwise, it looks good to me.

Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>

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

* Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-11-19  2:50     ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card Huang Changming-R66093
@ 2012-11-19  2:58       ` Anton Vorontsov
  2012-11-19  3:15         ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Anton Vorontsov @ 2012-11-19  2:58 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Mon, Nov 19, 2012 at 02:50:18AM +0000, Huang Changming-R66093 wrote:
[...]
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> > f05a377..cc9c8a6 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
> >  	return ret;
> >  }
> > 
> > +/* Return values for the sdjco_get_cd callback:
> > + *   0 for a absent card
> > + *   1 for a present card
> > + *   -ENOSYS when not supported (equal to NULL callback)
> > + */

Incorrect style.

> > +static int sdhci_get_cd(struct mmc_host *mmc) {

ditto

> > +	struct sdhci_host *host = mmc_priv(mmc);
> > +	unsigned long flags;
> > +	int present = -ENOSYS;

	if (!host->ops->get_cd)
		return -ENOSYS;

	...
	...

Otherwise, it looks good.

Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>

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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
                     ` (2 preceding siblings ...)
  2012-11-01 15:57   ` Johan Rudholm
@ 2012-11-19  3:05   ` Anton Vorontsov
  2012-11-19  3:11     ` Huang Changming-R66093
  3 siblings, 1 reply; 36+ messages in thread
From: Anton Vorontsov @ 2012-11-19  3:05 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Chris Ball

On Tue, Oct 30, 2012 at 04:12:47PM +0800, r66093@freescale.com wrote:
[..]
> If the card is present, 1 will return, if the card is absent, 0 will return.
> If the controller will not support this feature, -ENOSYS will return.
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Anton Vorontsov <cbouatmailru@gmail.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
[...]
>  int _mmc_detect_card_removed(struct mmc_host *host)
>  {
> -	int ret;
> +	int ret = -ENOSYS;
>  
>  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
>  		return 0;
> @@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
>  	if (!host->card || mmc_card_removed(host->card))
>  		return 1;
>  
> -	ret = host->bus_ops->alive(host);
> +	if (host->ops->get_cd) {
> +		ret = host->ops->get_cd(host);
> +		if (ret >= 0)
> +			ret = !ret;

o_O

Oh, I see...

Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>

(But I must confess I didn't follow the whole discussion about
get_cd()-via-gpio being unreliable. I'm assuming you fixed this?)

> +	}
> +	if (ret < 0)
> +		ret = host->bus_ops->alive(host);
>  	if (ret) {
>  		mmc_card_set_removed(host->card);
>  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> -- 
> 1.7.9.5

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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-11-19  3:05   ` Anton Vorontsov
@ 2012-11-19  3:11     ` Huang Changming-R66093
  0 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  3:11 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linux-mmc, Chris Ball


> -----Original Message-----
> From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]
> Sent: Monday, November 19, 2012 11:06 AM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> On Tue, Oct 30, 2012 at 04:12:47PM +0800, r66093@freescale.com wrote:
> [..]
> > If the card is present, 1 will return, if the card is absent, 0 will
> return.
> > If the controller will not support this feature, -ENOSYS will return.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Anton Vorontsov <cbouatmailru@gmail.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> [...]
> >  int _mmc_detect_card_removed(struct mmc_host *host)
> >  {
> > -	int ret;
> > +	int ret = -ENOSYS;
> >
> >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
> >  		return 0;
> > @@ -2081,7 +2081,13 @@ int _mmc_detect_card_removed(struct mmc_host
> *host)
> >  	if (!host->card || mmc_card_removed(host->card))
> >  		return 1;
> >
> > -	ret = host->bus_ops->alive(host);
> > +	if (host->ops->get_cd) {
> > +		ret = host->ops->get_cd(host);
> > +		if (ret >= 0)
> > +			ret = !ret;
> 
> o_O
> 
> Oh, I see...
> 
> Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>
> 
> (But I must confess I didn't follow the whole discussion about
> get_cd()-via-gpio being unreliable. I'm assuming you fixed this?)
> 
If the GPIO is unreliable, the related driver may not implement the callback function get_cd.
For eSDHC, the GPIO is reliable, so I do it.

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

* RE: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-11-19  2:58       ` Anton Vorontsov
@ 2012-11-19  3:15         ` Huang Changming-R66093
  2012-11-19  3:31           ` Anton Vorontsov
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  3:15 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

> -----Original Message-----
> From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]
> Sent: Monday, November 19, 2012 10:58 AM
> To: Huang Changming-R66093
> Cc: Chris Ball; linux-mmc@vger.kernel.org
> Subject: Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect
> the card
> 
> On Mon, Nov 19, 2012 at 02:50:18AM +0000, Huang Changming-R66093 wrote:
> [...]
> > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index
> > > f05a377..cc9c8a6 100644
> > > --- a/drivers/mmc/host/sdhci.c
> > > +++ b/drivers/mmc/host/sdhci.c
> > > @@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
> > >  	return ret;
> > >  }
> > >
> > > +/* Return values for the sdjco_get_cd callback:
> > > + *   0 for a absent card
> > > + *   1 for a present card
> > > + *   -ENOSYS when not supported (equal to NULL callback)
> > > + */
> 
> Incorrect style.
Hi, Anton, you mean the comment style is incrorrect?
It should be:
/*
 * xxxxx
 * xxxxxx
 */

> > > +static int sdhci_get_cd(struct mmc_host *mmc) {
> 
> ditto
I don't see the issue, could you explain it?

> 
> > > +	struct sdhci_host *host = mmc_priv(mmc);
> > > +	unsigned long flags;
> > > +	int present = -ENOSYS;
> 
> 	if (!host->ops->get_cd)
> 		return -ENOSYS;
> 
> 	...
> 	...
> 
> Otherwise, it looks good.
> 
> Reviewed-by: Anton Vorontsov <cbouatmailru@gmail.com>


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

* Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-11-19  3:15         ` Huang Changming-R66093
@ 2012-11-19  3:31           ` Anton Vorontsov
  2012-11-19  3:38             ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Anton Vorontsov @ 2012-11-19  3:31 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Mon, Nov 19, 2012 at 03:15:53AM +0000, Huang Changming-R66093 wrote:
[...]
> > > > @@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
> > > >  	return ret;
> > > >  }
> > > >
> > > > +/* Return values for the sdjco_get_cd callback:
> > > > + *   0 for a absent card
> > > > + *   1 for a present card
> > > > + *   -ENOSYS when not supported (equal to NULL callback)
> > > > + */
> > 
> > Incorrect style.
> Hi, Anton, you mean the comment style is incrorrect?
> It should be:
> /*
>  * xxxxx
>  * xxxxxx
>  */

Yup.

> 
> > > > +static int sdhci_get_cd(struct mmc_host *mmc) {
> > 
> > ditto
> I don't see the issue, could you explain it?

The issue is in the brace placement. It should be

static int sdhci_get_cd(struct mmc_host *mmc)
{
	...
}

Please refer to Documentation/CodingStyle -- it's a great document.

Thanks,
Anton.

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

* RE: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
  2012-11-19  3:31           ` Anton Vorontsov
@ 2012-11-19  3:38             ` Huang Changming-R66093
  0 siblings, 0 replies; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-11-19  3:38 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc



Best Regards
Jerry Huang


> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Anton Vorontsov
> Sent: Monday, November 19, 2012 11:31 AM
> To: Huang Changming-R66093
> Cc: Chris Ball; linux-mmc@vger.kernel.org
> Subject: Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect
> the card
> 
> On Mon, Nov 19, 2012 at 03:15:53AM +0000, Huang Changming-R66093 wrote:
> [...]
> > > > > @@ -1573,6 +1573,26 @@ static int sdhci_get_ro(struct mmc_host
> *mmc)
> > > > >  	return ret;
> > > > >  }
> > > > >
> > > > > +/* Return values for the sdjco_get_cd callback:
> > > > > + *   0 for a absent card
> > > > > + *   1 for a present card
> > > > > + *   -ENOSYS when not supported (equal to NULL callback)
> > > > > + */
> > >
> > > Incorrect style.
> > Hi, Anton, you mean the comment style is incrorrect?
> > It should be:
> > /*
> >  * xxxxx
> >  * xxxxxx
> >  */
> 
> Yup.

Thanks, Anton, I see.

> >
> > > > > +static int sdhci_get_cd(struct mmc_host *mmc) {
> > >
> > > ditto
> > I don't see the issue, could you explain it?
> 
> The issue is in the brace placement. It should be
> 
> static int sdhci_get_cd(struct mmc_host *mmc)
> {
> 	...
> }
> 
> Please refer to Documentation/CodingStyle -- it's a great document.
> 
Yes, my first post is that you say,
Maybe the extra lines breaks has been removed in you message, so you see the incorrect style.

Anyway, Thank you very much.
I will post new version with your Reviewed.


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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-01-13  7:05         ` Huang Changming-R66093
@ 2012-01-13  7:36           ` Aaron Lu
  0 siblings, 0 replies; 36+ messages in thread
From: Aaron Lu @ 2012-01-13  7:36 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linux-mmc, Chris Ball

On Fri, Jan 13, 2012 at 07:05:19AM +0000, Huang Changming-R66093 wrote:
> If you read the previous email about this serial patches discussed with other guys, you can understand.
> 
> > -----Original Message-----
> > From: Aaron Lu [mailto:aaron.lu@amd.com]
> > Sent: Friday, January 13, 2012 2:28 PM
> > To: Huang Changming-R66093
> > Cc: linux-mmc@vger.kernel.org; Chris Ball
> > Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> > 
> > Hi,
> > 
> > On Fri, Jan 13, 2012 at 04:52:42AM +0000, Huang Changming-R66093 wrote:
> > >
> > > > For sd hosts, this should only happen for hosts which have
> > > > SDHCI_QUIRK_BROKEN_CARD_DETECTION set.
> > > Yes, but which will impact the performance.
> > 
> > You only set this bit when your host broke, and if your host has other
> > means to detect this, then go with your newly added callback.
> To detect the card state, if SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, then driver will send command to card, which will cause the bad performance.
> So my patch will do:
> 1. use get_cd to detect the card state, if platform don't support this feature(get_cd is not defined in special platform), -ENOSYS will be returned
> 2. if -ENOSYS, then send the command to card.

OK, this is clear. I didn't know there is a get_cd callback already
defined in sdhci_ops with a clear return value description, sorry for
the mess.

> > I just suggested to change the name and use a different return value for
> > this get_cd function, not to add a new function call.
> > 
> The description for get_cd in file "include/linux/mmc/host.h":
>          * Return values for the get_cd callback should be:
>          *   0 for a absent card
>          *   1 for a present card
>          *   -ENOSYS when not supported (equal to NULL callback)
>          *   or a negative errno value when something bad happened
> I don't think your suggest is reasonable.
Agree.



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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-01-13  6:27       ` Aaron Lu
@ 2012-01-13  7:05         ` Huang Changming-R66093
  2012-01-13  7:36           ` Aaron Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  7:05 UTC (permalink / raw)
  To: Aaron Lu; +Cc: linux-mmc, Chris Ball

If you read the previous email about this serial patches discussed with other guys, you can understand.

> -----Original Message-----
> From: Aaron Lu [mailto:aaron.lu@amd.com]
> Sent: Friday, January 13, 2012 2:28 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> On Fri, Jan 13, 2012 at 04:52:42AM +0000, Huang Changming-R66093 wrote:
> >
> > > For sd hosts, this should only happen for hosts which have
> > > SDHCI_QUIRK_BROKEN_CARD_DETECTION set.
> > Yes, but which will impact the performance.
> 
> You only set this bit when your host broke, and if your host has other
> means to detect this, then go with your newly added callback.
To detect the card state, if SDHCI_QUIRK_BROKEN_CARD_DETECTION is set, then driver will send command to card, which will cause the bad performance.
So my patch will do:
1. use get_cd to detect the card state, if platform don't support this feature(get_cd is not defined in special platform), -ENOSYS will be returned
2. if -ENOSYS, then send the command to card.

> >
> > > > >
> > > > > If the card is present, 1 will return, if the card is absent, 0
> > > > > will return.
> > > > > If the controller will not support this feature, -ENOSYS will
> return.
> > >
> > > What about get_present, return 0 for present, and return error code
> > > otherwise like the alive function does.
> > The hook to detect card is get_cd in the kernel, don't need the new.
> >
> 
> I didn't mean to add a new function, I just can't get the meaning of cd.
> I just did a grep of the code and find some same fuction names in various
> host files, I think it's OK to continue with this name.


> > > > >
> > > > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > > > CC: Chris Ball <cjb@laptop.org>
> > > > > ---
> > > > > changes for v2:
> 
> > > > >
> > > > >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops-
> >alive)
> > > > >  		return 0;
> > > > > @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct
> > > > > mmc_host
> > > *host)
> > > > >  	if (!host->card || mmc_card_removed(host->card))
> > > > >  		return 1;
> > > > >
> > > > > -	ret = host->bus_ops->alive(host);
> > > > > +	if (host->ops->get_cd) {
> > > > > +		ret = host->ops->get_cd(host);
> > > > > +		if (ret >= 0)
> > > > > +			ret = !ret;
> > > > > +	}
> > > > > +	if (ret < 0)
> > > > > +		ret = host->bus_ops->alive(host);
> > > > >  	if (ret) {
> > > > >  		mmc_card_set_removed(host->card);
> > > > >  		pr_debug("%s: card remove detected\n",
> mmc_hostname(host));
> > > > > --
> > > > > 1.7.5.4
> > >
> > > And the code can be changed to something like:
> > > 	if (host->ops->get_present)
> > > 		ret = host->ops->get_present(host);
> > > 	else
> > > 		ret = host->bus_ops->alive(host);
> > > 	if (ret) {
> > > 		mmc_card_set_removed(host->card);
> > >   		pr_debug("%s: card remove detected\n",
> mmc_hostname(host));
> > > 	}
> > >
> > >
> > > Does this make sense?
> > No.
> > Because the get_cd is the hook to detect card in mmc_host_ops structure
> in include/linux/mmc/host.h.
> > We don't need to add new.
> >
> 
> I just suggested to change the name and use a different return value for
> this get_cd function, not to add a new function call.
> 
The description for get_cd in file "include/linux/mmc/host.h":
         * Return values for the get_cd callback should be:
         *   0 for a absent card
         *   1 for a present card
         *   -ENOSYS when not supported (equal to NULL callback)
         *   or a negative errno value when something bad happened
I don't think your suggest is reasonable.



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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-01-13  4:52     ` Huang Changming-R66093
@ 2012-01-13  6:27       ` Aaron Lu
  2012-01-13  7:05         ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Aaron Lu @ 2012-01-13  6:27 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linux-mmc, Chris Ball

Hi,

On Fri, Jan 13, 2012 at 04:52:42AM +0000, Huang Changming-R66093 wrote:
> 
> > For sd hosts, this should only happen for hosts which have
> > SDHCI_QUIRK_BROKEN_CARD_DETECTION set.
> Yes, but which will impact the performance.

You only set this bit when your host broke, and if your host has other
means to detect this, then go with your newly added callback.

> 
> 
> > > >
> > > > Therefore, add callback function get_cd() to check whether the card
> > > > has been removed when the driver has this callback function.
> > 
> > I don't quite get the meaning of cd, what does get_cd suppose to mean?
> This get_cd callback is implement in the special platform, because some SOC don't support this feature
> 
> > > >
> > > > If the card is present, 1 will return, if the card is absent, 0 will
> > > > return.
> > > > If the controller will not support this feature, -ENOSYS will return.
> > 
> > What about get_present, return 0 for present, and return error code
> > otherwise like the alive function does.
> The hook to detect card is get_cd in the kernel, don't need the new.
> 

I didn't mean to add a new function, I just can't get the meaning of cd.
I just did a grep of the code and find some same fuction names in
various host files, I think it's OK to continue with this name.

> > > >
> > > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > > CC: Chris Ball <cjb@laptop.org>
> > > > ---
> > > > changes for v2:
> > > >         - when controller don't support get_cd, return -ENOSYS
> > > >         - add the CC
> > > > changes for v3:
> > > >         - enalbe the controller clock in platform, instead of core
> > > > changes for v4:
> > > > 	- move the detect code to core.c according to the new structure
> > > >
> > > >  drivers/mmc/core/core.c |   10 ++++++++--
> > > >  1 files changed, 8 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index
> > > > 6db6621..d570c72 100644
> > > > --- a/drivers/mmc/core/core.c
> > > > +++ b/drivers/mmc/core/core.c
> > > > @@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> > > > *host, unsigned freq)
> > > >
> > 
> > snip
> > > >  int _mmc_detect_card_removed(struct mmc_host *host)  {
> > > > -	int ret;
> > > > +	int ret = -ENOSYS;
> > > >
> > > >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
> > > >  		return 0;
> > > > @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host
> > *host)
> > > >  	if (!host->card || mmc_card_removed(host->card))
> > > >  		return 1;
> > > >
> > > > -	ret = host->bus_ops->alive(host);
> > > > +	if (host->ops->get_cd) {
> > > > +		ret = host->ops->get_cd(host);
> > > > +		if (ret >= 0)
> > > > +			ret = !ret;
> > > > +	}
> > > > +	if (ret < 0)
> > > > +		ret = host->bus_ops->alive(host);
> > > >  	if (ret) {
> > > >  		mmc_card_set_removed(host->card);
> > > >  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > > > --
> > > > 1.7.5.4
> > 
> > And the code can be changed to something like:
> > 	if (host->ops->get_present)
> > 		ret = host->ops->get_present(host);
> > 	else
> > 		ret = host->bus_ops->alive(host);
> > 	if (ret) {
> > 		mmc_card_set_removed(host->card);
> >   		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > 	}
> > 
> > 
> > Does this make sense?
> No.
> Because the get_cd is the hook to detect card in mmc_host_ops structure in include/linux/mmc/host.h.
> We don't need to add new.
>

I just suggested to change the name and use a different return value for
this get_cd function, not to add a new function call.



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

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-01-13  3:26   ` Aaron Lu
@ 2012-01-13  4:52     ` Huang Changming-R66093
  2012-01-13  6:27       ` Aaron Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  4:52 UTC (permalink / raw)
  To: Aaron Lu; +Cc: linux-mmc, Chris Ball



> -----Original Message-----
> From: Aaron Lu [mailto:aaron.lu@amd.com]
> Sent: Friday, January 13, 2012 11:27 AM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Chris Ball
> Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> Hi,
> 
> On Fri, Jan 13, 2012 at 02:25:11AM +0000, Huang Changming-R66093 wrote:
> > Hi, Chris,
> > Could you have any comment about this patch?
> > Can it go into 3.3 or 3.4?
> >
> > Thanks
> > Jerry Huang
> > > -----Original Message-----
> > > From: Huang Changming-R66093
> > > Sent: Tuesday, December 27, 2011 4:01 PM
> > > To: linux-mmc@vger.kernel.org
> > > Cc: Huang Changming-R66093; Chris Ball
> > > Subject: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> > >
> > > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > >
> > > In order to check whether the card has been removed, the function
> > > mmc_send_status() will send command CMD13 to card and ask the card
> > > to send its status register to sdhc driver, which will generate many
> > > interrupts repeatedly and make the system performance bad.
> 
> For sd hosts, this should only happen for hosts which have
> SDHCI_QUIRK_BROKEN_CARD_DETECTION set.
Yes, but which will impact the performance.


> > >
> > > Therefore, add callback function get_cd() to check whether the card
> > > has been removed when the driver has this callback function.
> 
> I don't quite get the meaning of cd, what does get_cd suppose to mean?
This get_cd callback is implement in the special platform, because some SOC don't support this feature

> > >
> > > If the card is present, 1 will return, if the card is absent, 0 will
> > > return.
> > > If the controller will not support this feature, -ENOSYS will return.
> 
> What about get_present, return 0 for present, and return error code
> otherwise like the alive function does.
The hook to detect card is get_cd in the kernel, don't need the new.

> > >
> > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > CC: Chris Ball <cjb@laptop.org>
> > > ---
> > > changes for v2:
> > >         - when controller don't support get_cd, return -ENOSYS
> > >         - add the CC
> > > changes for v3:
> > >         - enalbe the controller clock in platform, instead of core
> > > changes for v4:
> > > 	- move the detect code to core.c according to the new structure
> > >
> > >  drivers/mmc/core/core.c |   10 ++++++++--
> > >  1 files changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index
> > > 6db6621..d570c72 100644
> > > --- a/drivers/mmc/core/core.c
> > > +++ b/drivers/mmc/core/core.c
> > > @@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> > > *host, unsigned freq)
> > >
> 
> snip
> > >  int _mmc_detect_card_removed(struct mmc_host *host)  {
> > > -	int ret;
> > > +	int ret = -ENOSYS;
> > >
> > >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
> > >  		return 0;
> > > @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host
> *host)
> > >  	if (!host->card || mmc_card_removed(host->card))
> > >  		return 1;
> > >
> > > -	ret = host->bus_ops->alive(host);
> > > +	if (host->ops->get_cd) {
> > > +		ret = host->ops->get_cd(host);
> > > +		if (ret >= 0)
> > > +			ret = !ret;
> > > +	}
> > > +	if (ret < 0)
> > > +		ret = host->bus_ops->alive(host);
> > >  	if (ret) {
> > >  		mmc_card_set_removed(host->card);
> > >  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > > --
> > > 1.7.5.4
> 
> And the code can be changed to something like:
> 	if (host->ops->get_present)
> 		ret = host->ops->get_present(host);
> 	else
> 		ret = host->bus_ops->alive(host);
> 	if (ret) {
> 		mmc_card_set_removed(host->card);
>   		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> 	}
> 
> 
> Does this make sense?
No.
Because the get_cd is the hook to detect card in mmc_host_ops structure in include/linux/mmc/host.h.
We don't need to add new.


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

* Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2012-01-13  2:25 ` Huang Changming-R66093
@ 2012-01-13  3:26   ` Aaron Lu
  2012-01-13  4:52     ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: Aaron Lu @ 2012-01-13  3:26 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: linux-mmc, Chris Ball

Hi,

On Fri, Jan 13, 2012 at 02:25:11AM +0000, Huang Changming-R66093 wrote:
> Hi, Chris,
> Could you have any comment about this patch?
> Can it go into 3.3 or 3.4?
> 
> Thanks
> Jerry Huang
> > -----Original Message-----
> > From: Huang Changming-R66093
> > Sent: Tuesday, December 27, 2011 4:01 PM
> > To: linux-mmc@vger.kernel.org
> > Cc: Huang Changming-R66093; Chris Ball
> > Subject: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> > 
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > 
> > In order to check whether the card has been removed, the function
> > mmc_send_status() will send command CMD13 to card and ask the card
> > to send its status register to sdhc driver, which will generate
> > many interrupts repeatedly and make the system performance bad.

For sd hosts, this should only happen for hosts which have
SDHCI_QUIRK_BROKEN_CARD_DETECTION set.

> > 
> > Therefore, add callback function get_cd() to check whether
> > the card has been removed when the driver has this callback function.

I don't quite get the meaning of cd, what does get_cd suppose to mean?

> > 
> > If the card is present, 1 will return, if the card is absent, 0 will
> > return.
> > If the controller will not support this feature, -ENOSYS will return.

What about get_present, return 0 for present, and return error code
otherwise like the alive function does.

> > 
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> > changes for v2:
> >         - when controller don't support get_cd, return -ENOSYS
> >         - add the CC
> > changes for v3:
> >         - enalbe the controller clock in platform, instead of core
> > changes for v4:
> > 	- move the detect code to core.c according to the new structure
> > 
> >  drivers/mmc/core/core.c |   10 ++++++++--
> >  1 files changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > index 6db6621..d570c72 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> > *host, unsigned freq)
> > 

snip
> >  int _mmc_detect_card_removed(struct mmc_host *host)
> >  {
> > -	int ret;
> > +	int ret = -ENOSYS;
> > 
> >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
> >  		return 0;
> > @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
> >  	if (!host->card || mmc_card_removed(host->card))
> >  		return 1;
> > 
> > -	ret = host->bus_ops->alive(host);
> > +	if (host->ops->get_cd) {
> > +		ret = host->ops->get_cd(host);
> > +		if (ret >= 0)
> > +			ret = !ret;
> > +	}
> > +	if (ret < 0)
> > +		ret = host->bus_ops->alive(host);
> >  	if (ret) {
> >  		mmc_card_set_removed(host->card);
> >  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > --
> > 1.7.5.4

And the code can be changed to something like:
	if (host->ops->get_present)
		ret = host->ops->get_present(host);
	else
		ret = host->bus_ops->alive(host);
	if (ret) {
		mmc_card_set_removed(host->card);
  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
	}


Does this make sense?

-Aaron

> 
> 
> --
> 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] 36+ messages in thread

* RE: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
  2011-12-27  8:00 [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
@ 2012-01-13  2:25 ` Huang Changming-R66093
  2012-01-13  3:26   ` Aaron Lu
  0 siblings, 1 reply; 36+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  2:25 UTC (permalink / raw)
  To: Huang Changming-R66093, linux-mmc; +Cc: Chris Ball

Hi, Chris,
Could you have any comment about this patch?
Can it go into 3.3 or 3.4?

Thanks
Jerry Huang
> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Tuesday, December 27, 2011 4:01 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Chris Ball
> Subject: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> In order to check whether the card has been removed, the function
> mmc_send_status() will send command CMD13 to card and ask the card
> to send its status register to sdhc driver, which will generate
> many interrupts repeatedly and make the system performance bad.
> 
> Therefore, add callback function get_cd() to check whether
> the card has been removed when the driver has this callback function.
> 
> If the card is present, 1 will return, if the card is absent, 0 will
> return.
> If the controller will not support this feature, -ENOSYS will return.
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
>         - when controller don't support get_cd, return -ENOSYS
>         - add the CC
> changes for v3:
>         - enalbe the controller clock in platform, instead of core
> changes for v4:
> 	- move the detect code to core.c according to the new structure
> 
>  drivers/mmc/core/core.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 6db6621..d570c72 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> *host, unsigned freq)
> 
>  int _mmc_detect_card_removed(struct mmc_host *host)
>  {
> -	int ret;
> +	int ret = -ENOSYS;
> 
>  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
>  		return 0;
> @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
>  	if (!host->card || mmc_card_removed(host->card))
>  		return 1;
> 
> -	ret = host->bus_ops->alive(host);
> +	if (host->ops->get_cd) {
> +		ret = host->ops->get_cd(host);
> +		if (ret >= 0)
> +			ret = !ret;
> +	}
> +	if (ret < 0)
> +		ret = host->bus_ops->alive(host);
>  	if (ret) {
>  		mmc_card_set_removed(host->card);
>  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> --
> 1.7.5.4



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

* [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
@ 2011-12-27  8:00 r66093
  2012-01-13  2:25 ` Huang Changming-R66093
  0 siblings, 1 reply; 36+ messages in thread
From: r66093 @ 2011-12-27  8:00 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

In order to check whether the card has been removed, the function
mmc_send_status() will send command CMD13 to card and ask the card
to send its status register to sdhc driver, which will generate
many interrupts repeatedly and make the system performance bad.

Therefore, add callback function get_cd() to check whether
the card has been removed when the driver has this callback function.

If the card is present, 1 will return, if the card is absent, 0 will return.
If the controller will not support this feature, -ENOSYS will return.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
        - when controller don't support get_cd, return -ENOSYS
        - add the CC
changes for v3:
        - enalbe the controller clock in platform, instead of core
changes for v4:
	- move the detect code to core.c according to the new structure

 drivers/mmc/core/core.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 6db6621..d570c72 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 
 int _mmc_detect_card_removed(struct mmc_host *host)
 {
-	int ret;
+	int ret = -ENOSYS;
 
 	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
 		return 0;
@@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host *host)
 	if (!host->card || mmc_card_removed(host->card))
 		return 1;
 
-	ret = host->bus_ops->alive(host);
+	if (host->ops->get_cd) {
+		ret = host->ops->get_cd(host);
+		if (ret >= 0)
+			ret = !ret;
+	}
+	if (ret < 0)
+		ret = host->bus_ops->alive(host);
 	if (ret) {
 		mmc_card_set_removed(host->card);
 		pr_debug("%s: card remove detected\n", mmc_hostname(host));
-- 
1.7.5.4



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

end of thread, other threads:[~2012-11-19  3:38 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30  8:12 [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() r66093
2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
2012-10-30  8:12   ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
2012-10-30  8:12     ` [PATCH 4/4 v4] ESDHC: add callback esdhc_of_get_cd to detect card r66093
2012-11-19  2:50       ` Huang Changming-R66093
2012-11-19  2:54         ` Anton Vorontsov
2012-11-19  2:50     ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card Huang Changming-R66093
2012-11-19  2:58       ` Anton Vorontsov
2012-11-19  3:15         ` Huang Changming-R66093
2012-11-19  3:31           ` Anton Vorontsov
2012-11-19  3:38             ` Huang Changming-R66093
2012-10-30 11:34   ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card Girish K S
2012-10-31  2:23     ` Huang Changming-R66093
2012-10-31  4:29       ` Jaehoon Chung
2012-10-31  5:52         ` Huang Changming-R66093
2012-11-01 15:57   ` Johan Rudholm
2012-11-02  1:37     ` Huang Changming-R66093
2012-11-02 10:33       ` Johan Rudholm
2012-11-05  3:17         ` Huang Changming-R66093
2012-11-05 14:07           ` Johan Rudholm
2012-11-06  1:55             ` Huang Changming-R66093
2012-11-06  1:55             ` Huang Changming-R66093
2012-11-13  7:50               ` Huang Changming-R66093
2012-11-19  2:48             ` Huang Changming-R66093
2012-11-19  3:05   ` Anton Vorontsov
2012-11-19  3:11     ` Huang Changming-R66093
2012-10-30 23:08 ` [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() Ulf Hansson
2012-10-31  2:23   ` Huang Changming-R66093
2012-10-31  4:21   ` Jaehoon Chung
  -- strict thread matches above, loose matches on Subject: below --
2011-12-27  8:00 [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
2012-01-13  2:25 ` Huang Changming-R66093
2012-01-13  3:26   ` Aaron Lu
2012-01-13  4:52     ` Huang Changming-R66093
2012-01-13  6:27       ` Aaron Lu
2012-01-13  7:05         ` Huang Changming-R66093
2012-01-13  7:36           ` Aaron Lu

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.