lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025110450-limping-retaliate-1ad9@gregkh>
Date: Tue, 4 Nov 2025 23:29:33 +0900
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Jakub Lecki <lec.jakub@...il.com>
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	Valentina Manea <valentina.manea.m@...il.com>,
	Shuah Khan <shuah@...nel.org>, Hongren Zheng <i@...ithal.me>
Subject: Re: [PATCH 1/3] usbip: Convert CONFIG_USBIP_VHCI_NR_HCS to a module
 parameter.

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ