None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch adds debug prints to the reservation and channel change
sequence to help with debugging channel change problems.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch adds support for isochronous IN transfers to the HWA driver.
The changes include removing the checks that return errors for isoc IN
URBs and adding functionality to read the isoc data returned from the
HWA.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch correctly sets the dwNumOfPackets field of the HWA transfer
request for isochronous transfers with multiple segments. Previously
all segments used the value that was set for the first segment which may
not be correct.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
If multiple segments belonging to an isoc transfer are submitted
concurrently, the isoc_frame_index field in struct wa_xfer can get
corrupted. This patch moves the isoc_frame_index field from struct
wa_xfer to struct wa_seg to prevent this from happening.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use USB_CTRL_SET_TIMEOUT and USB_CTRL_GET_TIMEOUT for USB control
messages instead of an arbitrary 1s timeout value. This is particularly
useful for WUSB since in the worst case RF scanario, a WUSB device can
be unresponsive for up to 4s and still be connected.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
If a URB is broken up into multiple transfer segments and a short
transfer occurs in any segment other than the last, the URB will
currently get stuck in the driver forever. This patch adds a check for
a short transfer and cleans up any pending segments so the URB can
complete properly.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add more info to debug prints in urb_unlink path
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add calls to usb_hcd_link_urb_to_ep, usb_hcd_unlink_urb_from_ep, and
usb_hcd_check_unlink_urb in the appropriate locations.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
When multiple wireless USB devices are connected and one of the devices
disconnects, the host will distribute a new group key to the remaining
devicese using wusbhc_gtk_rekey. wusbhc_gtk_rekey takes the
wusbhc->mutex and holds it while it submits a URB to set the new key.
This causes a deadlock in wa_urb_enqueue when it calls a device lookup
helper function that takes the same lock.
This patch changes wusbhc_gtk_rekey to submit a work item to set the GTK
so that the URB is submitted without holding wusbhc->mutex.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch modifies the device notification handler to not look up the
wusb_dev object before it calls the lower-level handler routines since
the wusbhc mutex is not held when calling those routines and the device
could go away in the meantime. Instead, let the individual notification
handlers get the device ptr if they need to after they have taken the
mutex.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch modifies the WUSB device disconnect timer code to send
keepalives to all connected devices even if they are not authenticated.
This fixes a problem where unauthenticated devices that lose their
connection before they are authenticated will stay in the device tree
forever. More importantly, devices in this situation will never
relinquish their port on the root hub so eventually all root ports will
be taken up and no other devices can connect.
A comment in the existing code states that there are some devices that
may not respond to keepalives if they have not been authenticated. That
comment is about 5 years old and I don't know of any WUSB devices that
act that way. Either way, any buggy devices that may still be around
will continue to work as long as they can transition to the
authenticated state within the WUSB LOA timeout of 4s, which is not
unreasonable to expect.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
change WA_SEGS_MAX to a number that is legal according to the WUSB
spec.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add a quirk for Alereon HWA devices to concatenate the frames of isoc
transfer requests.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Combine multiple isoc frames in a single transfer request. This allows
the HWA to take advantage of bursting to deliver data to endpoints
whose logical service interval is less than the minimum wireless USB
service interval of 4ms. Wireless audio quality is much improved after
this update.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
For isochronous endpoints, set the RPIPE wMaxPacketSize value using
wOverTheAirPacketSize from the endpoint companion descriptor instead of
wMaxPacketSize from the normal endpoint descriptor.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cbaf_probe() does cbaf->usb_dev = usb_get_dev(interface_to_usbdev(iface)),
but there is no usb_put_dev() anywhere in cbaf.
The patch adds usb_put_dev() to cbaf_disconnect() and to an error path in cbaf_probe().
Also it adds missed usb_put_intf(iface) to the error path.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Do not overwrite the multi-byte fields of usb_wa_descriptor with their
cpu format values after reading the descriptor. Leave the values as
__le16 and swap on use. This is more consistent with other uses of USB
descriptors.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch serializes access to the HWA data transfer out (DTO)
endpoint. This prevents a situation where two transfer requests being
sent concurrently to separate downstream endpoints could interleave
their transfer request and transfer data packets causing data
corruption. The transfer processing code will now attempt to acquire
the DTO resource before sending a transfer to the HWA. If it cannot
acquire the resource, the RPIPE that the transfer is assigned to will
be placed on a waiting list. When the DTO resource is released, the
actor releasing the resource will serivce the RPIPEs that are waiting.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
These aren't necessary after switch and if blocks.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch fixes compile warnings on 64-bit builds that were introduced
by the recent isoc changes.
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch adds support for isochronous out transfers to the HWA. The
primary changes are:
1. Add a isoc_pack_desc_urb field to struct wa_seg. This urb is used
to send the isochronous packet info message to the HWA which describes
the isoc data segment(s) that will be sent as the payload of the
transfer request.
2. Use the URB iso_frame_desc field to populate the isochronous packet
info message and data segments sent to the HWA.
3. After the data is sent and transfer result is returned from the
HWA, read the isoc packet status message from the HWA. The contents of
the isoc packet status message are used to set the iso_frame_desc
status and actual_length fields in the original isoc URB. This feature
required the addition of a some state tracking variables in struct wahc
so the dti_urb knows what type of packet it expects to receive next.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch sets the RPIPE bOverTheAirInterval field for RPIPES which
refer to isochronous endpoints.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch modifies wa_urb_enqueue to return an error and not call the
urb completion routine if it failed to enqueue the urb because the HWA
device is gone. This prevents a stack overflow due to infinite
submit/complete recursion when unplugging the HWA while connected to a
HID device.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix a build warning found by the kbuild test robot in the most recent
wusbcore patches.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch updates URB dequeue handling in wusbcore to make it more
reliable when a URB has been broken up into multiple WUSB transfer
request segments.
In wa_urb_dequeue, don't mark segments in the WA_SEG_SUBMITTED,
WA_SEG_PENDING or WA_SEG_DTI_PENDING states as completed if an ABORT
TRANSFER request was sent to the HWA to clean them up. Wait for the
HWA to return a transfer result indicating that it has aborted the
request before cleaning it up. This prevents the DTI state machine
from losing track of transfers and avoids confusion in the case where a
read transfer segment is dequeued after the driver has received the
transfer result but before the data is received.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Include the xfer_id in debug prints for transfers and transfer segments.
This makes it much easier to correlate debug logs to USB analyzer logs.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add a new function to get the xfer ID in little endian format
(wa_xfer_id_le32), and use it instead of wa_xfer_id where appropriate.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch fixes two cases where error handling code was freeing memory
but not setting the pointer to NULL. This could lead to a double free
in the HWA shutdown code.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Clean up the SG list after transfer completetion for out transfers if one
was created by the HWA.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This patch updates __wa_xfer_setup_segs error path to only clean up the
xfer->seg entry that it failed to create and then set that entry to
NULL. wa_xfer_destroy will clean up the remaining xfer->segs that were
fully created. It also moves the code to create the dto sg list to an
out of line function to make __wa_xfer_setup_segs easier to read. Prior
to this change, __wa_xfer_setup_segs would clean up all entries in the
xfer->seg array in case of an error but it did not set them to NULL.
This resulted in a double free when wa_xfer_destroy was eventually
called by the higher level error handler.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
If __wa_xfer_setup fails, it can leave a partially constructed wa_xfer
object. The error handling code eventually calls wa_xfer_destroy which
does not check for NULL before dereferencing xfer->seg which could cause
a kernel panic. This change also makes sure to free xfer->seg which was
being leaked for all transfers before this change.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rename xfer_result to dti_buf and xfer_result_size to dti_buf_size in
struct wahc. The dti buffer will also be used for isochronous status
packets once isochronous transfers are supported.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rename urb to tr_urb in struct wa_seg to make it clear that the urb is
used for the transfer request.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
In wa_seg_init, use usb_init_urb to init the URB object contained in the
transfer segment instead of initializing it manually. Use kmalloc to
allocate the memory for segment instead of kzalloc and then use memset
to set the non-URB portion of the transfer segment struct to 0 since
that was already done by usb_init_urb.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The check to free the URB was the opposite of the correct case. This
patch removes the check altogether since the ptr will be NULL if the URB
was not allocated. Also use usb_free_urb instead of usb_put_urb.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Use usb_free_urb instead of kfree in error path and point to the correct
URB. Also remember to clean up the sg list for the URB if it was allocated.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
When the HWA encounters a STALL on a control endpoint, it should clear the
RPIPE_STALL feature on the RPIPE before processing the next transfer
request. Otherwise, all transfer requests on that endpoint after the
first STALL will fail because the RPIPE is still in the halted state.
This also removes the unneccessary call to spin_lock_irqsave for a nested
lock that was present in the first patch.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>