diff mbox series

[v2,RFC] USB: hub.c: decrease the number of attempts of enumeration scheme

Message ID 20200810001935.4489-2-yazzep@gmail.com (mailing list archive)
State Superseded
Headers show
Series [v2,RFC] USB: hub.c: decrease the number of attempts of enumeration scheme | expand

Commit Message

yasushi asano Aug. 10, 2020, 12:19 a.m. UTC
From: Yasushi Asano <yasano@jp.adit-jv.com>

According to 6.7.22 A-UUT “Device No Response” for connection timeout
of USB OTG and EH automated compliance plan v1.2, the enumeration
failure has to be detected within 30 seconds. However, the old and new
enumeration schemes made a total of 16 attempts, and each attempt can
take 5 seconds to timeout, so it failed with PET test. Modify it to
reduce the number of attempts to 5 and pass PET test.

in case of old_schene_first=N and use_both_schemes=Y
attempt 3 * new scheme, then 2 * old scheme
in case of old_schene_first=Y and use_both_schemes=Y
attempt 2 * old scheme, then 3 * new scheme

Signed-off-by: Yasushi Asano <yasano@jp.adit-jv.com>
---
 drivers/usb/core/hub.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Greg Kroah-Hartman Aug. 10, 2020, 7:46 a.m. UTC | #1
On Mon, Aug 10, 2020 at 09:19:35AM +0900, Yasushi Asano wrote:
> From: Yasushi Asano <yasano@jp.adit-jv.com>
> 
> According to 6.7.22 A-UUT “Device No Response” for connection timeout
> of USB OTG and EH automated compliance plan v1.2, the enumeration
> failure has to be detected within 30 seconds. However, the old and new
> enumeration schemes made a total of 16 attempts, and each attempt can
> take 5 seconds to timeout, so it failed with PET test. Modify it to
> reduce the number of attempts to 5 and pass PET test.
> 
> in case of old_schene_first=N and use_both_schemes=Y
> attempt 3 * new scheme, then 2 * old scheme
> in case of old_schene_first=Y and use_both_schemes=Y
> attempt 2 * old scheme, then 3 * new scheme
> 
> Signed-off-by: Yasushi Asano <yasano@jp.adit-jv.com>
> ---
>  drivers/usb/core/hub.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)

Why is there a "[RFC]" on the subject line, do you not think this works
properly?  Does it work for your devices and solve the problem for you?

thanks,

greg k-h
yasushi asano Aug. 11, 2020, 3:20 p.m. UTC | #2
Hello Greg, I'm sorry for the inconvenience. I was not sure how to use
[RFC] well. If the patch works well, we already don't need to add RFC
in the subject line? This patch works fine on my target.  If it is not
needed [PFC] ,I will send the patch again without RFC in the patch
title and subject line in email later.

Best regards
Yasushi Asano


2020年8月10日(月) 16:45 Greg KH <gregkh@linuxfoundation.org>:
>
> On Mon, Aug 10, 2020 at 09:19:35AM +0900, Yasushi Asano wrote:
> > From: Yasushi Asano <yasano@jp.adit-jv.com>
> >
> > According to 6.7.22 A-UUT “Device No Response” for connection timeout
> > of USB OTG and EH automated compliance plan v1.2, the enumeration
> > failure has to be detected within 30 seconds. However, the old and new
> > enumeration schemes made a total of 16 attempts, and each attempt can
> > take 5 seconds to timeout, so it failed with PET test. Modify it to
> > reduce the number of attempts to 5 and pass PET test.
> >
> > in case of old_schene_first=N and use_both_schemes=Y
> > attempt 3 * new scheme, then 2 * old scheme
> > in case of old_schene_first=Y and use_both_schemes=Y
> > attempt 2 * old scheme, then 3 * new scheme
> >
> > Signed-off-by: Yasushi Asano <yasano@jp.adit-jv.com>
> > ---
> >  drivers/usb/core/hub.c | 16 +++++++---------
> >  1 file changed, 7 insertions(+), 9 deletions(-)
>
> Why is there a "[RFC]" on the subject line, do you not think this works
> properly?  Does it work for your devices and solve the problem for you?
>
> thanks,
>
> greg k-h
yasushi asano Sept. 7, 2020, 3:50 p.m. UTC | #3
From: Yasushi Asano <yasano@jp.adit-jv.com>

Dear Alan
Dear Greg

I added the log which was not applied this patch and the log which 
was applied this patch to the commit statement. When this patch is 
applied, enumeration failure is detected within 30 seconds and 
the PET test is passed.

In addition, I also fixed the error output which is pointed out 
from the kernel test robot. 
I would appreciate it if you would advance this PR. 
Thank you in advance.

Yasushi Asano (1):
  USB: hub.c: decrease the number of attempts of enumeration scheme

 drivers/usb/core/hub.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 052d5ac..5b15278c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2706,7 +2706,6 @@  static unsigned hub_is_wusb(struct usb_hub *hub)
 
 
 #define PORT_RESET_TRIES	5
-#define SET_ADDRESS_TRIES	2
 #define GET_DESCRIPTOR_TRIES	2
 #define SET_CONFIG_TRIES	(2 * (use_both_schemes + 1))
 #define USE_NEW_SCHEME(i, scheme)	((i) / 2 == (int)(scheme))
@@ -4539,7 +4538,7 @@  hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
 	struct usb_device	*hdev = hub->hdev;
 	struct usb_hcd		*hcd = bus_to_hcd(hdev->bus);
 	struct usb_port		*port_dev = hub->ports[port1 - 1];
-	int			retries, operations, retval, i;
+	int			retries, retval, i;
 	unsigned		delay = HUB_SHORT_RESET_TIME;
 	enum usb_device_speed	oldspeed = udev->speed;
 	const char		*speed;
@@ -4684,7 +4683,7 @@  hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
 			 * 255 is for WUSB devices, we actually need to use
 			 * 512 (WUSB1.0[4.8.1]).
 			 */
-			for (operations = 0; operations < 3; ++operations) {
+			if (!((retry_counter % 2 != 0) && (retries != 0))) {
 				buf->bMaxPacketSize0 = 0;
 				r = usb_control_msg(udev, usb_rcvaddr0pipe(),
 					USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
@@ -4714,7 +4713,10 @@  hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
 						retries == 0 &&
 						udev->speed > USB_SPEED_FULL))
 					break;
+			} else {
+				break;
 			}
+
 			udev->descriptor.bMaxPacketSize0 =
 					buf->bMaxPacketSize0;
 			kfree(buf);
@@ -4744,12 +4746,8 @@  hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
 		 * authorization will assign the final address.
 		 */
 		if (udev->wusb == 0) {
-			for (operations = 0; operations < SET_ADDRESS_TRIES; ++operations) {
-				retval = hub_set_address(udev, devnum);
-				if (retval >= 0)
-					break;
-				msleep(200);
-			}
+			retval = hub_set_address(udev, devnum);
+			msleep(200);
 			if (retval < 0) {
 				if (retval != -ENODEV)
 					dev_err(&udev->dev, "device not accepting address %d, error %d\n",