Skip to content

Commit 46df55c

Browse files
committed
Merge tag 'usb-4.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some USB fixes for 4.5-rc3. The usual, xhci fixes for reported issues, combined with some small gadget driver fixes, and a MAINTAINERS file update. All have been in linux-next with no reported issues" * tag 'usb-4.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: xhci: harden xhci_find_next_ext_cap against device removal xhci: Fix list corruption in urb dequeue at host removal usb: host: xhci-plat: fix NULL pointer in probe for device tree case usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling usb: xhci-mtk: fix bpkts value of LS/HS periodic eps not behind TT usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Broxton-M platforms usb: xhci: set SSIC port unused only if xhci_suspend succeeds usb: xhci: add a quirk bit for ssic port unused usb: xhci: handle both SSIC ports in PME stuck quirk usb: dwc3: gadget: set the OTG flag in dwc3 gadget driver. Revert "xhci: don't finish a TD if we get a short-transfer event mid TD" MAINTAINERS: fix my email address usb: dwc2: Fix probe problem on bcm2835 Revert "usb: dwc2: Move reset into dwc2_get_hwparams()" usb: musb: ux500: Fix NULL pointer dereference at system PM usb: phy: mxs: declare variable with initialized value usb: phy: msm: fix error handling in probe.
2 parents dacd53c + 89140fd commit 46df55c

15 files changed

+131
-65
lines changed

MAINTAINERS

+5-5
Original file line numberDiff line numberDiff line change
@@ -3450,7 +3450,7 @@ S: Maintained
34503450
F: drivers/usb/dwc2/
34513451

34523452
DESIGNWARE USB3 DRD IP DRIVER
3453-
M: Felipe Balbi <balbi@ti.com>
3453+
M: Felipe Balbi <balbi@kernel.org>
34543454
34553455
34563456
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
@@ -7362,7 +7362,7 @@ F: drivers/tty/isicom.c
73627362
F: include/linux/isicom.h
73637363

73647364
MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
7365-
M: Felipe Balbi <balbi@ti.com>
7365+
M: Felipe Balbi <balbi@kernel.org>
73667366
73677367
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
73687368
S: Maintained
@@ -7931,7 +7931,7 @@ F: drivers/media/platform/omap3isp/
79317931
F: drivers/staging/media/omap4iss/
79327932

79337933
OMAP USB SUPPORT
7934-
M: Felipe Balbi <balbi@ti.com>
7934+
M: Felipe Balbi <balbi@kernel.org>
79357935
79367936
79377937
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
@@ -11314,7 +11314,7 @@ F: Documentation/usb/ehci.txt
1131411314
F: drivers/usb/host/ehci*
1131511315

1131611316
USB GADGET/PERIPHERAL SUBSYSTEM
11317-
M: Felipe Balbi <balbi@ti.com>
11317+
M: Felipe Balbi <balbi@kernel.org>
1131811318
1131911319
W: http://www.linux-usb.org/gadget
1132011320
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
@@ -11390,7 +11390,7 @@ S: Maintained
1139011390
F: drivers/net/usb/pegasus.*
1139111391

1139211392
USB PHY LAYER
11393-
M: Felipe Balbi <balbi@ti.com>
11393+
M: Felipe Balbi <balbi@kernel.org>
1139411394
1139511395
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
1139611396
S: Maintained

drivers/usb/dwc2/core.c

-14
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,6 @@ static bool dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host)
572572
set = host ? GUSBCFG_FORCEHOSTMODE : GUSBCFG_FORCEDEVMODE;
573573
clear = host ? GUSBCFG_FORCEDEVMODE : GUSBCFG_FORCEHOSTMODE;
574574

575-
/*
576-
* If the force mode bit is already set, don't set it.
577-
*/
578-
if ((gusbcfg & set) && !(gusbcfg & clear))
579-
return false;
580-
581575
gusbcfg &= ~clear;
582576
gusbcfg |= set;
583577
dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
@@ -3278,17 +3272,13 @@ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg)
32783272
/**
32793273
* During device initialization, read various hardware configuration
32803274
* registers and interpret the contents.
3281-
*
3282-
* This should be called during driver probe. It will perform a core
3283-
* soft reset in order to get the reset values of the parameters.
32843275
*/
32853276
int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
32863277
{
32873278
struct dwc2_hw_params *hw = &hsotg->hw_params;
32883279
unsigned width;
32893280
u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4;
32903281
u32 grxfsiz;
3291-
int retval;
32923282

32933283
/*
32943284
* Attempt to ensure this device is really a DWC_otg Controller.
@@ -3308,10 +3298,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
33083298
hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
33093299
hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
33103300

3311-
retval = dwc2_core_reset(hsotg);
3312-
if (retval)
3313-
return retval;
3314-
33153301
hwcfg1 = dwc2_readl(hsotg->regs + GHWCFG1);
33163302
hwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2);
33173303
hwcfg3 = dwc2_readl(hsotg->regs + GHWCFG3);

drivers/usb/dwc2/platform.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,13 @@ static int dwc2_driver_probe(struct platform_device *dev)
530530
if (retval)
531531
return retval;
532532

533-
/* Reset the controller and detect hardware config values */
533+
/*
534+
* Reset before dwc2_get_hwparams() then it could get power-on real
535+
* reset value form registers.
536+
*/
537+
dwc2_core_reset_and_force_dr_mode(hsotg);
538+
539+
/* Detect config values from hardware */
534540
retval = dwc2_get_hwparams(hsotg);
535541
if (retval)
536542
goto error;

drivers/usb/dwc3/gadget.c

+1
Original file line numberDiff line numberDiff line change
@@ -2789,6 +2789,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
27892789
dwc->gadget.speed = USB_SPEED_UNKNOWN;
27902790
dwc->gadget.sg_supported = true;
27912791
dwc->gadget.name = "dwc3-gadget";
2792+
dwc->gadget.is_otg = dwc->dr_mode == USB_DR_MODE_OTG;
27922793

27932794
/*
27942795
* FIXME We might be setting max_speed to <SUPER, however versions

drivers/usb/host/xhci-ext-caps.h

+4
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ static inline int xhci_find_next_ext_cap(void __iomem *base, u32 start, int id)
112112
offset = start;
113113
if (!start || start == XHCI_HCC_PARAMS_OFFSET) {
114114
val = readl(base + XHCI_HCC_PARAMS_OFFSET);
115+
if (val == ~0)
116+
return 0;
115117
offset = XHCI_HCC_EXT_CAPS(val) << 2;
116118
if (!offset)
117119
return 0;
118120
};
119121
do {
120122
val = readl(base + offset);
123+
if (val == ~0)
124+
return 0;
121125
if (XHCI_EXT_CAPS_ID(val) == id && offset != start)
122126
return offset;
123127

drivers/usb/host/xhci-mtk-sch.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,9 @@ static bool need_bw_sch(struct usb_host_endpoint *ep,
275275
return false;
276276

277277
/*
278-
* for LS & FS periodic endpoints which its device don't attach
279-
* to TT are also ignored, root-hub will schedule them directly
278+
* for LS & FS periodic endpoints which its device is not behind
279+
* a TT are also ignored, root-hub will schedule them directly,
280+
* but need set @bpkts field of endpoint context to 1.
280281
*/
281282
if (is_fs_or_ls(speed) && !has_tt)
282283
return false;
@@ -339,8 +340,17 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
339340
GET_MAX_PACKET(usb_endpoint_maxp(&ep->desc)),
340341
usb_endpoint_dir_in(&ep->desc), ep);
341342

342-
if (!need_bw_sch(ep, udev->speed, slot_ctx->tt_info & TT_SLOT))
343+
if (!need_bw_sch(ep, udev->speed, slot_ctx->tt_info & TT_SLOT)) {
344+
/*
345+
* set @bpkts to 1 if it is LS or FS periodic endpoint, and its
346+
* device does not connected through an external HS hub
347+
*/
348+
if (usb_endpoint_xfer_int(&ep->desc)
349+
|| usb_endpoint_xfer_isoc(&ep->desc))
350+
ep_ctx->reserved[0] |= cpu_to_le32(EP_BPKTS(1));
351+
343352
return 0;
353+
}
344354

345355
bw_index = get_bw_index(xhci, udev, ep);
346356
sch_bw = &sch_array[bw_index];

drivers/usb/host/xhci-mtk.c

+23
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,24 @@ static int xhci_mtk_remove(struct platform_device *dev)
696696
}
697697

698698
#ifdef CONFIG_PM_SLEEP
699+
/*
700+
* if ip sleep fails, and all clocks are disabled, access register will hang
701+
* AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
702+
* and no need to check whether ip sleep failed or not; this will cause SPM
703+
* to wake up system immediately after system suspend complete if ip sleep
704+
* fails, it is what we wanted.
705+
*/
699706
static int xhci_mtk_suspend(struct device *dev)
700707
{
701708
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
709+
struct usb_hcd *hcd = mtk->hcd;
710+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
711+
712+
xhci_dbg(xhci, "%s: stop port polling\n", __func__);
713+
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
714+
del_timer_sync(&hcd->rh_timer);
715+
clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
716+
del_timer_sync(&xhci->shared_hcd->rh_timer);
702717

703718
xhci_mtk_host_disable(mtk);
704719
xhci_mtk_phy_power_off(mtk);
@@ -710,11 +725,19 @@ static int xhci_mtk_suspend(struct device *dev)
710725
static int xhci_mtk_resume(struct device *dev)
711726
{
712727
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
728+
struct usb_hcd *hcd = mtk->hcd;
729+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
713730

714731
usb_wakeup_disable(mtk);
715732
xhci_mtk_clks_enable(mtk);
716733
xhci_mtk_phy_power_on(mtk);
717734
xhci_mtk_host_enable(mtk);
735+
736+
xhci_dbg(xhci, "%s: restart port polling\n", __func__);
737+
set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
738+
usb_hcd_poll_rh_status(hcd);
739+
set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
740+
usb_hcd_poll_rh_status(xhci->shared_hcd);
718741
return 0;
719742
}
720743

drivers/usb/host/xhci-pci.c

+42-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include "xhci.h"
2929
#include "xhci-trace.h"
3030

31-
#define PORT2_SSIC_CONFIG_REG2 0x883c
31+
#define SSIC_PORT_NUM 2
32+
#define SSIC_PORT_CFG2 0x880c
33+
#define SSIC_PORT_CFG2_OFFSET 0x30
3234
#define PROG_DONE (1 << 30)
3335
#define SSIC_PORT_UNUSED (1 << 31)
3436

@@ -45,6 +47,7 @@
4547
#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
4648
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
4749
#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
50+
#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
4851

4952
static const char hcd_name[] = "xhci_hcd";
5053

@@ -151,9 +154,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
151154
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
152155
(pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
153156
pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
154-
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI)) {
157+
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
158+
pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI)) {
155159
xhci->quirks |= XHCI_PME_STUCK_QUIRK;
156160
}
161+
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
162+
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
163+
xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
164+
}
157165
if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
158166
pdev->device == PCI_DEVICE_ID_EJ168) {
159167
xhci->quirks |= XHCI_RESET_ON_RESUME;
@@ -312,22 +320,20 @@ static void xhci_pci_remove(struct pci_dev *dev)
312320
* SSIC PORT need to be marked as "unused" before putting xHCI
313321
* into D3. After D3 exit, the SSIC port need to be marked as "used".
314322
* Without this change, xHCI might not enter D3 state.
315-
* Make sure PME works on some Intel xHCI controllers by writing 1 to clear
316-
* the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
317323
*/
318-
static void xhci_pme_quirk(struct usb_hcd *hcd, bool suspend)
324+
static void xhci_ssic_port_unused_quirk(struct usb_hcd *hcd, bool suspend)
319325
{
320326
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
321-
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
322327
u32 val;
323328
void __iomem *reg;
329+
int i;
324330

325-
if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
326-
pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
327-
328-
reg = (void __iomem *) xhci->cap_regs + PORT2_SSIC_CONFIG_REG2;
331+
for (i = 0; i < SSIC_PORT_NUM; i++) {
332+
reg = (void __iomem *) xhci->cap_regs +
333+
SSIC_PORT_CFG2 +
334+
i * SSIC_PORT_CFG2_OFFSET;
329335

330-
/* Notify SSIC that SSIC profile programming is not done */
336+
/* Notify SSIC that SSIC profile programming is not done. */
331337
val = readl(reg) & ~PROG_DONE;
332338
writel(val, reg);
333339

@@ -344,6 +350,17 @@ static void xhci_pme_quirk(struct usb_hcd *hcd, bool suspend)
344350
writel(val, reg);
345351
readl(reg);
346352
}
353+
}
354+
355+
/*
356+
* Make sure PME works on some Intel xHCI controllers by writing 1 to clear
357+
* the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
358+
*/
359+
static void xhci_pme_quirk(struct usb_hcd *hcd)
360+
{
361+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
362+
void __iomem *reg;
363+
u32 val;
347364

348365
reg = (void __iomem *) xhci->cap_regs + 0x80a4;
349366
val = readl(reg);
@@ -355,6 +372,7 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
355372
{
356373
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
357374
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
375+
int ret;
358376

359377
/*
360378
* Systems with the TI redriver that loses port status change events
@@ -364,9 +382,16 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
364382
pdev->no_d3cold = true;
365383

366384
if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
367-
xhci_pme_quirk(hcd, true);
385+
xhci_pme_quirk(hcd);
386+
387+
if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
388+
xhci_ssic_port_unused_quirk(hcd, true);
368389

369-
return xhci_suspend(xhci, do_wakeup);
390+
ret = xhci_suspend(xhci, do_wakeup);
391+
if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
392+
xhci_ssic_port_unused_quirk(hcd, false);
393+
394+
return ret;
370395
}
371396

372397
static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
@@ -396,8 +421,11 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
396421
if (pdev->vendor == PCI_VENDOR_ID_INTEL)
397422
usb_enable_intel_xhci_ports(pdev);
398423

424+
if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
425+
xhci_ssic_port_unused_quirk(hcd, false);
426+
399427
if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
400-
xhci_pme_quirk(hcd, false);
428+
xhci_pme_quirk(hcd);
401429

402430
retval = xhci_resume(xhci, hibernated);
403431
return retval;

drivers/usb/host/xhci-plat.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static int xhci_plat_probe(struct platform_device *pdev)
184184
struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
185185

186186
/* Just copy data for now */
187-
*priv = *priv_match;
187+
if (priv_match)
188+
*priv = *priv_match;
188189
}
189190

190191
if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) {

drivers/usb/host/xhci-ring.c

-10
Original file line numberDiff line numberDiff line change
@@ -2193,10 +2193,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
21932193
}
21942194
/* Fast path - was this the last TRB in the TD for this URB? */
21952195
} else if (event_trb == td->last_trb) {
2196-
if (td->urb_length_set && trb_comp_code == COMP_SHORT_TX)
2197-
return finish_td(xhci, td, event_trb, event, ep,
2198-
status, false);
2199-
22002196
if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) {
22012197
td->urb->actual_length =
22022198
td->urb->transfer_buffer_length -
@@ -2248,12 +2244,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
22482244
td->urb->actual_length +=
22492245
TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) -
22502246
EVENT_TRB_LEN(le32_to_cpu(event->transfer_len));
2251-
2252-
if (trb_comp_code == COMP_SHORT_TX) {
2253-
xhci_dbg(xhci, "mid bulk/intr SP, wait for last TRB event\n");
2254-
td->urb_length_set = true;
2255-
return 0;
2256-
}
22572247
}
22582248

22592249
return finish_td(xhci, td, event_trb, event, ep, status, false);

drivers/usb/host/xhci.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
15541554
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
15551555
"HW died, freeing TD.");
15561556
urb_priv = urb->hcpriv;
1557-
for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {
1557+
for (i = urb_priv->td_cnt;
1558+
i < urb_priv->length && xhci->devs[urb->dev->slot_id];
1559+
i++) {
15581560
td = urb_priv->td[i];
15591561
if (!list_empty(&td->td_list))
15601562
list_del_init(&td->td_list);

drivers/usb/host/xhci.h

+1
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,7 @@ struct xhci_hcd {
16311631
#define XHCI_BROKEN_STREAMS (1 << 19)
16321632
#define XHCI_PME_STUCK_QUIRK (1 << 20)
16331633
#define XHCI_MTK_HOST (1 << 21)
1634+
#define XHCI_SSIC_PORT_UNUSED (1 << 22)
16341635
unsigned int num_active_eps;
16351636
unsigned int limit_active_eps;
16361637
/* There are two roothubs to keep track of bus suspend info for */

drivers/usb/musb/ux500.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ static int ux500_suspend(struct device *dev)
348348
struct ux500_glue *glue = dev_get_drvdata(dev);
349349
struct musb *musb = glue_to_musb(glue);
350350

351-
usb_phy_set_suspend(musb->xceiv, 1);
351+
if (musb)
352+
usb_phy_set_suspend(musb->xceiv, 1);
353+
352354
clk_disable_unprepare(glue->clk);
353355

354356
return 0;
@@ -366,7 +368,8 @@ static int ux500_resume(struct device *dev)
366368
return ret;
367369
}
368370

369-
usb_phy_set_suspend(musb->xceiv, 0);
371+
if (musb)
372+
usb_phy_set_suspend(musb->xceiv, 0);
370373

371374
return 0;
372375
}

0 commit comments

Comments
 (0)