aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-25 11:54:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-25 11:54:55 -0400
commitbfb0e9b490bc15f243009359745a9d8a94089dc4 (patch)
treea567b0b71bc383102363a796dd07851c71852555
parentccf791e5e6b16477b196e81b85f7d5a067e0c8d9 (diff)
parent3e3b81965cbfa01fda6d77750feedc3c46fc28d0 (diff)
Merge tag 'usb-4.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
I wrote: "USB fixes for 4.19-rc6 Here are some small USB core and driver fixes for reported issues for 4.19-rc6. The most visible is the oops fix for when the USB core is built into the kernel that is present in 4.18. Turns out not many people actually do that so it went unnoticed for a while. The rest is some tiny typec, musb, and other core fixes. All have been in linux-next with no reported issues." * tag 'usb-4.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: typec: mux: Take care of driver module reference counting usb: core: safely deal with the dynamic quirk lists usb: roles: Take care of driver module reference counting USB: handle NULL config in usb_find_alt_setting() USB: fix error handling in usb_driver_claim_interface() USB: remove LPM management from usb_driver_claim_interface() USB: usbdevfs: restore warning for nonsensical flags USB: usbdevfs: sanitize flags more Revert "usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()" usb: musb: dsps: do not disable CPPI41 irq in driver teardown
-rw-r--r--drivers/usb/class/cdc-wdm.c2
-rw-r--r--drivers/usb/common/roles.c15
-rw-r--r--drivers/usb/core/devio.c24
-rw-r--r--drivers/usb/core/driver.c28
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/core/usb.c2
-rw-r--r--drivers/usb/musb/musb_dsps.c12
-rw-r--r--drivers/usb/typec/mux.c17
8 files changed, 66 insertions, 37 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 656d247819c9..bec581fb7c63 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -460,7 +460,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
460 460
461 set_bit(WDM_RESPONDING, &desc->flags); 461 set_bit(WDM_RESPONDING, &desc->flags);
462 spin_unlock_irq(&desc->iuspin); 462 spin_unlock_irq(&desc->iuspin);
463 rv = usb_submit_urb(desc->response, GFP_ATOMIC); 463 rv = usb_submit_urb(desc->response, GFP_KERNEL);
464 spin_lock_irq(&desc->iuspin); 464 spin_lock_irq(&desc->iuspin);
465 if (rv) { 465 if (rv) {
466 dev_err(&desc->intf->dev, 466 dev_err(&desc->intf->dev,
diff --git a/drivers/usb/common/roles.c b/drivers/usb/common/roles.c
index 15cc76e22123..99116af07f1d 100644
--- a/drivers/usb/common/roles.c
+++ b/drivers/usb/common/roles.c
@@ -109,8 +109,15 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
109 */ 109 */
110struct usb_role_switch *usb_role_switch_get(struct device *dev) 110struct usb_role_switch *usb_role_switch_get(struct device *dev)
111{ 111{
112 return device_connection_find_match(dev, "usb-role-switch", NULL, 112 struct usb_role_switch *sw;
113 usb_role_switch_match); 113
114 sw = device_connection_find_match(dev, "usb-role-switch", NULL,
115 usb_role_switch_match);
116
117 if (!IS_ERR_OR_NULL(sw))
118 WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
119
120 return sw;
114} 121}
115EXPORT_SYMBOL_GPL(usb_role_switch_get); 122EXPORT_SYMBOL_GPL(usb_role_switch_get);
116 123
@@ -122,8 +129,10 @@ EXPORT_SYMBOL_GPL(usb_role_switch_get);
122 */ 129 */
123void usb_role_switch_put(struct usb_role_switch *sw) 130void usb_role_switch_put(struct usb_role_switch *sw)
124{ 131{
125 if (!IS_ERR_OR_NULL(sw)) 132 if (!IS_ERR_OR_NULL(sw)) {
126 put_device(&sw->dev); 133 put_device(&sw->dev);
134 module_put(sw->dev.parent->driver->owner);
135 }
127} 136}
128EXPORT_SYMBOL_GPL(usb_role_switch_put); 137EXPORT_SYMBOL_GPL(usb_role_switch_put);
129 138
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 6ce77b33da61..244417d0dfd1 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1434,10 +1434,13 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1434 struct async *as = NULL; 1434 struct async *as = NULL;
1435 struct usb_ctrlrequest *dr = NULL; 1435 struct usb_ctrlrequest *dr = NULL;
1436 unsigned int u, totlen, isofrmlen; 1436 unsigned int u, totlen, isofrmlen;
1437 int i, ret, is_in, num_sgs = 0, ifnum = -1; 1437 int i, ret, num_sgs = 0, ifnum = -1;
1438 int number_of_packets = 0; 1438 int number_of_packets = 0;
1439 unsigned int stream_id = 0; 1439 unsigned int stream_id = 0;
1440 void *buf; 1440 void *buf;
1441 bool is_in;
1442 bool allow_short = false;
1443 bool allow_zero = false;
1441 unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK | 1444 unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK |
1442 USBDEVFS_URB_BULK_CONTINUATION | 1445 USBDEVFS_URB_BULK_CONTINUATION |
1443 USBDEVFS_URB_NO_FSBR | 1446 USBDEVFS_URB_NO_FSBR |
@@ -1471,6 +1474,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1471 u = 0; 1474 u = 0;
1472 switch (uurb->type) { 1475 switch (uurb->type) {
1473 case USBDEVFS_URB_TYPE_CONTROL: 1476 case USBDEVFS_URB_TYPE_CONTROL:
1477 if (is_in)
1478 allow_short = true;
1474 if (!usb_endpoint_xfer_control(&ep->desc)) 1479 if (!usb_endpoint_xfer_control(&ep->desc))
1475 return -EINVAL; 1480 return -EINVAL;
1476 /* min 8 byte setup packet */ 1481 /* min 8 byte setup packet */
@@ -1511,6 +1516,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1511 break; 1516 break;
1512 1517
1513 case USBDEVFS_URB_TYPE_BULK: 1518 case USBDEVFS_URB_TYPE_BULK:
1519 if (!is_in)
1520 allow_zero = true;
1521 else
1522 allow_short = true;
1514 switch (usb_endpoint_type(&ep->desc)) { 1523 switch (usb_endpoint_type(&ep->desc)) {
1515 case USB_ENDPOINT_XFER_CONTROL: 1524 case USB_ENDPOINT_XFER_CONTROL:
1516 case USB_ENDPOINT_XFER_ISOC: 1525 case USB_ENDPOINT_XFER_ISOC:
@@ -1531,6 +1540,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1531 if (!usb_endpoint_xfer_int(&ep->desc)) 1540 if (!usb_endpoint_xfer_int(&ep->desc))
1532 return -EINVAL; 1541 return -EINVAL;
1533 interrupt_urb: 1542 interrupt_urb:
1543 if (!is_in)
1544 allow_zero = true;
1545 else
1546 allow_short = true;
1534 break; 1547 break;
1535 1548
1536 case USBDEVFS_URB_TYPE_ISO: 1549 case USBDEVFS_URB_TYPE_ISO:
@@ -1676,14 +1689,19 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1676 u = (is_in ? URB_DIR_IN : URB_DIR_OUT); 1689 u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
1677 if (uurb->flags & USBDEVFS_URB_ISO_ASAP) 1690 if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
1678 u |= URB_ISO_ASAP; 1691 u |= URB_ISO_ASAP;
1679 if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK && is_in) 1692 if (allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
1680 u |= URB_SHORT_NOT_OK; 1693 u |= URB_SHORT_NOT_OK;
1681 if (uurb->flags & USBDEVFS_URB_ZERO_PACKET) 1694 if (allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
1682 u |= URB_ZERO_PACKET; 1695 u |= URB_ZERO_PACKET;
1683 if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT) 1696 if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT)
1684 u |= URB_NO_INTERRUPT; 1697 u |= URB_NO_INTERRUPT;
1685 as->urb->transfer_flags = u; 1698 as->urb->transfer_flags = u;
1686 1699
1700 if (!allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
1701 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n");
1702 if (!allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
1703 dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n");
1704
1687 as->urb->transfer_buffer_length = uurb->buffer_length; 1705 as->urb->transfer_buffer_length = uurb->buffer_length;
1688 as->urb->setup_packet = (unsigned char *)dr; 1706 as->urb->setup_packet = (unsigned char *)dr;
1689 dr = NULL; 1707 dr = NULL;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index e76e95f62f76..a1f225f077cd 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -512,7 +512,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
512 struct device *dev; 512 struct device *dev;
513 struct usb_device *udev; 513 struct usb_device *udev;
514 int retval = 0; 514 int retval = 0;
515 int lpm_disable_error = -ENODEV;
516 515
517 if (!iface) 516 if (!iface)
518 return -ENODEV; 517 return -ENODEV;
@@ -533,16 +532,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
533 532
534 iface->condition = USB_INTERFACE_BOUND; 533 iface->condition = USB_INTERFACE_BOUND;
535 534
536 /* See the comment about disabling LPM in usb_probe_interface(). */
537 if (driver->disable_hub_initiated_lpm) {
538 lpm_disable_error = usb_unlocked_disable_lpm(udev);
539 if (lpm_disable_error) {
540 dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n",
541 __func__, driver->name);
542 return -ENOMEM;
543 }
544 }
545
546 /* Claimed interfaces are initially inactive (suspended) and 535 /* Claimed interfaces are initially inactive (suspended) and
547 * runtime-PM-enabled, but only if the driver has autosuspend 536 * runtime-PM-enabled, but only if the driver has autosuspend
548 * support. Otherwise they are marked active, to prevent the 537 * support. Otherwise they are marked active, to prevent the
@@ -561,9 +550,20 @@ int usb_driver_claim_interface(struct usb_driver *driver,
561 if (device_is_registered(dev)) 550 if (device_is_registered(dev))
562 retval = device_bind_driver(dev); 551 retval = device_bind_driver(dev);
563 552
564 /* Attempt to re-enable USB3 LPM, if the disable was successful. */ 553 if (retval) {
565 if (!lpm_disable_error) 554 dev->driver = NULL;
566 usb_unlocked_enable_lpm(udev); 555 usb_set_intfdata(iface, NULL);
556 iface->needs_remote_wakeup = 0;
557 iface->condition = USB_INTERFACE_UNBOUND;
558
559 /*
560 * Unbound interfaces are always runtime-PM-disabled
561 * and runtime-PM-suspended
562 */
563 if (driver->supports_autosuspend)
564 pm_runtime_disable(dev);
565 pm_runtime_set_suspended(dev);
566 }
567 567
568 return retval; 568 return retval;
569} 569}
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index e77dfe5ed5ec..178d6c6063c0 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -58,6 +58,7 @@ static int quirks_param_set(const char *val, const struct kernel_param *kp)
58 quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry), 58 quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
59 GFP_KERNEL); 59 GFP_KERNEL);
60 if (!quirk_list) { 60 if (!quirk_list) {
61 quirk_count = 0;
61 mutex_unlock(&quirk_mutex); 62 mutex_unlock(&quirk_mutex);
62 return -ENOMEM; 63 return -ENOMEM;
63 } 64 }
@@ -154,7 +155,7 @@ static struct kparam_string quirks_param_string = {
154 .string = quirks_param, 155 .string = quirks_param,
155}; 156};
156 157
157module_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644); 158device_param_cb(quirks, &quirks_param_ops, &quirks_param_string, 0644);
158MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks"); 159MODULE_PARM_DESC(quirks, "Add/modify USB quirks by specifying quirks=vendorID:productID:quirks");
159 160
160/* Lists of quirky USB devices, split in device quirks and interface quirks. 161/* Lists of quirky USB devices, split in device quirks and interface quirks.
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 623be3174fb3..79d8bd7a612e 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -228,6 +228,8 @@ struct usb_host_interface *usb_find_alt_setting(
228 struct usb_interface_cache *intf_cache = NULL; 228 struct usb_interface_cache *intf_cache = NULL;
229 int i; 229 int i;
230 230
231 if (!config)
232 return NULL;
231 for (i = 0; i < config->desc.bNumInterfaces; i++) { 233 for (i = 0; i < config->desc.bNumInterfaces; i++) {
232 if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber 234 if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber
233 == iface_num) { 235 == iface_num) {
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index df827ff57b0d..23a0df79ef21 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -658,16 +658,6 @@ dsps_dma_controller_create(struct musb *musb, void __iomem *base)
658 return controller; 658 return controller;
659} 659}
660 660
661static void dsps_dma_controller_destroy(struct dma_controller *c)
662{
663 struct musb *musb = c->musb;
664 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
665 void __iomem *usbss_base = glue->usbss_base;
666
667 musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP);
668 cppi41_dma_controller_destroy(c);
669}
670
671#ifdef CONFIG_PM_SLEEP 661#ifdef CONFIG_PM_SLEEP
672static void dsps_dma_controller_suspend(struct dsps_glue *glue) 662static void dsps_dma_controller_suspend(struct dsps_glue *glue)
673{ 663{
@@ -697,7 +687,7 @@ static struct musb_platform_ops dsps_ops = {
697 687
698#ifdef CONFIG_USB_TI_CPPI41_DMA 688#ifdef CONFIG_USB_TI_CPPI41_DMA
699 .dma_init = dsps_dma_controller_create, 689 .dma_init = dsps_dma_controller_create,
700 .dma_exit = dsps_dma_controller_destroy, 690 .dma_exit = cppi41_dma_controller_destroy,
701#endif 691#endif
702 .enable = dsps_musb_enable, 692 .enable = dsps_musb_enable,
703 .disable = dsps_musb_disable, 693 .disable = dsps_musb_disable,
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index ddaac63ecf12..d990aa510fab 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h>
12#include <linux/mutex.h> 13#include <linux/mutex.h>
13#include <linux/usb/typec_mux.h> 14#include <linux/usb/typec_mux.h>
14 15
@@ -49,8 +50,10 @@ struct typec_switch *typec_switch_get(struct device *dev)
49 mutex_lock(&switch_lock); 50 mutex_lock(&switch_lock);
50 sw = device_connection_find_match(dev, "typec-switch", NULL, 51 sw = device_connection_find_match(dev, "typec-switch", NULL,
51 typec_switch_match); 52 typec_switch_match);
52 if (!IS_ERR_OR_NULL(sw)) 53 if (!IS_ERR_OR_NULL(sw)) {
54 WARN_ON(!try_module_get(sw->dev->driver->owner));
53 get_device(sw->dev); 55 get_device(sw->dev);
56 }
54 mutex_unlock(&switch_lock); 57 mutex_unlock(&switch_lock);
55 58
56 return sw; 59 return sw;
@@ -65,8 +68,10 @@ EXPORT_SYMBOL_GPL(typec_switch_get);
65 */ 68 */
66void typec_switch_put(struct typec_switch *sw) 69void typec_switch_put(struct typec_switch *sw)
67{ 70{
68 if (!IS_ERR_OR_NULL(sw)) 71 if (!IS_ERR_OR_NULL(sw)) {
72 module_put(sw->dev->driver->owner);
69 put_device(sw->dev); 73 put_device(sw->dev);
74 }
70} 75}
71EXPORT_SYMBOL_GPL(typec_switch_put); 76EXPORT_SYMBOL_GPL(typec_switch_put);
72 77
@@ -136,8 +141,10 @@ struct typec_mux *typec_mux_get(struct device *dev, const char *name)
136 141
137 mutex_lock(&mux_lock); 142 mutex_lock(&mux_lock);
138 mux = device_connection_find_match(dev, name, NULL, typec_mux_match); 143 mux = device_connection_find_match(dev, name, NULL, typec_mux_match);
139 if (!IS_ERR_OR_NULL(mux)) 144 if (!IS_ERR_OR_NULL(mux)) {
145 WARN_ON(!try_module_get(mux->dev->driver->owner));
140 get_device(mux->dev); 146 get_device(mux->dev);
147 }
141 mutex_unlock(&mux_lock); 148 mutex_unlock(&mux_lock);
142 149
143 return mux; 150 return mux;
@@ -152,8 +159,10 @@ EXPORT_SYMBOL_GPL(typec_mux_get);
152 */ 159 */
153void typec_mux_put(struct typec_mux *mux) 160void typec_mux_put(struct typec_mux *mux)
154{ 161{
155 if (!IS_ERR_OR_NULL(mux)) 162 if (!IS_ERR_OR_NULL(mux)) {
163 module_put(mux->dev->driver->owner);
156 put_device(mux->dev); 164 put_device(mux->dev);
165 }
157} 166}
158EXPORT_SYMBOL_GPL(typec_mux_put); 167EXPORT_SYMBOL_GPL(typec_mux_put);
159 168