From nobody Tue Feb 07 13:27:21 2023 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PB3p43dbKz3mymb for ; Tue, 7 Feb 2023 13:27:24 +0000 (UTC) (envelope-from jsihv@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PB3p32VB9z3MJ9 for ; Tue, 7 Feb 2023 13:27:23 +0000 (UTC) (envelope-from jsihv@gmx.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of jsihv@gmx.com designates 212.227.15.19 as permitted sender) smtp.mailfrom=jsihv@gmx.com; dmarc=pass (policy=none) header.from=gmx.com Received: from [84.249.142.187] ([84.249.142.187]) by web-mail.gmx.net (3c-app-mailcom-bs06.server.lan [172.19.170.174]) (via HTTP); Tue, 7 Feb 2023 14:27:21 +0100 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Message-ID: From: JMT Sihvola To: freebsd-riscv@FreeBSD.org Subject: Investigating jh7100 (VisionFive) MMC issue Content-Type: text/plain; charset=UTF-8 Date: Tue, 7 Feb 2023 14:27:21 +0100 Importance: normal Sensitivity: Normal Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-Provags-ID: V03:K1:8qjYHXQL6f+593o+HMqo8Q0ybWO55P/S9x/Q9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VfTlgK fSzrihO9dCJyhwaqqjWj0paxaJYxcrT8H5T2DsxXVvBDClb3FsQ6ds48TI/Hog1zIc+NjBzFR V6dCEqRO4T1tbMZtaykyiY8A== X-Spamd-Result: default: False [-2.50 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[gmx.com,none]; R_SPF_ALLOW(-0.20)[+ip4:212.227.15.0/24]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[212.227.15.19:from]; NEURAL_HAM_SHORT(-0.10)[-0.096]; FREEMAIL_ENVFROM(0.00)[gmx.com]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MLMMJ_DEST(0.00)[freebsd-riscv@FreeBSD.org]; HAS_X_PRIO_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[212.227.15.19:from]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_FROM(0.00)[gmx.com]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4PB3p32VB9z3MJ9 X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N 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