2004-06-15 18:29:46

by Byron Stanoszek

[permalink] [raw]
Subject: [PATCH] Make USB process hub events in correct order

This patch fixes the USB hub module to process events in the order that they
are received. It fixes the case where multi-port devices have multiple
hubs in them--while they are detected in the correct order, they are
initialized in reverse. It is required for the Sealink 8-port USB->serial hubs
to initialize with the port numbers in the correct order.

I don't think it breaks any existing functionality, but I won't send this to
Linus yet till I know it doesn't break anything.

Patch below against 2.6.7-rc3.



--- linux/drivers/usb/core/hub.bak 2004-06-08 10:21:57.000000000 -0400
+++ linux/drivers/usb/core/hub.c 2004-06-08 10:59:34.000000000 -0400
@@ -260,7 +260,7 @@

/* Something happened, let khubd figure it out */
if (list_empty(&hub->event_list)) {
- list_add(&hub->event_list, &hub_event_list);
+ list_add_tail(&hub->event_list, &hub_event_list);
wake_up(&khubd_wait);
}


An example without the patch (1-1.2.1 gets initialized before 1-1.1.1):

usb 1-1: new full speed USB device using address 2
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
usb 1-1.1: new full speed USB device using address 3
hub 1-1.1:1.0: USB hub found
hub 1-1.1:1.0: 4 ports detected
usb 1-1.2: new full speed USB device using address 4
hub 1-1.2:1.0: USB hub found
hub 1-1.2:1.0: 4 ports detected
usb 1-1.2.1: new full speed USB device using address 5
ftdi_sio 1-1.2.1:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.1: FTDI FT232BM Compatible converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
usb 1-1.2.2: new full speed USB device using address 6
ftdi_sio 1-1.2.2:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.2: FTDI FT232BM Compatible converter now attached to ttyUSB1 (or usb/tts/1 for devfs)
usb 1-1.2.3: new full speed USB device using address 7
ftdi_sio 1-1.2.3:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.3: FTDI FT232BM Compatible converter now attached to ttyUSB2 (or usb/tts/2 for devfs)
usb 1-1.2.4: new full speed USB device using address 8
ftdi_sio 1-1.2.4:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.4: FTDI FT232BM Compatible converter now attached to ttyUSB3 (or usb/tts/3 for devfs)
usb 1-1.1.1: new full speed USB device using address 9
ftdi_sio 1-1.1.1:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.1: FTDI FT232BM Compatible converter now attached to ttyUSB4 (or usb/tts/4 for devfs)
usb 1-1.1.2: new full speed USB device using address 10
ftdi_sio 1-1.1.2:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.2: FTDI FT232BM Compatible converter now attached to ttyUSB5 (or usb/tts/5 for devfs)
usb 1-1.1.3: new full speed USB device using address 11
ftdi_sio 1-1.1.3:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.3: FTDI FT232BM Compatible converter now attached to ttyUSB6 (or usb/tts/6 for devfs)
usb 1-1.1.4: new full speed USB device using address 12
ftdi_sio 1-1.1.4:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.4: FTDI FT232BM Compatible converter now attached to ttyUSB7 (or usb/tts/7 for devfs)


With the patch (the correct ordering):

usb 1-1: new full speed USB device using address 2
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
usb 1-1.1: new full speed USB device using address 3
hub 1-1.1:1.0: USB hub found
hub 1-1.1:1.0: 4 ports detected
usb 1-1.2: new full speed USB device using address 4
hub 1-1.2:1.0: USB hub found
hub 1-1.2:1.0: 4 ports detected
usb 1-1.1.1: new full speed USB device using address 5
ftdi_sio 1-1.1.1:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.1: FTDI FT232BM Compatible converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
usb 1-1.1.2: new full speed USB device using address 6
ftdi_sio 1-1.1.2:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.2: FTDI FT232BM Compatible converter now attached to ttyUSB1 (or usb/tts/1 for devfs)
usb 1-1.1.3: new full speed USB device using address 7
ftdi_sio 1-1.1.3:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.3: FTDI FT232BM Compatible converter now attached to ttyUSB2 (or usb/tts/2 for devfs)
usb 1-1.1.4: new full speed USB device using address 8
ftdi_sio 1-1.1.4:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.1.4: FTDI FT232BM Compatible converter now attached to ttyUSB3 (or usb/tts/3 for devfs)
usb 1-1.2.1: new full speed USB device using address 9
ftdi_sio 1-1.2.1:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.1: FTDI FT232BM Compatible converter now attached to ttyUSB4 (or usb/tts/4 for devfs)
usb 1-1.2.2: new full speed USB device using address 10
ftdi_sio 1-1.2.2:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.2: FTDI FT232BM Compatible converter now attached to ttyUSB5 (or usb/tts/5 for devfs)
usb 1-1.2.3: new full speed USB device using address 11
ftdi_sio 1-1.2.3:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.3: FTDI FT232BM Compatible converter now attached to ttyUSB6 (or usb/tts/6 for devfs)
usb 1-1.2.4: new full speed USB device using address 12
ftdi_sio 1-1.2.4:1.0: FTDI FT232BM Compatible converter detected
usb 1-1.2.4: FTDI FT232BM Compatible converter now attached to ttyUSB7 (or usb/tts/7 for devfs)


-Byron

--
Byron Stanoszek Ph: (330) 644-3059
Systems Programmer Fax: (330) 644-8110
Commercial Timesharing Inc. Email: [email protected]


Attachments:
usb-2.6.patch (395.00 B)

2004-06-15 20:08:36

by Greg KH

[permalink] [raw]
Subject: Re: [linux-usb-devel] [PATCH] Make USB process hub events in correct order

On Tue, Jun 15, 2004 at 02:26:49PM -0400, Byron Stanoszek wrote:
> This patch fixes the USB hub module to process events in the order that they
> are received. It fixes the case where multi-port devices have multiple
> hubs in them--while they are detected in the correct order, they are
> initialized in reverse. It is required for the Sealink 8-port USB->serial
> hubs
> to initialize with the port numbers in the correct order.
>
> I don't think it breaks any existing functionality, but I won't send this to
> Linus yet till I know it doesn't break anything.

Linus isn't the person to send this to :)

> Patch below against 2.6.7-rc3.

You know you still can't rely on the events happening in "numerical"
order, even with this patch, right?

That's what tools like udev is for, that way you can always name your
/dev/ttyUSB* devices properly.

Anyway, I don't have a problem with this patch, other than it doesn't
apply to the current USB tree, as there has been a lot of work in the
hub driver recently. Care to make it up again against the latest -mm
release, as that has the USB development tree included in it.

thanks,

greg k-h