Skip to content

Commit 8004d08

Browse files
committed
Merge tag 'usb-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB driver fixes for 6.17-rc3 to resolve a bunch of reported issues. Included in here are: - typec driver fixes - dwc3 new device id - dwc3 driver fixes - new usb-storage driver quirks - xhci driver fixes - other tiny USB driver fixes to resolve bugs All of these have been in linux-next this week with no reported issues" * tag 'usb-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: xhci: fix host not responding after suspend and resume usb: xhci: Fix slot_id resource race conflict usb: typec: fusb302: Revert incorrect threaded irq fix USB: core: Update kerneldoc for usb_hcd_giveback_urb() usb: typec: maxim_contaminant: re-enable cc toggle if cc is open and port is clean usb: typec: maxim_contaminant: disable low power mode when reading comparator values usb: dwc3: Remove WARN_ON for device endpoint command timeouts USB: storage: Ignore driver CD mode for Realtek multi-mode Wi-Fi dongles usb: storage: realtek_cr: Use correct byte order for bcs->Residue usb: chipidea: imx: improve usbmisc_imx7d_pullup() kcov, usb: Don't disable interrupts in kcov_remote_start_usb_softirq() usb: dwc3: pci: add support for the Intel Wildcat Lake usb: dwc3: Ignore late xferNotReady event to prevent halt timeout USB: storage: Add unusual-devs entry for Novatek NTK96550-based camera usb: core: hcd: fix accessing unmapped memory in SINGLE_STEP_SET_FEATURE test usb: renesas-xhci: Fix External ROM access timeouts usb: gadget: tegra-xudc: fix PM use count underflow usb: quirks: Add DELAY_INIT quick for another SanDisk 3.2Gen1 Flash Drive
2 parents e1d8f9c + ff9a09b commit 8004d08

File tree

20 files changed

+224
-97
lines changed

20 files changed

+224
-97
lines changed

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
338338
schedule_work(&ci->usb_phy->chg_work);
339339
break;
340340
case CI_HDRC_CONTROLLER_PULLUP_EVENT:
341-
if (ci->role == CI_ROLE_GADGET)
341+
if (ci->role == CI_ROLE_GADGET &&
342+
ci->gadget.speed == USB_SPEED_HIGH)
342343
imx_usbmisc_pullup(data->usbmisc_data,
343344
ci->gadget.connected);
344345
break;

drivers/usb/chipidea/usbmisc_imx.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,15 +1068,24 @@ static void usbmisc_imx7d_pullup(struct imx_usbmisc_data *data, bool on)
10681068
unsigned long flags;
10691069
u32 val;
10701070

1071+
if (on)
1072+
return;
1073+
10711074
spin_lock_irqsave(&usbmisc->lock, flags);
10721075
val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
1073-
if (!on) {
1074-
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
1075-
val |= MX7D_USBNC_USB_CTRL2_OPMODE(1);
1076-
val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
1077-
} else {
1078-
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
1079-
}
1076+
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
1077+
val |= MX7D_USBNC_USB_CTRL2_OPMODE(1);
1078+
val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
1079+
writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
1080+
spin_unlock_irqrestore(&usbmisc->lock, flags);
1081+
1082+
/* Last for at least 1 micro-frame to let host see disconnect signal */
1083+
usleep_range(125, 150);
1084+
1085+
spin_lock_irqsave(&usbmisc->lock, flags);
1086+
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK;
1087+
val |= MX7D_USBNC_USB_CTRL2_OPMODE(0);
1088+
val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN;
10801089
writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2);
10811090
spin_unlock_irqrestore(&usbmisc->lock, flags);
10821091
}

drivers/usb/core/hcd.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,6 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
16361636
struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus);
16371637
struct usb_anchor *anchor = urb->anchor;
16381638
int status = urb->unlinked;
1639-
unsigned long flags;
16401639

16411640
urb->hcpriv = NULL;
16421641
if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) &&
@@ -1654,14 +1653,13 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
16541653
/* pass ownership to the completion handler */
16551654
urb->status = status;
16561655
/*
1657-
* Only collect coverage in the softirq context and disable interrupts
1658-
* to avoid scenarios with nested remote coverage collection sections
1659-
* that KCOV does not support.
1660-
* See the comment next to kcov_remote_start_usb_softirq() for details.
1656+
* This function can be called in task context inside another remote
1657+
* coverage collection section, but kcov doesn't support that kind of
1658+
* recursion yet. Only collect coverage in softirq context for now.
16611659
*/
1662-
flags = kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum);
1660+
kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum);
16631661
urb->complete(urb);
1664-
kcov_remote_stop_softirq(flags);
1662+
kcov_remote_stop_softirq();
16651663

16661664
usb_anchor_resume_wakeups(anchor);
16671665
atomic_dec(&urb->use_count);
@@ -1719,10 +1717,10 @@ static void usb_giveback_urb_bh(struct work_struct *work)
17191717
* @urb: urb being returned to the USB device driver.
17201718
* @status: completion status code for the URB.
17211719
*
1722-
* Context: atomic. The completion callback is invoked in caller's context.
1723-
* For HCDs with HCD_BH flag set, the completion callback is invoked in BH
1724-
* context (except for URBs submitted to the root hub which always complete in
1725-
* caller's context).
1720+
* Context: atomic. The completion callback is invoked either in a work queue
1721+
* (BH) context or in the caller's context, depending on whether the HCD_BH
1722+
* flag is set in the @hcd structure, except that URBs submitted to the
1723+
* root hub always complete in BH context.
17261724
*
17271725
* This hands the URB from HCD to its USB device driver, using its
17281726
* completion function. The HCD has freed all per-urb resources
@@ -2166,7 +2164,7 @@ static struct urb *request_single_step_set_feature_urb(
21662164
urb->complete = usb_ehset_completion;
21672165
urb->status = -EINPROGRESS;
21682166
urb->actual_length = 0;
2169-
urb->transfer_flags = URB_DIR_IN;
2167+
urb->transfer_flags = URB_DIR_IN | URB_NO_TRANSFER_DMA_MAP;
21702168
usb_get_urb(urb);
21712169
atomic_inc(&urb->use_count);
21722170
atomic_inc(&urb->dev->urbnum);
@@ -2230,9 +2228,15 @@ int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
22302228

22312229
/* Complete remaining DATA and STATUS stages using the same URB */
22322230
urb->status = -EINPROGRESS;
2231+
urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP;
22332232
usb_get_urb(urb);
22342233
atomic_inc(&urb->use_count);
22352234
atomic_inc(&urb->dev->urbnum);
2235+
if (map_urb_for_dma(hcd, urb, GFP_KERNEL)) {
2236+
usb_put_urb(urb);
2237+
goto out1;
2238+
}
2239+
22362240
retval = hcd->driver->submit_single_step_set_feature(hcd, urb, 0);
22372241
if (!retval && !wait_for_completion_timeout(&done,
22382242
msecs_to_jiffies(2000))) {

drivers/usb/core/quirks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ static const struct usb_device_id usb_quirk_list[] = {
371371
{ USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM },
372372

373373
/* SanDisk Corp. SanDisk 3.2Gen1 */
374+
{ USB_DEVICE(0x0781, 0x5596), .driver_info = USB_QUIRK_DELAY_INIT },
374375
{ USB_DEVICE(0x0781, 0x55a3), .driver_info = USB_QUIRK_DELAY_INIT },
375376

376377
/* SanDisk Extreme 55AE */

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#define PCI_DEVICE_ID_INTEL_TGPLP 0xa0ee
4242
#define PCI_DEVICE_ID_INTEL_TGPH 0x43ee
4343
#define PCI_DEVICE_ID_INTEL_JSP 0x4dee
44+
#define PCI_DEVICE_ID_INTEL_WCL 0x4d7e
4445
#define PCI_DEVICE_ID_INTEL_ADL 0x460e
4546
#define PCI_DEVICE_ID_INTEL_ADL_PCH 0x51ee
4647
#define PCI_DEVICE_ID_INTEL_ADLN 0x465e
@@ -431,6 +432,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
431432
{ PCI_DEVICE_DATA(INTEL, TGPLP, &dwc3_pci_intel_swnode) },
432433
{ PCI_DEVICE_DATA(INTEL, TGPH, &dwc3_pci_intel_swnode) },
433434
{ PCI_DEVICE_DATA(INTEL, JSP, &dwc3_pci_intel_swnode) },
435+
{ PCI_DEVICE_DATA(INTEL, WCL, &dwc3_pci_intel_swnode) },
434436
{ PCI_DEVICE_DATA(INTEL, ADL, &dwc3_pci_intel_swnode) },
435437
{ PCI_DEVICE_DATA(INTEL, ADL_PCH, &dwc3_pci_intel_swnode) },
436438
{ PCI_DEVICE_DATA(INTEL, ADLN, &dwc3_pci_intel_swnode) },

drivers/usb/dwc3/ep0.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
288288
dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 8,
289289
DWC3_TRBCTL_CONTROL_SETUP, false);
290290
ret = dwc3_ep0_start_trans(dep);
291-
WARN_ON(ret < 0);
291+
if (ret < 0)
292+
dev_err(dwc->dev, "ep0 out start transfer failed: %d\n", ret);
293+
292294
for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) {
293295
struct dwc3_ep *dwc3_ep;
294296

@@ -1061,7 +1063,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
10611063
ret = dwc3_ep0_start_trans(dep);
10621064
}
10631065

1064-
WARN_ON(ret < 0);
1066+
if (ret < 0)
1067+
dev_err(dwc->dev,
1068+
"ep0 data phase start transfer failed: %d\n", ret);
10651069
}
10661070

10671071
static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
@@ -1078,7 +1082,12 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep)
10781082

10791083
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
10801084
{
1081-
WARN_ON(dwc3_ep0_start_control_status(dep));
1085+
int ret;
1086+
1087+
ret = dwc3_ep0_start_control_status(dep);
1088+
if (ret)
1089+
dev_err(dwc->dev,
1090+
"ep0 status phase start transfer failed: %d\n", ret);
10821091
}
10831092

10841093
static void dwc3_ep0_do_control_status(struct dwc3 *dwc,
@@ -1121,7 +1130,10 @@ void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep)
11211130
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
11221131
memset(&params, 0, sizeof(params));
11231132
ret = dwc3_send_gadget_ep_cmd(dep, cmd, &params);
1124-
WARN_ON_ONCE(ret);
1133+
if (ret)
1134+
dev_err_ratelimited(dwc->dev,
1135+
"ep0 data phase end transfer failed: %d\n", ret);
1136+
11251137
dep->resource_index = 0;
11261138
}
11271139

drivers/usb/dwc3/gadget.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
17721772
dep->flags |= DWC3_EP_DELAY_STOP;
17731773
return 0;
17741774
}
1775-
WARN_ON_ONCE(ret);
1775+
1776+
if (ret)
1777+
dev_err_ratelimited(dep->dwc->dev,
1778+
"end transfer failed: %d\n", ret);
1779+
17761780
dep->resource_index = 0;
17771781

17781782
if (!interrupt)
@@ -3777,6 +3781,15 @@ static void dwc3_gadget_endpoint_transfer_complete(struct dwc3_ep *dep,
37773781
static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep,
37783782
const struct dwc3_event_depevt *event)
37793783
{
3784+
/*
3785+
* During a device-initiated disconnect, a late xferNotReady event can
3786+
* be generated after the End Transfer command resets the event filter,
3787+
* but before the controller is halted. Ignore it to prevent a new
3788+
* transfer from starting.
3789+
*/
3790+
if (!dep->dwc->connected)
3791+
return;
3792+
37803793
dwc3_gadget_endpoint_frame_from_event(dep, event);
37813794

37823795
/*
@@ -4039,7 +4052,9 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
40394052
dep->flags &= ~DWC3_EP_STALL;
40404053

40414054
ret = dwc3_send_clear_stall_ep_cmd(dep);
4042-
WARN_ON_ONCE(ret);
4055+
if (ret)
4056+
dev_err_ratelimited(dwc->dev,
4057+
"failed to clear STALL on %s\n", dep->name);
40434058
}
40444059
}
40454060

drivers/usb/gadget/udc/tegra-xudc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ struct tegra_xudc {
502502
struct clk_bulk_data *clks;
503503

504504
bool device_mode;
505+
bool current_device_mode;
505506
struct work_struct usb_role_sw_work;
506507

507508
struct phy **usb3_phy;
@@ -715,6 +716,8 @@ static void tegra_xudc_device_mode_on(struct tegra_xudc *xudc)
715716

716717
phy_set_mode_ext(xudc->curr_utmi_phy, PHY_MODE_USB_OTG,
717718
USB_ROLE_DEVICE);
719+
720+
xudc->current_device_mode = true;
718721
}
719722

720723
static void tegra_xudc_device_mode_off(struct tegra_xudc *xudc)
@@ -725,6 +728,8 @@ static void tegra_xudc_device_mode_off(struct tegra_xudc *xudc)
725728

726729
dev_dbg(xudc->dev, "device mode off\n");
727730

731+
xudc->current_device_mode = false;
732+
728733
connected = !!(xudc_readl(xudc, PORTSC) & PORTSC_CCS);
729734

730735
reinit_completion(&xudc->disconnect_complete);
@@ -4044,10 +4049,10 @@ static int __maybe_unused tegra_xudc_resume(struct device *dev)
40444049

40454050
spin_lock_irqsave(&xudc->lock, flags);
40464051
xudc->suspended = false;
4052+
if (xudc->device_mode != xudc->current_device_mode)
4053+
schedule_work(&xudc->usb_role_sw_work);
40474054
spin_unlock_irqrestore(&xudc->lock, flags);
40484055

4049-
schedule_work(&xudc->usb_role_sw_work);
4050-
40514056
pm_runtime_enable(dev);
40524057

40534058
return 0;

drivers/usb/host/xhci-hub.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,7 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
704704
if (!xhci->devs[i])
705705
continue;
706706

707-
retval = xhci_disable_slot(xhci, i);
708-
xhci_free_virt_device(xhci, i);
707+
retval = xhci_disable_and_free_slot(xhci, i);
709708
if (retval)
710709
xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n",
711710
i, retval);

drivers/usb/host/xhci-mem.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -865,21 +865,20 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
865865
* will be manipulated by the configure endpoint, allocate device, or update
866866
* hub functions while this function is removing the TT entries from the list.
867867
*/
868-
void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
868+
void xhci_free_virt_device(struct xhci_hcd *xhci, struct xhci_virt_device *dev,
869+
int slot_id)
869870
{
870-
struct xhci_virt_device *dev;
871871
int i;
872872
int old_active_eps = 0;
873873

874874
/* Slot ID 0 is reserved */
875-
if (slot_id == 0 || !xhci->devs[slot_id])
875+
if (slot_id == 0 || !dev)
876876
return;
877877

878-
dev = xhci->devs[slot_id];
879-
880-
xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
881-
if (!dev)
882-
return;
878+
/* If device ctx array still points to _this_ device, clear it */
879+
if (dev->out_ctx &&
880+
xhci->dcbaa->dev_context_ptrs[slot_id] == cpu_to_le64(dev->out_ctx->dma))
881+
xhci->dcbaa->dev_context_ptrs[slot_id] = 0;
883882

884883
trace_xhci_free_virt_device(dev);
885884

@@ -920,8 +919,9 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
920919
dev->udev->slot_id = 0;
921920
if (dev->rhub_port && dev->rhub_port->slot_id == slot_id)
922921
dev->rhub_port->slot_id = 0;
923-
kfree(xhci->devs[slot_id]);
924-
xhci->devs[slot_id] = NULL;
922+
if (xhci->devs[slot_id] == dev)
923+
xhci->devs[slot_id] = NULL;
924+
kfree(dev);
925925
}
926926

927927
/*
@@ -962,7 +962,7 @@ static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_i
962962
out:
963963
/* we are now at a leaf device */
964964
xhci_debugfs_remove_slot(xhci, slot_id);
965-
xhci_free_virt_device(xhci, slot_id);
965+
xhci_free_virt_device(xhci, vdev, slot_id);
966966
}
967967

968968
int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,

0 commit comments

Comments
 (0)