summaryrefslogtreecommitdiff
path: root/hw/usb
AgeCommit message (Collapse)AuthorFilesLines
2014-02-18xhci: fix overflow in usb_xhci_post_loadGerd Hoffmann1-1/+1
Found by Coverity. Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-02-18usb: Remove magic constants from device bmAttributesPantelis Koukousoulas11-18/+20
Replace magic constants in device bmAttributes with symbolic ones from Linux kernel ch9.h Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-02-17Use error_is_set() only when necessaryMarkus Armbruster1-1/+1
error_is_set(&var) is the same as var != NULL, but it takes whole-program analysis to figure that out. Unnecessarily hard for optimizers, static checkers, and human readers. Dumb it down to obvious. Gets rid of several dozen Coverity false positives. Note that the obvious form is already used in many places. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-14qdev: Remove hex8/32/64 property typesPaolo Bonzini1-2/+2
Replace them with uint8/32/64. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2014-02-10qdev:pci: refactor PCIDevice to use generic "hotpluggable" propertyIgor Mammedov4-4/+4
Get rid of PCIDevice specific PCIDeviceClass.no_hotplug and use generic DeviceClass.hotpluggable field instead. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2014-01-16usb-hid: add microsoft os descriptor supportGerd Hoffmann1-0/+8
Set SelectiveSuspendEnabled registy entry to one. This makes Windows use remote suspend by default, without manual registry fiddeling. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-01-16usb: add support for microsoft os descriptorsGerd Hoffmann5-6/+280
This patch adds support for special usb descriptors used by microsoft windows. They allow more fine-grained control over driver binding and adding entries to the registry for configuration. As this is a guest-visible change the "msos-desc" compat property has been added to turn this off for 1.7 + older Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-12-06Merge remote-tracking branch 'kraxel/tags/pull-usb-1' into stagingAnthony Liguori8-87/+290
Improvements for usb3 bulk stream (usb core, xhci). Bugfixes for uas emulation. Add remote wakeup support for ehci. Add suspend support for xhci. Misc minor tweaks and fixes. # gpg: Signature made Thu 28 Nov 2013 11:44:49 PM PST using RSA key ID D3E87138 # gpg: Can't check signature: public key not found # By Hans de Goede (11) and others # Via Gerd Hoffmann * kraxel/tags/pull-usb-1: usb: move usb_{hi,lo} helpers to header file. usb: add vendor request defines trace-events: Clean up after removal of old usb-host code Revert "usb-tablet: Don't claim wakeup capability for USB-2 version" ehci: implement port wakeup xhci: Call usb_device_alloc/free_streams usb: Add usb_device_alloc/free_streams usb: Add max_streams attribute to endpoint info uas: s/ui/iu/ uas: Fix response iu struct definition uas: Bounds check tags when using streams uas: Streams are numbered 1-y, rather then 0-x uas: Fix / cleanup usb_uas_task error handling uas: Only use report iu-s for task_mgmt status reporting scsi: Add 2 new sense codes needed by uas xhci: add support for suspend/resume xhci: Add a few missing checks for disconnected devices Message-id: 1385712381-30918-1-git-send-email-kraxel@redhat.com Signed-off-by: Anthony Liguori <aliguori@amazon.com>
2013-12-02trace: Remove trace.h from hw/usb/hcd-ehci.h (less dependencies)Stefan Weil2-1/+1
This reduces the dependencies on trace.h. Only one source file which needs hcd-ehci.h also needs trace.h. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-11-28usb: move usb_{hi,lo} helpers to header file.Gerd Hoffmann2-10/+11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-28Revert "usb-tablet: Don't claim wakeup capability for USB-2 version"Gerd Hoffmann1-1/+1
This reverts commit aa1c9e971e80d25b92908dce3dec7c38b49480ea. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-28ehci: implement port wakeupGerd Hoffmann1-2/+16
Update portsc register and raise irq in case a suspended port is woken up, so remote wakeup works on our ehci ports. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26xhci: Call usb_device_alloc/free_streamsHans de Goede1-0/+117
Note this code is not as KISS as I would like, the reason for this is that the Linux kernel interface wants streams on eps belonging to one interface to be allocated in one call. Things will also work if we do this one ep at a time (as long as all eps support the same amount of streams), but lets stick to the kernel API. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26usb: Add usb_device_alloc/free_streamsHans de Goede1-0/+18
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26usb: Add max_streams attribute to endpoint infoHans de Goede2-0/+24
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: s/ui/iu/Hans de Goede1-38/+38
The various uas data structures are called IU-s, which is short for Information Unit, rather then UI-s. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: Fix response iu struct definitionHans de Goede1-10/+8
This patch mirrors a patch to the Linux uas kernel driver which I've just submitted. It looks like the qemu uas struct definitions were taken from the Linux kernel driver, and have inherited the same mistake. Besides fixing the response iu struct, the patch also drops the add_info parameter from the usb_uas_queue_response() function, it is always 0 anyways, and expressing 3 zero-bytes as a function argument is a bit hard. Below is the long explanation for this change taken from the kernel commit: The response iu struct before this patch has a size of 7 bytes, which is weird since all other iu-s are explictly padded to a multiple of 4 bytes. Submitting a 7 byte bulk transfer to the status endpoint of a real uasp device when expecting a response iu results in an USB babble error, as the device actually sends 8 bytes. Up on closer reading of the UAS spec: http://www.t10.org/cgi-bin/ac.pl?t=f&f=uas2r00.pdf The reason for this becomes clear, the 2 entries in "Table 17 — RESPONSE IU" are numbered 4 and 6, looking at other iu definitions in the spec, esp. multi-byte fields, this indicates that the ADDITIONAL RESPONSE INFORMATION field is not a 2 byte field as one might assume at a first look, but is a multi-byte field containing 3 bytes. This also aligns with the SCSI Architecture Model 4 spec, which UAS is based on which states in paragraph "7.1 Task management function procedure calls" that the "Additional Response Information" output argument for a Task management function procedure call is 3 bytes. Last but not least I've verified this by sending a logical unit reset task management call with an invalid lun to an actual uasp device, and received back a response-iu with byte 6 being 0, and byte 7 being 9, which is the responce code for an invalid iu, which confirms that the response code is being reported in byte 7 of the response iu rather then in byte 6. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: Bounds check tags when using streamsHans de Goede1-0/+14
Disallow the guest to cause us to address the data3 and status3 arrays out of bounds. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: Streams are numbered 1-y, rather then 0-xHans de Goede1-3/+3
It is easier to simply make the arrays one larger, rather then substracting one everywhere. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: Fix / cleanup usb_uas_task error handlingHans de Goede1-17/+3
-The correct error if we cannot find the dev is INCORRECT_LUN rather then INVALID_INFO_UNIT -Move the device not found check to the top so we only need to do it once -Remove the dev->lun != lun checks, dev is returned by scsi_device_find which searches by lun, so this will never trigger Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26uas: Only use report iu-s for task_mgmt status reportingHans de Goede1-8/+22
Regular scsi cmds should always report their status using a sense-iu, using the sense code to report any errors. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26xhci: add support for suspend/resumeGerd Hoffmann1-0/+8
The OS can ask the xhci controller to save and restore its internal state, which is used by the OS when the system is suspended and resumed. This patch handles writes to the save + restore bits in the command register. Only thing it does is updating the restore error bit in the status register to signal an error on restore. The guest OS should do a full reinitialization after resume then. This is the minimal patch which gets S3 going with xhci. Implementing full save/restore support is TBD. https://bugzilla.redhat.com/show_bug.cgi?id=1012365 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-26xhci: Add a few missing checks for disconnected devicesHans de Goede1-2/+11
One of the reworks of qemu's usb core made changes to usb-port's disconnect handling. Now ports with a device will always have a non 0 dev member, but if the device is not attached (which is possible with usb redirection), dev->attached will be 0. So supplement all checks for dev to also check dev->attached, and add an extra check in a path where a device check was completely missing. This fixes various crashes (asserts triggering) I've been seeing when xhci attached usb devices get disconnected at the wrong time. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-11-13usb: drop unused USBNetState.inpkt fieldStefan Hajnoczi1-1/+0
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-11-05qdev: Drop misleading qdev_free() functionStefan Hajnoczi3-5/+6
The qdev_free() function name is misleading since all the function does is unlink the device from its parent. The device is not necessarily freed. The device will be freed when its QObject refcount reaches zero. It is usual for the parent (bus) to hold the final reference but there are cases where something else holds a reference so "free" is a misleading name. Call object_unparent(obj) directly instead of having a qdev wrapper function. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-10-31Merge remote-tracking branch 'kraxel/usb.91' into stagingAnthony Liguori2-37/+39
* kraxel/usb.91: usb-hcd-xhci: Update endpoint context dequeue pointer for streams too usb-hcd-xhci: Report completion of active transfer with CC_STOPPED on ep stop usb-hcd-xhci: Remove unused cancelled member from XHCITransfer usb-hcd-xhci: Remove unused sstreamsm member from XHCIStreamContext usb-host-libusb: Detach kernel drivers earlier usb-host-libusb: Configuration 0 may be a valid configuration usb-host-libusb: Fix reset handling Message-id: 1382620267-18065-1-git-send-email-kraxel@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-10-31Merge remote-tracking branch 'mst/tags/for_anthony' into stagingAnthony Liguori4-11/+6
pci, pc, acpi fixes, enhancements This includes some pretty big changes: - pci master abort support by Marcel - pci IRQ API rework by Marcel - acpi generation support by myself Everything has gone through several revisions, latest versions have been on list for a while without any more comments, tested by several people. Please pull for 1.7. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Tue 15 Oct 2013 07:33:48 AM CEST using RSA key ID D28D5469 # gpg: Can't check signature: public key not found * mst/tags/for_anthony: (39 commits) ssdt-proc: update generated file ssdt: fix PBLK length i386: ACPI table generation code from seabios pc: use new api to add builtin tables acpi: add interface to access user-installed tables hpet: add API to find it pvpanic: add API to access io port ich9: APIs for pc guest info piix: APIs for pc guest info acpi/piix: add macros for acpi property names i386: define pc guest info loader: allow adding ROMs in done callbacks i386: add bios linker/loader loader: use file path size from fw_cfg.h acpi: ssdt pcihp: updat generated file acpi: pre-compiled ASL files acpi: add rules to compile ASL source i386: add ACPI table files from seabios q35: expose mmcfg size as a property q35: use macro for MCFG property name ... Message-id: 1381818560-18367-1-git-send-email-mst@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-10-22usb-hcd-xhci: Update endpoint context dequeue pointer for streams tooHans de Goede1-2/+8
With streams the endpoint context dequeue pointer should point to the dequeue value for the currently active stream. At least Linux guests expect it to point to value set by an set_ep_dequeue upon completion of the set_ep_dequeue (before kicking the ep). Otherwise the Linux kernel will complain (and things won't work): xhci_hcd 0000:00:05.0: Mismatch between completed Set TR Deq Ptr command & xHCI internal state. xhci_hcd 0000:00:05.0: ep deq seg = ffff8800366f0880, deq ptr = ffff8800366ec010 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-hcd-xhci: Report completion of active transfer with CC_STOPPED on ep stopHans de Goede1-8/+18
As we should per the XHCI spec "4.6.9 Stop Endpoint". Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-hcd-xhci: Remove unused cancelled member from XHCITransferHans de Goede1-5/+0
Since qemu's USB model is geared towards emulated devices cancellation is instanteneous, so no need to wait for cancellation to complete, as such there is no wait for cancellation code, and the cancelled bool as well as the bogus comment about it can be removed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-hcd-xhci: Remove unused sstreamsm member from XHCIStreamContextHans de Goede1-9/+0
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-host-libusb: Detach kernel drivers earlierHans de Goede1-2/+5
If we detach the kernel drivers on the first set_config, then they will be still attached when the device gets its initial reset. Causing the drivers to re-initialize the device after the reset, dirtying the device state. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-host-libusb: Configuration 0 may be a valid configurationHans de Goede1-5/+4
Quoting from: linux/Documentation/ABI/stable/sysfs-bus-usb: Note that some devices, in violation of the USB spec, have a configuration with a value equal to 0. Writing 0 to bConfigurationValue for these devices will install that configuration, rather then unconfigure the device. So don't compare the configuration value against 0 to check for unconfigured devices, instead check for a LIBUSB_ERROR_NOT_FOUND return from libusb_get_active_config_descriptor(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-22usb-host-libusb: Fix reset handlingHans de Goede1-6/+4
The guest will issue an initial device reset when the device is attached, but since the current usb-host-libusb code only actually does the reset when udev->configuration != 0, and on attach the device is not yet configured, the reset gets ignored. This means that the device gets passed to the guest in an unknown state, which is not good. The udev->configuration check is there because of the release / claim interfaces done around the libusb_device_reset call, but these are not necessary. If interfaces are claimed when libusb_device_reset gets called libusb will release + reclaim them itself. The usb_host_ep_update call also is not necessary. If the reset succeeds the original config and interface alt settings will be restored. Last if the reset fails, that means the device has either disconnected or morphed into an another device and has been completely re-enumerated, so it is treated by the host as a new device and our handle is invalid, so on reset failure we need to call usb_host_nodev(). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-10-14hw: set interrupts using pci irq wrappersMarcel Apfelbaum4-11/+6
pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. An irq is allocated using pci_allocate_irq wrapper only if is needed by non pci devices. Removed irq related fields from state if not used anymore. Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2013-10-02pci-ohci: Add missing 'break' in ohci_service_tdJán Veselý1-0/+2
Device communication errors need to be reported to driver. Add a debug message while at it. Signed-off-by: Jan Vesely <jano.vesely@gmail.com> Acked-by: Gerd Hoffmann <kraxel@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2013-09-19usb: Fix iovec memleak on combined-packet freeHans de Goede1-0/+1
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19usb: Also reset max_packet_size on ep_resetHans de Goede1-0/+3
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19xhci: Fix memory leak on xhci_disable_epHans de Goede1-0/+5
The USBPacket-s in the transfers need to be cleaned up so that the memory allocated by the iovec in there gets freed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19xhci: Add xhci_epid_to_usbep helper functionHans de Goede1-10/+22
And use it instead of prying the USBEndpoint out of the packet struct in various places. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19xhci: Init a transfers xhci, slotid and epid member on epctx allocHans de Goede1-3/+3
Transfers are part of an epctx, which is part of a slot, which is part of a xhci. Transfers cannot dynamically be moved from one epctx to another, so once created their xhci, slotid and epid are constant, so lets set these up at creation time, rather then re-initializing them with the same value each time a transfer gets submitted. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19xhci: Fix number of streams allocated when using streamsHans de Goede1-1/+1
According to the xhci spec the total number of streams is 2 ^ (MaxPStreams + 1), and this is also how the Linux xhci driver uses this field. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-19usb: remove old usb-host codeGerd Hoffmann2-2550/+0
The usb-host code has been rewritten for qemu 1.5 to use libusb, the old code has been left in as temporary fallback. Now we are two releases further out, targeting the 1.7 release. No major issues with the new code poped up until now. Time to remove it from tre tree. Should we ever need it again for some reason -- git has a copy for us in the history. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-10ehci: save device pointer in EHCIStateGerd Hoffmann2-4/+4
We'll need a pointer to the actual pci/sysbus device, stick a pointer to it into the EHCIState struct. https://bugzilla.redhat.com/show_bug.cgi?id=1005495 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-10Remove dev-bluetooth.c dependency from vl.cMiroslav Rezanina2-4/+9
Use usb_legacy_register handling to create bt-dongle device and remove code dependency from vl.c so CONFIG_USB_BLUETOOTH can be disabled. Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-10usb: sanity check setup_index+setup_len in post_loadGerd Hoffmann1-0/+4
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-03Merge remote-tracking branch 'kraxel/usb.88' into stagingAnthony Liguori5-23/+78
# By Gerd Hoffmann (10) and Marcel Apfelbaum (1) # Via Gerd Hoffmann * kraxel/usb.88: usb/dev-hid: Modified usb-tablet category from Misc to Input Revert "usb-hub: report status changes only once" usb-hub: add tracepoint for status reports usb: parallelize usb3 streams uas: add property for request logging xhci: reset port when disabling slot xhci: emulate intr endpoint intervals correctly xhci: fix endpoint interval calculation xhci: add port to slot_address tracepoint xhci: add tracepoint for endpoint state changes xhci: remove leftover debug printf Message-id: 1378117055-29620-1-git-send-email-kraxel@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
2013-09-02usb/dev-hid: Modified usb-tablet category from Misc to InputMarcel Apfelbaum1-1/+1
usb-tablet device was wrongly assigned to Misc category Reported-by: Markus Armbruster <armbru@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02Revert "usb-hub: report status changes only once"Gerd Hoffmann1-5/+1
This reverts commit a309ee6e0a256f690760abfba44fceaa52a7c2f3. This isn't in line with the usb specification and adds regressions, win7 fails to drive the usb hub for example. Was added because it "solved" the issue of hubs interacting badly with the xhci host controller. Now with the root cause being fixed in xhci (commit <FIXME>) we can revert this one. Cc: qemu-stable@nongnu.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-02usb-hub: add tracepoint for status reportsGerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>