Wed Oct 12 02:50:44 2016 UTC ()
Stop urtwn devices from usb suspend, allow remote wifi activity wakeup.

Addresses PR/51111.

OK christos@


(nat)
diff -r1.46 -r1.47 src/sys/dev/usb/if_urtwn.c

cvs diff -r1.46 -r1.47 src/sys/dev/usb/if_urtwn.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_urtwn.c 2016/10/04 21:36:38 1.46
+++ src/sys/dev/usb/if_urtwn.c 2016/10/12 02:50:44 1.47
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_urtwn.c,v 1.46 2016/10/04 21:36:38 christos Exp $ */ 1/* $NetBSD: if_urtwn.c,v 1.47 2016/10/12 02:50:44 nat Exp $ */
2/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ 2/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org> 6 * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21/*- 21/*-
22 * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU. 22 * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.46 2016/10/04 21:36:38 christos Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.47 2016/10/12 02:50:44 nat Exp $");
27 27
28#ifdef _KERNEL_OPT 28#ifdef _KERNEL_OPT
29#include "opt_inet.h" 29#include "opt_inet.h"
30#endif 30#endif
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/sockio.h> 33#include <sys/sockio.h>
34#include <sys/sysctl.h> 34#include <sys/sysctl.h>
35#include <sys/mbuf.h> 35#include <sys/mbuf.h>
36#include <sys/kernel.h> 36#include <sys/kernel.h>
37#include <sys/socket.h> 37#include <sys/socket.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/module.h> 39#include <sys/module.h>
@@ -308,46 +308,55 @@ urtwn_match(device_t parent, cfdata_t ma @@ -308,46 +308,55 @@ urtwn_match(device_t parent, cfdata_t ma
308 return urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL ? 308 return urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL ?
309 UMATCH_VENDOR_PRODUCT : UMATCH_NONE; 309 UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
310} 310}
311 311
312static void 312static void
313urtwn_attach(device_t parent, device_t self, void *aux) 313urtwn_attach(device_t parent, device_t self, void *aux)
314{ 314{
315 struct urtwn_softc *sc = device_private(self); 315 struct urtwn_softc *sc = device_private(self);
316 struct ieee80211com *ic = &sc->sc_ic; 316 struct ieee80211com *ic = &sc->sc_ic;
317 struct ifnet *ifp = &sc->sc_if; 317 struct ifnet *ifp = &sc->sc_if;
318 struct usb_attach_arg *uaa = aux; 318 struct usb_attach_arg *uaa = aux;
319 char *devinfop; 319 char *devinfop;
320 const struct urtwn_dev *dev; 320 const struct urtwn_dev *dev;
 321 usb_device_request_t req;
321 size_t i; 322 size_t i;
322 int error; 323 int error;
323 324
324 sc->sc_dev = self; 325 sc->sc_dev = self;
325 sc->sc_udev = uaa->uaa_device; 326 sc->sc_udev = uaa->uaa_device;
326 327
327 sc->chip = 0; 328 sc->chip = 0;
328 dev = urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product); 329 dev = urtwn_lookup(urtwn_devs, uaa->uaa_vendor, uaa->uaa_product);
329 if (dev != NULL && ISSET(dev->flags, FLAG_RTL8188E)) 330 if (dev != NULL && ISSET(dev->flags, FLAG_RTL8188E))
330 SET(sc->chip, URTWN_CHIP_88E); 331 SET(sc->chip, URTWN_CHIP_88E);
331 332
332 aprint_naive("\n"); 333 aprint_naive("\n");
333 aprint_normal("\n"); 334 aprint_normal("\n");
334 335
335 DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); 336 DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
336 337
337 devinfop = usbd_devinfo_alloc(sc->sc_udev, 0); 338 devinfop = usbd_devinfo_alloc(sc->sc_udev, 0);
338 aprint_normal_dev(self, "%s\n", devinfop); 339 aprint_normal_dev(self, "%s\n", devinfop);
339 usbd_devinfo_free(devinfop); 340 usbd_devinfo_free(devinfop);
340 341
 342 req.bmRequestType = UT_WRITE_DEVICE;
 343 req.bRequest = UR_SET_FEATURE;
 344 USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
 345 USETW(req.wIndex, UHF_PORT_SUSPEND);
 346 USETW(req.wLength, 0);
 347
 348 (void) usbd_do_request(sc->sc_udev, &req, 0);
 349
341 mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET); 350 mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
342 mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_NONE); 351 mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_NONE);
343 mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE); 352 mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
344 mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE); 353 mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
345 354
346 usb_init_task(&sc->sc_task, urtwn_task, sc, 0); 355 usb_init_task(&sc->sc_task, urtwn_task, sc, 0);
347 356
348 callout_init(&sc->sc_scan_to, 0); 357 callout_init(&sc->sc_scan_to, 0);
349 callout_setfunc(&sc->sc_scan_to, urtwn_next_scan, sc); 358 callout_setfunc(&sc->sc_scan_to, urtwn_next_scan, sc);
350 callout_init(&sc->sc_calib_to, 0); 359 callout_init(&sc->sc_calib_to, 0);
351 callout_setfunc(&sc->sc_calib_to, urtwn_calib_to, sc); 360 callout_setfunc(&sc->sc_calib_to, urtwn_calib_to, sc);
352 361
353 error = usbd_set_config_no(sc->sc_udev, 1, 0); 362 error = usbd_set_config_no(sc->sc_udev, 1, 0);