Skip to contentSkip to conversation

mmc: mmc: Fix the timing for clock changing in mmc

PATCH In review Kyungmin Seo 4 participants 13 messages Feb 12, 2020 – Mar 11, 2020 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: mmc: Fix the timing for clock changing in mmc

The clock has to be changed after sending CMD6 for HS mode selection in mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c +4 -4
index 3486bc7fbb64..98640b51c73e 100644
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 	int err;
 	u8 val;
 
-	/* Reduce frequency to HS */
-	max_dtr = card->ext_csd.hs_max_dtr;
-	mmc_set_clock(host, max_dtr);
-
 	/* Switch HS400 to HS DDR */
 	val = EXT_CSD_TIMING_HS;
 	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
@@ -1210,6 +1206,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
 	mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
 
+	/* Reduce frequency to HS */
+	max_dtr = card->ext_csd.hs_max_dtr;
+	mmc_set_clock(host, max_dtr);
+
 	err = mmc_switch_status(card);
 	if (err)
 		goto out_err;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 35 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c +4 -5
index 3486bc7fbb64..98640b51c73e 100644
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
@@ -1210,6 +1206,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
 
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#2 lore raw

The mmc_hs400_to_hs200 function is called only in HS400 mode.
I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform.

I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock.

Thanks
KM

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, March 4, 2020 8:09 PM
To: Seo, Kyungmin <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

Quoted 8 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in
mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 36 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

3486bc7fbb64..98640b51c73e 100644

drivers/mmc/core/mmc.c +0 -4
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 

EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int
mmc_hs400_to_hs200(struct mmc_card *card)

        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
drivers/mmc/core/mmc.c +4 -1
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#3 lore raw

+ Adrian, Chaotian

Quoted 6 lines · Kyungmin

The mmc_hs400_to_hs200 function is called only in HS400 mode.
I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform.

I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock.

I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right.

Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted.

Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this.

Kind regards
Uffe

[1]
https://lore.kernel.org/linux-mmc/[email protected]/
[2]
https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/

Quoted 66 lines

Thanks
KM

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, March 4, 2020 8:09 PM
To: Seo, Kyungmin <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

Quoted 8 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in
mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 36 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

3486bc7fbb64..98640b51c73e 100644

drivers/mmc/core/mmc.c +0 -4
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,

EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int
mmc_hs400_to_hs200(struct mmc_card *card)

        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
drivers/mmc/core/mmc.c +4 -1
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#4 lore raw

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.
Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Thanks

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Friday, March 6, 2020 12:18 AM
To: Seo, Kyungmin <[email protected]>; Hunter, Adrian <[email protected]>; Chaotian Jing <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

+ Adrian, Chaotian

Quoted 6 lines · Kyungmin

The mmc_hs400_to_hs200 function is called only in HS400 mode.
I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform.

I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock.

I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right.

Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted.

Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this.

Kind regards
Uffe

[1]
https://lore.kernel.org/linux-mmc/[email protected]/
[2]
https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/

Quoted 68 lines

Thanks
KM

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, March 4, 2020 8:09 PM
To: Seo, Kyungmin <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

Quoted 8 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in
mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 36 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

3486bc7fbb64..98640b51c73e 100644

drivers/mmc/core/mmc.c +0 -4
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 

EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int
mmc_hs400_to_hs200(struct mmc_card *card)

        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
drivers/mmc/core/mmc.c +4 -1
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#5 lore raw
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Kind regards
Uffe

Quoted 104 lines

Thanks

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Friday, March 6, 2020 12:18 AM
To: Seo, Kyungmin <[email protected]>; Hunter, Adrian <[email protected]>; Chaotian Jing <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

+ Adrian, Chaotian

Quoted 6 lines · Kyungmin

The mmc_hs400_to_hs200 function is called only in HS400 mode.
I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform.

I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock.

I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right.

Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted.

Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this.

Kind regards
Uffe

[1]
https://lore.kernel.org/linux-mmc/[email protected]/
[2]
https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/

Quoted 68 lines

Thanks
KM

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, March 4, 2020 8:09 PM
To: Seo, Kyungmin <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

Quoted 8 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in
mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 36 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

3486bc7fbb64..98640b51c73e 100644

drivers/mmc/core/mmc.c +0 -4
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,

EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int
mmc_hs400_to_hs200(struct mmc_card *card)

        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
drivers/mmc/core/mmc.c +4 -1
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#6 lore raw
Quoted 13 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Quoted 8 lines

Yes, but not for all cases, as I said in my reply in those email-threads.

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

drivers/mmc/core/mmc.c +4 -1
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
 	/* Reduce frequency to HS */
 	max_dtr = card->ext_csd.hs_max_dtr;
-	mmc_set_clock(host, max_dtr);
+	if (host->ops->hs400_to_hs200_prep)
+		host->ops->hs400_to_hs200_prep(host, max_dtr);
+	else
+		mmc_set_clock(host, max_dtr);
 
 	/* Switch HS400 to HS DDR */
 	val = EXT_CSD_TIMING_HS;
Quoted 108 lines

Kind regards
Uffe

Quoted 104 lines

Thanks

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Friday, March 6, 2020 12:18 AM
To: Seo, Kyungmin <[email protected]>; Hunter, Adrian <[email protected]>; Chaotian Jing <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

+ Adrian, Chaotian

Quoted 6 lines · Kyungmin

The mmc_hs400_to_hs200 function is called only in HS400 mode.
I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform.

I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock.

I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right.

Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted.

Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this.

Kind regards
Uffe

[1]
https://lore.kernel.org/linux-mmc/[email protected]/
[2]
https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/

Quoted 68 lines

Thanks
KM

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, March 4, 2020 8:09 PM
To: Seo, Kyungmin <[email protected]>
Cc: [email protected]; Linux Kernel Mailing List <[email protected]>
Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc

Quoted 8 lines · Kyungmin Seo

The clock has to be changed after sending CMD6 for HS mode selection in
mmc_hs400_to_hs200() function.

The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to enable the the high speed mode timing in the Device, before chaning the clock frequency to a frequency between 26MHz and 52MHz.

I think that is based upon the assumption that you are using a lower frequency to start with.

For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate.

mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me.

Kind regards
Uffe

Quoted 36 lines
---
 drivers/mmc/core/mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

3486bc7fbb64..98640b51c73e 100644

drivers/mmc/core/mmc.c +0 -4
@@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
        int err;
        u8 val;
 
-       /* Reduce frequency to HS */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,

EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int
mmc_hs400_to_hs200(struct mmc_card *card)

        mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
drivers/mmc/core/mmc.c +4 -1
+       /* Reduce frequency to HS */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        err = mmc_switch_status(card);
        if (err)
                goto out_err;
--

2.17.1

#7 lore raw
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

Quoted 9 lines
drivers/mmc/core/mmc.c +0 -0
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 

drivers/mmc/core/mmc.c int mmc_hs400_to_hs200(struct mmc_card *card) · line 1246

Quoted 10 lines
drivers/mmc/core/mmc.c +4 -1
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

[...]

Kind regards
Uffe

#8 lore raw
Quoted 29 lines · Ulf Hansson
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

Quoted 8 lines

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

When start to send CMD6 to switch to HS mode, both Host & eMMC device are working on HS400 mode, so the timing used is MUST at HS400 mode and the clock MUST keep at current clock(usually 200Mhz). after received the response of CMD6, Never use CMD13 to polling card status for timing switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use it, if not,just do mmc_delay() for specific time.

the next step is that call mmc_set_ios() to set current timing to HS mode and clock to 50Mhz to let Host driver that eMMC device has been switched to HS mode and Host can switch to HS mode at 50Mhz(may apply parameters for this low speed).

Quoted 24 lines
Quoted 9 lines
drivers/mmc/core/mmc.c +0 -0
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 

drivers/mmc/core/mmc.c int mmc_hs400_to_hs200(struct mmc_card *card) · line 1246

Quoted 10 lines
drivers/mmc/core/mmc.c +4 -1
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

[...]

Kind regards
Uffe

#9 lore raw
Quoted 39 lines · Chaotian Jing
Quoted 29 lines · Ulf Hansson
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

Quoted 8 lines

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

Quoted 6 lines

When start to send CMD6 to switch to HS mode, both Host & eMMC device are working on HS400 mode, so the timing used is MUST at HS400 mode and the clock MUST keep at current clock(usually 200Mhz). after received the response of CMD6, Never use CMD13 to polling card status for timing switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use it, if not,just do mmc_delay() for specific time.

The CMD13 is currently not used when polling, because we set the send_status parameter to false in the calls to __mmc_switch(). So this should already be covered, according to your suggestions. Right?

When it comes to keeping the clock rate as is, before sending the CMD6
- I fully agree that it's a good idea when doing a periodic retuning. As you would expect things to work as they are.

The problem is, when you have received a CRC error and the re-tuning is being triggered because of that. In that case it may be a better option to decrease the clock rate, at least that is what I recall Adrian needs for his cases. Adrian?

What will happen when you receive a CRC error and there is re-tuning triggered, is that something you have seen happening on you boards?

Quoted 5 lines

the next step is that call mmc_set_ios() to set current timing to HS mode and clock to 50Mhz to let Host driver that eMMC device has been switched to HS mode and Host can switch to HS mode at 50Mhz(may apply parameters for this low speed).

Yep, makes sense.

Quoted 22 lines
Quoted 22 lines
Quoted 19 lines
drivers/mmc/core/mmc.c +4 -1
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

[...]

Quoted 3 lines
Quoted 2 lines

Kind regards
Uffe

Kind regards
Uffe

#10 lore raw
Quoted 51 lines · Ulf Hansson
Quoted 39 lines · Chaotian Jing
Quoted 29 lines · Ulf Hansson
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

Quoted 8 lines

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

Quoted 6 lines

When start to send CMD6 to switch to HS mode, both Host & eMMC device are working on HS400 mode, so the timing used is MUST at HS400 mode and the clock MUST keep at current clock(usually 200Mhz). after received the response of CMD6, Never use CMD13 to polling card status for timing switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use it, if not,just do mmc_delay() for specific time.

The CMD13 is currently not used when polling, because we set the send_status parameter to false in the calls to __mmc_switch(). So this should already be covered, according to your suggestions. Right?

Quoted 8 lines

When it comes to keeping the clock rate as is, before sending the CMD6
- I fully agree that it's a good idea when doing a periodic retuning. As you would expect things to work as they are.

The problem is, when you have received a CRC error and the re-tuning is being triggered because of that. In that case it may be a better option to decrease the clock rate, at least that is what I recall Adrian needs for his cases. Adrian?

It seems hardware supports HS400 only at the expected 200MHz frequency. The assumption then is that the command will be seen by the card but the response may have a CRC error. So we would need to ignore CRC errors, but it would also be worth waiting the timeout if the card is still busy whether or not there is an error.

The only way to mitigate errors then is to increase the number of retries.

Quoted 41 lines

What will happen when you receive a CRC error and there is re-tuning triggered, is that something you have seen happening on you boards?

Quoted 5 lines

the next step is that call mmc_set_ios() to set current timing to HS mode and clock to 50Mhz to let Host driver that eMMC device has been switched to HS mode and Host can switch to HS mode at 50Mhz(may apply parameters for this low speed).

Yep, makes sense.

Quoted 22 lines
Quoted 22 lines
Quoted 19 lines
drivers/mmc/core/mmc.c +4 -1
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

[...]

Quoted 3 lines
Quoted 2 lines

Kind regards
Uffe

Kind regards
Uffe

#11 lore raw
Quoted 57 lines · Adrian Hunter
Quoted 55 lines · Ulf Hansson
Quoted 39 lines · Chaotian Jing
Quoted 29 lines · Ulf Hansson
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

Quoted 8 lines

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

Quoted 6 lines

When start to send CMD6 to switch to HS mode, both Host & eMMC device are working on HS400 mode, so the timing used is MUST at HS400 mode and the clock MUST keep at current clock(usually 200Mhz). after received the response of CMD6, Never use CMD13 to polling card status for timing switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use it, if not,just do mmc_delay() for specific time.

The CMD13 is currently not used when polling, because we set the send_status parameter to false in the calls to __mmc_switch(). So this should already be covered, according to your suggestions. Right?

When it comes to keeping the clock rate as is, before sending the CMD6
- I fully agree that it's a good idea when doing a periodic retuning. As you would expect things to work as they are.

Quoted 6 lines
Quoted 4 lines

The problem is, when you have received a CRC error and the re-tuning is being triggered because of that. In that case it may be a better option to decrease the clock rate, at least that is what I recall Adrian needs for his cases. Adrian?

It seems hardware supports HS400 only at the expected 200MHz frequency.

Yes, that's my understanding as well.

Quoted 4 lines

The assumption then is that the command will be seen by the card but the response may have a CRC error. So we would need to ignore CRC errors, but it would also be worth waiting the timeout if the card is still busy whether or not there is an error.

Alright, so you're saying that keeping the clock rate to HS400 speed (decrease it after CMD6) could be fine, if we implement the above instead?

Quoted 2 lines

The only way to mitigate errors then is to increase the number of retries.

We already use MMC_CMD_RETRIES for CMD6. Is that sufficient you think (again assuming we implement to allow CRC errors for these CMD6 commands)?

Or are you suggesting we may need a re-try of the hole re-tune thing? Maybe a better option is then to simply bail out and do full re-init of the card?

Quoted 28 lines
Quoted 28 lines

What will happen when you receive a CRC error and there is re-tuning triggered, is that something you have seen happening on you boards?

Quoted 5 lines

the next step is that call mmc_set_ios() to set current timing to HS mode and clock to 50Mhz to let Host driver that eMMC device has been switched to HS mode and Host can switch to HS mode at 50Mhz(may apply parameters for this low speed).

Yep, makes sense.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/mmc/core/mmc.c +4 -1
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/mmc/core/mmc.c int mmc_hs400_to_hs200(struct mmc_card *card) · line 1246

Quoted 4 lines
drivers/mmc/core/mmc.c +0 -0
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

Kind regards
Uffe

#12 lore raw
Quoted 67 lines · Ulf Hansson
Quoted 57 lines · Adrian Hunter
Quoted 55 lines · Ulf Hansson
Quoted 39 lines · Chaotian Jing
Quoted 29 lines · Ulf Hansson
Quoted 17 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
Quoted 7 lines · Kyungmin

I read the link and patch of Chaotian Jing.
I also point out what Chaotian said.
Most host controllers have DLL tuning values for each mode. When host controller is set as HS400 mode with 50MHz clock, host controller uses DLL value which is tuned with 200MHz clock.

If DLL value in HS400 mode doesn't have the pass range in HS mode, command transfer failing may fail. In order to make robust sdhci driver, I think the patch needs to be considered.

I have, but I am not picking it up in its current form.

Quoted 1 line

Of course, CMD6 with HS400 mode and 200MHz clock should not cause any problem because it's correct configuration.

Yes, but not for all cases, as I said in my reply in those email-threads.

Quoted 8 lines
Quoted 6 lines

What I had in mind, is that I I think we should inform mmc_hs400_to_hs200() about under what situation it's getting called. Depending on that, we should either decrease the clock rate before or after we send the CMD6.

Would that work for your case?

Ulf, would you consider a new call back e.g.

That could work, but I am not sure what's best, honestly.

Quoted 8 lines

The problem may be generic or it could be specific to some host controller? I think we need to answer that question first.

What do you think?

Br
Uffe

Quoted 6 lines

When start to send CMD6 to switch to HS mode, both Host & eMMC device are working on HS400 mode, so the timing used is MUST at HS400 mode and the clock MUST keep at current clock(usually 200Mhz). after received the response of CMD6, Never use CMD13 to polling card status for timing switch. if host has ops->card_busy() or caps WAIT_WHILE_BUSY, then use it, if not,just do mmc_delay() for specific time.

The CMD13 is currently not used when polling, because we set the send_status parameter to false in the calls to __mmc_switch(). So this should already be covered, according to your suggestions. Right?

When it comes to keeping the clock rate as is, before sending the CMD6
- I fully agree that it's a good idea when doing a periodic retuning. As you would expect things to work as they are.

Quoted 6 lines
Quoted 4 lines

The problem is, when you have received a CRC error and the re-tuning is being triggered because of that. In that case it may be a better option to decrease the clock rate, at least that is what I recall Adrian needs for his cases. Adrian?

It seems hardware supports HS400 only at the expected 200MHz frequency.

Yes, that's my understanding as well.

Quoted 8 lines
Quoted 4 lines

The assumption then is that the command will be seen by the card but the response may have a CRC error. So we would need to ignore CRC errors, but it would also be worth waiting the timeout if the card is still busy whether or not there is an error.

Alright, so you're saying that keeping the clock rate to HS400 speed (decrease it after CMD6) could be fine, if we implement the above instead?

Yes, but I would like to try adding a simple retry at the lower frequency as well and see how well that works. I will test that tomorrow.

Quoted 7 lines
Quoted 3 lines

The only way to mitigate errors then is to increase the number of retries.

We already use MMC_CMD_RETRIES for CMD6. Is that sufficient you think (again assuming we implement to allow CRC errors for these CMD6 commands)?

That is only 3. If the CRC errors are random, then trying more times might help.

Quoted 4 lines

Or are you suggesting we may need a re-try of the hole re-tune thing? Maybe a better option is then to simply bail out and do full re-init of the card?

The block driver will try that at some point. I will see if I can test how well that works in this case.

Quoted 37 lines
Quoted 29 lines
Quoted 29 lines

What will happen when you receive a CRC error and there is re-tuning triggered, is that something you have seen happening on you boards?

Quoted 5 lines

the next step is that call mmc_set_ios() to set current timing to HS mode and clock to 50Mhz to let Host driver that eMMC device has been switched to HS mode and Host can switch to HS mode at 50Mhz(may apply parameters for this low speed).

Yep, makes sense.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/mmc/core/mmc.c +4 -1
index c2abd417a84a..1bc18fe2632f 100644
@@ -1237,7 +1237,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
 
        /* Reduce frequency to HS */
        max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
+       if (host->ops->hs400_to_hs200_prep)
+               host->ops->hs400_to_hs200_prep(host, max_dtr);
+       else
+               mmc_set_clock(host, max_dtr);
 
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/mmc/core/mmc.c int mmc_hs400_to_hs200(struct mmc_card *card) · line 1246

Quoted 4 lines
drivers/mmc/core/mmc.c +0 -0
        /* Switch HS400 to HS DDR */
        val = EXT_CSD_TIMING_HS;

Kind regards
Uffe