1. 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
  2. 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
  3. 20 6月, 2012 2 次提交
  4. 07 6月, 2012 18 次提交
  5. 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
  6. 26 4月, 2012 3 次提交
  7. 17 4月, 2012 4 次提交
    • G
      usb-ehci: drop assert() · c7020c97
      Gerd Hoffmann 提交于
      Not sure what the purpose of the assert() was, in any case it is bogous.
      We can arrive there if transfer descriptors passed to us from the guest
      failed to pass sanity checks, i.e. it is guest-triggerable.  We deal
      with that case by resetting the host controller.  Everything is ok, no
      need to throw a core dump here.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      c7020c97
    • H
      usb-ehci: Drop unused sofv value · 8e24283b
      Hans de Goede 提交于
      The sofv value only ever gets a value assigned and is never used (read)
      anywhere, so we can just drop it.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      8e24283b
    • H
      usb-ehci: frindex always is a 14 bits counter · 58ea88d8
      Hans de Goede 提交于
      frindex always is a 14 bits counter, and not a 13 bits one as we were
      emulating. There are some subtle hints to this in the spec, first of all
      "Table 2-12. FRINDEX - Frame Index Register" says:
      "Bit 13:0 Frame Index. The value in this register increments at the end of
      each time frame (e.g. micro-frame). Bits [N:3] are used for the Frame List
      current index. This means that each location of the frame list is accessed
      8 times (frames or micro-frames) before moving to the next index. The
      following illustrates values of N based on the value of the Frame List
      Size field in the USBCMD register.
      
      USBCMD[Frame List Size]	Number Elements		 N
      00b				1024		12
      01b				 512		11
      10b				 256		10
      11b			    Reserved"
      
      Notice how the text talks about "Bits [N:3]" are used ..., it does
      NOT say that when N == 12 (our case) the counter will wrap from 8191 to 0,
      or in otherwords that it is a 13 bits counter (bits 0 - 12).
      
      The other hint is in "Table 2-10. USBSTS USB Status Register Bit Definitions":
      
      "Bit 3 Frame List Rollover - R/WC. The Host Controller sets this bit to a one
      when the Frame List Index (see Section 2.3.4) rolls over from its maximum value
      to zero. The exact value at which the rollover occurs depends on the frame
      list size. For example, if the frame list size (as programmed in the Frame
      List Size field of the USBCMD register) is 1024, the Frame Index Register
      rolls over every time FRINDEX[13] toggles. Similarly, if the size is 512,
      the Host Controller sets this bit to a one every time FRINDEX[12] toggles."
      
      Notice how this text talks about setting bit 3 when bit 13 of frindex toggles
      (when there are 1024 entries, so our case), so this indicates that frindex
      has a bit 13 making it a 14 bit counter.
      
      Besides these clear hints the real proof is in the pudding. Before this
      patch I could not stream data from a USB2 webcam under Windows XP, after
      this cam using a USB2 webcam under Windows XP works fine, and no regressions
      with other operating systems were seen.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      58ea88d8
    • G
      usb-ehci: fix ehci_child_detach · 088351a7
      Gerd Hoffmann 提交于
      Looks like a cut+paste bug from ehci_detach.  When the device itself is
      detached from a ehci port (ehci_detach op) we have to clear the
      device pointer for the companion port too.  When a device gets removed
      from a downstream port of a usb hub (ehci_child_detach op) the ehci port
      where the usb hub is plugged in is not affected.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      088351a7
  8. 13 3月, 2012 2 次提交
  9. 07 3月, 2012 4 次提交
    • 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
    • H
      usb-ehci: Cleanup itd error handling · 5eafd438
      Hans de Goede 提交于
      All error statuses except for NAK are handled in a switch case, move the
      handling of NAK into the same switch case.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      5eafd438
    • H
      usb-ehci: Fix and simplify nakcnt handling · 553a6a59
      Hans de Goede 提交于
      The nakcnt code in ehci_execute_complete() marked transactions as finished
      when a packet completed with a result of USB_RET_NAK, but USB_RET_NAK
      means that the device cannot receive / send data at that time and that
      the transaction should be retried later, which is also what the usb-uhci
      and usb-ohci code does.
      
      Note that there already was some special code in place to handle this
      for interrupt endpoints in the form of doing a return from
      ehci_execute_complete() when reload == 0, but that for bulk transactions
      this was not handled correctly (where as for example the usb-ccid device does
      return USB_RET_NAK for bulk packets).
      
      Besides that the code in ehci_execute_complete() decrement nakcnt by 1
      on a packet result of USB_RET_NAK, but
      -since the transaction got marked as finished,
       nakcnt would never be decremented again
      -there is no code checking for nakcnt becoming 0
      -there is no use in re-trying the transaction within the same usb frame /
       usb-ehci frame-timer call, since the status of emulated devices won't change
       as long as the usb-ehci frame-timer is running
      So we should simply set the nakcnt to 0 when we get a USB_RET_NAK, thus
      claiming that we've tried reload times (or as many times as possible if
      reload is 0).
      
      Besides the code in ehci_execute_complete() handling USB_RET_NAK there
      was also code handling it in ehci_state_executing(), which calls
      ehci_execute_complete(), and then does its own handling on top of the handling
      in ehci_execute_complete(), this code would decrement nakcnt *again* (if not
      already 0), or restore the reload value (which was never changed) on success.
      
      Since the double decrement was wrong to begin with, and is no longer needed
      now that we set nakcnt directly to 0 on USB_RET_NAK, and the restore of reload
      is not needed either, this patch simply removes all nakcnt handling from
      ehci_state_executing().
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      553a6a59
    • H
      usb-ehci: Remove dead nakcnt code · aa73fcdc
      Hans de Goede 提交于
      This patch removes 2 bits of dead nakcnt code:
      
      1) usb_ehci_execute calls ehci_qh_do_overlay which does:
      nakcnt = reload;
      and then has a block of code which is conditional on:
      if (reload && !nakcnt) {
      which ofcourse is never true now as nakcnt == reload.
      
      2) ehci_state_fetchqh does:
      nakcnt = reload;
      but before nakcnt is ever used ehci_state_fetchqh is always followed
      by a ehci_qh_do_overlay call which also does:
      nakcnt = reload;
      So doing this from ehci_state_fetchqh is redundant.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      aa73fcdc