[{"id":1773258,"web_url":"http://patchwork.ozlabs.org/comment/1773258/","msgid":"<f6416069-ed17-9375-e299-8ef69d1c94d2@denx.de>","list_archive_url":null,"date":"2017-09-22T04:56:22","subject":"Re: [U-Boot] [PATCH 01/14] dm: usb: Fix broken usb_stop()","submitter":{"id":13,"url":"http://patchwork.ozlabs.org/api/people/13/","name":"Stefan Roese","email":"sr@denx.de"},"content":"On 18.09.2017 15:40, Bin Meng wrote:\n> At present we only do device_remove() during usb stop. The DM API\n> device_remove() only marks the device state as inactivated, but\n> still keeps its USB topology (eg: parent, children, etc) in the DM\n> device structure. There is no issue if we only start USB subsystem\n> once and never stop it. But a big issue occurs when we do 'usb stop'\n> and 'usb start' multiple times.\n> \n> Strange things may be observed with current implementation, like:\n> - the enumeration may report only 1 mass storage device is detected,\n>    but the total number of USB devices is correct.\n> - USB keyboard does not work anymore after a bunch of 'usb reset'\n>    even if 'usb tree' shows it is correctly identified.\n> - read/write flash drive via 'fatload usb' may complain \"Bad device\"\n> \n> In fact, every time when USB host controller starts the enumeration\n> process, it takes random time for each USB port to show up online,\n> hence each USB device may appear in a different order from previous\n> enumeration, and gets assigned to a totally different USB address.\n> As a result, we end up using a stale USB topology in the DM device\n> structure which still reflects the previous enumeration result, and\n> it may create an exact same DM device name like generic_bus_0_dev_7\n> that is already in the DM device structure. And since the DM device\n> structure is there, there is no device_bind() call to bind driver to\n> the device during current enumeration process, eventually creating\n> an inconsistent software representation of the hardware topology, a\n> non-working USB subsystem.\n> \n> The fix is to clear the unused USB topology in the usb_stop(), by\n> calling device_unbind() on each controller's root hub device, and\n> the unbinding will unbind all of its children automatically.\n> \n> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>\n\nReviewed-by: Stefan Roese <sr@denx.de>\nTested-by: Stefan Roese <sr@denx.de>\n\nThanks,\nStefan","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xz1RL0WHhz9sP1\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 14:56:45 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid C5E32C21E7F; Fri, 22 Sep 2017 04:56:42 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 12DE3C21C29;\n\tFri, 22 Sep 2017 04:56:39 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 5B485C21C29; Fri, 22 Sep 2017 04:56:38 +0000 (UTC)","from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215])\n\tby lists.denx.de (Postfix) with ESMTPS id 51203C21C26\n\tfor <u-boot@lists.denx.de>; Fri, 22 Sep 2017 04:56:37 +0000 (UTC)","from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mx2.mailbox.org (Postfix) with ESMTPS id 238E24B981;\n\tFri, 22 Sep 2017 06:56:37 +0200 (CEST)","from smtp1.mailbox.org ([80.241.60.240])\n\tby spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de\n\t[80.241.56.117]) (amavisd-new, port 10030)\n\twith ESMTP id iIJ92pr4nKZR; Fri, 22 Sep 2017 06:56:27 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW\n\tautolearn=unavailable autolearn_force=no version=3.4.0","X-Virus-Scanned":"amavisd-new at heinlein-support.de","To":"Bin Meng <bmeng.cn@gmail.com>, Marek Vasut <marex@denx.de>,\n\tU-Boot Mailing List <u-boot@lists.denx.de>","References":"<1505742050-5697-1-git-send-email-bmeng.cn@gmail.com>\n\t<1505742050-5697-2-git-send-email-bmeng.cn@gmail.com>","From":"Stefan Roese <sr@denx.de>","Message-ID":"<f6416069-ed17-9375-e299-8ef69d1c94d2@denx.de>","Date":"Fri, 22 Sep 2017 06:56:22 +0200","MIME-Version":"1.0","In-Reply-To":"<1505742050-5697-2-git-send-email-bmeng.cn@gmail.com>","Content-Language":"en-US","Subject":"Re: [U-Boot] [PATCH 01/14] dm: usb: Fix broken usb_stop()","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"utf-8\"; Format=\"flowed\"","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]