All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ana Bobillo <anabobillo3@gmail.com>
To: Marek Vasut <marek.vasut+usb@mailbox.org>
Cc: u-boot@lists.u-boot-project.org, Tom Rini <trini@konsulko.com>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH 1/6] usb: raise USB_MAXCHILDREN to 31
Date: Sat, 31 Oct 2026 06:16:53 +0000	[thread overview]
Message-ID: <a37483d4-31d4-49ee-b0f0-a96110055873@gmail.com> (raw)
In-Reply-To: <57123e9b-629d-49d3-b500-095503129ed2@gmail.com>

From: Ana Bobillo <anabobillo3@gmail.com>

A hub's per-port state is sized by USB_MAXCHILDREN: the DeviceRemovable
and PortPowerCtrlMask bitmaps and overcurrent_count[] in struct
usb_hub_device, and children[] in struct usb_device without driver
model. At 8 this is below the port count of many root hubs. An xHCI root
hub reports every USB 2 and USB 3 port of its controller (HCS_MAX_PORTS),
more than 8 on many PC chipsets, and usb_scan_port() then counts
over-current events past the end of overcurrent_count[] for the higher
ports.

Use 31, as Linux does: the port bitmaps, with their bit for the hub
itself, then fill four bytes. A following patch keeps
usb_hub_configure() from using more ports than this.

This grows struct usb_hub_device by 96 bytes and, without driver model,
children[] by 23 pointers: about 4.4 KiB more BSS on a 32-bit board
without driver model (USB_MAX_DEVICE devices, USB_MAX_HUB hubs).

Signed-off-by: Ana Bobillo <anabobillo3@gmail.com>
---
 include/usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/usb.h b/include/usb.h
index dab23753f0c..76a3efa49d3 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -38,7 +38,7 @@ extern bool usb_started; /* flag for the started/stopped USB status */
 #define USB_MAXCONFIG			8
 #define USB_MAXINTERFACES		8
 #define USB_MAXENDPOINTS		16
-#define USB_MAXCHILDREN			8	/* This is arbitrary */
+#define USB_MAXCHILDREN			31	/* As Linux: the port bitmaps fit 4 bytes */
 #define USB_MAX_HUB			16
 
 #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */

  reply	other threads:[~2026-10-31  6:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31  6:16 [PATCH 0/6] usb: check hub port and descriptor counts during enumeration Ana Bobillo
2026-10-31  6:16 ` Ana Bobillo [this message]
2026-10-31  6:16 ` [PATCH 2/6] usb: hub: don't use more ports than USB_MAXCHILDREN Ana Bobillo
2026-10-31  6:17 ` [PATCH 3/6] cmd: usb: don't look past the last port in usb tree Ana Bobillo
2026-10-31  6:17 ` [PATCH 4/6] usb: keep interface and endpoint counts within what was parsed Ana Bobillo
2026-10-31  6:17 ` [PATCH 5/6] usb: skip endpoint descriptors for endpoint zero Ana Bobillo
2026-10-31  6:17 ` [PATCH 6/6] usb: don't use a device whose configuration can't be parsed Ana Bobillo

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=a37483d4-31d4-49ee-b0f0-a96110055873@gmail.com \
    --to=anabobillo3@gmail.com \
    --cc=marek.vasut+usb@mailbox.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.