linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ray Chi <raychi@google.com>
Cc: corbet@lwn.net, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	albertccwang@google.com
Subject: Re: [PATCH] USB: hub: add module parameters to usbcore for port init retries
Date: Tue, 21 Jun 2022 09:20:13 +0200	[thread overview]
Message-ID: <YrFxLYibDtyuxSO6@kroah.com> (raw)
In-Reply-To: <20220617102256.3253019-1-raychi@google.com>

On Fri, Jun 17, 2022 at 06:22:56PM +0800, Ray Chi wrote:
> Currently, there is a Kconfig (CONFIG_USB_FEW_INIT_RETRIES) to
> reduce retries when the port initialization is failed. The retry
> times are fixed and assigned in compile time. To improve the
> flexibility, this patch add four module parameters:
> port_reset_tries, set_address_tries, get_descriptor_tries,
> and get_maxpacket0_tries, to replace the original default values.
> 
> The default value of module parameters is the same as before
> to preserve the existing behavior.
> 
> Signed-off-by: Ray Chi <raychi@google.com>
> ---
>  .../admin-guide/kernel-parameters.txt         | 16 ++++++++++
>  drivers/usb/core/hub.c                        | 31 ++++++++++++++++---
>  2 files changed, 42 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 8090130b544b..c467b2778128 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6277,6 +6277,22 @@
>  			USB_REQ_GET_DESCRIPTOR request in milliseconds
>  			(default 5000 = 5.0 seconds).
>  
> +	usbcore.port_reset_tries=
> +			[USB] Set the retry time of port reset for each
> +			port initialization (default PORT_RESET_TRIES = 5).
> +
> +	usbcore.set_address_tries=
> +			[USB] set the retry time of set address for each
> +			port initialization (default SET_ADDRESS_TRIES = 2).
> +
> +	usbcore.get_descriptor_tries=
> +			[USB] set the retry time of set address for each
> +			port initialization (default GET_DESCRIPTOR_TRIES = 2).
> +
> +	usbcore.get_maxpacket0_tries=
> +			[USB] set the retry time of get maxpacket0 for each
> +			port initialization (default GET_MAXPACKET0_TRIES = 3).
> +
>  	usbcore.nousb	[USB] Disable the USB subsystem
>  
>  	usbcore.quirks=
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index b7f66dcd1fe0..c5c695886424 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2788,6 +2788,27 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
>  #define HUB_LONG_RESET_TIME	200
>  #define HUB_RESET_TIMEOUT	800
>  
> +/* define retry time for port reset */
> +static int port_reset_tries = PORT_RESET_TRIES;
> +module_param(port_reset_tries, int, S_IRUGO|S_IWUSR);
> +MODULE_PARM_DESC(port_reset_tries, "retry times of port reset for each port initialization");

Please no.  Module parameters are from the 1990's, let us never add new
ones if at all possible.

These are global options, for all devices in the system.  Instead, use
per-device settings if you really need to change these values.

But I would even push back on that and ask why these values need to be
changed at all.  What hardware is broken so badly that our timeout
settings do not work properly?  Can we modify them gracefully to "just
work" without any need for tweaking or requiring any modification by a
user at all?  That would be the better solution instead of requiring
users to do this on their own when confronted by misbehaving hardware.

thanks,

greg k-h

  reply	other threads:[~2022-06-21  7:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 10:22 [PATCH] USB: hub: add module parameters to usbcore for port init retries Ray Chi
2022-06-21  7:20 ` Greg KH [this message]
2022-07-01  9:46   ` Ray Chi
2022-07-01 10:35     ` Greg KH

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=YrFxLYibDtyuxSO6@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=albertccwang@google.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=raychi@google.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).