aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-04-16 13:33:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-04-16 13:33:13 -0400
commit08150c533c57981054324b9e87dbf686006d890f (patch)
treea34c14f9a4d02b3d40179314d510b5efd0a41fb0 /drivers
parentfdfc552abe2c465ab91b84fb65f36d86c6737ab4 (diff)
parent753d8534cc190ed144caebc2ea49ab7a43dca662 (diff)
Merge branch 'usb-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* 'usb-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (43 commits) Revert "USB: isp1760-hcd: move imask clear after pending work is done" xHCI: Implement AMD PLL quirk xhci: Tell USB core both roothubs lost power. usbcore: Bug fix: system can't suspend with USB3.0 device connected to USB3.0 hub USB: Fix unplug of device with active streams USB: xhci - also free streams when resetting devices xhci: Fix NULL pointer deref in handle_port_status() USB: xhci - fix math in xhci_get_endpoint_interval() USB: xhci: simplify logic of skipping missed isoc TDs USB: xhci - remove excessive 'inline' markings USB: xhci: unsigned char never equals -1 USB: xhci - fix unsafe macro definitions USB: fix formatting of SuperSpeed endpoints in /proc/bus/usb/devices USB: isp1760-hcd: move imask clear after pending work is done USB: fsl_qe_udc: send ZLP when zero flag and length % maxpacket == 0 usb: qcserial add missing errorpath kfrees usb: qcserial avoid pointing to freed memory usb: Fix qcserial memory leak on rmmod USB: ftdi_sio: add ids for Hameg HO720 and HO730 USB: option: Added support for Samsung GT-B3730/GT-B3710 LTE USB modem. ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/core/devices.c10
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hub.c12
-rw-r--r--drivers/usb/gadget/f_audio.c1
-rw-r--r--drivers/usb/gadget/f_eem.c8
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c20
-rw-r--r--drivers/usb/gadget/inode.c4
-rw-r--r--drivers/usb/gadget/pch_udc.c8
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c2
-rw-r--r--drivers/usb/host/ehci-q.c15
-rw-r--r--drivers/usb/host/isp1760-hcd.c2
-rw-r--r--drivers/usb/host/ohci-au1xxx.c2
-rw-r--r--drivers/usb/host/pci-quirks.c117
-rw-r--r--drivers/usb/host/xhci-mem.c106
-rw-r--r--drivers/usb/host/xhci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c219
-rw-r--r--drivers/usb/host/xhci.c23
-rw-r--r--drivers/usb/host/xhci.h11
-rw-r--r--drivers/usb/musb/Kconfig6
-rw-r--r--drivers/usb/musb/blackfin.c24
-rw-r--r--drivers/usb/musb/cppi_dma.c27
-rw-r--r--drivers/usb/musb/musb_core.c2
-rw-r--r--drivers/usb/musb/musb_core.h5
-rw-r--r--drivers/usb/musb/musb_gadget.c4
-rw-r--r--drivers/usb/musb/musbhsdma.c8
-rw-r--r--drivers/usb/musb/omap2430.c3
-rw-r--r--drivers/usb/musb/ux500.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c5
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h12
-rw-r--r--drivers/usb/serial/option.c5
-rw-r--r--drivers/usb/serial/qcserial.c31
32 files changed, 483 insertions, 218 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 41b6e51188e..006489d82dc 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -66,6 +66,7 @@ config USB_ARCH_HAS_EHCI
66 default y if ARCH_VT8500 66 default y if ARCH_VT8500
67 default y if PLAT_SPEAR 67 default y if PLAT_SPEAR
68 default y if ARCH_MSM 68 default y if ARCH_MSM
69 default y if MICROBLAZE
69 default PCI 70 default PCI
70 71
71# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. 72# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index a3d2e239965..96fdfb815f8 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -221,7 +221,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
221 break; 221 break;
222 case USB_ENDPOINT_XFER_INT: 222 case USB_ENDPOINT_XFER_INT:
223 type = "Int."; 223 type = "Int.";
224 if (speed == USB_SPEED_HIGH) 224 if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER)
225 interval = 1 << (desc->bInterval - 1); 225 interval = 1 << (desc->bInterval - 1);
226 else 226 else
227 interval = desc->bInterval; 227 interval = desc->bInterval;
@@ -229,7 +229,8 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end,
229 default: /* "can't happen" */ 229 default: /* "can't happen" */
230 return start; 230 return start;
231 } 231 }
232 interval *= (speed == USB_SPEED_HIGH) ? 125 : 1000; 232 interval *= (speed == USB_SPEED_HIGH ||
233 speed == USB_SPEED_SUPER) ? 125 : 1000;
233 if (interval % 1000) 234 if (interval % 1000)
234 unit = 'u'; 235 unit = 'u';
235 else { 236 else {
@@ -542,8 +543,9 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
542 if (level == 0) { 543 if (level == 0) {
543 int max; 544 int max;
544 545
545 /* high speed reserves 80%, full/low reserves 90% */ 546 /* super/high speed reserves 80%, full/low reserves 90% */
546 if (usbdev->speed == USB_SPEED_HIGH) 547 if (usbdev->speed == USB_SPEED_HIGH ||
548 usbdev->speed == USB_SPEED_SUPER)
547 max = 800; 549 max = 800;
548 else 550 else
549 max = FRAME_TIME_MAX_USECS_ALLOC; 551 max = FRAME_TIME_MAX_USECS_ALLOC;
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8eed05d2383..77a7faec8d7 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1908,7 +1908,7 @@ void usb_free_streams(struct usb_interface *interface,
1908 1908
1909 /* Streams only apply to bulk endpoints. */ 1909 /* Streams only apply to bulk endpoints. */
1910 for (i = 0; i < num_eps; i++) 1910 for (i = 0; i < num_eps; i++)
1911 if (!usb_endpoint_xfer_bulk(&eps[i]->desc)) 1911 if (!eps[i] || !usb_endpoint_xfer_bulk(&eps[i]->desc))
1912 return; 1912 return;
1913 1913
1914 hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags); 1914 hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 8fb754916c6..93720bdc9ef 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2285,7 +2285,17 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2285 } 2285 }
2286 2286
2287 /* see 7.1.7.6 */ 2287 /* see 7.1.7.6 */
2288 status = set_port_feature(hub->hdev, port1, USB_PORT_FEAT_SUSPEND); 2288 /* Clear PORT_POWER if it's a USB3.0 device connected to USB 3.0
2289 * external hub.
2290 * FIXME: this is a temporary workaround to make the system able
2291 * to suspend/resume.
2292 */
2293 if ((hub->hdev->parent != NULL) && hub_is_superspeed(hub->hdev))
2294 status = clear_port_feature(hub->hdev, port1,
2295 USB_PORT_FEAT_POWER);
2296 else
2297 status = set_port_feature(hub->hdev, port1,
2298 USB_PORT_FEAT_SUSPEND);
2289 if (status) { 2299 if (status) {
2290 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n", 2300 dev_dbg(hub->intfdev, "can't suspend port %d, status %d\n",
2291 port1, status); 2301 port1, status);
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c
index 9abecfddb27..0111f8a9cf7 100644
--- a/drivers/usb/gadget/f_audio.c
+++ b/drivers/usb/gadget/f_audio.c
@@ -706,6 +706,7 @@ f_audio_unbind(struct usb_configuration *c, struct usb_function *f)
706 struct f_audio *audio = func_to_audio(f); 706 struct f_audio *audio = func_to_audio(f);
707 707
708 usb_free_descriptors(f->descriptors); 708 usb_free_descriptors(f->descriptors);
709 usb_free_descriptors(f->hs_descriptors);
709 kfree(audio); 710 kfree(audio);
710} 711}
711 712
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index 95dd4662d6a..b3c30429015 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -314,6 +314,9 @@ eem_unbind(struct usb_configuration *c, struct usb_function *f)
314 314
315static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req) 315static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req)
316{ 316{
317 struct sk_buff *skb = (struct sk_buff *)req->context;
318
319 dev_kfree_skb_any(skb);
317} 320}
318 321
319/* 322/*
@@ -428,10 +431,11 @@ static int eem_unwrap(struct gether *port,
428 skb_trim(skb2, len); 431 skb_trim(skb2, len);
429 put_unaligned_le16(BIT(15) | BIT(11) | len, 432 put_unaligned_le16(BIT(15) | BIT(11) | len,
430 skb_push(skb2, 2)); 433 skb_push(skb2, 2));
431 skb_copy_bits(skb, 0, req->buf, skb->len); 434 skb_copy_bits(skb2, 0, req->buf, skb2->len);
432 req->length = skb->len; 435 req->length = skb2->len;
433 req->complete = eem_cmd_complete; 436 req->complete = eem_cmd_complete;
434 req->zero = 1; 437 req->zero = 1;
438 req->context = skb2;
435 if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC)) 439 if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
436 DBG(cdev, "echo response queue fail\n"); 440 DBG(cdev, "echo response queue fail\n");
437 break; 441 break;
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index aee7e3c53c3..36613b37c50 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -1148,6 +1148,12 @@ static int qe_ep_tx(struct qe_ep *ep, struct qe_frame *frame)
1148static int txcomplete(struct qe_ep *ep, unsigned char restart) 1148static int txcomplete(struct qe_ep *ep, unsigned char restart)
1149{ 1149{
1150 if (ep->tx_req != NULL) { 1150 if (ep->tx_req != NULL) {
1151 struct qe_req *req = ep->tx_req;
1152 unsigned zlp = 0, last_len = 0;
1153
1154 last_len = min_t(unsigned, req->req.length - ep->sent,
1155 ep->ep.maxpacket);
1156
1151 if (!restart) { 1157 if (!restart) {
1152 int asent = ep->last; 1158 int asent = ep->last;
1153 ep->sent += asent; 1159 ep->sent += asent;
@@ -1156,9 +1162,18 @@ static int txcomplete(struct qe_ep *ep, unsigned char restart)
1156 ep->last = 0; 1162 ep->last = 0;
1157 } 1163 }
1158 1164
1165 /* zlp needed when req->re.zero is set */
1166 if (req->req.zero) {
1167 if (last_len == 0 ||
1168 (req->req.length % ep->ep.maxpacket) != 0)
1169 zlp = 0;
1170 else
1171 zlp = 1;
1172 } else
1173 zlp = 0;
1174
1159 /* a request already were transmitted completely */ 1175 /* a request already were transmitted completely */
1160 if ((ep->tx_req->req.length - ep->sent) <= 0) { 1176 if (((ep->tx_req->req.length - ep->sent) <= 0) && !zlp) {
1161 ep->tx_req->req.actual = (unsigned int)ep->sent;
1162 done(ep, ep->tx_req, 0); 1177 done(ep, ep->tx_req, 0);
1163 ep->tx_req = NULL; 1178 ep->tx_req = NULL;
1164 ep->last = 0; 1179 ep->last = 0;
@@ -1191,6 +1206,7 @@ static int qe_usb_senddata(struct qe_ep *ep, struct qe_frame *frame)
1191 buf = (u8 *)ep->tx_req->req.buf + ep->sent; 1206 buf = (u8 *)ep->tx_req->req.buf + ep->sent;
1192 if (buf && size) { 1207 if (buf && size) {
1193 ep->last = size; 1208 ep->last = size;
1209 ep->tx_req->req.actual += size;
1194 frame_set_data(frame, buf); 1210 frame_set_data(frame, buf);
1195 frame_set_length(frame, size); 1211 frame_set_length(frame, size);
1196 frame_set_status(frame, FRAME_OK); 1212 frame_set_status(frame, FRAME_OK);
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 3ed73f49cf1..a01383f71f3 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -386,8 +386,10 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
386 386
387 /* halt any endpoint by doing a "wrong direction" i/o call */ 387 /* halt any endpoint by doing a "wrong direction" i/o call */
388 if (usb_endpoint_dir_in(&data->desc)) { 388 if (usb_endpoint_dir_in(&data->desc)) {
389 if (usb_endpoint_xfer_isoc(&data->desc)) 389 if (usb_endpoint_xfer_isoc(&data->desc)) {
390 mutex_unlock(&data->lock);
390 return -EINVAL; 391 return -EINVAL;
392 }
391 DBG (data->dev, "%s halt\n", data->name); 393 DBG (data->dev, "%s halt\n", data->name);
392 spin_lock_irq (&data->dev->lock); 394 spin_lock_irq (&data->dev->lock);
393 if (likely (data->ep != NULL)) 395 if (likely (data->ep != NULL))
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 3e4b35e50c2..68dbcc3e4cc 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -1608,7 +1608,7 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1608 return -EINVAL; 1608 return -EINVAL;
1609 if (!dev->driver || (dev->gadget.speed == USB_SPEED_UNKNOWN)) 1609 if (!dev->driver || (dev->gadget.speed == USB_SPEED_UNKNOWN))
1610 return -ESHUTDOWN; 1610 return -ESHUTDOWN;
1611 spin_lock_irqsave(&ep->dev->lock, iflags); 1611 spin_lock_irqsave(&dev->lock, iflags);
1612 /* map the buffer for dma */ 1612 /* map the buffer for dma */
1613 if (usbreq->length && 1613 if (usbreq->length &&
1614 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) { 1614 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) {
@@ -1625,8 +1625,10 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1625 DMA_FROM_DEVICE); 1625 DMA_FROM_DEVICE);
1626 } else { 1626 } else {
1627 req->buf = kzalloc(usbreq->length, GFP_ATOMIC); 1627 req->buf = kzalloc(usbreq->length, GFP_ATOMIC);
1628 if (!req->buf) 1628 if (!req->buf) {
1629 return -ENOMEM; 1629 retval = -ENOMEM;
1630 goto probe_end;
1631 }
1630 if (ep->in) { 1632 if (ep->in) {
1631 memcpy(req->buf, usbreq->buf, usbreq->length); 1633 memcpy(req->buf, usbreq->buf, usbreq->length);
1632 req->dma = dma_map_single(&dev->pdev->dev, 1634 req->dma = dma_map_single(&dev->pdev->dev,
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 015118535f7..6dcc1f68fa6 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -1083,7 +1083,9 @@ static void irq_device_state(struct r8a66597 *r8a66597)
1083 1083
1084 if (dvsq == DS_DFLT) { 1084 if (dvsq == DS_DFLT) {
1085 /* bus reset */ 1085 /* bus reset */
1086 spin_unlock(&r8a66597->lock);
1086 r8a66597->driver->disconnect(&r8a66597->gadget); 1087 r8a66597->driver->disconnect(&r8a66597->gadget);
1088 spin_lock(&r8a66597->lock);
1087 r8a66597_update_usb_speed(r8a66597); 1089 r8a66597_update_usb_speed(r8a66597);
1088 } 1090 }
1089 if (r8a66597->old_dvsq == DS_CNFG && dvsq != DS_CNFG) 1091 if (r8a66597->old_dvsq == DS_CNFG && dvsq != DS_CNFG)
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 98ded66e8d3..42abd0f603b 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -1247,24 +1247,27 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1247 1247
1248static void scan_async (struct ehci_hcd *ehci) 1248static void scan_async (struct ehci_hcd *ehci)
1249{ 1249{
1250 bool stopped;
1250 struct ehci_qh *qh; 1251 struct ehci_qh *qh;
1251 enum ehci_timer_action action = TIMER_IO_WATCHDOG; 1252 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
1252 1253
1253 ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index); 1254 ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index);
1254 timer_action_done (ehci, TIMER_ASYNC_SHRINK); 1255 timer_action_done (ehci, TIMER_ASYNC_SHRINK);
1255rescan: 1256rescan:
1257 stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state);
1256 qh = ehci->async->qh_next.qh; 1258 qh = ehci->async->qh_next.qh;
1257 if (likely (qh != NULL)) { 1259 if (likely (qh != NULL)) {
1258 do { 1260 do {
1259 /* clean any finished work for this qh */ 1261 /* clean any finished work for this qh */
1260 if (!list_empty (&qh->qtd_list) 1262 if (!list_empty(&qh->qtd_list) && (stopped ||
1261 && qh->stamp != ehci->stamp) { 1263 qh->stamp != ehci->stamp)) {
1262 int temp; 1264 int temp;
1263 1265
1264 /* unlinks could happen here; completion 1266 /* unlinks could happen here; completion
1265 * reporting drops the lock. rescan using 1267 * reporting drops the lock. rescan using
1266 * the latest schedule, but don't rescan 1268 * the latest schedule, but don't rescan
1267 * qhs we already finished (no looping). 1269 * qhs we already finished (no looping)
1270 * unless the controller is stopped.
1268 */ 1271 */
1269 qh = qh_get (qh); 1272 qh = qh_get (qh);
1270 qh->stamp = ehci->stamp; 1273 qh->stamp = ehci->stamp;
@@ -1285,9 +1288,9 @@ rescan:
1285 */ 1288 */
1286 if (list_empty(&qh->qtd_list) 1289 if (list_empty(&qh->qtd_list)
1287 && qh->qh_state == QH_STATE_LINKED) { 1290 && qh->qh_state == QH_STATE_LINKED) {
1288 if (!ehci->reclaim 1291 if (!ehci->reclaim && (stopped ||
1289 && ((ehci->stamp - qh->stamp) & 0x1fff) 1292 ((ehci->stamp - qh->stamp) & 0x1fff)
1290 >= (EHCI_SHRINK_FRAMES * 8)) 1293 >= EHCI_SHRINK_FRAMES * 8))
1291 start_unlink_async(ehci, qh); 1294 start_unlink_async(ehci, qh);
1292 else 1295 else
1293 action = TIMER_ASYNC_SHRINK; 1296 action = TIMER_ASYNC_SHRINK;
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index f50e84ac570..795345ad45e 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -295,7 +295,7 @@ static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
295 } 295 }
296 296
297 dev_err(hcd->self.controller, 297 dev_err(hcd->self.controller,
298 "%s: Can not allocate %lu bytes of memory\n" 298 "%s: Cannot allocate %zu bytes of memory\n"
299 "Current memory map:\n", 299 "Current memory map:\n",
300 __func__, qtd->length); 300 __func__, qtd->length);
301 for (i = 0; i < BLOCKS; i++) { 301 for (i = 0; i < BLOCKS; i++) {
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 17a6043c1fa..958d985f295 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -33,7 +33,7 @@
33 33
34#ifdef __LITTLE_ENDIAN 34#ifdef __LITTLE_ENDIAN
35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C) 35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
36#elif __BIG_ENDIAN 36#elif defined(__BIG_ENDIAN)
37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | \ 37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | \
38 USBH_ENABLE_BE) 38 USBH_ENABLE_BE)
39#else 39#else
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 1d586d4f7b5..9b166d70ae9 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -84,65 +84,92 @@ int usb_amd_find_chipset_info(void)
84{ 84{
85 u8 rev = 0; 85 u8 rev = 0;
86 unsigned long flags; 86 unsigned long flags;
87 struct amd_chipset_info info;
88 int ret;
87 89
88 spin_lock_irqsave(&amd_lock, flags); 90 spin_lock_irqsave(&amd_lock, flags);
89 91
90 amd_chipset.probe_count++;
91 /* probe only once */ 92 /* probe only once */
92 if (amd_chipset.probe_count > 1) { 93 if (amd_chipset.probe_count > 0) {
94 amd_chipset.probe_count++;
93 spin_unlock_irqrestore(&amd_lock, flags); 95 spin_unlock_irqrestore(&amd_lock, flags);
94 return amd_chipset.probe_result; 96 return amd_chipset.probe_result;
95 } 97 }
98 memset(&info, 0, sizeof(info));
99 spin_unlock_irqrestore(&amd_lock, flags);
96 100
97 amd_chipset.smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL); 101 info.smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL);
98 if (amd_chipset.smbus_dev) { 102 if (info.smbus_dev) {
99 rev = amd_chipset.smbus_dev->revision; 103 rev = info.smbus_dev->revision;
100 if (rev >= 0x40) 104 if (rev >= 0x40)
101 amd_chipset.sb_type = 1; 105 info.sb_type = 1;
102 else if (rev >= 0x30 && rev <= 0x3b) 106 else if (rev >= 0x30 && rev <= 0x3b)
103 amd_chipset.sb_type = 3; 107 info.sb_type = 3;
104 } else { 108 } else {
105 amd_chipset.smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 109 info.smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
106 0x780b, NULL); 110 0x780b, NULL);
107 if (!amd_chipset.smbus_dev) { 111 if (!info.smbus_dev) {
108 spin_unlock_irqrestore(&amd_lock, flags); 112 ret = 0;
109 return 0; 113 goto commit;
110 } 114 }
111 rev = amd_chipset.smbus_dev->revision; 115
116 rev = info.smbus_dev->revision;
112 if (rev >= 0x11 && rev <= 0x18) 117 if (rev >= 0x11 && rev <= 0x18)
113 amd_chipset.sb_type = 2; 118 info.sb_type = 2;
114 } 119 }
115 120
116 if (amd_chipset.sb_type == 0) { 121 if (info.sb_type == 0) {
117 if (amd_chipset.smbus_dev) { 122 if (info.smbus_dev) {
118 pci_dev_put(amd_chipset.smbus_dev); 123 pci_dev_put(info.smbus_dev);
119 amd_chipset.smbus_dev = NULL; 124 info.smbus_dev = NULL;
120 } 125 }
121 spin_unlock_irqrestore(&amd_lock, flags); 126 ret = 0;
122 return 0; 127 goto commit;
123 } 128 }
124 129
125 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL); 130 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL);
126 if (amd_chipset.nb_dev) { 131 if (info.nb_dev) {
127 amd_chipset.nb_type = 1; 132 info.nb_type = 1;
128 } else { 133 } else {
129 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 134 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
130 0x1510, NULL); 135 if (info.nb_dev) {
131 if (amd_chipset.nb_dev) { 136 info.nb_type = 2;
132 amd_chipset.nb_type = 2; 137 } else {
133 } else { 138 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
134 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 139 0x9600, NULL);
135 0x9600, NULL); 140 if (info.nb_dev)
136 if (amd_chipset.nb_dev) 141 info.nb_type = 3;
137 amd_chipset.nb_type = 3;
138 } 142 }
139 } 143 }
140 144
141 amd_chipset.probe_result = 1; 145 ret = info.probe_result = 1;
142 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); 146 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");
143 147
144 spin_unlock_irqrestore(&amd_lock, flags); 148commit:
145 return amd_chipset.probe_result; 149
150 spin_lock_irqsave(&amd_lock, flags);
151 if (amd_chipset.probe_count > 0) {
152 /* race - someone else was faster - drop devices */
153
154 /* Mark that we where here */
155 amd_chipset.probe_count++;
156 ret = amd_chipset.probe_result;
157
158 spin_unlock_irqrestore(&amd_lock, flags);
159
160 if (info.nb_dev)
161 pci_dev_put(info.nb_dev);
162 if (info.smbus_dev)
163 pci_dev_put(info.smbus_dev);
164
165 } else {
166 /* no race - commit the result */
167 info.probe_count++;
168 amd_chipset = info;
169 spin_unlock_irqrestore(&amd_lock, flags);
170 }
171
172 return ret;
146} 173}
147EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); 174EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);
148 175
@@ -284,6 +311,7 @@ EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable);
284 311
285void usb_amd_dev_put(void) 312void usb_amd_dev_put(void)
286{ 313{
314 struct pci_dev *nb, *smbus;
287 unsigned long flags; 315 unsigned long flags;
288 316
289 spin_lock_irqsave(&amd_lock, flags); 317 spin_lock_irqsave(&amd_lock, flags);
@@ -294,20 +322,23 @@ void usb_amd_dev_put(void)
294 return; 322 return;
295 } 323 }
296 324
297 if (amd_chipset.nb_dev) { 325 /* save them to pci_dev_put outside of spinlock */
298 pci_dev_put(amd_chipset.nb_dev); 326 nb = amd_chipset.nb_dev;
299 amd_chipset.nb_dev = NULL; 327 smbus = amd_chipset.smbus_dev;
300 } 328
301 if (amd_chipset.smbus_dev) { 329 amd_chipset.nb_dev = NULL;
302 pci_dev_put(amd_chipset.smbus_dev); 330 amd_chipset.smbus_dev = NULL;
303 amd_chipset.smbus_dev = NULL;
304 }
305 amd_chipset.nb_type = 0; 331 amd_chipset.nb_type = 0;
306 amd_chipset.sb_type = 0; 332 amd_chipset.sb_type = 0;
307 amd_chipset.isoc_reqs = 0; 333 amd_chipset.isoc_reqs = 0;
308 amd_chipset.probe_result = 0; 334 amd_chipset.probe_result = 0;
309 335
310 spin_unlock_irqrestore(&amd_lock, flags); 336 spin_unlock_irqrestore(&amd_lock, flags);
337
338 if (nb)
339 pci_dev_put(nb);
340 if (smbus)
341 pci_dev_put(smbus);
311} 342}
312EXPORT_SYMBOL_GPL(usb_amd_dev_put); 343EXPORT_SYMBOL_GPL(usb_amd_dev_put);
313 344
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index a003e79aacd..627f3438028 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -846,7 +846,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
846 * Skip ports that don't have known speeds, or have duplicate 846 * Skip ports that don't have known speeds, or have duplicate
847 * Extended Capabilities port speed entries. 847 * Extended Capabilities port speed entries.
848 */ 848 */
849 if (port_speed == 0 || port_speed == -1) 849 if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
850 continue; 850 continue;
851 851
852 /* 852 /*
@@ -974,6 +974,47 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
974 return 0; 974 return 0;
975} 975}
976 976
977/*
978 * Convert interval expressed as 2^(bInterval - 1) == interval into
979 * straight exponent value 2^n == interval.
980 *
981 */
982static unsigned int xhci_parse_exponent_interval(struct usb_device *udev,
983 struct usb_host_endpoint *ep)
984{
985 unsigned int interval;
986
987 interval = clamp_val(ep->desc.bInterval, 1, 16) - 1;
988 if (interval != ep->desc.bInterval - 1)
989 dev_warn(&udev->dev,
990 "ep %#x - rounding interval to %d microframes\n",
991 ep->desc.bEndpointAddress,
992 1 << interval);
993
994 return interval;
995}
996
997/*
998 * Convert bInterval expressed in frames (in 1-255 range) to exponent of
999 * microframes, rounded down to nearest power of 2.
1000 */
1001static unsigned int xhci_parse_frame_interval(struct usb_device *udev,
1002 struct usb_host_endpoint *ep)
1003{
1004 unsigned int interval;
1005
1006 interval = fls(8 * ep->desc.bInterval) - 1;
1007 interval = clamp_val(interval, 3, 10);
1008 if ((1 << interval) != 8 * ep->desc.bInterval)
1009 dev_warn(&udev->dev,
1010 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n",
1011 ep->desc.bEndpointAddress,
1012 1 << interval,
1013 8 * ep->desc.bInterval);
1014
1015 return interval;
1016}
1017
977/* Return the polling or NAK interval. 1018/* Return the polling or NAK interval.
978 * 1019 *
979 * The polling interval is expressed in "microframes". If xHCI's Interval field 1020 * The polling interval is expressed in "microframes". If xHCI's Interval field
@@ -982,7 +1023,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
982 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval 1023 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval
983 * is set to 0. 1024 * is set to 0.
984 */ 1025 */
985static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev, 1026static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
986 struct usb_host_endpoint *ep) 1027 struct usb_host_endpoint *ep)
987{ 1028{
988 unsigned int interval = 0; 1029 unsigned int interval = 0;
@@ -991,45 +1032,38 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
991 case USB_SPEED_HIGH: 1032 case USB_SPEED_HIGH:
992 /* Max NAK rate */ 1033 /* Max NAK rate */
993 if (usb_endpoint_xfer_control(&ep->desc) || 1034 if (usb_endpoint_xfer_control(&ep->desc) ||
994 usb_endpoint_xfer_bulk(&ep->desc)) 1035 usb_endpoint_xfer_bulk(&ep->desc)) {
995 interval = ep->desc.bInterval; 1036 interval = ep->desc.bInterval;
1037 break;
1038 }
996 /* Fall through - SS and HS isoc/int have same decoding */ 1039 /* Fall through - SS and HS isoc/int have same decoding */
1040
997 case USB_SPEED_SUPER: 1041 case USB_SPEED_SUPER:
998 if (usb_endpoint_xfer_int(&ep->desc) || 1042 if (usb_endpoint_xfer_int(&ep->desc) ||
999 usb_endpoint_xfer_isoc(&ep->desc)) { 1043 usb_endpoint_xfer_isoc(&ep->desc)) {
1000 if (ep->desc.bInterval == 0) 1044 interval = xhci_parse_exponent_interval(udev, ep);
1001 interval = 0;
1002 else
1003 interval = ep->desc.bInterval - 1;
1004 if (interval > 15)
1005 interval = 15;
1006 if (interval != ep->desc.bInterval + 1)
1007 dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n",
1008 ep->desc.bEndpointAddress, 1 << interval);
1009 } 1045 }
1010 break; 1046 break;
1011 /* Convert bInterval (in 1-255 frames) to microframes and round down to 1047
1012 * nearest power of 2.
1013 */
1014 case USB_SPEED_FULL: 1048 case USB_SPEED_FULL:
1049 if (usb_endpoint_xfer_int(&ep->desc)) {
1050 interval = xhci_parse_exponent_interval(udev, ep);
1051 break;
1052 }
1053 /*
1054 * Fall through for isochronous endpoint interval decoding
1055 * since it uses the same rules as low speed interrupt
1056 * endpoints.
1057 */
1058
1015 case USB_SPEED_LOW: 1059 case USB_SPEED_LOW:
1016 if (usb_endpoint_xfer_int(&ep->desc) || 1060 if (usb_endpoint_xfer_int(&ep->desc) ||
1017 usb_endpoint_xfer_isoc(&ep->desc)) { 1061 usb_endpoint_xfer_isoc(&ep->desc)) {
1018 interval = fls(8*ep->desc.bInterval) - 1; 1062
1019 if (interval > 10) 1063 interval = xhci_parse_frame_interval(udev, ep);
1020 interval = 10;
1021 if (interval < 3)
1022 interval = 3;
1023 if ((1 << interval) != 8*ep->desc.bInterval)
1024 dev_warn(&udev->dev,
1025 "ep %#x - rounding interval"
1026 " to %d microframes, "
1027 "ep desc says %d microframes\n",
1028 ep->desc.bEndpointAddress,
1029 1 << interval,
1030 8*ep->desc.bInterval);
1031 } 1064 }
1032 break; 1065 break;
1066
1033 default: 1067 default:
1034 BUG(); 1068 BUG();
1035 } 1069 }
@@ -1041,7 +1075,7 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1041 * transaction opportunities per microframe", but that goes in the Max Burst 1075 * transaction opportunities per microframe", but that goes in the Max Burst
1042 * endpoint context field. 1076 * endpoint context field.
1043 */ 1077 */
1044static inline u32 xhci_get_endpoint_mult(struct usb_device *udev, 1078static u32 xhci_get_endpoint_mult(struct usb_device *udev,
1045 struct usb_host_endpoint *ep) 1079 struct usb_host_endpoint *ep)
1046{ 1080{
1047 if (udev->speed != USB_SPEED_SUPER || 1081 if (udev->speed != USB_SPEED_SUPER ||
@@ -1050,7 +1084,7 @@ static inline u32 xhci_get_endpoint_mult(struct usb_device *udev,
1050 return ep->ss_ep_comp.bmAttributes; 1084 return ep->ss_ep_comp.bmAttributes;
1051} 1085}
1052 1086
1053static inline u32 xhci_get_endpoint_type(struct usb_device *udev, 1087static u32 xhci_get_endpoint_type(struct usb_device *udev,
1054 struct usb_host_endpoint *ep) 1088 struct usb_host_endpoint *ep)
1055{ 1089{
1056 int in; 1090 int in;
@@ -1084,7 +1118,7 @@ static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
1084 * Basically, this is the maxpacket size, multiplied by the burst size 1118 * Basically, this is the maxpacket size, multiplied by the burst size
1085 * and mult size. 1119 * and mult size.
1086 */ 1120 */
1087static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, 1121static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1088 struct usb_device *udev, 1122 struct usb_device *udev,
1089 struct usb_host_endpoint *ep) 1123 struct usb_host_endpoint *ep)
1090{ 1124{
@@ -1727,12 +1761,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
1727 * found a similar duplicate. 1761 * found a similar duplicate.
1728 */ 1762 */
1729 if (xhci->port_array[i] != major_revision && 1763 if (xhci->port_array[i] != major_revision &&
1730 xhci->port_array[i] != (u8) -1) { 1764 xhci->port_array[i] != DUPLICATE_ENTRY) {
1731 if (xhci->port_array[i] == 0x03) 1765 if (xhci->port_array[i] == 0x03)
1732 xhci->num_usb3_ports--; 1766 xhci->num_usb3_ports--;
1733 else 1767 else
1734 xhci->num_usb2_ports--; 1768 xhci->num_usb2_ports--;
1735 xhci->port_array[i] = (u8) -1; 1769 xhci->port_array[i] = DUPLICATE_ENTRY;
1736 } 1770 }
1737 /* FIXME: Should we disable the port? */ 1771 /* FIXME: Should we disable the port? */
1738 continue; 1772 continue;
@@ -1831,7 +1865,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
1831 for (i = 0; i < num_ports; i++) { 1865 for (i = 0; i < num_ports; i++) {
1832 if (xhci->port_array[i] == 0x03 || 1866 if (xhci->port_array[i] == 0x03 ||
1833 xhci->port_array[i] == 0 || 1867 xhci->port_array[i] == 0 ||
1834 xhci->port_array[i] == -1) 1868 xhci->port_array[i] == DUPLICATE_ENTRY)
1835 continue; 1869 continue;
1836 1870
1837 xhci->usb2_ports[port_index] = 1871 xhci->usb2_ports[port_index] =
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ceea9f33491..a10494c2f3c 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -114,6 +114,10 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
114 if (pdev->vendor == PCI_VENDOR_ID_NEC) 114 if (pdev->vendor == PCI_VENDOR_ID_NEC)
115 xhci->quirks |= XHCI_NEC_HOST; 115 xhci->quirks |= XHCI_NEC_HOST;
116 116
117 /* AMD PLL quirk */
118 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
119 xhci->quirks |= XHCI_AMD_PLL_FIX;
120
117 /* Make sure the HC is halted. */ 121 /* Make sure the HC is halted. */
118 retval = xhci_halt(xhci); 122 retval = xhci_halt(xhci);
119 if (retval) 123 if (retval)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cfc1ad92473..7437386a9a5 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -93,7 +93,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
93/* Does this link TRB point to the first segment in a ring, 93/* Does this link TRB point to the first segment in a ring,
94 * or was the previous TRB the last TRB on the last segment in the ERST? 94 * or was the previous TRB the last TRB on the last segment in the ERST?
95 */ 95 */
96static inline bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring, 96static bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring,
97 struct xhci_segment *seg, union xhci_trb *trb) 97 struct xhci_segment *seg, union xhci_trb *trb)
98{ 98{
99 if (ring == xhci->event_ring) 99 if (ring == xhci->event_ring)
@@ -107,7 +107,7 @@ static inline bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring
107 * segment? I.e. would the updated event TRB pointer step off the end of the 107 * segment? I.e. would the updated event TRB pointer step off the end of the
108 * event seg? 108 * event seg?
109 */ 109 */
110static inline int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, 110static int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
111 struct xhci_segment *seg, union xhci_trb *trb) 111 struct xhci_segment *seg, union xhci_trb *trb)
112{ 112{
113 if (ring == xhci->event_ring) 113 if (ring == xhci->event_ring)
@@ -116,7 +116,7 @@ static inline int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
116 return (trb->link.control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK); 116 return (trb->link.control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK);
117} 117}
118 118
119static inline int enqueue_is_link_trb(struct xhci_ring *ring) 119static int enqueue_is_link_trb(struct xhci_ring *ring)
120{ 120{
121 struct xhci_link_trb *link = &ring->enqueue->link; 121 struct xhci_link_trb *link = &ring->enqueue->link;
122 return ((link->control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)); 122 return ((link->control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK));
@@ -592,7 +592,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
592 ep->ep_state |= SET_DEQ_PENDING; 592 ep->ep_state |= SET_DEQ_PENDING;
593} 593}
594 594
595static inline void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci, 595static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci,
596 struct xhci_virt_ep *ep) 596 struct xhci_virt_ep *ep)
597{ 597{
598 ep->ep_state &= ~EP_HALT_PENDING; 598 ep->ep_state &= ~EP_HALT_PENDING;
@@ -619,6 +619,13 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
619 619
620 /* Only giveback urb when this is the last td in urb */ 620 /* Only giveback urb when this is the last td in urb */
621 if (urb_priv->td_cnt == urb_priv->length) { 621 if (urb_priv->td_cnt == urb_priv->length) {
622 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
623 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs--;
624 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs == 0) {
625 if (xhci->quirks & XHCI_AMD_PLL_FIX)
626 usb_amd_quirk_pll_enable();
627 }
628 }
622 usb_hcd_unlink_urb_from_ep(hcd, urb); 629 usb_hcd_unlink_urb_from_ep(hcd, urb);
623 xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, urb); 630 xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, urb);
624 631
@@ -1209,7 +1216,7 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
1209 * Skip ports that don't have known speeds, or have duplicate 1216 * Skip ports that don't have known speeds, or have duplicate
1210 * Extended Capabilities port speed entries. 1217 * Extended Capabilities port speed entries.
1211 */ 1218 */
1212 if (port_speed == 0 || port_speed == -1) 1219 if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
1213 continue; 1220 continue;
1214 1221
1215 /* 1222 /*
@@ -1235,6 +1242,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1235 u8 major_revision; 1242 u8 major_revision;
1236 struct xhci_bus_state *bus_state; 1243 struct xhci_bus_state *bus_state;
1237 u32 __iomem **port_array; 1244 u32 __iomem **port_array;
1245 bool bogus_port_status = false;
1238 1246
1239 /* Port status change events always have a successful completion code */ 1247 /* Port status change events always have a successful completion code */
1240 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) { 1248 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) {
@@ -1247,6 +1255,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1247 max_ports = HCS_MAX_PORTS(xhci->hcs_params1); 1255 max_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1248 if ((port_id <= 0) || (port_id > max_ports)) { 1256 if ((port_id <= 0) || (port_id > max_ports)) {
1249 xhci_warn(xhci, "Invalid port id %d\n", port_id); 1257 xhci_warn(xhci, "Invalid port id %d\n", port_id);
1258 bogus_port_status = true;
1250 goto cleanup; 1259 goto cleanup;
1251 } 1260 }
1252 1261
@@ -1258,12 +1267,14 @@ static void handle_port_status(struct xhci_hcd *xhci,
1258 xhci_warn(xhci, "Event for port %u not in " 1267 xhci_warn(xhci, "Event for port %u not in "
1259 "Extended Capabilities, ignoring.\n", 1268 "Extended Capabilities, ignoring.\n",
1260 port_id); 1269 port_id);
1270 bogus_port_status = true;
1261 goto cleanup; 1271 goto cleanup;
1262 } 1272 }
1263 if (major_revision == (u8) -1) { 1273 if (major_revision == DUPLICATE_ENTRY) {
1264 xhci_warn(xhci, "Event for port %u duplicated in" 1274 xhci_warn(xhci, "Event for port %u duplicated in"
1265 "Extended Capabilities, ignoring.\n", 1275 "Extended Capabilities, ignoring.\n",
1266 port_id); 1276 port_id);
1277 bogus_port_status = true;
1267 goto cleanup; 1278 goto cleanup;
1268 } 1279 }
1269 1280
@@ -1335,6 +1346,13 @@ cleanup:
1335 /* Update event ring dequeue pointer before dropping the lock */ 1346 /* Update event ring dequeue pointer before dropping the lock */
1336 inc_deq(xhci, xhci->event_ring, true); 1347 inc_deq(xhci, xhci->event_ring, true);
1337 1348
1349 /* Don't make the USB core poll the roothub if we got a bad port status
1350 * change event. Besides, at that point we can't tell which roothub
1351 * (USB 2.0 or USB 3.0) to kick.
1352 */
1353 if (bogus_port_status)
1354 return;
1355
1338 spin_unlock(&xhci->lock); 1356 spin_unlock(&xhci->lock);
1339 /* Pass this up to the core */ 1357 /* Pass this up to the core */
1340 usb_hcd_poll_rh_status(hcd); 1358 usb_hcd_poll_rh_status(hcd);
@@ -1554,8 +1572,17 @@ td_cleanup:
1554 1572
1555 urb_priv->td_cnt++; 1573 urb_priv->td_cnt++;
1556 /* Giveback the urb when all the tds are completed */ 1574 /* Giveback the urb when all the tds are completed */
1557 if (urb_priv->td_cnt == urb_priv->length) 1575 if (urb_priv->td_cnt == urb_priv->length) {
1558 ret = 1; 1576 ret = 1;
1577 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
1578 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs--;
1579 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs
1580 == 0) {
1581 if (xhci->quirks & XHCI_AMD_PLL_FIX)
1582 usb_amd_quirk_pll_enable();
1583 }
1584 }
1585 }
1559 } 1586 }
1560 1587
1561 return ret; 1588 return ret;
@@ -1675,71 +1702,52 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1675 struct urb_priv *urb_priv; 1702 struct urb_priv *urb_priv;
1676 int idx; 1703 int idx;
1677 int len = 0; 1704 int len = 0;
1678 int skip_td = 0;
1679 union xhci_trb *cur_trb; 1705 union xhci_trb *cur_trb;
1680 struct xhci_segment *cur_seg; 1706 struct xhci_segment *cur_seg;
1707 struct usb_iso_packet_descriptor *frame;
1681 u32 trb_comp_code; 1708 u32 trb_comp_code;
1709 bool skip_td = false;
1682 1710
1683 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); 1711 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer);
1684 trb_comp_code = GET_COMP_CODE(event->transfer_len); 1712 trb_comp_code = GET_COMP_CODE(event->transfer_len);
1685 urb_priv = td->urb->hcpriv; 1713 urb_priv = td->urb->hcpriv;
1686 idx = urb_priv->td_cnt; 1714 idx = urb_priv->td_cnt;
1715 frame = &td->urb->iso_frame_desc[idx];
1687 1716
1688 if (ep->skip) { 1717 /* handle completion code */
1689 /* The transfer is partly done */ 1718 switch (trb_comp_code) {
1690 *status = -EXDEV; 1719 case COMP_SUCCESS:
1691 td->urb->iso_frame_desc[idx].status = -EXDEV; 1720 frame->status = 0;
1692 } else { 1721 xhci_dbg(xhci, "Successful isoc transfer!\n");
1693 /* handle completion code */ 1722 break;
1694 switch (trb_comp_code) { 1723 case COMP_SHORT_TX:
1695 case COMP_SUCCESS: 1724 frame->status = td->urb->transfer_flags & URB_SHORT_NOT_OK ?
1696 td->urb->iso_frame_desc[idx].status = 0; 1725 -EREMOTEIO : 0;
1697 xhci_dbg(xhci, "Successful isoc transfer!\n"); 1726 break;
1698 break; 1727 case COMP_BW_OVER:
1699 case COMP_SHORT_TX: 1728 frame->status = -ECOMM;
1700 if (td->urb->transfer_flags & URB_SHORT_NOT_OK) 1729 skip_td = true;
1701 td->urb->iso_frame_desc[idx].status = 1730 break;
1702 -EREMOTEIO; 1731 case COMP_BUFF_OVER:
1703 else 1732 case COMP_BABBLE:
1704 td->urb->iso_frame_desc[idx].status = 0; 1733 frame->status = -EOVERFLOW;
1705 break; 1734 skip_td = true;
1706 case COMP_BW_OVER: 1735 break;
1707 td->urb->iso_frame_desc[idx].status = -ECOMM; 1736 case COMP_STALL:
1708 skip_td = 1; 1737 frame->status = -EPROTO;
1709 break; 1738 skip_td = true;
1710 case COMP_BUFF_OVER: 1739 break;
1711 case COMP_BABBLE: 1740 case COMP_STOP:
1712 td->urb->iso_frame_desc[idx].status = -EOVERFLOW; 1741 case COMP_STOP_INVAL:
1713 skip_td = 1; 1742 break;
1714 break; 1743 default:
1715 case COMP_STALL: 1744 frame->status = -1;
1716 td->urb->iso_frame_desc[idx].status = -EPROTO; 1745 break;
1717 skip_td = 1;
1718 break;
1719 case COMP_STOP:
1720 case COMP_STOP_INVAL:
1721 break;
1722 default:
1723 td->urb->iso_frame_desc[idx].status = -1;
1724 break;
1725 }
1726 }
1727
1728 /* calc actual length */
1729 if (ep->skip) {
1730 td->urb->iso_frame_desc[idx].actual_length = 0;
1731 /* Update ring dequeue pointer */
1732 while (ep_ring->dequeue != td->last_trb)
1733 inc_deq(xhci, ep_ring, false);
1734 inc_deq(xhci, ep_ring, false);
1735 return finish_td(xhci, td, event_trb, event, ep, status, true);
1736 } 1746 }
1737 1747
1738 if (trb_comp_code == COMP_SUCCESS || skip_td == 1) { 1748 if (trb_comp_code == COMP_SUCCESS || skip_td) {
1739 td->urb->iso_frame_desc[idx].actual_length = 1749 frame->actual_length = frame->length;
1740 td->urb->iso_frame_desc[idx].length; 1750 td->urb->actual_length += frame->length;
1741 td->urb->actual_length +=
1742 td->urb->iso_frame_desc[idx].length;
1743 } else { 1751 } else {
1744 for (cur_trb = ep_ring->dequeue, 1752 for (cur_trb = ep_ring->dequeue,
1745 cur_seg = ep_ring->deq_seg; cur_trb != event_trb; 1753 cur_seg = ep_ring->deq_seg; cur_trb != event_trb;
@@ -1755,7 +1763,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1755 TRB_LEN(event->transfer_len); 1763 TRB_LEN(event->transfer_len);
1756 1764
1757 if (trb_comp_code != COMP_STOP_INVAL) { 1765 if (trb_comp_code != COMP_STOP_INVAL) {
1758 td->urb->iso_frame_desc[idx].actual_length = len; 1766 frame->actual_length = len;
1759 td->urb->actual_length += len; 1767 td->urb->actual_length += len;
1760 } 1768 }
1761 } 1769 }
@@ -1766,6 +1774,35 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1766 return finish_td(xhci, td, event_trb, event, ep, status, false); 1774 return finish_td(xhci, td, event_trb, event, ep, status, false);
1767} 1775}
1768 1776
1777static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1778 struct xhci_transfer_event *event,
1779 struct xhci_virt_ep *ep, int *status)
1780{
1781 struct xhci_ring *ep_ring;
1782 struct urb_priv *urb_priv;
1783 struct usb_iso_packet_descriptor *frame;
1784 int idx;
1785
1786 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer);
1787 urb_priv = td->urb->hcpriv;
1788 idx = urb_priv->td_cnt;
1789 frame = &td->urb->iso_frame_desc[idx];
1790
1791 /* The transfer is partly done */
1792 *status = -EXDEV;
1793 frame->status = -EXDEV;
1794
1795 /* calc actual length */
1796 frame->actual_length = 0;
1797
1798 /* Update ring dequeue pointer */
1799 while (ep_ring->dequeue != td->last_trb)
1800 inc_deq(xhci, ep_ring, false);
1801 inc_deq(xhci, ep_ring, false);
1802
1803 return finish_td(xhci, td, NULL, event, ep, status, true);
1804}
1805
1769/* 1806/*
1770 * Process bulk and interrupt tds, update urb status and actual_length. 1807 * Process bulk and interrupt tds, update urb status and actual_length.
1771 */ 1808 */
@@ -2024,36 +2061,42 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2024 } 2061 }
2025 2062
2026 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); 2063 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list);
2064
2027 /* Is this a TRB in the currently executing TD? */ 2065 /* Is this a TRB in the currently executing TD? */
2028 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, 2066 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue,
2029 td->last_trb, event_dma); 2067 td->last_trb, event_dma);
2030 if (event_seg && ep->skip) { 2068 if (!event_seg) {
2069 if (!ep->skip ||
2070 !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
2071 /* HC is busted, give up! */
2072 xhci_err(xhci,
2073 "ERROR Transfer event TRB DMA ptr not "
2074 "part of current TD\n");
2075 return -ESHUTDOWN;
2076 }
2077
2078 ret = skip_isoc_td(xhci, td, event, ep, &status);
2079 goto cleanup;
2080 }
2081
2082 if (ep->skip) {
2031 xhci_dbg(xhci, "Found td. Clear skip flag.\n"); 2083 xhci_dbg(xhci, "Found td. Clear skip flag.\n");
2032 ep->skip = false; 2084 ep->skip = false;
2033 } 2085 }
2034 if (!event_seg &&
2035 (!ep->skip || !usb_endpoint_xfer_isoc(&td->urb->ep->desc))) {
2036 /* HC is busted, give up! */
2037 xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not "
2038 "part of current TD\n");
2039 return -ESHUTDOWN;
2040 }
2041 2086
2042 if (event_seg) { 2087 event_trb = &event_seg->trbs[(event_dma - event_seg->dma) /
2043 event_trb = &event_seg->trbs[(event_dma - 2088 sizeof(*event_trb)];
2044 event_seg->dma) / sizeof(*event_trb)]; 2089 /*
2045 /* 2090 * No-op TRB should not trigger interrupts.
2046 * No-op TRB should not trigger interrupts. 2091 * If event_trb is a no-op TRB, it means the
2047 * If event_trb is a no-op TRB, it means the 2092 * corresponding TD has been cancelled. Just ignore
2048 * corresponding TD has been cancelled. Just ignore 2093 * the TD.
2049 * the TD. 2094 */
2050 */ 2095 if ((event_trb->generic.field[3] & TRB_TYPE_BITMASK)
2051 if ((event_trb->generic.field[3] & TRB_TYPE_BITMASK) 2096 == TRB_TYPE(TRB_TR_NOOP)) {
2052 == TRB_TYPE(TRB_TR_NOOP)) { 2097 xhci_dbg(xhci,
2053 xhci_dbg(xhci, "event_trb is a no-op TRB. " 2098 "event_trb is a no-op TRB. Skip it\n");
2054 "Skip it\n"); 2099 goto cleanup;
2055 goto cleanup;
2056 }
2057 } 2100 }
2058 2101
2059 /* Now update the urb's actual_length and give back to 2102 /* Now update the urb's actual_length and give back to
@@ -3126,6 +3169,12 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3126 } 3169 }
3127 } 3170 }
3128 3171
3172 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs == 0) {
3173 if (xhci->quirks & XHCI_AMD_PLL_FIX)
3174 usb_amd_quirk_pll_disable();
3175 }
3176 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs++;
3177
3129 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, 3178 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
3130 start_cycle, start_trb); 3179 start_cycle, start_trb);
3131 return 0; 3180 return 0;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 196e0181b2e..81b976e4588 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -550,6 +550,9 @@ void xhci_stop(struct usb_hcd *hcd)
550 del_timer_sync(&xhci->event_ring_timer); 550 del_timer_sync(&xhci->event_ring_timer);
551#endif 551#endif
552 552
553 if (xhci->quirks & XHCI_AMD_PLL_FIX)
554 usb_amd_dev_put();
555
553 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); 556 xhci_dbg(xhci, "// Disabling event ring interrupts\n");
554 temp = xhci_readl(xhci, &xhci->op_regs->status); 557 temp = xhci_readl(xhci, &xhci->op_regs->status);
555 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status); 558 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
@@ -771,7 +774,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
771 774
772 /* If restore operation fails, re-initialize the HC during resume */ 775 /* If restore operation fails, re-initialize the HC during resume */
773 if ((temp & STS_SRE) || hibernated) { 776 if ((temp & STS_SRE) || hibernated) {
774 usb_root_hub_lost_power(hcd->self.root_hub); 777 /* Let the USB core know _both_ roothubs lost power. */
778 usb_root_hub_lost_power(xhci->main_hcd->self.root_hub);
779 usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub);
775 780
776 xhci_dbg(xhci, "Stop HCD\n"); 781 xhci_dbg(xhci, "Stop HCD\n");
777 xhci_halt(xhci); 782 xhci_halt(xhci);
@@ -2386,10 +2391,18 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
2386 /* Everything but endpoint 0 is disabled, so free or cache the rings. */ 2391 /* Everything but endpoint 0 is disabled, so free or cache the rings. */
2387 last_freed_endpoint = 1; 2392 last_freed_endpoint = 1;
2388 for (i = 1; i < 31; ++i) { 2393 for (i = 1; i < 31; ++i) {
2389 if (!virt_dev->eps[i].ring) 2394 struct xhci_virt_ep *ep = &virt_dev->eps[i];
2390 continue; 2395
2391 xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); 2396 if (ep->ep_state & EP_HAS_STREAMS) {
2392 last_freed_endpoint = i; 2397 xhci_free_stream_info(xhci, ep->stream_info);
2398 ep->stream_info = NULL;
2399 ep->ep_state &= ~EP_HAS_STREAMS;
2400 }
2401
2402 if (ep->ring) {
2403 xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
2404 last_freed_endpoint = i;
2405 }
2393 } 2406 }
2394 xhci_dbg(xhci, "Output context after successful reset device cmd:\n"); 2407 xhci_dbg(xhci, "Output context after successful reset device cmd:\n");
2395 xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint); 2408 xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 07e263063e3..ba1be6b7cc6 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -30,6 +30,7 @@
30 30
31/* Code sharing between pci-quirks and xhci hcd */ 31/* Code sharing between pci-quirks and xhci hcd */
32#include "xhci-ext-caps.h" 32#include "xhci-ext-caps.h"
33#include "pci-quirks.h"
33 34
34/* xHCI PCI Configuration Registers */ 35/* xHCI PCI Configuration Registers */
35#define XHCI_SBRN_OFFSET (0x60) 36#define XHCI_SBRN_OFFSET (0x60)
@@ -232,7 +233,7 @@ struct xhci_op_regs {
232 * notification type that matches a bit set in this bit field. 233 * notification type that matches a bit set in this bit field.
233 */ 234 */
234#define DEV_NOTE_MASK (0xffff) 235#define DEV_NOTE_MASK (0xffff)
235#define ENABLE_DEV_NOTE(x) (1 << x) 236#define ENABLE_DEV_NOTE(x) (1 << (x))
236/* Most of the device notification types should only be used for debug. 237/* Most of the device notification types should only be used for debug.
237 * SW does need to pay attention to function wake notifications. 238 * SW does need to pay attention to function wake notifications.
238 */ 239 */
@@ -348,6 +349,9 @@ struct xhci_op_regs {
348/* Initiate a warm port reset - complete when PORT_WRC is '1' */ 349/* Initiate a warm port reset - complete when PORT_WRC is '1' */
349#define PORT_WR (1 << 31) 350#define PORT_WR (1 << 31)
350 351
352/* We mark duplicate entries with -1 */
353#define DUPLICATE_ENTRY ((u8)(-1))
354
351/* Port Power Management Status and Control - port_power_base bitmasks */ 355/* Port Power Management Status and Control - port_power_base bitmasks */
352/* Inactivity timer value for transitions into U1, in microseconds. 356/* Inactivity timer value for transitions into U1, in microseconds.
353 * Timeout can be up to 127us. 0xFF means an infinite timeout. 357 * Timeout can be up to 127us. 0xFF means an infinite timeout.
@@ -601,11 +605,11 @@ struct xhci_ep_ctx {
601#define EP_STATE_STOPPED 3 605#define EP_STATE_STOPPED 3
602#define EP_STATE_ERROR 4 606#define EP_STATE_ERROR 4
603/* Mult - Max number of burtst within an interval, in EP companion desc. */ 607/* Mult - Max number of burtst within an interval, in EP companion desc. */
604#define EP_MULT(p) ((p & 0x3) << 8) 608#define EP_MULT(p) (((p) & 0x3) << 8)
605/* bits 10:14 are Max Primary Streams */ 609/* bits 10:14 are Max Primary Streams */
606/* bit 15 is Linear Stream Array */ 610/* bit 15 is Linear Stream Array */
607/* Interval - period between requests to an endpoint - 125u increments. */ 611/* Interval - period between requests to an endpoint - 125u increments. */
608#define EP_INTERVAL(p) ((p & 0xff) << 16) 612#define EP_INTERVAL(p) (((p) & 0xff) << 16)
609#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 613#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff))
610#define EP_MAXPSTREAMS_MASK (0x1f << 10) 614#define EP_MAXPSTREAMS_MASK (0x1f << 10)
611#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) 615#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK)
@@ -1276,6 +1280,7 @@ struct xhci_hcd {
1276#define XHCI_LINK_TRB_QUIRK (1 << 0) 1280#define XHCI_LINK_TRB_QUIRK (1 << 0)
1277#define XHCI_RESET_EP_QUIRK (1 << 1) 1281#define XHCI_RESET_EP_QUIRK (1 << 1)
1278#define XHCI_NEC_HOST (1 << 2) 1282#define XHCI_NEC_HOST (1 << 2)
1283#define XHCI_AMD_PLL_FIX (1 << 3)
1279 /* There are two roothubs to keep track of bus suspend info for */ 1284 /* There are two roothubs to keep track of bus suspend info for */
1280 struct xhci_bus_state bus_state[2]; 1285 struct xhci_bus_state bus_state[2];
1281 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */ 1286 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 4cbb7e4b368..74073b363c3 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -14,7 +14,7 @@ config USB_MUSB_HDRC
14 select TWL4030_USB if MACH_OMAP_3430SDP 14 select TWL4030_USB if MACH_OMAP_3430SDP
15 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA 15 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
16 select USB_OTG_UTILS 16 select USB_OTG_UTILS
17 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' 17 bool 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
18 help 18 help
19 Say Y here if your system has a dual role high speed USB 19 Say Y here if your system has a dual role high speed USB
20 controller based on the Mentor Graphics silicon IP. Then 20 controller based on the Mentor Graphics silicon IP. Then
@@ -30,8 +30,8 @@ config USB_MUSB_HDRC
30 30
31 If you do not know what this is, please say N. 31 If you do not know what this is, please say N.
32 32
33 To compile this driver as a module, choose M here; the 33# To compile this driver as a module, choose M here; the
34 module will be called "musb-hdrc". 34# module will be called "musb-hdrc".
35 35
36choice 36choice
37 prompt "Platform Glue Layer" 37 prompt "Platform Glue Layer"
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 52312e8af21..8e2a1ff8a35 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -21,6 +21,7 @@
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22 22
23#include "musb_core.h" 23#include "musb_core.h"
24#include "musbhsdma.h"
24#include "blackfin.h" 25#include "blackfin.h"
25 26
26struct bfin_glue { 27struct bfin_glue {
@@ -332,6 +333,27 @@ static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode)
332 return -EIO; 333 return -EIO;
333} 334}
334 335
336static int bfin_musb_adjust_channel_params(struct dma_channel *channel,
337 u16 packet_sz, u8 *mode,
338 dma_addr_t *dma_addr, u32 *len)
339{
340 struct musb_dma_channel *musb_channel = channel->private_data;
341
342 /*
343 * Anomaly 05000450 might cause data corruption when using DMA
344 * MODE 1 transmits with short packet. So to work around this,
345 * we truncate all MODE 1 transfers down to a multiple of the
346 * max packet size, and then do the last short packet transfer
347 * (if there is any) using MODE 0.
348 */
349 if (ANOMALY_05000450) {
350 if (musb_channel->transmit && *mode == 1)
351 *len = *len - (*len % packet_sz);
352 }
353
354 return 0;
355}
356
335static void bfin_musb_reg_init(struct musb *musb) 357static void bfin_musb_reg_init(struct musb *musb)
336{ 358{
337 if (ANOMALY_05000346) { 359 if (ANOMALY_05000346) {
@@ -430,6 +452,8 @@ static const struct musb_platform_ops bfin_ops = {
430 452
431 .vbus_status = bfin_musb_vbus_status, 453 .vbus_status = bfin_musb_vbus_status,
432 .set_vbus = bfin_musb_set_vbus, 454 .set_vbus = bfin_musb_set_vbus,
455
456 .adjust_channel_params = bfin_musb_adjust_channel_params,
433}; 457};
434 458
435static u64 bfin_dmamask = DMA_BIT_MASK(32); 459static u64 bfin_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index de55a3c3259..ab434fbd8c3 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -597,12 +597,12 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
597 length = min(n_bds * maxpacket, length); 597 length = min(n_bds * maxpacket, length);
598 } 598 }
599 599
600 DBG(4, "TX DMA%d, pktSz %d %s bds %d dma 0x%x len %u\n", 600 DBG(4, "TX DMA%d, pktSz %d %s bds %d dma 0x%llx len %u\n",
601 tx->index, 601 tx->index,
602 maxpacket, 602 maxpacket,
603 rndis ? "rndis" : "transparent", 603 rndis ? "rndis" : "transparent",
604 n_bds, 604 n_bds,
605 addr, length); 605 (unsigned long long)addr, length);
606 606
607 cppi_rndis_update(tx, 0, musb->ctrl_base, rndis); 607 cppi_rndis_update(tx, 0, musb->ctrl_base, rndis);
608 608
@@ -820,7 +820,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
820 length = min(n_bds * maxpacket, length); 820 length = min(n_bds * maxpacket, length);
821 821
822 DBG(4, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) " 822 DBG(4, "RX DMA%d seg, maxp %d %s bds %d (cnt %d) "
823 "dma 0x%x len %u %u/%u\n", 823 "dma 0x%llx len %u %u/%u\n",
824 rx->index, maxpacket, 824 rx->index, maxpacket,
825 onepacket 825 onepacket
826 ? (is_rndis ? "rndis" : "onepacket") 826 ? (is_rndis ? "rndis" : "onepacket")
@@ -829,7 +829,8 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
829 musb_readl(tibase, 829 musb_readl(tibase,
830 DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4)) 830 DAVINCI_RXCPPI_BUFCNT0_REG + (rx->index * 4))
831 & 0xffff, 831 & 0xffff,
832 addr, length, rx->channel.actual_len, rx->buf_len); 832 (unsigned long long)addr, length,
833 rx->channel.actual_len, rx->buf_len);
833 834
834 /* only queue one segment at a time, since the hardware prevents 835 /* only queue one segment at a time, since the hardware prevents
835 * correct queue shutdown after unexpected short packets 836 * correct queue shutdown after unexpected short packets
@@ -1039,9 +1040,9 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
1039 if (!completed && (bd->hw_options & CPPI_OWN_SET)) 1040 if (!completed && (bd->hw_options & CPPI_OWN_SET))
1040 break; 1041 break;
1041 1042
1042 DBG(5, "C/RXBD %08x: nxt %08x buf %08x " 1043 DBG(5, "C/RXBD %llx: nxt %08x buf %08x "
1043 "off.len %08x opt.len %08x (%d)\n", 1044 "off.len %08x opt.len %08x (%d)\n",
1044 bd->dma, bd->hw_next, bd->hw_bufp, 1045 (unsigned long long)bd->dma, bd->hw_next, bd->hw_bufp,
1045 bd->hw_off_len, bd->hw_options, 1046 bd->hw_off_len, bd->hw_options,
1046 rx->channel.actual_len); 1047 rx->channel.actual_len);
1047 1048
@@ -1111,11 +1112,12 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
1111 musb_ep_select(cppi->mregs, rx->index + 1); 1112 musb_ep_select(cppi->mregs, rx->index + 1);
1112 csr = musb_readw(regs, MUSB_RXCSR); 1113 csr = musb_readw(regs, MUSB_RXCSR);
1113 if (csr & MUSB_RXCSR_DMAENAB) { 1114 if (csr & MUSB_RXCSR_DMAENAB) {
1114 DBG(4, "list%d %p/%p, last %08x%s, csr %04x\n", 1115 DBG(4, "list%d %p/%p, last %llx%s, csr %04x\n",
1115 rx->index, 1116 rx->index,
1116 rx->head, rx->tail, 1117 rx->head, rx->tail,
1117 rx->last_processed 1118 rx->last_processed
1118 ? rx->last_processed->dma 1119 ? (unsigned long long)
1120 rx->last_processed->dma
1119 : 0, 1121 : 0,
1120 completed ? ", completed" : "", 1122 completed ? ", completed" : "",
1121 csr); 1123 csr);
@@ -1167,8 +1169,11 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
1167 tx = musb_readl(tibase, DAVINCI_TXCPPI_MASKED_REG); 1169 tx = musb_readl(tibase, DAVINCI_TXCPPI_MASKED_REG);
1168 rx = musb_readl(tibase, DAVINCI_RXCPPI_MASKED_REG); 1170 rx = musb_readl(tibase, DAVINCI_RXCPPI_MASKED_REG);
1169 1171
1170 if (!tx && !rx) 1172 if (!tx && !rx) {
1173 if (cppi->irq)
1174 spin_unlock_irqrestore(&musb->lock, flags);
1171 return IRQ_NONE; 1175 return IRQ_NONE;
1176 }
1172 1177
1173 DBG(4, "CPPI IRQ Tx%x Rx%x\n", tx, rx); 1178 DBG(4, "CPPI IRQ Tx%x Rx%x\n", tx, rx);
1174 1179
@@ -1199,7 +1204,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
1199 */ 1204 */
1200 if (NULL == bd) { 1205 if (NULL == bd) {
1201 DBG(1, "null BD\n"); 1206 DBG(1, "null BD\n");
1202 tx_ram->tx_complete = 0; 1207 musb_writel(&tx_ram->tx_complete, 0, 0);
1203 continue; 1208 continue;
1204 } 1209 }
1205 1210
@@ -1452,7 +1457,7 @@ static int cppi_channel_abort(struct dma_channel *channel)
1452 * compare mode by writing 1 to the tx_complete register. 1457 * compare mode by writing 1 to the tx_complete register.
1453 */ 1458 */
1454 cppi_reset_tx(tx_ram, 1); 1459 cppi_reset_tx(tx_ram, 1);
1455 cppi_ch->head = 0; 1460 cppi_ch->head = NULL;
1456 musb_writel(&tx_ram->tx_complete, 0, 1); 1461 musb_writel(&tx_ram->tx_complete, 0, 1);
1457 cppi_dump_tx(5, cppi_ch, " (done teardown)"); 1462 cppi_dump_tx(5, cppi_ch, " (done teardown)");
1458 1463
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 630ae7f3cd4..f10ff00ca09 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1030,6 +1030,7 @@ static void musb_shutdown(struct platform_device *pdev)
1030 struct musb *musb = dev_to_musb(&pdev->dev); 1030 struct musb *musb = dev_to_musb(&pdev->dev);
1031 unsigned long flags; 1031 unsigned long flags;
1032 1032
1033 pm_runtime_get_sync(musb->controller);
1033 spin_lock_irqsave(&musb->lock, flags); 1034 spin_lock_irqsave(&musb->lock, flags);
1034 musb_platform_disable(musb); 1035 musb_platform_disable(musb);
1035 musb_generic_disable(musb); 1036 musb_generic_disable(musb);
@@ -1040,6 +1041,7 @@ static void musb_shutdown(struct platform_device *pdev)
1040 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 1041 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
1041 musb_platform_exit(musb); 1042 musb_platform_exit(musb);
1042 1043
1044 pm_runtime_put(musb->controller);
1043 /* FIXME power down */ 1045 /* FIXME power down */
1044} 1046}
1045 1047
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 4bd9e2145ee..0e053b58796 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -261,6 +261,7 @@ enum musb_g_ep0_state {
261 * @try_ilde: tries to idle the IP 261 * @try_ilde: tries to idle the IP
262 * @vbus_status: returns vbus status if possible 262 * @vbus_status: returns vbus status if possible
263 * @set_vbus: forces vbus status 263 * @set_vbus: forces vbus status
264 * @channel_program: pre check for standard dma channel_program func
264 */ 265 */
265struct musb_platform_ops { 266struct musb_platform_ops {
266 int (*init)(struct musb *musb); 267 int (*init)(struct musb *musb);
@@ -274,6 +275,10 @@ struct musb_platform_ops {
274 275
275 int (*vbus_status)(struct musb *musb); 276 int (*vbus_status)(struct musb *musb);
276 void (*set_vbus)(struct musb *musb, int on); 277 void (*set_vbus)(struct musb *musb, int on);
278
279 int (*adjust_channel_params)(struct dma_channel *channel,
280 u16 packet_sz, u8 *mode,
281 dma_addr_t *dma_addr, u32 *len);
277}; 282};
278 283
279/* 284/*
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 98519c5d8b5..6dfbf9ffd7a 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -535,7 +535,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)
535 is_dma = 1; 535 is_dma = 1;
536 csr |= MUSB_TXCSR_P_WZC_BITS; 536 csr |= MUSB_TXCSR_P_WZC_BITS;
537 csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN | 537 csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN |
538 MUSB_TXCSR_TXPKTRDY); 538 MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_AUTOSET);
539 musb_writew(epio, MUSB_TXCSR, csr); 539 musb_writew(epio, MUSB_TXCSR, csr);
540 /* Ensure writebuffer is empty. */ 540 /* Ensure writebuffer is empty. */
541 csr = musb_readw(epio, MUSB_TXCSR); 541 csr = musb_readw(epio, MUSB_TXCSR);
@@ -1296,7 +1296,7 @@ static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *request)
1296 } 1296 }
1297 1297
1298 /* if the hardware doesn't have the request, easy ... */ 1298 /* if the hardware doesn't have the request, easy ... */
1299 if (musb_ep->req_list.next != &request->list || musb_ep->busy) 1299 if (musb_ep->req_list.next != &req->list || musb_ep->busy)
1300 musb_g_giveback(musb_ep, request, -ECONNRESET); 1300 musb_g_giveback(musb_ep, request, -ECONNRESET);
1301 1301
1302 /* ... else abort the dma transfer ... */ 1302 /* ... else abort the dma transfer ... */
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 0144a2d481f..d281792db05 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -169,6 +169,14 @@ static int dma_channel_program(struct dma_channel *channel,
169 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || 169 BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
170 channel->status == MUSB_DMA_STATUS_BUSY); 170 channel->status == MUSB_DMA_STATUS_BUSY);
171 171
172 /* Let targets check/tweak the arguments */
173 if (musb->ops->adjust_channel_params) {
174 int ret = musb->ops->adjust_channel_params(channel,
175 packet_sz, &mode, &dma_addr, &len);
176 if (ret)
177 return ret;
178 }
179
172 /* 180 /*
173 * The DMA engine in RTL1.8 and above cannot handle 181 * The DMA engine in RTL1.8 and above cannot handle
174 * DMA addresses that are not aligned to a 4 byte boundary. 182 * DMA addresses that are not aligned to a 4 byte boundary.
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 25cb8b0003b..57a27fa954b 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -259,9 +259,10 @@ static int musb_otg_notifications(struct notifier_block *nb,
259 case USB_EVENT_VBUS: 259 case USB_EVENT_VBUS:
260 DBG(4, "VBUS Connect\n"); 260 DBG(4, "VBUS Connect\n");
261 261
262#ifdef CONFIG_USB_GADGET_MUSB_HDRC
262 if (musb->gadget_driver) 263 if (musb->gadget_driver)
263 pm_runtime_get_sync(musb->controller); 264 pm_runtime_get_sync(musb->controller);
264 265#endif
265 otg_init(musb->xceiv); 266 otg_init(musb->xceiv);
266 break; 267 break;
267 268
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d6384e4aeef..f7e04bf34a1 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -93,6 +93,8 @@ static int __init ux500_probe(struct platform_device *pdev)
93 } 93 }
94 94
95 musb->dev.parent = &pdev->dev; 95 musb->dev.parent = &pdev->dev;
96 musb->dev.dma_mask = pdev->dev.dma_mask;
97 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
96 98
97 glue->dev = &pdev->dev; 99 glue->dev = &pdev->dev;
98 glue->musb = musb; 100 glue->musb = musb;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index a973c7a29d6..4de6ef0ae52 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -151,6 +151,8 @@ static struct ftdi_sio_quirk ftdi_stmclite_quirk = {
151 * /sys/bus/usb/ftdi_sio/new_id, then send patch/report! 151 * /sys/bus/usb/ftdi_sio/new_id, then send patch/report!
152 */ 152 */
153static struct usb_device_id id_table_combined [] = { 153static struct usb_device_id id_table_combined [] = {
154 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) },
155 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) },
154 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, 156 { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
155 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, 157 { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
156 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, 158 { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
@@ -525,6 +527,7 @@ static struct usb_device_id id_table_combined [] = {
525 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) }, 527 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
526 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) }, 528 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
527 { USB_DEVICE(OCT_VID, OCT_US101_PID) }, 529 { USB_DEVICE(OCT_VID, OCT_US101_PID) },
530 { USB_DEVICE(OCT_VID, OCT_DK201_PID) },
528 { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID), 531 { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
529 .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk }, 532 .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
530 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID), 533 { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
@@ -787,6 +790,8 @@ static struct usb_device_id id_table_combined [] = {
787 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), 790 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
788 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 791 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
789 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, 792 { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
793 { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) },
794 { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) },
790 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) }, 795 { USB_DEVICE(FTDI_VID, HAMEG_HO870_PID) },
791 { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) }, 796 { USB_DEVICE(FTDI_VID, MJSG_GENERIC_PID) },
792 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) }, 797 { USB_DEVICE(FTDI_VID, MJSG_SR_RADIO_PID) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index c543e55bafb..efffc23723b 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -300,6 +300,8 @@
300 * Hameg HO820 and HO870 interface (using VID 0x0403) 300 * Hameg HO820 and HO870 interface (using VID 0x0403)
301 */ 301 */
302#define HAMEG_HO820_PID 0xed74 302#define HAMEG_HO820_PID 0xed74
303#define HAMEG_HO730_PID 0xed73
304#define HAMEG_HO720_PID 0xed72
303#define HAMEG_HO870_PID 0xed71 305#define HAMEG_HO870_PID 0xed71
304 306
305/* 307/*
@@ -572,6 +574,7 @@
572/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */ 574/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
573/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */ 575/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
574/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */ 576/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
577#define OCT_DK201_PID 0x0103 /* OCT DK201 USB docking station */
575#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 578#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
576 579
577/* 580/*
@@ -1141,3 +1144,12 @@
1141#define QIHARDWARE_VID 0x20B7 1144#define QIHARDWARE_VID 0x20B7
1142#define MILKYMISTONE_JTAGSERIAL_PID 0x0713 1145#define MILKYMISTONE_JTAGSERIAL_PID 0x0713
1143 1146
1147/*
1148 * CTI GmbH RS485 Converter http://www.cti-lean.com/
1149 */
1150/* USB-485-Mini*/
1151#define FTDI_CTI_MINI_PID 0xF608
1152/* USB-Nano-485*/
1153#define FTDI_CTI_NANO_PID 0xF60B
1154
1155
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 75c7f456eed..d77ff043589 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -407,6 +407,10 @@ static void option_instat_callback(struct urb *urb);
407/* ONDA MT825UP HSDPA 14.2 modem */ 407/* ONDA MT825UP HSDPA 14.2 modem */
408#define ONDA_MT825UP 0x000b 408#define ONDA_MT825UP 0x000b
409 409
410/* Samsung products */
411#define SAMSUNG_VENDOR_ID 0x04e8
412#define SAMSUNG_PRODUCT_GT_B3730 0x6889
413
410/* some devices interfaces need special handling due to a number of reasons */ 414/* some devices interfaces need special handling due to a number of reasons */
411enum option_blacklist_reason { 415enum option_blacklist_reason {
412 OPTION_BLACKLIST_NONE = 0, 416 OPTION_BLACKLIST_NONE = 0,
@@ -968,6 +972,7 @@ static const struct usb_device_id option_ids[] = {
968 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, 972 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
969 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 973 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
970 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */ 974 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
975 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730/GT-B3710 LTE USB modem.*/
971 { } /* Terminating entry */ 976 { } /* Terminating entry */
972}; 977};
973MODULE_DEVICE_TABLE(usb, option_ids); 978MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 8858201eb1d..54a9dab1f33 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -111,7 +111,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
111 ifnum = intf->desc.bInterfaceNumber; 111 ifnum = intf->desc.bInterfaceNumber;
112 dbg("This Interface = %d", ifnum); 112 dbg("This Interface = %d", ifnum);
113 113
114 data = serial->private = kzalloc(sizeof(struct usb_wwan_intf_private), 114 data = kzalloc(sizeof(struct usb_wwan_intf_private),
115 GFP_KERNEL); 115 GFP_KERNEL);
116 if (!data) 116 if (!data)
117 return -ENOMEM; 117 return -ENOMEM;
@@ -134,8 +134,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
134 usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) { 134 usb_endpoint_is_bulk_out(&intf->endpoint[1].desc)) {
135 dbg("QDL port found"); 135 dbg("QDL port found");
136 136
137 if (serial->interface->num_altsetting == 1) 137 if (serial->interface->num_altsetting == 1) {
138 return 0; 138 retval = 0; /* Success */
139 break;
140 }
139 141
140 retval = usb_set_interface(serial->dev, ifnum, 1); 142 retval = usb_set_interface(serial->dev, ifnum, 1);
141 if (retval < 0) { 143 if (retval < 0) {
@@ -145,7 +147,6 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
145 retval = -ENODEV; 147 retval = -ENODEV;
146 kfree(data); 148 kfree(data);
147 } 149 }
148 return retval;
149 } 150 }
150 break; 151 break;
151 152
@@ -166,6 +167,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
166 "Could not set interface, error %d\n", 167 "Could not set interface, error %d\n",
167 retval); 168 retval);
168 retval = -ENODEV; 169 retval = -ENODEV;
170 kfree(data);
169 } 171 }
170 } else if (ifnum == 2) { 172 } else if (ifnum == 2) {
171 dbg("Modem port found"); 173 dbg("Modem port found");
@@ -177,7 +179,6 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
177 retval = -ENODEV; 179 retval = -ENODEV;
178 kfree(data); 180 kfree(data);
179 } 181 }
180 return retval;
181 } else if (ifnum==3) { 182 } else if (ifnum==3) {
182 /* 183 /*
183 * NMEA (serial line 9600 8N1) 184 * NMEA (serial line 9600 8N1)
@@ -191,6 +192,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
191 "Could not set interface, error %d\n", 192 "Could not set interface, error %d\n",
192 retval); 193 retval);
193 retval = -ENODEV; 194 retval = -ENODEV;
195 kfree(data);
194 } 196 }
195 } 197 }
196 break; 198 break;
@@ -199,12 +201,27 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
199 dev_err(&serial->dev->dev, 201 dev_err(&serial->dev->dev,
200 "unknown number of interfaces: %d\n", nintf); 202 "unknown number of interfaces: %d\n", nintf);
201 kfree(data); 203 kfree(data);
202 return -ENODEV; 204 retval = -ENODEV;
203 } 205 }
204 206
207 /* Set serial->private if not returning -ENODEV */
208 if (retval != -ENODEV)
209 usb_set_serial_data(serial, data);
205 return retval; 210 return retval;
206} 211}
207 212
213static void qc_release(struct usb_serial *serial)
214{
215 struct usb_wwan_intf_private *priv = usb_get_serial_data(serial);
216
217 dbg("%s", __func__);
218
219 /* Call usb_wwan release & free the private data allocated in qcprobe */
220 usb_wwan_release(serial);
221 usb_set_serial_data(serial, NULL);
222 kfree(priv);
223}
224
208static struct usb_serial_driver qcdevice = { 225static struct usb_serial_driver qcdevice = {
209 .driver = { 226 .driver = {
210 .owner = THIS_MODULE, 227 .owner = THIS_MODULE,
@@ -222,7 +239,7 @@ static struct usb_serial_driver qcdevice = {
222 .chars_in_buffer = usb_wwan_chars_in_buffer, 239 .chars_in_buffer = usb_wwan_chars_in_buffer,
223 .attach = usb_wwan_startup, 240 .attach = usb_wwan_startup,
224 .disconnect = usb_wwan_disconnect, 241 .disconnect = usb_wwan_disconnect,
225 .release = usb_wwan_release, 242 .release = qc_release,
226#ifdef CONFIG_PM 243#ifdef CONFIG_PM
227 .suspend = usb_wwan_suspend, 244 .suspend = usb_wwan_suspend,
228 .resume = usb_wwan_resume, 245 .resume = usb_wwan_resume,