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 BBF34EB64D9 for ; Mon, 19 Jun 2023 11:54:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DB2F8545F; Mon, 19 Jun 2023 13:54:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (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=1687175661; bh=rSbUhTAqZ1caFjny2hQ2z5NXoatZvOh/WIVa34y315M=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KPwyvzCn4XLEYYELwMNT1SdBhN+55b8MHI2ZiBO8htSAvJb+Th2iRsaxfrwri+BeK ZBSGF6sZ4DuwpU8trunHKTm7VHtEo0+QHOF/ixcktU8mXy0GMQoY9ulv7BEuEtBaze PSek1fW3nkBMHojk8L2Y6Xwb6CKf7ABdcvkPQuQHqwXXl9tFh0H9UExyBij5BJeNrp Wm8rUm0W4QKjieF/95yAk2sxzSW7xMMK1SXuxURQ+2xNehk13hIhB7i2PFu1338rzB N9Xg3t3c+CdcdiUJ3+ugrtipqEY22VhiSPkfHxevfrZRFVS+ZzWZpXHSXUaOM1eo39 Jc0SmM7SYjfvw== 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 2DF32847D3; Mon, 19 Jun 2023 13:54:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1687175658; bh=rSbUhTAqZ1caFjny2hQ2z5NXoatZvOh/WIVa34y315M=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aAKNF2UGpwMAvseFKwXiinin+cuW3Bh6dF0QW2avFecPpK1I90K8J4v1HyWnUEe+J 8N5ATfub1MbfM4MAhtwZUbX5LnBflA4bQ23tana7ieWeOzl1L8VWoUaE3CY0mMmjVV pRc299aTkooH9LYchmGNfw5/AeKKTi6BfyVI/XHgBfhbWwrKnWvUI4uiNmlOrESJ8h ukv9Ouzi1s4gFr1rLodPPG8g+SnmttY6e/N5GAVuU3PS0oM9rBuZuhoL++zDNejnDb CPKhSpxM26eeWtXDuUWVGCf+u2yVD1BDNYeQM39IAkEykJdiqn7LQp2H9/tnGD7zqb HN/57QoQFSMQw== Message-ID: <96347aaf-2572-e4be-17e1-dca9452727a3@denx.de> Date: Mon, 19 Jun 2023 13:54:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command Content-Language: en-US To: Xavier Drudis Ferran , u-boot@lists.denx.de Cc: Simon Glass , Lukasz Majewski , Sean Anderson , Suneel Garapati , Bin Meng References: From: Marek Vasut In-Reply-To: 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.8 at phobos.denx.de X-Virus-Status: Clean On 6/19/23 12:26, Xavier Drudis Ferran wrote: > When DISTRO_DEFAULTS is not set, the default environment has > bootcmd=bootflow and this will cause a UCLASS_BOOTDEV device to be > added as sibling of those UCLASS_BLK devices in boot_targets, until > boot succeeds from some device. If none succeeds, and usb is in > boot_targets, and an usb storage device is plugged to some usb port at > boot time, its UCLASS_MASS_STORAGE device will have a UCLASS_BOOTDEV > device as child, besides a UCLASS_BLK child. > > If once the boot fails the user enters at the U-Boot shell prompt: > > usb info > > or > > usb tree > > The code in cmd/usb.c will eventually recurse into the UCLASS_BOOTDEV > and pass a null pointer to usb_device (because it has no parent_priv_). > This causes a reset. > > Fix it (twice) by checking for null parent_priv_ and adding > UCLASS_BOOTDEV to the list of ignored class ids before the recursive > call. > > This prevents the current particular problem with UCLASS_BOOTDEV, even > in case it ever gets some parent_priv_ struct which is not an > usb_device, despite being the child of a usb_device->dev. And it also > prevents possible future problems if other children are added to usb > devices that don't have parent_priv_ because they are not part of the > usb tree, just abstractions of functionality (like UCLASS_BLK and > UCLASS_BOOTDEV are now). > > Signed-off-by: Xavier Drudis Ferran > --- > > v2: added UCLASS_BOOTDEV check (discussion of v1 dried up without much > evident consensus, so hopefully Simon Glass likes it better now) > [ https://patchwork.ozlabs.org/project/uboot/patch/ZH39SVA1vbZR3+Gk@xdrudis.tinet.cat/ ] > --- > > Apologies to the people in Cc: for resending this. I had a typo in the > email list address. git send-email -v2 would help Also you can add a CC list into the commit message below --- , then git send-email will automatically pick the CC list up. To get a list of people to CC , use get-maintainer script.