Juan Zea <juan.zea@xxxxxxxxxx> writes: > Having a look at the code of the VHCI driver at > https://github.com/torvalds/linux/tree/master/drivers/usb/usbip , I > found these two parameters: USBIP_VHCI_HC_PORTS and USBIP_VHCI_NR_HCS > > I've compiled VHCI driver from latest source above, altering both > parameters to get higher number of controllers and ports per > controller (not only the driver, but also the usbip cli tool at > https://github.com/torvalds/linux/tree/master/tools/usb/usbip ), and > run into several problems: > > 1. USBIP_VHCI_HC_PORTS x USBIP_VHCI_NR_HCS <= 128 > > It seems, whatever the combination of both parameters, usbip command > line tool won't accept that your driver is compiled with numbers > violating the above rule. Is this a problem of the tool code or is > there a reason behind this? As far as I 've researched, the 127 > devices limit in Linux is per controller, so increasing the number of > controllers in usbip driver shouldn't be limited this way, am I wrong? > > 2. I've compiled with 4 ports per controller and 32 controllers. Given > that the drivers creates an usb2 and an usb3 controller, it results in > 64 controllers with four ports each: 128 ports. Here, usbip cli tool > works. But... if you try to attach a device, the kernel dumps a trace > that starts with this: > > Oct 30 10 :43:14 test-mononode-ubuntu-16 kernel: [ 44.138068] usbcore: failed to get bus number > Oct 30 10 :43:14 test-mononode-ubuntu-16 kernel: [ 44.138813] vhci_hcd: usb_add_hcd hs failed -7 > Oct 30 10 :43:14 test-mononode-ubuntu-16 kernel: [ 44.139559] vhci_hcd: probe of vhci_hcd.31 failed with error -7 > Oct 30 10 :44:23 test-mononode-ubuntu-16 kernel: [ 113.345824] BUG: unable to handle kernel NULL pointer dereference at 0000000000000230 > Oct 30 10 :44:23 test-mononode-ubuntu-16 kernel: [ 113.347584] IP: status_show+0x13c/0x360 [vhci_hcd] > Oct 30 10 :44:23 test-mononode-ubuntu-16 kernel: [ 113.348592] PGD 1398cc067 > Oct 30 10 :44:23 test-mononode-ubuntu-16 kernel: [ 113.348593] PUD 136a96067 > Oct 30 10 :44:23 test-mononode-ubuntu-16 kernel: [ 113.349119] PMD 0 > > This leads me to thinking there is some problem with such a big number > of controllers, although the controller number parameters is supposed > to have a max value of 128. Could this be related to the kernel I'm > using? Maybe I should compile the full kernel to get higher numbers > working? You are correct. There are multiple issues here: 1) the drivers/usb/core/hcd.c has a limit on the number of USB buses. This is currently 64, and not configurable without editing the source. So setting USBIP_VHCI_NR_HCS to anything higher than ~30 is futile and has probably never been tested. It cannot work 2) The sysfs code does not consider the possibility that one or more of the VHCIs could have failed to register. It will happily register attributes for all "vhci_num_controllers", and does little to sanity check anything when accessing those attributes. So it should not come as a surprise that this goes Ooops if one or more controllers have failed to register. > 3. For this last test, I compiled with smaller numbers, just to test > how the several controllers thing works. Specifically, one port per > controller, 16 controllers in total. This leads to the module loading, > the controllers listable with lsusb, and no problems in kernel log. I > attach one device, and it goes to the first controller. Working... no > problem at all. But, if you attach a second device, the command hangs > and I get this in syslog: > > Oct 30 11 :07:14 test-mononode-ubuntu-16 kernel: [ 1078.239613] vhci_hcd vhci_hcd.0: port 0 already used > > This message was repeated for more than 7000 times before I could stop > the command. So... my conclusion is that usbip won't work correctly if > compiled with more than one controller. Is this related to the usbip > cli tool or is there any problem at the driver? I think it would be great if you could work a little on the usbip drivers. The multi-controller support was very immature when it was merged, and has not gotten much love since. I still think using a fixed number of controllers was a big mistake. It would have been much better to add controllers dynamically when you needed more ports. The bugs you have found are fallout of the shortcuts taken when the code was merged. Bjørn -- 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