Skip to content

Commit

Permalink
Merge tag 'usb-4.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are a few minor USB fixes for 4.15-rc3.

  The largest here is the Kconfig text and configuration changes for the
  USB TypeC build options that you reported during the -rc1 merge
  window. The others are all just small fixes for reported issues, as
  well as some new device ids.

  The most "interesting" of anything here is the usbip fixes as it seems
  lots of people are starting to pay attention to that driver at the
  moment. These fixes should resolve all of the reported problems as of
  now.

  Of course there are the usual xhci and gadget fixes as well, can't go
  a pull request without those...

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-4.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (22 commits)
  usb: xhci: fix panic in xhci_free_virt_devices_depth_first
  xhci: Don't show incorrect WARN message about events for empty rings
  usbip: fix usbip attach to find a port that matches the requested speed
  usbip: Fix USB device hang due to wrong enabling of scatter-gather
  uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices
  usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub
  usb: build drivers/usb/common/ when USB_SUPPORT is set
  usb: hub: Cycle HUB power when initialization fails
  USB: core: Add type-specific length check of BOS descriptors
  usb: host: fix incorrect updating of offset
  USB: ulpi: fix bus-node lookup
  USB: usbfs: Filter flags passed in from user space
  usb: add user selectable option for the whole USB Type-C Support
  usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT
  usb: gadget: core: Fix ->udc_set_speed() speed handling
  usb: gadget: allow to enable legacy drivers without USB_ETH
  usb: gadget: udc: renesas_usb3: fix number of the pipes
  usb: gadget: don't dereference g until after it has been null checked
  USB: serial: usb_debug: add new USB device id
  usb: bdc: fix platform_no_drv_owner.cocci warnings
  ...
  • Loading branch information
Linus Torvalds committed Dec 5, 2017
2 parents 54b9937 + 80e4576 commit 6b0b3bd
Show file tree
Hide file tree
Showing 24 changed files with 169 additions and 40 deletions.
1 change: 1 addition & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ obj-$(CONFIG_TC) += tc/
obj-$(CONFIG_UWB) += uwb/
obj-$(CONFIG_USB_PHY) += usb/
obj-$(CONFIG_USB) += usb/
obj-$(CONFIG_USB_SUPPORT) += usb/
obj-$(CONFIG_PCI) += usb/
obj-$(CONFIG_USB_GADGET) += usb/
obj-$(CONFIG_OF) += usb/
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/common/ulpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ static int ulpi_of_register(struct ulpi *ulpi)
/* Find a ulpi bus underneath the parent or the grandparent */
parent = ulpi->dev.parent;
if (parent->of_node)
np = of_find_node_by_name(parent->of_node, "ulpi");
np = of_get_child_by_name(parent->of_node, "ulpi");
else if (parent->parent && parent->parent->of_node)
np = of_find_node_by_name(parent->parent->of_node, "ulpi");
np = of_get_child_by_name(parent->parent->of_node, "ulpi");
if (!np)
return 0;

Expand Down
28 changes: 24 additions & 4 deletions drivers/usb/core/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,25 @@ void usb_release_bos_descriptor(struct usb_device *dev)
}
}

static const __u8 bos_desc_len[256] = {
[USB_CAP_TYPE_WIRELESS_USB] = USB_DT_USB_WIRELESS_CAP_SIZE,
[USB_CAP_TYPE_EXT] = USB_DT_USB_EXT_CAP_SIZE,
[USB_SS_CAP_TYPE] = USB_DT_USB_SS_CAP_SIZE,
[USB_SSP_CAP_TYPE] = USB_DT_USB_SSP_CAP_SIZE(1),
[CONTAINER_ID_TYPE] = USB_DT_USB_SS_CONTN_ID_SIZE,
[USB_PTM_CAP_TYPE] = USB_DT_USB_PTM_ID_SIZE,
};

/* Get BOS descriptor set */
int usb_get_bos_descriptor(struct usb_device *dev)
{
struct device *ddev = &dev->dev;
struct usb_bos_descriptor *bos;
struct usb_dev_cap_header *cap;
struct usb_ssp_cap_descriptor *ssp_cap;
unsigned char *buffer;
int length, total_len, num, i;
int length, total_len, num, i, ssac;
__u8 cap_type;
int ret;

bos = kzalloc(sizeof(struct usb_bos_descriptor), GFP_KERNEL);
Expand Down Expand Up @@ -965,15 +976,21 @@ int usb_get_bos_descriptor(struct usb_device *dev)
dev->bos->desc->bNumDeviceCaps = i;
break;
}
cap_type = cap->bDevCapabilityType;
length = cap->bLength;
if (bos_desc_len[cap_type] && length < bos_desc_len[cap_type]) {
dev->bos->desc->bNumDeviceCaps = i;
break;
}

total_len -= length;

if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
dev_warn(ddev, "descriptor type invalid, skip\n");
continue;
}

switch (cap->bDevCapabilityType) {
switch (cap_type) {
case USB_CAP_TYPE_WIRELESS_USB:
/* Wireless USB cap descriptor is handled by wusb */
break;
Expand All @@ -986,8 +1003,11 @@ int usb_get_bos_descriptor(struct usb_device *dev)
(struct usb_ss_cap_descriptor *)buffer;
break;
case USB_SSP_CAP_TYPE:
dev->bos->ssp_cap =
(struct usb_ssp_cap_descriptor *)buffer;
ssp_cap = (struct usb_ssp_cap_descriptor *)buffer;
ssac = (le32_to_cpu(ssp_cap->bmAttributes) &
USB_SSP_SUBLINK_SPEED_ATTRIBS) + 1;
if (length >= USB_DT_USB_SSP_CAP_SIZE(ssac))
dev->bos->ssp_cap = ssp_cap;
break;
case CONTAINER_ID_TYPE:
dev->bos->ss_id =
Expand Down
14 changes: 9 additions & 5 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,18 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
int number_of_packets = 0;
unsigned int stream_id = 0;
void *buf;

if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP |
USBDEVFS_URB_SHORT_NOT_OK |
unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK |
USBDEVFS_URB_BULK_CONTINUATION |
USBDEVFS_URB_NO_FSBR |
USBDEVFS_URB_ZERO_PACKET |
USBDEVFS_URB_NO_INTERRUPT))
return -EINVAL;
USBDEVFS_URB_NO_INTERRUPT;
/* USBDEVFS_URB_ISO_ASAP is a special case */
if (uurb->type == USBDEVFS_URB_TYPE_ISO)
mask |= USBDEVFS_URB_ISO_ASAP;

if (uurb->flags & ~mask)
return -EINVAL;

if ((unsigned int)uurb->buffer_length >= USBFS_XFER_MAX)
return -EINVAL;
if (uurb->buffer_length > 0 && !uurb->buffer)
Expand Down
9 changes: 9 additions & 0 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -4948,6 +4948,15 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
usb_put_dev(udev);
if ((status == -ENOTCONN) || (status == -ENOTSUPP))
break;

/* When halfway through our retry count, power-cycle the port */
if (i == (SET_CONFIG_TRIES / 2) - 1) {
dev_info(&port_dev->dev, "attempt power cycle\n");
usb_hub_set_port_power(hdev, hub, port1, false);
msleep(2 * hub_power_on_good_delay(hub));
usb_hub_set_port_power(hdev, hub, port1, true);
msleep(hub_power_on_good_delay(hub));
}
}
if (hub->hdev->parent ||
!hcd->driver->port_handed_over ||
Expand Down
3 changes: 3 additions & 0 deletions drivers/usb/core/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ static const struct usb_device_id usb_quirk_list[] = {
/* appletouch */
{ USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },

/* Genesys Logic hub, internally used by KY-688 USB 3.1 Type-C Hub */
{ USB_DEVICE(0x05e3, 0x0612), .driver_info = USB_QUIRK_NO_LPM },

/* Genesys Logic hub, internally used by Moshi USB to Ethernet Adapter */
{ USB_DEVICE(0x05e3, 0x0616), .driver_info = USB_QUIRK_NO_LPM },

Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ choice
controller, and the relevant drivers for each function declared
by the device.

source "drivers/usb/gadget/legacy/Kconfig"

endchoice

source "drivers/usb/gadget/legacy/Kconfig"

endif # USB_GADGET
7 changes: 5 additions & 2 deletions drivers/usb/gadget/composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
{
struct usb_composite_dev *cdev = get_gadget_data(g);
struct usb_endpoint_descriptor *chosen_desc = NULL;
struct usb_descriptor_header **speed_desc = NULL;

Expand Down Expand Up @@ -226,8 +225,12 @@ int config_ep_by_speed(struct usb_gadget *g,
_ep->maxburst = comp_desc->bMaxBurst + 1;
break;
default:
if (comp_desc->bMaxBurst != 0)
if (comp_desc->bMaxBurst != 0) {
struct usb_composite_dev *cdev;

cdev = get_gadget_data(g);
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
}
_ep->maxburst = 1;
break;
}
Expand Down
15 changes: 12 additions & 3 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
else
ret = ep->status;
goto error_mutex;
} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_KERNEL))) {
} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
ret = -ENOMEM;
} else {
req->buf = data;
Expand Down Expand Up @@ -2282,9 +2282,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;

if (len < sizeof(*d) ||
d->bFirstInterfaceNumber >= ffs->interfaces_count ||
!d->Reserved1)
d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
if (d->Reserved1 != 1) {
/*
* According to the spec, Reserved1 must be set to 1
* but older kernels incorrectly rejected non-zero
* values. We fix it here to avoid returning EINVAL
* in response to values we used to accept.
*/
pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
d->Reserved1 = 1;
}
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
return -EINVAL;
Expand Down
10 changes: 10 additions & 0 deletions drivers/usb/gadget/legacy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
# both kinds of controller can also support "USB On-the-Go" (CONFIG_USB_OTG).
#

menuconfig USB_GADGET_LEGACY
bool "Legacy USB Gadget Support"
help
Legacy USB gadgets are USB gadgets that do not use the USB gadget
configfs interface.

if USB_GADGET_LEGACY

config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE
Expand Down Expand Up @@ -490,3 +498,5 @@ config USB_G_WEBCAM

Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "g_webcam".

endif
1 change: 0 additions & 1 deletion drivers/usb/gadget/udc/bdc/bdc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ static const struct of_device_id bdc_of_match[] = {
static struct platform_driver bdc_driver = {
.driver = {
.name = BRCM_BDC_NAME,
.owner = THIS_MODULE,
.pm = &bdc_pm_ops,
.of_match_table = bdc_of_match,
},
Expand Down
8 changes: 6 additions & 2 deletions drivers/usb/gadget/udc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,12 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
static inline void usb_gadget_udc_set_speed(struct usb_udc *udc,
enum usb_device_speed speed)
{
if (udc->gadget->ops->udc_set_speed)
udc->gadget->ops->udc_set_speed(udc->gadget, speed);
if (udc->gadget->ops->udc_set_speed) {
enum usb_device_speed s;

s = min(speed, udc->gadget->max_speed);
udc->gadget->ops->udc_set_speed(udc->gadget, s);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/udc/renesas_usb3.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
#define USB3_EP0_SS_MAX_PACKET_SIZE 512
#define USB3_EP0_HSFS_MAX_PACKET_SIZE 64
#define USB3_EP0_BUF_SIZE 8
#define USB3_MAX_NUM_PIPES 30
#define USB3_MAX_NUM_PIPES 6 /* This includes PIPE 0 */
#define USB3_WAIT_US 3
#define USB3_DMA_NUM_SETTING_AREA 4
/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
default: /* unknown */
break;
}
temp = (cap >> 8) & 0xff;
offset = (cap >> 8) & 0xff;
}
}
#endif
Expand Down
7 changes: 7 additions & 0 deletions drivers/usb/host/xhci-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,12 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
if (!vdev)
return;

if (vdev->real_port == 0 ||
vdev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) {
xhci_dbg(xhci, "Bad vdev->real_port.\n");
goto out;
}

tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
/* is this a hub device that added a tt_info to the tts list */
Expand All @@ -947,6 +953,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_id)
}
}
}
out:
/* we are now at a leaf device */
xhci_debugfs_remove_slot(xhci, slot_id);
xhci_free_virt_device(xhci, slot_id);
Expand Down
12 changes: 8 additions & 4 deletions drivers/usb/host/xhci-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2477,12 +2477,16 @@ static int handle_tx_event(struct xhci_hcd *xhci,
*/
if (list_empty(&ep_ring->td_list)) {
/*
* A stopped endpoint may generate an extra completion
* event if the device was suspended. Don't print
* warnings.
* Don't print wanings if it's due to a stopped endpoint
* generating an extra completion event if the device
* was suspended. Or, a event for the last TRB of a
* short TD we already got a short event for.
* The short TD is already removed from the TD list.
*/

if (!(trb_comp_code == COMP_STOPPED ||
trb_comp_code == COMP_STOPPED_LENGTH_INVALID)) {
trb_comp_code == COMP_STOPPED_LENGTH_INVALID ||
ep_ring->last_td_was_short)) {
xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n",
TRB_TO_SLOT_ID(le32_to_cpu(event->flags)),
ep_index);
Expand Down
3 changes: 3 additions & 0 deletions drivers/usb/serial/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ static void option_instat_callback(struct urb *urb);
/* These Quectel products use Quectel's vendor ID */
#define QUECTEL_PRODUCT_EC21 0x0121
#define QUECTEL_PRODUCT_EC25 0x0125
#define QUECTEL_PRODUCT_BG96 0x0296

#define CMOTECH_VENDOR_ID 0x16d8
#define CMOTECH_PRODUCT_6001 0x6001
Expand Down Expand Up @@ -1182,6 +1183,8 @@ static const struct usb_device_id option_ids[] = {
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/serial/usb_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ static const struct usb_device_id id_table[] = {
};

static const struct usb_device_id dbc_id_table[] = {
{ USB_DEVICE(0x1d6b, 0x0010) },
{ USB_DEVICE(0x1d6b, 0x0011) },
{ },
};

static const struct usb_device_id id_table_combined[] = {
{ USB_DEVICE(0x0525, 0x127a) },
{ USB_DEVICE(0x1d6b, 0x0010) },
{ USB_DEVICE(0x1d6b, 0x0011) },
{ },
};
Expand Down
4 changes: 4 additions & 0 deletions drivers/usb/storage/uas-detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ static int uas_use_uas_driver(struct usb_interface *intf,
}
}

/* All Seagate disk enclosures have broken ATA pass-through support */
if (le16_to_cpu(udev->descriptor.idVendor) == 0x0bc2)
flags |= US_FL_NO_ATA_1X;

usb_stor_adjust_quirks(udev, &flags);

if (flags & US_FL_IGNORE_UAS) {
Expand Down
Loading

0 comments on commit 6b0b3bd

Please sign in to comment.