All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jakub Lecki <lec.jakub@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Valentina Manea <valentina.manea.m@gmail.com>,
	Shuah Khan <shuah@kernel.org>, Hongren Zheng <i@zenithal.me>
Subject: Re: [PATCH 3/3] usbip: Limit maximum number of virtual host controllers to 31.
Date: Tue, 4 Nov 2025 23:30:18 +0900	[thread overview]
Message-ID: <2025110450-abnormal-goofball-bc68@gregkh> (raw)
In-Reply-To: <20251104113248.223594-4-lec.jakub@gmail.com>

On Tue, Nov 04, 2025 at 12:32:48PM +0100, Jakub Lecki wrote:
> When loading the vhci-hcd module with number of virtual host controllers
> configured to max value of 128, the module initialization fails due to
> insufficient number of available IDs for USB busses.
> 
> Each virtual host controller registers two usb hubs (USB2.0 & USB3.0) to
> the usb core, each with a unique bus number. The number of USB busses is
> limited by ID allocation range [1 .. USB_MAXBUS - 1] (defined in
> usb_register_bus()). Therefore, VHCI_MAX_NR_HCS must not be greater than
> (USB_MAXBUS - 1) / 2 = 31.
> 
> In real world scenarios the maximum number of virtual host controllers
> possible to create may be even lower as other USB host controllers may
> be registered. In this case, the module initialization failure is
> correct as the number of virtual host controllers must be adjusted by
> a user to a given use-case.
> 
> Signed-off-by: Jakub Lecki <lec.jakub@gmail.com>
> ---
>  drivers/usb/usbip/vhci.h | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
> index 2772d923a8cb..3b0ea4038e51 100644
> --- a/drivers/usb/usbip/vhci.h
> +++ b/drivers/usb/usbip/vhci.h
> @@ -76,8 +76,17 @@ enum hub_speed {
>  #define VHCI_DEFAULT_HC_PORTS 8
>  #define VHCI_MAX_HC_PORTS USB_SS_MAXPORTS
>  
> +/*
> + * Number of supported virtual host controllers. Value has upperbound of
> + * maximum possible usb busses.
> + * It is limited by a bus ID allocation in [1 .. USB_MAXBUS - 1] range,
> + * resulting in maximum of USB_MAXBUS - 1 usb busses allocated.
> + * Additionally, each virtual host controller registers 2 usb hubs (USB2.0
> + * & USB3.0), therefore maximum number of virtual host controllers is:
> + * (USB_MAXBUS - 1) / 2
> + */
>  #define VHCI_DEFAULT_NR_HCS 1
> -#define VHCI_MAX_NR_HCS 128
> +#define VHCI_MAX_NR_HCS 31

Why have any max at all?  Why not just dynamically allocate them when
asked for?

thanks,

greg k-h

      reply	other threads:[~2025-11-04 14:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04 11:32 [PATCH 0/3] usbip: Convert vhci-hcd Kconfig related to number of ports to module parameters Jakub Lecki
2025-11-04 11:32 ` [PATCH 1/3] usbip: Convert CONFIG_USBIP_VHCI_NR_HCS to a module parameter Jakub Lecki
2025-11-04 14:29   ` Greg Kroah-Hartman
2025-11-04 11:32 ` [PATCH 2/3] usbip: Convert CONFIG_USBIP_VHCI_HC_PORTS " Jakub Lecki
2025-11-04 11:32 ` [PATCH 3/3] usbip: Limit maximum number of virtual host controllers to 31 Jakub Lecki
2025-11-04 14:30   ` Greg Kroah-Hartman [this message]

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=2025110450-abnormal-goofball-bc68@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=i@zenithal.me \
    --cc=lec.jakub@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.com \
    /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.