RE: USB2.0 disk format failure in windows guest

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

 



> -----Original Message-----
> From: Alan Stern [mailto:stern@xxxxxxxxxxxxxxxxxxx]
> Sent: Tuesday, April 16, 2013 1:44 AM
> To: Gonglei (Arei)
> Cc: linux-usb@xxxxxxxxxxxxxxx; Yanqiangjun; Hanweidong; Luonengjun;
> kraxel@xxxxxxxxxx; hdegoede@xxxxxxxxxx; qemu-devel@xxxxxxxxxx
> Subject: RE: USB2.0 disk format failure in windows guest
> 
> On Sun, 14 Apr 2013, Gonglei (Arei) wrote:
> 
> > > > Hi Alan,
> > > > We pass-throughed USB 2.0 disk to guest using usb-host (qemu option:
> > > -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=2,hostport=1)
> on
> > > KVM(on linux-3.8.3 or linux-3.0.13) and qemu 1.4.0 ,
> > >
> > > Are you sure this disk was using EHCI?  The attached log shows bulk
> > > packet sizes that aren't multiples of 512, which isn't possible in the
> > > middle of a high-speed transfer.
> >
> > Yes, this disk was using EHCI, since guest QEMU and Linux kernel both
> > prints matching EHCI logs, such as transfer types and transfer sizes.
> > There are many buck-out URBs whose sizes are 31 or 4064 that are not
> > multiples of 512. Since URB size 31 does occur without guest format
> > USB 2.0 disk sceneiro, did you mean that buck-out size 4064 should
> > not occur? /* EHCI spec version 1.0 Section 4.10.6 */
> 
> That's right; it should not occur.
> 
> It's okay to have an URB size that isn't a multiple of 512 if that URB
> is the last one in a transfer.  For example, the 31-byte URBs were the
> only URBs in their transfers, so they were okay.  But the 4064-byte
> URBs occurred at the start and in the middle of their transfers, so
> they were wrong.
> 

Alan, the code which get the virtual machine USB packet in the Qemu is as follows:
# /qemu-1.4.0/hw/usb/hcd-ehci.c
static int ehci_init_transfer(EHCIPacket *p)
{
    uint32_t cpage, offset, bytes, plen;
    dma_addr_t page;

    cpage  = get_field(p->qtd.token, QTD_TOKEN_CPAGE);
    bytes  = get_field(p->qtd.token, QTD_TOKEN_TBYTES);
    offset = p->qtd.bufptr[0] & ~QTD_BUFPTR_MASK;
    pci_dma_sglist_init(&p->sgl, &p->queue->ehci->dev, 5);

    while (bytes > 0) {
        if (cpage > 4) {
            fprintf(stderr, "cpage out of range (%d)\n", cpage);
            return USB_RET_PROCERR;
        }

        page  = p->qtd.bufptr[cpage] & QTD_BUFPTR_MASK;
        page += offset;
        plen  = bytes;
        if (plen > 4096 - offset) {
            plen = 4096 - offset;
            offset = 0;
            cpage++;
        }

        qemu_sglist_add(&p->sgl, page, plen);
        bytes -= plen;
    }
    return 0;
}

After our repeated verification and debug, we found that windows virtual machine USB disk format will send a 64Kbits's URB packet which was divided into four QTD (Size: 19968,16384,16384,12800):
The first QTD offset is 32, split into five URB 4064/4096/4096/4096/3616 bits ( we don't understand why the offset is always 32, but the linux virtual machine is always 0)
The second QTD offset 3616, split into five URB 480/4096/4096/4096/3616 bits
Third QTD offset is 3616, split into five URB 480/4096/4096/4096/3616 bits
Fourth QTD offset is 3616, split into five URB 480/4096/4096/4096/32 bits

> > > What kernel version did you use while recording this log?
> >
> > We tested KVM on Linux 3.8.3 and Linux 3.0.13, and the problem exists
> > on both kernels.
> 
> But which kernel version did you use while recording the log that you
> posted?

Sorry, the kernel version is Linux-3.8.3 while recording the log.

> 
> Also, what type of computer is your host?

The host's system Information:
	    Manufacturer: Huawei Technologies Co., Ltd.
        Product Name: Tecal RH2285
BTW, we tested on the IBM Server (IBM System X iDataPlex dx360 M4 Server -[7912FT1]-), and got the same results.

> 
> > This time we attached a usbmon USB disk format failed log and
> > USBlyzer' logs for another test. Would you give us some advice,
> > thanks a lot!
> >
> > Something look like:
> >
> > ffff88180b974600 480512312 S Bo:6:009:2 -115 31 = 55534243 50599784
> 00000100 00000a2a 00000008 de000080 00000000 000000
> > ffff88180b974600 480512375 C Bo:6:009:2 0 31 >
> > ffff88180b974600 480513372 S Bo:6:009:2 -115 4064 = f8ffff0f ffffff0f ffffff0f
> 00000000 00000000 00000000 00000000 00000000
> 
> This is a lot more concise than the other log, but it still shows the
> same problem: the 4064-byte URB.
> 
> Can you post the contents of the /sys/kernel/debug/usb/devices file?
> 
OK, it looks like

$ cat /sys/kernel/debug/usb/devices 

T:  Bus=06 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 6
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1d.7
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=06 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  9 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=136b ProdID=0003 Rev= 1.00
S:  Manufacturer=STEC
S:  Product=STEC USB 2.0
S:  SerialNumber=86C7150011163C1E
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=300mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

T:  Bus=06 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  8 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0781 ProdID=5571 Rev= 1.26
S:  Manufacturer=SanDisk
S:  Product=Cruzer Fit
S:  SerialNumber=4C532000060611107175
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=200mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=125us

T:  Bus=05 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=0000:00:1a.7
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12   MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0001 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:1d.2
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12   MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0001 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:1d.1
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12   MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0001 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:1d.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12   MxCh= 2
B:  Alloc=  4/900 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0001 Rev= 3.08
S:  Manufacturer=Linux 3.8.3-0.27-gonglei uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:1a.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=0003 Rev= 1.00
S:  Manufacturer=Huawei Technologies  
S:  Product=HUAWEI Keyboard/Mouse KVM 1.1.0
C:* #Ifs= 2 Cfg#= 1 Atr=40 MxPwr=  2mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=5ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid
E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=5ms

Thanks for your help!

-Gonglei



��.n��������+%������w��{.n�����{���)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥





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

  Powered by Linux