From: Xavier Drudis Ferran <xdrudis@tinet.cat>
To: Simon Glass <sjg@chromium.org>
Cc: Xavier Drudis Ferran <xdrudis@tinet.cat>,
Marek Vasut <marex@denx.de>,
u-boot@lists.denx.de, Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>
Subject: Re: [SPAM] Re: [PATCH] cmd: usb: Prevent reset in usb tree/info command
Date: Tue, 20 Jun 2023 13:20:25 +0200 [thread overview]
Message-ID: <ZJGLeRzS4FKbH9Pk@xdrudis.tinet.cat> (raw)
In-Reply-To: <CAPnjgZ09fo7MNn5PuxuhOPv9tTPn7dQFVmGP64fdL_D=qFembw@mail.gmail.com>
El Tue, Jun 20, 2023 at 11:03:57AM +0100, Simon Glass deia:
> Hi Xavier,
>
Hi Simon,
> >
> > It is also possible that one day a device that is not UCLASS_BLK,
> > UCLASS_BOOTDEV or UCLASS_USB_EMUL is put as children of a usb storage
> > device (just imagine a future system similar to bootstd for firmware
> > updates, trust material, etc.). Is it likely to have a struct in
> > parent_priv_ that is not a usb_device ?
> >
> > So which is more likely to survive future changes ?
> >
> > - checking for parent_priv_ not null and not UCLASS_USB_EMUL
> >
> > - checking for parent_priv_ not null and not UCLASS_USB_EMUL and not UCLASS_BLK
> > (my patch, overcautious ?)
> >
> > - checking for not (UCLASS_BLK, UCLASS_BOOTDEV or UCLASS_USB_EMUL)
> > (Simon Glass' idea)
> >
> > - checking for not UCLASS_BLK and not UCLASS_BOOTDEV and not UCLASS_USB_EMUL
> > and parent_priv_ not null
>
> Really the parent_priv thing is a separate issue, a side effect of
> something having a UCLASS_USB parent.
>
I don't think it's a separate issue. If parent_priv is present it
could be a usb_device (most likely) or not, but if it's null there's
no way the recursive call can succeed.
> The key point here is that we cannot iterate down into a bootdev
> device looking for USB devices. So we should use that as the check,
> since it is the most direct check.
>
But things keep appearing that have a UCLASS_USB* parent and no
parent_priv.
in 2017 Suneel Garapati already fixed the issue of UCLASS_BLK
being a child of a device. Now it's UCLASS_BOOTDEV, and tomorrow
may be something else.
The most direct check will miss future cases as the devices tend to
become more abstract instead of mapping one to one to physical stuff.
>
> >From my memory, I think you can check for a USB hub instead, but I'm
> not completely sure.
>
On second thoughts I didn't find it so easy. There's the root hub,
UCLASS_USB, I think and a UCLASS_USB_EMUL may also be a hub, so I
don't know anymore how more elegant that could be, so I left it be.
> I suggest adding a test for the command (see test/dm/acpi.c for an
> example) since a test is the best way to ensure this doesn't happen
> again.
>
Makes sense. But I don't have any more time for that, sorry.
I think we'll have to leave it at this unless someone else has the time.
Bye.
next prev parent reply other threads:[~2023-06-20 11:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 15:20 [PATCH] cmd: usb: Prevent reset in usb tree/info command Xavier Drudis Ferran
2023-06-07 22:05 ` Marek Vasut
2023-06-08 7:39 ` Xavier Drudis Ferran
2023-06-09 1:20 ` Marek Vasut
[not found] ` <ZILsTOaXliizQjiH@xdrudis.tinet.cat>
2023-06-09 18:52 ` [SPAM] " Xavier Drudis Ferran
2023-06-11 12:29 ` Marek Vasut
2023-06-12 21:17 ` Simon Glass
2023-06-13 6:42 ` Xavier Drudis Ferran
2023-06-13 6:52 ` Xavier Drudis Ferran
2023-06-13 14:58 ` Simon Glass
2023-06-13 16:04 ` Xavier Drudis Ferran
2023-06-13 20:12 ` Simon Glass
2023-06-14 8:40 ` Xavier Drudis Ferran
2023-06-20 10:03 ` Simon Glass
2023-06-20 11:20 ` Xavier Drudis Ferran [this message]
2023-06-20 14:36 ` Simon Glass
2023-06-20 0:50 ` Marek Vasut
2023-06-20 7:03 ` Xavier Drudis Ferran
2023-06-20 9:13 ` Marek Vasut
[not found] <ZJAqKxrO7qa8r6Kq@xdrudis.tinet.cat>
2023-06-19 21:49 ` Marek Vasut
2023-06-20 9:17 ` Xavier Drudis Ferran
2023-06-20 9:49 ` Marek Vasut
2023-06-20 10:43 ` [SPAM] " Xavier Drudis Ferran
2023-06-20 23:08 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZJGLeRzS4FKbH9Pk@xdrudis.tinet.cat \
--to=xdrudis@tinet.cat \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox