All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  3:28 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  3:28 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Matthias Brugger, Adrian Hunter, Johan Rudholm, Gwendal Grignou,
	linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek,
	srv_heupstream, Sascha Hauer, Chaotian Jing

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, that results in card init
was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
re-init card.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
---
 drivers/mmc/core/mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..f2d0c2a 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
 
 	/* Set initial state and call mmc_set_ios */
 	mmc_set_initial_state(host);
+	mmc_set_clock(host, host->f_init);
 	mmc_host_clk_release(host);
 
 	return mmc_init_card(host, card->ocr, card);
-- 
1.8.1.1.dirty


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  3:28 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  3:28 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Matthias Brugger, Adrian Hunter, Johan Rudholm, Gwendal Grignou,
	linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek,
	srv_heupstream, Sascha Hauer, Chaotian Jing

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, that results in card init
was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
re-init card.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
---
 drivers/mmc/core/mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..f2d0c2a 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
 
 	/* Set initial state and call mmc_set_ios */
 	mmc_set_initial_state(host);
+	mmc_set_clock(host, host->f_init);
 	mmc_host_clk_release(host);
 
 	return mmc_init_card(host, card->ocr, card);
-- 
1.8.1.1.dirty


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  3:28 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  3:28 UTC (permalink / raw)
  To: linux-arm-kernel

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, that results in card init
was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
re-init card.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
---
 drivers/mmc/core/mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..f2d0c2a 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
 
 	/* Set initial state and call mmc_set_ios */
 	mmc_set_initial_state(host);
+	mmc_set_clock(host, host->f_init);
 	mmc_host_clk_release(host);
 
 	return mmc_init_card(host, card->ocr, card);
-- 
1.8.1.1.dirty

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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
  2015-09-30  3:28 ` Chaotian Jing
@ 2015-09-30  8:24   ` Adrian Hunter
  -1 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2015-09-30  8:24 UTC (permalink / raw)
  To: Chaotian Jing, Ulf Hansson
  Cc: Matthias Brugger, Johan Rudholm, Gwendal Grignou, linux-mmc,
	linux-kernel, linux-arm-kernel, linux-mediatek, srv_heupstream,
	Sascha Hauer

On 30/09/15 06:28, Chaotian Jing wrote:
> Suppose that we got a data crc error, and it triggers the mmc_reset.
> mmc_reset will call mmc_send_status to see if HW reset was supported.
> before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
> it will reduce frequency to 52Mhz firstly, that results in card init
> was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
> re-init card.

The call to mmc_send_status() was originally only done for mmc_test and
doesn't belong in a real reset.  However the test parameter was removed
to simplify the code by:

commit 83533ab28380f6957af39a7b322e639e42dbdaf1
Author: Johan Rudholm <johan.rudholm@axis.com>
Date:   Mon Jan 12 15:38:04 2015 +0100

    mmc: core: always check status after reset
    
    Always check if the card is alive after a successful reset. This allows
    us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
    card reset interface.
    
    Signed-off-by: Johan Rudholm <johanru@axis.com>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

IMHO having a test to check whether hw reset actually did reset the card
is useful, so I would suggest putting back mmc_hw_reset_check() and
removing the check from the non-test path.

An alternative is to recognize that we don't want retuning here, and it is
unlikely to be needed in the mmc_test case.  So if retuning is needed, just
skip the call to mmc_send_status() i.e.

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f2d0c2ae85b1..c3749ba42739 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}

Could then make mmc_test aware of that:

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b78cf5d403a3..7b105b97be78 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
 	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
 		return RESULT_UNSUP_CARD;
 
+	err = mmc_send_status(card, NULL);
+	if (err)
+		return err;
+
+	if (host->need_retune) {
+		pr_info("%s: cannot test hw reset because retune needed\n",
+			mmc_hostname(test->card->host));
+		return RESULT_FAIL;
+	}
+
 	err = mmc_hw_reset(host);
 	if (!err)
 		return RESULT_OK;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f2d0c2ae85b1..c3749ba42739 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}




> 
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> ---
>  drivers/mmc/core/mmc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index e726903..f2d0c2a 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
>  
>  	/* Set initial state and call mmc_set_ios */
>  	mmc_set_initial_state(host);
> +	mmc_set_clock(host, host->f_init);
>  	mmc_host_clk_release(host);
>  
>  	return mmc_init_card(host, card->ocr, card);
> 


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  8:24   ` Adrian Hunter
  0 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2015-09-30  8:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/09/15 06:28, Chaotian Jing wrote:
> Suppose that we got a data crc error, and it triggers the mmc_reset.
> mmc_reset will call mmc_send_status to see if HW reset was supported.
> before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
> it will reduce frequency to 52Mhz firstly, that results in card init
> was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
> re-init card.

The call to mmc_send_status() was originally only done for mmc_test and
doesn't belong in a real reset.  However the test parameter was removed
to simplify the code by:

commit 83533ab28380f6957af39a7b322e639e42dbdaf1
Author: Johan Rudholm <johan.rudholm@axis.com>
Date:   Mon Jan 12 15:38:04 2015 +0100

    mmc: core: always check status after reset
    
    Always check if the card is alive after a successful reset. This allows
    us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
    card reset interface.
    
    Signed-off-by: Johan Rudholm <johanru@axis.com>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

IMHO having a test to check whether hw reset actually did reset the card
is useful, so I would suggest putting back mmc_hw_reset_check() and
removing the check from the non-test path.

An alternative is to recognize that we don't want retuning here, and it is
unlikely to be needed in the mmc_test case.  So if retuning is needed, just
skip the call to mmc_send_status() i.e.

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f2d0c2ae85b1..c3749ba42739 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}

Could then make mmc_test aware of that:

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b78cf5d403a3..7b105b97be78 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
 	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
 		return RESULT_UNSUP_CARD;
 
+	err = mmc_send_status(card, NULL);
+	if (err)
+		return err;
+
+	if (host->need_retune) {
+		pr_info("%s: cannot test hw reset because retune needed\n",
+			mmc_hostname(test->card->host));
+		return RESULT_FAIL;
+	}
+
 	err = mmc_hw_reset(host);
 	if (!err)
 		return RESULT_OK;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f2d0c2ae85b1..c3749ba42739 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}




> 
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> ---
>  drivers/mmc/core/mmc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index e726903..f2d0c2a 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
>  
>  	/* Set initial state and call mmc_set_ios */
>  	mmc_set_initial_state(host);
> +	mmc_set_clock(host, host->f_init);
>  	mmc_host_clk_release(host);
>  
>  	return mmc_init_card(host, card->ocr, card);
> 

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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
  2015-09-30  8:24   ` Adrian Hunter
  (?)
@ 2015-09-30  9:03     ` Chaotian Jing
  -1 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  9:03 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, Matthias Brugger, Johan Rudholm, Gwendal Grignou,
	linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek,
	srv_heupstream, Sascha Hauer

On Wed, 2015-09-30 at 11:24 +0300, Adrian Hunter wrote:
> On 30/09/15 06:28, Chaotian Jing wrote:
> > Suppose that we got a data crc error, and it triggers the mmc_reset.
> > mmc_reset will call mmc_send_status to see if HW reset was supported.
> > before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
> > it will reduce frequency to 52Mhz firstly, that results in card init
> > was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
> > re-init card.
> 
> The call to mmc_send_status() was originally only done for mmc_test and
> doesn't belong in a real reset.  However the test parameter was removed
> to simplify the code by:
> 
> commit 83533ab28380f6957af39a7b322e639e42dbdaf1
> Author: Johan Rudholm <johan.rudholm@axis.com>
> Date:   Mon Jan 12 15:38:04 2015 +0100
> 
>     mmc: core: always check status after reset
>     
>     Always check if the card is alive after a successful reset. This allows
>     us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
>     card reset interface.
>     
>     Signed-off-by: Johan Rudholm <johanru@axis.com>
>     Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> IMHO having a test to check whether hw reset actually did reset the card
> is useful, so I would suggest putting back mmc_hw_reset_check() and
> removing the check from the non-test path.
> 
> An alternative is to recognize that we don't want retuning here, and it is
> unlikely to be needed in the mmc_test case.  So if retuning is needed, just
> skip the call to mmc_send_status() i.e.
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> Could then make mmc_test aware of that:
>  

> This solution is better, please help to upstream it. Thx!
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index b78cf5d403a3..7b105b97be78 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
>  	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
>  		return RESULT_UNSUP_CARD;
>  
> +	err = mmc_send_status(card, NULL);
> +	if (err)
> +		return err;
> +
> +	if (host->need_retune) {
> +		pr_info("%s: cannot test hw reset because retune needed\n",
> +			mmc_hostname(test->card->host));
> +		return RESULT_FAIL;
> +	}
> +
>  	err = mmc_hw_reset(host);
>  	if (!err)
>  		return RESULT_OK;
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> 
> 
> 
> > 
> > Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> > ---
> >  drivers/mmc/core/mmc.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index e726903..f2d0c2a 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
> >  
> >  	/* Set initial state and call mmc_set_ios */
> >  	mmc_set_initial_state(host);
> > +	mmc_set_clock(host, host->f_init);
> >  	mmc_host_clk_release(host);
> >  
> >  	return mmc_init_card(host, card->ocr, card);
> > 
> 



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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  9:03     ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  9:03 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, Matthias Brugger, Johan Rudholm, Gwendal Grignou,
	linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek,
	srv_heupstream, Sascha Hauer

On Wed, 2015-09-30 at 11:24 +0300, Adrian Hunter wrote:
> On 30/09/15 06:28, Chaotian Jing wrote:
> > Suppose that we got a data crc error, and it triggers the mmc_reset.
> > mmc_reset will call mmc_send_status to see if HW reset was supported.
> > before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
> > it will reduce frequency to 52Mhz firstly, that results in card init
> > was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
> > re-init card.
> 
> The call to mmc_send_status() was originally only done for mmc_test and
> doesn't belong in a real reset.  However the test parameter was removed
> to simplify the code by:
> 
> commit 83533ab28380f6957af39a7b322e639e42dbdaf1
> Author: Johan Rudholm <johan.rudholm@axis.com>
> Date:   Mon Jan 12 15:38:04 2015 +0100
> 
>     mmc: core: always check status after reset
>     
>     Always check if the card is alive after a successful reset. This allows
>     us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
>     card reset interface.
>     
>     Signed-off-by: Johan Rudholm <johanru@axis.com>
>     Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> IMHO having a test to check whether hw reset actually did reset the card
> is useful, so I would suggest putting back mmc_hw_reset_check() and
> removing the check from the non-test path.
> 
> An alternative is to recognize that we don't want retuning here, and it is
> unlikely to be needed in the mmc_test case.  So if retuning is needed, just
> skip the call to mmc_send_status() i.e.
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> Could then make mmc_test aware of that:
>  

> This solution is better, please help to upstream it. Thx!
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index b78cf5d403a3..7b105b97be78 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
>  	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
>  		return RESULT_UNSUP_CARD;
>  
> +	err = mmc_send_status(card, NULL);
> +	if (err)
> +		return err;
> +
> +	if (host->need_retune) {
> +		pr_info("%s: cannot test hw reset because retune needed\n",
> +			mmc_hostname(test->card->host));
> +		return RESULT_FAIL;
> +	}
> +
>  	err = mmc_hw_reset(host);
>  	if (!err)
>  		return RESULT_OK;
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> 
> 
> 
> > 
> > Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> > ---
> >  drivers/mmc/core/mmc.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index e726903..f2d0c2a 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
> >  
> >  	/* Set initial state and call mmc_set_ios */
> >  	mmc_set_initial_state(host);
> > +	mmc_set_clock(host, host->f_init);
> >  	mmc_host_clk_release(host);
> >  
> >  	return mmc_init_card(host, card->ocr, card);
> > 
> 



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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30  9:03     ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-09-30  9:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 2015-09-30 at 11:24 +0300, Adrian Hunter wrote:
> On 30/09/15 06:28, Chaotian Jing wrote:
> > Suppose that we got a data crc error, and it triggers the mmc_reset.
> > mmc_reset will call mmc_send_status to see if HW reset was supported.
> > before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
> > it will reduce frequency to 52Mhz firstly, that results in card init
> > was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
> > re-init card.
> 
> The call to mmc_send_status() was originally only done for mmc_test and
> doesn't belong in a real reset.  However the test parameter was removed
> to simplify the code by:
> 
> commit 83533ab28380f6957af39a7b322e639e42dbdaf1
> Author: Johan Rudholm <johan.rudholm@axis.com>
> Date:   Mon Jan 12 15:38:04 2015 +0100
> 
>     mmc: core: always check status after reset
>     
>     Always check if the card is alive after a successful reset. This allows
>     us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
>     card reset interface.
>     
>     Signed-off-by: Johan Rudholm <johanru@axis.com>
>     Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> IMHO having a test to check whether hw reset actually did reset the card
> is useful, so I would suggest putting back mmc_hw_reset_check() and
> removing the check from the non-test path.
> 
> An alternative is to recognize that we don't want retuning here, and it is
> unlikely to be needed in the mmc_test case.  So if retuning is needed, just
> skip the call to mmc_send_status() i.e.
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> Could then make mmc_test aware of that:
>  

> This solution is better, please help to upstream it. Thx!
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index b78cf5d403a3..7b105b97be78 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
>  	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
>  		return RESULT_UNSUP_CARD;
>  
> +	err = mmc_send_status(card, NULL);
> +	if (err)
> +		return err;
> +
> +	if (host->need_retune) {
> +		pr_info("%s: cannot test hw reset because retune needed\n",
> +			mmc_hostname(test->card->host));
> +		return RESULT_FAIL;
> +	}
> +
>  	err = mmc_hw_reset(host);
>  	if (!err)
>  		return RESULT_OK;
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f2d0c2ae85b1..c3749ba42739 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>  	host->ops->hw_reset(host);
>  
>  	/* If the reset has happened, then a status command will fail */
> -	if (!mmc_send_status(card, &status)) {
> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>  		mmc_host_clk_release(host);
>  		return -ENOSYS;
>  	}
> 
> 
> 
> 
> > 
> > Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> > ---
> >  drivers/mmc/core/mmc.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index e726903..f2d0c2a 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
> >  
> >  	/* Set initial state and call mmc_set_ios */
> >  	mmc_set_initial_state(host);
> > +	mmc_set_clock(host, host->f_init);
> >  	mmc_host_clk_release(host);
> >  
> >  	return mmc_init_card(host, card->ocr, card);
> > 
> 

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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
  2015-09-30  9:03     ` Chaotian Jing
@ 2015-09-30 13:01       ` Adrian Hunter
  -1 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2015-09-30 13:01 UTC (permalink / raw)
  To: Chaotian Jing
  Cc: Ulf Hansson, Matthias Brugger, Johan Rudholm, Gwendal Grignou,
	linux-mmc, linux-kernel, linux-arm-kernel, linux-mediatek,
	srv_heupstream, Sascha Hauer

On 30/09/15 12:03, Chaotian Jing wrote:
> On Wed, 2015-09-30 at 11:24 +0300, Adrian Hunter wrote:
>> On 30/09/15 06:28, Chaotian Jing wrote:
>>> Suppose that we got a data crc error, and it triggers the mmc_reset.
>>> mmc_reset will call mmc_send_status to see if HW reset was supported.
>>> before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
>>> it will reduce frequency to 52Mhz firstly, that results in card init
>>> was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
>>> re-init card.
>>
>> The call to mmc_send_status() was originally only done for mmc_test and
>> doesn't belong in a real reset.  However the test parameter was removed
>> to simplify the code by:
>>
>> commit 83533ab28380f6957af39a7b322e639e42dbdaf1
>> Author: Johan Rudholm <johan.rudholm@axis.com>
>> Date:   Mon Jan 12 15:38:04 2015 +0100
>>
>>     mmc: core: always check status after reset
>>     
>>     Always check if the card is alive after a successful reset. This allows
>>     us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
>>     card reset interface.
>>     
>>     Signed-off-by: Johan Rudholm <johanru@axis.com>
>>     Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>>
>> IMHO having a test to check whether hw reset actually did reset the card
>> is useful, so I would suggest putting back mmc_hw_reset_check() and
>> removing the check from the non-test path.
>>
>> An alternative is to recognize that we don't want retuning here, and it is
>> unlikely to be needed in the mmc_test case.  So if retuning is needed, just
>> skip the call to mmc_send_status() i.e.
>>
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index f2d0c2ae85b1..c3749ba42739 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>>  	host->ops->hw_reset(host);
>>  
>>  	/* If the reset has happened, then a status command will fail */
>> -	if (!mmc_send_status(card, &status)) {
>> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>>  		mmc_host_clk_release(host);
>>  		return -ENOSYS;
>>  	}
>>
>> Could then make mmc_test aware of that:
>>  
> 
>> This solution is better, please help to upstream it. Thx!

Then please, make it a patch, and test it and submit it.  You can add:

Suggested-by: Adrian Hunter <adrian.hunter@intel.com>


>> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
>> index b78cf5d403a3..7b105b97be78 100644
>> --- a/drivers/mmc/card/mmc_test.c
>> +++ b/drivers/mmc/card/mmc_test.c
>> @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
>>  	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
>>  		return RESULT_UNSUP_CARD;
>>  
>> +	err = mmc_send_status(card, NULL);
>> +	if (err)
>> +		return err;
>> +
>> +	if (host->need_retune) {
>> +		pr_info("%s: cannot test hw reset because retune needed\n",
>> +			mmc_hostname(test->card->host));
>> +		return RESULT_FAIL;
>> +	}
>> +
>>  	err = mmc_hw_reset(host);
>>  	if (!err)
>>  		return RESULT_OK;
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index f2d0c2ae85b1..c3749ba42739 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>>  	host->ops->hw_reset(host);
>>  
>>  	/* If the reset has happened, then a status command will fail */
>> -	if (!mmc_send_status(card, &status)) {
>> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>>  		mmc_host_clk_release(host);
>>  		return -ENOSYS;
>>  	}
>>
>>
>>
>>
>>>
>>> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
>>> ---
>>>  drivers/mmc/core/mmc.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>> index e726903..f2d0c2a 100644
>>> --- a/drivers/mmc/core/mmc.c
>>> +++ b/drivers/mmc/core/mmc.c
>>> @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
>>>  
>>>  	/* Set initial state and call mmc_set_ios */
>>>  	mmc_set_initial_state(host);
>>> +	mmc_set_clock(host, host->f_init);
>>>  	mmc_host_clk_release(host);
>>>  
>>>  	return mmc_init_card(host, card->ocr, card);
>>>
>>
> 
> 
> 


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-09-30 13:01       ` Adrian Hunter
  0 siblings, 0 replies; 16+ messages in thread
From: Adrian Hunter @ 2015-09-30 13:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/09/15 12:03, Chaotian Jing wrote:
> On Wed, 2015-09-30 at 11:24 +0300, Adrian Hunter wrote:
>> On 30/09/15 06:28, Chaotian Jing wrote:
>>> Suppose that we got a data crc error, and it triggers the mmc_reset.
>>> mmc_reset will call mmc_send_status to see if HW reset was supported.
>>> before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
>>> it will reduce frequency to 52Mhz firstly, that results in card init
>>> was doing at 52Mhz, So need ensure frequency is lower than 400Khz when
>>> re-init card.
>>
>> The call to mmc_send_status() was originally only done for mmc_test and
>> doesn't belong in a real reset.  However the test parameter was removed
>> to simplify the code by:
>>
>> commit 83533ab28380f6957af39a7b322e639e42dbdaf1
>> Author: Johan Rudholm <johan.rudholm@axis.com>
>> Date:   Mon Jan 12 15:38:04 2015 +0100
>>
>>     mmc: core: always check status after reset
>>     
>>     Always check if the card is alive after a successful reset. This allows
>>     us to remove mmc_hw_reset_check(), leaving mmc_hw_reset() as the only
>>     card reset interface.
>>     
>>     Signed-off-by: Johan Rudholm <johanru@axis.com>
>>     Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>>
>> IMHO having a test to check whether hw reset actually did reset the card
>> is useful, so I would suggest putting back mmc_hw_reset_check() and
>> removing the check from the non-test path.
>>
>> An alternative is to recognize that we don't want retuning here, and it is
>> unlikely to be needed in the mmc_test case.  So if retuning is needed, just
>> skip the call to mmc_send_status() i.e.
>>
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index f2d0c2ae85b1..c3749ba42739 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>>  	host->ops->hw_reset(host);
>>  
>>  	/* If the reset has happened, then a status command will fail */
>> -	if (!mmc_send_status(card, &status)) {
>> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>>  		mmc_host_clk_release(host);
>>  		return -ENOSYS;
>>  	}
>>
>> Could then make mmc_test aware of that:
>>  
> 
>> This solution is better, please help to upstream it. Thx!

Then please, make it a patch, and test it and submit it.  You can add:

Suggested-by: Adrian Hunter <adrian.hunter@intel.com>


>> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
>> index b78cf5d403a3..7b105b97be78 100644
>> --- a/drivers/mmc/card/mmc_test.c
>> +++ b/drivers/mmc/card/mmc_test.c
>> @@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
>>  	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
>>  		return RESULT_UNSUP_CARD;
>>  
>> +	err = mmc_send_status(card, NULL);
>> +	if (err)
>> +		return err;
>> +
>> +	if (host->need_retune) {
>> +		pr_info("%s: cannot test hw reset because retune needed\n",
>> +			mmc_hostname(test->card->host));
>> +		return RESULT_FAIL;
>> +	}
>> +
>>  	err = mmc_hw_reset(host);
>>  	if (!err)
>>  		return RESULT_OK;
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index f2d0c2ae85b1..c3749ba42739 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
>>  	host->ops->hw_reset(host);
>>  
>>  	/* If the reset has happened, then a status command will fail */
>> -	if (!mmc_send_status(card, &status)) {
>> +	if (!host->need_retune && !mmc_send_status(card, &status)) {
>>  		mmc_host_clk_release(host);
>>  		return -ENOSYS;
>>  	}
>>
>>
>>
>>
>>>
>>> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
>>> ---
>>>  drivers/mmc/core/mmc.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>> index e726903..f2d0c2a 100644
>>> --- a/drivers/mmc/core/mmc.c
>>> +++ b/drivers/mmc/core/mmc.c
>>> @@ -1945,6 +1945,7 @@ static int mmc_reset(struct mmc_host *host)
>>>  
>>>  	/* Set initial state and call mmc_set_ios */
>>>  	mmc_set_initial_state(host);
>>> +	mmc_set_clock(host, host->f_init);
>>>  	mmc_host_clk_release(host);
>>>  
>>>  	return mmc_init_card(host, card->ocr, card);
>>>
>>
> 
> 
> 

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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
  2015-10-08  6:41 ` Chaotian Jing
  (?)
@ 2015-10-08  6:51   ` kbuild test robot
  -1 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2015-10-08  6:51 UTC (permalink / raw)
  To: Chaotian Jing
  Cc: kbuild-all, Ulf Hansson, Matthias Brugger, Jaehoon Chung,
	Chaotian Jing, Adrian Hunter, Fabio Estevam, Johan Rudholm,
	Gwendal Grignou, linux-mmc, linux-kernel, linux-arm-kernel,
	linux-mediatek, srv_heupstream, Sascha Hauer

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

Hi Chaotian,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: i386-randconfig-i1-201540 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/mmc/card/mmc_test.c: In function 'mmc_test_hw_reset':
>> drivers/mmc/card/mmc_test.c:2275:8: error: implicit declaration of function 'mmc_send_status' [-Werror=implicit-function-declaration]
     err = mmc_send_status(card, NULL);
           ^
   cc1: some warnings being treated as errors

vim +/mmc_send_status +2275 drivers/mmc/card/mmc_test.c

  2269		struct mmc_host *host = card->host;
  2270		int err;
  2271	
  2272		if (!mmc_card_mmc(card) || !mmc_can_reset(card))
  2273			return RESULT_UNSUP_CARD;
  2274	
> 2275		err = mmc_send_status(card, NULL);
  2276		if (err)
  2277			return err;
  2278	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 20381 bytes --]

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

* Re: [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-10-08  6:51   ` kbuild test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2015-10-08  6:51 UTC (permalink / raw)
  Cc: kbuild-all, Ulf Hansson, Matthias Brugger, Jaehoon Chung,
	Chaotian Jing, Adrian Hunter, Fabio Estevam, Johan Rudholm,
	Gwendal Grignou, linux-mmc, linux-kernel, linux-arm-kernel,
	linux-mediatek, srv_heupstream, Sascha Hauer

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

Hi Chaotian,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: i386-randconfig-i1-201540 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/mmc/card/mmc_test.c: In function 'mmc_test_hw_reset':
>> drivers/mmc/card/mmc_test.c:2275:8: error: implicit declaration of function 'mmc_send_status' [-Werror=implicit-function-declaration]
     err = mmc_send_status(card, NULL);
           ^
   cc1: some warnings being treated as errors

vim +/mmc_send_status +2275 drivers/mmc/card/mmc_test.c

  2269		struct mmc_host *host = card->host;
  2270		int err;
  2271	
  2272		if (!mmc_card_mmc(card) || !mmc_can_reset(card))
  2273			return RESULT_UNSUP_CARD;
  2274	
> 2275		err = mmc_send_status(card, NULL);
  2276		if (err)
  2277			return err;
  2278	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 20381 bytes --]

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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-10-08  6:51   ` kbuild test robot
  0 siblings, 0 replies; 16+ messages in thread
From: kbuild test robot @ 2015-10-08  6:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Chaotian,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: i386-randconfig-i1-201540 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/mmc/card/mmc_test.c: In function 'mmc_test_hw_reset':
>> drivers/mmc/card/mmc_test.c:2275:8: error: implicit declaration of function 'mmc_send_status' [-Werror=implicit-function-declaration]
     err = mmc_send_status(card, NULL);
           ^
   cc1: some warnings being treated as errors

vim +/mmc_send_status +2275 drivers/mmc/card/mmc_test.c

  2269		struct mmc_host *host = card->host;
  2270		int err;
  2271	
  2272		if (!mmc_card_mmc(card) || !mmc_can_reset(card))
  2273			return RESULT_UNSUP_CARD;
  2274	
> 2275		err = mmc_send_status(card, NULL);
  2276		if (err)
  2277			return err;
  2278	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 20381 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151008/0670878a/attachment-0001.obj>

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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-10-08  6:41 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-10-08  6:41 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Matthias Brugger, Jaehoon Chung, Chaotian Jing, Adrian Hunter,
	Fabio Estevam, Johan Rudholm, Gwendal Grignou, linux-mmc,
	linux-kernel, linux-arm-kernel, linux-mediatek, srv_heupstream,
	Sascha Hauer

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, then results in card init
was doing at 52Mhz.
The mmc_send_status was originally only done for mmc_test, so if retune
needed, do not call mmc_send_status, and move it to mmc_test code.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/card/mmc_test.c | 10 ++++++++++
 drivers/mmc/core/mmc.c      |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b78cf5d..7b105b9 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
 	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
 		return RESULT_UNSUP_CARD;
 
+	err = mmc_send_status(card, NULL);
+	if (err)
+		return err;
+
+	if (host->need_retune) {
+		pr_info("%s: cannot test hw reset because retune needed\n",
+			mmc_hostname(test->card->host));
+		return RESULT_FAIL;
+	}
+
 	err = mmc_hw_reset(host);
 	if (!err)
 		return RESULT_OK;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..647c96d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}
-- 
1.8.1.1.dirty


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-10-08  6:41 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-10-08  6:41 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Matthias Brugger, Jaehoon Chung, Chaotian Jing, Adrian Hunter,
	Fabio Estevam, Johan Rudholm, Gwendal Grignou, linux-mmc,
	linux-kernel, linux-arm-kernel, linux-mediatek, srv_heupstream,
	Sascha Hauer

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, then results in card init
was doing at 52Mhz.
The mmc_send_status was originally only done for mmc_test, so if retune
needed, do not call mmc_send_status, and move it to mmc_test code.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/card/mmc_test.c | 10 ++++++++++
 drivers/mmc/core/mmc.c      |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b78cf5d..7b105b9 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
 	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
 		return RESULT_UNSUP_CARD;
 
+	err = mmc_send_status(card, NULL);
+	if (err)
+		return err;
+
+	if (host->need_retune) {
+		pr_info("%s: cannot test hw reset because retune needed\n",
+			mmc_hostname(test->card->host));
+		return RESULT_FAIL;
+	}
+
 	err = mmc_hw_reset(host);
 	if (!err)
 		return RESULT_OK;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..647c96d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}
-- 
1.8.1.1.dirty


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

* [PATCH] mmc: core: Fix init_card in 52Mhz
@ 2015-10-08  6:41 ` Chaotian Jing
  0 siblings, 0 replies; 16+ messages in thread
From: Chaotian Jing @ 2015-10-08  6:41 UTC (permalink / raw)
  To: linux-arm-kernel

Suppose that we got a data crc error, and it triggers the mmc_reset.
mmc_reset will call mmc_send_status to see if HW reset was supported.
before issue CMD13, it will do retune, and if EMMC was in HS400 mode,
it will reduce frequency to 52Mhz firstly, then results in card init
was doing at 52Mhz.
The mmc_send_status was originally only done for mmc_test, so if retune
needed, do not call mmc_send_status, and move it to mmc_test code.

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/card/mmc_test.c | 10 ++++++++++
 drivers/mmc/core/mmc.c      |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index b78cf5d..7b105b9 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2272,6 +2272,16 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
 	if (!mmc_card_mmc(card) || !mmc_can_reset(card))
 		return RESULT_UNSUP_CARD;
 
+	err = mmc_send_status(card, NULL);
+	if (err)
+		return err;
+
+	if (host->need_retune) {
+		pr_info("%s: cannot test hw reset because retune needed\n",
+			mmc_hostname(test->card->host));
+		return RESULT_FAIL;
+	}
+
 	err = mmc_hw_reset(host);
 	if (!err)
 		return RESULT_OK;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e726903..647c96d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1938,7 +1938,7 @@ static int mmc_reset(struct mmc_host *host)
 	host->ops->hw_reset(host);
 
 	/* If the reset has happened, then a status command will fail */
-	if (!mmc_send_status(card, &status)) {
+	if (!host->need_retune && !mmc_send_status(card, &status)) {
 		mmc_host_clk_release(host);
 		return -ENOSYS;
 	}
-- 
1.8.1.1.dirty

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

end of thread, other threads:[~2015-10-08  6:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30  3:28 [PATCH] mmc: core: Fix init_card in 52Mhz Chaotian Jing
2015-09-30  3:28 ` Chaotian Jing
2015-09-30  3:28 ` Chaotian Jing
2015-09-30  8:24 ` Adrian Hunter
2015-09-30  8:24   ` Adrian Hunter
2015-09-30  9:03   ` Chaotian Jing
2015-09-30  9:03     ` Chaotian Jing
2015-09-30  9:03     ` Chaotian Jing
2015-09-30 13:01     ` Adrian Hunter
2015-09-30 13:01       ` Adrian Hunter
2015-10-08  6:41 Chaotian Jing
2015-10-08  6:41 ` Chaotian Jing
2015-10-08  6:41 ` Chaotian Jing
2015-10-08  6:51 ` kbuild test robot
2015-10-08  6:51   ` kbuild test robot
2015-10-08  6:51   ` kbuild test robot

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.