Re: [PATCH V5 8/8] usb : Add usb port's power control attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012年06月30日 23:22, Alan Stern wrote:
On Sat, 30 Jun 2012, Lan Tianyu wrote:

Do you mean while a new device was enumerating, the port powered off? I
guess the enumerating process will fail.

That's what I thought too, but I haven't actually tried it.  Something
strange might happen when two different threads send concurrent
messages to the same hub port.  You might want to do a few experiments.

Ok. I will do some experiments. But I guess it may be hard. Those two
operation maybe too quirk to be simultaneous. :)

Add ssleep() calls at the right spots.  Then you can make anything
happen the way you want.  :-)

What's concurrent messages? I think even from the two threads, messages
will also be processed in the message queue in order. Right?

Yes, they will be.  But even so, messages from one thread might occur
in between messages from a different thread.

hi alan:
I have done some experiments. I insert clear PORT_POWER in the hub_port_connect_change() to simulate such situation. I found there is leak if I clear PORT_POWER in the hub_port_connect_change()
after hub_port_init() and before usb_new_device().

[    7.083502] xhci_hub_control: clear port power, actual port 1 status  = 0xe01
[    7.090793] usb 1-2: unable to read config index 0 descriptor/start: -71
[    7.097469] usb 1-2: chopping to 0 config(s)
[    7.098898] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[    7.107898] ata2.00: ATAPI: Optiarc BD ROM BC-5640H, 1.00, max UDMA/100
[    7.107982] usb 1-2: string descriptor 0 read error: -71
[    7.107988] usb 1-2: New USB device found, idVendor=0781, idProduct=5567
[    7.107990] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    7.108144] usb 1-2: no configuration chosen from 0 choices
In usb_get_configuration(), usb_get_descriptor failed but not return err. The device
was still enumerated. I do following change and it works. Why here don't return err?

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index f4bdd0c..90f962b 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -704,7 +704,7 @@ int usb_get_configuration(struct usb_device *dev)
                            "descriptor/%s: %d\n", cfgno, "start", result);
                        dev_err(ddev, "chopping to %d config(s)\n", cfgno);
                        dev->descriptor.bNumConfigurations = cfgno;
-                       break;
+                       goto err;
                } else if (result < 4) {
                        dev_err(ddev, "config index %d descriptor too short "
                            "(expected %i, got %i)\n", cfgno,

Alan Stern


--
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux