Skip to content

Commit 0dc1f31

Browse files
committed
Merge tag 'usb-6.14-rc6' 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 some reported issues. These contain: - typec driver fixes - dwc3 driver fixes - xhci driver fixes - renesas controller fixes - gadget driver fixes - a new USB quirk added All of these have been in linux-next with no reported issues" * tag 'usb-6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: typec: ucsi: Fix NULL pointer access usb: quirks: Add DELAY_INIT and NO_LPM for Prolific Mass Storage Card Reader usb: xhci: Fix host controllers "dying" after suspend and resume usb: dwc3: Set SUSPENDENABLE soon after phy init usb: hub: lack of clearing xHC resources usb: renesas_usbhs: Flush the notify_hotplug_work usb: renesas_usbhs: Use devm_usb_get_phy() usb: renesas_usbhs: Call clk_put() usb: dwc3: gadget: Prevent irq storm when TH re-executes usb: gadget: Check bmAttributes only if configuration is valid xhci: Restrict USB4 tunnel detection for USB3 devices to Intel hosts usb: xhci: Enable the TRB overfetch quirk on VIA VL805 usb: gadget: Fix setting self-powered state on suspend usb: typec: ucsi: increase timeout for PPM reset operations acpi: typec: ucsi: Introduce a ->poll_cci method usb: typec: tcpci_rt1711h: Unmask alert interrupts to fix functionality usb: gadget: Set self-powered based on MaxPower and bmAttributes usb: gadget: u_ether: Set is_suspend flag if remote wakeup fails usb: atm: cxacru: fix a flaw in existing endpoint checks
2 parents 51b38f3 + b13abcb commit 0dc1f31

File tree

24 files changed

+189
-83
lines changed

24 files changed

+189
-83
lines changed

drivers/usb/atm/cxacru.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,10 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
11311131
struct cxacru_data *instance;
11321132
struct usb_device *usb_dev = interface_to_usbdev(intf);
11331133
struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD];
1134-
struct usb_endpoint_descriptor *in, *out;
1134+
static const u8 ep_addrs[] = {
1135+
CXACRU_EP_CMD + USB_DIR_IN,
1136+
CXACRU_EP_CMD + USB_DIR_OUT,
1137+
0};
11351138
int ret;
11361139

11371140
/* instance init */
@@ -1179,13 +1182,11 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
11791182
}
11801183

11811184
if (usb_endpoint_xfer_int(&cmd_ep->desc))
1182-
ret = usb_find_common_endpoints(intf->cur_altsetting,
1183-
NULL, NULL, &in, &out);
1185+
ret = usb_check_int_endpoints(intf, ep_addrs);
11841186
else
1185-
ret = usb_find_common_endpoints(intf->cur_altsetting,
1186-
&in, &out, NULL, NULL);
1187+
ret = usb_check_bulk_endpoints(intf, ep_addrs);
11871188

1188-
if (ret) {
1189+
if (!ret) {
11891190
usb_err(usbatm_instance, "cxacru_bind: interface has incorrect endpoints\n");
11901191
ret = -ENODEV;
11911192
goto fail;

drivers/usb/core/hub.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6065,6 +6065,36 @@ void usb_hub_cleanup(void)
60656065
usb_deregister(&hub_driver);
60666066
} /* usb_hub_cleanup() */
60676067

6068+
/**
6069+
* hub_hc_release_resources - clear resources used by host controller
6070+
* @udev: pointer to device being released
6071+
*
6072+
* Context: task context, might sleep
6073+
*
6074+
* Function releases the host controller resources in correct order before
6075+
* making any operation on resuming usb device. The host controller resources
6076+
* allocated for devices in tree should be released starting from the last
6077+
* usb device in tree toward the root hub. This function is used only during
6078+
* resuming device when usb device require reinitialization – that is, when
6079+
* flag udev->reset_resume is set.
6080+
*
6081+
* This call is synchronous, and may not be used in an interrupt context.
6082+
*/
6083+
static void hub_hc_release_resources(struct usb_device *udev)
6084+
{
6085+
struct usb_hub *hub = usb_hub_to_struct_hub(udev);
6086+
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
6087+
int i;
6088+
6089+
/* Release up resources for all children before this device */
6090+
for (i = 0; i < udev->maxchild; i++)
6091+
if (hub->ports[i]->child)
6092+
hub_hc_release_resources(hub->ports[i]->child);
6093+
6094+
if (hcd->driver->reset_device)
6095+
hcd->driver->reset_device(hcd, udev);
6096+
}
6097+
60686098
/**
60696099
* usb_reset_and_verify_device - perform a USB port reset to reinitialize a device
60706100
* @udev: device to reset (not in SUSPENDED or NOTATTACHED state)
@@ -6129,6 +6159,9 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
61296159
bos = udev->bos;
61306160
udev->bos = NULL;
61316161

6162+
if (udev->reset_resume)
6163+
hub_hc_release_resources(udev);
6164+
61326165
mutex_lock(hcd->address0_mutex);
61336166

61346167
for (i = 0; i < PORT_INIT_TRIES; ++i) {

drivers/usb/core/quirks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ static const struct usb_device_id usb_quirk_list[] = {
341341
{ USB_DEVICE(0x0638, 0x0a13), .driver_info =
342342
USB_QUIRK_STRING_FETCH_255 },
343343

344+
/* Prolific Single-LUN Mass Storage Card Reader */
345+
{ USB_DEVICE(0x067b, 0x2731), .driver_info = USB_QUIRK_DELAY_INIT |
346+
USB_QUIRK_NO_LPM },
347+
344348
/* Saitek Cyborg Gold Joystick */
345349
{ USB_DEVICE(0x06a3, 0x0006), .driver_info =
346350
USB_QUIRK_CONFIG_INTF_STRINGS },

drivers/usb/dwc3/core.c

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,24 @@ void dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
131131
}
132132
}
133133

134-
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
134+
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode, bool ignore_susphy)
135135
{
136+
unsigned int hw_mode;
136137
u32 reg;
137138

138139
reg = dwc3_readl(dwc->regs, DWC3_GCTL);
140+
141+
/*
142+
* For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE and
143+
* GUSB2PHYCFG.SUSPHY should be cleared during mode switching,
144+
* and they can be set after core initialization.
145+
*/
146+
hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
147+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && !ignore_susphy) {
148+
if (DWC3_GCTL_PRTCAP(reg) != mode)
149+
dwc3_enable_susphy(dwc, false);
150+
}
151+
139152
reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
140153
reg |= DWC3_GCTL_PRTCAPDIR(mode);
141154
dwc3_writel(dwc->regs, DWC3_GCTL, reg);
@@ -216,7 +229,7 @@ static void __dwc3_set_mode(struct work_struct *work)
216229

217230
spin_lock_irqsave(&dwc->lock, flags);
218231

219-
dwc3_set_prtcap(dwc, desired_dr_role);
232+
dwc3_set_prtcap(dwc, desired_dr_role, false);
220233

221234
spin_unlock_irqrestore(&dwc->lock, flags);
222235

@@ -658,16 +671,7 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
658671
*/
659672
reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX;
660673

661-
/*
662-
* Above DWC_usb3.0 1.94a, it is recommended to set
663-
* DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration.
664-
* So default value will be '0' when the core is reset. Application
665-
* needs to set it to '1' after the core initialization is completed.
666-
*
667-
* Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be
668-
* cleared after power-on reset, and it can be set after core
669-
* initialization.
670-
*/
674+
/* Ensure the GUSB3PIPECTL.SUSPENDENABLE is cleared prior to phy init. */
671675
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
672676

673677
if (dwc->u2ss_inp3_quirk)
@@ -747,15 +751,7 @@ static int dwc3_hs_phy_setup(struct dwc3 *dwc, int index)
747751
break;
748752
}
749753

750-
/*
751-
* Above DWC_usb3.0 1.94a, it is recommended to set
752-
* DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration.
753-
* So default value will be '0' when the core is reset. Application
754-
* needs to set it to '1' after the core initialization is completed.
755-
*
756-
* Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared
757-
* after power-on reset, and it can be set after core initialization.
758-
*/
754+
/* Ensure the GUSB2PHYCFG.SUSPHY is cleared prior to phy init. */
759755
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
760756

761757
if (dwc->dis_enblslpm_quirk)
@@ -830,6 +826,25 @@ static int dwc3_phy_init(struct dwc3 *dwc)
830826
goto err_exit_usb3_phy;
831827
}
832828

829+
/*
830+
* Above DWC_usb3.0 1.94a, it is recommended to set
831+
* DWC3_GUSB3PIPECTL_SUSPHY and DWC3_GUSB2PHYCFG_SUSPHY to '0' during
832+
* coreConsultant configuration. So default value will be '0' when the
833+
* core is reset. Application needs to set it to '1' after the core
834+
* initialization is completed.
835+
*
836+
* Certain phy requires to be in P0 power state during initialization.
837+
* Make sure GUSB3PIPECTL.SUSPENDENABLE and GUSB2PHYCFG.SUSPHY are clear
838+
* prior to phy init to maintain in the P0 state.
839+
*
840+
* After phy initialization, some phy operations can only be executed
841+
* while in lower P states. Ensure GUSB3PIPECTL.SUSPENDENABLE and
842+
* GUSB2PHYCFG.SUSPHY are set soon after initialization to avoid
843+
* blocking phy ops.
844+
*/
845+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
846+
dwc3_enable_susphy(dwc, true);
847+
833848
return 0;
834849

835850
err_exit_usb3_phy:
@@ -1588,7 +1603,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
15881603

15891604
switch (dwc->dr_mode) {
15901605
case USB_DR_MODE_PERIPHERAL:
1591-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
1606+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, false);
15921607

15931608
if (dwc->usb2_phy)
15941609
otg_set_vbus(dwc->usb2_phy->otg, false);
@@ -1600,7 +1615,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
16001615
return dev_err_probe(dev, ret, "failed to initialize gadget\n");
16011616
break;
16021617
case USB_DR_MODE_HOST:
1603-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
1618+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST, false);
16041619

16051620
if (dwc->usb2_phy)
16061621
otg_set_vbus(dwc->usb2_phy->otg, true);
@@ -1645,7 +1660,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
16451660
}
16461661

16471662
/* de-assert DRVVBUS for HOST and OTG mode */
1648-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
1663+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, true);
16491664
}
16501665

16511666
static void dwc3_get_software_properties(struct dwc3 *dwc)
@@ -1835,8 +1850,6 @@ static void dwc3_get_properties(struct dwc3 *dwc)
18351850
dwc->tx_thr_num_pkt_prd = tx_thr_num_pkt_prd;
18361851
dwc->tx_max_burst_prd = tx_max_burst_prd;
18371852

1838-
dwc->imod_interval = 0;
1839-
18401853
dwc->tx_fifo_resize_max_num = tx_fifo_resize_max_num;
18411854
}
18421855

@@ -1854,21 +1867,19 @@ static void dwc3_check_params(struct dwc3 *dwc)
18541867
unsigned int hwparam_gen =
18551868
DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3);
18561869

1857-
/* Check for proper value of imod_interval */
1858-
if (dwc->imod_interval && !dwc3_has_imod(dwc)) {
1859-
dev_warn(dwc->dev, "Interrupt moderation not supported\n");
1860-
dwc->imod_interval = 0;
1861-
}
1862-
18631870
/*
1871+
* Enable IMOD for all supporting controllers.
1872+
*
1873+
* Particularly, DWC_usb3 v3.00a must enable this feature for
1874+
* the following reason:
1875+
*
18641876
* Workaround for STAR 9000961433 which affects only version
18651877
* 3.00a of the DWC_usb3 core. This prevents the controller
18661878
* interrupt from being masked while handling events. IMOD
18671879
* allows us to work around this issue. Enable it for the
18681880
* affected version.
18691881
*/
1870-
if (!dwc->imod_interval &&
1871-
DWC3_VER_IS(DWC3, 300A))
1882+
if (dwc3_has_imod((dwc)))
18721883
dwc->imod_interval = 1;
18731884

18741885
/* Check the maximum_speed parameter */
@@ -2457,15 +2468,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
24572468
if (ret)
24582469
return ret;
24592470

2460-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
2471+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, true);
24612472
dwc3_gadget_resume(dwc);
24622473
break;
24632474
case DWC3_GCTL_PRTCAP_HOST:
24642475
if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) {
24652476
ret = dwc3_core_init_for_resume(dwc);
24662477
if (ret)
24672478
return ret;
2468-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
2479+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST, true);
24692480
break;
24702481
}
24712482
/* Restore GUSB2PHYCFG bits that were modified in suspend */
@@ -2494,7 +2505,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
24942505
if (ret)
24952506
return ret;
24962507

2497-
dwc3_set_prtcap(dwc, dwc->current_dr_role);
2508+
dwc3_set_prtcap(dwc, dwc->current_dr_role, true);
24982509

24992510
dwc3_otg_init(dwc);
25002511
if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) {

drivers/usb/dwc3/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ struct dwc3_gadget_ep_cmd_params {
15581558
#define DWC3_HAS_OTG BIT(3)
15591559

15601560
/* prototypes */
1561-
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode);
1561+
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode, bool ignore_susphy);
15621562
void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
15631563
u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type);
15641564

drivers/usb/dwc3/drd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void dwc3_otg_init(struct dwc3 *dwc)
173173
* block "Initialize GCTL for OTG operation".
174174
*/
175175
/* GCTL.PrtCapDir=2'b11 */
176-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG);
176+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG, true);
177177
/* GUSB2PHYCFG0.SusPHY=0 */
178178
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
179179
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
@@ -556,7 +556,7 @@ int dwc3_drd_init(struct dwc3 *dwc)
556556

557557
dwc3_drd_update(dwc);
558558
} else {
559-
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG);
559+
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG, true);
560560

561561
/* use OTG block to get ID event */
562562
irq = dwc3_otg_get_irq(dwc);

drivers/usb/dwc3/gadget.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4501,14 +4501,18 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
45014501
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
45024502
DWC3_GEVNTSIZ_SIZE(evt->length));
45034503

4504+
evt->flags &= ~DWC3_EVENT_PENDING;
4505+
/*
4506+
* Add an explicit write memory barrier to make sure that the update of
4507+
* clearing DWC3_EVENT_PENDING is observed in dwc3_check_event_buf()
4508+
*/
4509+
wmb();
4510+
45044511
if (dwc->imod_interval) {
45054512
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB);
45064513
dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
45074514
}
45084515

4509-
/* Keep the clearing of DWC3_EVENT_PENDING at the end */
4510-
evt->flags &= ~DWC3_EVENT_PENDING;
4511-
45124516
return ret;
45134517
}
45144518

drivers/usb/gadget/composite.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,10 +1050,11 @@ static int set_config(struct usb_composite_dev *cdev,
10501050
else
10511051
usb_gadget_set_remote_wakeup(gadget, 0);
10521052
done:
1053-
if (power <= USB_SELF_POWER_VBUS_MAX_DRAW)
1054-
usb_gadget_set_selfpowered(gadget);
1055-
else
1053+
if (power > USB_SELF_POWER_VBUS_MAX_DRAW ||
1054+
(c && !(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)))
10561055
usb_gadget_clear_selfpowered(gadget);
1056+
else
1057+
usb_gadget_set_selfpowered(gadget);
10571058

10581059
usb_gadget_vbus_draw(gadget, power);
10591060
if (result >= 0 && cdev->delayed_status)
@@ -2615,7 +2616,10 @@ void composite_suspend(struct usb_gadget *gadget)
26152616

26162617
cdev->suspended = 1;
26172618

2618-
usb_gadget_set_selfpowered(gadget);
2619+
if (cdev->config &&
2620+
cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
2621+
usb_gadget_set_selfpowered(gadget);
2622+
26192623
usb_gadget_vbus_draw(gadget, 2);
26202624
}
26212625

@@ -2649,8 +2653,11 @@ void composite_resume(struct usb_gadget *gadget)
26492653
else
26502654
maxpower = min(maxpower, 900U);
26512655

2652-
if (maxpower > USB_SELF_POWER_VBUS_MAX_DRAW)
2656+
if (maxpower > USB_SELF_POWER_VBUS_MAX_DRAW ||
2657+
!(cdev->config->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
26532658
usb_gadget_clear_selfpowered(gadget);
2659+
else
2660+
usb_gadget_set_selfpowered(gadget);
26542661

26552662
usb_gadget_vbus_draw(gadget, maxpower);
26562663
} else {

drivers/usb/gadget/function/u_ether.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,8 @@ void gether_suspend(struct gether *link)
10521052
* There is a transfer in progress. So we trigger a remote
10531053
* wakeup to inform the host.
10541054
*/
1055-
ether_wakeup_host(dev->port_usb);
1056-
return;
1055+
if (!ether_wakeup_host(dev->port_usb))
1056+
return;
10571057
}
10581058
spin_lock_irqsave(&dev->lock, flags);
10591059
link->is_suspend = true;

drivers/usb/host/xhci-hub.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/slab.h>
1313
#include <linux/unaligned.h>
1414
#include <linux/bitfield.h>
15+
#include <linux/pci.h>
1516

1617
#include "xhci.h"
1718
#include "xhci-trace.h"
@@ -770,9 +771,16 @@ static int xhci_exit_test_mode(struct xhci_hcd *xhci)
770771
enum usb_link_tunnel_mode xhci_port_is_tunneled(struct xhci_hcd *xhci,
771772
struct xhci_port *port)
772773
{
774+
struct usb_hcd *hcd;
773775
void __iomem *base;
774776
u32 offset;
775777

778+
/* Don't try and probe this capability for non-Intel hosts */
779+
hcd = xhci_to_hcd(xhci);
780+
if (!dev_is_pci(hcd->self.controller) ||
781+
to_pci_dev(hcd->self.controller)->vendor != PCI_VENDOR_ID_INTEL)
782+
return USB_LINK_UNKNOWN;
783+
776784
base = &xhci->cap_regs->hc_capbase;
777785
offset = xhci_find_next_ext_cap(base, 0, XHCI_EXT_CAPS_INTEL_SPR_SHADOW);
778786

0 commit comments

Comments
 (0)