From c51fa66802b922070dfda0d77fac364c367db5f6 Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 21 May 2012 05:34:24 -0700 Subject: brcm80211: Fix compile error for .disable_hub_initiated_lpm. Fix missing comma. Signed-off-by: Sarah Sharp Reported-by: Wu Fengguang diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 8852d23..f2bc48b 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 = { .id_table = brcmf_usb_devid_table, .suspend = brcmf_usb_suspend, .resume = brcmf_usb_resume, - .supports_autosuspend = 1 + .supports_autosuspend = 1, .disable_hub_initiated_lpm = 1, }; -- cgit v0.10.2 From e9261fb62a8b6a79a58c57cc6f4a40530b040b61 Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 21 May 2012 08:29:01 -0700 Subject: USB: Fix core compile with CONFIG_USB_SUSPEND=n When CONFIG_PM=n, make sure that the usb_[unlocked_][en/dis]able_lpm declarations are visible in include/linux/usb.h, and exported from drivers/usb/core/hub.c. Before this patch, if CONFIG_USB_SUSPEND was turned off, it would cause build errors: drivers/usb/core/hub.c: In function 'usb_disable_lpm': drivers/usb/core/hub.c:3394:2: error: implicit declaration of function 'usb_enable_lpm' [-Werror=implicit-function-declaration] drivers/usb/core/hub.c: At top level: drivers/usb/core/hub.c:3424:6: warning: conflicting types for 'usb_enable_lpm' [enabled by default] drivers/usb/core/hub.c:3394:2: note: previous implicit declaration of 'usb_enable_lpm' was here drivers/usb/core/driver.c: In function 'usb_probe_interface': drivers/usb/core/driver.c:339:2: error: implicit declaration of function 'usb_unlocked_disable_lpm' [-Werror=implicit-function-declaration] drivers/usb/core/driver.c:364:3: error: implicit declaration of function 'usb_unlocked_enable_lpm' [-Werror=implicit-function-declaration] drivers/usb/core/message.c: In function 'usb_set_interface': drivers/usb/core/message.c:1314:2: error: implicit declaration of function 'usb_disable_lpm' [-Werror=implicit-function-declaration] drivers/usb/core/message.c:1323:3: error: implicit declaration of function 'usb_enable_lpm' [-Werror=implicit-function-declaration] drivers/usb/core/message.c:1368:2: error: implicit declaration of function 'usb_unlocked_enable_lpm' [-Werror=implicit-function-declaration] Signed-off-by: Sarah Sharp Reported-by: Stephen Rothwell Reported-by: Chen Peter-B29397 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index fcc244e..04fb834 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) { return 0; } +EXPORT_SYMBOL_GPL(usb_disable_lpm); void usb_enable_lpm(struct usb_device *udev) { } +EXPORT_SYMBOL_GPL(usb_enable_lpm); int usb_unlocked_disable_lpm(struct usb_device *udev) { return 0; } +EXPORT_SYMBOL_GPL(usb_unlocked_disable_lpm); void usb_unlocked_enable_lpm(struct usb_device *udev) { } +EXPORT_SYMBOL_GPL(usb_unlocked_enable_lpm); #endif diff --git a/include/linux/usb.h b/include/linux/usb.h index c19297a..dea39dc 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); extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); -extern int usb_disable_lpm(struct usb_device *udev); -extern void usb_enable_lpm(struct usb_device *udev); -/* Same as above, but these functions lock/unlock the bandwidth_mutex. */ -extern int usb_unlocked_disable_lpm(struct usb_device *udev); -extern void usb_unlocked_enable_lpm(struct usb_device *udev); - static inline void usb_mark_last_busy(struct usb_device *udev) { pm_runtime_mark_last_busy(&udev->dev); @@ -629,6 +623,12 @@ static inline void usb_mark_last_busy(struct usb_device *udev) { } #endif +extern int usb_disable_lpm(struct usb_device *udev); +extern void usb_enable_lpm(struct usb_device *udev); +/* Same as above, but these functions lock/unlock the bandwidth_mutex. */ +extern int usb_unlocked_disable_lpm(struct usb_device *udev); +extern void usb_unlocked_enable_lpm(struct usb_device *udev); + /*-------------------------------------------------------------------------*/ /* for drivers using iso endpoints */ -- cgit v0.10.2 From b01bcbf7aeba5e87cf51147c654b1be8686ba643 Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 21 May 2012 07:54:42 -0700 Subject: xhci: Fix compile with CONFIG_USB_SUSPEND=n The USB 2.0 Link PM code is conditionally compiled when CONFIG_USB_SUSPEND=y. I believe that's a mistake, since Link PM is not directly related to USB device suspend and Link PM is implemented without relying on any of the suspend code in the USB core. For now, keep the USB 2.0 Link PM code conditionally compiled if CONFIG_USB_SUSPEND=y. This patch does move the code to implement USB 3.0 Link PM out of the xHCI driver #ifdefs for CONFIG_USB_SUSPEND and moves it into a section dependent on CONFIG_PM. The USB core functions for USB 3.0 Link PM are already conditionally compiled when CONFIG_PM=y. Signed-off-by: Sarah Sharp diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4ceba14..ad9ef05 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, return 0; } +int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + + ret = xhci_usb2_software_lpm_test(hcd, udev); + if (!ret) { + xhci_dbg(xhci, "software LPM test succeed\n"); + if (xhci->hw_lpm_support == 1) { + udev->usb2_hw_lpm_capable = 1; + ret = xhci_set_usb2_hardware_lpm(hcd, udev, 1); + if (!ret) + udev->usb2_hw_lpm_enabled = 1; + } + } + + return 0; +} + +#else + +int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, + struct usb_device *udev, int enable) +{ + return 0; +} + +int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) +{ + return 0; +} + +#endif /* CONFIG_USB_SUSPEND */ + /*---------------------- USB 3.0 Link PM functions ------------------------*/ +#ifdef CONFIG_PM /* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */ static unsigned long long xhci_service_interval_to_ns( struct usb_endpoint_descriptor *desc) @@ -4287,41 +4322,22 @@ int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd, return ret; return 0; } -/*-------------------------------------------------------------------------*/ - -int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) -{ - struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int ret; - - ret = xhci_usb2_software_lpm_test(hcd, udev); - if (!ret) { - xhci_dbg(xhci, "software LPM test succeed\n"); - if (xhci->hw_lpm_support == 1) { - udev->usb2_hw_lpm_capable = 1; - ret = xhci_set_usb2_hardware_lpm(hcd, udev, 1); - if (!ret) - udev->usb2_hw_lpm_enabled = 1; - } - } +#else /* CONFIG_PM */ - return 0; -} - -#else - -int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, - struct usb_device *udev, int enable) +int xhci_enable_usb3_lpm_timeout(struct usb_hcd *hcd, + struct usb_device *udev, enum usb3_link_state state) { - return 0; + return USB3_LPM_DISABLED; } -int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev) +int xhci_disable_usb3_lpm_timeout(struct usb_hcd *hcd, + struct usb_device *udev, enum usb3_link_state state) { return 0; } +#endif /* CONFIG_PM */ -#endif /* CONFIG_USB_SUSPEND */ +/*-------------------------------------------------------------------------*/ /* Once a hub descriptor is fetched for a device, we need to update the xHC's * internal data structures for the device. -- cgit v0.10.2 From c88db160a30cccb81303212b256680f2e37e35ae Mon Sep 17 00:00:00 2001 From: Sarah Sharp Date: Mon, 21 May 2012 08:44:33 -0700 Subject: xhci: Fix DIV_ROUND_UP compile error. Fengguang reports that the xHCI driver isn't linked properly on his machine: ERROR: "__udivdi3" [drivers/usb/host/xhci-hcd.ko] undefined! ERROR: "handle_edge_irq" [drivers/gpio/gpio-pch.ko] undefined! ERROR: "irq_to_desc" [drivers/gpio/gpio-pch.ko] undefined! The driver compiles fine on my 64-bit box (gcc version 4.6.1). Fengguang thinks it's because the xHCI driver was using DIV_ROUND_UP() instead of DIV_ROUND_UP_ULL() with arguments that were unsigned long long variables. Signed-off-by: Sarah Sharp Reported-by: Wu Fengguang diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ad9ef05..afdc73e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3956,7 +3956,7 @@ static u16 xhci_calculate_intel_u1_timeout(struct usb_device *udev, /* Otherwise the calculation is the same as isoc eps */ case USB_ENDPOINT_XFER_ISOC: timeout_ns = xhci_service_interval_to_ns(desc); - timeout_ns = DIV_ROUND_UP(timeout_ns * 105, 100); + timeout_ns = DIV_ROUND_UP_ULL(timeout_ns * 105, 100); if (timeout_ns < udev->u1_params.sel * 2) timeout_ns = udev->u1_params.sel * 2; break; @@ -3965,7 +3965,7 @@ static u16 xhci_calculate_intel_u1_timeout(struct usb_device *udev, } /* The U1 timeout is encoded in 1us intervals. */ - timeout_ns = DIV_ROUND_UP(timeout_ns, 1000); + timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 1000); /* Don't return a timeout of zero, because that's USB3_LPM_DISABLED. */ if (timeout_ns == USB3_LPM_DISABLED) timeout_ns++; @@ -4004,7 +4004,7 @@ static u16 xhci_calculate_intel_u2_timeout(struct usb_device *udev, timeout_ns = u2_del_ns; /* The U2 timeout is encoded in 256us intervals */ - timeout_ns = DIV_ROUND_UP(timeout_ns, 256 * 1000); + timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000); /* If the necessary timeout value is bigger than what we can set in the * USB 3.0 hub, we have to disable hub-initiated U2. */ -- cgit v0.10.2