Re: [PATCH] mmc: core: restore ocr and operation voltage in resume

2013-04-05 Thread Prasanna NAVARATNA
Ulf Hansson ulf.hansson at linaro.org writes:

 host-ocr is intended for keeping the negotiated ocr mask. Another
 variable is not needed.
 
 A proper patch would in principle remove the workaround, which means
 the reset of the host-ocr in mmc_power_off is not done any more.
 
 Exactly what you need to make this work, is as stated before a bit
 more complicated.

Hello Ulf,

The work around is introduced by yourself :-
At power off, reset OCR mask to be the highest possible voltage
supported for the current mmc host.

This solves the re-initialization during the power up sequence.
The voltage may have been decreased due to the card accepts a lower
voltage than the voltage used during the initialization sequence.
We need to reset the voltage to by the host highest possible value
since according to _specification_ the initialization must always be
done at high voltage

So do you think, solution to current issue is to revert this patch? This 
will not violate the spec as you are mentioning above?
If you agree, i'll push a new patch by reverting this. Else consider another 
way in my new post mmc: core: negotiate ocr during resume
This patch will follow the spec and will also negotiate ocr during 
mmc_resume_host.

Thanks,
Prasanna NAVARATNA

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: mxs-mmc: Add support for non-removable cards

2013-04-05 Thread Marek Vasut
Dear Alexandre Pereira da Silva,

 Some boards and card slots doesn't have card detect feature available.
 In that case allow to mark the cards as non-removable, via devicetree.
 
 Signed-off-by: Alexandre Pereira da Silva aletes@gmail.com

Looks good,

Reviewed-by: Marek Vasut ma...@denx.de

btw. did you know you can let git send-email automatically handle CC for you so 
you don't have to type it into the command line by simply sticking

Cc: Us Er e...@ma.il

in the commit message? Preferably under the SoB line.

 ---
  drivers/mmc/host/mxs-mmc.c |6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
 index 4efe302..7d2cd74 100644
 --- a/drivers/mmc/host/mxs-mmc.c
 +++ b/drivers/mmc/host/mxs-mmc.c
 @@ -95,6 +95,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
   struct mxs_mmc_host *host = mmc_priv(mmc);
   struct mxs_ssp *ssp = host-ssp;
 
 + if (mmc-caps  MMC_CAP_NONREMOVABLE)
 + return 1;
 +
   return !(readl(ssp-base + HW_SSP_STATUS(ssp)) 
BM_SSP_STATUS_CARD_DETECT);
  }
 @@ -691,6 +694,9 @@ static int mxs_mmc_probe(struct platform_device *pdev)
   if (flags  OF_GPIO_ACTIVE_LOW)
   host-wp_inverted = 1;
 
 + if (of_find_property(np, non-removable, NULL))
 + mmc-caps |= MMC_CAP_NONREMOVABLE;
 +
   mmc-f_min = 40;
   mmc-f_max = 28800;
   mmc-ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mmc: core: fix performance regression initializing MMC host controllers

2013-04-05 Thread Adrian Hunter
On 05/04/13 00:02, Ulf Hansson wrote:
 On 4 April 2013 15:41, Adrian Hunter adrian.hun...@intel.com wrote:
 Commit fa5501890d8974301042e0202d342a6cbe8609f4 introduced a performance
 regression by adding mmc_power_up() to mmc_start_host().  mmc_power_up()
 is not necessary to host controller initialization, it is part of card
 initialization and is performed anyway asynchronously.
 
 This commit message is a bit miss-leading. In eMMC case, when the host
 driver has no possibility of power cycle the VCCQ power supply but
 only the VCC, this is the only proper way to prevent violation of the
 eMMC spec.

But that is not true.  The host controller driver can manage the voltages.
The patch is a workaround for the regulator_init_complete late initcall.

I deliberately did not paraphrase the original commit so that people who
wanted to know would have to look at it for themselves.  I really cannot add
things to my commit message that do not make sense to me.

 
From SD-card point of view, it is not needed, so this can be optimized
 to be done as before in an asynchronous mode.
 

 This patch allows a driver to leave the power up in asynchronous code
 (as it was before).

 On my current target platform this reduces driver initialization from:

 [1.313220] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 102008 usecs

 to this:

 [1.217209] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 8331 usecs

 Signed-off-by: Adrian Hunter adrian.hun...@intel.com
 ---
  drivers/mmc/core/core.c   | 3 ++-
  drivers/mmc/host/sdhci-acpi.c | 2 ++
  include/linux/mmc/host.h  | 1 +
  3 files changed, 5 insertions(+), 1 deletion(-)

 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
 index 3bf1c46..c1893c9 100644
 --- a/drivers/mmc/core/core.c
 +++ b/drivers/mmc/core/core.c
 @@ -2416,7 +2416,8 @@ void mmc_start_host(struct mmc_host *host)
  {
 host-f_init = max(freqs[0], host-f_min);
 host-rescan_disable = 0;
 -   mmc_power_up(host);
 +   if (!(host-caps2  MMC_CAP2_NO_PRESCAN_POWERUP))
 +   mmc_power_up(host);
 mmc_detect_change(host, 0);
  }

 diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
 index 2592ddd..7bcf74b 100644
 --- a/drivers/mmc/host/sdhci-acpi.c
 +++ b/drivers/mmc/host/sdhci-acpi.c
 @@ -195,6 +195,8 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 host-mmc-pm_caps  |= c-slot-pm_caps;
 }

 +   host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
 +
 err = sdhci_add_host(host);
 if (err)
 goto err_free;
 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
 index 17d7148..8873e83 100644
 --- a/include/linux/mmc/host.h
 +++ b/include/linux/mmc/host.h
 @@ -280,6 +280,7 @@ struct mmc_host {
  #define MMC_CAP2_PACKED_WR (1  13)   /* Allow packed write */
  #define MMC_CAP2_PACKED_CMD(MMC_CAP2_PACKED_RD | \
  MMC_CAP2_PACKED_WR)
 +#define MMC_CAP2_NO_PRESCAN_POWERUP (1  14)  /* Don't power up before 
 scan */

 mmc_pm_flag_t   pm_caps;/* supported pm features */

 --
 1.7.11.7

 
 
 Some update to the commit msg, then I am happy.
 
 Reviewed-by: Ulf Hansson ulf.hans...@linaro.org
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 2/2] mmc: core: fix performance regression initializing MMC, host controllers

2013-04-05 Thread Adrian Hunter
Commit fa5501890d8974301042e0202d342a6cbe8609f4 introduced a performance
regression by adding mmc_power_up() to mmc_start_host().  mmc_power_up()
is not necessary to host controller initialization, it is part of card
initialization and is performed anyway asynchronously.  Please see the
original commit for an explanation of the use of mmc_power_up() in
mmc_start_host().

This patch allows a driver to leave the power up in asynchronous code
(as it was before).

On my current target platform this reduces driver initialization from:

[1.313220] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 102008 
usecs

to this:

[1.217209] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 8331 
usecs

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/core/core.c   | 3 ++-
 drivers/mmc/host/sdhci-acpi.c | 2 ++
 include/linux/mmc/host.h  | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 3bf1c46..c1893c9 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2416,7 +2416,8 @@ void mmc_start_host(struct mmc_host *host)
 {
host-f_init = max(freqs[0], host-f_min);
host-rescan_disable = 0;
-   mmc_power_up(host);
+   if (!(host-caps2  MMC_CAP2_NO_PRESCAN_POWERUP))
+   mmc_power_up(host);
mmc_detect_change(host, 0);
 }
 
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 2592ddd..7bcf74b 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -195,6 +195,8 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
host-mmc-pm_caps  |= c-slot-pm_caps;
}
 
+   host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
+
err = sdhci_add_host(host);
if (err)
goto err_free;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 17d7148..8873e83 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -280,6 +280,7 @@ struct mmc_host {
 #define MMC_CAP2_PACKED_WR (1  13)   /* Allow packed write */
 #define MMC_CAP2_PACKED_CMD(MMC_CAP2_PACKED_RD | \
 MMC_CAP2_PACKED_WR)
+#define MMC_CAP2_NO_PRESCAN_POWERUP (1  14)  /* Don't power up before scan */
 
mmc_pm_flag_t   pm_caps;/* supported pm features */
 
-- 
1.7.11.7
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] RFC: mmc: dw_mmc: Always go to STATE_DATA_BUSY from STATE_DATA_ERROR

2013-04-05 Thread Jaehoon Chung
Hi Doug,

You're right..it's something wrong.
Actually i didn't test with your patch, but your commit message is reasonable.

I will check until next week after test.

Best Regards,
Jaehoon Chung

On 03/27/2013 03:06 AM, Doug Anderson wrote:
 Jaehoon,
 
 On Mon, Mar 18, 2013 at 3:21 AM, Jaehoon Chung jh80.ch...@samsung.com wrote:
 Hi Doug,

 Great..i have found the problem like this.
 I will check your patch..and share the result.
 
 Did you have any time to check this patch?
 
 Thanks!
 
 -Doug
 

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: core: negotiate ocr during resume

2013-04-05 Thread Kevin Liu
 -Original Message-
 From: linux-mmc-ow...@vger.kernel.org 
 [mailto:linux-mmc-ow...@vger.kernel.org] On Behalf Of Prasanna NAVARATNA
 Sent: Thursday, April 04, 2013 10:35 PM
 To: linux-mmc@vger.kernel.org
 Subject: mmc: core: negotiate ocr during resume

 From f43005e05f1e9d93705ec6b3ab98cfa5215c1896 Mon Sep 17 00:00:00 2001
 From: Prasanna NAVARATNA prasanna.navara...@broadcom.com
 Date: Thu, 4 Apr 2013 19:55:19 +0530
 Subject: [PATCH] mmc: core: negotiate ocr during resume

 Save the card ocr into struct mmc_card when read from sd card and
 negotiate ocr mask during mmc_sd_init_card with host-ocr  card-ocr.
 ---
  drivers/mmc/core/sd.c|7 +++
  include/linux/mmc/card.h |1 +
  2 files changed, 8 insertions(+), 0 deletions(-)

 diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
 index 9e645e1..8ee27e8 100644
 --- a/drivers/mmc/core/sd.c
 +++ b/drivers/mmc/core/sd.c
 @@ -910,6 +910,10 @@ static int mmc_sd_init_card(struct mmc_host *host, u32
 ocr,
 BUG_ON(!host);
 WARN_ON(!host-claimed);

 +   /* Negotiate OCR with oldcard-ocr */
 +   if (oldcard)
 +   ocr = oldcard-ocr;
 +

I think there are several issues here:
1. with this patch the vmmc voltage should still be 3.3v after resume
back since the vmmc voltage is updated in set_ios which depend on
mmc_select_voltage. But mmc_select_voltage didn't notice your ocr
update.
2. you didn't handle the special case that the card is changed to a
new card during suspended. So the ocr may be different here.
3. mmc.c and sdio.c should also be updated besides sd.c.

I have another old version of this patch attached below for your reference:

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index aaed768..f3c7b33 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1351,6 +1351,7 @@ void mmc_power_off(struct mmc_host *host)
 * Reset ocr mask to be the highest possible voltage supported for
 * this mmc host. This value will be used at next power up.
 */
+   host-ocr_bak = host-ocr;
host-ocr = 1  (fls(host-ocr_avail) - 1);

if (!mmc_host_is_spi(host)) {
@@ -2491,7 +2492,6 @@ int mmc_resume_host(struct mmc_host *host)
if (host-bus_ops  !host-bus_dead) {
if (!mmc_card_keep_power(host)) {
mmc_power_up(host);
-   mmc_select_voltage(host, host-ocr);
/*
 * Tell runtime PM core we just powered up the card,
 * since it still believes the card is powered off.
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e6e3911..a8e81d2 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -882,7 +882,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
err = -ENOENT;
goto err;
}
-
+   /* restore ocr for the same card */
+   if (host-ocr_bak  (host-ocr_bak != host-ocr))
+   host-ocr = mmc_select_voltage(host, host-ocr_bak);
card = oldcard;
} else {
/*
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 3dafb54..2eea1ae 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -908,7 +908,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (oldcard) {
if (memcmp(cid, oldcard-raw_cid, sizeof(cid)) != 0)
return -ENOENT;
-
+   /* restore ocr for the same card */
+   if (host-ocr_bak  (host-ocr_bak != host-ocr))
+   host-ocr = mmc_select_voltage(host, host-ocr_bak);
card = oldcard;
} else {
/*
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 2273ce6..f66cc9a 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -594,6 +594,11 @@ static int mmc_sdio_init_card(struct mmc_host
*host, u32 ocr,
err = mmc_send_io_op_cond(host, host-ocr, ocr);
if (err)
goto err;
+   if (oldcard) {
+   /* restore ocr for the same card */
+   if (host-ocr_bak  (host-ocr_bak != host-ocr))
+   host-ocr = mmc_select_voltage(host,
host-ocr_bak);
+   }
}

/*
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index a90ea7b..ae5533e 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -285,6 +285,7 @@ struct mmc_host {

struct mmc_ios  ios;/* current io bus settings */
u32 ocr;/* the current OCR setting */
+   u32 ocr_bak;/* save current OCR setting */

/* group bitfields together to minimize padding */
unsigned intuse_spi_crc:1;

Thanks
Kevin


Re: [PATCH 1/3] mmc: core: Remove power_restore bus_ops for mmc and sd

2013-04-05 Thread Adrian Hunter
On 04/04/13 17:58, Ulf Hansson wrote:
 On 4 April 2013 14:00, Adrian Hunter adrian.hun...@intel.com wrote:
 On 04/04/13 14:52, Ulf Hansson wrote:
 On 4 April 2013 13:44, Adrian Hunter adrian.hun...@intel.com wrote:
 On 04/04/13 12:55, Ulf Hansson wrote:
 On 4 April 2013 10:46, Adrian Hunter adrian.hun...@intel.com wrote:
 On 01/03/13 14:47, Ulf Hansson wrote:
 From: Ulf Hansson ulf.hans...@linaro.org

 The mmc_power_restore|save_host API is only used by SDIO func drivers. 
 SDIO

 NAK - it is also used by eMMC hardware reset i.e. mmc_do_hw_reset()

 True for eMMC, but for SD card the bus_ops can go away. Thanks for
 spotting this Adrian!

 Although, I see some serious problems with the mmc_do_hw_reset
 function - it could cause eMMC data corruption.

 Issuing hw reset and doing re-initialization by using the mmc
 bus_ops-power_restore will mean no consideration is taken to cache
 ctrl, bkops and power off notify. I think it must.

 So the more proper way instead of calling power_restore, should be to
 use bus_ops-suspend and bus_ops-resume callbacks from the
 mmc_do_hw_reset function. Additionally if bus_ops-suspend is done
 successfully, we should be able to skip the actual hw reset and just
 do bus_ops-resume.

 Do you have any thoughts on this?

 Certainly the bootloader should leave the eMMC is a safe state including:
 flushing the cache or turning it off (why did it turn on?), stopping
 background operations (why did it start them?), disabling power-off
 notification CMD0? (again why it it enable it?)

 Not sure what you mean here. What has a booloader to do with this?

 When do you think hw reset is used?
 
 Two types is being used.
 
 1. At the mmc_rescan sequence. At this point mmc_do_hw_reset is _not_
 used. Instead mmc_hw_reset_for_init, which onlcy makes use of
 host-ops-hw_reset, no power_restore of course. So this has no
 issues whatsoever with this patch.
 
 2. At blk request errors, which I thought we were discussing from the
 beginning. In this case mmc_do_hw_reset is used. And it here my
 proposals doing bus_ops-suspend|resume make sense.
 
 



 Note that according to spec. CMD0 anyway clears the cache so you have lost
 your data anyway.

 What I am saying that we can try send cache ctrl and power off
 notify before we send CMD0 / do hw reset. The no data shall be lost.

 With an uninitialized bus?  Or an unresponsive card?
 
 See above.
 
 The bus is never uninitialized.
 
 The card has responded with an error, but that does not have to mean
 that it is completely unresponsive.

True.  Arguably caching should be disabled at the first sign of trouble
and never re-enabled.

However reset could attempt to flush the cache.  Then, even if the reset is
successful, an error must still be returned if the flush failed.


--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: core: Re-use code for MMC_CAP2_DETECT_ON_ERR in polling mode

2013-04-05 Thread Kevin Liu
 -Original Message-
 From: linux-mmc-ow...@vger.kernel.org 
 [mailto:linux-mmc-ow...@vger.kernel.org] On Behalf Of Ulf Hansson
 Sent: Thursday, March 28, 2013 12:12 AM
 To: linux-mmc@vger.kernel.org; Chris Ball
 Cc: Ulf Hansson
 Subject: [PATCH] mmc: core: Re-use code for MMC_CAP2_DETECT_ON_ERR in polling 
 mode

 From: Ulf Hansson ulf.hans...@linaro.org

 Previously the MMC_CAP2_DETECT_ON_ERR was invented for detecting
 slow card removal. In was never a realy good solution and a proper
 fix has been merged using gpio debouncing instead. We remove this
 cap in this patch.

 Although when using polling card detect mode, the code invented for
 MMC_CAP2_DETECT_ON_ERR is re-used to complete card removal in an
 earlier phase. There are no need waiting for the polling timeout to
 elapse in this case.

 Signed-off-by: Ulf Hansson ulf.hans...@linaro.org
 ---
  drivers/mmc/core/core.c  |5 ++---
  include/linux/mmc/host.h |1 -
  2 files changed, 2 insertions(+), 4 deletions(-)

 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
 index ad7decc..59ae194 100644
 --- a/drivers/mmc/core/core.c
 +++ b/drivers/mmc/core/core.c
 @@ -2325,14 +2325,13 @@ int mmc_detect_card_removed(struct mmc_host *host)
  * The card will be considered unchanged unless we have been asked to
  * detect a change or host requires polling to provide card detection.
  */
 -   if (!host-detect_change  !(host-caps  MMC_CAP_NEEDS_POLL) 
 -   !(host-caps2  MMC_CAP2_DETECT_ON_ERR))
 +   if (!host-detect_change  !(host-caps  MMC_CAP_NEEDS_POLL))
 return ret;

 host-detect_change = 0;
 if (!ret) {
 ret = _mmc_detect_card_removed(host);
 -   if (ret  (host-caps2  MMC_CAP2_DETECT_ON_ERR)) {
 +   if (ret  (host-caps  MMC_CAP_NEEDS_POLL)) {
 /*
  * Schedule a detect work as soon as possible to let a
  * rescan handle the card removal.
 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
 index 17d7148..301892a 100644
 --- a/include/linux/mmc/host.h
 +++ b/include/linux/mmc/host.h
 @@ -272,7 +272,6 @@ struct mmc_host {
  #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \
  MMC_CAP2_HS200_1_2V_SDR)
  #define MMC_CAP2_BROKEN_VOLTAGE(1  7)/* Use the broken 
 voltage */
 -#define MMC_CAP2_DETECT_ON_ERR (1  8)/* On I/O err check card 
 removal */
  #define MMC_CAP2_HC_ERASE_SZ   (1  9)/* High-capacity erase size */
  #define MMC_CAP2_CD_ACTIVE_HIGH(1  10)   /* Card-detect signal 
 active high */
  #define MMC_CAP2_RO_ACTIVE_HIGH(1  11)   /* Write-protect 
 signal active high */

Reviewed-by: Kevin Liu kl...@marvell.com

 --
 1.7.10

 --
 To unsubscribe from this list: send the line unsubscribe linux-mmc in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3i v6] MMC/SD: Add callback function to detect card

2013-04-05 Thread Kevin Liu
2013/4/5 Ulf Hansson ulf.hans...@linaro.org:
 On 25 March 2013 16:27, Kevin Liu keyuan@gmail.com wrote:
 2013/3/25 Ulf Hansson ulf.hans...@linaro.org:
 On 22 March 2013 16:27, Kevin Liu keyuan@gmail.com wrote:
 2013/3/22 Ulf Hansson ulf.hans...@linaro.org:
 On 22 March 2013 08:42, Huang Changming-R66093 r66...@freescale.com 
 wrote:

 r66...@freescale.com:
   Jerry,
  
   Function _mmc_detect_card_removed should only be called when card
   insert/removal or i/o error occur unless POLLING is used(called
   once per second). So it should _not_ impact performance much.
   [jerry]
   No, your understanding is wrong.
   Function _mmc_detect_card_removed  is called to check if our card
   has
  been removed when driver run the function mmc_rescan every time.
  
 
  But when will mmc_rescan be called?
  Besides boot up, only when card status change it will be called.
  So usually it should _not_ be called frequently.
  [jerry]
  For poll mode, how to know card status changed?
  The answer is mmc_rescan.
  maybe you could read the last two lines of this function ago.
 

 I mentioned this in my first response unless POLLING is used(called 
 once
 per second). I was a bit confused firstly.
 I think slot-gpio is a better solution, with which you don't need the
 every second polling.
 [jerry]
 Not all Soc has GPIO to do this. our controller has the pin to detect 
 the card status, need the external hardware to support it.
 But due to some reasons, some boards don't do this work, so need the 
 poll mode for all boards.

   POLLING is poor for performance, why not change to slot-gpio if
   host is broken for card detect.
   [jerry]
   Some our boards can't support interrupt mode to detect card
  insert/removable, so we unify the poll mode.
  
 
  Not support gpio interrupt?
  I think you only don't support sdh host interrupt.
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-mmc in
 the body of a message to majord...@vger.kernel.org More majordomo info 
 at
 http://vger.kernel.org/majordomo-info.html



 A suggestion; the poll time out is 1s today. We could make some more
 intelligent update to the timeout value so we decrease the number of
 timeouts to happen. In other words minimize the number of mmc_rescan
 to be executed.

 1. When no card is inserted, use 1 s.
 2. When card is inserted, switch to 30 s timeout. The card removal
 will be detected anyway when a blk err occurs, due to that
 mmc_detect_card_removed will be called from the block layer at error
 handling path.


 Ulf,

 Sounds good! But I have one concern:
 If the card is removed when there is no i/o access. Then the
 mmc_rescan won't run until 30 seconds later (just imagine the worst
 case). If within 30 seconds, the card is inserted again or another
 different card is inserted, then issue may occur.

 True!

 Do you think a timeout of say 10 s could be more more acceptable?


 I prefer below solution.


 Then I have a suggestion as below:
 1. keep current code as 1 second in mmc_rescan for polling.
 2. When an i/o request come, we can cancel current delay work and
 reschedule the delay detect work after 1 second from that point.
 3. If next i/o request come within 1 second, we can reschedule the
 detect work after 1 second from that point again.

 Well, I actually thought of such a solution as well, but I kind of
 dropped it because it felt a bit messy. Although, I guess you are
 right, that is probably the most proper way of doing it.

 Giving it some more thoughts, I guess we should utilize the runtime pm
 callbacks for the sd card bus_ops somehow. I pushed a skeleton
 patchset for this a while ago. If it gets merged of course.

 1.mmc_rescan could check the runtime status, if active, skip the rescan.
 2. Or, make the runtime supend callback schedule a rescan work.


 Good idea!
 Agree with either of above two. Maybe the second is better. Cancel the
 rescan work in runtime resume callback while schedule the rescan in
 runtime suspend.
 I think above should can handle normal cases.
 To handle the special case that card is removed during i/o operations,
 can remove  MMC_CAP2_DETECT_ON_ERR and use MMC_CAP_NEEDS_POLL in
 mmc_detect_card_removed when error occur as your patch did.


 So during continuous i/o operations, there will be no mmc_rescan execution.
 Once i/o operation stopped, the mmc_rescan will be called every 1 second.
 This way can solve above issue.
 How do you think?

 Thanks
 Kevin

 Any thoughts?

 Kind regards
 Ulf Hansson

 Hi Kevin,

 For reference, I have sent a patch which removes the
 MMC_CAP2_DETECT_ON_ERR and instead use MMC_CAP_NEEDS_POLL for the same
 code. I will send another patch for the second part, if the runtime PM
 patchset gets merged.


Ulf,

I noticed that patch and added my review. Thanks for the reminder.

Kevin
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

Re: [PATCH] mmc: mxs-mmc: Add support for non-removable cards

2013-04-05 Thread Shawn Guo
On Fri, Apr 05, 2013 at 01:18:38AM -0300, Alexandre Pereira da Silva wrote:
 Some boards and card slots doesn't have card detect feature available.
 In that case allow to mark the cards as non-removable, via devicetree.
 
 Signed-off-by: Alexandre Pereira da Silva aletes@gmail.com

Marc already sent a similar patch[1] for that.

Shawn

[1] http://thread.gmane.org/gmane.linux.kernel.mmc/19823/focus=19825

 ---
  drivers/mmc/host/mxs-mmc.c |6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
 index 4efe302..7d2cd74 100644
 --- a/drivers/mmc/host/mxs-mmc.c
 +++ b/drivers/mmc/host/mxs-mmc.c
 @@ -95,6 +95,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
   struct mxs_mmc_host *host = mmc_priv(mmc);
   struct mxs_ssp *ssp = host-ssp;
  
 + if (mmc-caps  MMC_CAP_NONREMOVABLE)
 + return 1;
 +
   return !(readl(ssp-base + HW_SSP_STATUS(ssp)) 
BM_SSP_STATUS_CARD_DETECT);
  }
 @@ -691,6 +694,9 @@ static int mxs_mmc_probe(struct platform_device *pdev)
   if (flags  OF_GPIO_ACTIVE_LOW)
   host-wp_inverted = 1;
  
 + if (of_find_property(np, non-removable, NULL))
 + mmc-caps |= MMC_CAP_NONREMOVABLE;
 +
   mmc-f_min = 40;
   mmc-f_max = 28800;
   mmc-ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 -- 
 1.7.10
 

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: core: restore ocr and operation voltage in resume

2013-04-05 Thread Ulf Hansson
On 5 April 2013 08:07, Prasanna NAVARATNA prasanna.navara...@gmail.com wrote:
 Ulf Hansson ulf.hansson at linaro.org writes:

 host-ocr is intended for keeping the negotiated ocr mask. Another
 variable is not needed.

 A proper patch would in principle remove the workaround, which means
 the reset of the host-ocr in mmc_power_off is not done any more.

 Exactly what you need to make this work, is as stated before a bit
 more complicated.

 Hello Ulf,

 The work around is introduced by yourself :-
 At power off, reset OCR mask to be the highest possible voltage
 supported for the current mmc host.

 This solves the re-initialization during the power up sequence.
 The voltage may have been decreased due to the card accepts a lower
 voltage than the voltage used during the initialization sequence.
 We need to reset the voltage to by the host highest possible value
 since according to _specification_ the initialization must always be
 done at high voltage

 So do you think, solution to current issue is to revert this patch? This
 will not violate the spec as you are mentioning above?

The solution is not to revert, but to make a proper patch which solves
the initialization issues and the suspend/resume issues.

If you just revert the patch you will break suspend/resume sequence
for a many SoC I believe.

 If you agree, i'll push a new patch by reverting this. Else consider another
 way in my new post mmc: core: negotiate ocr during resume
 This patch will follow the spec and will also negotiate ocr during
 mmc_resume_host.

 Thanks,
 Prasanna NAVARATNA

 --
 To unsubscribe from this list: send the line unsubscribe linux-mmc in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mmc: core: fix performance regression initializing MMC host controllers

2013-04-05 Thread Ulf Hansson
On 5 April 2013 09:26, Adrian Hunter adrian.hun...@intel.com wrote:
 On 05/04/13 00:02, Ulf Hansson wrote:
 On 4 April 2013 15:41, Adrian Hunter adrian.hun...@intel.com wrote:
 Commit fa5501890d8974301042e0202d342a6cbe8609f4 introduced a performance
 regression by adding mmc_power_up() to mmc_start_host().  mmc_power_up()
 is not necessary to host controller initialization, it is part of card
 initialization and is performed anyway asynchronously.

 This commit message is a bit miss-leading. In eMMC case, when the host
 driver has no possibility of power cycle the VCCQ power supply but
 only the VCC, this is the only proper way to prevent violation of the
 eMMC spec.

 But that is not true.  The host controller driver can manage the voltages.
 The patch is a workaround for the regulator_init_complete late initcall.

In my view, the host driver is not responsible for implementing the
mmc/sd/sdio protocol as such, that is the core layer responsibility.
Moreover I don't think you should consider this as a workaround, it is
a proper fix to make sure we follow eMMC spec.

I noticed you V2 patch, but would still like some more clear
information in there and maybe mention boot time performance instead
of just performance.

Kind regards
Ulf Hansson


 I deliberately did not paraphrase the original commit so that people who
 wanted to know would have to look at it for themselves.  I really cannot add
 things to my commit message that do not make sense to me.


From SD-card point of view, it is not needed, so this can be optimized
 to be done as before in an asynchronous mode.


 This patch allows a driver to leave the power up in asynchronous code
 (as it was before).

 On my current target platform this reduces driver initialization from:

 [1.313220] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 102008 usecs

 to this:

 [1.217209] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 8331 usecs

 Signed-off-by: Adrian Hunter adrian.hun...@intel.com
 ---
  drivers/mmc/core/core.c   | 3 ++-
  drivers/mmc/host/sdhci-acpi.c | 2 ++
  include/linux/mmc/host.h  | 1 +
  3 files changed, 5 insertions(+), 1 deletion(-)

 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
 index 3bf1c46..c1893c9 100644
 --- a/drivers/mmc/core/core.c
 +++ b/drivers/mmc/core/core.c
 @@ -2416,7 +2416,8 @@ void mmc_start_host(struct mmc_host *host)
  {
 host-f_init = max(freqs[0], host-f_min);
 host-rescan_disable = 0;
 -   mmc_power_up(host);
 +   if (!(host-caps2  MMC_CAP2_NO_PRESCAN_POWERUP))
 +   mmc_power_up(host);
 mmc_detect_change(host, 0);
  }

 diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
 index 2592ddd..7bcf74b 100644
 --- a/drivers/mmc/host/sdhci-acpi.c
 +++ b/drivers/mmc/host/sdhci-acpi.c
 @@ -195,6 +195,8 @@ static int sdhci_acpi_probe(struct platform_device 
 *pdev)
 host-mmc-pm_caps  |= c-slot-pm_caps;
 }

 +   host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
 +
 err = sdhci_add_host(host);
 if (err)
 goto err_free;
 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
 index 17d7148..8873e83 100644
 --- a/include/linux/mmc/host.h
 +++ b/include/linux/mmc/host.h
 @@ -280,6 +280,7 @@ struct mmc_host {
  #define MMC_CAP2_PACKED_WR (1  13)   /* Allow packed write */
  #define MMC_CAP2_PACKED_CMD(MMC_CAP2_PACKED_RD | \
  MMC_CAP2_PACKED_WR)
 +#define MMC_CAP2_NO_PRESCAN_POWERUP (1  14)  /* Don't power up before 
 scan */

 mmc_pm_flag_t   pm_caps;/* supported pm features */

 --
 1.7.11.7



 Some update to the commit msg, then I am happy.

 Reviewed-by: Ulf Hansson ulf.hans...@linaro.org



--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: mxs-mmc: Add support for non-removable cards

2013-04-05 Thread Mark Brown
On Fri, Apr 05, 2013 at 08:37:39AM +0200, Marek Vasut wrote:

 btw. did you know you can let git send-email automatically handle CC for you 
 so 
 you don't have to type it into the command line by simply sticking

 Cc: Us Er e...@ma.il

 in the commit message? Preferably under the SoB line.

Though not everyone likes seeing things like that end up in the commit
log (or having to edit them out of commit logs).


signature.asc
Description: Digital signature


Re: [PATCH] mmc: mxs-mmc: Add support for non-removable cards

2013-04-05 Thread Alexandre Pereira da Silva
On Fri, Apr 5, 2013 at 6:13 AM, Shawn Guo shawn@linaro.org wrote:

 Marc already sent a similar patch[1] for that.

Thanks for pointing it out.

I will work on top of that patch.

 Shawn

 [1] http://thread.gmane.org/gmane.linux.kernel.mmc/19823/focus=19825

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: mmc: mxs-mmc: add non-removeable property

2013-04-05 Thread Marc Kleine-Budde
On 04/05/2013 02:01 PM, Alexandre Pereira da Silva wrote:
 I just sent a patch to fix the same thing to the list, without seeing
 yours first.
 
 But in the discussion, I learned that I should be checking for
 broken-cd instead of non-removable.

I'm not subscribed to linux-mmc and on
http://news.gmane.org/gmane.linux.kernel.mmc I just see Marek's
Reviewed-by. Can you point me to the discussion?

In fact my board has an eMMC, which is soldered to the board and the
card detect is not connected...the documentation says:

   - broken-cd: There is no card detection available; polling must be used.
   - non-removable: non-removable slot (like eMMC); assume always present.

I see no point in using polling if the card is in deed always present.

 Would you like for me to send a separate patch for broken-cd or do you
 prefer to check on yours when you resubmit?

If your card detect is not connected and the card is removable, you
should use broken-cd and base you patch on mine.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH v2 1/2] mmc: mxs-mmc: add cd-inverted property

2013-04-05 Thread Marc Kleine-Budde
The card-detect GPIO is inverted on some boards. Handle such case.

Acked-by: Shawn Guo shawn@linaro.org
Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
---
 drivers/mmc/host/mxs-mmc.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 4efe302..0cdf1f6 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -72,6 +72,7 @@ struct mxs_mmc_host {
int sdio_irq_en;
int wp_gpio;
boolwp_inverted;
+   boolcd_inverted;
 };
 
 static int mxs_mmc_get_ro(struct mmc_host *mmc)
@@ -96,7 +97,7 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_ssp *ssp = host-ssp;
 
return !(readl(ssp-base + HW_SSP_STATUS(ssp)) 
-BM_SSP_STATUS_CARD_DETECT);
+BM_SSP_STATUS_CARD_DETECT)) ^ host-cd_inverted;
 }
 
 static void mxs_mmc_reset(struct mxs_mmc_host *host)
@@ -691,6 +692,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
if (flags  OF_GPIO_ACTIVE_LOW)
host-wp_inverted = 1;
 
+   host-cd_inverted = of_property_read_bool(np, cd-inverted);
+
mmc-f_min = 40;
mmc-f_max = 28800;
mmc-ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] mmc: mxs-mmc: add cd-inverted and non-removeable

2013-04-05 Thread Marc Kleine-Budde
Hello,

this patch add support for the cd-inverted and non-removeable property (as
defined in devicetree/bindings/mmc/mmc.txt) to the mxs-mmc driver. Tested on a
custom imx28 board.

This series applies to Chris Ball's cjb/mmc-next branch.

Changes since v1:
- add Shawn's Acked-by
- fixed typo in [PATCH 2/2] mmc: mxs-mmc: add non-removeable property
  (tnx Chris)

regards,
Marc Kleine-Budde

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] mmc: mxs-mmc: add non-removable property

2013-04-05 Thread Marc Kleine-Budde
Some boards have non removable cards like eMMC. Handle such case.

Acked-by: Shawn Guo shawn@linaro.org
Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
---
changes since v1:
- fix removeable typo

 drivers/mmc/host/mxs-mmc.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 0cdf1f6..c231881 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -73,6 +73,7 @@ struct mxs_mmc_host {
int wp_gpio;
boolwp_inverted;
boolcd_inverted;
+   boolnon_removable;
 };
 
 static int mxs_mmc_get_ro(struct mmc_host *mmc)
@@ -96,8 +97,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_mmc_host *host = mmc_priv(mmc);
struct mxs_ssp *ssp = host-ssp;
 
-   return !(readl(ssp-base + HW_SSP_STATUS(ssp)) 
-BM_SSP_STATUS_CARD_DETECT)) ^ host-cd_inverted;
+   return host-non_removable ||
+   !(readl(ssp-base + HW_SSP_STATUS(ssp)) 
+ BM_SSP_STATUS_CARD_DETECT) ^ host-cd_inverted;
 }
 
 static void mxs_mmc_reset(struct mxs_mmc_host *host)
@@ -687,8 +689,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc-caps |= MMC_CAP_4_BIT_DATA;
else if (bus_width == 8)
mmc-caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
+   host-non_removable = of_property_read_bool(np, non-removable);
+   if (host-non_removable)
+   mmc-caps |= MMC_CAP_NONREMOVABLE;
host-wp_gpio = of_get_named_gpio_flags(np, wp-gpios, 0, flags);
-
if (flags  OF_GPIO_ACTIVE_LOW)
host-wp_inverted = 1;
 
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: mmc: mxs-mmc: add non-removeable property

2013-04-05 Thread Marc Kleine-Budde
On 04/05/2013 02:31 PM, Alexandre Pereira da Silva wrote:
 On Fri, Apr 5, 2013 at 9:14 AM, Marc Kleine-Budde m...@pengutronix.de
 wrote:
 I'm not subscribed to linux-mmc and on
 http://news.gmane.org/gmane.linux.kernel.mmc I just see Marek's
 Reviewed-by. Can you point me to the discussion?
 
 http://marc.info/?l=linux-kernelm=136515344220293w=2

tnx

 If your card detect is not connected and the card is removable, you
 should use broken-cd and base you patch on mine.
 
 Ok, I will do that.

I've just posted an updated series.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3 0/2] omap_hsmmc DT DMA Client support

2013-04-05 Thread Balaji T K

On Wednesday 06 March 2013 07:42 PM, Matt Porter wrote:

Changes since v2:
- dropped skip platform_get_resource_byname() patch
Changes since v1:
- rebase to 3.9-rc1, previous dependencies upstream

This series adds DT DMA Engine Client support to the omap_hsmmc.
It leverages the generic DMA OF helpers and the
dma_request_slave_channel_compat() wrapper to support DMA in
omap_hsmmc on platforms booting via DT. These platforms include
omap2/3/4/5 and am33xx.

These patches were split out from the v5 version of the AM33XX DMA
series and split from the EDMA-specific omap_hsmmc changes.

Matt Porter (2):
   mmc: omap_hsmmc: convert to dma_request_slave_channel_compat()
   mmc: omap_hsmmc: add generic DMA request support to the DT binding



Looks good to me
Acked-by: Balaji T K balaj...@ti.com


  .../devicetree/bindings/mmc/ti-omap-hsmmc.txt  |   26 +++-
  drivers/mmc/host/omap_hsmmc.c  |   10 ++--
  2 files changed, 33 insertions(+), 3 deletions(-)



--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mmc: core: fix performance regression initializing MMC host controllers

2013-04-05 Thread Adrian Hunter
On 05/04/13 12:49, Ulf Hansson wrote:
 On 5 April 2013 09:26, Adrian Hunter adrian.hun...@intel.com wrote:
 On 05/04/13 00:02, Ulf Hansson wrote:
 On 4 April 2013 15:41, Adrian Hunter adrian.hun...@intel.com wrote:
 Commit fa5501890d8974301042e0202d342a6cbe8609f4 introduced a performance
 regression by adding mmc_power_up() to mmc_start_host().  mmc_power_up()
 is not necessary to host controller initialization, it is part of card
 initialization and is performed anyway asynchronously.

 This commit message is a bit miss-leading. In eMMC case, when the host
 driver has no possibility of power cycle the VCCQ power supply but
 only the VCC, this is the only proper way to prevent violation of the
 eMMC spec.

 But that is not true.  The host controller driver can manage the voltages.
 The patch is a workaround for the regulator_init_complete late initcall.
 
 In my view, the host driver is not responsible for implementing the
 mmc/sd/sdio protocol as such, that is the core layer responsibility.

Having VCC always on is not part of the MMC protocol.  For example, you
can't look up EXT_CSD and find out if VCC is always on.  Consequently,
the core does not support it.  If a platform requires it, it should be
added as a new feature and flagged as such, not introduced as a fix.

 Moreover I don't think you should consider this as a workaround, it is
 a proper fix to make sure we follow eMMC spec.

It won't work if the host controller driver is loaded as a module.

Also it causes attempts to initialize cards without first powering off
thereby ensuring they are in a known state.

 
 I noticed you V2 patch, but would still like some more clear
 information in there and maybe mention boot time performance instead
 of just performance.



 
 Kind regards
 Ulf Hansson
 

 I deliberately did not paraphrase the original commit so that people who
 wanted to know would have to look at it for themselves.  I really cannot add
 things to my commit message that do not make sense to me.


 From SD-card point of view, it is not needed, so this can be optimized
 to be done as before in an asynchronous mode.


 This patch allows a driver to leave the power up in asynchronous code
 (as it was before).

 On my current target platform this reduces driver initialization from:

 [1.313220] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 102008 usecs

 to this:

 [1.217209] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 
 8331 usecs

 Signed-off-by: Adrian Hunter adrian.hun...@intel.com
 ---
  drivers/mmc/core/core.c   | 3 ++-
  drivers/mmc/host/sdhci-acpi.c | 2 ++
  include/linux/mmc/host.h  | 1 +
  3 files changed, 5 insertions(+), 1 deletion(-)

 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
 index 3bf1c46..c1893c9 100644
 --- a/drivers/mmc/core/core.c
 +++ b/drivers/mmc/core/core.c
 @@ -2416,7 +2416,8 @@ void mmc_start_host(struct mmc_host *host)
  {
 host-f_init = max(freqs[0], host-f_min);
 host-rescan_disable = 0;
 -   mmc_power_up(host);
 +   if (!(host-caps2  MMC_CAP2_NO_PRESCAN_POWERUP))
 +   mmc_power_up(host);
 mmc_detect_change(host, 0);
  }

 diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
 index 2592ddd..7bcf74b 100644
 --- a/drivers/mmc/host/sdhci-acpi.c
 +++ b/drivers/mmc/host/sdhci-acpi.c
 @@ -195,6 +195,8 @@ static int sdhci_acpi_probe(struct platform_device 
 *pdev)
 host-mmc-pm_caps  |= c-slot-pm_caps;
 }

 +   host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
 +
 err = sdhci_add_host(host);
 if (err)
 goto err_free;
 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
 index 17d7148..8873e83 100644
 --- a/include/linux/mmc/host.h
 +++ b/include/linux/mmc/host.h
 @@ -280,6 +280,7 @@ struct mmc_host {
  #define MMC_CAP2_PACKED_WR (1  13)   /* Allow packed write */
  #define MMC_CAP2_PACKED_CMD(MMC_CAP2_PACKED_RD | \
  MMC_CAP2_PACKED_WR)
 +#define MMC_CAP2_NO_PRESCAN_POWERUP (1  14)  /* Don't power up before 
 scan */

 mmc_pm_flag_t   pm_caps;/* supported pm features */

 --
 1.7.11.7



 Some update to the commit msg, then I am happy.

 Reviewed-by: Ulf Hansson ulf.hans...@linaro.org



 
 

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 2/2] mmc: core: fix performance regression initializing MMC host controllers

2013-04-05 Thread Adrian Hunter
Commit fa5501890d8974301042e0202d342a6cbe8609f4 introduced a boot time
performance regression by adding mmc_power_up() to mmc_start_host().
mmc_power_up() is not necessary to host controller initialization, it is
part of card initialization and is performed anyway asynchronously.
Please see the original commit for an explanation of the use of
mmc_power_up() in mmc_start_host().

This patch allows a driver to leave the power up in asynchronous code
(as it was before).

On my current target platform this reduces driver initialization from:

[1.313220] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 102008 
usecs

to this:

[1.217209] initcall sdhci_acpi_driver_init+0x0/0x12 returned 0 after 8331 
usecs

Signed-off-by: Adrian Hunter adrian.hun...@intel.com
---
 drivers/mmc/core/core.c   | 3 ++-
 drivers/mmc/host/sdhci-acpi.c | 2 ++
 include/linux/mmc/host.h  | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 3bf1c46..c1893c9 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2416,7 +2416,8 @@ void mmc_start_host(struct mmc_host *host)
 {
host-f_init = max(freqs[0], host-f_min);
host-rescan_disable = 0;
-   mmc_power_up(host);
+   if (!(host-caps2  MMC_CAP2_NO_PRESCAN_POWERUP))
+   mmc_power_up(host);
mmc_detect_change(host, 0);
 }
 
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 2592ddd..7bcf74b 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -195,6 +195,8 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
host-mmc-pm_caps  |= c-slot-pm_caps;
}
 
+   host-mmc-caps2 |= MMC_CAP2_NO_PRESCAN_POWERUP;
+
err = sdhci_add_host(host);
if (err)
goto err_free;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 17d7148..8873e83 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -280,6 +280,7 @@ struct mmc_host {
 #define MMC_CAP2_PACKED_WR (1  13)   /* Allow packed write */
 #define MMC_CAP2_PACKED_CMD(MMC_CAP2_PACKED_RD | \
 MMC_CAP2_PACKED_WR)
+#define MMC_CAP2_NO_PRESCAN_POWERUP (1  14)  /* Don't power up before scan */
 
mmc_pm_flag_t   pm_caps;/* supported pm features */
 
-- 
1.7.11.7
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] mmc: dw_mmc: let device core setup the default pin configuration

2013-04-05 Thread Thomas Abraham
With device core now able to setup the default pin configuration,
the pin configuration code based on the deprecated Samsung specific
gpio bindings is removed.

Signed-off-by: Thomas Abraham thomas.abra...@linaro.org
---
Changes since v2:
- Changed patch subject from mmc: dwmmc: let... to mmc: dw_mmc: let...
- Rebased to Chris's latest mmc-next branch.

 drivers/mmc/host/dw_mmc-exynos.c |   38 --
 drivers/mmc/host/dw_mmc.c|   12 ++--
 drivers/mmc/host/dw_mmc.h|3 ---
 3 files changed, 2 insertions(+), 51 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index c7f0976..f013e7e 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -152,43 +152,6 @@ static int dw_mci_exynos_parse_dt(struct dw_mci *host)
return 0;
 }
 
-static int dw_mci_exynos_setup_bus(struct dw_mci *host,
-   struct device_node *slot_np, u8 bus_width)
-{
-   int idx, gpio, ret;
-
-   if (!slot_np)
-   return -EINVAL;
-
-   /* cmd + clock + bus-width pins */
-   for (idx = 0; idx  NUM_PINS(bus_width); idx++) {
-   gpio = of_get_gpio(slot_np, idx);
-   if (!gpio_is_valid(gpio)) {
-   dev_err(host-dev, invalid gpio: %d\n, gpio);
-   return -EINVAL;
-   }
-
-   ret = devm_gpio_request(host-dev, gpio, dw-mci-bus);
-   if (ret) {
-   dev_err(host-dev, gpio [%d] request failed\n, gpio);
-   return -EBUSY;
-   }
-   }
-
-   if (host-pdata-quirks  DW_MCI_QUIRK_BROKEN_CARD_DETECTION)
-   return 0;
-
-   gpio = of_get_named_gpio(slot_np, samsung,cd-pinmux-gpio, 0);
-   if (gpio_is_valid(gpio)) {
-   if (devm_gpio_request(host-dev, gpio, dw-mci-cd))
-   dev_err(host-dev, gpio [%d] request failed\n, gpio);
-   } else {
-   dev_info(host-dev, cd gpio not available);
-   }
-
-   return 0;
-}
-
 /* Common capabilities of Exynos4/Exynos5 SoC */
 static unsigned long exynos_dwmmc_caps[4] = {
MMC_CAP_UHS_DDR50 | MMC_CAP_1_8V_DDR |
@@ -205,7 +168,6 @@ static const struct dw_mci_drv_data exynos_drv_data = {
.prepare_command= dw_mci_exynos_prepare_command,
.set_ios= dw_mci_exynos_set_ios,
.parse_dt   = dw_mci_exynos_parse_dt,
-   .setup_bus  = dw_mci_exynos_setup_bus,
 };
 
 static const struct of_device_id dw_mci_exynos_match[] = {
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index a443820..2ed9989 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1945,14 +1945,6 @@ static int dw_mci_init_slot(struct dw_mci *host, 
unsigned int id)
else
bus_width = 1;
 
-   if (drv_data  drv_data-setup_bus) {
-   struct device_node *slot_np;
-   slot_np = dw_mci_of_find_slot_node(host-dev, slot-id);
-   ret = drv_data-setup_bus(host, slot_np, bus_width);
-   if (ret)
-   goto err_setup_bus;
-   }
-
switch (bus_width) {
case 8:
mmc-caps |= MMC_CAP_8_BIT_DATA;
@@ -2002,7 +1994,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned 
int id)
 
ret = mmc_add_host(mmc);
if (ret)
-   goto err_setup_bus;
+   goto err_add_host;
 
 #if defined(CONFIG_DEBUG_FS)
dw_mci_init_debugfs(slot);
@@ -2019,7 +2011,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned 
int id)
 
return 0;
 
-err_setup_bus:
+err_add_host:
mmc_free_host(mmc);
return -EINVAL;
 }
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 53b8fd9..0b74189 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -190,7 +190,6 @@ extern int dw_mci_resume(struct dw_mci *host);
  * @prepare_command: handle CMD register extensions.
  * @set_ios: handle bus specific extensions.
  * @parse_dt: parse implementation specific device tree properties.
- * @setup_bus: initialize io-interface
  *
  * Provide controller implementation specific extensions. The usage of this
  * data structure is fully optional and usage of each member in this structure
@@ -203,7 +202,5 @@ struct dw_mci_drv_data {
void(*prepare_command)(struct dw_mci *host, u32 *cmdr);
void(*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
int (*parse_dt)(struct dw_mci *host);
-   int (*setup_bus)(struct dw_mci *host,
-   struct device_node *slot_np, u8 bus_width);
 };
 #endif /* _DW_MMC_H_ */
-- 
1.6.6.rc2

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

Re: [PATCH] mmc: mxs-mmc: Add support for non-removable cards

2013-04-05 Thread Marek Vasut
Dear Mark Brown,

 On Fri, Apr 05, 2013 at 08:37:39AM +0200, Marek Vasut wrote:
  btw. did you know you can let git send-email automatically handle CC for
  you so you don't have to type it into the command line by simply
  sticking
  
  Cc: Us Er e...@ma.il
  
  in the commit message? Preferably under the SoB line.
 
 Though not everyone likes seeing things like that end up in the commit
 log (or having to edit them out of commit logs).

Ah, all right.

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 1/2] mmc: core: Add bus_ops for runtime pm callbacks

2013-04-05 Thread merez

 From: Ulf Hansson ulf.hans...@linaro.org

 SDIO is the only protocol that uses runtime pm for the card device
 right now. To provide the option for sd and mmc to use runtime pm as
 well the bus_ops callback are extended with two new functions. One for
 runtime_suspend and one for runtime_resume.

 This patch will also implement the callbacks for SDIO to make sure
 existing functionallity is maintained.
functionality

 Signed-off-by: Ulf Hansson ulf.hans...@linaro.org
 Acked-by: Maya Erez me...@codeaurora.org
 Acked-by: Arnd Bergmann a...@arndb.de
 Acked-by: Kevin Liu kl...@marvell.com
 ---
  drivers/mmc/core/bus.c  |   14 --
  drivers/mmc/core/core.h |2 ++
  drivers/mmc/core/sdio.c |   20 
  3 files changed, 34 insertions(+), 2 deletions(-)

 diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
 index e219c97..d9e8c2b 100644
 --- a/drivers/mmc/core/bus.c
 +++ b/drivers/mmc/core/bus.c
 @@ -151,15 +151,25 @@ static int mmc_bus_resume(struct device *dev)
  static int mmc_runtime_suspend(struct device *dev)
  {
   struct mmc_card *card = mmc_dev_to_card(dev);
 + struct mmc_host *host = card-host;
 + int ret = 0;
 +
 + if (host-bus_ops-runtime_suspend)
 + ret = host-bus_ops-runtime_suspend(host);

 - return mmc_power_save_host(card-host);
 + return ret;
  }

  static int mmc_runtime_resume(struct device *dev)
  {
   struct mmc_card *card = mmc_dev_to_card(dev);
 + struct mmc_host *host = card-host;
 + int ret = 0;
 +
 + if (host-bus_ops-runtime_resume)
 + ret = host-bus_ops-runtime_resume(host);

 - return mmc_power_restore_host(card-host);
 + return ret;
  }

  static int mmc_runtime_idle(struct device *dev)
 diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
 index b9f18a2..9445519 100644
 --- a/drivers/mmc/core/core.h
 +++ b/drivers/mmc/core/core.h
 @@ -22,6 +22,8 @@ struct mmc_bus_ops {
   void (*detect)(struct mmc_host *);
   int (*suspend)(struct mmc_host *);
   int (*resume)(struct mmc_host *);
 + int (*runtime_suspend)(struct mmc_host *);
 + int (*runtime_resume)(struct mmc_host *);
   int (*power_save)(struct mmc_host *);
   int (*power_restore)(struct mmc_host *);
   int (*alive)(struct mmc_host *);
 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
 index aa0719a..0e6e8c1 100644
 --- a/drivers/mmc/core/sdio.c
 +++ b/drivers/mmc/core/sdio.c
 @@ -988,6 +988,24 @@ static int mmc_sdio_resume(struct mmc_host *host)
   return err;
  }

 +static int mmc_sdio_runtime_suspend(struct mmc_host *host)
 +{
 + /*
 +  * Once sdio clients has entirely switched to runtime pm we wrap
 +  * the call to power_save here.
 +  */
 + return mmc_power_save_host(host);
 +}
 +
 +static int mmc_sdio_runtime_resume(struct mmc_host *host)
 +{
 + /*
 +  * Once sdio clients has entirely switched to runtime pm we wrap
 +  * the call to power_restore here.
 +  */
 + return mmc_power_restore_host(host);
 +}
 +
  static int mmc_sdio_power_restore(struct mmc_host *host)
  {
   int ret;
 @@ -1054,6 +1072,8 @@ static const struct mmc_bus_ops mmc_sdio_ops = {
   .detect = mmc_sdio_detect,
   .suspend = mmc_sdio_suspend,
   .resume = mmc_sdio_resume,
 + .runtime_suspend = mmc_sdio_runtime_suspend,
 + .runtime_resume = mmc_sdio_runtime_resume,
   .power_restore = mmc_sdio_power_restore,
   .alive = mmc_sdio_alive,
  };
 --
 1.7.10

 --
 To unsubscribe from this list: send the line unsubscribe linux-mmc in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Maya Erez
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 2/2] mmc: block: Enable runtime pm for mmc blkdevice

2013-04-05 Thread merez

 From: Ulf Hansson ulf.hans...@linaro.org

 Once the mmc blkdevice is being probed, runtime pm will be enabled.
 By using runtime autosuspend, the power save operations can be done
 when request inactivity occurs for a certain time. Right now the
 selected timeout value is set to 3 s.

 Moreover, when the blk device is being suspended, we make sure the device
 will be runtime resumed. The reason for doing this is that we what the
 host suspend sequence to be unaware of any runtime power save operations,
 so it can just handle the suspend as the device is fully powerered from a
powered
 runtime perspective.

 This patch is preparing to make it possible to move BKOPS handling into
 the runtime callbacks for the mmc bus_ops. Thus IDLE BKOPS can be
 accomplished.

 Signed-off-by: Ulf Hansson ulf.hans...@linaro.org
 Acked-by: Maya Erez me...@codeaurora.org
 Acked-by: Arnd Bergmann a...@arndb.de
 Acked-by: Kevin Liu kl...@marvell.com
 ---
  drivers/mmc/card/block.c |   28 ++--
  1 file changed, 26 insertions(+), 2 deletions(-)

 diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
 index e12a03c..536331a 100644
 --- a/drivers/mmc/card/block.c
 +++ b/drivers/mmc/card/block.c
 @@ -34,6 +34,7 @@
  #include linux/delay.h
  #include linux/capability.h
  #include linux/compat.h
 +#include linux/pm_runtime.h

  #include linux/mmc/ioctl.h
  #include linux/mmc/card.h
 @@ -222,6 +223,7 @@ static ssize_t power_ro_lock_store(struct device *dev,
   md = mmc_blk_get(dev_to_disk(dev));
   card = md-queue.card;

 + pm_runtime_get_sync(card-dev);
   mmc_claim_host(card-host);

   ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
 @@ -234,6 +236,8 @@ static ssize_t power_ro_lock_store(struct device *dev,
   card-ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN;

   mmc_release_host(card-host);
 + pm_runtime_mark_last_busy(card-dev);
 + pm_runtime_put_autosuspend(card-dev);

   if (!ret) {
   pr_info(%s: Locking boot partition ro until next power on\n,
 @@ -492,6 +496,7 @@ static int mmc_blk_ioctl_cmd(struct block_device
 *bdev,

   mrq.cmd = cmd;

 + pm_runtime_get_sync(card-dev);
   mmc_claim_host(card-host);

   err = mmc_blk_part_switch(card, md);
 @@ -560,6 +565,8 @@ static int mmc_blk_ioctl_cmd(struct block_device
 *bdev,

  cmd_rel_host:
   mmc_release_host(card-host);
 + pm_runtime_mark_last_busy(card-dev);
 + pm_runtime_put_autosuspend(card-dev);

  cmd_done:
   mmc_blk_put(md);
 @@ -1894,9 +1901,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq,
 struct request *req)
   struct mmc_host *host = card-host;
   unsigned long flags;

 - if (req  !mq-mqrq_prev-req)
 + if (req  !mq-mqrq_prev-req) {
 + pm_runtime_get_sync(card-dev);
   /* claim host only for the first request */
   mmc_claim_host(card-host);
 + }

   ret = mmc_blk_part_switch(card, md);
   if (ret) {
 @@ -1933,7 +1942,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq,
 struct request *req)

  out:
   if ((!req  !(mq-flags  MMC_QUEUE_NEW_REQUEST)) ||
 -  (req  (req-cmd_flags  MMC_REQ_SPECIAL_MASK)))
 +  (req  (req-cmd_flags  MMC_REQ_SPECIAL_MASK))) {
   /*
* Release host when there are no more requests
* and after special request(discard, flush) is done.
 @@ -1941,6 +1950,10 @@ out:
* the 'mmc_blk_issue_rq' with 'mqrq_prev-req'.
*/
   mmc_release_host(card-host);
 + pm_runtime_mark_last_busy(card-dev);
 + pm_runtime_put_autosuspend(card-dev);
 + }
 +
   return ret;
  }

 @@ -2337,6 +2350,12 @@ static int mmc_blk_probe(struct mmc_card *card)
   if (mmc_add_disk(part_md))
   goto out;
   }
 +
 + pm_runtime_set_active(card-dev);
 + pm_runtime_set_autosuspend_delay(card-dev, 3000);
 + pm_runtime_use_autosuspend(card-dev);
 + pm_runtime_enable(card-dev);
 +
   return 0;

   out:
 @@ -2350,9 +2369,12 @@ static void mmc_blk_remove(struct mmc_card *card)
   struct mmc_blk_data *md = mmc_get_drvdata(card);

   mmc_blk_remove_parts(card, md);
 + pm_runtime_get_sync(card-dev);
   mmc_claim_host(card-host);
   mmc_blk_part_switch(card, md);
   mmc_release_host(card-host);
 + pm_runtime_disable(card-dev);
 + pm_runtime_put_noidle(card-dev);
   mmc_blk_remove_req(md);
   mmc_set_drvdata(card, NULL);
  }
 @@ -2364,6 +2386,7 @@ static int mmc_blk_suspend(struct mmc_card *card)
   struct mmc_blk_data *md = mmc_get_drvdata(card);

   if (md) {
 + pm_runtime_get_sync(card-dev);
   mmc_queue_suspend(md-queue);
   list_for_each_entry(part_md, md-part, part) {
   mmc_queue_suspend(part_md-queue);
 @@ -2387,6 +2410,7 @@ static int mmc_blk_resume(struct mmc_card *card)