aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c2
-rw-r--r--drivers/usb/core/hub.c4
-rw-r--r--drivers/usb/host/xhci.c76
-rw-r--r--include/linux/usb.h12
4 files changed, 57 insertions, 37 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index 8852d23ef82..f2bc48b745e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -1604,7 +1604,7 @@ static struct usb_driver brcmf_usbdrvr = {
1604 .id_table = brcmf_usb_devid_table, 1604 .id_table = brcmf_usb_devid_table,
1605 .suspend = brcmf_usb_suspend, 1605 .suspend = brcmf_usb_suspend,
1606 .resume = brcmf_usb_resume, 1606 .resume = brcmf_usb_resume,
1607 .supports_autosuspend = 1 1607 .supports_autosuspend = 1,
1608 .disable_hub_initiated_lpm = 1, 1608 .disable_hub_initiated_lpm = 1,
1609}; 1609};
1610 1610
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index fcc244e9056..04fb834c3fa 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3472,15 +3472,19 @@ int usb_disable_lpm(struct usb_device *udev)
3472{ 3472{
3473 return 0; 3473 return 0;
3474} 3474}
3475EXPORT_SYMBOL_GPL(usb_disable_lpm);
3475 3476
3476void usb_enable_lpm(struct usb_device *udev) { } 3477void usb_enable_lpm(struct usb_device *udev) { }
3478EXPORT_SYMBOL_GPL(usb_enable_lpm);
3477 3479
3478int usb_unlocked_disable_lpm(struct usb_device *udev) 3480int usb_unlocked_disable_lpm(struct usb_device *udev)
3479{ 3481{
3480 return 0; 3482 return 0;
3481} 3483}
3484EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm);
3482 3485
3483void usb_unlocked_enable_lpm(struct usb_device *udev) { } 3486void usb_unlocked_enable_lpm(struct usb_device *udev) { }
3487EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm);
3484#endif 3488#endif
3485 3489
3486 3490
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4ceba145fa8..afdc73ee84a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3837,8 +3837,43 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
3837 return 0; 3837 return 0;
3838} 3838}
3839 3839
3840int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
3841{
3842 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
3843 int ret;
3844
3845 ret = xhci_usb2_software_lpm_test(hcd, udev);
3846 if (!ret) {
3847 xhci_dbg(xhci, "software LPM test succeed\n");
3848 if (xhci->hw_lpm_support == 1) {
3849 udev->usb2_hw_lpm_capable = 1;
3850 ret = xhci_set_usb2_hardware_lpm(hcd, udev, 1);
3851 if (!ret)
3852 udev->usb2_hw_lpm_enabled = 1;
3853 }
3854 }
3855
3856 return 0;
3857}
3858
3859#else
3860
3861int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
3862 struct usb_device *udev, int enable)
3863{
3864 return 0;
3865}
3866
3867int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
3868{
3869 return 0;
3870}
3871
3872#endif /* CONFIG_USB_SUSPEND */
3873
3840/*---------------------- USB 3.0 Link PM functions ------------------------*/ 3874/*---------------------- USB 3.0 Link PM functions ------------------------*/
3841 3875
3876#ifdef CONFIG_PM
3842/* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */ 3877/* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */
3843static unsigned long long xhci_service_interval_to_ns( 3878static unsigned long long xhci_service_interval_to_ns(
3844 struct usb_endpoint_descriptor *desc) 3879 struct usb_endpoint_descriptor *desc)
@@ -3921,7 +3956,7 @@ static u16 xhci_calculate_intel_u1_timeout(struct usb_device *udev,
3921 /* Otherwise the calculation is the same as isoc eps */ 3956 /* Otherwise the calculation is the same as isoc eps */
3922 case USB_ENDPOINT_XFER_ISOC: 3957 case USB_ENDPOINT_XFER_ISOC:
3923 timeout_ns = xhci_service_interval_to_ns(desc); 3958 timeout_ns = xhci_service_interval_to_ns(desc);
3924 timeout_ns = DIV_ROUND_UP(timeout_ns * 105, 100); 3959 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns * 105, 100);
3925 if (timeout_ns < udev->u1_params.sel * 2) 3960 if (timeout_ns < udev->u1_params.sel * 2)
3926 timeout_ns = udev->u1_params.sel * 2; 3961 timeout_ns = udev->u1_params.sel * 2;
3927 break; 3962 break;
@@ -3930,7 +3965,7 @@ static u16 xhci_calculate_intel_u1_timeout(struct usb_device *udev,
3930 } 3965 }
3931 3966
3932 /* The U1 timeout is encoded in 1us intervals. */ 3967 /* The U1 timeout is encoded in 1us intervals. */
3933 timeout_ns = DIV_ROUND_UP(timeout_ns, 1000); 3968 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 1000);
3934 /* Don't return a timeout of zero, because that's USB3_LPM_DISABLED. */ 3969 /* Don't return a timeout of zero, because that's USB3_LPM_DISABLED. */
3935 if (timeout_ns == USB3_LPM_DISABLED) 3970 if (timeout_ns == USB3_LPM_DISABLED)
3936 timeout_ns++; 3971 timeout_ns++;
@@ -3969,7 +4004,7 @@ static u16 xhci_calculate_intel_u2_timeout(struct usb_device *udev,
3969 timeout_ns = u2_del_ns; 4004 timeout_ns = u2_del_ns;
3970 4005
3971 /* The U2 timeout is encoded in 256us intervals */ 4006 /* The U2 timeout is encoded in 256us intervals */
3972 timeout_ns = DIV_ROUND_UP(timeout_ns, 256 * 1000); 4007 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000);
3973 /* If the necessary timeout value is bigger than what we can set in the 4008 /* If the necessary timeout value is bigger than what we can set in the
3974 * USB 3.0 hub, we have to disable hub-initiated U2. 4009 * USB 3.0 hub, we have to disable hub-initiated U2.
3975 */ 4010 */
@@ -4287,41 +4322,22 @@ int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd,
4287 return ret; 4322 return ret;
4288 return 0; 4323 return 0;
4289} 4324}
4290/*-------------------------------------------------------------------------*/ 4325#else /* CONFIG_PM */
4291
4292int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4293{
4294 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4295 int ret;
4296
4297 ret = xhci_usb2_software_lpm_test(hcd, udev);
4298 if (!ret) {
4299 xhci_dbg(xhci, "software LPM test succeed\n");
4300 if (xhci->hw_lpm_support == 1) {
4301 udev->usb2_hw_lpm_capable = 1;
4302 ret = xhci_set_usb2_hardware_lpm(hcd, udev, 1);
4303 if (!ret)
4304 udev->usb2_hw_lpm_enabled = 1;
4305 }
4306 }
4307 4326
4308 return 0; 4327int xhci_enable_usb3_lpm_timeout(struct usb_hcd *hcd,
4309} 4328 struct usb_device *udev, enum usb3_link_state state)
4310
4311#else
4312
4313int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4314 struct usb_device *udev, int enable)
4315{ 4329{
4316 return 0; 4330 return USB3_LPM_DISABLED;
4317} 4331}
4318 4332
4319int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) 4333int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd,
4334 struct usb_device *udev, enum usb3_link_state state)
4320{ 4335{
4321 return 0; 4336 return 0;
4322} 4337}
4338#endif /* CONFIG_PM */
4323 4339
4324#endif /* CONFIG_USB_SUSPEND */ 4340/*-------------------------------------------------------------------------*/
4325 4341
4326/* Once a hub descriptor is fetched for a device, we need to update the xHC's 4342/* Once a hub descriptor is fetched for a device, we need to update the xHC's
4327 * internal data structures for the device. 4343 * internal data structures for the device.
diff --git a/include/linux/usb.h b/include/linux/usb.h
index c19297a8779..dea39dc551d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -592,12 +592,6 @@ extern void usb_autopm_put_interface_async(struct usb_interface *intf);
592extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); 592extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
593extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); 593extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
594 594
595extern int usb_disable_lpm(struct usb_device *udev);
596extern void usb_enable_lpm(struct usb_device *udev);
597/* Same as above, but these functions lock/unlock the bandwidth_mutex. */
598extern int usb_unlocked_disable_lpm(struct usb_device *udev);
599extern void usb_unlocked_enable_lpm(struct usb_device *udev);
600
601static inline void usb_mark_last_busy(struct usb_device *udev) 595static inline void usb_mark_last_busy(struct usb_device *udev)
602{ 596{
603 pm_runtime_mark_last_busy(&udev->dev); 597 pm_runtime_mark_last_busy(&udev->dev);
@@ -629,6 +623,12 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
629{ } 623{ }
630#endif 624#endif
631 625
626extern int usb_disable_lpm(struct usb_device *udev);
627extern void usb_enable_lpm(struct usb_device *udev);
628/* Same as above, but these functions lock/unlock the bandwidth_mutex. */
629extern int usb_unlocked_disable_lpm(struct usb_device *udev);
630extern void usb_unlocked_enable_lpm(struct usb_device *udev);
631
632/*-------------------------------------------------------------------------*/ 632/*-------------------------------------------------------------------------*/
633 633
634/* for drivers using iso endpoints */ 634/* for drivers using iso endpoints */