This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MUSB driver and packet loss

Hi there,

I'm using a system that packs an ARM CPU. The usb controller should be an Inventra HDRC USB Controller so I'm using the MUSB OTG driver and I'm trying to use it with a device that uses isochronous transfer (about 20-30 MB/s). I patched the /driver/usb/musb/musb_host.h/c and musb_core.h/c  with: http://www.mail-archive.com/linux-omap@vger.kernel.org/msg03991.html but after some packet transfers there is a massive packet loss as you can see:

 

.....

Creating EP 81 transfer #14

Creating EP 81 transfer #15

.....

Write Reg 0x0005 <= 0x00

Control cmd=0003 tag=0000 len=0004: 12

Control reply: 12

 

[stram 70] Invalid magic ffff

....

[stream 70] Not synced yet...

..

[stream 70] Lost 8 packets

[Stream 70] Lost too many packets, resyncing...

...

[Stream 70] Invalid magic c458

[Stream 70] Invalid magic af39

...

 

 

[stream 70] Lost 8 packets

[Stream 70] Lost too many packets, resyncing...

 

 

The packets are of big dimension: 1760 and 1920 bytes. Some people has my same problem and they think that the problem is in this kernel driver.

They said that It seems that the USB stack is forwarding packets with some sort of offset and that the packets are prone to be forwarded non-ordered.

 

Any idea of the possible cause of this behavior?

 

Cheers

 

  • Dany,

    Please try below patch and let us knwo the result,

    http://arago-project.org/git/people/?p=sriram/ti-psp-omap.git;a=commitdiff;h=d516a8b2de9d04d32850f29020635f4f65e3695e

    Regards,

    Ajay

  • Hi Ajay and thanks for the answer.

    I can't apply that patch, the code is too different.

    Some days ago the camera didn't initialize but after I applied this patch and now at least initializes. 

    http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a483d7068f661213e9586d4d132fc0e0287118b4;hp=d1043a2697effee3054451a9293a376bfb013e4b


    My musb_core.h, musb_core.c and musb_host.c are these:

    http://pastebin.com/ur07CkNh            ----> musb_core.h

    http://pastebin.com/EmSvME3C        ----> musb_core.c

    http://pastebin.com/RzFJKsbL           .......>musb_host.c

     

    I modified musb_core.c, creating different fifo_cfg with different settings (taking into account that the size of the packet transmitted is very big) but nothing happend.

    I was thinking too that the problem could be the 600 Mhz CPU (I hope not....), what do you think?

     

    I read that usb hubs are not supported. I'm using a female to female usb adapter.. is it considered a usb hub?

     

     

     

     

     

  • About the modifies I was speaking about, the configuration I have tried are of this type:

     

    --- ds_musb_core.c 2011-02-18 11:18:05.000000000 +0000

    +++ musb_core.c.ver9 2011-02-22 23:01:54.000000000 +0000

    @@ -1364,6 +1364,20 @@

     { .hw_ep_num =  9, .style = FIFO_RX,   .maxpacket = 512, },

     };

     

    +/* mode 6 - fits in 16KB */

    +static struct fifo_cfg __initdata mode_6_cfg[] = {

    +{ .hw_ep_num =  1, .style = FIFO_TX,   .maxpacket = 256, },

    +{ .hw_ep_num =  1, .style = FIFO_RX,   .maxpacket = 256, }, 

    +{ .hw_ep_num =  2, .style = FIFO_RXTX,  .maxpacket = 2048, }, 

    +{ .hw_ep_num =  3, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  4, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  5, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  6, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  7, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  8, .style = FIFO_RXTX,  .maxpacket = 2048, },

    +{ .hw_ep_num =  8, .style = FIFO_RXTX,  .maxpacket = 1024, },

    +};

    +

     /*

      * configure a fifo; for non-shared endpoints, this may be called

      * once for a tx fifo and once for an rx fifo.

    @@ -1466,6 +1480,8 @@

     

      if (machine_is_nokia_rx51())

      fifo_mode = 5;

    +

    + fifo_mode=6; //danyfix

     

      switch (fifo_mode) {

      default:

    @@ -1495,6 +1511,10 @@

      cfg = mode_5_cfg;

      n = ARRAY_SIZE(mode_5_cfg);

      break;

    + case 6://danyfix mode

    + cfg = mode_6_cfg;

    + n = ARRAY_SIZE(mode_6_cfg);

    + break;

      }

     

      printk(KERN_DEBUG "%s: setup fifo_mode %d\n",

  • [I modified musb_core.c, creating different fifo_cfg with different settings (taking into account that the size of the packet transmitted is very big) but nothing happend.]

    There is already an entry with 4K in mode_4_cfg so this part is ok.

    [I was thinking too that the problem could be the 600 Mhz CPU (I hope not....), what do you think?]

    I have used high bandwidth camera with OMAP3EVM running at same speed and no issue in streaming.

     [I read that usb hubs are not supported. I'm using a female to female usb adapter.. is it considered a usb hub?]

    Who said so? Which platform are you using ? You should be able to connect the usb hub to OTG port via a min-A plug to STD-A receptacle.

    Regards,
    Ajay

  •  

    [There is already an entry with 4K in mode_4_cfg so this part is ok.]

    No it isn't. The endpoints of the camera are two. Packet sizes at the most are 1920 (2 x960) bytes for the first endpoint and  1760 for the second.

    Modifying the usb_core.c, without  adding another entry with >2K I get the ENOSPC error for one of these two endpoints.

     

    [I have used high bandwidth camera with OMAP3EVM running at same speed and no issue in streaming.]

    Yep, you're right. I tried to overclock the CPU at 1Ghz but same results.

     

    [Who said so? Which platform are you using ? You should be able to connect the usb hub to OTG port via a min-A plug to STD-A receptacle]

    In musb_core.c there is written:

     

    "At one extreme, bandwidth can be overcommitted in

     *        some hardware configurations, no faults will be reported.

     *        At the other extreme, the bandwidth capabilities which do

     *        exist tend to be severely undercommitted.  You can't yet hook

     *        up both a keyboard and a mouse to an external USB hub."

     

     

    I'm using a N900 with female to female USB adapter, and the stock USB cable.

    More info here:

    http://www.nokian900applications.com/usb-on-the-go-on-nokia-n900/

    http://talk.maemo.org/showthread.php?t=65232&highlight=usb+host

     

    I get also  a lot of "magic number errors" meaning that the packets arriving to my application (I'm using libusb but the problem is here in the kernel) maybe are not sent by the kernel in the correct order. One guy with a similar problem was suggesting that since the application requires almost every time 1960 bytes, (two packets of 960) so if the stream is 0 1 2 3 4 5 6 7... maybe sometimes it gets the packets in this order [0 1] [2 3] [4 5] ... sometimes in this other 0 [1 2] [3 4]. 

     

     

  • Dany,

    I don;t think there would be any issue with supporting external hubs. So do you still see packet drops with new FIFO table you set? COuld you apply the patch on workqueue I sent earlier ?

    Regards,
    ajay

  • Hi Ajay,

    I have checked well and I have seen that I receive more packets that I thought but a lot of these packets have errors in the header and probably also in the data even if the sequence number is often ok (the only field that it seems not corrupted).

    That patch is very very hard to apply because my kernel is a bit old and it is not the standard kernel. It's modified by nokia and has also other hacks.

    I applied  manually just the patch:  http://www.mail-archive.com/linux-omap@vger.kernel.org/msg03991.html 

  • hi again,

     

    does anyone know the main fix/change in terms of usb transfers between kernel 2.6.32 to kernel 2.6.35?

    Somobody solved a problem similar to mine making this update

     

    Cheers