Re: Scheduling of interrupt transfer delayed on ehci when interval not 1?

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

 



On Tue, Oct 15, 2013 at 6:07 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:

> Why does the driver make this mistake?

My initial assumption was wrong, the driver doesn't infrequently poll, but
does so more often. I was misled by the confusing source.
However, I now made usbmon traces and analyzed them with LibreOffice.

During data transfer, the driver does a interrupt transfer about 48ms after
the last one, and has to wait about 15ms for the result. But every 40 transfers,
it executes 3 transfers without waiting inbetween and has to wait 63ms for the
result. This is with transfer interval set to 10 on xhci.
I also compiled the driver with transfer interval set to 1 (the
original setting before
my patch [1]), but the result is similar, an interrupt transfer every
44ms, and waiting
of 19ms for the result. I don't have ehci hardware to test it.

When the URB completition callback is executed, it calles complete(),
while the driver
is using wait_for_completion_interruptible_timeout() for this signal
with 100ms timeout
(originally that was 50ms but I changed it in patch [2] to make it
work with xhci)

This function seems to timeout on ehci hardware after about 700MB to
7GB transfered.

I guess that the thread isn't scheduled fast enough under load, although the USB
transfer was successful.

> Does the device connect at high speed (480 Mb/s)?

Yes, even with xhci it is only using 480Mb/s.

> What needs to be fixed?  It sounds like xhci-hcd and ehci-hcd are
> working correctly and the problem is in the rts5139 driver.
After looking at the usbmon traces, i have to agree.

> bInterval = 10 means the polling period is 64 ms (for a high-speed
> device).  So a timeout of 100 ms should be adequate -- provided the
> device always sends data over the interrupt endpoint without any
> further delay.

What i do not understand: with ehci hardware, the driver works when
interval in the urb is set to 1 and the timeout is 50ms.

With xhci, the urb appears to be scheduled not more often then every
64ms even if the interval in the urb is set to 1.

I'm just looking for the correct solution for this issue.

regards
Marcus

below some more info:


[1] patch I made to get rid of syslog warnings because of wrong
interval with xhci (that broke it for ehci hardware)
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6441a57887281106ed01222c2b0561ab25f77212

[2] patch I made to get it working on xhci (increasing timeout from 50 to 100):
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c5c141dfe737706d8bd57f40b4a9a8818c5ce4der

T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs=  1
P:  Vendor=0bda ProdID=0129 Rev=39.60
S:  Manufacturer=Generic
S:  Product=USB2.0-CRW
S:  SerialNumber=20100201396000000
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=   3 Ivl=64ms


root@goetterdaemmerung:/home/marcus/linux# lsusb -v -s 3:2

Bus 003 Device 002: ID 0bda:0129 Realtek Semiconductor Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x0129
  bcdDevice           39.60
  iManufacturer           1 Generic
  iProduct                2 USB2.0-CRW
  iSerial                 3 20100201396000000
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          4 CARD READER
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      6
      bInterfaceProtocol     80
      iInterface              5 Bulk-In, Bulk-Out, Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0003  1x 3 bytes
        bInterval              10
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)
root@goetterdaemmerung:/home/marcus/linux#
--
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