If the version and low/high capabilities flags of a sdcard controller are invalid (0xFFFF), assume the controller address is invalid, and exit setup before attempting to reset the controller, which would introduce an unnecessary delay, since the reset would ultimately fail after timing out.
This eliminates the delay in displaying the boot menu message on Baytrail ChromeOS devices, where multiple /etc/sdcard entries are present in a single payload to cover the range of eMMC controller addresses used.
Signed-off-by: Matt DeVillier matt.devillier@gmail.com --- src/hw/sdcard.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c index 38d05c4..e6090b8 100644 --- a/src/hw/sdcard.c +++ b/src/hw/sdcard.c @@ -486,9 +486,13 @@ sdcard_controller_setup(struct sdhci_s *regs, int prio) if (!(present_state & SP_CARD_INSERTED)) // No card present return; - dprintf(3, "sdhci@%p ver=%x cap=%x %x\n", regs - , readw(®s->controller_version) - , readl(®s->cap_lo), readl(®s->cap_hi)); + u16 ver = readw(®s->controller_version); + u32 cap_lo = readl(®s->cap_lo); + u32 cap_hi = readl(®s->cap_hi); + dprintf(3, "sdhci@%p ver=%x cap=%x %x\n", regs, ver, cap_lo, cap_hi); + if (ver == 0xffff && cap_lo == 0xffffffff && cap_hi == 0xffffffff) + //invalid controller address + return; sdcard_reset(regs, SRF_ALL); writew(®s->irq_signal, 0); writew(®s->irq_enable, 0x01ff);
On Wed, Mar 16, 2016 at 08:53:09PM -0500, Matt DeVillier wrote:
If the version and low/high capabilities flags of a sdcard controller are invalid (0xFFFF), assume the controller address is invalid, and exit setup before attempting to reset the controller, which would introduce an unnecessary delay, since the reset would ultimately fail after timing out.
This eliminates the delay in displaying the boot menu message on Baytrail ChromeOS devices, where multiple /etc/sdcard entries are present in a single payload to cover the range of eMMC controller addresses used.
Signed-off-by: Matt DeVillier matt.devillier@gmail.com
I think this is a good idea, but I don't think we can rely on the memory having all 0xff. At a minimum I think 0x00 should be checked for as well, but ideally the controller would have a signature we could check.
BTW, the patch got white-space mangled.
-Kevin