Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a small number of USB fixes for 5.12-rc3 to resolve a bunch
of reported issues:

- usbip fixups for issues found by syzbot

- xhci driver fixes and quirk additions

- gadget driver fixes

- dwc3 QCOM driver fix

- usb-serial new ids and fixes

- usblp fix for a long-time issue

- cdc-acm quirk addition

- other tiny fixes for reported problems

All of these have been in linux-next for a while with no reported
issues"

* tag 'usb-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits)
xhci: Fix repeated xhci wake after suspend due to uncleared internal wake state
usb: xhci: Fix ASMedia ASM1042A and ASM3242 DMA addressing
xhci: Improve detection of device initiated wake signal.
usb: xhci: do not perform Soft Retry for some xHCI hosts
usbip: fix vudc usbip_sockfd_store races leading to gpf
usbip: fix vhci_hcd attach_store() races leading to gpf
usbip: fix stub_dev usbip_sockfd_store() races leading to gpf
usbip: fix vudc to check for stream socket
usbip: fix vhci_hcd to check for stream socket
usbip: fix stub_dev to check for stream socket
usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement
USB: usblp: fix a hang in poll() if disconnected
USB: gadget: udc: s3c2410_udc: fix return value check in s3c2410_udc_probe()
usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM
usb: dwc3: qcom: Honor wakeup enabled/disabled state
usb: gadget: f_uac1: stop playback on function disable
usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot
USB: gadget: u_ether: Fix a configfs return code
usb: dwc3: qcom: add ACPI device id for sc8180x
Goodix Fingerprint device is not a modem
...

+229 -110
+5
drivers/usb/class/cdc-acm.c
··· 1935 1935 .driver_info = SEND_ZERO_PACKET, 1936 1936 }, 1937 1937 1938 + /* Exclude Goodix Fingerprint Reader */ 1939 + { USB_DEVICE(0x27c6, 0x5395), 1940 + .driver_info = IGNORE_DEVICE, 1941 + }, 1942 + 1938 1943 /* control interfaces without any protocol set */ 1939 1944 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1940 1945 USB_CDC_PROTO_NONE) },
+12 -4
drivers/usb/class/usblp.c
··· 494 494 /* No kernel lock - fine */ 495 495 static __poll_t usblp_poll(struct file *file, struct poll_table_struct *wait) 496 496 { 497 - __poll_t ret; 497 + struct usblp *usblp = file->private_data; 498 + __poll_t ret = 0; 498 499 unsigned long flags; 499 500 500 - struct usblp *usblp = file->private_data; 501 501 /* Should we check file->f_mode & FMODE_WRITE before poll_wait()? */ 502 502 poll_wait(file, &usblp->rwait, wait); 503 503 poll_wait(file, &usblp->wwait, wait); 504 + 505 + mutex_lock(&usblp->mut); 506 + if (!usblp->present) 507 + ret |= EPOLLHUP; 508 + mutex_unlock(&usblp->mut); 509 + 504 510 spin_lock_irqsave(&usblp->lock, flags); 505 - ret = ((usblp->bidir && usblp->rcomplete) ? EPOLLIN | EPOLLRDNORM : 0) | 506 - ((usblp->no_paper || usblp->wcomplete) ? EPOLLOUT | EPOLLWRNORM : 0); 511 + if (usblp->bidir && usblp->rcomplete) 512 + ret |= EPOLLIN | EPOLLRDNORM; 513 + if (usblp->no_paper || usblp->wcomplete) 514 + ret |= EPOLLOUT | EPOLLWRNORM; 507 515 spin_unlock_irqrestore(&usblp->lock, flags); 508 516 return ret; 509 517 }
+13 -5
drivers/usb/dwc3/dwc3-qcom.c
··· 358 358 if (ret) 359 359 dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret); 360 360 361 + if (device_may_wakeup(qcom->dev)) 362 + dwc3_qcom_enable_interrupts(qcom); 363 + 361 364 qcom->is_suspended = true; 362 - dwc3_qcom_enable_interrupts(qcom); 363 365 364 366 return 0; 365 367 } ··· 374 372 if (!qcom->is_suspended) 375 373 return 0; 376 374 377 - dwc3_qcom_disable_interrupts(qcom); 375 + if (device_may_wakeup(qcom->dev)) 376 + dwc3_qcom_disable_interrupts(qcom); 378 377 379 378 for (i = 0; i < qcom->num_clocks; i++) { 380 379 ret = clk_prepare_enable(qcom->clks[i]); ··· 653 650 ret = of_platform_populate(np, NULL, NULL, dev); 654 651 if (ret) { 655 652 dev_err(dev, "failed to register dwc3 core - %d\n", ret); 656 - return ret; 653 + goto node_put; 657 654 } 658 655 659 656 qcom->dwc3 = of_find_device_by_node(dwc3_np); 660 657 if (!qcom->dwc3) { 658 + ret = -ENODEV; 661 659 dev_err(dev, "failed to get dwc3 platform device\n"); 662 - return -ENODEV; 663 660 } 664 661 665 - return 0; 662 + node_put: 663 + of_node_put(dwc3_np); 664 + 665 + return ret; 666 666 } 667 667 668 668 static struct platform_device * ··· 944 938 static const struct acpi_device_id dwc3_qcom_acpi_match[] = { 945 939 { "QCOM2430", (unsigned long)&sdm845_acpi_pdata }, 946 940 { "QCOM0304", (unsigned long)&sdm845_acpi_urs_pdata }, 941 + { "QCOM0497", (unsigned long)&sdm845_acpi_urs_pdata }, 942 + { "QCOM04A6", (unsigned long)&sdm845_acpi_pdata }, 947 943 { }, 948 944 }; 949 945 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
+1
drivers/usb/gadget/function/f_uac1.c
··· 499 499 uac1->as_out_alt = 0; 500 500 uac1->as_in_alt = 0; 501 501 502 + u_audio_stop_playback(&uac1->g_audio); 502 503 u_audio_stop_capture(&uac1->g_audio); 503 504 } 504 505
+1 -1
drivers/usb/gadget/function/f_uac2.c
··· 478 478 } 479 479 480 480 max_size_bw = num_channels(chmask) * ssize * 481 - DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))); 481 + ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1); 482 482 ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw, 483 483 max_size_ep)); 484 484
+2 -3
drivers/usb/gadget/function/u_ether_configfs.h
··· 182 182 size_t len) \ 183 183 { \ 184 184 struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 185 - int ret; \ 185 + int ret = -EINVAL; \ 186 186 u8 val; \ 187 187 \ 188 188 mutex_lock(&opts->lock); \ 189 - ret = sscanf(page, "%02hhx", &val); \ 190 - if (ret > 0) { \ 189 + if (sscanf(page, "%02hhx", &val) > 0) { \ 191 190 opts->_n_ = val; \ 192 191 ret = len; \ 193 192 } \
+2 -2
drivers/usb/gadget/udc/s3c2410_udc.c
··· 1773 1773 udc_info = dev_get_platdata(&pdev->dev); 1774 1774 1775 1775 base_addr = devm_platform_ioremap_resource(pdev, 0); 1776 - if (!base_addr) { 1777 - retval = -ENOMEM; 1776 + if (IS_ERR(base_addr)) { 1777 + retval = PTR_ERR(base_addr); 1778 1778 goto err_mem; 1779 1779 } 1780 1780
+11 -2
drivers/usb/host/xhci-pci.c
··· 66 66 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 67 67 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242 68 68 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 69 + #define PCI_DEVICE_ID_ASMEDIA_3242_XHCI 0x3242 69 70 70 71 static const char hcd_name[] = "xhci_hcd"; 71 72 ··· 277 276 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) 278 277 xhci->quirks |= XHCI_BROKEN_STREAMS; 279 278 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && 280 - pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) 279 + pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) { 281 280 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 281 + xhci->quirks |= XHCI_NO_64BIT_SUPPORT; 282 + } 282 283 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && 283 284 (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI || 284 - pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI)) 285 + pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI || 286 + pdev->device == PCI_DEVICE_ID_ASMEDIA_3242_XHCI)) 285 287 xhci->quirks |= XHCI_NO_64BIT_SUPPORT; 286 288 287 289 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && ··· 298 294 pdev->vendor == PCI_VENDOR_ID_CAVIUM) && 299 295 pdev->device == 0x9026) 300 296 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT; 297 + 298 + if (pdev->vendor == PCI_VENDOR_ID_AMD && 299 + (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2 || 300 + pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4)) 301 + xhci->quirks |= XHCI_NO_SOFT_RETRY; 301 302 302 303 if (xhci->quirks & XHCI_RESET_ON_RESUME) 303 304 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
+2 -1
drivers/usb/host/xhci-ring.c
··· 2484 2484 remaining = 0; 2485 2485 break; 2486 2486 case COMP_USB_TRANSACTION_ERROR: 2487 - if ((ep_ring->err_count++ > MAX_SOFT_RETRY) || 2487 + if (xhci->quirks & XHCI_NO_SOFT_RETRY || 2488 + (ep_ring->err_count++ > MAX_SOFT_RETRY) || 2488 2489 le32_to_cpu(slot_ctx->tt_info) & TT_SLOT) 2489 2490 break; 2490 2491
+43 -35
drivers/usb/host/xhci.c
··· 883 883 xhci_set_cmd_ring_deq(xhci); 884 884 } 885 885 886 - static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci) 886 + /* 887 + * Disable port wake bits if do_wakeup is not set. 888 + * 889 + * Also clear a possible internal port wake state left hanging for ports that 890 + * detected termination but never successfully enumerated (trained to 0U). 891 + * Internal wake causes immediate xHCI wake after suspend. PORT_CSC write done 892 + * at enumeration clears this wake, force one here as well for unconnected ports 893 + */ 894 + 895 + static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci, 896 + struct xhci_hub *rhub, 897 + bool do_wakeup) 887 898 { 888 - struct xhci_port **ports; 889 - int port_index; 890 899 unsigned long flags; 891 900 u32 t1, t2, portsc; 901 + int i; 892 902 893 903 spin_lock_irqsave(&xhci->lock, flags); 894 904 895 - /* disable usb3 ports Wake bits */ 896 - port_index = xhci->usb3_rhub.num_ports; 897 - ports = xhci->usb3_rhub.ports; 898 - while (port_index--) { 899 - t1 = readl(ports[port_index]->addr); 900 - portsc = t1; 901 - t1 = xhci_port_state_to_neutral(t1); 902 - t2 = t1 & ~PORT_WAKE_BITS; 903 - if (t1 != t2) { 904 - writel(t2, ports[port_index]->addr); 905 - xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n", 906 - xhci->usb3_rhub.hcd->self.busnum, 907 - port_index + 1, portsc, t2); 908 - } 909 - } 905 + for (i = 0; i < rhub->num_ports; i++) { 906 + portsc = readl(rhub->ports[i]->addr); 907 + t1 = xhci_port_state_to_neutral(portsc); 908 + t2 = t1; 910 909 911 - /* disable usb2 ports Wake bits */ 912 - port_index = xhci->usb2_rhub.num_ports; 913 - ports = xhci->usb2_rhub.ports; 914 - while (port_index--) { 915 - t1 = readl(ports[port_index]->addr); 916 - portsc = t1; 917 - t1 = xhci_port_state_to_neutral(t1); 918 - t2 = t1 & ~PORT_WAKE_BITS; 910 + /* clear wake bits if do_wake is not set */ 911 + if (!do_wakeup) 912 + t2 &= ~PORT_WAKE_BITS; 913 + 914 + /* Don't touch csc bit if connected or connect change is set */ 915 + if (!(portsc & (PORT_CSC | PORT_CONNECT))) 916 + t2 |= PORT_CSC; 917 + 919 918 if (t1 != t2) { 920 - writel(t2, ports[port_index]->addr); 921 - xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n", 922 - xhci->usb2_rhub.hcd->self.busnum, 923 - port_index + 1, portsc, t2); 919 + writel(t2, rhub->ports[i]->addr); 920 + xhci_dbg(xhci, "config port %d-%d wake bits, portsc: 0x%x, write: 0x%x\n", 921 + rhub->hcd->self.busnum, i + 1, portsc, t2); 924 922 } 925 923 } 926 924 spin_unlock_irqrestore(&xhci->lock, flags); ··· 981 983 return -EINVAL; 982 984 983 985 /* Clear root port wake on bits if wakeup not allowed. */ 984 - if (!do_wakeup) 985 - xhci_disable_port_wake_on_bits(xhci); 986 + xhci_disable_hub_port_wake(xhci, &xhci->usb3_rhub, do_wakeup); 987 + xhci_disable_hub_port_wake(xhci, &xhci->usb2_rhub, do_wakeup); 986 988 987 989 if (!HCD_HW_ACCESSIBLE(hcd)) 988 990 return 0; ··· 1086 1088 struct usb_hcd *secondary_hcd; 1087 1089 int retval = 0; 1088 1090 bool comp_timer_running = false; 1091 + bool pending_portevent = false; 1089 1092 1090 1093 if (!hcd->state) 1091 1094 return 0; ··· 1225 1226 1226 1227 done: 1227 1228 if (retval == 0) { 1228 - /* Resume root hubs only when have pending events. */ 1229 - if (xhci_pending_portevent(xhci)) { 1229 + /* 1230 + * Resume roothubs only if there are pending events. 1231 + * USB 3 devices resend U3 LFPS wake after a 100ms delay if 1232 + * the first wake signalling failed, give it that chance. 1233 + */ 1234 + pending_portevent = xhci_pending_portevent(xhci); 1235 + if (!pending_portevent) { 1236 + msleep(120); 1237 + pending_portevent = xhci_pending_portevent(xhci); 1238 + } 1239 + 1240 + if (pending_portevent) { 1230 1241 usb_hcd_resume_root_hub(xhci->shared_hcd); 1231 1242 usb_hcd_resume_root_hub(hcd); 1232 1243 } 1233 1244 } 1234 - 1235 1245 /* 1236 1246 * If system is subject to the Quirk, Compliance Mode Timer needs to 1237 1247 * be re-initialized Always after a system resume. Ports are subject
+1
drivers/usb/host/xhci.h
··· 1891 1891 #define XHCI_SKIP_PHY_INIT BIT_ULL(37) 1892 1892 #define XHCI_DISABLE_SPARSE BIT_ULL(38) 1893 1893 #define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39) 1894 + #define XHCI_NO_SOFT_RETRY BIT_ULL(40) 1894 1895 1895 1896 unsigned int num_active_eps; 1896 1897 unsigned int limit_active_eps;
+2
drivers/usb/renesas_usbhs/pipe.c
··· 746 746 747 747 void usbhs_pipe_free(struct usbhs_pipe *pipe) 748 748 { 749 + usbhsp_pipe_select(pipe); 750 + usbhsp_pipe_cfg_set(pipe, 0xFFFF, 0); 749 751 usbhsp_put_pipe(pipe); 750 752 } 751 753
+1
drivers/usb/serial/ch341.c
··· 86 86 { USB_DEVICE(0x1a86, 0x7522) }, 87 87 { USB_DEVICE(0x1a86, 0x7523) }, 88 88 { USB_DEVICE(0x4348, 0x5523) }, 89 + { USB_DEVICE(0x9986, 0x7523) }, 89 90 { }, 90 91 }; 91 92 MODULE_DEVICE_TABLE(usb, id_table);
+3
drivers/usb/serial/cp210x.c
··· 145 145 { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */ 146 146 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ 147 147 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ 148 + { USB_DEVICE(0x10C4, 0x88D8) }, /* Acuity Brands nLight Air Adapter */ 148 149 { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */ 149 150 { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */ 150 151 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ ··· 202 201 { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */ 203 202 { USB_DEVICE(0x1901, 0x0195) }, /* GE B850/B650/B450 CP2104 DP UART interface */ 204 203 { USB_DEVICE(0x1901, 0x0196) }, /* GE B850 CP2105 DP UART interface */ 204 + { USB_DEVICE(0x1901, 0x0197) }, /* GE CS1000 Display serial interface */ 205 + { USB_DEVICE(0x1901, 0x0198) }, /* GE CS1000 M.2 Key E serial interface */ 205 206 { USB_DEVICE(0x199B, 0xBA30) }, /* LORD WSDA-200-USB */ 206 207 { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */ 207 208 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
+16 -10
drivers/usb/serial/io_edgeport.c
··· 3003 3003 response = -ENODEV; 3004 3004 } 3005 3005 3006 - usb_free_urb(edge_serial->interrupt_read_urb); 3007 - kfree(edge_serial->interrupt_in_buffer); 3008 - 3009 - usb_free_urb(edge_serial->read_urb); 3010 - kfree(edge_serial->bulk_in_buffer); 3011 - 3012 - kfree(edge_serial); 3013 - 3014 - return response; 3006 + goto error; 3015 3007 } 3016 3008 3017 3009 /* start interrupt read for this edgeport this interrupt will 3018 3010 * continue as long as the edgeport is connected */ 3019 3011 response = usb_submit_urb(edge_serial->interrupt_read_urb, 3020 3012 GFP_KERNEL); 3021 - if (response) 3013 + if (response) { 3022 3014 dev_err(ddev, "%s - Error %d submitting control urb\n", 3023 3015 __func__, response); 3016 + 3017 + goto error; 3018 + } 3024 3019 } 3020 + return response; 3021 + 3022 + error: 3023 + usb_free_urb(edge_serial->interrupt_read_urb); 3024 + kfree(edge_serial->interrupt_in_buffer); 3025 + 3026 + usb_free_urb(edge_serial->read_urb); 3027 + kfree(edge_serial->bulk_in_buffer); 3028 + 3029 + kfree(edge_serial); 3030 + 3025 3031 return response; 3026 3032 } 3027 3033
-25
drivers/usb/serial/xr_serial.c
··· 545 545 546 546 static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id) 547 547 { 548 - struct usb_driver *driver = serial->type->usb_driver; 549 - struct usb_interface *control_interface; 550 - int ret; 551 - 552 548 /* Don't bind to control interface */ 553 549 if (serial->interface->cur_altsetting->desc.bInterfaceNumber == 0) 554 550 return -ENODEV; 555 551 556 - /* But claim the control interface during data interface probe */ 557 - control_interface = usb_ifnum_to_if(serial->dev, 0); 558 - if (!control_interface) 559 - return -ENODEV; 560 - 561 - ret = usb_driver_claim_interface(driver, control_interface, NULL); 562 - if (ret) { 563 - dev_err(&serial->interface->dev, "Failed to claim control interface\n"); 564 - return ret; 565 - } 566 - 567 552 return 0; 568 - } 569 - 570 - static void xr_disconnect(struct usb_serial *serial) 571 - { 572 - struct usb_driver *driver = serial->type->usb_driver; 573 - struct usb_interface *control_interface; 574 - 575 - control_interface = usb_ifnum_to_if(serial->dev, 0); 576 - usb_driver_release_interface(driver, control_interface); 577 553 } 578 554 579 555 static const struct usb_device_id id_table[] = { ··· 566 590 .id_table = id_table, 567 591 .num_ports = 1, 568 592 .probe = xr_probe, 569 - .disconnect = xr_disconnect, 570 593 .open = xr_open, 571 594 .close = xr_close, 572 595 .break_ctl = xr_break_ctl,
+38 -10
drivers/usb/usbip/stub_dev.c
··· 46 46 int sockfd = 0; 47 47 struct socket *socket; 48 48 int rv; 49 + struct task_struct *tcp_rx = NULL; 50 + struct task_struct *tcp_tx = NULL; 49 51 50 52 if (!sdev) { 51 53 dev_err(dev, "sdev is null\n"); ··· 71 69 } 72 70 73 71 socket = sockfd_lookup(sockfd, &err); 74 - if (!socket) 72 + if (!socket) { 73 + dev_err(dev, "failed to lookup sock"); 75 74 goto err; 75 + } 76 76 77 + if (socket->type != SOCK_STREAM) { 78 + dev_err(dev, "Expecting SOCK_STREAM - found %d", 79 + socket->type); 80 + goto sock_err; 81 + } 82 + 83 + /* unlock and create threads and get tasks */ 84 + spin_unlock_irq(&sdev->ud.lock); 85 + tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx"); 86 + if (IS_ERR(tcp_rx)) { 87 + sockfd_put(socket); 88 + return -EINVAL; 89 + } 90 + tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx"); 91 + if (IS_ERR(tcp_tx)) { 92 + kthread_stop(tcp_rx); 93 + sockfd_put(socket); 94 + return -EINVAL; 95 + } 96 + 97 + /* get task structs now */ 98 + get_task_struct(tcp_rx); 99 + get_task_struct(tcp_tx); 100 + 101 + /* lock and update sdev->ud state */ 102 + spin_lock_irq(&sdev->ud.lock); 77 103 sdev->ud.tcp_socket = socket; 78 104 sdev->ud.sockfd = sockfd; 79 - 80 - spin_unlock_irq(&sdev->ud.lock); 81 - 82 - sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, 83 - "stub_rx"); 84 - sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, 85 - "stub_tx"); 86 - 87 - spin_lock_irq(&sdev->ud.lock); 105 + sdev->ud.tcp_rx = tcp_rx; 106 + sdev->ud.tcp_tx = tcp_tx; 88 107 sdev->ud.status = SDEV_ST_USED; 89 108 spin_unlock_irq(&sdev->ud.lock); 109 + 110 + wake_up_process(sdev->ud.tcp_rx); 111 + wake_up_process(sdev->ud.tcp_tx); 90 112 91 113 } else { 92 114 dev_info(dev, "stub down\n"); ··· 126 100 127 101 return count; 128 102 103 + sock_err: 104 + sockfd_put(socket); 129 105 err: 130 106 spin_unlock_irq(&sdev->ud.lock); 131 107 return -EINVAL;
+34 -5
drivers/usb/usbip/vhci_sysfs.c
··· 312 312 struct vhci *vhci; 313 313 int err; 314 314 unsigned long flags; 315 + struct task_struct *tcp_rx = NULL; 316 + struct task_struct *tcp_tx = NULL; 315 317 316 318 /* 317 319 * @rhport: port number of vhci_hcd ··· 351 349 352 350 /* Extract socket from fd. */ 353 351 socket = sockfd_lookup(sockfd, &err); 354 - if (!socket) 352 + if (!socket) { 353 + dev_err(dev, "failed to lookup sock"); 355 354 return -EINVAL; 355 + } 356 + if (socket->type != SOCK_STREAM) { 357 + dev_err(dev, "Expecting SOCK_STREAM - found %d", 358 + socket->type); 359 + sockfd_put(socket); 360 + return -EINVAL; 361 + } 356 362 357 - /* now need lock until setting vdev status as used */ 363 + /* create threads before locking */ 364 + tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx"); 365 + if (IS_ERR(tcp_rx)) { 366 + sockfd_put(socket); 367 + return -EINVAL; 368 + } 369 + tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx"); 370 + if (IS_ERR(tcp_tx)) { 371 + kthread_stop(tcp_rx); 372 + sockfd_put(socket); 373 + return -EINVAL; 374 + } 358 375 359 - /* begin a lock */ 376 + /* get task structs now */ 377 + get_task_struct(tcp_rx); 378 + get_task_struct(tcp_tx); 379 + 380 + /* now begin lock until setting vdev status set */ 360 381 spin_lock_irqsave(&vhci->lock, flags); 361 382 spin_lock(&vdev->ud.lock); 362 383 ··· 389 364 spin_unlock_irqrestore(&vhci->lock, flags); 390 365 391 366 sockfd_put(socket); 367 + kthread_stop_put(tcp_rx); 368 + kthread_stop_put(tcp_tx); 392 369 393 370 dev_err(dev, "port %d already used\n", rhport); 394 371 /* ··· 409 382 vdev->speed = speed; 410 383 vdev->ud.sockfd = sockfd; 411 384 vdev->ud.tcp_socket = socket; 385 + vdev->ud.tcp_rx = tcp_rx; 386 + vdev->ud.tcp_tx = tcp_tx; 412 387 vdev->ud.status = VDEV_ST_NOTASSIGNED; 413 388 usbip_kcov_handle_init(&vdev->ud); 414 389 ··· 418 389 spin_unlock_irqrestore(&vhci->lock, flags); 419 390 /* end the lock */ 420 391 421 - vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); 422 - vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx"); 392 + wake_up_process(vdev->ud.tcp_rx); 393 + wake_up_process(vdev->ud.tcp_tx); 423 394 424 395 rh_port_connect(vdev, speed); 425 396
+42 -7
drivers/usb/usbip/vudc_sysfs.c
··· 90 90 } 91 91 static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); 92 92 93 - static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *attr, 94 - const char *in, size_t count) 93 + static ssize_t usbip_sockfd_store(struct device *dev, 94 + struct device_attribute *attr, 95 + const char *in, size_t count) 95 96 { 96 97 struct vudc *udc = (struct vudc *) dev_get_drvdata(dev); 97 98 int rv; ··· 101 100 struct socket *socket; 102 101 unsigned long flags; 103 102 int ret; 103 + struct task_struct *tcp_rx = NULL; 104 + struct task_struct *tcp_tx = NULL; 104 105 105 106 rv = kstrtoint(in, 0, &sockfd); 106 107 if (rv != 0) ··· 141 138 goto unlock_ud; 142 139 } 143 140 144 - udc->ud.tcp_socket = socket; 141 + if (socket->type != SOCK_STREAM) { 142 + dev_err(dev, "Expecting SOCK_STREAM - found %d", 143 + socket->type); 144 + ret = -EINVAL; 145 + goto sock_err; 146 + } 145 147 148 + /* unlock and create threads and get tasks */ 146 149 spin_unlock_irq(&udc->ud.lock); 147 150 spin_unlock_irqrestore(&udc->lock, flags); 148 151 149 - udc->ud.tcp_rx = kthread_get_run(&v_rx_loop, 150 - &udc->ud, "vudc_rx"); 151 - udc->ud.tcp_tx = kthread_get_run(&v_tx_loop, 152 - &udc->ud, "vudc_tx"); 152 + tcp_rx = kthread_create(&v_rx_loop, &udc->ud, "vudc_rx"); 153 + if (IS_ERR(tcp_rx)) { 154 + sockfd_put(socket); 155 + return -EINVAL; 156 + } 157 + tcp_tx = kthread_create(&v_tx_loop, &udc->ud, "vudc_tx"); 158 + if (IS_ERR(tcp_tx)) { 159 + kthread_stop(tcp_rx); 160 + sockfd_put(socket); 161 + return -EINVAL; 162 + } 153 163 164 + /* get task structs now */ 165 + get_task_struct(tcp_rx); 166 + get_task_struct(tcp_tx); 167 + 168 + /* lock and update udc->ud state */ 154 169 spin_lock_irqsave(&udc->lock, flags); 155 170 spin_lock_irq(&udc->ud.lock); 171 + 172 + udc->ud.tcp_socket = socket; 173 + udc->ud.tcp_rx = tcp_rx; 174 + udc->ud.tcp_rx = tcp_tx; 156 175 udc->ud.status = SDEV_ST_USED; 176 + 157 177 spin_unlock_irq(&udc->ud.lock); 158 178 159 179 ktime_get_ts64(&udc->start_time); 160 180 v_start_timer(udc); 161 181 udc->connected = 1; 182 + 183 + spin_unlock_irqrestore(&udc->lock, flags); 184 + 185 + wake_up_process(udc->ud.tcp_rx); 186 + wake_up_process(udc->ud.tcp_tx); 187 + return count; 188 + 162 189 } else { 163 190 if (!udc->connected) { 164 191 dev_err(dev, "Device not connected"); ··· 210 177 211 178 return count; 212 179 180 + sock_err: 181 + sockfd_put(socket); 213 182 unlock_ud: 214 183 spin_unlock_irq(&udc->ud.lock); 215 184 unlock: