1. 08 1月, 2013 1 次提交
    • H
      usbredir: Add support for buffered bulk input (v2) · b2d1fe67
      Hans de Goede 提交于
      Buffered bulk mode is intended for bulk *input* endpoints, where the data is
      of a streaming nature (not part of a command-response protocol). These
      endpoints' input buffer may overflow if data is not read quickly enough.
      So in buffered bulk mode the usb-host takes care of the submitting and
      re-submitting of bulk transfers.
      
      Buffered bulk mode is necessary for reliable operation with the bulk in
      endpoints of usb to serial convertors. Unfortunatelty buffered bulk input
      mode will only work with certain devices, therefor this patch also adds a
      usb-id table to enable it for devices which need it, while leaving the
      bulk ep handling for other devices unmodified.
      
      Note that the bumping of the required usbredir from 0.5.3 to 0.6 does
      not mean that we will now need a newer usbredir release then qemu-1.3,
      .pc files reporting 0.5.3 have only ever existed in usbredir builds directly
      from git, so qemu-1.3 needs the 0.6 release too.
      
      Changes in v2:
      -Split of quirk handling into quirks.c
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      b2d1fe67
  2. 07 1月, 2013 1 次提交
    • H
      usb: Add an usb_device_ep_stopped USBDevice method · f79738b0
      Hans de Goede 提交于
      Some usb devices (host or network redirection) can benefit from knowing when
      the guest stops using an endpoint. Redirection may involve submitting packets
      independently from the guest (in combination with a fifo buffer between the
      redirection code and the guest), to ensure that buffers of the real usb device
      are timely emptied. This is done for example for isoc traffic and for interrupt
      input endpoints. But when the (re)submission of packets is done by the device
      code, then how does it know when to stop this?
      
      For isoc endpoints this is handled by detecting a set interface (change alt
      setting) command, which works well for isoc endpoints. But for interrupt
      endpoints currently the redirection code never stops receiving data from
      the device, which is less then ideal.
      
      However the controller emulation is aware when a guest looses interest, as
      then the qh for the endpoint gets unlinked (ehci, ohci, uhci) or the endpoint
      is explicitly stopped (xhci). This patch adds a new ep_stopped USBDevice
      method and modifies the hcd code to call this on queue unlink / ep stop.
      
      This makes it possible for the redirection code to properly stop receiving
      interrupt input (*) data when the guest no longer has interest in it.
      
      *) And in the future also buffered bulk input.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      f79738b0
  3. 19 12月, 2012 1 次提交
  4. 07 12月, 2012 1 次提交
  5. 04 12月, 2012 2 次提交
  6. 09 11月, 2012 1 次提交
    • H
      usb: split packet result into actual_length + status · 9a77a0f5
      Hans de Goede 提交于
      Since with the ehci and xhci controllers a single packet can be larger
      then maxpacketsize, it is possible for the result of a single packet
      to be both having transferred some data as well as the transfer to have
      an error.
      
      An example would be an input transfer from a bulk endpoint successfully
      receiving 1 or more maxpacketsize packets from the device, followed
      by a packet signalling halt.
      
      While already touching all the devices and controllers handle_packet /
      handle_data / handle_control code, also change the return type of
      these functions to void, solely storing the status in the packet. To
      make the code paths for regular versus async packet handling more
      uniform.
      
      This patch unfortunately is somewhat invasive, since makeing the qemu
      usb core deal with this requires changes everywhere. This patch only
      prepares the usb core for this, all the hcd / device changes are done
      in such a way that there are no functional changes.
      
      This patch has been tested with uhci and ehci hcds, together with usb-audio,
      usb-hid and usb-storage devices, as well as with usb-redir redirection
      with a wide variety of real devices.
      
      Note that there is usually no need to directly set packet->actual_length
      form devices handle_data callback, as that is done by usb_packet_copy()
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      9a77a0f5
  7. 01 11月, 2012 2 次提交
    • H
      usb: Add packet combining functions · a552a966
      Hans de Goede 提交于
      Currently we only do pipelining for output endpoints, since to properly
      support short-not-ok semantics we can only have one outstanding input
      packet. Since the ehci and uhci controllers have a limited per td packet
      size guests will split large input transfers to into multiple packets,
      and since we don't pipeline these, this comes with a serious performance
      penalty.
      
      This patch adds helper functions to (re-)combine packets which belong to 1
      transfer at the guest device-driver level into 1 large transger. This can be
      used by (redirection) usb-devices to enable pipelining for input endpoints.
      
      This patch will combine packets together until a transfer terminating packet
      is encountered. A terminating packet is a packet which meets one or more of
      the following conditions:
      1) The packet size is *not* a multiple of the endpoint max packet size
      2) The packet does *not* have its short-not-ok flag set
      3) The packet has its interrupt-on-complete flag set
      
      The short-not-ok flag of the combined packet is that of the terminating packet.
      Multiple combined packets may be submitted to the device, if the combined
      packets do not have their short-not-ok flag set, enabling true pipelining.
      
      If a combined packet does have its short-not-ok flag set the queue will
      wait with submitting further packets to the device until that packet has
      completed.
      
      Once enabled in the usb-redir and ehci code, this improves the speed (MB/s)
      of a Linux guest reading from a USB mass storage device by a factor of
      1.2 - 1.5.
      
      And the main reason why I started working on this, when reading from a pl2303
      USB<->serial converter, it combines the previous 4 packets submitted per
      device-driver level read into 1 big read, reducing the number of packets / sec
      by a factor 4, and it allows to have multiple reads outstanding. This allows
      for much better latency tolerance without the pl2303's internal buffer
      overflowing (which was happening at 115200 bps, without serial flow control).
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      a552a966
    • G
      bb4d2b2f
  8. 25 10月, 2012 5 次提交
  9. 11 9月, 2012 3 次提交
  10. 31 8月, 2012 2 次提交
    • G
      usb: unique packet ids · e983395d
      Gerd Hoffmann 提交于
      This patch adds IDs to usb packets.  Those IDs are (a) supposed to be
      unique for the lifecycle of a packet (from packet setup until the packet
      is either completed or canceled) and (b) stable across migration.
      
      uhci, ohci, ehci and xhci use the guest physical address of the transfer
      descriptor for this.
      
      musb needs a different approach because there is no transfer descriptor.
      But musb also doesn't support pipelining, so we have never more than one
      packet per endpoint in flight.  So we go create an ID based on endpoint
      and device address.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      e983395d
    • H
      usb: Halt ep queue en cancel pending packets on a packet error · 0132b4b6
      Hans de Goede 提交于
      For controllers which queue up more then 1 packet at a time, we must halt the
      ep queue, and inside the controller code cancel all pending packets on an
      error.
      
      There are multiple reasons for this:
      1) Guests expect the controllers to halt ep queues on error, so that they
      get the opportunity to cancel transfers which the scheduled after the failing
      one, before processing continues
      
      2) Not cancelling queued up packets after a failed transfer also messes up
      the controller state machine, in the case of EHCI causing the following
      assert to trigger: "assert(p->qtdaddr == q->qtdaddr)" at hcd-ehci.c:2075
      
      3) For bulk endpoints with pipelining enabled (redirection to a real USB
      device), we must cancel all the transfers after this a failed one so that:
      a) If they've completed already, they are not processed further causing more
         stalls to be reported, originating from the same failed transfer
      b) If still in flight, they are cancelled before the guest does
         a clear stall, otherwise the guest and device can loose sync!
      
      Note this patch only touches the ehci and uhci controller changes, since AFAIK
      no other controllers actually queue up multiple transfer. If I'm wrong on this
      other controllers need to be updated too!
      
      Also note that this patch was heavily tested with the ehci code, where I had
      a reproducer for a device causing a transfer to fail. The uhci code is not
      tested with actually failing transfers and could do with a thorough review!
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      0132b4b6
  11. 17 7月, 2012 1 次提交
  12. 09 7月, 2012 2 次提交
  13. 28 6月, 2012 1 次提交
    • D
      usb: Convert usb_packet_{map, unmap} to universal DMA helpers · e2f89926
      David Gibson 提交于
      The USB UHCI and EHCI drivers were converted some time ago to use the
      pci_dma_*() helper functions.  However, this conversion was not complete
      because in some places both these drivers do DMA via the usb_packet_map()
      function in usb-libhw.c.  That function directly used
      cpu_physical_memory_map().
      
      Now that the sglist code uses DMA wrappers properly, we can convert the
      functions in usb-libhw.c, thus conpleting the conversion of UHCI and EHCI
      to use the DMA wrappers.
      
      Note that usb_packet_map() invokes dma_memory_map() with a NULL invalidate
      callback function.  When IOMMU support is added, this will mean that
      usb_packet_map() and the corresponding usb_packet_unmap() must be called in
      close proximity without dropping the qemu device lock - otherwise the guest
      might invalidate IOMMU mappings while they are still in use by the device
      code.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      e2f89926
  14. 18 6月, 2012 1 次提交
  15. 17 4月, 2012 1 次提交
    • G
      usb/vmstate: add parent dev path · eeb0cf9a
      Gerd Hoffmann 提交于
      ... to make vmstate id string truely unique with multiple host
      controllers, i.e. move from "1/usb-ptr" to "0000:00:01.3/1/usb-ptr"
      (usb tabled connected to piix3 uhci).
      
      This obviously breaks migration.  To handle this the usb bus
      property "full-path" is added.  When setting this to false old
      behavior is maintained.  This way current qemu will be compatible
      with old versions when started using '-M pc-$oldversion'.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      eeb0cf9a
  16. 13 3月, 2012 1 次提交
  17. 07 3月, 2012 3 次提交
    • G
      usb: add shortcut for control transfers · 1b4b29a1
      Gerd Hoffmann 提交于
      Add a more direct code path to submit control transfers.  Instead of
      feeding three usb packets (setup, data, ack) to usb_handle_packet and
      have the do_token_* functions in usb.c poke the control transfer
      parameters out of it just submit a single packet carrying the actual
      data with the control xfer parameters filled into USBPacket->parameters.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      1b4b29a1
    • G
      usb: add pipelining option to usb endpoints · 7936e0f0
      Gerd Hoffmann 提交于
      With this patch applied USB drivers can enable pipelining per endpoint.
      With pipelining enabled the usb core will continue submitting packets
      even when there are still async transfers in flight instead of passing
      them on one by one.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7936e0f0
    • H
      usb: add USB_RET_IOERROR · d61000a8
      Hans de Goede 提交于
      We already have USB_RET_NAK, but that means that a device does not want
      to send/receive right now. But with host / network redirection we can
      actually have a transaction fail due to some io error, rather then ie
      the device just not having any data atm.
      
      This patch adds a new error code named USB_RET_IOERROR for this, and uses
      it were appropriate.
      
      Notes:
      -Currently all usb-controllers handle this the same as NODEV, but that
       may change in the future, OHCI could indicate a CRC error instead for example.
      -This patch does not touch hw/usb-musb.c, that is because the code in there
       handles STALL and NAK specially and has a if status < 0 generic catch all
       for all other errors
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      d61000a8
  18. 27 2月, 2012 1 次提交
  19. 10 2月, 2012 10 次提交
    • G
      usb: add USBBusOps->wakeup_endpoint · 37f32f0f
      Gerd Hoffmann 提交于
      Add usb bus op which is called whenever a usb endpoint becomes ready,
      so the host adapter emulation can react on that event.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      37f32f0f
    • G
      usb: pass USBEndpoint to usb_wakeup · 7567b51f
      Gerd Hoffmann 提交于
      Devices must specify which endpoint has data to transfer now.
      The plan is to use the usb_wakeup() not only for remove wakeup support,
      but for "data ready" signaling in general, so we can move away from
      constant polling to event driven usb device emulation.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7567b51f
    • G
      usb: maintain async packet list per endpoint · db4be873
      Gerd Hoffmann 提交于
      Maintain a list of async packets per endpoint.  With the current code
      the list will never receive more than a single item.  I think you can
      guess what the future plan is though ;)
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      db4be873
    • G
      usb: Set USBEndpoint in usb_packet_setup(). · 079d0b7f
      Gerd Hoffmann 提交于
      With the separation of the device lookup (via usb_find_device) and
      packet processing we can lookup device and endpoint before setting up
      the usb packet.  So we can initialize USBPacket->ep early and keep it
      valid for the whole lifecycle of the USBPacket.  Also the devaddr and
      devep fields are not needed any more.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      079d0b7f
    • G
      usb: add USBEndpoint->{nr,pid} · 63095ab5
      Gerd Hoffmann 提交于
      Add a "nr" and "pid" fields to USBEndpoint so you can easily figure the
      endpoint number and direction of any given endpoint.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      63095ab5
    • G
      usb: USBPacket: add status, rename owner -> ep · f53c398a
      Gerd Hoffmann 提交于
      Add enum to track the status of USBPackets, use that instead of the
      owner pointer to figure whenever a usb packet is currently in flight
      or not.  Add some more packet status sanity checks.  Also rename the
      USBEndpoint pointer from "owner" to "ep".
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      f53c398a
    • G
      usb: kill handle_packet callback · 7f74a56b
      Gerd Hoffmann 提交于
      All drivers except usb-hub use usb_generic_handle_packet.  The only
      reason the usb hub has its own function is that it used to be called
      with packets which are intended for downstream devices.  With the new,
      separate device lookup step this doesn't happen any more, so the need
      for a different handle_packet callback is gone.
      
      So we can kill the handle_packet callback and just call
      usb_generic_handle_packet directly.  The special hub handling in
      usb_handle_packet() can go away for the same reason.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7f74a56b
    • G
      usb: add usb_find_device() · 73796fe6
      Gerd Hoffmann 提交于
      Add usb_find_device().  This function will check whenever a device with
      a specific address is connected to the specified port.  Usually this
      will just check state and address of the device hooked up to the port,
      but in case of a hub it will ask the hub to check all hub ports for a
      matching device.
      
      This patch doesn't put the code into use yet, see the following patches
      for details.
      
      The master plan is to separate device lookup and packet processing.
      Right now the usb code simply walks all devices, calls
      usb_handle_packet() on each until one accepts the packet (by returning
      something different that USB_RET_NODEV).  I want to have a device lookup
      first, then call usb_handle_packet() once, for the device which actually
      processes the packet.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      73796fe6
    • G
      usb: kill usb_send_msg · 70fc20d4
      Gerd Hoffmann 提交于
      No users left.  Zap it.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      70fc20d4
    • G
      usb: kill USB_MSG_RESET · d28f4e2d
      Gerd Hoffmann 提交于
      The USB subsystem pipes internal reset notifications through
      usb_handle_packet() with a special magic PID.  This indirection
      is a pretty pointless excercise as it ends up being handled by
      usb_generic_handle_packet anyway.
      
      Replace the USB_MSG_RESET with a usb_device_reset() function
      which can be called directly.  Also rename the existing usb_reset()
      function to usb_port_reset() to avoid confusion.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      d28f4e2d