mmc: core: improve fallback in mmc_select_timing()
PATCH 1/1 mmc: core: improve fallback in mmc_select_timing()
I have a system (cheap Amlogic S905W based TV box) where the eMMC chip refuses to switch to HS200 timing. That's not nice, but my bigger problem is that the system then falls back to the very slow default mode, even though DDR52 is supported and works well.
Therefore, if setting a mode fails with EBADMSG (switch error), try the next (in descending performance order) mode instead of immediately falling back to the slowest mode.
With the patch it looks like this on my system:
mmc1: mmc_select_hs200 failed, error -74
mmc1: new DDR MMC card at address 0001
mmcblk1: mmc1:0001 DG4008 7.28 GiB
--- drivers/mmc/core/mmc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/mmc/core/mmc.c +15 -3
@@ -1523,11 +1523,23 @@ static int mmc_select_timing(struct mmc_card *card)if (!mmc_can_ext_csd (card)) goto bus_speed; -if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS400ES ) +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS400ES ) { err =mmc_select_hs400es (card); -else if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS200 ) +if (!err) + goto bus_speed; +if (err != -EBADMSG ) +return err; + } + +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS200 ) { err =mmc_select_hs200 (card); -else if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS ) +if (!err) + goto bus_speed; +if (err != -EBADMSG ) +return err; + } + +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS ) err =mmc_select_hs (card);if (err && err != -EBADMSG )
Signature · 1 line
2.35.1
Quoted 10 lines · Heiner Kallweit
I have a system (cheap Amlogic S905W based TV box) where the eMMC chip refuses to switch to HS200 timing. That's not nice, but my bigger problem is that the system then falls back to the very slow default mode, even though DDR52 is supported and works well.
Therefore, if setting a mode fails with EBADMSG (switch error), try the next (in descending performance order) mode instead of immediately falling back to the slowest mode.
Quoted 6 lines
With the patch it looks like this on my system:
mmc1:
mmc_select_hs200failed, error -74
mmc1: new DDR MMC card at address 0001
mmcblk1: mmc1:0001 DG4008 7.28 GiB
Overall, I think the approach seems very much reasonable!
Although, I want to have a closer look at the impact on the different scenarios, as mmc_select_timing() is being called during power management and reset too.
Allow me a day or so, then I will get back to this, either with some more detailed suggestions or I may post a patch.
Kind regards
Uffe
Quoted 39 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/mmc/core/mmc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)drivers/mmc/core/mmc.c +15
-4@@ -1523,11 +1523,23 @@ static int mmc_select_timing(struct mmc_card *card)if (!mmc_can_ext_csd (card)) goto bus_speed; -if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS400ES ) +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS400ES ) { err =mmc_select_hs400es (card); -else if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS200 ) +if (!err) + goto bus_speed; +if (err != -EBADMSG ) +return err; + } + +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS200 ) { err =mmc_select_hs200 (card); -else if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS ) +if (!err) + goto bus_speed; +if (err != -EBADMSG ) +return err; + } + +if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS ) err =mmc_select_hs (card);if (err && err != -EBADMSG ) --2.35.1