Date: Tue, 7 Feb 2023 14:27:21 +0100 From: JMT Sihvola <jsihv@gmx.com> To: freebsd-riscv@FreeBSD.org Subject: Investigating jh7100 (VisionFive) MMC issue Message-ID: <trinity-4b69d1d1-615d-40c5-a186-14ea7a98c1f5-1675776441517@3c-app-mailcom-bs06>
next in thread | raw e-mail | index | archive | help
Hello, Here is a description of my efforts to investigate what is missing from=20 jh7100 (VisionFive) MMC host driver -- the driver file is here: https://github=2Ecom/mhorne/freebsd/blob/beaglev/sys/riscv/ starfive/starfive_if_dwc=2Ec I use device trees provided in Linux repository: https://github=2Ecom/starfive-tech/linux/blob/ 594a662ba20ee2234e2c09a4b25d79f8fb99cfef/arch/riscv/boot/dts/starfive/ I also have my own GPIO and reset drivers in use plus one clock added=2E These may affect the boot process=2E Ask me if interested=2E -- Without "sc->use_pio =3D 1" in dwmmc_starfive=2Ec the execution halts at m= sleep() call which is located in the file sys/dev/mmc/mmc=2Ec It seems that it remains waiting for an external event which never occurs= =2E After switching pio mode on (like is done in several other board specific dwmmc driver codes) booting does not stall anymore but we get an error mes= sage: mmcsd0: Error indicated: 4 Failed Possibly related to this error =E2=80=93 which appears multiple times duri= ng the boot =E2=80=93 mountroot fails (error 19) Using printfs to track the execution suggests that the earlier manifestati= on of mmscd0's error 4 happens in the function dwmmc_intr() which is found in a = file sys/dev/mmc/host/dwmmc=2Ec=2E The error number 4 matches to this error cod= e (MMC_ERR_FAILED defined in mmcreg=2Eh) and printfs rule out other places w= here the same error is assigned=2E Printing opcodes and register data out at this point indicates that opcode= s used when the error manifests are 17, MMC_READ_SINGLE_BLOCK and 18, MMC_READ_MULTIPLE_BLOCK and MINTSTS register has bits 3 and 7 on=2E These = bits indicate data_transfer_over_interrupt and data_crc_error_interrupt accordi= ng to two datasheets I've found=2E So it looks like there is a CRC error=2E= =20 Printfs reveal that during the boot many data packets are transferred=2E CRC error appears with some of these=2E Data packets transfered during the boot consists of 3735929054 sequences (0xDEADC0DE), only tails of transfers may be different: example 1: =2E=2E=2E 3735929054 8309528 4294967232 9 example 2: =2E=2E=2E 3735929054 8313624 4294967232 3735929054 Curiously sometimes the very last row is another 3735929054 sequence inste= ad of 9 (example 2) but this difference is seen between different boots and conc= erns all the transfers instead of marking a difference between error indicating= and non-error indicating transfers=2E The quantity of data transferred seems to be always correct (=2E=2E=2Eat l= east if value 9 is not an error) Printing out all the possible variables related to these data transfers (s= truct mmc_command) does not seem to reveal much differences between error giving= and non-error giving transfers=2E Only suspectible variable I have found is "a= rg" variable=2E It is usually 0 and sometimes 2 when the error occurs=2E With = errorless transfers (when opcodes are 17, 18) these values seem not to appear=2E Tracking this arg variable takes us to function mmcsd_rw() in file mmscd= =2Ec=2E There arg gets its value from bp->bio_pblkno (physical block address) via "block" variable=2E This argument comes from function's parameter struct b= io *bp=2E Ultimately the origin of this value seems to lie in the struct bio's bio_o= ffset which is initialised somewhere in geom system (files like geom_slice=2Ec, geom_disk=2Ec) Might this path be worth of studying further=2E=2E=2E Another hypothesis is that the error is related to bus/clock rates: fedora linux boot prints: [ 3=2E071120] mmc_host mmc0: Bus speed (slot 0) =3D 100000000Hz (slot req 400000Hz, actual 400000HZ div =3D 125) [ 3=2E168274] mmc_host mmc0: Bus speed (slot 0) =3D 100000000Hz (slot req 50000000Hz, actual 50000000HZ div =3D 1) [ 9=2E240888] mmc_host mmc1: Bus speed (slot 0) =3D 123750000Hz (slot req 400000Hz, actual 399193HZ div =3D 155) [ 9=2E398503] mmc_host mmc1: Bus speed (slot 0) =3D 123750000Hz (slot req 50000000Hz, actual 30937500HZ div =3D 2) freebsd boot prints (with my own printfs): dwmmc_setup_bus(), div: 1, bus_hz: 100000000, freq: 50000000 dwmmc_setup_bus(), div: 125, bus_hz: 100000000, freq: 400000 dwmmc_setup_bus(), div: 155, bus_hz: 123750000, freq: 400000 It seems one combination of rates is missing from FreeBSD (or the booting simply doesn't proceed far enough?) =2E=2E=2Ethough it's related to mmc1 w= hile the relevant action seems to take place in mmc0=2E I wonder if those rates seen are actually supported by FreeBSD=2E In some = previous cases FreeBSD has used different rates to linux due to less extensive driv= ers=2E So here's where I currently stand=2E Tips are welcome=2E --=20 Jari Sihvola <jsihv at gmx=2Ecom>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?trinity-4b69d1d1-615d-40c5-a186-14ea7a98c1f5-1675776441517>