mmc: core: host: fix mmc retuning
PATCH 1/1 mmc: core: host: fix mmc retuning
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB, hold_retune variable was introduced but it is not taken into account while making the tuning decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0: mmc_hs400_to_hs200 failed, error -84
To fix this, take hold_retune variable into account while making retune decision in mmc_retune() function.
--- drivers/mmc/core/host.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/core/host.c +3 -0
@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host)bool return_to_hs400 = false;int err; +if (host->hold_retune >=1 ) +return 0 ; +if (host->retune_now) host->retune_now =0 ;else
Signature · 1 line
2.34.1
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.
We observed that hold_retune is always greater or equal to 1 in mmc_retune() function,
so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
Quoted 5 lines · Shyam Saini
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introduced
No, mmc_retune_pause() is used:
/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
void mmc_retune_pause(struct mmc_host *host)
{
if (!host->retune_paused) {
host->retune_paused = 1;
mmc_retune_needed(host);
mmc_retune_hold(host);
}
}Quoted 4 lines
but it is not taken into account while making the tuning
decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84
Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>--- drivers/mmc/core/host.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0
drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host)bool return_to_hs400 = false;int err; +if (host->hold_retune >=1 ) +return 0 ;
No, hold_retune is set *before* the command *after* which tuning is not permitted.
Quoted 7 lines
drivers/mmc/core/host.c +1
-0+if (host->retune_now) host->retune_now =0 ;else Signature · 1 line
2.34.1
Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
Hi Adrian,
Thank you for response.
Quoted 22 lines · Shyam Saini
Quoted 5 lines
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introducedNo,
mmc_retune_pause()is used:/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
voidmmc_retune_pause(struct mmc_host *host){ if (!host->retune_paused) { host->retune_paused = 1; mmc_retune_needed(host); mmc_retune_hold(host); } }
Quoted 8 lines
Quoted 4 lines
but it is not taken into account while making the tuning
decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Yes, we are able to retune.
In fact this bug occurs when we iteratively switch to RPMB partition.
May be related to this, we also observed that in __mmc_blk_ioctl_cmd function in line 487[1] part_index is assigned target_part variable and on the next line EXT_CSD_PART_CONFIG_ACC_RPMB OR'ed to the target_part variable.
In mmc_blk_part_switch_pre function line 831 [2], part_type variable is compared to EXT_CSD_PART_CONFIG_ACC_RPMB without taking into account that the part_index variable is also OR'ed and its not separated before the comparision.
Same thing happens in mmc_blk_part_switch_post function.
Is it expected to be this way?, please let me know.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n487
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n831
Quoted 55 lines
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>--- drivers/mmc/core/host.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host)bool return_to_hs400 = false;int err; +if (host->hold_retune >=1 ) +return 0 ;No,
hold_retuneis set *before* the command *after* which tuning is not permitted.Quoted 7 lines
drivers/mmc/core/host.c +1
-1+if (host->retune_now) host->retune_now =0 ;else --2.34.1
Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
Quoted 45 lines · Shyam Saini
Hi Adrian,
Thank you for response.
Quoted 22 lines · Shyam Saini
Quoted 5 lines
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introducedNo,
mmc_retune_pause()is used:/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
voidmmc_retune_pause(struct mmc_host *host)
{
if (!host->retune_paused) {
host->retune_paused= 1;
mmc_retune_needed(host);
mmc_retune_hold(host);
}
}Quoted 8 lines
Quoted 4 lines
but it is not taken into account while making the tuning decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Yes, we are able to retune.
In fact this bug occurs when we iteratively switch to RPMB partition.
May be related to this, we also observed that in
__mmc_blk_ioctl_cmdfunction in line 487[1]part_indexis assignedtarget_partvariable and on the next lineEXT_CSD_PART_CONFIG_ACC_RPMBOR'ed to thetarget_partvariable.
Quoted 8 lines
In
mmc_blk_part_switch_prefunction line 831 [2],part_typevariable is compared toEXT_CSD_PART_CONFIG_ACC_RPMBwithout taking into account that thepart_indexvariable is also OR'ed and its not separated before the comparision.Same thing happens in
mmc_blk_part_switch_postfunction.Is it expected to be this way?, please let me know.
According to the spec, there can only be 1 RPMB partition, so the comment and code are not very meaningful.
AFAICT rpmb->part_index is set to EXT_CSD_PART_CONFIG_ACC_RPMB anyway, originally by mmc_decode_ext_csd():
/*
* RPMB regions are defined in multiples of 128K.
*/
card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT];
if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) {
mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,
EXT_CSD_PART_CONFIG_ACC_RPMB,
"rpmb", 0, false,
MMC_BLK_DATA_AREA_RPMB);
}So the OR has no effect.
As for "mmc_hs400_to_hs200 failed, error -84", I suggest enabling some dynamic debug messages to determine what command is getting an error and what the I/O state (as per mmc_set_ios()) is.
Quoted 59 lines
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n487
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n831Quoted 55 lines
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>---
drivers/mmc/core/host.c | 3 +++1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host) bool return_to_hs400 = false; int err; + if (host->hold_retune >= 1) + return 0;No,
hold_retuneis set *before* the command *after* which tuning is not permitted.Quoted 7 lines
drivers/mmc/core/host.c +1
-0+ if (host->retune_now) host->retune_now = 0;else
Signature · 1 line
2.34.1Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
Quoted 72 lines · Adrian Hunter
Quoted 45 lines · Shyam Saini
Hi Adrian,
Thank you for response.
Quoted 22 lines · Shyam Saini
Quoted 5 lines
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introducedNo,
mmc_retune_pause()is used:/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
voidmmc_retune_pause(struct mmc_host *host)
{
if (!host->retune_paused) {
host->retune_paused= 1;
mmc_retune_needed(host);
mmc_retune_hold(host);
}
}Quoted 8 lines
Quoted 4 lines
but it is not taken into account while making the tuning decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Yes, we are able to retune.
In fact this bug occurs when we iteratively switch to RPMB partition.
May be related to this, we also observed that in
__mmc_blk_ioctl_cmdfunction in line 487[1]part_indexis assignedtarget_partvariable and on the next lineEXT_CSD_PART_CONFIG_ACC_RPMBOR'ed to thetarget_partvariable.Quoted 8 lines
In
mmc_blk_part_switch_prefunction line 831 [2],part_typevariable is compared toEXT_CSD_PART_CONFIG_ACC_RPMBwithout taking into account that thepart_indexvariable is also OR'ed and its not separated before the comparision.Same thing happens in
mmc_blk_part_switch_postfunction.Is it expected to be this way?, please let me know.
According to the spec, there can only be 1 RPMB partition, so the comment and code are not very meaningful.
AFAICT
rpmb->part_indexis set toEXT_CSD_PART_CONFIG_ACC_RPMBanyway, originally bymmc_decode_ext_csd():/* * RPMB regions are defined in multiples of 128K. */ card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT]; if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) { mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17, EXT_CSD_PART_CONFIG_ACC_RPMB, "rpmb", 0, false, MMC_BLK_DATA_AREA_RPMB); }
Quoted 1 line
So the OR has no effect.
Thank you for the insight.
Quoted 5 lines
As for "
mmc_hs400_to_hs200failed, error -84", I suggest enabling some dynamic debug messages to determine what command is getting an error and what the I/O state (as permmc_set_ios()) is.
As per your suggestion I enabled dynamic debug messages and added few more statements just to check current partition. It seems like it fails after the CMD6 is started in the retuning code path.
The partition seems to be non-RPMB when this happens.
Snipet from the dmesg logs:
[ 92.573713] mmc_request_done: mmc0: req done <CMD23>: 0: 00000000 00000000 00000000 00000000 [ 92.573715] mmc_request_done: mmc0: req done (CMD18): 0: 00000900 00000000 00000000 00000000 [ 92.573718] mmc_request_done: mmc0: 512 bytes transferred: 0 [ 92.573727] mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573740] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.573747] mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000 [ 92.573754] =====>>>>>>>>>>> part_type is Non RPMB <<<<<<============== [ 92.573758] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b30001 flags 0000049d [ 92.573768] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.573867] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.573872] mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.573882] mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573892] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.573900] mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000 [ 92.574246] =====>>>>>>>>>>> part_type is RPMB [ 92.574251] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b30301 flags 0000049d [ 92.574253] ============>>>>>>>>>>>>>>> just before mmc_hs400_to_hs200 [ 92.574256] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 10 [ 92.574262] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574272] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574300] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574307] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b90101 flags 0000049d [ 92.574321] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.574326] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574331] mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.574343] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 8 [ 92.574349] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574360] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574367] mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.574378] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001
full logs are available here [1]
If we look at complete logs [1] it seems there isn't any tuning related error initially, but it occurs after few iterations of accessing RPMB partition.
[1] https://pastebin.ubuntu.com/p/9ZzYd4gfhj/plain/
Best Regards,
Shyam
Quoted 59 lines
Quoted 58 lines
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n487
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n831Quoted 55 lines
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>---
drivers/mmc/core/host.c | 3 +++1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host) bool return_to_hs400 = false; int err; + if (host->hold_retune >= 1) + return 0;No,
hold_retuneis set *before* the command *after* which tuning is not permitted.Quoted 7 lines
drivers/mmc/core/host.c +1
-0+ if (host->retune_now) host->retune_now = 0;else
--
2.34.1Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
Quoted 92 lines · Shyam Saini
Quoted 72 lines · Adrian Hunter
Quoted 45 lines · Shyam Saini
Hi Adrian,
Thank you for response.
Quoted 22 lines · Shyam Saini
Quoted 5 lines
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introducedNo,
mmc_retune_pause()is used:/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
voidmmc_retune_pause(struct mmc_host *host)
{
if (!host->retune_paused) {
host->retune_paused= 1;
mmc_retune_needed(host);
mmc_retune_hold(host);
}
}Quoted 8 lines
Quoted 4 lines
but it is not taken into account while making the tuning decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Yes, we are able to retune.
In fact this bug occurs when we iteratively switch to RPMB partition.
May be related to this, we also observed that in
__mmc_blk_ioctl_cmdfunction in line 487[1]part_indexis assignedtarget_partvariable and on the next lineEXT_CSD_PART_CONFIG_ACC_RPMBOR'ed to thetarget_partvariable.Quoted 8 lines
In
mmc_blk_part_switch_prefunction line 831 [2],part_typevariable is compared toEXT_CSD_PART_CONFIG_ACC_RPMBwithout taking into account that thepart_indexvariable is also OR'ed and its not separated before the comparision.Same thing happens in
mmc_blk_part_switch_postfunction.Is it expected to be this way?, please let me know.
According to the spec, there can only be 1 RPMB partition, so the comment and code are not very meaningful.
AFAICT
rpmb->part_indexis set toEXT_CSD_PART_CONFIG_ACC_RPMBanyway, originally bymmc_decode_ext_csd():/*
* RPMB regions are defined in multiples of 128K.
*/
card->ext_csd.raw_rpmb_size_mult= ext_csd[EXT_CSD_RPMB_MULT]; if (ext_csd[EXT_CSD_RPMB_MULT] &&mmc_host_cmd23(card->host)) { mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,EXT_CSD_PART_CONFIG_ACC_RPMB,
"rpmb", 0, false,
MMC_BLK_DATA_AREA_RPMB);
}Quoted 1 line
So the OR has no effect.
Thank you for the insight.
Quoted 5 lines
As for "
mmc_hs400_to_hs200failed, error -84", I suggest enabling some dynamic debug messages to determine what command is getting an error and what the I/O state (as permmc_set_ios()) is.As per your suggestion I enabled dynamic debug messages and added few more statements just to check current partition. It seems like it fails after the CMD6 is started in the retuning code path.
The partition seems to be non-RPMB when this happens.
Snipet from the dmesg logs:
Quoted 7 lines
[ 92.573713]
mmc_request_done: mmc0: req done <CMD23>: 0: 00000000 00000000 00000000 00000000 [ 92.573715]mmc_request_done: mmc0: req done (CMD18): 0: 00000900 00000000 00000000 00000000 [ 92.573718]mmc_request_done: mmc0: 512 bytes transferred: 0
[ 92.573727]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573740]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573747]mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000 [ 92.573754] =====>>>>>>>>>>>part_typeis Non RPMB <<<<<<==============
eMMC partition is RPMB and about to switch to the main partition.
Quoted 7 lines
[ 92.573758]
mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b30001flags0000049d[ 92.573768]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573867]sdhci_irq: mmc0: sdhci: IRQ status0x00000002
[ 92.573872]mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.573882]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573892]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573900]mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000
eMMC partition is the main partition, needing to switch to RPMB.
Quoted 8 lines
[ 92.574246] =====>>>>>>>>>>>
part_typeis RPMB
[ 92.574251]mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b30301flags0000049d
[ 92.574253] ============>>>>>>>>>>>>>>> just beforemmc_hs400_to_hs200
[ 92.574256]mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 10 [ 92.574262]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574272]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574300]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574307]mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b90101flags0000049d
Quoted 8 lines
[ 92.574321]
sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.574326]sdhci_irq: mmc0: sdhci: IRQ status0x00000002
[ 92.574331]mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.574343]mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 8 [ 92.574349]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574360]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574367]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195
[ 92.574378]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
The commands above are done when the eMMC partition is the main partition.
Quoted 9 lines
full logs are available here [1]
If we look at complete logs [1] it seems there isn't any tuning related error initially, but it occurs after few iterations of accessing RPMB partition.
It would be easier for me if you just attach logs
especially when they are so small.
[ 92.574246] =====>>>>>>>>>>> part_type is RPMB
eMMC partition is the main partition
[ 92.574251] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b30301 flags 0000049d
CMD6 is being processed by mmc core, but it has not been issued to the card. The commands below are issued to the eMMC main partition.
[ 92.574253] ============>>>>>>>>>>>>>>> just before mmc_hs400_to_hs200 [ 92.574256] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 10 [ 92.574262] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574272] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574300] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000
Frequency has dropped to 52 MHz
[ 92.574307] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b90101 flags 0000049d [ 92.574321] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.574326] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574331] mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000
Successful switch from HS400 to DDR52 mode
[ 92.574343] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 8 [ 92.574349] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574360] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574367] mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.574378] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.574385] mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000
CMD13 has been done successfully which checks it is still working.
Now attempting bus width switch from DDR to SDR:
[ 92.574394] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b70201 flags 0000049d
All the errors in the log are coming from this switch command, which is issued when the eMMC partition is the main partition.
[ 92.574407] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574415] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574431] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying...
Probably some settings are not configured correctly for DDR52 mode at this point.
I don't remember if I asked this already, which driver is it?
[ 92.574444] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574449] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574465] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying... [ 92.574479] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574484] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574500] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying... [ 92.574513] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574517] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574527] mmc_request_done: mmc0: req done (CMD6): -84: 00000000 00000000 00000000 00000000 [ 92.574536] mmc0: mmc_hs400_to_hs200 failed, error -84 [ 92.579677] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying...
Quoted 64 lines
Best Regards,
ShyamQuoted 59 lines
Quoted 58 lines
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n487
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n831Quoted 55 lines
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>---
drivers/mmc/core/host.c | 3 +++1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host) bool return_to_hs400 = false; int err; + if (host->hold_retune >= 1) + return 0;No,
hold_retuneis set *before* the command *after* which tuning is not permitted.Quoted 7 lines
drivers/mmc/core/host.c +1
-0+ if (host->retune_now) host->retune_now = 0;else
Signature · 1 line
2.34.1Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 105 lines · Shyam Saini
Quoted 101 lines · Adrian Hunter
Quoted 99 lines · Shyam Saini
Quoted 72 lines · Adrian Hunter
Quoted 45 lines · Shyam Saini
Hi Adrian,
Thank you for response.
Quoted 22 lines · Shyam Saini
Quoted 5 lines
As per the JEDEC spec, tuning(command CMD21) is not allowed in RPMB partition.
To avoid retuning while switching to RPMB,
hold_retunevariable was introducedNo,
mmc_retune_pause()is used:/*
* Pause re-tuning for a small set of operations. The pause begins after the
* next command and after first doing re-tuning.
*/
voidmmc_retune_pause(struct mmc_host *host)
{
if (!host->retune_paused) {
host->retune_paused= 1;
mmc_retune_needed(host);
mmc_retune_hold(host);
}
}Quoted 8 lines
Quoted 4 lines
but it is not taken into account while making the tuning decision. As a consequence of this, mmc driver aborts while switching to RPMB partition:
mmc0:mmc_hs400_to_hs200failed, error -84Do you normally re-tune at all? It could just be that re-tuning doesn't work.
Yes, we are able to retune.
In fact this bug occurs when we iteratively switch to RPMB partition.
May be related to this, we also observed that in
__mmc_blk_ioctl_cmdfunction in line 487[1]part_indexis assignedtarget_partvariable and on the next lineEXT_CSD_PART_CONFIG_ACC_RPMBOR'ed to thetarget_partvariable.Quoted 8 lines
In
mmc_blk_part_switch_prefunction line 831 [2],part_typevariable is compared toEXT_CSD_PART_CONFIG_ACC_RPMBwithout taking into account that thepart_indexvariable is also OR'ed and its not separated before the comparision.Same thing happens in
mmc_blk_part_switch_postfunction.Is it expected to be this way?, please let me know.
According to the spec, there can only be 1 RPMB partition, so the comment and code are not very meaningful.
AFAICT
rpmb->part_indexis set toEXT_CSD_PART_CONFIG_ACC_RPMBanyway, originally bymmc_decode_ext_csd():/*
* RPMB regions are defined in multiples of 128K.
*/
card->ext_csd.raw_rpmb_size_mult= ext_csd[EXT_CSD_RPMB_MULT]; if (ext_csd[EXT_CSD_RPMB_MULT] &&mmc_host_cmd23(card->host)) { mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,EXT_CSD_PART_CONFIG_ACC_RPMB,
"rpmb", 0, false,
MMC_BLK_DATA_AREA_RPMB);
}Quoted 1 line
So the OR has no effect.
Thank you for the insight.
Quoted 5 lines
As for "
mmc_hs400_to_hs200failed, error -84", I suggest enabling some dynamic debug messages to determine what command is getting an error and what the I/O state (as permmc_set_ios()) is.As per your suggestion I enabled dynamic debug messages and added few more statements just to check current partition. It seems like it fails after the CMD6 is started in the retuning code path.
The partition seems to be non-RPMB when this happens.
Snipet from the dmesg logs:
[ 92.573713]
mmc_request_done: mmc0: req done <CMD23>: 0: 00000000 00000000 00000000 00000000 [ 92.573715]mmc_request_done: mmc0: req done (CMD18): 0: 00000900 00000000 00000000 00000000 [ 92.573718]mmc_request_done: mmc0: 512 bytes transferred: 0
[ 92.573727]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573740]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573747]mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000 [ 92.573754] =====>>>>>>>>>>>part_typeis Non RPMB <<<<<<==============
Quoted 3 lines
Quoted 2 lines
eMMC partition is RPMB and about to switch to the main partition.
yes, Thank you. I overlooked it initially
Quoted 37 lines
Quoted 37 lines
Quoted 8 lines
[ 92.573758]
mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b30001flags0000049d[ 92.573768]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573867]sdhci_irq: mmc0: sdhci: IRQ status0x00000002
[ 92.573872]mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.573882]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.573892]sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.573900]mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000eMMC partition is the main partition, needing to switch to RPMB.
Quoted 8 lines
[ 92.574246] =====>>>>>>>>>>>
part_typeis RPMB
[ 92.574251]mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b30301flags0000049d
[ 92.574253] ============>>>>>>>>>>>>>>> just beforemmc_hs400_to_hs200
[ 92.574256]mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 10 [ 92.574262]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574272]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574300]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574307]mmc_mrq_pr_debug: mmc0: starting CMD6 arg03b90101flags0000049dQuoted 8 lines
[ 92.574321]
sdhci_irq: mmc0: sdhci: IRQ status0x00000001
[ 92.574326]sdhci_irq: mmc0: sdhci: IRQ status0x00000002
[ 92.574331]mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000 [ 92.574343]mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 8 [ 92.574349]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574360]esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574367]mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195
[ 92.574378]sdhci_irq: mmc0: sdhci: IRQ status0x00000001The commands above are done when the eMMC partition is the main partition.
Quoted 5 lines
full logs are available here [1]
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
If we look at complete logs [1] it seems there isn't any tuning related error initially, but it occurs after few iterations of accessing RPMB partition.
It would be easier for me if you just attach logs
especially when they are so small.
sure.
Quoted 41 lines
Quoted 41 lines
[ 92.574246] =====>>>>>>>>>>> part_type is RPMBeMMC partition is the main partition
[ 92.574251] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b30301 flags 0000049dCMD6 is being processed by mmc core, but it has not been issued to the card. The commands below are issued to the eMMC main partition.
[ 92.574253] ============>>>>>>>>>>>>>>> just before mmc_hs400_to_hs200 [ 92.574256] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 10 [ 92.574262] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574272] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574300] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000Frequency has dropped to 52 MHz
[ 92.574307] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b90101 flags 0000049d [ 92.574321] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.574326] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574331] mmc_request_done: mmc0: req done (CMD6): 0: 00000800 00000000 00000000 00000000Successful switch from HS400 to DDR52 mode
[ 92.574343] mmc_set_ios: mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 8 timing 8 [ 92.574349] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574360] esdhc_of_set_clock: sdhci-esdhc 2150000.esdhc: desired SD clock: 52000000, actual: 50000000 [ 92.574367] mmc_mrq_pr_debug: mmc0: starting CMD13 arg 00010000 flags 00000195 [ 92.574378] sdhci_irq: mmc0: sdhci: IRQ status 0x00000001 [ 92.574385] mmc_request_done: mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000CMD13 has been done successfully which checks it is still working.
Now attempting bus width switch from DDR to SDR:
[ 92.574394] mmc_mrq_pr_debug: mmc0: starting CMD6 arg 03b70201 flags 0000049dAll the errors in the log are coming from this switch command, which is issued when the eMMC partition is the main partition.
Quoted 7 lines
Quoted 7 lines
[ 92.574407] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574415] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574431] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying...Probably some settings are not configured correctly for DDR52 mode at this point.
Do you have any suggestions for me to check any related settings/properties, please let me know.
Quoted 1 line
Quoted 1 line
I don't remember if I asked this already, which driver is it?
This is Freescale eSDHC controller driver.
Quoted 79 lines
Quoted 79 lines
[ 92.574444] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574449] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574465] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying... [ 92.574479] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574484] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574500] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying... [ 92.574513] sdhci_irq: mmc0: sdhci: IRQ status 0x000a0001 [ 92.574517] sdhci_irq: mmc0: sdhci: IRQ status 0x00000002 [ 92.574527] mmc_request_done: mmc0: req done (CMD6): -84: 00000000 00000000 00000000 00000000 [ 92.574536] mmc0: mmc_hs400_to_hs200 failed, error -84 [ 92.579677] mmc_wait_for_req_done: mmc0: req failed (CMD6): -84, retrying...Quoted 64 lines
Best Regards,
ShyamQuoted 59 lines
Quoted 58 lines
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n487
[2] https://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git/tree/drivers/mmc/core/block.c?h=next#n831Quoted 55 lines
Quoted 16 lines
To fix this, take
hold_retunevariable into account while making retune decision inmmc_retune()function.Fixes 57da0c042f4a ("mmc: block: Pause re-tuning while switched to the RPMB partition")Reported-by Judy Wang <[email protected]>Signed-off-by Shyam Saini <[email protected]>---
drivers/mmc/core/host.c | 3 +++1 file changed, 3 insertions(+)drivers/mmc/core/host.c +0
-0drivers/mmc/core/host.c int mmc_retune(struct mmc_host *host) · line 185
Quoted 5 lines
drivers/mmc/core/host.c +2
-0@@ -181,6 +181,9 @@ int mmc_retune(struct mmc_host *host) bool return_to_hs400 = false; int err; + if (host->hold_retune >= 1) + return 0;No,
hold_retuneis set *before* the command *after* which tuning is not permitted.Quoted 7 lines
drivers/mmc/core/host.c +1
-0+ if (host->retune_now) host->retune_now = 0;else
--
2.34.1Quoted 20 lines · Shyam Saini
Hi All,
Cc'ing Tyler
Please note that I am not 100 % sure about the fix.
This issue is reproducible without this patch and the patch at least fix the issue without any regressions on our side.We observed that
hold_retuneis always greater or equal to 1 inmmc_retune()function,so it may always avoid re-tuning when it is actually needed and there may
be a better fix for the issue.
Please let me know your any feedback or comments.
Best Regards,
Shyam