From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 344E2C77B7A for ; Tue, 13 Jun 2023 06:52:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80AAC85E44; Tue, 13 Jun 2023 08:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 2A97284988; Tue, 13 Jun 2023 08:52:53 +0200 (CEST) Received: from mx1.tinet.cat (smtp.altanet.org [195.76.233.59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D802B85E44 for ; Tue, 13 Jun 2023 08:52:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xdrudis@tinet.cat X-ASG-Debug-ID: 1686639168-12aaf22e9734f0d0001-4l7tJC Received: from smtp01.tinet.cat (smtp.tinet.org [195.77.216.131]) by mx1.tinet.cat with ESMTP id DY4hAZPpkfKCTS4x; Tue, 13 Jun 2023 08:52:48 +0200 (CEST) X-Barracuda-Envelope-From: xdrudis@tinet.cat X-Barracuda-Effective-Source-IP: smtp.tinet.org[195.77.216.131] X-Barracuda-Apparent-Source-IP: 195.77.216.131 Received: from xdrudis.tinet.cat (180.red-79-152-181.dynamicip.rima-tde.net [79.152.181.180]) by smtp01.tinet.cat (Postfix) with ESMTPSA id 918BB605DE40; Tue, 13 Jun 2023 08:52:48 +0200 (CEST) Date: Tue, 13 Jun 2023 08:52:47 +0200 From: Xavier Drudis Ferran To: Marek Vasut Cc: Xavier Drudis Ferran , u-boot@lists.denx.de, Simon Glass , Lukasz Majewski , Sean Anderson Subject: Re: [SPAM] Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command Message-ID: X-ASG-Orig-Subj: Re: [SPAM] Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command References: <78623f65-0cb5-fad8-7a85-f7370dda022c@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Barracuda-Connect: smtp.tinet.org[195.77.216.131] X-Barracuda-Start-Time: 1686639168 X-Barracuda-URL: https://webmail.tinet.cat:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 7028 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: SPAM GLOBAL 1.0000 1.0000 4.3430 X-Barracuda-Spam-Score: 4.84 X-Barracuda-Spam-Status: No, SCORE=4.84 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=6.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.109981 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Ok. New test. This uses yesterday morning's next branch. commit 5b589e139620214f Merge: cc5a940923 32d2461e04 Merge branch 'next_net/phy_connect_dev' USB2 does not work for rk3399 in next (fixes are in master, thanks), but USB3 is enough. I compiled for rock-pi-4-rk3399_defconfig flashed to a new microSD card as per doc/board/rockchip/rockchip.rst : dd if=3Du-boot-rockchip.bin of=3D/dev/sda seek=3D64 sync Put this microSD card in a Rock Pi 4 B+ Put a new USB stick in the USB3 port (center blue port closer to board). (the microSD card and USB stick come from factory, I guess they were partitioned with a single FAT partition) (make sure emmc and spi are blank) Connected only serial console and power.=20 Got this: U-Boot TPL 2023.07-rc2-00144-g497967f1ee (Jun 12 2023 - 11:15:47) lpddr4_set_rate: change freq to 400MHz 0, 1 Channel 0: LPDDR4, 400MHz BW=3D32 Col=3D10 Bk=3D8 CS0 Row=3D15 CS1 Row=3D15 CS=3D2 Die BW=3D16 Size= =3D2048MB Channel 1: LPDDR4, 400MHz BW=3D32 Col=3D10 Bk=3D8 CS0 Row=3D15 CS1 Row=3D15 CS=3D2 Die BW=3D16 Size= =3D2048MB 256B stride lpddr4_set_rate: change freq to 800MHz 1, 0 Trying to boot from BOOTROM Returning to boot ROM... U-Boot SPL 2023.07-rc2-00144-g497967f1ee (Jun 12 2023 - 11:15:47 +0200) Trying to boot from MMC1 NOTICE: BL31: v2.1(release):v2.1-728-ged01e0c4-dirty NOTICE: BL31: Built : 18:29:11, Mar 22 2022 U-Boot 2023.07-rc2-00144-g497967f1ee (Jun 12 2023 - 11:15:47 +0200) SoC: Rockchip rk3399 Reset cause: POR Model: Radxa ROCK Pi 4B DRAM: 4 GiB (effective 3.9 GiB) PMIC: RK808=20 Core: 283 devices, 29 uclasses, devicetree: separate MMC: mmc@fe310000: 2, mmc@fe320000: 1, mmc@fe330000: 0 Loading Environment from MMC... *** Warning - bad CRC, using default enviro= nment In: serial Out: serial Err: serial Model: Radxa ROCK Pi 4B Net: eth0: ethernet@fe300000 Hit any key to stop autoboot: 2 =08=08=08 1 =08=08=08 0=20 rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout! Bus usb@fe380000: ehci_generic usb@fe380000: Failed to get clocks (ret=3D-1= 9) Port not available. Bus usb@fe3c0000: ehci_generic usb@fe3c0000: Failed to get clocks (ret=3D-1= 9) Port not available. Bus usb@fe800000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 Bus usb@fe900000: Register 2000140 NbrPorts 2 Starting the controller USB XHCI 1.10 scanning bus usb@fe800000 for devices... 1 USB Device(s) found scanning bus usb@fe900000 for devices... cannot reset port 1!? 2 USB Device(s) found rockchip_pcie pcie@f8000000: failed to find ep-gpios property ethernet@fe300000 Waiting for PHY auto negotiation to complete......... TIM= EOUT ! Could not initialize PHY ethernet@fe300000 rockchip_pcie pcie@f8000000: failed to find ep-gpios property ethernet@fe300000 Waiting for PHY auto negotiation to complete......... TIM= EOUT ! Could not initialize PHY ethernet@fe300000 =3D> printenv preboot ## Error: "preboot" not defined =3D> printenv arch=3Darm baudrate=3D1500000 board=3Devb_rk3399 board_name=3Devb_rk3399 boot_targets=3Dmmc1 mmc0 nvme scsi usb pxe dhcp spi bootcmd=3Dbootflow scan bootdelay=3D2 cpu=3Darmv8 cpuid#=3D[something] eth1addr=3D[:so:me:th:in:g] ethact=3Dethernet@fe300000 ethaddr=3D[:so:me:th:in:g] fdt_addr_r=3D0x01f00000 fdtcontroladdr=3Df1ef9170 fdtfile=3Drockchip/rk3399-rock-pi-4b.dtb fdtoverlay_addr_r=3D0x02000000 kernel_addr_r=3D0x02080000 kernel_comp_addr_r=3D0x08000000 kernel_comp_size=3D0x2000000 loadaddr=3D0x800800 partitions=3Duuid_disk=3D${uuid_gpt_disk};name=3Dloader1,start=3D32K,size= =3D4000K,uuid=3D${uuid_gpt_loader1};name=3Dloader2,start=3D8MB,size=3D4MB,u= uid=3D${uuid_gpt_loader2};name=3Dtrust,size=3D4M,uuid=3D${uuid_gpt_atf};nam= e=3Dboot,size=3D112M,bootable,uuid=3D${uuid_gpt_boot};name=3Drootfs,size=3D= -,uuid=3D[something]; pxefile_addr_r=3D0x00600000 ramdisk_addr_r=3D0x06000000 script_offset_f=3D0xffe000 script_size_f=3D0x2000 scriptaddr=3D0x00500000 serial#=3D[something] soc=3Drk3399 stderr=3Dserial,vidconsole stdin=3Dserial,usbkbd stdout=3Dserial,vidconsole vendor=3Drockchip Environment size: 1041/32764 bytes =3D> usb info 1: Hub, USB Revision 3.0 - U-Boot XHCI Host Controller=20 - Class: Hub - PacketSize: 512 Configurations: 1 - Vendor: 0x0000 Product 0x0000 Version 1.0 Configuration: 1 - Interfaces: 1 Self Powered 0mA Interface: 0 - Alternate Setting 0, Endpoints: 1 - Class Hub - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms 1: Hub, USB Revision 3.0 - U-Boot XHCI Host Controller=20 - Class: Hub - PacketSize: 512 Configurations: 1 - Vendor: 0x0000 Product 0x0000 Version 1.0 Configuration: 1 - Interfaces: 1 Self Powered 0mA Interface: 0 - Alternate Setting 0, Endpoints: 1 - Class Hub - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms 2: Mass Storage, USB Revision 3.20 - USB SanDisk 3.2Gen1 05017d2e4d7b4ea0c5822c90c51e0b7 - Class: (from Interface) Mass Storage - PacketSize: 512 Configurations: 1 - Vendor: 0x0781 Product 0x5591 Version 1.0 Configuration: 1 - Interfaces: 1 Bus Powered 224mA Interface: 0 - Alternate Setting 0, Endpoints: 2 - Class Mass Storage, Transp. SCSI, Bulk only - Endpoint 1 In Bulk MaxPacket 1024 - Endpoint 2 Out Bulk MaxPacket 1024 "Synchronous Abort" handler, esr 0x96000010, far 0x101 elr: 000000000021c398 lr : 000000000021ca70 (reloc) elr: 00000000f3f32398 lr : 00000000f3f32a70 x0 : 0000000000000000 x1 : 00000000000010d1 x2 : 00000000f1f404b8 x3 : 00000000f1f41998 x4 : 00000000ff1a0000 x5 : 0000000000000034 x6 : 000000000000000a x7 : 0000000000000002 x8 : 0000000000000000 x9 : 0000000000000400 x10: 0000000000000006 x11: 000000000001869f x12: 0000000000000200 x13: 0000000000000000 x14: 00000000ffffffff x15: 00000000f1ef81c3 x16: 0000000000000000 x17: 0000000000000000 x18: 00000000f1f0dd90 x19: 0000000000000000 x20: 00000000f1ef8848 x21: 0000000000000002 x22: 00000000f1ef8848 x23: 0000000000000002 x24: 00000000f1ef8844 x25: 0000000000000000 x26: 0000000000000000 x27: 0000000000000000 x28: 0000000000000000 x29: 00000000f1ef86b0 Code: f0000460 a8c27bfd 91099000 1401e518 (39440401)=20 Resetting CPU ... resetting ... bootcmd=3Dbootflow scan is because DISTRO_DEFAULTS is not in configs/rock-pi-4-rk3399_defconfig I'd say the changes to Kconfig are in ef5e3891f57 and 2d653f686b6. In any case this causes bootflow scan=20 to be called. This tries to access the media in boot_targets until it reach= es usb ( do_bootflow_scan() in cmd/bootflow.c tries mmc1, mmc0 and nvme unsucc= essfully). I think this adds a UCLASS_BOOTDEV device under a usb mass storage device as sibling of a UCLASS_BLK device, and this makes usb info recurse with a null usb_device pointer and a reset at this dereference. But I'm still reading the code to understand quite exactly how and which are the paths. I don't understand how much of this is intendeded and what should be prevented. Thsi is why my patch just fixed the last consequence, tthe null pointer dereference. I'll keep looking when I can.