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 A8A88C6FA8E for ; Thu, 2 Mar 2023 21:05:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0EB5785C84; Thu, 2 Mar 2023 22:05:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1677791146; bh=XPjrqgKLd8ZMDJhDWX8p9k/v8foOCy17t/iEGGWB78o=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fqlkFxj1gKH+a6UpVixriBzt6yxXZ1NlqpO4VEGYS4zv91hFmFtVb3IuZBwz/hjk+ dmbjuYVHmjAPIk3sQH9QbJ/Q8ySoIgE4hybOituHI4KHTD/+wq23wn8qKe9EMoueiz 6Yg9v93v8xWsXBqGOISwsi1NzlhJ3KIKz621LAg0PPIsGao7flm3djyj5WKROw8bB/ wx9sS6/DLEdHeSnSD1XCd1Jlz5hITwwPqyKAKPUEshr8La91q8ovtYyZYrlcHqRxyQ 9KBEq3iylbYdrSAMSPOAw9VVRnyiH7CkRmH3NmNTbIctXMSvh+5YiWNd1f6e6XkjHW 6y3ChQV+hiaNA== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 1C3F185B17; Thu, 2 Mar 2023 22:05:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1677791144; bh=XPjrqgKLd8ZMDJhDWX8p9k/v8foOCy17t/iEGGWB78o=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=rSwiZ4KJ84mi28Zp2tpdrjE/OSWc5erBzAk0g9M3eMLMGLyMko7NxYLOtilnTAO4q xG4W+PyhFl6eCgrXZEcTxTcIs0Abjy8vW2t23O2PfaCnUEmvrK9o68J0Ie5AITJTZk 4w4VFi2koHCud6JDINU6BXln6zbDCDtA44oxyswzeQliTnK/uKLmUbLRmxJOpK6Qd6 w5iIymSe2XpBzsJAcevTt5LN2ZtrlTu6MapZDXYSOSXgLRRT8YLXKfn8bTNrOYFO4i wqNq5RP5nIqY02UF08OuFk7EpixBChvhkUehPcq3w4wKWHAOOnRxjPKPIBYoZwLgIV u7jHvmeO6SdaA== Message-ID: Date: Thu, 2 Mar 2023 22:05:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: u-boot crashes if mass-storage devices are connected via USB-C To: Janne Grunau Cc: Simon Glass , bluetail , Bin Meng , Mark Kettenis , Tom Rini , u-boot@lists.denx.de References: <322414817369964463b2ffd89ff1989f@posteo.net> <79b7c4da-eae4-2e9c-585e-ae10f5bb0489@denx.de> <20230302091413.GD24656@jannau.net> <1229fb53-96b0-a4bc-f126-6563b4cff24d@denx.de> <20230302185153.GE24656@jannau.net> Content-Language: en-US From: Marek Vasut In-Reply-To: <20230302185153.GE24656@jannau.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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.6 at phobos.denx.de X-Virus-Status: Clean On 3/2/23 19:51, Janne Grunau wrote: > On 2023-03-02 18:33:15 +0100, Marek Vasut wrote: >> On 3/2/23 10:14, Janne Grunau wrote: >>> On 2023-03-01 23:51:14 +0100, Marek Vasut wrote: >>>> On 3/1/23 21:34, Simon Glass wrote: >>>>> +Marek Vasut +Bin Meng +Mark Kettenis +Tom Rini >>>>> >>>>> On Wed, 1 Mar 2023 at 08:12, bluetail wrote: >>>>>> >>>>>> Essentially, I connect a mass-storage device to the USB-C port of a Mac >>>>>> Mini 2020 (M1), and it leads to the issue in the attachment. >>>>>> I was able to reproduce it with Icy Box IB-3810 and ICY BOX IB-3805. >>>>>> Initially I thought this issue was only for some devices (also attached >>>>>> here) https://github.com/AsahiLinux/u-boot/issues/4 but it appears this >>>>>> might be a issue that is with many devices. >>>>>> >>>>>> If you need any more information, please feel free to ask. I am very >>>>>> eager to have this issue fixed because it seems to be a very broad issue >>>>>> with mass media storage in general. >>>>>> uname-r returns 6.1.0-asahi-2-2-edge-ARCH >>>> Would it be possible to check whether current u-boot/master works any better >>> >>> Reproduced with b0eda49bc9b0 ("Merge tag 'u-boot-at91-fixes-2023.04-a' >>> of https://source.denx.de/u-boot/custodians/u-boot-at91") and Icy Box >>> IB-3804-C31 (same design as IB-3805/IB-3810 but just a single 4 port >>> USB3 hub + 4 independent asmedia usb3 to sata converters). >>> >>> | scanning bus usb@b02280000 for devices... Device NOT ready >>> | Request Sense returned 02 3A 00 >>> | Device NOT ready >>> | Request Sense returned 02 3A 00 >>> | Resetting EP 0... >>> | WARN halted endpoint, queueing URB anyway. >>> | Unexpected XHCI event TRB, skipping... (c9208350 0000010f 13000000 04008401) >>> | "Synchronous Abort" handler, esr 0x96000005 >>> | elr: 000000000003934c lr : 000000000003934c (reloc) >>> | elr: 0000010fcd24034c lr : 0000010fcd24034c >> >> Could you decode the trace and check where exactly this exception occurred ? >> >> It should be enough to run "aarch64-...-objdump -lSD u-boot | less" on the >> U-Boot which matches the one which generated the trace, and then look up the >> lr/elr address in that trace. That should point you to the exact place in >> code where the exception occurred . > > Slightly different binary due to unrelated chnages: > > | scanning bus usb@702280000 for devices... 1 USB Device(s) found > | scanning bus usb@b02280000 for devices... 1 USB Device(s) found > | scanning bus usb@f02280000 for devices... 1 USB Device(s) found > | scanning bus usb@1302280000 for devices... 2 USB Device(s) found > | scanning bus usb@702280000 for devices... 1 USB Device(s) found > | scanning bus usb@b02280000 for devices... Resetting EP 0... > | WARN halted endpoint, queueing URB anyway. > | Unexpected XHCI event TRB, skipping... (c92247b0 0000010f 13000000 02008400) > | "Synchronous Abort" handler, esr 0x96000005 > | elr: 0000000000039d9c lr : 0000000000039d9c (reloc) > | elr: 0000010fcd240d9c lr : 0000010fcd240d9c > | x0 : 0000000000000000 x1 : 00000000000003e8 > | x2 : 0000000000000040 x3 : 000000000000003f > | x4 : 0000010fc9223040 x5 : 0000010fc921ef90 > | x6 : 0000000000001800 x7 : 00000000300c0300 > | x8 : 0000000000000424 x9 : 0000000000000008 > | x10: 00000000ffffffe8 x11: 0000000000000010 > | x12: 0000000000010000 x13: 0000000000000001 > | x14: 0000010fc91ba320 x15: 0000000000000021 > | x16: 0000010fcd23addc x17: 0000000000000040 > | x18: 0000010fc91e7d70 x19: 0000010fc9223040 > | x20: 0000010fc9234b20 x21: 0000000000000002 > | x22: 0000010fc9233790 x23: 0000000000000080 > | x24: 0000000000000000 x25: 0000010fc91b9d00 > | x26: 0000010fc91b9d00 x27: 0000010fc9233790 > | x28: 0000000000000000 x29: 0000010fc91b99b0 > | > | Code: 97ffff3c 52800401 aa1303e0 97ffffa2 (b9400c00) > > objdump -lSD u-boot | grep -C 12 ' 39d9c' > > | Disassembly of section .text_rest: > | ... > | 39d84: f9400c36 ldr x22, [x1, #24] > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:544 > | xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_STOP_RING); > | 39d88: d2800001 mov x1, #0x0 // #0 > | 39d8c: 97ffff3c bl 39a7c > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:546 > | event = xhci_wait_for_event(ctrl, TRB_TRANSFER); > | 39d90: 52800401 mov w1, #0x20 // #32 > | 39d94: aa1303e0 mov x0, x19 > | 39d98: 97ffffa2 bl 39c20 > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:547 > | field = le32_to_cpu(event->trans_event.flags); > | 39d9c: b9400c00 ldr w0, [x0, #12] > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:548 > | BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id); > | 39da0: b9494681 ldr w1, [x20, #2372] > | 39da4: 6b40603f cmp w1, w0, lsr #24 > | 39da8: 54000180 b.eq 39dd8 // b.none > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:548 (discriminator 1) > | 39dac: 90000143 adrp x3, 61000 > | 39db0: 913d0863 add x3, x3, #0xf42 > | 39db4: 52804482 mov w2, #0x224 // #548 > | /home/janne/src/asahi/u-boot/drivers/usb/host/xhci-ring.c:549 (discriminator 1) > | BUG_ON(TRB_TO_EP_INDEX(field) != ep_index); > | 39db8: b0000181 adrp x1, 6a000 > > not immediately obvious to me what's the problem. x0 looks valid before the ldr. x0 in the splat is | x0 : 0000000000000000 x1 : 00000000000003e8 so, I think xhci_wait_for_event() returns NULL . I found this device locally: New USB device found, idVendor=174c, idProduct=55aa, bcdDevice= 1.00 Product: ICY BOX IB-366StU3+B I will see if I can reproduce the problem on iMX8MP DWC3 too, unless someone wants to dig into it first, which might expedite the fix.