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 2 次提交
  3. 15 8月, 2012 1 次提交
  4. 12 7月, 2012 3 次提交
  5. 09 7月, 2012 5 次提交
    • 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
  6. 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
  7. 20 6月, 2012 2 次提交
  8. 07 6月, 2012 18 次提交
  9. 14 5月, 2012 1 次提交
    • J
      fix some common typos · a31f0531
      Jim Meyering 提交于
      These were identified using: http://github.com/lyda/misspell-check
      and run like this to create a bourne shell script using GNU sed's
      -i option:
      
      git ls-files|grep -vF .bin | misspellings -f - |grep -v '^ERROR:' |perl \
      -pe 's/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/sed -i '\''${2}s!$3!$4!'\'' $1/'
      
      Manually eliding the FP, "rela->real" and resolving "addres" to
      address (not "adders") we get this:
      
        sed -i '450s!thru!through!' Changelog
        sed -i '260s!neccessary!necessary!' coroutine-sigaltstack.c
        sed -i '54s!miniscule!minuscule!' disas.c
        sed -i '1094s!thru!through!' hw/usb/hcd-ehci.c
        sed -i '1095s!thru!through!' hw/usb/hcd-ehci.c
        sed -i '21s!unecessary!unnecessary!' qapi-schema-guest.json
        sed -i '307s!explictly!explicitly!' qemu-ga.c
        sed -i '490s!preceeding!preceding!' qga/commands-posix.c
        sed -i '792s!addres!address!' qga/commands-posix.c
        sed -i '6s!beeing!being!' tests/tcg/test-mmap.c
      
      Also, manually fix "arithmentic", spotted by Peter Maydell:
      
        sed -i 's!arithmentic!arithmetic!' coroutine-sigaltstack.c
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      a31f0531
  10. 26 4月, 2012 1 次提交