Daily Archives: 2017-05-29

VoCore2: Fix microSD randomly umount issue

The day before yesterday I released a firmware fixed the microSD randomly umount issue. Now let me explain how it works. (Lastest Firmware: Link)

People report this issue: they find the following log in console when they trying to using microSD.

[ 112.750000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.750000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.760000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.770000] msdc-1 -> cmd card power PID<kworker/u2:1>
[ 112.780000] mmc0: card aaaa removed
[ 112.800000] EXT4-fs error (device mmcblk0p1): ext4_wait_block_bitmap:494: comm kworker/u2:3: Cannot read block bitmap - block_group = 0, block_bitmap = 475
[ 112.820000] EXT4-fs warning (device mmcblk0p1): ext4_end_bio:317: I/O error -5 writing to inode 12 (offset 0 size 4194304 starting block 34175)
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33792
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33793
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33794
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33795
[ 112.820000] Buffer I/O error on device mmcblk0p1, logical block 33796

microSD is umount randomly and microSD card can not use at all.

After some research, I find it is caused by microSD driver. VoCore2 do not have CD(card detect pin), but driver use that pin for card detect, even we already set “cd-poll” and “broken-cd” in VOCORE2.dts, but looks like the mmc driver did not code such flag.

I have to make a patch to fix it.


--- a/drivers/mmc/host/mtk-mmc/sd.c
+++ b/drivers/mmc/host/mtk-mmc/sd.c
@@ -580,6 +580,7 @@
inserted = (status & MSDC_PS_CDSTS) ? 0 : 1;
else
inserted = (status & MSDC_PS_CDSTS) ? 1 : 0;
+ inserted = 1;
}

#if 0
@@ -2328,6 +2329,7 @@
present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 0 : 1;
else
present = (sdr_read32(MSDC_PS) & MSDC_PS_CDSTS) ? 1 : 0;
+ present = 1;
host->card_inserted = present;
#endif
spin_unlock_irqrestore(&host->lock, flags);

This upper code force the driver always “believe” the microSD is inserted, so the float CD pin will not randomly unmount microSD card, and let cd-polling do the real card-detect work. 🙂