1. 31 8月, 2012 6 次提交
    • H
      ehci: simplify ehci_state_executing · 574ef171
      Hans de Goede 提交于
      ehci_state_executing does not need to check for p->usb_status == USB_RET_ASYNC
      or USB_RET_PROCERR, since ehci_execute_complete already does a similar check
      and will trigger an assert if either value is encountered.
      
      USB_RET_ASYNC should never be the packet status when execute_complete runs
      for obvious reasons, and USB_RET_PROCERR is only used by ehci_state_execute /
      ehci_execute not by ehci_state_executing / ehci_execute_complete.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      574ef171
    • H
      ehci: Remove unnecessary ehci_flush_qh call · 53dd6f70
      Hans de Goede 提交于
      ehci_qh_do_overlay() already calls ehci_flush_qh() before it returns, calling
      it twice is useless.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      53dd6f70
    • H
      ehci: Schedule async-bh when IAAD bit gets set · a1c3e4b8
      Hans de Goede 提交于
      After the "ehci: Print a warning when a queue unexpectedly contains packets
      on cancel" commit. Under certain reproducable conditions I was getting the
      following message: "EHCI: Warning queue not empty on queue reset".
      
      After aprox. 8 hours of debugging I've finally found the cause. The Linux EHCI
      driver has an IAAD watchdog, to work around certain EHCI hardware sometimes
      not acknowledging the doorbell at all. This watchdog has a timeout of 10 ms,
      which is less then the time between 2 runs through the async schedule when
      async_stepdown is at its highest value.
      
      Thus the watchdog can trigger, after which Linux clears the IAAD bit and
      re-uses the QH. IOW we were not properly detecting the unlink of the qh, due
      to us missing (ignoring for more then 10 ms) the IAAD command, which triggered
      the warning.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      a1c3e4b8
    • H
    • 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
  2. 16 8月, 2012 4 次提交
  3. 15 8月, 2012 1 次提交
  4. 07 8月, 2012 2 次提交
  5. 01 8月, 2012 2 次提交
  6. 23 7月, 2012 1 次提交
  7. 17 7月, 2012 1 次提交
  8. 12 7月, 2012 5 次提交
    • G
      ehci: improve expire time calculation · afb7a0b8
      Gerd Hoffmann 提交于
      Move down the expire time calculation down in the frame timer, to the
      point where the timer is actually reloaded.  This way we'll notice any
      async_stepdown changes (especially resetting to 0 due to usb activity).
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      afb7a0b8
    • G
      ehci: implement Interrupt Threshold Control support · 7efc17af
      Gerd Hoffmann 提交于
      Also reorganize and comment the irq functions while being at it.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7efc17af
    • G
      ehci: raise irq in the frame timer · f0ad01f9
      Gerd Hoffmann 提交于
      With the async schedule being kicked from other places than the frame
      timer (commit 0f588df8) it may happen
      that we call ehci_commit_interrupt() more than once per frame.
      
      Move the call from the async schedule handler to the frame timer to
      restore old irq behavior, which is more correct.  Fixes regressions
      with some linux kernel versions.
      
      TODO: implement full Interrupt Threshold Control support.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      f0ad01f9
    • G
      uhci: initialize expire_time when loading v1 vmstate · 75f151cd
      Gerd Hoffmann 提交于
      $subject says all: when loading old (v1) vmstate which doesn't contain
      expire_time initialize it with a reasonable default (current time).
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      75f151cd
    • G
      usb: add usb attached scsi emulation · 0f58f68b
      Gerd Hoffmann 提交于
      $subject says all.  First cut.
      
      It's a pure UAS (usb attached scsi) emulation, without BOT (bulk-only
      transport) compatibility.  If your guest can't handle it use usb-storage
      instead.
      
      The emulation works like any other scsi hba emulation (eps, lsi, virtio,
      megasas, ...).  It provides just the HBA where you can attach scsi
      devices as you like using '-device'.  A single scsi target with up to
      256 luns is supported.
      
      For now only usb 2.0 transport is supported.  This will change in the
      future though as I plan to use this as playground when codeing up &
      testing usb 3.0 transport and streams support in the qemu usb core and
      the xhci emulation.
      
      No migration support yet.  I'm planning to add usb 3.0 support first as
      this probably requires saving additional state.
      
      Special thanks go to Paolo for bringing the qemu scsi emulation into
      shape, so this can be added nicely without having to touch a single line
      of scsi code.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      0f58f68b
  9. 09 7月, 2012 9 次提交
    • G
      usb-host: add trace events for iso xfers · c32da151
      Gerd Hoffmann 提交于
      Replace iso transfer fprintf's with trace points.  Also rename existing
      tracepoints so they all match usb_host_iso_*.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      c32da151
    • G
      usb: fix interface initialization · 7c37e6a4
      Gerd Hoffmann 提交于
      zero is a valid interface number, so don't use it when resetting the
      endpoints.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7c37e6a4
    • G
      usb: split endpoint init and reset · 19deaa08
      Gerd Hoffmann 提交于
      Create a new usb_ep_reset() function to reset endpoint state, without
      re-initialiting the queues, so we don't unlink in-flight packets just
      because usb-host has to re-parse the descriptor tables.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      19deaa08
    • H
    • H
      ehci: Kick async schedule on wakeup in the non companion case · 37952117
      Hans de Goede 提交于
      Commit 0f588df8, added code
      to ehci_wakeup to kick the async schedule on wakeup, but the else
      was positioned wrong making it trigger for devices which are routed
      to the companion rather then to the ehci controller itself.
      
      This patch fixes this. Note that the "programming style" with using the
      return at the end of the companion block matches how the companion case
      is handled in the other ports ops, and is done this way for consistency.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      37952117
    • H
      usb-ehci: Fix an assert whenever isoc transfers are used · 7341ea07
      Hans de Goede 提交于
      hcd-ehci.c is missing an usb_packet_init() call for the ipacket UsbPacket
      it uses for isoc transfers, triggering an assert (taking the entire vm down)
      in usb_packet_setup as soon as any isoc transfers are done by a high speed
      USB device.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      7341ea07
    • G
      ehci: don't flush cache on doorbell rings. · 9bc3a3a2
      Gerd Hoffmann 提交于
      Commit 4be23939 makes ehci instantly
      zap any unlinked queue heads when the guest rings the doorbell.
      
      While hacking up uas support this turned out to be a problem.  The linux
      kernel can unlink and instantly relink the very same queue head, thereby
      killing any async packets in flight.  That alone isn't an issue yet, the
      packet will canceled and resubmitted and everything is fine.  We'll run
      into trouble though in case the async packet is completed already, so we
      can't cancel it any more.  The transaction is simply lost then.
      
      usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f0c2 qtds 29dbce40,29dbc4e0,00000009
      usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2
      usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: alloc
      usb_packet_state_change bus 0, port 2, ep 1, packet 0x7f95fdec32e0, state undef -> setup
      usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: process
      usb_uas_command dev 2, tag 0x2, lun 0, lun64 00000000-00000000
      scsi_req_parsed target 0 lun 0 tag 2 command 42 dir 2 length 16384
      scsi_req_parsed_lba target 0 lun 0 tag 2 command 42 lba 5933312
      scsi_req_alloc target 0 lun 0 tag 2
      scsi_req_continue target 0 lun 0 tag 2
      scsi_req_data target 0 lun 0 tag 2 len 16384
      usb_uas_scsi_data dev 2, tag 0x2, bytes 16384
      usb_uas_write_ready dev 2, tag 0x2
      usb_packet_state_change bus 0, port 2, ep 1, packet 0x7f95fdec32e0, state setup -> complete
      usb_ehci_packet_action q 0x7f95fe515210 p 0x7f95fdec32a0: free
      usb_ehci_qh_ptrs q 0x7f95fdec3210 - QH @ 39c4f0c0: next 39c4f002 qtds 29dbce40,00000001,00000009
      usb_ehci_qh_fields QH @ 39c4f0c0 - rl 4, mplen 512, eps 2, ep 2, dev 2
      usb_ehci_queue_action q 0x7f95fe5152a0: free
      usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state async -> complete
      ^^^ async packets completes.
      usb_ehci_packet_action q 0x7f95fdec3210 p 0x7f95feba9130: wakeup
      
      usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f122 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f002 qtds 29dbc4e0,29dbc8a0,00000009
      usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2
      usb_ehci_queue_action q 0x7f95fdec3210: free
      usb_ehci_packet_action q 0x7f95fdec3210 p 0x7f95feba9130: free
      ^^^ endpoint #2 queue head removed from schedule, doorbell makes ehci zap the queue,
          the (completed) usb packet is freed too and gets lost.
      
      usb_ehci_qh_ptrs q (nil) - QH @ 39c4f000: next 39c4f0c2 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_qh_ptrs q 0x7f95feba90a0 - QH @ 39c4f000: next 39c4f0c2 qtds 00000000,00000001,39c50000
      usb_ehci_qh_fields QH @ 39c4f000 - rl 0, mplen 0, eps 0, ep 0, dev 0
      usb_ehci_queue_action q 0x7f9600dff570: alloc
      usb_ehci_qh_ptrs q 0x7f9600dff570 - QH @ 39c4f0c0: next 39c4f122 qtds 29dbce40,00000001,00000009
      usb_ehci_qh_fields QH @ 39c4f0c0 - rl 4, mplen 512, eps 2, ep 2, dev 2
      usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: alloc
      usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state undef -> setup
      usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: process
      usb_packet_state_change bus 0, port 2, ep 2, packet 0x7f95feba9170, state setup -> async
      usb_ehci_packet_action q 0x7f9600dff570 p 0x7f95feba9130: async
      ^^^ linux kernel relinked the queue head, ehci creates a new usb packet,
          but we should have delivered the completed one instead.
      usb_ehci_qh_ptrs q 0x7f95fe515210 - QH @ 39c4f120: next 39c4f002 qtds 29dbc4e0,29dbc8a0,00000009
      usb_ehci_qh_fields QH @ 39c4f120 - rl 4, mplen 512, eps 2, ep 1, dev 2
      
      So instead of instantly zapping the queue we'll set a flag that the
      queue needs revalidation in case we'll see it again in the schedule.
      ehci then checks that the queue head fields addressing / describing the
      endpoint and the qtd pointer match the cached content before reusing it.
      
      Cc: Hans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      9bc3a3a2
    • G
      ehci: fix td writeback · 4ed1c57a
      Gerd Hoffmann 提交于
      Only write back the dwords the hc is supposed to update.  Should not
      make a difference in theory as the guest must not touch the td while
      it is active to avoid races.  But it is still more correct.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      4ed1c57a
    • G
      ehci: fix ehci_qh_do_overlay · a5e0139a
      Gerd Hoffmann 提交于
      Use ehci_flush_qh to make sure we touch inly the fields the hc is
      allowed to touch.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      a5e0139a
  10. 04 7月, 2012 1 次提交
  11. 28 6月, 2012 2 次提交
    • 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
    • D
      usb-ohci: Use universal DMA helper functions · 9ac6a217
      David Gibson 提交于
      The OHCI device emulation can provide both PCI and SysBus OHCI
      implementations.  Because of this, it was not previously converted to
      use the PCI DMA helper functions.
      
      This patch converts it to use the new universal DMA helper functions.
      In the PCI case, it obtains its DMAContext from pci_dma_context(), in
      the SysBus case, it uses NULL - i.e. assumes for now that there will
      be no IOMMU translation for a SysBus OHCI.
      
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      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>
      9ac6a217
  12. 20 6月, 2012 6 次提交