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-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are a bunch (65) of USB fixes for 4.7-rc4. Sorry about the
quantity, I've been slow in getting these out.

The majority are the "normal" gadget, musb, and xhci fixes, that we
all are used to. There are also a few other tiny fixes resolving a
number of reported issues that showed up in 4.7-rc1.

All of these have been in linux-next"

* tag 'usb-4.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (65 commits)
usbip: rate limit get_frame_number message
usb: musb: sunxi: Remove bogus "Frees glue" comment
usb: musb: sunxi: Fix NULL ptr deref when gadget is registered before musb
usb: echi-hcd: Add ehci_setup check before echi_shutdown
usb: host: ehci-msm: Conditionally call ehci suspend/resume
MAINTAINERS: Add file patterns for usb device tree bindings
usb: host: ehci-tegra: Avoid getting the same reset twice
usb: host: ehci-tegra: Grab the correct UTMI pads reset
USB: mos7720: delete parport
USB: OHCI: Don't mark EDs as ED_OPER if scheduling fails
phy: ti-pipe3: Program the DPLL even if it was already locked
usb: musb: Stop bulk endpoint while queue is rotated
usb: musb: Ensure rx reinit occurs for shared_fifo endpoints
usb: musb: host: correct cppi dma channel for isoch transfer
usb: musb: only restore devctl when session was set in backup
usb: phy: Check initial state for twl6030
usb: musb: Use normal module_init for 2430 glue
usb: musb: Remove pm_runtime_set_irq_safe
usb: musb: Remove extra PM runtime calls from 2430 glue layer
usb: musb: Return error value from musb_mailbox
...

+573 -447
+29 -29
Documentation/ABI/testing/configfs-usb-gadget-uvc
··· 1 1 What: /config/usb-gadget/gadget/functions/uvc.name 2 2 Date: Dec 2014 3 - KernelVersion: 3.20 3 + KernelVersion: 4.0 4 4 Description: UVC function directory 5 5 6 6 streaming_maxburst - 0..15 (ss only) ··· 9 9 10 10 What: /config/usb-gadget/gadget/functions/uvc.name/control 11 11 Date: Dec 2014 12 - KernelVersion: 3.20 12 + KernelVersion: 4.0 13 13 Description: Control descriptors 14 14 15 15 What: /config/usb-gadget/gadget/functions/uvc.name/control/class 16 16 Date: Dec 2014 17 - KernelVersion: 3.20 17 + KernelVersion: 4.0 18 18 Description: Class descriptors 19 19 20 20 What: /config/usb-gadget/gadget/functions/uvc.name/control/class/ss 21 21 Date: Dec 2014 22 - KernelVersion: 3.20 22 + KernelVersion: 4.0 23 23 Description: Super speed control class descriptors 24 24 25 25 What: /config/usb-gadget/gadget/functions/uvc.name/control/class/fs 26 26 Date: Dec 2014 27 - KernelVersion: 3.20 27 + KernelVersion: 4.0 28 28 Description: Full speed control class descriptors 29 29 30 30 What: /config/usb-gadget/gadget/functions/uvc.name/control/terminal 31 31 Date: Dec 2014 32 - KernelVersion: 3.20 32 + KernelVersion: 4.0 33 33 Description: Terminal descriptors 34 34 35 35 What: /config/usb-gadget/gadget/functions/uvc.name/control/terminal/output 36 36 Date: Dec 2014 37 - KernelVersion: 3.20 37 + KernelVersion: 4.0 38 38 Description: Output terminal descriptors 39 39 40 40 What: /config/usb-gadget/gadget/functions/uvc.name/control/terminal/output/default 41 41 Date: Dec 2014 42 - KernelVersion: 3.20 42 + KernelVersion: 4.0 43 43 Description: Default output terminal descriptors 44 44 45 45 All attributes read only: ··· 53 53 54 54 What: /config/usb-gadget/gadget/functions/uvc.name/control/terminal/camera 55 55 Date: Dec 2014 56 - KernelVersion: 3.20 56 + KernelVersion: 4.0 57 57 Description: Camera terminal descriptors 58 58 59 59 What: /config/usb-gadget/gadget/functions/uvc.name/control/terminal/camera/default 60 60 Date: Dec 2014 61 - KernelVersion: 3.20 61 + KernelVersion: 4.0 62 62 Description: Default camera terminal descriptors 63 63 64 64 All attributes read only: ··· 75 75 76 76 What: /config/usb-gadget/gadget/functions/uvc.name/control/processing 77 77 Date: Dec 2014 78 - KernelVersion: 3.20 78 + KernelVersion: 4.0 79 79 Description: Processing unit descriptors 80 80 81 81 What: /config/usb-gadget/gadget/functions/uvc.name/control/processing/default 82 82 Date: Dec 2014 83 - KernelVersion: 3.20 83 + KernelVersion: 4.0 84 84 Description: Default processing unit descriptors 85 85 86 86 All attributes read only: ··· 94 94 95 95 What: /config/usb-gadget/gadget/functions/uvc.name/control/header 96 96 Date: Dec 2014 97 - KernelVersion: 3.20 97 + KernelVersion: 4.0 98 98 Description: Control header descriptors 99 99 100 100 What: /config/usb-gadget/gadget/functions/uvc.name/control/header/name 101 101 Date: Dec 2014 102 - KernelVersion: 3.20 102 + KernelVersion: 4.0 103 103 Description: Specific control header descriptors 104 104 105 105 dwClockFrequency 106 106 bcdUVC 107 107 What: /config/usb-gadget/gadget/functions/uvc.name/streaming 108 108 Date: Dec 2014 109 - KernelVersion: 3.20 109 + KernelVersion: 4.0 110 110 Description: Streaming descriptors 111 111 112 112 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class 113 113 Date: Dec 2014 114 - KernelVersion: 3.20 114 + KernelVersion: 4.0 115 115 Description: Streaming class descriptors 116 116 117 117 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class/ss 118 118 Date: Dec 2014 119 - KernelVersion: 3.20 119 + KernelVersion: 4.0 120 120 Description: Super speed streaming class descriptors 121 121 122 122 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class/hs 123 123 Date: Dec 2014 124 - KernelVersion: 3.20 124 + KernelVersion: 4.0 125 125 Description: High speed streaming class descriptors 126 126 127 127 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class/fs 128 128 Date: Dec 2014 129 - KernelVersion: 3.20 129 + KernelVersion: 4.0 130 130 Description: Full speed streaming class descriptors 131 131 132 132 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/color_matching 133 133 Date: Dec 2014 134 - KernelVersion: 3.20 134 + KernelVersion: 4.0 135 135 Description: Color matching descriptors 136 136 137 137 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/color_matching/default 138 138 Date: Dec 2014 139 - KernelVersion: 3.20 139 + KernelVersion: 4.0 140 140 Description: Default color matching descriptors 141 141 142 142 All attributes read only: ··· 150 150 151 151 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/mjpeg 152 152 Date: Dec 2014 153 - KernelVersion: 3.20 153 + KernelVersion: 4.0 154 154 Description: MJPEG format descriptors 155 155 156 156 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/mjpeg/name 157 157 Date: Dec 2014 158 - KernelVersion: 3.20 158 + KernelVersion: 4.0 159 159 Description: Specific MJPEG format descriptors 160 160 161 161 All attributes read only, ··· 174 174 175 175 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/mjpeg/name/name 176 176 Date: Dec 2014 177 - KernelVersion: 3.20 177 + KernelVersion: 4.0 178 178 Description: Specific MJPEG frame descriptors 179 179 180 180 dwFrameInterval - indicates how frame interval can be ··· 196 196 197 197 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/uncompressed 198 198 Date: Dec 2014 199 - KernelVersion: 3.20 199 + KernelVersion: 4.0 200 200 Description: Uncompressed format descriptors 201 201 202 202 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/uncompressed/name 203 203 Date: Dec 2014 204 - KernelVersion: 3.20 204 + KernelVersion: 4.0 205 205 Description: Specific uncompressed format descriptors 206 206 207 207 bmaControls - this format's data for bmaControls in ··· 221 221 222 222 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/uncompressed/name/name 223 223 Date: Dec 2014 224 - KernelVersion: 3.20 224 + KernelVersion: 4.0 225 225 Description: Specific uncompressed frame descriptors 226 226 227 227 dwFrameInterval - indicates how frame interval can be ··· 243 243 244 244 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/header 245 245 Date: Dec 2014 246 - KernelVersion: 3.20 246 + KernelVersion: 4.0 247 247 Description: Streaming header descriptors 248 248 249 249 What: /config/usb-gadget/gadget/functions/uvc.name/streaming/header/name 250 250 Date: Dec 2014 251 - KernelVersion: 3.20 251 + KernelVersion: 4.0 252 252 Description: Specific streaming header descriptors 253 253 254 254 All attributes read only:
+1
MAINTAINERS
··· 11975 11975 W: http://www.linux-usb.org 11976 11976 T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 11977 11977 S: Supported 11978 + F: Documentation/devicetree/bindings/usb/ 11978 11979 F: Documentation/usb/ 11979 11980 F: drivers/usb/ 11980 11981 F: include/linux/usb.h
+5 -1
drivers/phy/phy-exynos-mipi-video.c
··· 233 233 struct exynos_mipi_video_phy *state) 234 234 { 235 235 u32 val; 236 + int ret; 236 237 237 - regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); 238 + ret = regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); 239 + if (ret) 240 + return 0; 241 + 238 242 return val & data->resetn_val; 239 243 } 240 244
+11 -4
drivers/phy/phy-ti-pipe3.c
··· 293 293 ret = ti_pipe3_dpll_wait_lock(phy); 294 294 } 295 295 296 - /* Program the DPLL only if not locked */ 296 + /* SATA has issues if re-programmed when locked */ 297 297 val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS); 298 - if (!(val & PLL_LOCK)) 299 - if (ti_pipe3_dpll_program(phy)) 300 - return -EINVAL; 298 + if ((val & PLL_LOCK) && of_device_is_compatible(phy->dev->of_node, 299 + "ti,phy-pipe3-sata")) 300 + return ret; 301 + 302 + /* Program the DPLL */ 303 + ret = ti_pipe3_dpll_program(phy); 304 + if (ret) { 305 + ti_pipe3_disable_clocks(phy); 306 + return -EINVAL; 307 + } 301 308 302 309 return ret; 303 310 }
+10 -4
drivers/phy/phy-twl4030-usb.c
··· 463 463 twl4030_usb_set_mode(twl, twl->usb_mode); 464 464 if (twl->usb_mode == T2_USB_MODE_ULPI) 465 465 twl4030_i2c_access(twl, 0); 466 - schedule_delayed_work(&twl->id_workaround_work, 0); 466 + twl->linkstat = MUSB_UNKNOWN; 467 + schedule_delayed_work(&twl->id_workaround_work, HZ); 467 468 468 469 return 0; 469 470 } ··· 538 537 struct twl4030_usb *twl = _twl; 539 538 enum musb_vbus_id_status status; 540 539 bool status_changed = false; 540 + int err; 541 541 542 542 status = twl4030_usb_linkstat(twl); 543 543 ··· 569 567 pm_runtime_mark_last_busy(twl->dev); 570 568 pm_runtime_put_autosuspend(twl->dev); 571 569 } 572 - musb_mailbox(status); 570 + err = musb_mailbox(status); 571 + if (err) 572 + twl->linkstat = MUSB_UNKNOWN; 573 573 } 574 574 575 575 /* don't schedule during sleep - irq works right then */ ··· 599 595 struct twl4030_usb *twl = phy_get_drvdata(phy); 600 596 601 597 pm_runtime_get_sync(twl->dev); 602 - schedule_delayed_work(&twl->id_workaround_work, 0); 598 + twl->linkstat = MUSB_UNKNOWN; 599 + schedule_delayed_work(&twl->id_workaround_work, HZ); 603 600 pm_runtime_mark_last_busy(twl->dev); 604 601 pm_runtime_put_autosuspend(twl->dev); 605 602 ··· 768 763 if (cable_present(twl->linkstat)) 769 764 pm_runtime_put_noidle(twl->dev); 770 765 pm_runtime_mark_last_busy(twl->dev); 771 - pm_runtime_put_sync_suspend(twl->dev); 766 + pm_runtime_dont_use_autosuspend(&pdev->dev); 767 + pm_runtime_put_sync(twl->dev); 772 768 pm_runtime_disable(twl->dev); 773 769 774 770 /* autogate 60MHz ULPI clock,
+13 -10
drivers/usb/core/quirks.c
··· 44 44 /* Creative SB Audigy 2 NX */ 45 45 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, 46 46 47 + /* USB3503 */ 48 + { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, 49 + 47 50 /* Microsoft Wireless Laser Mouse 6000 Receiver */ 48 51 { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME }, 49 52 ··· 176 173 /* MAYA44USB sound device */ 177 174 { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, 178 175 176 + /* ASUS Base Station(T100) */ 177 + { USB_DEVICE(0x0b05, 0x17e0), .driver_info = 178 + USB_QUIRK_IGNORE_REMOTE_WAKEUP }, 179 + 179 180 /* Action Semiconductor flash disk */ 180 181 { USB_DEVICE(0x10d6, 0x2200), .driver_info = 181 182 USB_QUIRK_STRING_FETCH_255 }, ··· 195 188 { USB_DEVICE(0x1908, 0x1315), .driver_info = 196 189 USB_QUIRK_HONOR_BNUMINTERFACES }, 197 190 198 - /* INTEL VALUE SSD */ 199 - { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, 200 - 201 - /* USB3503 */ 202 - { USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME }, 203 - 204 - /* ASUS Base Station(T100) */ 205 - { USB_DEVICE(0x0b05, 0x17e0), .driver_info = 206 - USB_QUIRK_IGNORE_REMOTE_WAKEUP }, 207 - 208 191 /* Protocol and OTG Electrical Test Device */ 209 192 { USB_DEVICE(0x1a0a, 0x0200), .driver_info = 210 193 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, 194 + 195 + /* Acer C120 LED Projector */ 196 + { USB_DEVICE(0x1de1, 0xc102), .driver_info = USB_QUIRK_NO_LPM }, 211 197 212 198 /* Blackmagic Design Intensity Shuttle */ 213 199 { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM }, 214 200 215 201 /* Blackmagic Design UltraStudio SDI */ 216 202 { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, 203 + 204 + /* INTEL VALUE SSD */ 205 + { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, 217 206 218 207 { } /* terminating entry must be last */ 219 208 };
+27
drivers/usb/dwc2/core.h
··· 64 64 DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \ 65 65 dev_name(hsotg->dev), ##__VA_ARGS__) 66 66 67 + #ifdef CONFIG_MIPS 68 + /* 69 + * There are some MIPS machines that can run in either big-endian 70 + * or little-endian mode and that use the dwc2 register without 71 + * a byteswap in both ways. 72 + * Unlike other architectures, MIPS apparently does not require a 73 + * barrier before the __raw_writel() to synchronize with DMA but does 74 + * require the barrier after the __raw_writel() to serialize a set of 75 + * writes. This set of operations was added specifically for MIPS and 76 + * should only be used there. 77 + */ 67 78 static inline u32 dwc2_readl(const void __iomem *addr) 68 79 { 69 80 u32 value = __raw_readl(addr); ··· 101 90 pr_info("INFO:: wrote %08x to %p\n", value, addr); 102 91 #endif 103 92 } 93 + #else 94 + /* Normal architectures just use readl/write */ 95 + static inline u32 dwc2_readl(const void __iomem *addr) 96 + { 97 + return readl(addr); 98 + } 99 + 100 + static inline void dwc2_writel(u32 value, void __iomem *addr) 101 + { 102 + writel(value, addr); 103 + 104 + #ifdef DWC2_LOG_WRITES 105 + pr_info("info:: wrote %08x to %p\n", value, addr); 106 + #endif 107 + } 108 + #endif 104 109 105 110 /* Maximum number of Endpoints/HostChannels */ 106 111 #define MAX_EPS_CHANNELS 16
+20 -4
drivers/usb/dwc2/gadget.c
··· 1018 1018 return 1; 1019 1019 } 1020 1020 1021 - static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value); 1021 + static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now); 1022 1022 1023 1023 /** 1024 1024 * get_ep_head - return the first request on the endpoint ··· 1094 1094 case USB_ENDPOINT_HALT: 1095 1095 halted = ep->halted; 1096 1096 1097 - dwc2_hsotg_ep_sethalt(&ep->ep, set); 1097 + dwc2_hsotg_ep_sethalt(&ep->ep, set, true); 1098 1098 1099 1099 ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0); 1100 1100 if (ret) { ··· 2948 2948 * dwc2_hsotg_ep_sethalt - set halt on a given endpoint 2949 2949 * @ep: The endpoint to set halt. 2950 2950 * @value: Set or unset the halt. 2951 + * @now: If true, stall the endpoint now. Otherwise return -EAGAIN if 2952 + * the endpoint is busy processing requests. 2953 + * 2954 + * We need to stall the endpoint immediately if request comes from set_feature 2955 + * protocol command handler. 2951 2956 */ 2952 - static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value) 2957 + static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now) 2953 2958 { 2954 2959 struct dwc2_hsotg_ep *hs_ep = our_ep(ep); 2955 2960 struct dwc2_hsotg *hs = hs_ep->parent; ··· 2972 2967 dev_warn(hs->dev, 2973 2968 "%s: can't clear halt on ep0\n", __func__); 2974 2969 return 0; 2970 + } 2971 + 2972 + if (hs_ep->isochronous) { 2973 + dev_err(hs->dev, "%s is Isochronous Endpoint\n", ep->name); 2974 + return -EINVAL; 2975 + } 2976 + 2977 + if (!now && value && !list_empty(&hs_ep->queue)) { 2978 + dev_dbg(hs->dev, "%s request is pending, cannot halt\n", 2979 + ep->name); 2980 + return -EAGAIN; 2975 2981 } 2976 2982 2977 2983 if (hs_ep->dir_in) { ··· 3036 3020 int ret = 0; 3037 3021 3038 3022 spin_lock_irqsave(&hs->lock, flags); 3039 - ret = dwc2_hsotg_ep_sethalt(ep, value); 3023 + ret = dwc2_hsotg_ep_sethalt(ep, value, false); 3040 3024 spin_unlock_irqrestore(&hs->lock, flags); 3041 3025 3042 3026 return ret;
+1
drivers/usb/dwc3/core.h
··· 402 402 #define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) 403 403 #define DWC3_DEPCMD_STATUS(x) (((x) >> 12) & 0x0F) 404 404 #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) 405 + #define DWC3_DEPCMD_CLEARPENDIN (1 << 11) 405 406 #define DWC3_DEPCMD_CMDACT (1 << 10) 406 407 #define DWC3_DEPCMD_CMDIOC (1 << 8) 407 408
+11 -8
drivers/usb/dwc3/dwc3-exynos.c
··· 128 128 129 129 platform_set_drvdata(pdev, exynos); 130 130 131 - ret = dwc3_exynos_register_phys(exynos); 132 - if (ret) { 133 - dev_err(dev, "couldn't register PHYs\n"); 134 - return ret; 135 - } 136 - 137 131 exynos->dev = dev; 138 132 139 133 exynos->clk = devm_clk_get(dev, "usbdrd30"); ··· 177 183 goto err3; 178 184 } 179 185 186 + ret = dwc3_exynos_register_phys(exynos); 187 + if (ret) { 188 + dev_err(dev, "couldn't register PHYs\n"); 189 + goto err4; 190 + } 191 + 180 192 if (node) { 181 193 ret = of_platform_populate(node, NULL, NULL, dev); 182 194 if (ret) { 183 195 dev_err(dev, "failed to add dwc3 core\n"); 184 - goto err4; 196 + goto err5; 185 197 } 186 198 } else { 187 199 dev_err(dev, "no device node, failed to add dwc3 core\n"); 188 200 ret = -ENODEV; 189 - goto err4; 201 + goto err5; 190 202 } 191 203 192 204 return 0; 193 205 206 + err5: 207 + platform_device_unregister(exynos->usb2_phy); 208 + platform_device_unregister(exynos->usb3_phy); 194 209 err4: 195 210 regulator_disable(exynos->vdd10); 196 211 err3:
+8 -2
drivers/usb/dwc3/dwc3-st.c
··· 129 129 switch (dwc3_data->dr_mode) { 130 130 case USB_DR_MODE_PERIPHERAL: 131 131 132 - val &= ~(USB3_FORCE_VBUSVALID | USB3_DELAY_VBUSVALID 132 + val &= ~(USB3_DELAY_VBUSVALID 133 133 | USB3_SEL_FORCE_OPMODE | USB3_FORCE_OPMODE(0x3) 134 134 | USB3_SEL_FORCE_DPPULLDOWN2 | USB3_FORCE_DPPULLDOWN2 135 135 | USB3_SEL_FORCE_DMPULLDOWN2 | USB3_FORCE_DMPULLDOWN2); 136 136 137 - val |= USB3_DEVICE_NOT_HOST; 137 + /* 138 + * USB3_PORT2_FORCE_VBUSVALID When '1' and when 139 + * USB3_PORT2_DEVICE_NOT_HOST = 1, forces VBUSVLDEXT2 input 140 + * of the pico PHY to 1. 141 + */ 142 + 143 + val |= USB3_DEVICE_NOT_HOST | USB3_FORCE_VBUSVALID; 138 144 break; 139 145 140 146 case USB_DR_MODE_HOST:
+24 -6
drivers/usb/dwc3/gadget.c
··· 347 347 return ret; 348 348 } 349 349 350 + static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep) 351 + { 352 + struct dwc3 *dwc = dep->dwc; 353 + struct dwc3_gadget_ep_cmd_params params; 354 + u32 cmd = DWC3_DEPCMD_CLEARSTALL; 355 + 356 + /* 357 + * As of core revision 2.60a the recommended programming model 358 + * is to set the ClearPendIN bit when issuing a Clear Stall EP 359 + * command for IN endpoints. This is to prevent an issue where 360 + * some (non-compliant) hosts may not send ACK TPs for pending 361 + * IN transfers due to a mishandled error condition. Synopsys 362 + * STAR 9000614252. 363 + */ 364 + if (dep->direction && (dwc->revision >= DWC3_REVISION_260A)) 365 + cmd |= DWC3_DEPCMD_CLEARPENDIN; 366 + 367 + memset(&params, 0, sizeof(params)); 368 + 369 + return dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params); 370 + } 371 + 350 372 static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, 351 373 struct dwc3_trb *trb) 352 374 { ··· 1336 1314 else 1337 1315 dep->flags |= DWC3_EP_STALL; 1338 1316 } else { 1339 - ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 1340 - DWC3_DEPCMD_CLEARSTALL, &params); 1317 + ret = dwc3_send_clear_stall_ep_cmd(dep); 1341 1318 if (ret) 1342 1319 dev_err(dwc->dev, "failed to clear STALL on %s\n", 1343 1320 dep->name); ··· 2268 2247 2269 2248 for (epnum = 1; epnum < DWC3_ENDPOINTS_NUM; epnum++) { 2270 2249 struct dwc3_ep *dep; 2271 - struct dwc3_gadget_ep_cmd_params params; 2272 2250 int ret; 2273 2251 2274 2252 dep = dwc->eps[epnum]; ··· 2279 2259 2280 2260 dep->flags &= ~DWC3_EP_STALL; 2281 2261 2282 - memset(&params, 0, sizeof(params)); 2283 - ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 2284 - DWC3_DEPCMD_CLEARSTALL, &params); 2262 + ret = dwc3_send_clear_stall_ep_cmd(dep); 2285 2263 WARN_ON_ONCE(ret); 2286 2264 } 2287 2265 }
+13 -8
drivers/usb/gadget/composite.c
··· 1868 1868 } 1869 1869 break; 1870 1870 } 1871 - req->length = value; 1872 - req->context = cdev; 1873 - req->zero = value < w_length; 1874 - value = composite_ep0_queue(cdev, req, GFP_ATOMIC); 1875 - if (value < 0) { 1876 - DBG(cdev, "ep_queue --> %d\n", value); 1877 - req->status = 0; 1878 - composite_setup_complete(gadget->ep0, req); 1871 + 1872 + if (value >= 0) { 1873 + req->length = value; 1874 + req->context = cdev; 1875 + req->zero = value < w_length; 1876 + value = composite_ep0_queue(cdev, req, 1877 + GFP_ATOMIC); 1878 + if (value < 0) { 1879 + DBG(cdev, "ep_queue --> %d\n", value); 1880 + req->status = 0; 1881 + composite_setup_complete(gadget->ep0, 1882 + req); 1883 + } 1879 1884 } 1880 1885 return value; 1881 1886 }
+1
drivers/usb/gadget/configfs.c
··· 1401 1401 .owner = THIS_MODULE, 1402 1402 .name = "configfs-gadget", 1403 1403 }, 1404 + .match_existing_only = 1, 1404 1405 }; 1405 1406 1406 1407 static struct config_group *gadgets_make(
+15 -15
drivers/usb/gadget/function/f_fs.c
··· 2051 2051 2052 2052 if (len < sizeof(*d) || 2053 2053 d->bFirstInterfaceNumber >= ffs->interfaces_count || 2054 - d->Reserved1) 2054 + !d->Reserved1) 2055 2055 return -EINVAL; 2056 2056 for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i) 2057 2057 if (d->Reserved2[i]) ··· 2729 2729 func->ffs->ss_descs_count; 2730 2730 2731 2731 int fs_len, hs_len, ss_len, ret, i; 2732 + struct ffs_ep *eps_ptr; 2732 2733 2733 2734 /* Make it a single chunk, less management later on */ 2734 2735 vla_group(d); ··· 2778 2777 ffs->raw_descs_length); 2779 2778 2780 2779 memset(vla_ptr(vlabuf, d, inums), 0xff, d_inums__sz); 2781 - for (ret = ffs->eps_count; ret; --ret) { 2782 - struct ffs_ep *ptr; 2783 - 2784 - ptr = vla_ptr(vlabuf, d, eps); 2785 - ptr[ret].num = -1; 2786 - } 2780 + eps_ptr = vla_ptr(vlabuf, d, eps); 2781 + for (i = 0; i < ffs->eps_count; i++) 2782 + eps_ptr[i].num = -1; 2787 2783 2788 2784 /* Save pointers 2789 2785 * d_eps == vlabuf, func->eps used to kfree vlabuf later ··· 2849 2851 goto error; 2850 2852 2851 2853 func->function.os_desc_table = vla_ptr(vlabuf, d, os_desc_table); 2852 - if (c->cdev->use_os_string) 2854 + if (c->cdev->use_os_string) { 2853 2855 for (i = 0; i < ffs->interfaces_count; ++i) { 2854 2856 struct usb_os_desc *desc; 2855 2857 ··· 2860 2862 vla_ptr(vlabuf, d, ext_compat) + i * 16; 2861 2863 INIT_LIST_HEAD(&desc->ext_prop); 2862 2864 } 2863 - ret = ffs_do_os_descs(ffs->ms_os_descs_count, 2864 - vla_ptr(vlabuf, d, raw_descs) + 2865 - fs_len + hs_len + ss_len, 2866 - d_raw_descs__sz - fs_len - hs_len - ss_len, 2867 - __ffs_func_bind_do_os_desc, func); 2868 - if (unlikely(ret < 0)) 2869 - goto error; 2865 + ret = ffs_do_os_descs(ffs->ms_os_descs_count, 2866 + vla_ptr(vlabuf, d, raw_descs) + 2867 + fs_len + hs_len + ss_len, 2868 + d_raw_descs__sz - fs_len - hs_len - 2869 + ss_len, 2870 + __ffs_func_bind_do_os_desc, func); 2871 + if (unlikely(ret < 0)) 2872 + goto error; 2873 + } 2870 2874 func->function.os_desc_n = 2871 2875 c->cdev->use_os_string ? ffs->interfaces_count : 0; 2872 2876
-8
drivers/usb/gadget/function/f_printer.c
··· 161 161 .wMaxPacketSize = cpu_to_le16(512) 162 162 }; 163 163 164 - static struct usb_qualifier_descriptor dev_qualifier = { 165 - .bLength = sizeof(dev_qualifier), 166 - .bDescriptorType = USB_DT_DEVICE_QUALIFIER, 167 - .bcdUSB = cpu_to_le16(0x0200), 168 - .bDeviceClass = USB_CLASS_PRINTER, 169 - .bNumConfigurations = 1 170 - }; 171 - 172 164 static struct usb_descriptor_header *hs_printer_function[] = { 173 165 (struct usb_descriptor_header *) &intf_desc, 174 166 (struct usb_descriptor_header *) &hs_ep_in_desc,
+11 -9
drivers/usb/gadget/function/f_tcm.c
··· 1445 1445 for (i = 0; i < TPG_INSTANCES; ++i) 1446 1446 if (tpg_instances[i].tpg == tpg) 1447 1447 break; 1448 - if (i < TPG_INSTANCES) 1448 + if (i < TPG_INSTANCES) { 1449 1449 tpg_instances[i].tpg = NULL; 1450 - opts = container_of(tpg_instances[i].func_inst, 1451 - struct f_tcm_opts, func_inst); 1452 - mutex_lock(&opts->dep_lock); 1453 - if (opts->has_dep) 1454 - module_put(opts->dependent); 1455 - else 1456 - configfs_undepend_item_unlocked(&opts->func_inst.group.cg_item); 1457 - mutex_unlock(&opts->dep_lock); 1450 + opts = container_of(tpg_instances[i].func_inst, 1451 + struct f_tcm_opts, func_inst); 1452 + mutex_lock(&opts->dep_lock); 1453 + if (opts->has_dep) 1454 + module_put(opts->dependent); 1455 + else 1456 + configfs_undepend_item_unlocked( 1457 + &opts->func_inst.group.cg_item); 1458 + mutex_unlock(&opts->dep_lock); 1459 + } 1458 1460 mutex_unlock(&tpg_instances_lock); 1459 1461 1460 1462 kfree(tpg);
+1 -12
drivers/usb/gadget/function/f_uac2.c
··· 598 598 NULL, 599 599 }; 600 600 601 - static struct usb_qualifier_descriptor devqual_desc = { 602 - .bLength = sizeof devqual_desc, 603 - .bDescriptorType = USB_DT_DEVICE_QUALIFIER, 604 - 605 - .bcdUSB = cpu_to_le16(0x200), 606 - .bDeviceClass = USB_CLASS_MISC, 607 - .bDeviceSubClass = 0x02, 608 - .bDeviceProtocol = 0x01, 609 - .bNumConfigurations = 1, 610 - .bRESERVED = 0, 611 - }; 612 - 613 601 static struct usb_interface_assoc_descriptor iad_desc = { 614 602 .bLength = sizeof iad_desc, 615 603 .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, ··· 1280 1292 1281 1293 if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { 1282 1294 struct cntrl_cur_lay3 c; 1295 + memset(&c, 0, sizeof(struct cntrl_cur_lay3)); 1283 1296 1284 1297 if (entity_id == USB_IN_CLK_ID) 1285 1298 c.dCUR = p_srate;
+1 -3
drivers/usb/gadget/function/storage_common.c
··· 83 83 * USB 2.0 devices need to expose both high speed and full speed 84 84 * descriptors, unless they only run at full speed. 85 85 * 86 - * That means alternate endpoint descriptors (bigger packets) 87 - * and a "device qualifier" ... plus more construction options 88 - * for the configuration descriptor. 86 + * That means alternate endpoint descriptors (bigger packets). 89 87 */ 90 88 struct usb_endpoint_descriptor fsg_hs_bulk_in_desc = { 91 89 .bLength = USB_DT_ENDPOINT_SIZE,
+13 -4
drivers/usb/gadget/legacy/inode.c
··· 938 938 struct usb_ep *ep = dev->gadget->ep0; 939 939 struct usb_request *req = dev->req; 940 940 941 - if ((retval = setup_req (ep, req, 0)) == 0) 942 - retval = usb_ep_queue (ep, req, GFP_ATOMIC); 941 + if ((retval = setup_req (ep, req, 0)) == 0) { 942 + spin_unlock_irq (&dev->lock); 943 + retval = usb_ep_queue (ep, req, GFP_KERNEL); 944 + spin_lock_irq (&dev->lock); 945 + } 943 946 dev->state = STATE_DEV_CONNECTED; 944 947 945 948 /* assume that was SET_CONFIGURATION */ ··· 1460 1457 w_length); 1461 1458 if (value < 0) 1462 1459 break; 1460 + 1461 + spin_unlock (&dev->lock); 1463 1462 value = usb_ep_queue (gadget->ep0, dev->req, 1464 - GFP_ATOMIC); 1463 + GFP_KERNEL); 1464 + spin_lock (&dev->lock); 1465 1465 if (value < 0) { 1466 1466 clean_req (gadget->ep0, dev->req); 1467 1467 break; ··· 1487 1481 if (value >= 0 && dev->state != STATE_DEV_SETUP) { 1488 1482 req->length = value; 1489 1483 req->zero = value < w_length; 1490 - value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC); 1484 + 1485 + spin_unlock (&dev->lock); 1486 + value = usb_ep_queue (gadget->ep0, req, GFP_KERNEL); 1491 1487 if (value < 0) { 1492 1488 DBG (dev, "ep_queue --> %d\n", value); 1493 1489 req->status = 0; 1494 1490 } 1491 + return value; 1495 1492 } 1496 1493 1497 1494 /* device stalls when value < 0 */
+8 -4
drivers/usb/gadget/udc/udc-core.c
··· 603 603 } 604 604 } 605 605 606 - list_add_tail(&driver->pending, &gadget_driver_pending_list); 607 - pr_info("udc-core: couldn't find an available UDC - added [%s] to list of pending drivers\n", 608 - driver->function); 606 + if (!driver->match_existing_only) { 607 + list_add_tail(&driver->pending, &gadget_driver_pending_list); 608 + pr_info("udc-core: couldn't find an available UDC - added [%s] to list of pending drivers\n", 609 + driver->function); 610 + ret = 0; 611 + } 612 + 609 613 mutex_unlock(&udc_lock); 610 - return 0; 614 + return ret; 611 615 found: 612 616 ret = udc_bind_to_driver(udc, driver); 613 617 mutex_unlock(&udc_lock);
+9
drivers/usb/host/ehci-hcd.c
··· 368 368 { 369 369 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 370 370 371 + /** 372 + * Protect the system from crashing at system shutdown in cases where 373 + * usb host is not added yet from OTG controller driver. 374 + * As ehci_setup() not done yet, so stop accessing registers or 375 + * variables initialized in ehci_setup() 376 + */ 377 + if (!ehci->sbrn) 378 + return; 379 + 371 380 spin_lock_irq(&ehci->lock); 372 381 ehci->shutdown = true; 373 382 ehci->rh_state = EHCI_RH_STOPPING;
+11 -3
drivers/usb/host/ehci-hub.c
··· 872 872 ) { 873 873 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 874 874 int ports = HCS_N_PORTS (ehci->hcs_params); 875 - u32 __iomem *status_reg = &ehci->regs->port_status[ 876 - (wIndex & 0xff) - 1]; 877 - u32 __iomem *hostpc_reg = &ehci->regs->hostpc[(wIndex & 0xff) - 1]; 875 + u32 __iomem *status_reg, *hostpc_reg; 878 876 u32 temp, temp1, status; 879 877 unsigned long flags; 880 878 int retval = 0; 881 879 unsigned selector; 880 + 881 + /* 882 + * Avoid underflow while calculating (wIndex & 0xff) - 1. 883 + * The compiler might deduce that wIndex can never be 0 and then 884 + * optimize away the tests for !wIndex below. 885 + */ 886 + temp = wIndex & 0xff; 887 + temp -= (temp > 0); 888 + status_reg = &ehci->regs->port_status[temp]; 889 + hostpc_reg = &ehci->regs->hostpc[temp]; 882 890 883 891 /* 884 892 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
+12 -2
drivers/usb/host/ehci-msm.c
··· 179 179 static int ehci_msm_pm_suspend(struct device *dev) 180 180 { 181 181 struct usb_hcd *hcd = dev_get_drvdata(dev); 182 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 182 183 bool do_wakeup = device_may_wakeup(dev); 183 184 184 185 dev_dbg(dev, "ehci-msm PM suspend\n"); 185 186 186 - return ehci_suspend(hcd, do_wakeup); 187 + /* Only call ehci_suspend if ehci_setup has been done */ 188 + if (ehci->sbrn) 189 + return ehci_suspend(hcd, do_wakeup); 190 + 191 + return 0; 187 192 } 188 193 189 194 static int ehci_msm_pm_resume(struct device *dev) 190 195 { 191 196 struct usb_hcd *hcd = dev_get_drvdata(dev); 197 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 192 198 193 199 dev_dbg(dev, "ehci-msm PM resume\n"); 194 - ehci_resume(hcd, false); 200 + 201 + /* Only call ehci_resume if ehci_setup has been done */ 202 + if (ehci->sbrn) 203 + ehci_resume(hcd, false); 195 204 196 205 return 0; 197 206 } 207 + 198 208 #else 199 209 #define ehci_msm_pm_suspend NULL 200 210 #define ehci_msm_pm_resume NULL
+13 -3
drivers/usb/host/ehci-tegra.c
··· 81 81 struct usb_hcd *hcd = platform_get_drvdata(pdev); 82 82 struct tegra_ehci_hcd *tegra = 83 83 (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; 84 + bool has_utmi_pad_registers = false; 84 85 85 86 phy_np = of_parse_phandle(pdev->dev.of_node, "nvidia,phy", 0); 86 87 if (!phy_np) 87 88 return -ENOENT; 88 89 90 + if (of_property_read_bool(phy_np, "nvidia,has-utmi-pad-registers")) 91 + has_utmi_pad_registers = true; 92 + 89 93 if (!usb1_reset_attempted) { 90 94 struct reset_control *usb1_reset; 91 95 92 - usb1_reset = of_reset_control_get(phy_np, "usb"); 96 + if (!has_utmi_pad_registers) 97 + usb1_reset = of_reset_control_get(phy_np, "utmi-pads"); 98 + else 99 + usb1_reset = tegra->rst; 100 + 93 101 if (IS_ERR(usb1_reset)) { 94 102 dev_warn(&pdev->dev, 95 103 "can't get utmi-pads reset from the PHY\n"); ··· 107 99 reset_control_assert(usb1_reset); 108 100 udelay(1); 109 101 reset_control_deassert(usb1_reset); 102 + 103 + if (!has_utmi_pad_registers) 104 + reset_control_put(usb1_reset); 110 105 } 111 106 112 - reset_control_put(usb1_reset); 113 107 usb1_reset_attempted = true; 114 108 } 115 109 116 - if (!of_property_read_bool(phy_np, "nvidia,has-utmi-pad-registers")) { 110 + if (!has_utmi_pad_registers) { 117 111 reset_control_assert(tegra->rst); 118 112 udelay(1); 119 113 reset_control_deassert(tegra->rst);
+2 -1
drivers/usb/host/ohci-q.c
··· 183 183 { 184 184 int branch; 185 185 186 - ed->state = ED_OPER; 187 186 ed->ed_prev = NULL; 188 187 ed->ed_next = NULL; 189 188 ed->hwNextED = 0; ··· 258 259 /* the HC may not see the schedule updates yet, but if it does 259 260 * then they'll be properly ordered. 260 261 */ 262 + 263 + ed->state = ED_OPER; 261 264 return 0; 262 265 } 263 266
+5
drivers/usb/host/xhci-pci.c
··· 37 37 /* Device for a quirk */ 38 38 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 39 39 #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 40 + #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009 40 41 #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400 41 42 42 43 #define PCI_VENDOR_ID_ETRON 0x1b6f ··· 114 113 pdev->revision); 115 114 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 116 115 } 116 + 117 + if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && 118 + pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009) 119 + xhci->quirks |= XHCI_BROKEN_STREAMS; 117 120 118 121 if (pdev->vendor == PCI_VENDOR_ID_NEC) 119 122 xhci->quirks |= XHCI_NEC_HOST;
+3
drivers/usb/host/xhci-plat.c
··· 196 196 ret = clk_prepare_enable(clk); 197 197 if (ret) 198 198 goto put_hcd; 199 + } else if (PTR_ERR(clk) == -EPROBE_DEFER) { 200 + ret = -EPROBE_DEFER; 201 + goto put_hcd; 199 202 } 200 203 201 204 xhci = hcd_to_xhci(hcd);
+24 -6
drivers/usb/host/xhci-ring.c
··· 290 290 291 291 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 292 292 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; 293 + 294 + /* 295 + * Writing the CMD_RING_ABORT bit should cause a cmd completion event, 296 + * however on some host hw the CMD_RING_RUNNING bit is correctly cleared 297 + * but the completion event in never sent. Use the cmd timeout timer to 298 + * handle those cases. Use twice the time to cover the bit polling retry 299 + */ 300 + mod_timer(&xhci->cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT)); 293 301 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, 294 302 &xhci->op_regs->cmd_ring); 295 303 ··· 322 314 323 315 xhci_err(xhci, "Stopped the command ring failed, " 324 316 "maybe the host is dead\n"); 317 + del_timer(&xhci->cmd_timer); 325 318 xhci->xhc_state |= XHCI_STATE_DYING; 326 319 xhci_quiesce(xhci); 327 320 xhci_halt(xhci); ··· 1255 1246 int ret; 1256 1247 unsigned long flags; 1257 1248 u64 hw_ring_state; 1258 - struct xhci_command *cur_cmd = NULL; 1249 + bool second_timeout = false; 1259 1250 xhci = (struct xhci_hcd *) data; 1260 1251 1261 1252 /* mark this command to be cancelled */ 1262 1253 spin_lock_irqsave(&xhci->lock, flags); 1263 1254 if (xhci->current_cmd) { 1264 - cur_cmd = xhci->current_cmd; 1265 - cur_cmd->status = COMP_CMD_ABORT; 1255 + if (xhci->current_cmd->status == COMP_CMD_ABORT) 1256 + second_timeout = true; 1257 + xhci->current_cmd->status = COMP_CMD_ABORT; 1266 1258 } 1267 - 1268 1259 1269 1260 /* Make sure command ring is running before aborting it */ 1270 1261 hw_ring_state = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 1271 1262 if ((xhci->cmd_ring_state & CMD_RING_STATE_RUNNING) && 1272 1263 (hw_ring_state & CMD_RING_RUNNING)) { 1273 - 1274 1264 spin_unlock_irqrestore(&xhci->lock, flags); 1275 1265 xhci_dbg(xhci, "Command timeout\n"); 1276 1266 ret = xhci_abort_cmd_ring(xhci); ··· 1281 1273 } 1282 1274 return; 1283 1275 } 1276 + 1277 + /* command ring failed to restart, or host removed. Bail out */ 1278 + if (second_timeout || xhci->xhc_state & XHCI_STATE_REMOVING) { 1279 + spin_unlock_irqrestore(&xhci->lock, flags); 1280 + xhci_dbg(xhci, "command timed out twice, ring start fail?\n"); 1281 + xhci_cleanup_command_queue(xhci); 1282 + return; 1283 + } 1284 + 1284 1285 /* command timeout on stopped ring, ring can't be aborted */ 1285 1286 xhci_dbg(xhci, "Command timeout on stopped ring\n"); 1286 1287 xhci_handle_stopped_cmd_ring(xhci, xhci->current_cmd); ··· 2738 2721 writel(irq_pending, &xhci->ir_set->irq_pending); 2739 2722 } 2740 2723 2741 - if (xhci->xhc_state & XHCI_STATE_DYING) { 2724 + if (xhci->xhc_state & XHCI_STATE_DYING || 2725 + xhci->xhc_state & XHCI_STATE_HALTED) { 2742 2726 xhci_dbg(xhci, "xHCI dying, ignoring interrupt. " 2743 2727 "Shouldn't IRQs be disabled?\n"); 2744 2728 /* Clear the event handler busy flag (RW1C);
+16 -13
drivers/usb/host/xhci.c
··· 685 685 u32 temp; 686 686 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 687 687 688 - if (xhci->xhc_state & XHCI_STATE_HALTED) 689 - return; 690 - 691 688 mutex_lock(&xhci->mutex); 692 - spin_lock_irq(&xhci->lock); 693 - xhci->xhc_state |= XHCI_STATE_HALTED; 694 - xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 695 689 696 - /* Make sure the xHC is halted for a USB3 roothub 697 - * (xhci_stop() could be called as part of failed init). 698 - */ 699 - xhci_halt(xhci); 700 - xhci_reset(xhci); 701 - spin_unlock_irq(&xhci->lock); 690 + if (!(xhci->xhc_state & XHCI_STATE_HALTED)) { 691 + spin_lock_irq(&xhci->lock); 692 + 693 + xhci->xhc_state |= XHCI_STATE_HALTED; 694 + xhci->cmd_ring_state = CMD_RING_STATE_STOPPED; 695 + xhci_halt(xhci); 696 + xhci_reset(xhci); 697 + 698 + spin_unlock_irq(&xhci->lock); 699 + } 700 + 701 + if (!usb_hcd_is_primary_hcd(hcd)) { 702 + mutex_unlock(&xhci->mutex); 703 + return; 704 + } 702 705 703 706 xhci_cleanup_msix(xhci); 704 707 ··· 4889 4886 xhci->hcc_params2 = readl(&xhci->cap_regs->hcc_params2); 4890 4887 xhci_print_registers(xhci); 4891 4888 4892 - xhci->quirks = quirks; 4889 + xhci->quirks |= quirks; 4893 4890 4894 4891 get_quirks(dev, xhci); 4895 4892
+37 -48
drivers/usb/musb/musb_core.c
··· 1090 1090 musb_platform_try_idle(musb, 0); 1091 1091 } 1092 1092 1093 - static void musb_shutdown(struct platform_device *pdev) 1094 - { 1095 - struct musb *musb = dev_to_musb(&pdev->dev); 1096 - unsigned long flags; 1097 - 1098 - pm_runtime_get_sync(musb->controller); 1099 - 1100 - musb_host_cleanup(musb); 1101 - musb_gadget_cleanup(musb); 1102 - 1103 - spin_lock_irqsave(&musb->lock, flags); 1104 - musb_platform_disable(musb); 1105 - musb_generic_disable(musb); 1106 - spin_unlock_irqrestore(&musb->lock, flags); 1107 - 1108 - musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 1109 - musb_platform_exit(musb); 1110 - 1111 - pm_runtime_put(musb->controller); 1112 - /* FIXME power down */ 1113 - } 1114 - 1115 - 1116 1093 /*-------------------------------------------------------------------------*/ 1117 1094 1118 1095 /* ··· 1679 1702 #define use_dma 0 1680 1703 #endif 1681 1704 1682 - static void (*musb_phy_callback)(enum musb_vbus_id_status status); 1705 + static int (*musb_phy_callback)(enum musb_vbus_id_status status); 1683 1706 1684 1707 /* 1685 1708 * musb_mailbox - optional phy notifier function ··· 1688 1711 * Optionally gets called from the USB PHY. Note that the USB PHY must be 1689 1712 * disabled at the point the phy_callback is registered or unregistered. 1690 1713 */ 1691 - void musb_mailbox(enum musb_vbus_id_status status) 1714 + int musb_mailbox(enum musb_vbus_id_status status) 1692 1715 { 1693 1716 if (musb_phy_callback) 1694 - musb_phy_callback(status); 1717 + return musb_phy_callback(status); 1695 1718 1719 + return -ENODEV; 1696 1720 }; 1697 1721 EXPORT_SYMBOL_GPL(musb_mailbox); 1698 1722 ··· 2006 2028 musb_readl = musb_default_readl; 2007 2029 musb_writel = musb_default_writel; 2008 2030 2009 - /* We need musb_read/write functions initialized for PM */ 2010 - pm_runtime_use_autosuspend(musb->controller); 2011 - pm_runtime_set_autosuspend_delay(musb->controller, 200); 2012 - pm_runtime_enable(musb->controller); 2013 - 2014 2031 /* The musb_platform_init() call: 2015 2032 * - adjusts musb->mregs 2016 2033 * - sets the musb->isr ··· 2107 2134 if (musb->ops->phy_callback) 2108 2135 musb_phy_callback = musb->ops->phy_callback; 2109 2136 2137 + /* 2138 + * We need musb_read/write functions initialized for PM. 2139 + * Note that at least 2430 glue needs autosuspend delay 2140 + * somewhere above 300 ms for the hardware to idle properly 2141 + * after disconnecting the cable in host mode. Let's use 2142 + * 500 ms for some margin. 2143 + */ 2144 + pm_runtime_use_autosuspend(musb->controller); 2145 + pm_runtime_set_autosuspend_delay(musb->controller, 500); 2146 + pm_runtime_enable(musb->controller); 2110 2147 pm_runtime_get_sync(musb->controller); 2111 2148 2112 2149 status = usb_phy_init(musb->xceiv); ··· 2220 2237 if (status) 2221 2238 goto fail5; 2222 2239 2223 - pm_runtime_put(musb->controller); 2224 - 2225 - /* 2226 - * For why this is currently needed, see commit 3e43a0725637 2227 - * ("usb: musb: core: add pm_runtime_irq_safe()") 2228 - */ 2229 - pm_runtime_irq_safe(musb->controller); 2240 + pm_runtime_mark_last_busy(musb->controller); 2241 + pm_runtime_put_autosuspend(musb->controller); 2230 2242 2231 2243 return 0; 2232 2244 ··· 2243 2265 usb_phy_shutdown(musb->xceiv); 2244 2266 2245 2267 err_usb_phy_init: 2268 + pm_runtime_dont_use_autosuspend(musb->controller); 2246 2269 pm_runtime_put_sync(musb->controller); 2270 + pm_runtime_disable(musb->controller); 2247 2271 2248 2272 fail2: 2249 2273 if (musb->irq_wake) ··· 2253 2273 musb_platform_exit(musb); 2254 2274 2255 2275 fail1: 2256 - pm_runtime_disable(musb->controller); 2257 2276 dev_err(musb->controller, 2258 2277 "musb_init_controller failed with status %d\n", status); 2259 2278 ··· 2291 2312 { 2292 2313 struct device *dev = &pdev->dev; 2293 2314 struct musb *musb = dev_to_musb(dev); 2315 + unsigned long flags; 2294 2316 2295 2317 /* this gets called on rmmod. 2296 2318 * - Host mode: host may still be active ··· 2299 2319 * - OTG mode: both roles are deactivated (or never-activated) 2300 2320 */ 2301 2321 musb_exit_debugfs(musb); 2302 - musb_shutdown(pdev); 2303 - musb_phy_callback = NULL; 2304 - 2305 - if (musb->dma_controller) 2306 - musb_dma_controller_destroy(musb->dma_controller); 2307 - 2308 - usb_phy_shutdown(musb->xceiv); 2309 2322 2310 2323 cancel_work_sync(&musb->irq_work); 2311 2324 cancel_delayed_work_sync(&musb->finish_resume_work); 2312 2325 cancel_delayed_work_sync(&musb->deassert_reset_work); 2326 + pm_runtime_get_sync(musb->controller); 2327 + musb_host_cleanup(musb); 2328 + musb_gadget_cleanup(musb); 2329 + spin_lock_irqsave(&musb->lock, flags); 2330 + musb_platform_disable(musb); 2331 + musb_generic_disable(musb); 2332 + spin_unlock_irqrestore(&musb->lock, flags); 2333 + musb_writeb(musb->mregs, MUSB_DEVCTL, 0); 2334 + pm_runtime_dont_use_autosuspend(musb->controller); 2335 + pm_runtime_put_sync(musb->controller); 2336 + pm_runtime_disable(musb->controller); 2337 + musb_platform_exit(musb); 2338 + musb_phy_callback = NULL; 2339 + if (musb->dma_controller) 2340 + musb_dma_controller_destroy(musb->dma_controller); 2341 + usb_phy_shutdown(musb->xceiv); 2313 2342 musb_free(musb); 2314 2343 device_init_wakeup(dev, 0); 2315 2344 return 0; ··· 2418 2429 musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe); 2419 2430 musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe); 2420 2431 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); 2421 - musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); 2432 + if (musb->context.devctl & MUSB_DEVCTL_SESSION) 2433 + musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); 2422 2434 2423 2435 for (i = 0; i < musb->config->num_eps; ++i) { 2424 2436 struct musb_hw_ep *hw_ep; ··· 2602 2612 }, 2603 2613 .probe = musb_probe, 2604 2614 .remove = musb_remove, 2605 - .shutdown = musb_shutdown, 2606 2615 }; 2607 2616 2608 2617 module_platform_driver(musb_driver);
+2 -1
drivers/usb/musb/musb_core.h
··· 215 215 dma_addr_t *dma_addr, u32 *len); 216 216 void (*pre_root_reset_end)(struct musb *musb); 217 217 void (*post_root_reset_end)(struct musb *musb); 218 - void (*phy_callback)(enum musb_vbus_id_status status); 218 + int (*phy_callback)(enum musb_vbus_id_status status); 219 219 }; 220 220 221 221 /* ··· 312 312 struct work_struct irq_work; 313 313 struct delayed_work deassert_reset_work; 314 314 struct delayed_work finish_resume_work; 315 + struct delayed_work gadget_work; 315 316 u16 hwvers; 316 317 317 318 u16 intrrxe;
+23 -11
drivers/usb/musb/musb_gadget.c
··· 1656 1656 return usb_phy_set_power(musb->xceiv, mA); 1657 1657 } 1658 1658 1659 + static void musb_gadget_work(struct work_struct *work) 1660 + { 1661 + struct musb *musb; 1662 + unsigned long flags; 1663 + 1664 + musb = container_of(work, struct musb, gadget_work.work); 1665 + pm_runtime_get_sync(musb->controller); 1666 + spin_lock_irqsave(&musb->lock, flags); 1667 + musb_pullup(musb, musb->softconnect); 1668 + spin_unlock_irqrestore(&musb->lock, flags); 1669 + pm_runtime_mark_last_busy(musb->controller); 1670 + pm_runtime_put_autosuspend(musb->controller); 1671 + } 1672 + 1659 1673 static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) 1660 1674 { 1661 1675 struct musb *musb = gadget_to_musb(gadget); ··· 1677 1663 1678 1664 is_on = !!is_on; 1679 1665 1680 - pm_runtime_get_sync(musb->controller); 1681 - 1682 1666 /* NOTE: this assumes we are sensing vbus; we'd rather 1683 1667 * not pullup unless the B-session is active. 1684 1668 */ 1685 1669 spin_lock_irqsave(&musb->lock, flags); 1686 1670 if (is_on != musb->softconnect) { 1687 1671 musb->softconnect = is_on; 1688 - musb_pullup(musb, is_on); 1672 + schedule_delayed_work(&musb->gadget_work, 0); 1689 1673 } 1690 1674 spin_unlock_irqrestore(&musb->lock, flags); 1691 - 1692 - pm_runtime_put(musb->controller); 1693 1675 1694 1676 return 0; 1695 1677 } ··· 1855 1845 #elif IS_ENABLED(CONFIG_USB_MUSB_GADGET) 1856 1846 musb->g.is_otg = 0; 1857 1847 #endif 1858 - 1848 + INIT_DELAYED_WORK(&musb->gadget_work, musb_gadget_work); 1859 1849 musb_g_init_endpoints(musb); 1860 1850 1861 1851 musb->is_active = 0; ··· 1876 1866 { 1877 1867 if (musb->port_mode == MUSB_PORT_MODE_HOST) 1878 1868 return; 1869 + 1870 + cancel_delayed_work_sync(&musb->gadget_work); 1879 1871 usb_del_gadget_udc(&musb->g); 1880 1872 } 1881 1873 ··· 1926 1914 if (musb->xceiv->last_event == USB_EVENT_ID) 1927 1915 musb_platform_set_vbus(musb, 1); 1928 1916 1929 - if (musb->xceiv->last_event == USB_EVENT_NONE) 1930 - pm_runtime_put(musb->controller); 1917 + pm_runtime_mark_last_busy(musb->controller); 1918 + pm_runtime_put_autosuspend(musb->controller); 1931 1919 1932 1920 return 0; 1933 1921 ··· 1946 1934 struct musb *musb = gadget_to_musb(g); 1947 1935 unsigned long flags; 1948 1936 1949 - if (musb->xceiv->last_event == USB_EVENT_NONE) 1950 - pm_runtime_get_sync(musb->controller); 1937 + pm_runtime_get_sync(musb->controller); 1951 1938 1952 1939 /* 1953 1940 * REVISIT always use otg_set_peripheral() here too; ··· 1974 1963 * that currently misbehaves. 1975 1964 */ 1976 1965 1977 - pm_runtime_put(musb->controller); 1966 + pm_runtime_mark_last_busy(musb->controller); 1967 + pm_runtime_put_autosuspend(musb->controller); 1978 1968 1979 1969 return 0; 1980 1970 }
+37 -31
drivers/usb/musb/musb_host.c
··· 434 434 } 435 435 } 436 436 437 - if (qh != NULL && qh->is_ready) { 437 + /* 438 + * The pipe must be broken if current urb->status is set, so don't 439 + * start next urb. 440 + * TODO: to minimize the risk of regression, only check urb->status 441 + * for RX, until we have a test case to understand the behavior of TX. 442 + */ 443 + if ((!status || !is_in) && qh && qh->is_ready) { 438 444 dev_dbg(musb->controller, "... next ep%d %cX urb %p\n", 439 445 hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); 440 446 musb_start_urb(musb, is_in, qh); ··· 600 594 musb_writew(ep->regs, MUSB_TXCSR, 0); 601 595 602 596 /* scrub all previous state, clearing toggle */ 603 - } else { 604 - csr = musb_readw(ep->regs, MUSB_RXCSR); 605 - if (csr & MUSB_RXCSR_RXPKTRDY) 606 - WARNING("rx%d, packet/%d ready?\n", ep->epnum, 607 - musb_readw(ep->regs, MUSB_RXCOUNT)); 608 - 609 - musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG); 610 597 } 598 + csr = musb_readw(ep->regs, MUSB_RXCSR); 599 + if (csr & MUSB_RXCSR_RXPKTRDY) 600 + WARNING("rx%d, packet/%d ready?\n", ep->epnum, 601 + musb_readw(ep->regs, MUSB_RXCOUNT)); 602 + 603 + musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG); 611 604 612 605 /* target addr and (for multipoint) hub addr/port */ 613 606 if (musb->is_multipoint) { ··· 632 627 ep->rx_reinit = 0; 633 628 } 634 629 635 - static int musb_tx_dma_set_mode_mentor(struct dma_controller *dma, 630 + static void musb_tx_dma_set_mode_mentor(struct dma_controller *dma, 636 631 struct musb_hw_ep *hw_ep, struct musb_qh *qh, 637 632 struct urb *urb, u32 offset, 638 633 u32 *length, u8 *mode) ··· 669 664 } 670 665 channel->desired_mode = *mode; 671 666 musb_writew(epio, MUSB_TXCSR, csr); 672 - 673 - return 0; 674 667 } 675 668 676 - static int musb_tx_dma_set_mode_cppi_tusb(struct dma_controller *dma, 677 - struct musb_hw_ep *hw_ep, 678 - struct musb_qh *qh, 679 - struct urb *urb, 680 - u32 offset, 681 - u32 *length, 682 - u8 *mode) 669 + static void musb_tx_dma_set_mode_cppi_tusb(struct dma_controller *dma, 670 + struct musb_hw_ep *hw_ep, 671 + struct musb_qh *qh, 672 + struct urb *urb, 673 + u32 offset, 674 + u32 *length, 675 + u8 *mode) 683 676 { 684 677 struct dma_channel *channel = hw_ep->tx_channel; 685 - 686 - if (!is_cppi_enabled(hw_ep->musb) && !tusb_dma_omap(hw_ep->musb)) 687 - return -ENODEV; 688 678 689 679 channel->actual_len = 0; 690 680 ··· 688 688 * to identify the zero-length-final-packet case. 689 689 */ 690 690 *mode = (urb->transfer_flags & URB_ZERO_PACKET) ? 1 : 0; 691 - 692 - return 0; 693 691 } 694 692 695 693 static bool musb_tx_dma_program(struct dma_controller *dma, ··· 697 699 struct dma_channel *channel = hw_ep->tx_channel; 698 700 u16 pkt_size = qh->maxpacket; 699 701 u8 mode; 700 - int res; 701 702 702 703 if (musb_dma_inventra(hw_ep->musb) || musb_dma_ux500(hw_ep->musb)) 703 - res = musb_tx_dma_set_mode_mentor(dma, hw_ep, qh, urb, 704 - offset, &length, &mode); 704 + musb_tx_dma_set_mode_mentor(dma, hw_ep, qh, urb, offset, 705 + &length, &mode); 706 + else if (is_cppi_enabled(hw_ep->musb) || tusb_dma_omap(hw_ep->musb)) 707 + musb_tx_dma_set_mode_cppi_tusb(dma, hw_ep, qh, urb, offset, 708 + &length, &mode); 705 709 else 706 - res = musb_tx_dma_set_mode_cppi_tusb(dma, hw_ep, qh, urb, 707 - offset, &length, &mode); 708 - if (res) 709 710 return false; 710 711 711 712 qh->segsize = length; ··· 992 995 if (is_in) { 993 996 dma = is_dma_capable() ? ep->rx_channel : NULL; 994 997 995 - /* clear nak timeout bit */ 998 + /* 999 + * Need to stop the transaction by clearing REQPKT first 1000 + * then the NAK Timeout bit ref MUSBMHDRC USB 2.0 HIGH-SPEED 1001 + * DUAL-ROLE CONTROLLER Programmer's Guide, section 9.2.2 1002 + */ 996 1003 rx_csr = musb_readw(epio, MUSB_RXCSR); 997 1004 rx_csr |= MUSB_RXCSR_H_WZC_BITS; 1005 + rx_csr &= ~MUSB_RXCSR_H_REQPKT; 1006 + musb_writew(epio, MUSB_RXCSR, rx_csr); 998 1007 rx_csr &= ~MUSB_RXCSR_DATAERROR; 999 1008 musb_writew(epio, MUSB_RXCSR, rx_csr); 1000 1009 ··· 1554 1551 struct urb *urb, 1555 1552 size_t len) 1556 1553 { 1557 - struct dma_channel *channel = hw_ep->tx_channel; 1554 + struct dma_channel *channel = hw_ep->rx_channel; 1558 1555 void __iomem *epio = hw_ep->regs; 1559 1556 dma_addr_t *buf; 1560 1557 u32 length, res; ··· 1872 1869 1873 1870 status = -EPROTO; 1874 1871 musb_writeb(epio, MUSB_RXINTERVAL, 0); 1872 + 1873 + rx_csr &= ~MUSB_RXCSR_H_ERROR; 1874 + musb_writew(epio, MUSB_RXCSR, rx_csr); 1875 1875 1876 1876 } else if (rx_csr & MUSB_RXCSR_DATAERROR) { 1877 1877
+89 -168
drivers/usb/musb/omap2430.c
··· 49 49 enum musb_vbus_id_status status; 50 50 struct work_struct omap_musb_mailbox_work; 51 51 struct device *control_otghs; 52 + bool cable_connected; 53 + bool enabled; 54 + bool powered; 52 55 }; 53 56 #define glue_to_musb(g) platform_get_drvdata(g->musb) 54 57 55 58 static struct omap2430_glue *_glue; 56 - 57 - static struct timer_list musb_idle_timer; 58 - 59 - static void musb_do_idle(unsigned long _musb) 60 - { 61 - struct musb *musb = (void *)_musb; 62 - unsigned long flags; 63 - u8 power; 64 - u8 devctl; 65 - 66 - spin_lock_irqsave(&musb->lock, flags); 67 - 68 - switch (musb->xceiv->otg->state) { 69 - case OTG_STATE_A_WAIT_BCON: 70 - 71 - devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 72 - if (devctl & MUSB_DEVCTL_BDEVICE) { 73 - musb->xceiv->otg->state = OTG_STATE_B_IDLE; 74 - MUSB_DEV_MODE(musb); 75 - } else { 76 - musb->xceiv->otg->state = OTG_STATE_A_IDLE; 77 - MUSB_HST_MODE(musb); 78 - } 79 - break; 80 - case OTG_STATE_A_SUSPEND: 81 - /* finish RESUME signaling? */ 82 - if (musb->port1_status & MUSB_PORT_STAT_RESUME) { 83 - power = musb_readb(musb->mregs, MUSB_POWER); 84 - power &= ~MUSB_POWER_RESUME; 85 - dev_dbg(musb->controller, "root port resume stopped, power %02x\n", power); 86 - musb_writeb(musb->mregs, MUSB_POWER, power); 87 - musb->is_active = 1; 88 - musb->port1_status &= ~(USB_PORT_STAT_SUSPEND 89 - | MUSB_PORT_STAT_RESUME); 90 - musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; 91 - usb_hcd_poll_rh_status(musb->hcd); 92 - /* NOTE: it might really be A_WAIT_BCON ... */ 93 - musb->xceiv->otg->state = OTG_STATE_A_HOST; 94 - } 95 - break; 96 - case OTG_STATE_A_HOST: 97 - devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 98 - if (devctl & MUSB_DEVCTL_BDEVICE) 99 - musb->xceiv->otg->state = OTG_STATE_B_IDLE; 100 - else 101 - musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; 102 - default: 103 - break; 104 - } 105 - spin_unlock_irqrestore(&musb->lock, flags); 106 - } 107 - 108 - 109 - static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) 110 - { 111 - unsigned long default_timeout = jiffies + msecs_to_jiffies(3); 112 - static unsigned long last_timer; 113 - 114 - if (timeout == 0) 115 - timeout = default_timeout; 116 - 117 - /* Never idle if active, or when VBUS timeout is not set as host */ 118 - if (musb->is_active || ((musb->a_wait_bcon == 0) 119 - && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) { 120 - dev_dbg(musb->controller, "%s active, deleting timer\n", 121 - usb_otg_state_string(musb->xceiv->otg->state)); 122 - del_timer(&musb_idle_timer); 123 - last_timer = jiffies; 124 - return; 125 - } 126 - 127 - if (time_after(last_timer, timeout)) { 128 - if (!timer_pending(&musb_idle_timer)) 129 - last_timer = timeout; 130 - else { 131 - dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n"); 132 - return; 133 - } 134 - } 135 - last_timer = timeout; 136 - 137 - dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", 138 - usb_otg_state_string(musb->xceiv->otg->state), 139 - (unsigned long)jiffies_to_msecs(timeout - jiffies)); 140 - mod_timer(&musb_idle_timer, timeout); 141 - } 142 59 143 60 static void omap2430_musb_set_vbus(struct musb *musb, int is_on) 144 61 { ··· 122 205 musb_readb(musb->mregs, MUSB_DEVCTL)); 123 206 } 124 207 125 - static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) 126 - { 127 - u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 128 - 129 - devctl |= MUSB_DEVCTL_SESSION; 130 - musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); 131 - 132 - return 0; 133 - } 134 - 135 208 static inline void omap2430_low_level_exit(struct musb *musb) 136 209 { 137 210 u32 l; ··· 141 234 musb_writel(musb->mregs, OTG_FORCESTDBY, l); 142 235 } 143 236 144 - static void omap2430_musb_mailbox(enum musb_vbus_id_status status) 237 + /* 238 + * We can get multiple cable events so we need to keep track 239 + * of the power state. Only keep power enabled if USB cable is 240 + * connected and a gadget is started. 241 + */ 242 + static void omap2430_set_power(struct musb *musb, bool enabled, bool cable) 243 + { 244 + struct device *dev = musb->controller; 245 + struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 246 + bool power_up; 247 + int res; 248 + 249 + if (glue->enabled != enabled) 250 + glue->enabled = enabled; 251 + 252 + if (glue->cable_connected != cable) 253 + glue->cable_connected = cable; 254 + 255 + power_up = glue->enabled && glue->cable_connected; 256 + if (power_up == glue->powered) { 257 + dev_warn(musb->controller, "power state already %i\n", 258 + power_up); 259 + return; 260 + } 261 + 262 + glue->powered = power_up; 263 + 264 + if (power_up) { 265 + res = pm_runtime_get_sync(musb->controller); 266 + if (res < 0) { 267 + dev_err(musb->controller, "could not enable: %i", res); 268 + glue->powered = false; 269 + } 270 + } else { 271 + pm_runtime_mark_last_busy(musb->controller); 272 + pm_runtime_put_autosuspend(musb->controller); 273 + } 274 + } 275 + 276 + static int omap2430_musb_mailbox(enum musb_vbus_id_status status) 145 277 { 146 278 struct omap2430_glue *glue = _glue; 147 279 148 280 if (!glue) { 149 281 pr_err("%s: musb core is not yet initialized\n", __func__); 150 - return; 282 + return -EPROBE_DEFER; 151 283 } 152 284 glue->status = status; 153 285 154 286 if (!glue_to_musb(glue)) { 155 287 pr_err("%s: musb core is not yet ready\n", __func__); 156 - return; 288 + return -EPROBE_DEFER; 157 289 } 158 290 159 291 schedule_work(&glue->omap_musb_mailbox_work); 292 + 293 + return 0; 160 294 } 161 295 162 296 static void omap_musb_set_mailbox(struct omap2430_glue *glue) ··· 207 259 struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); 208 260 struct omap_musb_board_data *data = pdata->board_data; 209 261 struct usb_otg *otg = musb->xceiv->otg; 262 + bool cable_connected; 263 + 264 + cable_connected = ((glue->status == MUSB_ID_GROUND) || 265 + (glue->status == MUSB_VBUS_VALID)); 266 + 267 + if (cable_connected) 268 + omap2430_set_power(musb, glue->enabled, cable_connected); 210 269 211 270 switch (glue->status) { 212 271 case MUSB_ID_GROUND: ··· 223 268 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 224 269 musb->xceiv->last_event = USB_EVENT_ID; 225 270 if (musb->gadget_driver) { 226 - pm_runtime_get_sync(dev); 227 271 omap_control_usb_set_mode(glue->control_otghs, 228 272 USB_MODE_HOST); 229 273 omap2430_musb_set_vbus(musb, 1); ··· 235 281 otg->default_a = false; 236 282 musb->xceiv->otg->state = OTG_STATE_B_IDLE; 237 283 musb->xceiv->last_event = USB_EVENT_VBUS; 238 - if (musb->gadget_driver) 239 - pm_runtime_get_sync(dev); 240 284 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE); 241 285 break; 242 286 ··· 243 291 dev_dbg(dev, "VBUS Disconnect\n"); 244 292 245 293 musb->xceiv->last_event = USB_EVENT_NONE; 246 - if (musb->gadget_driver) { 294 + if (musb->gadget_driver) 247 295 omap2430_musb_set_vbus(musb, 0); 248 - pm_runtime_mark_last_busy(dev); 249 - pm_runtime_put_autosuspend(dev); 250 - } 251 296 252 297 if (data->interface_type == MUSB_INTERFACE_UTMI) 253 298 otg_set_vbus(musb->xceiv->otg, 0); ··· 256 307 dev_dbg(dev, "ID float\n"); 257 308 } 258 309 310 + if (!cable_connected) 311 + omap2430_set_power(musb, glue->enabled, cable_connected); 312 + 259 313 atomic_notifier_call_chain(&musb->xceiv->notifier, 260 314 musb->xceiv->last_event, NULL); 261 315 } ··· 268 316 { 269 317 struct omap2430_glue *glue = container_of(mailbox_work, 270 318 struct omap2430_glue, omap_musb_mailbox_work); 271 - struct musb *musb = glue_to_musb(glue); 272 - struct device *dev = musb->controller; 273 319 274 - pm_runtime_get_sync(dev); 275 320 omap_musb_set_mailbox(glue); 276 - pm_runtime_mark_last_busy(dev); 277 - pm_runtime_put_autosuspend(dev); 278 321 } 279 322 280 323 static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci) ··· 336 389 return PTR_ERR(musb->phy); 337 390 } 338 391 musb->isr = omap2430_musb_interrupt; 339 - 340 - /* 341 - * Enable runtime PM for musb parent (this driver). We can't 342 - * do it earlier as struct musb is not yet allocated and we 343 - * need to touch the musb registers for runtime PM. 344 - */ 345 - pm_runtime_enable(glue->dev); 346 - status = pm_runtime_get_sync(glue->dev); 347 - if (status < 0) 348 - goto err1; 349 - 350 - status = pm_runtime_get_sync(dev); 351 - if (status < 0) { 352 - dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); 353 - pm_runtime_put_sync(glue->dev); 354 - goto err1; 355 - } 392 + phy_init(musb->phy); 356 393 357 394 l = musb_readl(musb->mregs, OTG_INTERFSEL); 358 395 ··· 358 427 musb_readl(musb->mregs, OTG_INTERFSEL), 359 428 musb_readl(musb->mregs, OTG_SIMENABLE)); 360 429 361 - setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); 362 - 363 430 if (glue->status != MUSB_UNKNOWN) 364 431 omap_musb_set_mailbox(glue); 365 432 366 - phy_init(musb->phy); 367 - phy_power_on(musb->phy); 368 - 369 - pm_runtime_put_noidle(musb->controller); 370 - pm_runtime_put_noidle(glue->dev); 371 433 return 0; 372 - 373 - err1: 374 - return status; 375 434 } 376 435 377 436 static void omap2430_musb_enable(struct musb *musb) ··· 372 451 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 373 452 struct musb_hdrc_platform_data *pdata = dev_get_platdata(dev); 374 453 struct omap_musb_board_data *data = pdata->board_data; 454 + 455 + if (!WARN_ON(!musb->phy)) 456 + phy_power_on(musb->phy); 457 + 458 + omap2430_set_power(musb, true, glue->cable_connected); 375 459 376 460 switch (glue->status) { 377 461 ··· 413 487 struct device *dev = musb->controller; 414 488 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 415 489 490 + if (!WARN_ON(!musb->phy)) 491 + phy_power_off(musb->phy); 492 + 416 493 if (glue->status != MUSB_UNKNOWN) 417 494 omap_control_usb_set_mode(glue->control_otghs, 418 495 USB_MODE_DISCONNECT); 496 + 497 + omap2430_set_power(musb, false, glue->cable_connected); 419 498 } 420 499 421 500 static int omap2430_musb_exit(struct musb *musb) 422 501 { 423 - del_timer_sync(&musb_idle_timer); 502 + struct device *dev = musb->controller; 503 + struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 424 504 425 505 omap2430_low_level_exit(musb); 426 - phy_power_off(musb->phy); 427 506 phy_exit(musb->phy); 507 + musb->phy = NULL; 508 + cancel_work_sync(&glue->omap_musb_mailbox_work); 428 509 429 510 return 0; 430 511 } ··· 444 511 #endif 445 512 .init = omap2430_musb_init, 446 513 .exit = omap2430_musb_exit, 447 - 448 - .set_mode = omap2430_musb_set_mode, 449 - .try_idle = omap2430_musb_try_idle, 450 514 451 515 .set_vbus = omap2430_musb_set_vbus, 452 516 ··· 569 639 goto err2; 570 640 } 571 641 572 - /* 573 - * Note that we cannot enable PM runtime yet for this 574 - * driver as we need struct musb initialized first. 575 - * See omap2430_musb_init above. 576 - */ 642 + pm_runtime_enable(glue->dev); 643 + pm_runtime_use_autosuspend(glue->dev); 644 + pm_runtime_set_autosuspend_delay(glue->dev, 500); 577 645 578 646 ret = platform_device_add(musb); 579 647 if (ret) { ··· 590 662 591 663 static int omap2430_remove(struct platform_device *pdev) 592 664 { 593 - struct omap2430_glue *glue = platform_get_drvdata(pdev); 665 + struct omap2430_glue *glue = platform_get_drvdata(pdev); 666 + struct musb *musb = glue_to_musb(glue); 594 667 595 668 pm_runtime_get_sync(glue->dev); 596 - cancel_work_sync(&glue->omap_musb_mailbox_work); 597 669 platform_device_unregister(glue->musb); 670 + omap2430_set_power(musb, false, false); 598 671 pm_runtime_put_sync(glue->dev); 672 + pm_runtime_dont_use_autosuspend(glue->dev); 599 673 pm_runtime_disable(glue->dev); 600 674 601 675 return 0; ··· 610 680 struct omap2430_glue *glue = dev_get_drvdata(dev); 611 681 struct musb *musb = glue_to_musb(glue); 612 682 613 - if (musb) { 614 - musb->context.otg_interfsel = musb_readl(musb->mregs, 615 - OTG_INTERFSEL); 683 + if (!musb) 684 + return 0; 616 685 617 - omap2430_low_level_exit(musb); 618 - } 686 + musb->context.otg_interfsel = musb_readl(musb->mregs, 687 + OTG_INTERFSEL); 688 + 689 + omap2430_low_level_exit(musb); 619 690 620 691 return 0; 621 692 } ··· 627 696 struct musb *musb = glue_to_musb(glue); 628 697 629 698 if (!musb) 630 - return -EPROBE_DEFER; 699 + return 0; 631 700 632 701 omap2430_low_level_init(musb); 633 702 musb_writel(musb->mregs, OTG_INTERFSEL, ··· 669 738 }, 670 739 }; 671 740 741 + module_platform_driver(omap2430_driver); 742 + 672 743 MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer"); 673 744 MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); 674 745 MODULE_LICENSE("GPL v2"); 675 - 676 - static int __init omap2430_init(void) 677 - { 678 - return platform_driver_register(&omap2430_driver); 679 - } 680 - subsys_initcall(omap2430_init); 681 - 682 - static void __exit omap2430_exit(void) 683 - { 684 - platform_driver_unregister(&omap2430_driver); 685 - } 686 - module_exit(omap2430_exit);
+34 -20
drivers/usb/musb/sunxi.c
··· 80 80 81 81 struct sunxi_glue { 82 82 struct device *dev; 83 - struct platform_device *musb; 83 + struct musb *musb; 84 + struct platform_device *musb_pdev; 84 85 struct clk *clk; 85 86 struct reset_control *rst; 86 87 struct phy *phy; ··· 103 102 return; 104 103 105 104 if (test_and_clear_bit(SUNXI_MUSB_FL_HOSTMODE_PEND, &glue->flags)) { 106 - struct musb *musb = platform_get_drvdata(glue->musb); 105 + struct musb *musb = glue->musb; 107 106 unsigned long flags; 108 107 u8 devctl; 109 108 ··· 113 112 if (test_bit(SUNXI_MUSB_FL_HOSTMODE, &glue->flags)) { 114 113 set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); 115 114 musb->xceiv->otg->default_a = 1; 116 - musb->xceiv->otg->state = OTG_STATE_A_IDLE; 115 + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 117 116 MUSB_HST_MODE(musb); 118 117 devctl |= MUSB_DEVCTL_SESSION; 119 118 } else { ··· 146 145 { 147 146 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); 148 147 149 - if (is_on) 148 + if (is_on) { 150 149 set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); 151 - else 150 + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 151 + } else { 152 152 clear_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); 153 + } 153 154 154 155 schedule_work(&glue->work); 155 156 } ··· 267 264 if (ret) 268 265 goto error_unregister_notifier; 269 266 270 - if (musb->port_mode == MUSB_PORT_MODE_HOST) { 271 - ret = phy_power_on(glue->phy); 272 - if (ret) 273 - goto error_phy_exit; 274 - set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); 275 - /* Stop musb work from turning vbus off again */ 276 - set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); 277 - } 278 - 279 267 musb->isr = sunxi_musb_interrupt; 280 268 281 269 /* Stop the musb-core from doing runtime pm (not supported on sunxi) */ ··· 274 280 275 281 return 0; 276 282 277 - error_phy_exit: 278 - phy_exit(glue->phy); 279 283 error_unregister_notifier: 280 284 if (musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) 281 285 extcon_unregister_notifier(glue->extcon, EXTCON_USB_HOST, ··· 315 323 return 0; 316 324 } 317 325 326 + static int sunxi_set_mode(struct musb *musb, u8 mode) 327 + { 328 + struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); 329 + int ret; 330 + 331 + if (mode == MUSB_HOST) { 332 + ret = phy_power_on(glue->phy); 333 + if (ret) 334 + return ret; 335 + 336 + set_bit(SUNXI_MUSB_FL_PHY_ON, &glue->flags); 337 + /* Stop musb work from turning vbus off again */ 338 + set_bit(SUNXI_MUSB_FL_VBUS_ON, &glue->flags); 339 + musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; 340 + } 341 + 342 + return 0; 343 + } 344 + 318 345 static void sunxi_musb_enable(struct musb *musb) 319 346 { 320 347 struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); 348 + 349 + glue->musb = musb; 321 350 322 351 /* musb_core does not call us in a balanced manner */ 323 352 if (test_and_set_bit(SUNXI_MUSB_FL_ENABLED, &glue->flags)) ··· 582 569 .exit = sunxi_musb_exit, 583 570 .enable = sunxi_musb_enable, 584 571 .disable = sunxi_musb_disable, 572 + .set_mode = sunxi_set_mode, 585 573 .fifo_offset = sunxi_musb_fifo_offset, 586 574 .ep_offset = sunxi_musb_ep_offset, 587 575 .busctl_offset = sunxi_musb_busctl_offset, ··· 735 721 pinfo.data = &pdata; 736 722 pinfo.size_data = sizeof(pdata); 737 723 738 - glue->musb = platform_device_register_full(&pinfo); 739 - if (IS_ERR(glue->musb)) { 740 - ret = PTR_ERR(glue->musb); 724 + glue->musb_pdev = platform_device_register_full(&pinfo); 725 + if (IS_ERR(glue->musb_pdev)) { 726 + ret = PTR_ERR(glue->musb_pdev); 741 727 dev_err(&pdev->dev, "Error registering musb dev: %d\n", ret); 742 728 goto err_unregister_usb_phy; 743 729 } ··· 754 740 struct sunxi_glue *glue = platform_get_drvdata(pdev); 755 741 struct platform_device *usb_phy = glue->usb_phy; 756 742 757 - platform_device_unregister(glue->musb); /* Frees glue ! */ 743 + platform_device_unregister(glue->musb_pdev); 758 744 usb_phy_generic_unregister(usb_phy); 759 745 760 746 return 0;
+24 -5
drivers/usb/phy/phy-twl6030-usb.c
··· 97 97 98 98 struct regulator *usb3v3; 99 99 100 + /* used to check initial cable status after probe */ 101 + struct delayed_work get_status_work; 102 + 100 103 /* used to set vbus, in atomic path */ 101 104 struct work_struct set_vbus_work; 102 105 ··· 230 227 twl->asleep = 1; 231 228 status = MUSB_VBUS_VALID; 232 229 twl->linkstat = status; 233 - musb_mailbox(status); 230 + ret = musb_mailbox(status); 231 + if (ret) 232 + twl->linkstat = MUSB_UNKNOWN; 234 233 } else { 235 234 if (twl->linkstat != MUSB_UNKNOWN) { 236 235 status = MUSB_VBUS_OFF; 237 236 twl->linkstat = status; 238 - musb_mailbox(status); 237 + ret = musb_mailbox(status); 238 + if (ret) 239 + twl->linkstat = MUSB_UNKNOWN; 239 240 if (twl->asleep) { 240 241 regulator_disable(twl->usb3v3); 241 242 twl->asleep = 0; ··· 271 264 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_SET); 272 265 status = MUSB_ID_GROUND; 273 266 twl->linkstat = status; 274 - musb_mailbox(status); 267 + ret = musb_mailbox(status); 268 + if (ret) 269 + twl->linkstat = MUSB_UNKNOWN; 275 270 } else { 276 271 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_CLR); 277 272 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET); ··· 281 272 twl6030_writeb(twl, TWL_MODULE_USB, status, USB_ID_INT_LATCH_CLR); 282 273 283 274 return IRQ_HANDLED; 275 + } 276 + 277 + static void twl6030_status_work(struct work_struct *work) 278 + { 279 + struct twl6030_usb *twl = container_of(work, struct twl6030_usb, 280 + get_status_work.work); 281 + 282 + twl6030_usb_irq(twl->irq2, twl); 283 + twl6030_usbotg_irq(twl->irq1, twl); 284 284 } 285 285 286 286 static int twl6030_enable_irq(struct twl6030_usb *twl) ··· 302 284 REG_INT_MSK_LINE_C); 303 285 twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK, 304 286 REG_INT_MSK_STS_C); 305 - twl6030_usb_irq(twl->irq2, twl); 306 - twl6030_usbotg_irq(twl->irq1, twl); 307 287 308 288 return 0; 309 289 } ··· 387 371 dev_warn(&pdev->dev, "could not create sysfs file\n"); 388 372 389 373 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); 374 + INIT_DELAYED_WORK(&twl->get_status_work, twl6030_status_work); 390 375 391 376 status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq, 392 377 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, ··· 412 395 413 396 twl->asleep = 0; 414 397 twl6030_enable_irq(twl); 398 + schedule_delayed_work(&twl->get_status_work, HZ); 415 399 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); 416 400 417 401 return 0; ··· 422 404 { 423 405 struct twl6030_usb *twl = platform_get_drvdata(pdev); 424 406 407 + cancel_delayed_work(&twl->get_status_work); 425 408 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, 426 409 REG_INT_MSK_LINE_C); 427 410 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
+1
drivers/usb/serial/mos7720.c
··· 2007 2007 urblist_entry) 2008 2008 usb_unlink_urb(urbtrack->urb); 2009 2009 spin_unlock_irqrestore(&mos_parport->listlock, flags); 2010 + parport_del_port(mos_parport->pp); 2010 2011 2011 2012 kref_put(&mos_parport->ref_count, destroy_mos_parport); 2012 2013 }
+1 -1
drivers/usb/storage/uas.c
··· 836 836 if (devinfo->flags & US_FL_BROKEN_FUA) 837 837 sdev->broken_fua = 1; 838 838 839 + scsi_change_queue_depth(sdev, devinfo->qdepth - 2); 839 840 return 0; 840 841 } 841 842 ··· 849 848 .slave_configure = uas_slave_configure, 850 849 .eh_abort_handler = uas_eh_abort_handler, 851 850 .eh_bus_reset_handler = uas_eh_bus_reset_handler, 852 - .can_queue = MAX_CMNDS, 853 851 .this_id = -1, 854 852 .sg_tablesize = SG_NONE, 855 853 .skip_settle_delay = 1,
+1 -1
drivers/usb/usbip/vhci_hcd.c
··· 941 941 942 942 static int vhci_get_frame_number(struct usb_hcd *hcd) 943 943 { 944 - pr_err("Not yet implemented\n"); 944 + dev_err_ratelimited(&hcd->self.root_hub->dev, "Not yet implemented\n"); 945 945 return 0; 946 946 } 947 947
+3
include/linux/usb/gadget.h
··· 1034 1034 * @udc_name: A name of UDC this driver should be bound to. If udc_name is NULL, 1035 1035 * this driver will be bound to any available UDC. 1036 1036 * @pending: UDC core private data used for deferred probe of this driver. 1037 + * @match_existing_only: If udc is not found, return an error and don't add this 1038 + * gadget driver to list of pending driver 1037 1039 * 1038 1040 * Devices are disabled till a gadget driver successfully bind()s, which 1039 1041 * means the driver will handle setup() requests needed to enumerate (and ··· 1099 1097 1100 1098 char *udc_name; 1101 1099 struct list_head pending; 1100 + unsigned match_existing_only:1; 1102 1101 }; 1103 1102 1104 1103
+3 -2
include/linux/usb/musb.h
··· 142 142 }; 143 143 144 144 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC) 145 - void musb_mailbox(enum musb_vbus_id_status status); 145 + int musb_mailbox(enum musb_vbus_id_status status); 146 146 #else 147 - static inline void musb_mailbox(enum musb_vbus_id_status status) 147 + static inline int musb_mailbox(enum musb_vbus_id_status status) 148 148 { 149 + return 0; 149 150 } 150 151 #endif 151 152