Skip to content

Commit 2798396

Browse files
committed
Merge tag 'usb-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB fixes and new device ids for 6.19-rc6 Included in here are: - new usb-serial device ids - dwc3-apple driver fixes to get things working properly on that hardware platform - ohci/uhci platfrom driver module soft-deps with ehci to remove a runtime warning that sometimes shows up on some platforms. - quirk for broken devices that can not handle reading the BOS descriptor from them without going crazy. - usb-serial driver fixes - xhci driver fixes - usb gadget driver fixes All of these except for the last xhci fix has been in linux-next for a while. The xhci fix has been reported by others to solve the issue for them, so should be ok" * tag 'usb-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: xhci: sideband: don't dereference freed ring when removing sideband endpoint usb: gadget: uvc: retry vb2_reqbufs() with vb_vmalloc_memops if use_sg fail usb: gadget: uvc: return error from uvcg_queue_init() usb: gadget: uvc: fix interval_duration calculation usb: gadget: uvc: fix req_payload_size calculation usb: dwc3: apple: Ignore USB role switches to the active role usb: host: xhci-tegra: Use platform_get_irq_optional() for wake IRQs USB: OHCI/UHCI: Add soft dependencies on ehci_platform usb: dwc3: apple: Set USB2 PHY mode before dwc3 init USB: serial: f81232: fix incomplete serial port generation USB: serial: ftdi_sio: add support for PICAXE AXE027 cable USB: serial: option: add Telit LE910 MBIM composition usb: core: add USB_QUIRK_NO_BOS for devices that hang on BOS descriptor dt-bindings: usb: qcom,dwc3: Correct MSM8994 interrupts dt-bindings: usb: qcom,dwc3: Correct IPQ5018 interrupts tcpm: allow looking for role_sw device in the main node usb: dwc3: Check for USB4 IP_NAME
2 parents 5d1765a + dd83dc1 commit 2798396

22 files changed

Lines changed: 166 additions & 67 deletions

File tree

Documentation/devicetree/bindings/usb/qcom,dwc3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ allOf:
406406
compatible:
407407
contains:
408408
enum:
409-
- qcom,ipq5018-dwc3
410409
- qcom,ipq6018-dwc3
411410
- qcom,ipq8074-dwc3
412411
- qcom,msm8953-dwc3
@@ -428,6 +427,7 @@ allOf:
428427
compatible:
429428
contains:
430429
enum:
430+
- qcom,msm8994-dwc3
431431
- qcom,msm8996-dwc3
432432
- qcom,qcs404-dwc3
433433
- qcom,sdm660-dwc3
@@ -451,6 +451,7 @@ allOf:
451451
compatible:
452452
contains:
453453
enum:
454+
- qcom,ipq5018-dwc3
454455
- qcom,ipq5332-dwc3
455456
then:
456457
properties:
@@ -488,7 +489,6 @@ allOf:
488489
enum:
489490
- qcom,ipq4019-dwc3
490491
- qcom,ipq8064-dwc3
491-
- qcom,msm8994-dwc3
492492
- qcom,qcs615-dwc3
493493
- qcom,qcs8300-dwc3
494494
- qcom,qdu1000-dwc3

Documentation/devicetree/bindings/usb/qcom,snps-dwc3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ allOf:
420420
compatible:
421421
contains:
422422
enum:
423-
- qcom,ipq5018-dwc3
424423
- qcom,ipq6018-dwc3
425424
- qcom,ipq8074-dwc3
426425
- qcom,msm8953-dwc3
@@ -443,6 +442,7 @@ allOf:
443442
compatible:
444443
contains:
445444
enum:
445+
- qcom,msm8994-dwc3
446446
- qcom,msm8996-dwc3
447447
- qcom,qcs404-dwc3
448448
- qcom,sdm660-dwc3
@@ -467,6 +467,7 @@ allOf:
467467
compatible:
468468
contains:
469469
enum:
470+
- qcom,ipq5018-dwc3
470471
- qcom,ipq5332-dwc3
471472
then:
472473
properties:
@@ -509,7 +510,6 @@ allOf:
509510
- qcom,ipq4019-dwc3
510511
- qcom,ipq8064-dwc3
511512
- qcom,kaanapali-dwc3
512-
- qcom,msm8994-dwc3
513513
- qcom,qcs615-dwc3
514514
- qcom,qcs8300-dwc3
515515
- qcom,qdu1000-dwc3

drivers/usb/core/config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,11 @@ int usb_get_bos_descriptor(struct usb_device *dev)
10401040
__u8 cap_type;
10411041
int ret;
10421042

1043+
if (dev->quirks & USB_QUIRK_NO_BOS) {
1044+
dev_dbg(ddev, "skipping BOS descriptor\n");
1045+
return -ENOMSG;
1046+
}
1047+
10431048
bos = kzalloc(sizeof(*bos), GFP_KERNEL);
10441049
if (!bos)
10451050
return -ENOMEM;

drivers/usb/core/quirks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ static const struct usb_device_id usb_quirk_list[] = {
450450
{ USB_DEVICE(0x0c45, 0x7056), .driver_info =
451451
USB_QUIRK_IGNORE_REMOTE_WAKEUP },
452452

453+
/* Elgato 4K X - BOS descriptor fetch hangs at SuperSpeed Plus */
454+
{ USB_DEVICE(0x0fd9, 0x009b), .driver_info = USB_QUIRK_NO_BOS },
455+
453456
/* Sony Xperia XZ1 Compact (lilac) smartphone in fastboot mode */
454457
{ USB_DEVICE(0x0fce, 0x0dde), .driver_info = USB_QUIRK_NO_LPM },
455458

drivers/usb/dwc3/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc)
993993

994994
reg = dwc3_readl(dwc->regs, DWC3_GSNPSID);
995995
dwc->ip = DWC3_GSNPS_ID(reg);
996+
if (dwc->ip == DWC4_IP)
997+
dwc->ip = DWC32_IP;
996998

997999
/* This should read as U3 followed by revision number */
9981000
if (DWC3_IP_IS(DWC3)) {

drivers/usb/dwc3/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ struct dwc3 {
12651265
#define DWC3_IP 0x5533
12661266
#define DWC31_IP 0x3331
12671267
#define DWC32_IP 0x3332
1268+
#define DWC4_IP 0x3430
12681269

12691270
u32 revision;
12701271

drivers/usb/dwc3/dwc3-apple.c

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -218,25 +218,31 @@ static int dwc3_apple_core_init(struct dwc3_apple *appledwc)
218218
return ret;
219219
}
220220

221-
static void dwc3_apple_phy_set_mode(struct dwc3_apple *appledwc, enum phy_mode mode)
222-
{
223-
lockdep_assert_held(&appledwc->lock);
224-
225-
/*
226-
* This platform requires SUSPHY to be enabled here already in order to properly configure
227-
* the PHY and switch dwc3's PIPE interface to USB3 PHY.
228-
*/
229-
dwc3_enable_susphy(&appledwc->dwc, true);
230-
phy_set_mode(appledwc->dwc.usb2_generic_phy[0], mode);
231-
phy_set_mode(appledwc->dwc.usb3_generic_phy[0], mode);
232-
}
233-
234221
static int dwc3_apple_init(struct dwc3_apple *appledwc, enum dwc3_apple_state state)
235222
{
236223
int ret, ret_reset;
237224

238225
lockdep_assert_held(&appledwc->lock);
239226

227+
/*
228+
* The USB2 PHY on this platform must be configured for host or device mode while it is
229+
* still powered off and before dwc3 tries to access it. Otherwise, the new configuration
230+
* will sometimes only take affect after the *next* time dwc3 is brought up which causes
231+
* the connected device to just not work.
232+
* The USB3 PHY must be configured later after dwc3 has already been initialized.
233+
*/
234+
switch (state) {
235+
case DWC3_APPLE_HOST:
236+
phy_set_mode(appledwc->dwc.usb2_generic_phy[0], PHY_MODE_USB_HOST);
237+
break;
238+
case DWC3_APPLE_DEVICE:
239+
phy_set_mode(appledwc->dwc.usb2_generic_phy[0], PHY_MODE_USB_DEVICE);
240+
break;
241+
default:
242+
/* Unreachable unless there's a bug in this driver */
243+
return -EINVAL;
244+
}
245+
240246
ret = reset_control_deassert(appledwc->reset);
241247
if (ret) {
242248
dev_err(appledwc->dev, "Failed to deassert reset, err=%d\n", ret);
@@ -257,7 +263,13 @@ static int dwc3_apple_init(struct dwc3_apple *appledwc, enum dwc3_apple_state st
257263
case DWC3_APPLE_HOST:
258264
appledwc->dwc.dr_mode = USB_DR_MODE_HOST;
259265
dwc3_apple_set_ptrcap(appledwc, DWC3_GCTL_PRTCAP_HOST);
260-
dwc3_apple_phy_set_mode(appledwc, PHY_MODE_USB_HOST);
266+
/*
267+
* This platform requires SUSPHY to be enabled here already in order to properly
268+
* configure the PHY and switch dwc3's PIPE interface to USB3 PHY. The USB2 PHY
269+
* has already been configured to the correct mode earlier.
270+
*/
271+
dwc3_enable_susphy(&appledwc->dwc, true);
272+
phy_set_mode(appledwc->dwc.usb3_generic_phy[0], PHY_MODE_USB_HOST);
261273
ret = dwc3_host_init(&appledwc->dwc);
262274
if (ret) {
263275
dev_err(appledwc->dev, "Failed to initialize host, ret=%d\n", ret);
@@ -268,7 +280,13 @@ static int dwc3_apple_init(struct dwc3_apple *appledwc, enum dwc3_apple_state st
268280
case DWC3_APPLE_DEVICE:
269281
appledwc->dwc.dr_mode = USB_DR_MODE_PERIPHERAL;
270282
dwc3_apple_set_ptrcap(appledwc, DWC3_GCTL_PRTCAP_DEVICE);
271-
dwc3_apple_phy_set_mode(appledwc, PHY_MODE_USB_DEVICE);
283+
/*
284+
* This platform requires SUSPHY to be enabled here already in order to properly
285+
* configure the PHY and switch dwc3's PIPE interface to USB3 PHY. The USB2 PHY
286+
* has already been configured to the correct mode earlier.
287+
*/
288+
dwc3_enable_susphy(&appledwc->dwc, true);
289+
phy_set_mode(appledwc->dwc.usb3_generic_phy[0], PHY_MODE_USB_DEVICE);
272290
ret = dwc3_gadget_init(&appledwc->dwc);
273291
if (ret) {
274292
dev_err(appledwc->dev, "Failed to initialize gadget, ret=%d\n", ret);
@@ -339,6 +357,22 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, enum usb_role ro
339357

340358
guard(mutex)(&appledwc->lock);
341359

360+
/*
361+
* Skip role switches if appledwc is already in the desired state. The
362+
* USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices issues
363+
* additional interrupts which results in usb_role_switch_set_role()
364+
* calls with the current role.
365+
* Ignore those calls here to ensure the USB-C port controller and
366+
* appledwc are in a consistent state.
367+
* This matches the behaviour in __dwc3_set_mode().
368+
* Do no handle USB_ROLE_NONE for DWC3_APPLE_NO_CABLE and
369+
* DWC3_APPLE_PROBE_PENDING since that is no-op anyway.
370+
*/
371+
if (appledwc->state == DWC3_APPLE_HOST && role == USB_ROLE_HOST)
372+
return 0;
373+
if (appledwc->state == DWC3_APPLE_DEVICE && role == USB_ROLE_DEVICE)
374+
return 0;
375+
342376
/*
343377
* We need to tear all of dwc3 down and re-initialize it every time a cable is
344378
* connected or disconnected or when the mode changes. See the documentation for enum

drivers/usb/gadget/function/f_uvc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
362362
return ret;
363363
usb_ep_enable(uvc->video.ep);
364364

365+
uvc->video.max_req_size = uvc->video.ep->maxpacket
366+
* max_t(unsigned int, uvc->video.ep->maxburst, 1)
367+
* (uvc->video.ep->mult);
368+
365369
memset(&v4l2_event, 0, sizeof(v4l2_event));
366370
v4l2_event.type = UVC_EVENT_STREAMON;
367371
v4l2_event_queue(&uvc->vdev, &v4l2_event);

drivers/usb/gadget/function/uvc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct uvc_video {
107107
unsigned int width;
108108
unsigned int height;
109109
unsigned int imagesize;
110-
unsigned int interval;
110+
unsigned int interval; /* in 100ns units */
111111
struct mutex mutex; /* protects frame parameters */
112112

113113
unsigned int uvc_num_requests;
@@ -117,6 +117,7 @@ struct uvc_video {
117117
/* Requests */
118118
bool is_enabled; /* tracks whether video stream is enabled */
119119
unsigned int req_size;
120+
unsigned int max_req_size;
120121
struct list_head ureqs; /* all uvc_requests allocated by uvc_video */
121122

122123
/* USB requests that the video pump thread can encode into */

drivers/usb/gadget/function/uvc_queue.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,17 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
8686
buf->bytesused = 0;
8787
} else {
8888
buf->bytesused = vb2_get_plane_payload(vb, 0);
89-
buf->req_payload_size =
90-
DIV_ROUND_UP(buf->bytesused +
91-
(video->reqs_per_frame * UVCG_REQUEST_HEADER_LEN),
92-
video->reqs_per_frame);
89+
90+
if (video->reqs_per_frame != 0) {
91+
buf->req_payload_size =
92+
DIV_ROUND_UP(buf->bytesused +
93+
(video->reqs_per_frame * UVCG_REQUEST_HEADER_LEN),
94+
video->reqs_per_frame);
95+
if (buf->req_payload_size > video->req_size)
96+
buf->req_payload_size = video->req_size;
97+
} else {
98+
buf->req_payload_size = video->max_req_size;
99+
}
93100
}
94101

95102
return 0;
@@ -175,7 +182,15 @@ int uvcg_alloc_buffers(struct uvc_video_queue *queue,
175182
{
176183
int ret;
177184

185+
retry:
178186
ret = vb2_reqbufs(&queue->queue, rb);
187+
if (ret < 0 && queue->use_sg) {
188+
uvc_trace(UVC_TRACE_IOCTL,
189+
"failed to alloc buffer with sg enabled, try non-sg mode\n");
190+
queue->use_sg = 0;
191+
queue->queue.mem_ops = &vb2_vmalloc_memops;
192+
goto retry;
193+
}
179194

180195
return ret ? ret : rb->count;
181196
}

0 commit comments

Comments
 (0)