Skip to content

Commit cd3f77d

Browse files
committed
Merge tag 'usb-4.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a number of USB fixes and new device ids for 4.18-rc7. The largest number are a bunch of gadget driver fixes that got delayed in being submitted earlier due to vacation schedules, but nothing really huge is present in them. There are some new device ids and some PHY driver fixes that were connected to some USB ones. Full details are in the shortlog. All have been in linux-next for a while with no reported issues" * tag 'usb-4.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (28 commits) usb: core: handle hub C_PORT_OVER_CURRENT condition usb: xhci: Fix memory leak in xhci_endpoint_reset() usb: typec: tcpm: Fix sink PDO starting index for PPS APDO selection usb: gadget: f_fs: Only return delayed status when len is 0 usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3' usb: dwc2: Fix inefficient copy of unaligned buffers usb: dwc2: Fix DMA alignment to start at allocated boundary usb: dwc3: rockchip: Fix PHY documentation links. tools: usb: ffs-test: Fix build on big endian systems usb: gadget: aspeed: Workaround memory ordering issue usb: dwc3: gadget: remove redundant variable maxpacket usb: dwc2: avoid NULL dereferences usb/phy: fix PPC64 build errors in phy-fsl-usb.c usb: dwc2: host: do not delay retries for CONTROL IN transfers usb: gadget: u_audio: protect stream runtime fields with stream spinlock usb: gadget: u_audio: remove cached period bytes value usb: gadget: u_audio: remove caching of stream buffer parameters usb: gadget: u_audio: update hw_ptr in iso_complete after data copied usb: gadget: u_audio: fix pcm/card naming in g_audio_setup() usb: gadget: f_uac2: fix error handling in afunc_bind (again) ...
2 parents fd4f84f + 249a32b commit cd3f77d

File tree

25 files changed

+187
-135
lines changed

25 files changed

+187
-135
lines changed

Documentation/devicetree/bindings/usb/rockchip,dwc3.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ A child node must exist to represent the core DWC3 IP block. The name of
1616
the node is not important. The content of the node is defined in dwc3.txt.
1717

1818
Phy documentation is provided in the following places:
19-
Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
19+
Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt - USB2.0 PHY
20+
Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt - Type-C PHY
2021

2122
Example device nodes:
2223

drivers/phy/broadcom/phy-brcm-usb-init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,10 @@ void brcm_usb_init_xhci(struct brcm_usb_init_params *params)
962962
{
963963
void __iomem *ctrl = params->ctrl_regs;
964964

965+
USB_CTRL_UNSET(ctrl, USB30_PCTL, PHY3_IDDQ_OVERRIDE);
966+
/* 1 millisecond - for USB clocks to settle down */
967+
usleep_range(1000, 2000);
968+
965969
if (BRCM_ID(params->family_id) == 0x7366) {
966970
/*
967971
* The PHY3_SOFT_RESETB bits default to the wrong state.

drivers/phy/motorola/phy-mapphone-mdm6600.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ static void phy_mdm6600_status(struct work_struct *work)
182182
ddata = container_of(work, struct phy_mdm6600, status_work.work);
183183
dev = ddata->dev;
184184

185-
error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES,
185+
error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_STATUS_LINES,
186186
ddata->status_gpios->desc,
187187
values);
188188
if (error)
189189
return;
190190

191-
for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++) {
191+
for (i = 0; i < PHY_MDM6600_NR_STATUS_LINES; i++) {
192192
val |= values[i] << i;
193193
dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n",
194194
__func__, i, values[i], val);

drivers/usb/chipidea/Kconfig

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config USB_CHIPIDEA
33
depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
44
select EXTCON
55
select RESET_CONTROLLER
6+
select USB_ULPI_BUS
67
help
78
Say Y here if your system has a dual role high speed USB
89
controller based on ChipIdea silicon IP. It supports:
@@ -38,12 +39,4 @@ config USB_CHIPIDEA_HOST
3839
help
3940
Say Y here to enable host controller functionality of the
4041
ChipIdea driver.
41-
42-
config USB_CHIPIDEA_ULPI
43-
bool "ChipIdea ULPI PHY support"
44-
depends on USB_ULPI_BUS=y || USB_ULPI_BUS=USB_CHIPIDEA
45-
help
46-
Say Y here if you have a ULPI PHY attached to your ChipIdea
47-
controller.
48-
4942
endif

drivers/usb/chipidea/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o
33

4-
ci_hdrc-y := core.o otg.o debug.o
4+
ci_hdrc-y := core.o otg.o debug.o ulpi.o
55
ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
66
ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o
77
ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o
8-
ci_hdrc-$(CONFIG_USB_CHIPIDEA_ULPI) += ulpi.o
98

109
# Glue/Bridge layers go here
1110

drivers/usb/chipidea/ci.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,8 @@ struct ci_hdrc {
240240

241241
struct ci_hdrc_platform_data *platdata;
242242
int vbus_active;
243-
#ifdef CONFIG_USB_CHIPIDEA_ULPI
244243
struct ulpi *ulpi;
245244
struct ulpi_ops ulpi_ops;
246-
#endif
247245
struct phy *phy;
248246
/* old usb_phy interface */
249247
struct usb_phy *usb_phy;
@@ -426,15 +424,9 @@ static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
426424
#endif
427425
}
428426

429-
#if IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI)
430427
int ci_ulpi_init(struct ci_hdrc *ci);
431428
void ci_ulpi_exit(struct ci_hdrc *ci);
432429
int ci_ulpi_resume(struct ci_hdrc *ci);
433-
#else
434-
static inline int ci_ulpi_init(struct ci_hdrc *ci) { return 0; }
435-
static inline void ci_ulpi_exit(struct ci_hdrc *ci) { }
436-
static inline int ci_ulpi_resume(struct ci_hdrc *ci) { return 0; }
437-
#endif
438430

439431
u32 hw_read_intr_enable(struct ci_hdrc *ci);
440432

drivers/usb/chipidea/ulpi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ int ci_ulpi_resume(struct ci_hdrc *ci)
9595
{
9696
int cnt = 100000;
9797

98+
if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
99+
return 0;
100+
98101
while (cnt-- > 0) {
99102
if (hw_read(ci, OP_ULPI_VIEWPORT, ULPI_SYNC_STATE))
100103
return 0;

drivers/usb/class/cdc-acm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,9 @@ static const struct usb_device_id acm_ids[] = {
18311831
{ USB_DEVICE(0x09d8, 0x0320), /* Elatec GmbH TWN3 */
18321832
.driver_info = NO_UNION_NORMAL, /* has misplaced union descriptor */
18331833
},
1834+
{ USB_DEVICE(0x0ca6, 0xa050), /* Castles VEGA3000 */
1835+
.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1836+
},
18341837

18351838
{ USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
18361839
.driver_info = CLEAR_HALT_CONDITIONS,

drivers/usb/core/hub.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,14 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
11421142

11431143
if (!udev || udev->state == USB_STATE_NOTATTACHED) {
11441144
/* Tell hub_wq to disconnect the device or
1145-
* check for a new connection
1145+
* check for a new connection or over current condition.
1146+
* Based on USB2.0 Spec Section 11.12.5,
1147+
* C_PORT_OVER_CURRENT could be set while
1148+
* PORT_OVER_CURRENT is not. So check for any of them.
11461149
*/
11471150
if (udev || (portstatus & USB_PORT_STAT_CONNECTION) ||
1148-
(portstatus & USB_PORT_STAT_OVERCURRENT))
1151+
(portstatus & USB_PORT_STAT_OVERCURRENT) ||
1152+
(portchange & USB_PORT_STAT_C_OVERCURRENT))
11491153
set_bit(port1, hub->change_bits);
11501154

11511155
} else if (portstatus & USB_PORT_STAT_ENABLE) {

drivers/usb/dwc2/gadget.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,7 @@ static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg)
34303430
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
34313431
hs_ep = hsotg->eps_in[idx];
34323432
/* Proceed only unmasked ISOC EPs */
3433-
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
3433+
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
34343434
continue;
34353435

34363436
epctrl = dwc2_readl(hsotg->regs + DIEPCTL(idx));
@@ -3476,7 +3476,7 @@ static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg)
34763476
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
34773477
hs_ep = hsotg->eps_out[idx];
34783478
/* Proceed only unmasked ISOC EPs */
3479-
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
3479+
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
34803480
continue;
34813481

34823482
epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));
@@ -3650,7 +3650,7 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw)
36503650
for (idx = 1; idx < hsotg->num_of_eps; idx++) {
36513651
hs_ep = hsotg->eps_out[idx];
36523652
/* Proceed only unmasked ISOC EPs */
3653-
if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))
3653+
if ((BIT(idx) & ~daintmsk) || !hs_ep->isochronous)
36543654
continue;
36553655

36563656
epctrl = dwc2_readl(hsotg->regs + DOEPCTL(idx));

drivers/usb/dwc2/hcd.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,57 +2665,65 @@ static int dwc2_alloc_split_dma_aligned_buf(struct dwc2_hsotg *hsotg,
26652665

26662666
#define DWC2_USB_DMA_ALIGN 4
26672667

2668-
struct dma_aligned_buffer {
2669-
void *kmalloc_ptr;
2670-
void *old_xfer_buffer;
2671-
u8 data[0];
2672-
};
2673-
26742668
static void dwc2_free_dma_aligned_buffer(struct urb *urb)
26752669
{
2676-
struct dma_aligned_buffer *temp;
2670+
void *stored_xfer_buffer;
2671+
size_t length;
26772672

26782673
if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
26792674
return;
26802675

2681-
temp = container_of(urb->transfer_buffer,
2682-
struct dma_aligned_buffer, data);
2676+
/* Restore urb->transfer_buffer from the end of the allocated area */
2677+
memcpy(&stored_xfer_buffer, urb->transfer_buffer +
2678+
urb->transfer_buffer_length, sizeof(urb->transfer_buffer));
26832679

2684-
if (usb_urb_dir_in(urb))
2685-
memcpy(temp->old_xfer_buffer, temp->data,
2686-
urb->transfer_buffer_length);
2687-
urb->transfer_buffer = temp->old_xfer_buffer;
2688-
kfree(temp->kmalloc_ptr);
2680+
if (usb_urb_dir_in(urb)) {
2681+
if (usb_pipeisoc(urb->pipe))
2682+
length = urb->transfer_buffer_length;
2683+
else
2684+
length = urb->actual_length;
2685+
2686+
memcpy(stored_xfer_buffer, urb->transfer_buffer, length);
2687+
}
2688+
kfree(urb->transfer_buffer);
2689+
urb->transfer_buffer = stored_xfer_buffer;
26892690

26902691
urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
26912692
}
26922693

26932694
static int dwc2_alloc_dma_aligned_buffer(struct urb *urb, gfp_t mem_flags)
26942695
{
2695-
struct dma_aligned_buffer *temp, *kmalloc_ptr;
2696+
void *kmalloc_ptr;
26962697
size_t kmalloc_size;
26972698

26982699
if (urb->num_sgs || urb->sg ||
26992700
urb->transfer_buffer_length == 0 ||
27002701
!((uintptr_t)urb->transfer_buffer & (DWC2_USB_DMA_ALIGN - 1)))
27012702
return 0;
27022703

2703-
/* Allocate a buffer with enough padding for alignment */
2704+
/*
2705+
* Allocate a buffer with enough padding for original transfer_buffer
2706+
* pointer. This allocation is guaranteed to be aligned properly for
2707+
* DMA
2708+
*/
27042709
kmalloc_size = urb->transfer_buffer_length +
2705-
sizeof(struct dma_aligned_buffer) + DWC2_USB_DMA_ALIGN - 1;
2710+
sizeof(urb->transfer_buffer);
27062711

27072712
kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
27082713
if (!kmalloc_ptr)
27092714
return -ENOMEM;
27102715

2711-
/* Position our struct dma_aligned_buffer such that data is aligned */
2712-
temp = PTR_ALIGN(kmalloc_ptr + 1, DWC2_USB_DMA_ALIGN) - 1;
2713-
temp->kmalloc_ptr = kmalloc_ptr;
2714-
temp->old_xfer_buffer = urb->transfer_buffer;
2716+
/*
2717+
* Position value of original urb->transfer_buffer pointer to the end
2718+
* of allocation for later referencing
2719+
*/
2720+
memcpy(kmalloc_ptr + urb->transfer_buffer_length,
2721+
&urb->transfer_buffer, sizeof(urb->transfer_buffer));
2722+
27152723
if (usb_urb_dir_out(urb))
2716-
memcpy(temp->data, urb->transfer_buffer,
2724+
memcpy(kmalloc_ptr, urb->transfer_buffer,
27172725
urb->transfer_buffer_length);
2718-
urb->transfer_buffer = temp->data;
2726+
urb->transfer_buffer = kmalloc_ptr;
27192727

27202728
urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
27212729

drivers/usb/dwc2/hcd_intr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,10 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
12311231
* avoid interrupt storms we'll wait before retrying if we've got
12321232
* several NAKs. If we didn't do this we'd retry directly from the
12331233
* interrupt handler and could end up quickly getting another
1234-
* interrupt (another NAK), which we'd retry.
1234+
* interrupt (another NAK), which we'd retry. Note that we do not
1235+
* delay retries for IN parts of control requests, as those are expected
1236+
* to complete fairly quickly, and if we delay them we risk confusing
1237+
* the device and cause it issue STALL.
12351238
*
12361239
* Note that in DMA mode software only gets involved to re-send NAKed
12371240
* transfers for split transactions, so we only need to apply this
@@ -1244,7 +1247,9 @@ static void dwc2_hc_nak_intr(struct dwc2_hsotg *hsotg,
12441247
qtd->error_count = 0;
12451248
qtd->complete_split = 0;
12461249
qtd->num_naks++;
1247-
qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY;
1250+
qtd->qh->want_wait = qtd->num_naks >= DWC2_NAKS_BEFORE_DELAY &&
1251+
!(chan->ep_type == USB_ENDPOINT_XFER_CONTROL &&
1252+
chan->ep_is_in);
12481253
dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_NAK);
12491254
goto handle_nak_done;
12501255
}

drivers/usb/dwc3/ep0.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,15 +973,12 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
973973
ret = dwc3_ep0_start_trans(dep);
974974
} else if (IS_ALIGNED(req->request.length, dep->endpoint.maxpacket) &&
975975
req->request.length && req->request.zero) {
976-
u32 maxpacket;
977976

978977
ret = usb_gadget_map_request_by_dev(dwc->sysdev,
979978
&req->request, dep->number);
980979
if (ret)
981980
return;
982981

983-
maxpacket = dep->endpoint.maxpacket;
984-
985982
/* prepare normal TRB */
986983
dwc3_ep0_prepare_one_trb(dep, req->request.dma,
987984
req->request.length,

drivers/usb/gadget/composite.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,6 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
18191819
if (cdev->use_os_string && cdev->os_desc_config &&
18201820
(ctrl->bRequestType & USB_TYPE_VENDOR) &&
18211821
ctrl->bRequest == cdev->b_vendor_code) {
1822-
struct usb_request *req;
18231822
struct usb_configuration *os_desc_cfg;
18241823
u8 *buf;
18251824
int interface;

drivers/usb/gadget/function/f_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,7 @@ static int ffs_func_setup(struct usb_function *f,
32633263
__ffs_event_add(ffs, FUNCTIONFS_SETUP);
32643264
spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
32653265

3266-
return USB_GADGET_DELAYED_STATUS;
3266+
return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
32673267
}
32683268

32693269
static bool ffs_func_req_match(struct usb_function *f,

drivers/usb/gadget/function/f_uac2.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,14 @@ static struct usb_descriptor_header *hs_audio_desc[] = {
438438
};
439439

440440
struct cntrl_cur_lay3 {
441-
__u32 dCUR;
441+
__le32 dCUR;
442442
};
443443

444444
struct cntrl_range_lay3 {
445-
__u16 wNumSubRanges;
446-
__u32 dMIN;
447-
__u32 dMAX;
448-
__u32 dRES;
445+
__le16 wNumSubRanges;
446+
__le32 dMIN;
447+
__le32 dMAX;
448+
__le32 dRES;
449449
} __packed;
450450

451451
static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
@@ -559,13 +559,13 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
559559
agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
560560
if (!agdev->out_ep) {
561561
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
562-
return ret;
562+
return -ENODEV;
563563
}
564564

565565
agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
566566
if (!agdev->in_ep) {
567567
dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
568-
return ret;
568+
return -ENODEV;
569569
}
570570

571571
agdev->in_ep_maxpsize = max_t(u16,
@@ -703,9 +703,9 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
703703
memset(&c, 0, sizeof(struct cntrl_cur_lay3));
704704

705705
if (entity_id == USB_IN_CLK_ID)
706-
c.dCUR = p_srate;
706+
c.dCUR = cpu_to_le32(p_srate);
707707
else if (entity_id == USB_OUT_CLK_ID)
708-
c.dCUR = c_srate;
708+
c.dCUR = cpu_to_le32(c_srate);
709709

710710
value = min_t(unsigned, w_length, sizeof c);
711711
memcpy(req->buf, &c, value);
@@ -742,15 +742,15 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
742742

743743
if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) {
744744
if (entity_id == USB_IN_CLK_ID)
745-
r.dMIN = p_srate;
745+
r.dMIN = cpu_to_le32(p_srate);
746746
else if (entity_id == USB_OUT_CLK_ID)
747-
r.dMIN = c_srate;
747+
r.dMIN = cpu_to_le32(c_srate);
748748
else
749749
return -EOPNOTSUPP;
750750

751751
r.dMAX = r.dMIN;
752752
r.dRES = 0;
753-
r.wNumSubRanges = 1;
753+
r.wNumSubRanges = cpu_to_le16(1);
754754

755755
value = min_t(unsigned, w_length, sizeof r);
756756
memcpy(req->buf, &r, value);

0 commit comments

Comments
 (0)