Skip to content

Commit 30ceb4e

Browse files
committed
Merge tag 'usb-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a number of USB driver fixes for 3.12-rc3. These are all for host controller issues that have been reported, and there's a fix for an annoying error message that gets printed every time you remove a USB 3 device from the system that's been bugging me for a while" * tag 'usb-3.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: dwc3: add support for Merrifield USB: fsl/ehci: fix failure of checking PHY_CLK_VALID during reinitialization USB: Fix breakage in ffs_fs_mount() fsl/usb: Resolve PHY_CLK_VLD instability issue for ULPI phy usb/core/devio.c: Don't reject control message to endpoint with wrong direction bit usb: chipidea: USB_CHIPIDEA should depend on HAS_DMA usb: chipidea: udc: free pending TD at removal procedure usb: chipidea: imx: Add usb_phy_shutdown at probe's error path usb: chipidea: Fix memleak for ci->hw_bank.regmap when removal usb: chipidea: udc: fix the oops after rmmod gadget USB: fix PM config symbol in uhci-hcd, ehci-hcd, and xhci-hcd USB: OHCI: accept very late isochronous URBs USB: UHCI: accept very late isochronous URBs USB: iMX21: accept very late isochronous URBs usbcore: check usb device's state before sending a Set SEL control transfer xhci: Fix race between ep halt and URB cancellation usb: Fix xHCI host issues on remote wakeup. xhci: Ensure a command structure points to the correct trb on the command ring xhci: Fix oops happening after address device timeout
2 parents 26c019f + 85601f8 commit 30ceb4e

File tree

21 files changed

+201
-107
lines changed

21 files changed

+201
-107
lines changed

drivers/usb/chipidea/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
config USB_CHIPIDEA
22
tristate "ChipIdea Highspeed Dual Role Controller"
3-
depends on (USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)
3+
depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
44
help
55
Say Y here if your system has a dual role high speed USB
66
controller based on ChipIdea silicon IP. Currently, only the

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
131131
if (ret) {
132132
dev_err(&pdev->dev, "usbmisc init failed, ret=%d\n",
133133
ret);
134-
goto err_clk;
134+
goto err_phy;
135135
}
136136
}
137137

@@ -143,7 +143,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
143143
dev_err(&pdev->dev,
144144
"Can't register ci_hdrc platform device, err=%d\n",
145145
ret);
146-
goto err_clk;
146+
goto err_phy;
147147
}
148148

149149
if (data->usbmisc_data) {
@@ -164,6 +164,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
164164

165165
disable_device:
166166
ci_hdrc_remove_device(data->ci_pdev);
167+
err_phy:
168+
if (data->phy)
169+
usb_phy_shutdown(data->phy);
167170
err_clk:
168171
clk_disable_unprepare(data->clk);
169172
return ret;

drivers/usb/chipidea/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
605605
dbg_remove_files(ci);
606606
free_irq(ci->irq, ci);
607607
ci_role_destroy(ci);
608+
kfree(ci->hw_bank.regmap);
608609

609610
return 0;
610611
}

drivers/usb/chipidea/udc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,8 @@ static void destroy_eps(struct ci_hdrc *ci)
16001600
for (i = 0; i < ci->hw_ep_max; i++) {
16011601
struct ci_hw_ep *hwep = &ci->ci_hw_ep[i];
16021602

1603+
if (hwep->pending_td)
1604+
free_pending_td(hwep);
16031605
dma_pool_free(ci->qh_pool, hwep->qh.ptr, hwep->qh.dma);
16041606
}
16051607
}
@@ -1667,13 +1669,13 @@ static int ci_udc_stop(struct usb_gadget *gadget,
16671669
if (ci->platdata->notify_event)
16681670
ci->platdata->notify_event(ci,
16691671
CI_HDRC_CONTROLLER_STOPPED_EVENT);
1670-
ci->driver = NULL;
16711672
spin_unlock_irqrestore(&ci->lock, flags);
16721673
_gadget_stop_activity(&ci->gadget);
16731674
spin_lock_irqsave(&ci->lock, flags);
16741675
pm_runtime_put(&ci->gadget.dev);
16751676
}
16761677

1678+
ci->driver = NULL;
16771679
spin_unlock_irqrestore(&ci->lock, flags);
16781680

16791681
return 0;

drivers/usb/core/devio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,22 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
742742
if ((index & ~USB_DIR_IN) == 0)
743743
return 0;
744744
ret = findintfep(ps->dev, index);
745+
if (ret < 0) {
746+
/*
747+
* Some not fully compliant Win apps seem to get
748+
* index wrong and have the endpoint number here
749+
* rather than the endpoint address (with the
750+
* correct direction). Win does let this through,
751+
* so we'll not reject it here but leave it to
752+
* the device to not break KVM. But we warn.
753+
*/
754+
ret = findintfep(ps->dev, index ^ 0x80);
755+
if (ret >= 0)
756+
dev_info(&ps->dev->dev,
757+
"%s: process %i (%s) requesting ep %02x but needs %02x\n",
758+
__func__, task_pid_nr(current),
759+
current->comm, index, index ^ 0x80);
760+
}
745761
if (ret >= 0)
746762
ret = checkintf(ps, ret);
747763
break;

drivers/usb/core/hub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,9 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state)
34263426
unsigned long long u2_pel;
34273427
int ret;
34283428

3429+
if (udev->state != USB_STATE_CONFIGURED)
3430+
return 0;
3431+
34293432
/* Convert SEL and PEL stored in ns to us */
34303433
u1_sel = DIV_ROUND_UP(udev->u1_params.sel, 1000);
34313434
u1_pel = DIV_ROUND_UP(udev->u1_params.pel, 1000);

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define PCI_VENDOR_ID_SYNOPSYS 0x16c3
3030
#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
3131
#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
32+
#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
3233

3334
struct dwc3_pci {
3435
struct device *dev;
@@ -189,6 +190,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = {
189190
PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
190191
},
191192
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
193+
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
192194
{ } /* Terminating Entry */
193195
};
194196
MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);

drivers/usb/gadget/f_fs.c

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,37 +1034,19 @@ struct ffs_sb_fill_data {
10341034
struct ffs_file_perms perms;
10351035
umode_t root_mode;
10361036
const char *dev_name;
1037-
union {
1038-
/* set by ffs_fs_mount(), read by ffs_sb_fill() */
1039-
void *private_data;
1040-
/* set by ffs_sb_fill(), read by ffs_fs_mount */
1041-
struct ffs_data *ffs_data;
1042-
};
1037+
struct ffs_data *ffs_data;
10431038
};
10441039

10451040
static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
10461041
{
10471042
struct ffs_sb_fill_data *data = _data;
10481043
struct inode *inode;
1049-
struct ffs_data *ffs;
1044+
struct ffs_data *ffs = data->ffs_data;
10501045

10511046
ENTER();
10521047

1053-
/* Initialise data */
1054-
ffs = ffs_data_new();
1055-
if (unlikely(!ffs))
1056-
goto Enomem;
1057-
10581048
ffs->sb = sb;
1059-
ffs->dev_name = kstrdup(data->dev_name, GFP_KERNEL);
1060-
if (unlikely(!ffs->dev_name))
1061-
goto Enomem;
1062-
ffs->file_perms = data->perms;
1063-
ffs->private_data = data->private_data;
1064-
1065-
/* used by the caller of this function */
1066-
data->ffs_data = ffs;
1067-
1049+
data->ffs_data = NULL;
10681050
sb->s_fs_info = ffs;
10691051
sb->s_blocksize = PAGE_CACHE_SIZE;
10701052
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
@@ -1080,17 +1062,14 @@ static int ffs_sb_fill(struct super_block *sb, void *_data, int silent)
10801062
&data->perms);
10811063
sb->s_root = d_make_root(inode);
10821064
if (unlikely(!sb->s_root))
1083-
goto Enomem;
1065+
return -ENOMEM;
10841066

10851067
/* EP0 file */
10861068
if (unlikely(!ffs_sb_create_file(sb, "ep0", ffs,
10871069
&ffs_ep0_operations, NULL)))
1088-
goto Enomem;
1070+
return -ENOMEM;
10891071

10901072
return 0;
1091-
1092-
Enomem:
1093-
return -ENOMEM;
10941073
}
10951074

10961075
static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
@@ -1193,25 +1172,38 @@ ffs_fs_mount(struct file_system_type *t, int flags,
11931172
struct dentry *rv;
11941173
int ret;
11951174
void *ffs_dev;
1175+
struct ffs_data *ffs;
11961176

11971177
ENTER();
11981178

11991179
ret = ffs_fs_parse_opts(&data, opts);
12001180
if (unlikely(ret < 0))
12011181
return ERR_PTR(ret);
12021182

1183+
ffs = ffs_data_new();
1184+
if (unlikely(!ffs))
1185+
return ERR_PTR(-ENOMEM);
1186+
ffs->file_perms = data.perms;
1187+
1188+
ffs->dev_name = kstrdup(dev_name, GFP_KERNEL);
1189+
if (unlikely(!ffs->dev_name)) {
1190+
ffs_data_put(ffs);
1191+
return ERR_PTR(-ENOMEM);
1192+
}
1193+
12031194
ffs_dev = functionfs_acquire_dev_callback(dev_name);
1204-
if (IS_ERR(ffs_dev))
1205-
return ffs_dev;
1195+
if (IS_ERR(ffs_dev)) {
1196+
ffs_data_put(ffs);
1197+
return ERR_CAST(ffs_dev);
1198+
}
1199+
ffs->private_data = ffs_dev;
1200+
data.ffs_data = ffs;
12061201

1207-
data.dev_name = dev_name;
1208-
data.private_data = ffs_dev;
12091202
rv = mount_nodev(t, flags, &data, ffs_sb_fill);
1210-
1211-
/* data.ffs_data is set by ffs_sb_fill */
1212-
if (IS_ERR(rv))
1203+
if (IS_ERR(rv) && data.ffs_data) {
12131204
functionfs_release_dev_callback(data.ffs_data);
1214-
1205+
ffs_data_put(data.ffs_data);
1206+
}
12151207
return rv;
12161208
}
12171209

drivers/usb/host/ehci-fsl.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
130130
}
131131

132132
/* Enable USB controller, 83xx or 8536 */
133-
if (pdata->have_sysif_regs)
133+
if (pdata->have_sysif_regs && pdata->controller_ver < FSL_USB_VER_1_6)
134134
setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
135135

136136
/* Don't need to set host mode here. It will be done by tdi_reset() */
@@ -232,15 +232,9 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
232232
case FSL_USB2_PHY_ULPI:
233233
if (pdata->have_sysif_regs && pdata->controller_ver) {
234234
/* controller version 1.6 or above */
235+
clrbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN);
235236
setbits32(non_ehci + FSL_SOC_USB_CTRL,
236-
ULPI_PHY_CLK_SEL);
237-
/*
238-
* Due to controller issue of PHY_CLK_VALID in ULPI
239-
* mode, we set USB_CTRL_USB_EN before checking
240-
* PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work.
241-
*/
242-
clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL,
243-
UTMI_PHY_EN, USB_CTRL_USB_EN);
237+
ULPI_PHY_CLK_SEL | USB_CTRL_USB_EN);
244238
}
245239
portsc |= PORT_PTS_ULPI;
246240
break;
@@ -270,8 +264,9 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
270264
if (pdata->have_sysif_regs && pdata->controller_ver &&
271265
(phy_mode == FSL_USB2_PHY_ULPI)) {
272266
/* check PHY_CLK_VALID to get phy clk valid */
273-
if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) &
274-
PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) {
267+
if (!(spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) &
268+
PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0) ||
269+
in_be32(non_ehci + FSL_SOC_USB_PRICTRL))) {
275270
printk(KERN_WARNING "fsl-ehci: USB PHY clock invalid\n");
276271
return -EINVAL;
277272
}

drivers/usb/host/ehci-pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static struct pci_driver ehci_pci_driver = {
361361
.remove = usb_hcd_pci_remove,
362362
.shutdown = usb_hcd_pci_shutdown,
363363

364-
#ifdef CONFIG_PM_SLEEP
364+
#ifdef CONFIG_PM
365365
.driver = {
366366
.pm = &usb_hcd_pci_pm_ops
367367
},

drivers/usb/host/imx21-hcd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,13 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
824824
i = DIV_ROUND_UP(wrap_frame(
825825
cur_frame - urb->start_frame),
826826
urb->interval);
827-
if (urb->transfer_flags & URB_ISO_ASAP) {
827+
828+
/* Treat underruns as if URB_ISO_ASAP was set */
829+
if ((urb->transfer_flags & URB_ISO_ASAP) ||
830+
i >= urb->number_of_packets) {
828831
urb->start_frame = wrap_frame(urb->start_frame
829832
+ i * urb->interval);
830833
i = 0;
831-
} else if (i >= urb->number_of_packets) {
832-
ret = -EXDEV;
833-
goto alloc_dmem_failed;
834834
}
835835
}
836836
}

drivers/usb/host/ohci-hcd.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,31 +216,26 @@ static int ohci_urb_enqueue (
216216
frame &= ~(ed->interval - 1);
217217
frame |= ed->branch;
218218
urb->start_frame = frame;
219+
ed->last_iso = frame + ed->interval * (size - 1);
219220
}
220221
} else if (ed->type == PIPE_ISOCHRONOUS) {
221222
u16 next = ohci_frame_no(ohci) + 1;
222223
u16 frame = ed->last_iso + ed->interval;
224+
u16 length = ed->interval * (size - 1);
223225

224226
/* Behind the scheduling threshold? */
225227
if (unlikely(tick_before(frame, next))) {
226228

227-
/* USB_ISO_ASAP: Round up to the first available slot */
229+
/* URB_ISO_ASAP: Round up to the first available slot */
228230
if (urb->transfer_flags & URB_ISO_ASAP) {
229231
frame += (next - frame + ed->interval - 1) &
230232
-ed->interval;
231233

232234
/*
233-
* Not ASAP: Use the next slot in the stream. If
234-
* the entire URB falls before the threshold, fail.
235+
* Not ASAP: Use the next slot in the stream,
236+
* no matter what.
235237
*/
236238
} else {
237-
if (tick_before(frame + ed->interval *
238-
(urb->number_of_packets - 1), next)) {
239-
retval = -EXDEV;
240-
usb_hcd_unlink_urb_from_ep(hcd, urb);
241-
goto fail;
242-
}
243-
244239
/*
245240
* Some OHCI hardware doesn't handle late TDs
246241
* correctly. After retiring them it proceeds
@@ -251,9 +246,16 @@ static int ohci_urb_enqueue (
251246
urb_priv->td_cnt = DIV_ROUND_UP(
252247
(u16) (next - frame),
253248
ed->interval);
249+
if (urb_priv->td_cnt >= urb_priv->length) {
250+
++urb_priv->td_cnt; /* Mark it */
251+
ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n",
252+
urb, frame, length,
253+
next);
254+
}
254255
}
255256
}
256257
urb->start_frame = frame;
258+
ed->last_iso = frame + length;
257259
}
258260

259261
/* fill the TDs and link them to the ed; and

0 commit comments

Comments
 (0)