Skip to content

Commit ffb927d

Browse files
committed
Merge tag 'usb-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some USB fixes and new device ids for 4.6-rc3. Nothing major, the normal USB gadget fixes and usb-serial driver ids, along with some other fixes mixed in. All except the USB serial ids have been tested in linux-next, the id additions should be fine as they are 'trivial'" * tag 'usb-4.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits) USB: option: add "D-Link DWM-221 B1" device id USB: serial: cp210x: Adding GE Healthcare Device ID USB: serial: ftdi_sio: Add support for ICP DAS I-756xU devices usb: dwc3: keystone: drop dma_mask configuration usb: gadget: udc-core: remove manual dma configuration usb: dwc3: pci: add ID for one more Intel Broxton platform usb: renesas_usbhs: fix to avoid using a disabled ep in usbhsg_queue_done() usb: dwc2: do not override forced dr_mode in gadget setup usb: gadget: f_midi: unlock on error USB: digi_acceleport: do sanity checking for the number of ports USB: cypress_m8: add endpoint sanity check USB: mct_u232: add sanity checking in probe usb: fix regression in SuperSpeed endpoint descriptor parsing USB: usbip: fix potential out-of-bounds write usb: renesas_usbhs: disable TX IRQ before starting TX DMAC transfer usb: renesas_usbhs: avoid NULL pointer derefernce in usbhsf_pkt_handler() usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize usb: phy: qcom-8x16: fix regulator API abuse usb: ch9: Fix SSP Device Cap wFunctionalitySupport type usb: gadget: composite: Access SSP Dev Cap fields properly ...
2 parents c6e6e58 + 636c8a8 commit ffb927d

File tree

22 files changed

+151
-148
lines changed

22 files changed

+151
-148
lines changed

drivers/usb/core/config.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
7575
* be the first thing immediately following the endpoint descriptor.
7676
*/
7777
desc = (struct usb_ss_ep_comp_descriptor *) buffer;
78-
buffer += desc->bLength;
79-
size -= desc->bLength;
8078

8179
if (desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP ||
8280
size < USB_DT_SS_EP_COMP_SIZE) {
@@ -100,7 +98,8 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
10098
ep->desc.wMaxPacketSize;
10199
return;
102100
}
103-
101+
buffer += desc->bLength;
102+
size -= desc->bLength;
104103
memcpy(&ep->ss_ep_comp, desc, USB_DT_SS_EP_COMP_SIZE);
105104

106105
/* Check the various values */
@@ -146,12 +145,6 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
146145
ep->ss_ep_comp.bmAttributes = 2;
147146
}
148147

149-
/* Parse a possible SuperSpeedPlus isoc ep companion descriptor */
150-
if (usb_endpoint_xfer_isoc(&ep->desc) &&
151-
USB_SS_SSP_ISOC_COMP(desc->bmAttributes))
152-
usb_parse_ssp_isoc_endpoint_companion(ddev, cfgno, inum, asnum,
153-
ep, buffer, size);
154-
155148
if (usb_endpoint_xfer_isoc(&ep->desc))
156149
max_tx = (desc->bMaxBurst + 1) *
157150
(USB_SS_MULT(desc->bmAttributes)) *
@@ -171,6 +164,11 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
171164
max_tx);
172165
ep->ss_ep_comp.wBytesPerInterval = cpu_to_le16(max_tx);
173166
}
167+
/* Parse a possible SuperSpeedPlus isoc ep companion descriptor */
168+
if (usb_endpoint_xfer_isoc(&ep->desc) &&
169+
USB_SS_SSP_ISOC_COMP(desc->bmAttributes))
170+
usb_parse_ssp_isoc_endpoint_companion(ddev, cfgno, inum, asnum,
171+
ep, buffer, size);
174172
}
175173

176174
static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,

drivers/usb/dwc2/gadget.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
22542254
{
22552255
u32 intmsk;
22562256
u32 val;
2257+
u32 usbcfg;
22572258

22582259
/* Kill any ep0 requests as controller will be reinitialized */
22592260
kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
@@ -2267,10 +2268,16 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
22672268
* set configuration.
22682269
*/
22692270

2271+
/* keep other bits untouched (so e.g. forced modes are not lost) */
2272+
usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
2273+
usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
2274+
GUSBCFG_HNPCAP);
2275+
22702276
/* set the PLL on, remove the HNP/SRP and set the PHY */
22712277
val = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5;
2272-
dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) |
2273-
(val << GUSBCFG_USBTRDTIM_SHIFT), hsotg->regs + GUSBCFG);
2278+
usbcfg |= hsotg->phyif | GUSBCFG_TOUTCAL(7) |
2279+
(val << GUSBCFG_USBTRDTIM_SHIFT);
2280+
dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
22742281

22752282
dwc2_hsotg_init_fifo(hsotg);
22762283

@@ -3031,6 +3038,7 @@ static struct usb_ep_ops dwc2_hsotg_ep_ops = {
30313038
static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg)
30323039
{
30333040
u32 trdtim;
3041+
u32 usbcfg;
30343042
/* unmask subset of endpoint interrupts */
30353043

30363044
dwc2_writel(DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK |
@@ -3054,11 +3062,16 @@ static void dwc2_hsotg_init(struct dwc2_hsotg *hsotg)
30543062

30553063
dwc2_hsotg_init_fifo(hsotg);
30563064

3065+
/* keep other bits untouched (so e.g. forced modes are not lost) */
3066+
usbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
3067+
usbcfg &= ~(GUSBCFG_TOUTCAL_MASK | GUSBCFG_PHYIF16 | GUSBCFG_SRPCAP |
3068+
GUSBCFG_HNPCAP);
3069+
30573070
/* set the PLL on, remove the HNP/SRP and set the PHY */
30583071
trdtim = (hsotg->phyif == GUSBCFG_PHYIF8) ? 9 : 5;
3059-
dwc2_writel(hsotg->phyif | GUSBCFG_TOUTCAL(7) |
3060-
(trdtim << GUSBCFG_USBTRDTIM_SHIFT),
3061-
hsotg->regs + GUSBCFG);
3072+
usbcfg |= hsotg->phyif | GUSBCFG_TOUTCAL(7) |
3073+
(trdtim << GUSBCFG_USBTRDTIM_SHIFT);
3074+
dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
30623075

30633076
if (using_dma(hsotg))
30643077
__orr32(hsotg->regs + GAHBCFG, GAHBCFG_DMA_EN);

drivers/usb/dwc3/core.c

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,9 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
6767
static int dwc3_core_soft_reset(struct dwc3 *dwc)
6868
{
6969
u32 reg;
70+
int retries = 1000;
7071
int ret;
7172

72-
/* Before Resetting PHY, put Core in Reset */
73-
reg = dwc3_readl(dwc->regs, DWC3_GCTL);
74-
reg |= DWC3_GCTL_CORESOFTRESET;
75-
dwc3_writel(dwc->regs, DWC3_GCTL, reg);
76-
77-
/* Assert USB3 PHY reset */
78-
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
79-
reg |= DWC3_GUSB3PIPECTL_PHYSOFTRST;
80-
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
81-
82-
/* Assert USB2 PHY reset */
83-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
84-
reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST;
85-
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
86-
8773
usb_phy_init(dwc->usb2_phy);
8874
usb_phy_init(dwc->usb3_phy);
8975
ret = phy_init(dwc->usb2_generic_phy);
@@ -95,26 +81,28 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
9581
phy_exit(dwc->usb2_generic_phy);
9682
return ret;
9783
}
98-
mdelay(100);
9984

100-
/* Clear USB3 PHY reset */
101-
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
102-
reg &= ~DWC3_GUSB3PIPECTL_PHYSOFTRST;
103-
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
85+
/*
86+
* We're resetting only the device side because, if we're in host mode,
87+
* XHCI driver will reset the host block. If dwc3 was configured for
88+
* host-only mode, then we can return early.
89+
*/
90+
if (dwc->dr_mode == USB_DR_MODE_HOST)
91+
return 0;
10492

105-
/* Clear USB2 PHY reset */
106-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
107-
reg &= ~DWC3_GUSB2PHYCFG_PHYSOFTRST;
108-
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
93+
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
94+
reg |= DWC3_DCTL_CSFTRST;
95+
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
10996

110-
mdelay(100);
97+
do {
98+
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
99+
if (!(reg & DWC3_DCTL_CSFTRST))
100+
return 0;
111101

112-
/* After PHYs are stable we can take Core out of reset state */
113-
reg = dwc3_readl(dwc->regs, DWC3_GCTL);
114-
reg &= ~DWC3_GCTL_CORESOFTRESET;
115-
dwc3_writel(dwc->regs, DWC3_GCTL, reg);
102+
udelay(1);
103+
} while (--retries);
116104

117-
return 0;
105+
return -ETIMEDOUT;
118106
}
119107

120108
/**

drivers/usb/dwc3/dwc3-keystone.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#define USBSS_IRQ_COREIRQ_EN BIT(0)
4040
#define USBSS_IRQ_COREIRQ_CLR BIT(0)
4141

42-
static u64 kdwc3_dma_mask;
43-
4442
struct dwc3_keystone {
4543
struct device *dev;
4644
struct clk *clk;
@@ -108,9 +106,6 @@ static int kdwc3_probe(struct platform_device *pdev)
108106
if (IS_ERR(kdwc->usbss))
109107
return PTR_ERR(kdwc->usbss);
110108

111-
kdwc3_dma_mask = dma_get_mask(dev);
112-
dev->dma_mask = &kdwc3_dma_mask;
113-
114109
kdwc->clk = devm_clk_get(kdwc->dev, "usb");
115110

116111
error = clk_prepare_enable(kdwc->clk);

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30
3636
#define PCI_DEVICE_ID_INTEL_SPTH 0xa130
3737
#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
38+
#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
3839
#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
3940

4041
static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
@@ -213,6 +214,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
213214
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTLP), },
214215
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTH), },
215216
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
217+
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
216218
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
217219
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
218220
{ } /* Terminating Entry */

drivers/usb/dwc3/gadget.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
568568
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
569569

570570
if (!usb_endpoint_xfer_isoc(desc))
571-
return 0;
571+
goto out;
572572

573573
/* Link TRB for ISOC. The HWO bit is never reset */
574574
trb_st_hw = &dep->trb_pool[0];
@@ -582,9 +582,10 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
582582
trb_link->ctrl |= DWC3_TRB_CTRL_HWO;
583583
}
584584

585+
out:
585586
switch (usb_endpoint_type(desc)) {
586587
case USB_ENDPOINT_XFER_CONTROL:
587-
strlcat(dep->name, "-control", sizeof(dep->name));
588+
/* don't change name */
588589
break;
589590
case USB_ENDPOINT_XFER_ISOC:
590591
strlcat(dep->name, "-isoc", sizeof(dep->name));
@@ -2487,7 +2488,11 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc)
24872488
* implemented.
24882489
*/
24892490

2490-
dwc->gadget_driver->resume(&dwc->gadget);
2491+
if (dwc->gadget_driver && dwc->gadget_driver->resume) {
2492+
spin_unlock(&dwc->lock);
2493+
dwc->gadget_driver->resume(&dwc->gadget);
2494+
spin_lock(&dwc->lock);
2495+
}
24912496
}
24922497

24932498
static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,

drivers/usb/gadget/composite.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,8 @@ static int bos_desc(struct usb_composite_dev *cdev)
656656
ssp_cap->bmAttributes = cpu_to_le32(1);
657657

658658
/* Min RX/TX Lane Count = 1 */
659-
ssp_cap->wFunctionalitySupport = (1 << 8) | (1 << 12);
659+
ssp_cap->wFunctionalitySupport =
660+
cpu_to_le16((1 << 8) | (1 << 12));
660661

661662
/*
662663
* bmSublinkSpeedAttr[0]:
@@ -666,7 +667,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
666667
* LSM = 10 (10 Gbps)
667668
*/
668669
ssp_cap->bmSublinkSpeedAttr[0] =
669-
(3 << 4) | (1 << 14) | (0xa << 16);
670+
cpu_to_le32((3 << 4) | (1 << 14) | (0xa << 16));
670671
/*
671672
* bmSublinkSpeedAttr[1] =
672673
* ST = Symmetric, TX
@@ -675,7 +676,8 @@ static int bos_desc(struct usb_composite_dev *cdev)
675676
* LSM = 10 (10 Gbps)
676677
*/
677678
ssp_cap->bmSublinkSpeedAttr[1] =
678-
(3 << 4) | (1 << 14) | (0xa << 16) | (1 << 7);
679+
cpu_to_le32((3 << 4) | (1 << 14) |
680+
(0xa << 16) | (1 << 7));
679681
}
680682

681683
return le16_to_cpu(bos->wTotalLength);

drivers/usb/gadget/function/f_midi.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/slab.h>
2525
#include <linux/device.h>
2626
#include <linux/kfifo.h>
27+
#include <linux/spinlock.h>
2728

2829
#include <sound/core.h>
2930
#include <sound/initval.h>
@@ -89,6 +90,7 @@ struct f_midi {
8990
unsigned int buflen, qlen;
9091
/* This fifo is used as a buffer ring for pre-allocated IN usb_requests */
9192
DECLARE_KFIFO_PTR(in_req_fifo, struct usb_request *);
93+
spinlock_t transmit_lock;
9294
unsigned int in_last_port;
9395

9496
struct gmidi_in_port in_ports_array[/* in_ports */];
@@ -358,7 +360,9 @@ static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
358360
/* allocate a bunch of read buffers and queue them all at once. */
359361
for (i = 0; i < midi->qlen && err == 0; i++) {
360362
struct usb_request *req =
361-
midi_alloc_ep_req(midi->out_ep, midi->buflen);
363+
midi_alloc_ep_req(midi->out_ep,
364+
max_t(unsigned, midi->buflen,
365+
bulk_out_desc.wMaxPacketSize));
362366
if (req == NULL)
363367
return -ENOMEM;
364368

@@ -597,17 +601,24 @@ static void f_midi_transmit(struct f_midi *midi)
597601
{
598602
struct usb_ep *ep = midi->in_ep;
599603
int ret;
604+
unsigned long flags;
600605

601606
/* We only care about USB requests if IN endpoint is enabled */
602607
if (!ep || !ep->enabled)
603608
goto drop_out;
604609

610+
spin_lock_irqsave(&midi->transmit_lock, flags);
611+
605612
do {
606613
ret = f_midi_do_transmit(midi, ep);
607-
if (ret < 0)
614+
if (ret < 0) {
615+
spin_unlock_irqrestore(&midi->transmit_lock, flags);
608616
goto drop_out;
617+
}
609618
} while (ret);
610619

620+
spin_unlock_irqrestore(&midi->transmit_lock, flags);
621+
611622
return;
612623

613624
drop_out:
@@ -1201,6 +1212,8 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
12011212
if (status)
12021213
goto setup_fail;
12031214

1215+
spin_lock_init(&midi->transmit_lock);
1216+
12041217
++opts->refcnt;
12051218
mutex_unlock(&opts->lock);
12061219

drivers/usb/gadget/udc/atmel_usba_udc.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,20 +1045,6 @@ static void reset_all_endpoints(struct usba_udc *udc)
10451045
list_del_init(&req->queue);
10461046
request_complete(ep, req, -ECONNRESET);
10471047
}
1048-
1049-
/* NOTE: normally, the next call to the gadget driver is in
1050-
* charge of disabling endpoints... usually disconnect().
1051-
* The exception would be entering a high speed test mode.
1052-
*
1053-
* FIXME remove this code ... and retest thoroughly.
1054-
*/
1055-
list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
1056-
if (ep->ep.desc) {
1057-
spin_unlock(&udc->lock);
1058-
usba_ep_disable(&ep->ep);
1059-
spin_lock(&udc->lock);
1060-
}
1061-
}
10621048
}
10631049

10641050
static struct usba_ep *get_ep_by_addr(struct usba_udc *udc, u16 wIndex)

drivers/usb/gadget/udc/udc-core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
371371
INIT_WORK(&gadget->work, usb_gadget_state_work);
372372
gadget->dev.parent = parent;
373373

374-
#ifdef CONFIG_HAS_DMA
375-
dma_set_coherent_mask(&gadget->dev, parent->coherent_dma_mask);
376-
gadget->dev.dma_parms = parent->dma_parms;
377-
gadget->dev.dma_mask = parent->dma_mask;
378-
#endif
379-
380374
if (release)
381375
gadget->dev.release = release;
382376
else

0 commit comments

Comments
 (0)