All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL] usb patch queue
@ 2011-11-01 14:56 Gerd Hoffmann
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Three little usb patches for 1.0.

please pull,
  Gerd

The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240:

  Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500)

are available in the git repository at:

  git://git.kraxel.org/qemu usb.29

Gerd Hoffmann (2):
      usb-hub: wakeup on attach
      usb-host: fix host close

Roy Tam (1):
      usb: change VID/PID for usb-hub and usb-msd to prevent conflict

 hw/usb-hub.c |    5 +++--
 hw/usb-msd.c |    4 ++--
 usb-linux.c  |    6 ++++--
 3 files changed, 9 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
@ 2011-11-01 14:56 ` Gerd Hoffmann
  2011-11-02  9:38   ` hkran
  2011-11-10  3:45   ` hkran
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

When attaching a new device we must send a wakeup request to the root
hub, otherwise the guest will not notice the new device in case the
usb hub is suspended.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb-hub.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 09c6516..7b47079 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -163,6 +163,7 @@ static void usb_hub_attach(USBPort *port1)
     } else {
         port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
     }
+    usb_wakeup(&s->dev);
 }
 
 static void usb_hub_detach(USBPort *port1)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
  2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
@ 2011-11-01 14:56 ` Gerd Hoffmann
  2011-11-01 15:29   ` Andreas Färber
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 3/3] usb-host: fix host close Gerd Hoffmann
  2011-11-01 18:13 ` [Qemu-devel] [PULL] usb patch queue Anthony Liguori
  3 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Roy Tam

From: Roy Tam <roytam@gmail.com>

Some USB drivers, for example USBASPI.SYS, will skip different type of
device which has same VID/PID. The following patch helps preventing
usb-msd being skipped by the driver.

Sign-off-by: Roy Tam <roytam@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb-hub.c |    4 ++--
 hw/usb-msd.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 7b47079..3eb0f1a 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -127,8 +127,8 @@ static const USBDescDevice desc_device_hub = {
 
 static const USBDesc desc_hub = {
     .id = {
-        .idVendor          = 0,
-        .idProduct         = 0,
+        .idVendor          = 0x0409,
+        .idProduct         = 0x55aa,
         .bcdDevice         = 0x0101,
         .iManufacturer     = STR_MANUFACTURER,
         .iProduct          = STR_PRODUCT,
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 1a0815a..b734177 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -162,8 +162,8 @@ static const USBDescDevice desc_device_high = {
 
 static const USBDesc desc = {
     .id = {
-        .idVendor          = 0,
-        .idProduct         = 0,
+        .idVendor          = 0x46f4, /* CRC16() of "QEMU" */
+        .idProduct         = 0x0001,
         .bcdDevice         = 0,
         .iManufacturer     = STR_MANUFACTURER,
         .iProduct          = STR_PRODUCT,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 3/3] usb-host: fix host close
  2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict Gerd Hoffmann
@ 2011-11-01 14:56 ` Gerd Hoffmann
  2011-11-01 18:13 ` [Qemu-devel] [PULL] usb patch queue Anthony Liguori
  3 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 14:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The whole usb_host_close() function is skipped in case the device is not
in attached state.  This is wrong though, only then usb_device_detach()
must be skipped, all other cleanup (especially device reset and closing
the file handle) still needs to be done.  There are code paths where
usb_host_close() is called with the device in detached state already.

This fixes usb-host devices not being released and returned to the host
after removing them with device_del.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 usb-linux.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index 7d4d1d7..f086d57 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1349,7 +1349,7 @@ static int usb_host_close(USBHostDevice *dev)
 {
     int i;
 
-    if (dev->fd == -1 || !dev->dev.attached) {
+    if (dev->fd == -1) {
         return -1;
     }
 
@@ -1367,7 +1367,9 @@ static int usb_host_close(USBHostDevice *dev)
     }
     async_complete(dev);
     dev->closing = 0;
-    usb_device_detach(&dev->dev);
+    if (dev->dev.attached) {
+        usb_device_detach(&dev->dev);
+    }
     ioctl(dev->fd, USBDEVFS_RESET);
     close(dev->fd);
     dev->fd = -1;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict Gerd Hoffmann
@ 2011-11-01 15:29   ` Andreas Färber
  2011-11-01 15:40     ` Gerd Hoffmann
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Färber @ 2011-11-01 15:29 UTC (permalink / raw)
  To: Gerd Hoffmann, Roy Tam; +Cc: qemu-devel

Am 01.11.2011 15:56, schrieb Gerd Hoffmann:
> From: Roy Tam <roytam@gmail.com>
> 
> Some USB drivers, for example USBASPI.SYS, will skip different type of
> device which has same VID/PID. The following patch helps preventing
> usb-msd being skipped by the driver.
> 

> Sign-off-by: Roy Tam <roytam@gmail.com>

Typo?

Andreas

> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/usb-hub.c |    4 ++--
>  hw/usb-msd.c |    4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/usb-hub.c b/hw/usb-hub.c
> index 7b47079..3eb0f1a 100644
> --- a/hw/usb-hub.c
> +++ b/hw/usb-hub.c
> @@ -127,8 +127,8 @@ static const USBDescDevice desc_device_hub = {
>  
>  static const USBDesc desc_hub = {
>      .id = {
> -        .idVendor          = 0,
> -        .idProduct         = 0,
> +        .idVendor          = 0x0409,
> +        .idProduct         = 0x55aa,
>          .bcdDevice         = 0x0101,
>          .iManufacturer     = STR_MANUFACTURER,
>          .iProduct          = STR_PRODUCT,
> diff --git a/hw/usb-msd.c b/hw/usb-msd.c
> index 1a0815a..b734177 100644
> --- a/hw/usb-msd.c
> +++ b/hw/usb-msd.c
> @@ -162,8 +162,8 @@ static const USBDescDevice desc_device_high = {
>  
>  static const USBDesc desc = {
>      .id = {
> -        .idVendor          = 0,
> -        .idProduct         = 0,
> +        .idVendor          = 0x46f4, /* CRC16() of "QEMU" */
> +        .idProduct         = 0x0001,
>          .bcdDevice         = 0,
>          .iManufacturer     = STR_MANUFACTURER,
>          .iProduct          = STR_PRODUCT,


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict
  2011-11-01 15:29   ` Andreas Färber
@ 2011-11-01 15:40     ` Gerd Hoffmann
  0 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-01 15:40 UTC (permalink / raw)
  To: Andreas Färber; +Cc: qemu-devel, Roy Tam

On 11/01/11 16:29, Andreas Färber wrote:
> Am 01.11.2011 15:56, schrieb Gerd Hoffmann:
>> From: Roy Tam <roytam@gmail.com>
>>
>> Some USB drivers, for example USBASPI.SYS, will skip different type of
>> device which has same VID/PID. The following patch helps preventing
>> usb-msd being skipped by the driver.
>>
> 
>> Sign-off-by: Roy Tam <roytam@gmail.com>
> 
> Typo?

Yea.  Updated comment, pushed to the same location.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PULL] usb patch queue
  2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 3/3] usb-host: fix host close Gerd Hoffmann
@ 2011-11-01 18:13 ` Anthony Liguori
  3 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2011-11-01 18:13 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 11/01/2011 09:56 AM, Gerd Hoffmann wrote:
>    Hi,
>
> Three little usb patches for 1.0.
>
> please pull,
>    Gerd
>
> The following changes since commit ff74c5a9a91c6dbf1017195462aa4176f7381240:
>
>    Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging (2011-10-31 15:05:40 -0500)

Pulled.  Thanks.

Regards,

Anthony Liguori

> are available in the git repository at:
>
>    git://git.kraxel.org/qemu usb.29
>
> Gerd Hoffmann (2):
>        usb-hub: wakeup on attach
>        usb-host: fix host close
>
> Roy Tam (1):
>        usb: change VID/PID for usb-hub and usb-msd to prevent conflict
>
>   hw/usb-hub.c |    5 +++--
>   hw/usb-msd.c |    4 ++--
>   usb-linux.c  |    6 ++++--
>   3 files changed, 9 insertions(+), 6 deletions(-)
>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
@ 2011-11-02  9:38   ` hkran
  2011-11-02 12:56     ` Gerd Hoffmann
  2011-11-10  3:45   ` hkran
  1 sibling, 1 reply; 14+ messages in thread
From: hkran @ 2011-11-02  9:38 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 11/01/2011 10:56 PM, Gerd Hoffmann wrote:
> When attaching a new device we must send a wakeup request to the root
> hub, otherwise the guest will not notice the new device in case the
> usb hub is suspended.
>
> Signed-off-by: Gerd Hoffmann<kraxel@redhat.com>
> ---
>   hw/usb-hub.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/hw/usb-hub.c b/hw/usb-hub.c
> index 09c6516..7b47079 100644
> --- a/hw/usb-hub.c
> +++ b/hw/usb-hub.c
> @@ -163,6 +163,7 @@ static void usb_hub_attach(USBPort *port1)
>       } else {
>           port->wPortStatus&= ~PORT_STAT_LOW_SPEED;
>       }
> +    usb_wakeup(&s->dev);
>   }
>
>   static void usb_hub_detach(USBPort *port1)
pulled, In what cases, the usb hub will be suspended? and how to tell it 
happened? thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-02  9:38   ` hkran
@ 2011-11-02 12:56     ` Gerd Hoffmann
  2011-11-03  6:01       ` hkran
  0 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-02 12:56 UTC (permalink / raw)
  To: hkran; +Cc: qemu-devel

  Hi,

>>   static void usb_hub_detach(USBPort *port1)
> pulled, In what cases, the usb hub will be suspended? and how to tell it
> happened? thanks.

The guest enables the remote-wakeup feature.  'lspci -v' (within the
guest) shows it.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-02 12:56     ` Gerd Hoffmann
@ 2011-11-03  6:01       ` hkran
  2011-11-03  8:41         ` Gerd Hoffmann
  0 siblings, 1 reply; 14+ messages in thread
From: hkran @ 2011-11-03  6:01 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: hkran, qemu-devel

On 11/02/2011 08:56 PM, Gerd Hoffmann wrote:
>    Hi,
>
>>>    static void usb_hub_detach(USBPort *port1)
>> pulled, In what cases, the usb hub will be suspended? and how to tell it
>> happened? thanks.
> The guest enables the remote-wakeup feature.  'lspci -v' (within the
> guest) shows it.
>
> cheers,
>    Gerd
>
I use the param "-usb -usbdevice tablet" to start qemu  and then usb_del 
tablet via monitor console after getting qemu up.
I saw this by entering lsusb -v

Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Device Descriptor:
   bLength                18
   bDescriptorType         1
   bcdUSB               1.10
   bDeviceClass            9 Hub
   bDeviceSubClass         0 Unused
   bDeviceProtocol         0 Full speed (or root) hub
   bMaxPacketSize0        64
   idVendor           0x1d6b Linux Foundation
   idProduct          0x0001 1.1 root hub
   bcdDevice            2.06
   iManufacturer           3 Linux 2.6.32-131.0.15.el6.x86_64 uhci_hcd
   iProduct                2 UHCI Host Controller
   iSerial                 1 0000:00:01.2
..........................
Hub Descriptor:
   bLength               9
   bDescriptorType      41
   nNbrPorts             2
   wHubCharacteristic 0x000a
     No power switching (usb 1.0)
     Per-port overcurrent protection
   bPwrOn2PwrGood        1 * 2 milli seconds
   bHubContrCurrent      0 milli Ampere
   DeviceRemovable    0x00
   PortPwrCtrlMask    0xff
  Hub Port Status:
    Port 1: 0000.0100 power
    Port 2: 0000.0100 power
Device Status:     0x0003
   Self Powered
   Remote Wakeup Enabled

(It seems that the Remote-wakeup feature has been enabled)
There are two ports with the status "power",  and I do not know how to 
make it suspended yet. Can you help more ?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-03  6:01       ` hkran
@ 2011-11-03  8:41         ` Gerd Hoffmann
  2011-11-03  9:20           ` hkran
  0 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-03  8:41 UTC (permalink / raw)
  To: hkran; +Cc: hkran, qemu-devel

On 11/03/11 07:01, hkran wrote:
> On 11/02/2011 08:56 PM, Gerd Hoffmann wrote:
>>    Hi,
>>
>>>>    static void usb_hub_detach(USBPort *port1)
>>> pulled, In what cases, the usb hub will be suspended? and how to tell it
>>> happened? thanks.
>> The guest enables the remote-wakeup feature.  'lspci -v' (within the
>> guest) shows it.
>>
>> cheers,
>>    Gerd
>>
> I use the param "-usb -usbdevice tablet" to start qemu  and then usb_del
> tablet via monitor console after getting qemu up.
> I saw this by entering lsusb -v
> 
> Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Device Descriptor:
>   bLength                18
>   bDescriptorType         1
>   bcdUSB               1.10
>   bDeviceClass            9 Hub
>   bDeviceSubClass         0 Unused
>   bDeviceProtocol         0 Full speed (or root) hub
>   bMaxPacketSize0        64
>   idVendor           0x1d6b Linux Foundation
>   idProduct          0x0001 1.1 root hub
>   bcdDevice            2.06
>   iManufacturer           3 Linux 2.6.32-131.0.15.el6.x86_64 uhci_hcd
>   iProduct                2 UHCI Host Controller
>   iSerial                 1 0000:00:01.2
> ..........................
> Hub Descriptor:
>   bLength               9
>   bDescriptorType      41
>   nNbrPorts             2
>   wHubCharacteristic 0x000a
>     No power switching (usb 1.0)
>     Per-port overcurrent protection
>   bPwrOn2PwrGood        1 * 2 milli seconds
>   bHubContrCurrent      0 milli Ampere
>   DeviceRemovable    0x00
>   PortPwrCtrlMask    0xff
>  Hub Port Status:
>    Port 1: 0000.0100 power
>    Port 2: 0000.0100 power
> Device Status:     0x0003
>   Self Powered
>   Remote Wakeup Enabled
> 
> (It seems that the Remote-wakeup feature has been enabled)
> There are two ports with the status "power",  and I do not know how to
> make it suspended yet. Can you help more ?

That is the root hub created by the linux kernel, not the hub emulated
by qemu.  If you hook up just a single device no hob is needed.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-03  8:41         ` Gerd Hoffmann
@ 2011-11-03  9:20           ` hkran
  0 siblings, 0 replies; 14+ messages in thread
From: hkran @ 2011-11-03  9:20 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: hkran, qemu-devel

On 11/03/2011 04:41 PM, Gerd Hoffmann wrote:
> On 11/03/11 07:01, hkran wrote:
>> On 11/02/2011 08:56 PM, Gerd Hoffmann wrote:
>>>     Hi,
>>>
>>>>>     static void usb_hub_detach(USBPort *port1)
>>>> pulled, In what cases, the usb hub will be suspended? and how to tell it
>>>> happened? thanks.
>>> The guest enables the remote-wakeup feature.  'lspci -v' (within the
>>> guest) shows it.
>>>
>>> cheers,
>>>     Gerd
>>>
>> I use the param "-usb -usbdevice tablet" to start qemu  and then usb_del
>> tablet via monitor console after getting qemu up.
>> I saw this by entering lsusb -v
>>
>> Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
>> Device Descriptor:
>>    bLength                18
>>    bDescriptorType         1
>>    bcdUSB               1.10
>>    bDeviceClass            9 Hub
>>    bDeviceSubClass         0 Unused
>>    bDeviceProtocol         0 Full speed (or root) hub
>>    bMaxPacketSize0        64
>>    idVendor           0x1d6b Linux Foundation
>>    idProduct          0x0001 1.1 root hub
>>    bcdDevice            2.06
>>    iManufacturer           3 Linux 2.6.32-131.0.15.el6.x86_64 uhci_hcd
>>    iProduct                2 UHCI Host Controller
>>    iSerial                 1 0000:00:01.2
>> ..........................
>> Hub Descriptor:
>>    bLength               9
>>    bDescriptorType      41
>>    nNbrPorts             2
>>    wHubCharacteristic 0x000a
>>      No power switching (usb 1.0)
>>      Per-port overcurrent protection
>>    bPwrOn2PwrGood        1 * 2 milli seconds
>>    bHubContrCurrent      0 milli Ampere
>>    DeviceRemovable    0x00
>>    PortPwrCtrlMask    0xff
>>   Hub Port Status:
>>     Port 1: 0000.0100 power
>>     Port 2: 0000.0100 power
>> Device Status:     0x0003
>>    Self Powered
>>    Remote Wakeup Enabled
>>
>> (It seems that the Remote-wakeup feature has been enabled)
>> There are two ports with the status "power",  and I do not know how to
>> make it suspended yet. Can you help more ?
> That is the root hub created by the linux kernel, not the hub emulated
> by qemu.  If you hook up just a single device no hob is needed.
>
> cheers,
>    Gerd
>
Yes, it is. After I usb_add a storage a 8-port hub emulated is added :

lsusb
Bus 001 Device 004: ID 0000:7777
Bus 001 Device 003: ID 0000:0000
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Device 003 is the hub and Device 004 is my storage

lsusb -s 3 -v:

Bus 001 Device 003: ID 0000:0000
Device Descriptor:
   bLength                18
   bDescriptorType         1
   bcdUSB               1.10
   bDeviceClass            9 Hub
   bDeviceSubClass         0 Unused
   bDeviceProtocol         0 Full speed (or root) hub
   bMaxPacketSize0         8
   idVendor           0x0000
   idProduct          0x0000
   bcdDevice            1.01
   iManufacturer           1 QEMU 0.15.50
   iProduct                2 QEMU USB Hub
   iSerial                 3 314159
   bNumConfigurations      1
...........................................
     iConfiguration          0
     bmAttributes         0xe0
       Self Powered
       Remote Wakeup
     MaxPower                0mA
     Interface Descriptor:
       bLength                 9
       bDescriptorType         4
       bInterfaceNumber        0
       bAlternateSetting       0
       bNumEndpoints           1
       bInterfaceClass         9 Hub
       bInterfaceSubClass      0 Unused
       bInterfaceProtocol      0 Full speed (or root) hub
       iInterface              0
       Endpoint Descriptor:
         bLength                 7
         bDescriptorType         5
         bEndpointAddress     0x81  EP 1 IN
         bmAttributes            3
           Transfer Type            Interrupt
           Synch Type               None
           Usage Type               Data
         wMaxPacketSize     0x0002  1x 2 bytes
         bInterval             255
Hub Descriptor:
   bLength              10
   bDescriptorType      41
   nNbrPorts             8
   wHubCharacteristic 0x000a
     No power switching (usb 1.0)
     Per-port overcurrent protection
   bPwrOn2PwrGood        1 * 2 milli seconds
   bHubContrCurrent      0 milli Ampere
   DeviceRemovable    0x00 0x00
   PortPwrCtrlMask    0xff 0x00
  Hub Port Status:
    Port 1: 0000.0103 power enable connect
    Port 2: 0000.0100 power
    Port 3: 0000.0100 power
    Port 4: 0000.0100 power
    Port 5: 0000.0100 power
    Port 6: 0000.0100 power
    Port 7: 0000.0100 power
    Port 8: 0000.0100 power
Device Status:     0x0001
   Self Powered

my storage is connected to the port 1.

after usb_del, all the hub port status will turn to power. how should i 
do next to get it to be suspended?thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
  2011-11-02  9:38   ` hkran
@ 2011-11-10  3:45   ` hkran
  2011-11-22 12:23     ` Gerd Hoffmann
  1 sibling, 1 reply; 14+ messages in thread
From: hkran @ 2011-11-10  3:45 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

On 11/01/2011 10:56 PM, Gerd Hoffmann wrote:
> When attaching a new device we must send a wakeup request to the root
> hub, otherwise the guest will not notice the new device in case the
> usb hub is suspended.
>
> Signed-off-by: Gerd Hoffmann<kraxel@redhat.com>
> ---
>   hw/usb-hub.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/hw/usb-hub.c b/hw/usb-hub.c
> index 09c6516..7b47079 100644
> --- a/hw/usb-hub.c
> +++ b/hw/usb-hub.c
> @@ -163,6 +163,7 @@ static void usb_hub_attach(USBPort *port1)
>       } else {
>           port->wPortStatus&= ~PORT_STAT_LOW_SPEED;
>       }
> +    usb_wakeup(&s->dev);
>   }
>
>   static void usb_hub_detach(USBPort *port1)
It seems "attach" works. But the "detach" did not work.
I added over two usbdevice "tablet" and usb_del them. I found sometimes 
the guest did not know that the tablet had been deleted in host when the 
port
's status changed to "suspend".

After I add usb_wake like this in the function usb_hub_detach. the 
problem can be fixed.

static void usb_hub_detach(USBPort *port1)
{
     USBHubState *s = port1->opaque;
     USBHubPort *port = &s->ports[port1->index];

     usb_wakeup(&s->dev);                 
---------------------------------->wakeup when detach
     /* Let upstream know the device on this port is gone */
     s->dev.port->ops->child_detach(s->dev.port, port1->dev);

     port->wPortStatus &= ~PORT_STAT_CONNECTION;
     port->wPortChange |= PORT_STAT_C_CONNECTION;
     if (port->wPortStatus & PORT_STAT_ENABLE) {
         port->wPortStatus &= ~PORT_STAT_ENABLE;
         port->wPortChange |= PORT_STAT_C_ENABLE;
     }
}

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach
  2011-11-10  3:45   ` hkran
@ 2011-11-22 12:23     ` Gerd Hoffmann
  0 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2011-11-22 12:23 UTC (permalink / raw)
  To: hkran; +Cc: qemu-devel

  Hi,

> After I add usb_wake like this in the function usb_hub_detach. the
> problem can be fixed.
> 
> static void usb_hub_detach(USBPort *port1)
> {
>     USBHubState *s = port1->opaque;
>     USBHubPort *port = &s->ports[port1->index];
> 
>     usb_wakeup(&s->dev);                
> ---------------------------------->wakeup when detach

Fix added to usb patch queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-11-22 12:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-01 14:56 [Qemu-devel] [PULL] usb patch queue Gerd Hoffmann
2011-11-01 14:56 ` [Qemu-devel] [PATCH 1/3] usb-hub: wakeup on attach Gerd Hoffmann
2011-11-02  9:38   ` hkran
2011-11-02 12:56     ` Gerd Hoffmann
2011-11-03  6:01       ` hkran
2011-11-03  8:41         ` Gerd Hoffmann
2011-11-03  9:20           ` hkran
2011-11-10  3:45   ` hkran
2011-11-22 12:23     ` Gerd Hoffmann
2011-11-01 14:56 ` [Qemu-devel] [PATCH 2/3] usb: change VID/PID for usb-hub and usb-msd to prevent conflict Gerd Hoffmann
2011-11-01 15:29   ` Andreas Färber
2011-11-01 15:40     ` Gerd Hoffmann
2011-11-01 14:56 ` [Qemu-devel] [PATCH 3/3] usb-host: fix host close Gerd Hoffmann
2011-11-01 18:13 ` [Qemu-devel] [PULL] usb patch queue Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.