From: Janne Grunau <j@jannau.net>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: u-boot@lists.denx.de, asahi@lists.linux.dev,
Neal Gompa <neal@gompa.dev>, Bin Meng <bmeng.cn@gmail.com>,
Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>,
Simon Glass <sjg@chromium.org>,
Joe Hershberger <joe.hershberger@ni.com>
Subject: Re: [PATCH v3 2/6] usb: xhci: Set up endpoints for the first 2 interfaces
Date: Tue, 26 Mar 2024 09:36:07 +0100 [thread overview]
Message-ID: <ZgKI9y4RITeAgAKj@robin> (raw)
In-Reply-To: <082bfd68-1dd4-4bc5-acb3-1000de1a19b8@canonical.com>
On Fri, Mar 22, 2024 at 09:17:08AM +0100, Heinrich Schuchardt wrote:
> On 3/22/24 08:47, Janne Grunau via B4 Relay wrote:
> > From: Janne Grunau <j@jannau.net>
> >
> > The xhci driver currently only does the necessary initialization for
> > endpoints found in the first interface descriptor. Apple USB keyboards
> > (released 2021) use the second interface descriptor for the HID keyboard
> > boot protocol. To allow USB drivers to use endpoints from other
> > interface descriptors the xhci driver needs to ensure these endpoints
> > are initialized as well.
> > Use USB_MAX_ACTIVE_INTERFACES to control how many interface descriptors
> > are considered during endpoint initialisation.
> > For now define it to 2 as that is sufficient for supporting the Apple
> > keyboards.
> >
> > Reviewed-by: Marek Vasut <marex@denx.de>
> > Reviewed-by: Neal Gompa <neal@gompa.dev>
> > Signed-off-by: Janne Grunau <j@jannau.net>
> > ---
> > drivers/usb/host/xhci.c | 31 +++++++++++++++++++------------
> > include/usb.h | 6 ++++++
> > 2 files changed, 25 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> > index 534c4b973f..741e186ee0 100644
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> > @@ -606,24 +606,28 @@ static int xhci_set_configuration(struct usb_device *udev)
> > int slot_id = udev->slot_id;
> > struct xhci_virt_device *virt_dev = ctrl->devs[slot_id];
> > struct usb_interface *ifdesc;
> > + unsigned int ifnum;
> > + unsigned int max_ifnum = min((unsigned int)USB_MAX_ACTIVE_INTERFACES,
>
> no_of_if being of type u8 limits the number of interfaces to 255.
> Introducing USB_MAX_ACTIVE_INTERFACES limit us to the first two
> interfaces. Is this really needed? Handling all interface would avoid
> the introduction of artificial limitations which may hit us on the next
> device.
It's not strictly necessary but assume that the code was only tested
with a single interface. Given the general state of u-boot's USB stack
I wouldn't be surprised if it would blew up with USB descriptors maxing
out the number of interfaces / endpoints. So limiting it to the minimum
of what's needed to support the device in front of me looks like the
safer option.
Janne
next prev parent reply other threads:[~2024-03-26 8:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-22 7:47 [PATCH v3 0/6] USB keyboard improvements for asahi / desktop systems Janne Grunau via B4 Relay
2024-03-22 7:47 ` [PATCH v3 1/6] usb: xhci: refactor xhci_set_configuration Janne Grunau via B4 Relay
2024-03-22 7:47 ` [PATCH v3 2/6] usb: xhci: Set up endpoints for the first 2 interfaces Janne Grunau via B4 Relay
2024-03-22 8:17 ` Heinrich Schuchardt
2024-03-26 8:36 ` Janne Grunau [this message]
2024-03-22 7:47 ` [PATCH v3 3/6] usb: xhci: Abort transfers with unallocated rings Janne Grunau via B4 Relay
2024-03-22 7:47 ` [PATCH v3 4/6] usb: Add environment based device ignorelist Janne Grunau via B4 Relay
2024-03-22 11:56 ` Marek Vasut
2024-03-26 8:40 ` Janne Grunau
2024-03-26 11:29 ` Marek Vasut
2024-03-22 7:47 ` [PATCH v3 5/6] usb: kbd: support Apple Magic Keyboards (2021) Janne Grunau via B4 Relay
2024-03-22 7:47 ` [PATCH v3 6/6] usb: kbd: Add probe quirk for Apple and Keychron keyboards Janne Grunau via B4 Relay
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=ZgKI9y4RITeAgAKj@robin \
--to=j@jannau.net \
--cc=asahi@lists.linux.dev \
--cc=bmeng.cn@gmail.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=joe.hershberger@ni.com \
--cc=marex@denx.de \
--cc=neal@gompa.dev \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--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