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

usb: hub_handle_remote_wakeup() depends on CONFIG_PM_RUNTIME=y

Per Alan:
"You mean from within hub_handle_remote_wakeup()? That routine will
never get called if CONFIG_PM_RUNTIME isn't enabled, because khubd
never sees wakeup requests if they arise during system suspend.

In fact, that routine ought to go inside the "#ifdef CONFIG_PM_RUNTIME"
portion of hub.c, along with the other suspend/resume code."

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Williams and committed by
Greg Kroah-Hartman
7e73be22 5c79a1e3

+49 -46
+49 -41
drivers/usb/core/hub.c
··· 3348 3348 return status; 3349 3349 } 3350 3350 3351 + /* Returns 1 if there was a remote wakeup and a connect status change. */ 3352 + static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, 3353 + u16 portstatus, u16 portchange) 3354 + __must_hold(&port_dev->status_lock) 3355 + { 3356 + struct usb_port *port_dev = hub->ports[port - 1]; 3357 + struct usb_device *hdev; 3358 + struct usb_device *udev; 3359 + int connect_change = 0; 3360 + int ret; 3361 + 3362 + hdev = hub->hdev; 3363 + udev = port_dev->child; 3364 + if (!hub_is_superspeed(hdev)) { 3365 + if (!(portchange & USB_PORT_STAT_C_SUSPEND)) 3366 + return 0; 3367 + usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); 3368 + } else { 3369 + if (!udev || udev->state != USB_STATE_SUSPENDED || 3370 + (portstatus & USB_PORT_STAT_LINK_STATE) != 3371 + USB_SS_PORT_LS_U0) 3372 + return 0; 3373 + } 3374 + 3375 + if (udev) { 3376 + /* TRSMRCY = 10 msec */ 3377 + msleep(10); 3378 + 3379 + usb_unlock_port(port_dev); 3380 + ret = usb_remote_wakeup(udev); 3381 + usb_lock_port(port_dev); 3382 + if (ret < 0) 3383 + connect_change = 1; 3384 + } else { 3385 + ret = -ENODEV; 3386 + hub_port_disable(hub, port, 1); 3387 + } 3388 + dev_dbg(&port_dev->dev, "resume, status %d\n", ret); 3389 + return connect_change; 3390 + } 3391 + 3392 + #else 3393 + 3394 + static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, 3395 + u16 portstatus, u16 portchange) 3396 + { 3397 + return 0; 3398 + } 3399 + 3351 3400 #endif 3352 3401 3353 3402 static int check_ports_changed(struct usb_hub *hub) ··· 4744 4695 usb_unlock_port(port_dev); 4745 4696 hub_port_connect(hub, port1, portstatus, portchange); 4746 4697 usb_lock_port(port_dev); 4747 - } 4748 - 4749 - /* Returns 1 if there was a remote wakeup and a connect status change. */ 4750 - static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, 4751 - u16 portstatus, u16 portchange) 4752 - __must_hold(&port_dev->status_lock) 4753 - { 4754 - struct usb_port *port_dev = hub->ports[port - 1]; 4755 - struct usb_device *hdev; 4756 - struct usb_device *udev; 4757 - int connect_change = 0; 4758 - int ret; 4759 - 4760 - hdev = hub->hdev; 4761 - udev = port_dev->child; 4762 - if (!hub_is_superspeed(hdev)) { 4763 - if (!(portchange & USB_PORT_STAT_C_SUSPEND)) 4764 - return 0; 4765 - usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); 4766 - } else { 4767 - if (!udev || udev->state != USB_STATE_SUSPENDED || 4768 - (portstatus & USB_PORT_STAT_LINK_STATE) != 4769 - USB_SS_PORT_LS_U0) 4770 - return 0; 4771 - } 4772 - 4773 - if (udev) { 4774 - /* TRSMRCY = 10 msec */ 4775 - msleep(10); 4776 - 4777 - usb_unlock_port(port_dev); 4778 - ret = usb_remote_wakeup(udev); 4779 - usb_lock_port(port_dev); 4780 - if (ret < 0) 4781 - connect_change = 1; 4782 - } else { 4783 - ret = -ENODEV; 4784 - hub_port_disable(hub, port, 1); 4785 - } 4786 - dev_dbg(&port_dev->dev, "resume, status %d\n", ret); 4787 - return connect_change; 4788 4698 } 4789 4699 4790 4700 static void port_event(struct usb_hub *hub, int port1)
-5
drivers/usb/core/usb.h
··· 107 107 return 0; 108 108 } 109 109 110 - static inline int usb_remote_wakeup(struct usb_device *udev) 111 - { 112 - return 0; 113 - } 114 - 115 110 static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) 116 111 { 117 112 return 0;