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 1/3] usbip: Convert CONFIG_USBIP_VHCI_NR_HCS to a module parameter.
Date: Tue, 4 Nov 2025 23:29:33 +0900 [thread overview]
Message-ID: <2025110450-limping-retaliate-1ad9@gregkh> (raw)
In-Reply-To: <20251104113248.223594-2-lec.jakub@gmail.com>
On Tue, Nov 04, 2025 at 12:32:46PM +0100, Jakub Lecki wrote:
> In workflows involving a greater number of remote
> USB/IP devices, the default number of available virtual ports may be
> insufficient, forcing user to recompile the module with greater number
> of configured virtual host controllers and/or number of ports.
>
> Allow a user to configure the number of USB/IP virtual host controllers
> via a new 'num_controllers' module parameter to simplify the usage of
> this module.
>
> VHCI controller structures are already dynamically allocated during
> module initialization, so the only change is switch from assigning
> 'vhci_num_controllers' via Kconfig to using the module parameter
> framework.
>
> - Remove the USBIP_VHCI_NR_HCS Kconfig option and replace it with a
> module parameter.
> - Trim the value of the configured 'num_controllers' parameter if it
> exceeds bounds, and emit a warning.
>
> Signed-off-by: Jakub Lecki <lec.jakub@gmail.com>
> ---
> drivers/usb/usbip/Kconfig | 11 -----------
> drivers/usb/usbip/vhci.h | 9 +++------
> drivers/usb/usbip/vhci_hcd.c | 16 ++++++++++++++--
> 3 files changed, 17 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/usb/usbip/Kconfig b/drivers/usb/usbip/Kconfig
> index b9f94e2e278d..bdcb6f4fdbec 100644
> --- a/drivers/usb/usbip/Kconfig
> +++ b/drivers/usb/usbip/Kconfig
> @@ -38,17 +38,6 @@ config USBIP_VHCI_HC_PORTS
> host controller driver, this defines number of ports per
> USB/IP virtual host controller.
>
> -config USBIP_VHCI_NR_HCS
> - int "Number of USB/IP virtual host controllers"
> - range 1 128
> - default 1
> - depends on USBIP_VHCI_HCD
> - help
> - To increase number of ports available for USB/IP virtual
> - host controller driver, this defines number of USB/IP
> - virtual host controllers as if adding physical host
> - controllers.
> -
> config USBIP_HOST
> tristate "Host driver"
> depends on USBIP_CORE && USB
> diff --git a/drivers/usb/usbip/vhci.h b/drivers/usb/usbip/vhci.h
> index 5659dce1526e..30b8540e0b49 100644
> --- a/drivers/usb/usbip/vhci.h
> +++ b/drivers/usb/usbip/vhci.h
> @@ -82,11 +82,8 @@ enum hub_speed {
> /* Each VHCI has 2 hubs (USB2 and USB3), each has VHCI_HC_PORTS ports */
> #define VHCI_PORTS (VHCI_HC_PORTS*2)
>
> -#ifdef CONFIG_USBIP_VHCI_NR_HCS
> -#define VHCI_NR_HCS CONFIG_USBIP_VHCI_NR_HCS
> -#else
> -#define VHCI_NR_HCS 1
> -#endif
> +#define VHCI_DEFAULT_NR_HCS 1
> +#define VHCI_MAX_NR_HCS 128
>
> #define MAX_STATUS_NAME 16
>
> @@ -118,7 +115,7 @@ struct vhci_hcd {
> struct vhci_device vdev[VHCI_HC_PORTS];
> };
>
> -extern int vhci_num_controllers;
> +extern unsigned int vhci_num_controllers;
> extern struct vhci *vhcis;
> extern struct attribute_group vhci_attr_group;
>
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index e70fba9f55d6..93c3fa3e1c53 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -10,6 +10,7 @@
> #include <linux/kthread.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> +#include <linux/printk.h>
> #include <linux/slab.h>
> #include <linux/string_choices.h>
>
> @@ -44,7 +45,12 @@ static int vhci_get_frame_number(struct usb_hcd *hcd);
> static const char driver_name[] = "vhci_hcd";
> static const char driver_desc[] = "USB/IP Virtual Host Controller";
>
> -int vhci_num_controllers = VHCI_NR_HCS;
> +unsigned int vhci_num_controllers = VHCI_DEFAULT_NR_HCS;
> +module_param_named(num_controllers, vhci_num_controllers, uint, 0444);
> +MODULE_PARM_DESC(num_controllers, "Number of USB/IP virtual host controllers (range: 0-"
> + __MODULE_STRING(VHCI_MAX_NR_HCS) ", default: "
> + __MODULE_STRING(VHCI_DEFAULT_NR_HCS) ")");
I'm all for making this dynamic, but this is not the 1990's, please do
not add new module parameters. Use the "proper" api for this, either
sysfs or configfs, instead.
thanks,
greg k-h
next prev parent reply other threads:[~2025-11-04 14:29 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 [this message]
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
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-limping-retaliate-1ad9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).