Date: Thu, 26 Mar 2020 05:38:33 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r359318 - stable/10/sys/dev/usb Message-ID: <202003260538.02Q5cXIP082013@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Mar 26 05:38:33 2020 New Revision: 359318 URL: https://svnweb.freebsd.org/changeset/base/359318 Log: MFC r359120: Correctly implement support for remote wakeup for USB 3.0 device. Submitted by: Horse Ma <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/usb/usb.h stable/10/sys/dev/usb/usb_hub.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/usb.h ============================================================================== --- stable/10/sys/dev/usb/usb.h Thu Mar 26 05:37:50 2020 (r359317) +++ stable/10/sys/dev/usb/usb.h Thu Mar 26 05:38:33 2020 (r359318) @@ -273,6 +273,11 @@ typedef struct usb_device_request usb_device_request_t #define UHF_C_BH_PORT_RESET 29 #define UHF_FORCE_LINKPM_ACCEPT 30 +/* SuperSpeed suspend support */ +#define USB_INTERFACE_FUNC_SUSPEND 0 +#define USB_INTERFACE_FUNC_SUSPEND_LP (1 << 8) +#define USB_INTERFACE_FUNC_SUSPEND_RW (1 << 9) + struct usb_descriptor { uByte bLength; uByte bDescriptorType; Modified: stable/10/sys/dev/usb/usb_hub.c ============================================================================== --- stable/10/sys/dev/usb/usb_hub.c Thu Mar 26 05:37:50 2020 (r359317) +++ stable/10/sys/dev/usb/usb_hub.c Thu Mar 26 05:38:33 2020 (r359318) @@ -2617,6 +2617,50 @@ usb_bus_powerd(struct usb_bus *bus) } #endif +static usb_error_t +usbd_device_30_remote_wakeup(struct usb_device *udev, uint8_t bRequest) +{ + struct usb_device_request req = {}; + + req.bmRequestType = UT_WRITE_INTERFACE; + req.bRequest = bRequest; + USETW(req.wValue, USB_INTERFACE_FUNC_SUSPEND); + USETW(req.wIndex, USB_INTERFACE_FUNC_SUSPEND_LP | + USB_INTERFACE_FUNC_SUSPEND_RW); + + return (usbd_do_request(udev, NULL, &req, 0)); +} + +static usb_error_t +usbd_clear_dev_wakeup(struct usb_device *udev) +{ + usb_error_t err; + + if (usb_device_20_compatible(udev)) { + err = usbd_req_clear_device_feature(udev, + NULL, UF_DEVICE_REMOTE_WAKEUP); + } else { + err = usbd_device_30_remote_wakeup(udev, + UR_CLEAR_FEATURE); + } + return (err); +} + +static usb_error_t +usbd_set_dev_wakeup(struct usb_device *udev) +{ + usb_error_t err; + + if (usb_device_20_compatible(udev)) { + err = usbd_req_set_device_feature(udev, + NULL, UF_DEVICE_REMOTE_WAKEUP); + } else { + err = usbd_device_30_remote_wakeup(udev, + UR_SET_FEATURE); + } + return (err); +} + /*------------------------------------------------------------------------* * usb_dev_resume_peer * @@ -2720,8 +2764,7 @@ usb_dev_resume_peer(struct usb_device *udev) /* check if peer has wakeup capability */ if (usb_peer_can_wakeup(udev)) { /* clear remote wakeup */ - err = usbd_req_clear_device_feature(udev, - NULL, UF_DEVICE_REMOTE_WAKEUP); + err = usbd_clear_dev_wakeup(udev); if (err) { DPRINTFN(0, "Clearing device " "remote wakeup failed: %s\n", @@ -2786,8 +2829,7 @@ repeat: */ /* allow device to do remote wakeup */ - err = usbd_req_set_device_feature(udev, - NULL, UF_DEVICE_REMOTE_WAKEUP); + err = usbd_set_dev_wakeup(udev); if (err) { DPRINTFN(0, "Setting device " "remote wakeup failed\n"); @@ -2813,8 +2855,7 @@ repeat: if (err != 0) { if (usb_peer_can_wakeup(udev)) { /* allow device to do remote wakeup */ - err = usbd_req_clear_device_feature(udev, - NULL, UF_DEVICE_REMOTE_WAKEUP); + err = usbd_clear_dev_wakeup(udev); if (err) { DPRINTFN(0, "Setting device " "remote wakeup failed\n");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202003260538.02Q5cXIP082013>