Skip to contentSkip to conversation

usb: fixes for 2.4 (ccid, xhci and usb-host)

GIT PULL Applied Gerd Hoffmann 2 participants 6 messages Jul 17, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

Here are usb fixes for 2.4.

please pull,
Gerd

The following changes since commit 2d5ee9e7a7dd495d233cf9613a865f63f88e3375:

Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150716' into staging (2015-07-16 10:40:23 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-usb-20150717-1

for you to fetch changes up to 92fdfa4bef9c92addcc009dd3e0131172b4fdc78:

Revert "xhci: set timer to retry xfers" (2015-07-17 13:20:53 +0200)

----------------------------------------------------------------
usb: fixes for 2.4 (ccid, xhci and usb-host)

----------------------------------------------------------------
Gerd Hoffmann (3):
usb-ccid: fix 61b4887b41b270bc837ead57bc502d904af023bb
usb-ccid: add missing wakeup calls
Revert "xhci: set timer to retry xfers"

Lin Ma (1):
Re-attach usb device to kernel while usb_host_open fails

 hw/usb/dev-smartcard-reader.c | 21 +++++++++++++--------
 hw/usb/hcd-xhci.c             |  2 --
 hw/usb/host-libusb.c          |  3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/4] Re-attach usb device to kernel while usb_host_open fails

From: Lin Ma <[email protected]>

---
 hw/usb/host-libusb.c | 3 +++
 1 file changed, 3 insertions(+)
hw/usb/host-libusb.c +3 -0
index bc2944c..11429f5 100644
@@ -889,6 +889,9 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev)
 fail:
     trace_usb_host_open_failure(bus_num, addr);
     if (s->dh != NULL) {
+        usb_host_release_interfaces(s);
+        libusb_reset_device(s->dh);
+        usb_host_attach_kernel(s);
         libusb_close(s->dh);
         s->dh = NULL;
         s->dev = NULL;
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 3/4] usb-ccid: add missing wakeup calls

In reply to Gerd Hoffmann

Properly notify the host adapter that we have
data pending, so it doesn't has to poll us.

---
 hw/usb/dev-smartcard-reader.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/usb/dev-smartcard-reader.c +5 -0
index 904b568..8952eff 100644
@@ -283,6 +283,7 @@ typedef struct CCIDBus {
 typedef struct USBCCIDState {
     USBDevice dev;
     USBEndpoint *intr;
+    USBEndpoint *bulk;
     CCIDBus bus;
     CCIDCardState *card;
     BulkIn bulk_in_pending[BULK_IN_PENDING_NUM]; /* circular */
@@ -769,6 +770,7 @@ static void ccid_write_slot_status(USBCCIDState *s, CCID_Header *recv)
     h->b.bError = s->bError;
     h->bClockStatus = CLOCK_STATUS_RUNNING;
     ccid_reset_error_status(s);
+    usb_wakeup(s->bulk, 0);
 }
 
 static void ccid_write_parameters(USBCCIDState *s, CCID_Header *recv)
@@ -789,6 +791,7 @@ static void ccid_write_parameters(USBCCIDState *s, CCID_Header *recv)
     h->bProtocolNum = s->bProtocolNum;
     h->abProtocolDataStructure = s->abProtocolDataStructure;
     ccid_reset_error_status(s);
+    usb_wakeup(s->bulk, 0);
 }
 
 static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
@@ -810,6 +813,7 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
     }
     memcpy(p->abData, data, len);
     ccid_reset_error_status(s);
+    usb_wakeup(s->bulk, 0);
 }
 
 static void ccid_report_error_failed(USBCCIDState *s, uint8_t error)
@@ -1319,6 +1323,7 @@ static void ccid_realize(USBDevice *dev, Error **errp)
                         NULL);
     qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(dev), &error_abort);
     s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP);
+    s->bulk = usb_ep_get(dev, USB_TOKEN_IN, CCID_BULK_IN_EP);
     s->card = NULL;
     s->migration_state = MIGRATION_NONE;
     s->migration_target_ip = 0;
Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL 4/4] Revert "xhci: set timer to retry xfers"

In reply to Gerd Hoffmann

This reverts commit 4e8cfbe1143d8384387595b500212d7a7f11aeae.

We should not poll via timer, and with ccid being fixed to properly notify us about pending transfers we don't have to.

---
 hw/usb/hcd-xhci.c | 2 --
 1 file changed, 2 deletions(-)
hw/usb/hcd-xhci.c +0 -2
index 90a5fbf..c673bed 100644
@@ -2222,8 +2222,6 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
         if (xfer->running_retry) {
             DPRINTF("xhci: xfer nacked, stopping schedule\n");
             epctx->retry = xfer;
-            timer_mod(epctx->kick_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-                      epctx->interval * 125000);
             break;
         }
     }
Signature · 1 line
1.8.3.1
#4 lore raw

[Qemu-devel] [PULL 2/4] usb-ccid: fix 61b4887b41b270bc837ead57bc502d904af023bb

In reply to Gerd Hoffmann

QOMification dropped the parent device lookup, fix it.

---
 hw/usb/dev-smartcard-reader.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/usb/dev-smartcard-reader.c +8 -8
index de534ba..904b568 100644
@@ -1184,7 +1184,7 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card,
                                   uint8_t *apdu, uint32_t len)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
     Answer *answer;
 
@@ -1207,7 +1207,7 @@ void ccid_card_send_apdu_to_guest(CCIDCardState *card,
 void ccid_card_card_removed(CCIDCardState *card)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     ccid_on_slot_change(s, false);
@@ -1218,7 +1218,7 @@ void ccid_card_card_removed(CCIDCardState *card)
 int ccid_card_ccid_attach(CCIDCardState *card)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     DPRINTF(s, 1, "CCID Attach\n");
@@ -1231,7 +1231,7 @@ int ccid_card_ccid_attach(CCIDCardState *card)
 void ccid_card_ccid_detach(CCIDCardState *card)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     DPRINTF(s, 1, "CCID Detach\n");
@@ -1244,7 +1244,7 @@ void ccid_card_ccid_detach(CCIDCardState *card)
 void ccid_card_card_error(CCIDCardState *card, uint64_t error)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     s->bmCommandStatus = COMMAND_STATUS_FAILED;
@@ -1263,7 +1263,7 @@ void ccid_card_card_error(CCIDCardState *card, uint64_t error)
 void ccid_card_card_inserted(CCIDCardState *card)
 {
     DeviceState *qdev = DEVICE(card);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     s->bmCommandStatus = COMMAND_STATUS_NO_ERROR;
@@ -1275,7 +1275,7 @@ static int ccid_card_exit(DeviceState *qdev)
 {
     int ret = 0;
     CCIDCardState *card = CCID_CARD(qdev);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
 
     if (ccid_card_inserted(s)) {
@@ -1289,7 +1289,7 @@ static int ccid_card_exit(DeviceState *qdev)
 static int ccid_card_init(DeviceState *qdev)
 {
     CCIDCardState *card = CCID_CARD(qdev);
-    USBDevice *dev = USB_DEVICE(qdev);
+    USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent);
     USBCCIDState *s = USB_CCID_DEV(dev);
     int ret = 0;
 
Signature · 1 line
1.8.3.1
#5 lore raw
In reply to Gerd Hoffmann
Quoted 14 lines · Gerd Hoffmann

Hi,

Here are usb fixes for 2.4.

please pull,
Gerd

The following changes since commit 2d5ee9e7a7dd495d233cf9613a865f63f88e3375:

Merge remote-tracking branch 'remotes/lalrae/tags/mips-20150716' into staging (2015-07-16 10:40:23 +0100)

are available in the git repository at:

Quoted 8 lines

git://git.kraxel.org/qemu tags/pull-usb-20150717-1

for you to fetch changes up to 92fdfa4bef9c92addcc009dd3e0131172b4fdc78:

Revert "xhci: set timer to retry xfers" (2015-07-17 13:20:53 +0200)

----------------------------------------------------------------
usb: fixes for 2.4 (ccid, xhci and usb-host)

Applied, thanks.

-- PMM