Module Name: src Committed By: skrll Date: Thu Sep 26 07:25:31 UTC 2013
Modified Files: src/sys/dev/usb: uhidev.c uhidev.h ukbd.c usb_subr.c usbdi.c usbdi.h usbdi_util.c usbdi_util.h Log Message: Remove usbd_do_request_async. It's callback was calling usbd_free_xfer from softint context. Adjust callers appropriately - usbd_clear_endpoint_stall_async is already triggered via a usb_task, so simply call usbd_do_request. - uhidev_set_report_async had one caller in ukbd_set_leds. Convert this usage to use usb_task as well. Discussed with mrg@ To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/dev/usb/uhidev.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/usb/uhidev.h cvs rdiff -u -r1.128 -r1.129 src/sys/dev/usb/ukbd.c cvs rdiff -u -r1.193 -r1.194 src/sys/dev/usb/usb_subr.c cvs rdiff -u -r1.155 -r1.156 src/sys/dev/usb/usbdi.c cvs rdiff -u -r1.88 -r1.89 src/sys/dev/usb/usbdi.h cvs rdiff -u -r1.61 -r1.62 src/sys/dev/usb/usbdi_util.c cvs rdiff -u -r1.44 -r1.45 src/sys/dev/usb/usbdi_util.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/uhidev.c diff -u src/sys/dev/usb/uhidev.c:1.56 src/sys/dev/usb/uhidev.c:1.57 --- src/sys/dev/usb/uhidev.c:1.56 Sun Jun 10 06:15:54 2012 +++ src/sys/dev/usb/uhidev.c Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: uhidev.c,v 1.56 2012/06/10 06:15:54 mrg Exp $ */ +/* $NetBSD: uhidev.c,v 1.57 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.56 2012/06/10 06:15:54 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.57 2013/09/26 07:25:31 skrll Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -670,22 +670,6 @@ uhidev_set_report(struct uhidev *scd, in return retstat; } -void -uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len) -{ - /* XXX */ - char buf[100]; - if (scd->sc_report_id) { - buf[0] = scd->sc_report_id; - memcpy(buf+1, data, len); - len++; - data = buf; - } - - usbd_set_report_async(scd->sc_parent->sc_iface, type, - scd->sc_report_id, data, len); -} - usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data, int len) { Index: src/sys/dev/usb/uhidev.h diff -u src/sys/dev/usb/uhidev.h:1.13 src/sys/dev/usb/uhidev.h:1.14 --- src/sys/dev/usb/uhidev.h:1.13 Sun Jun 10 06:15:54 2012 +++ src/sys/dev/usb/uhidev.h Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: uhidev.h,v 1.13 2012/06/10 06:15:54 mrg Exp $ */ +/* $NetBSD: uhidev.h,v 1.14 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -79,7 +79,6 @@ struct uhidev_attach_arg { void uhidev_get_report_desc(struct uhidev_softc *, void **, int *); int uhidev_open(struct uhidev *); void uhidev_close(struct uhidev *); -usbd_status uhidev_set_report(struct uhidev *scd, int type, void *data,int len); -void uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len); -usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data,int len); +usbd_status uhidev_set_report(struct uhidev *, int, void *, int); +usbd_status uhidev_get_report(struct uhidev *, int, void *, int); usbd_status uhidev_write(struct uhidev_softc *, void *, int); Index: src/sys/dev/usb/ukbd.c diff -u src/sys/dev/usb/ukbd.c:1.128 src/sys/dev/usb/ukbd.c:1.129 --- src/sys/dev/usb/ukbd.c:1.128 Sun Sep 15 15:44:53 2013 +++ src/sys/dev/usb/ukbd.c Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ukbd.c,v 1.128 2013/09/15 15:44:53 martin Exp $ */ +/* $NetBSD: ukbd.c,v 1.129 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.128 2013/09/15 15:44:53 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.129 2013/09/26 07:25:31 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_ukbd.h" @@ -271,6 +271,7 @@ struct ukbd_softc { struct hid_location sc_scroloc; struct hid_location sc_compose; int sc_leds; + struct usb_task sc_ledtask; device_t sc_wskbddev; #if defined(WSDISPLAY_COMPAT_RAWKBD) @@ -341,6 +342,7 @@ Static void ukbd_delayed_decode(void *ad Static int ukbd_enable(void *, int); Static void ukbd_set_leds(void *, int); +Static void ukbd_set_leds_task(void *); Static int ukbd_ioctl(void *, u_long, void *, int, struct lwp *); #if defined(WSDISPLAY_COMPAT_RAWKBD) && defined(UKBD_REPEAT) @@ -476,6 +478,9 @@ ukbd_attach(device_t parent, device_t se callout_init(&sc->sc_delay, 0); + usb_init_task(&sc->sc_ledtask, ukbd_set_leds_task, sc, + USB_TASKQ_MPSAFE); + /* Flash the leds; no real purpose, just shows we're alive. */ ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS | WSKBD_LED_COMPOSE); @@ -884,7 +889,7 @@ void ukbd_set_leds(void *v, int leds) { struct ukbd_softc *sc = v; - u_int8_t res; + usbd_device_handle udev = sc->sc_hdev.sc_parent->sc_udev; DPRINTF(("ukbd_set_leds: sc=%p leds=%d, sc_leds=%d\n", sc, leds, sc->sc_leds)); @@ -894,8 +899,18 @@ ukbd_set_leds(void *v, int leds) if (sc->sc_leds == leds) return; + sc->sc_leds = leds; - res = 0; + usb_add_task(udev, &sc->sc_ledtask, USB_TASKQ_DRIVER); +} + +void +ukbd_set_leds_task(void *v) +{ + struct ukbd_softc *sc = v; + int leds = sc->sc_leds; + uint8_t res = 0; + /* XXX not really right */ if ((leds & WSKBD_LED_COMPOSE) && sc->sc_compose.size == 1) res |= 1 << sc->sc_compose.pos; @@ -905,7 +920,8 @@ ukbd_set_leds(void *v, int leds) res |= 1 << sc->sc_numloc.pos; if ((leds & WSKBD_LED_CAPS) && sc->sc_capsloc.size == 1) res |= 1 << sc->sc_capsloc.pos; - uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, &res, 1); + + uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, &res, 1); } #if defined(WSDISPLAY_COMPAT_RAWKBD) && defined(UKBD_REPEAT) Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.193 src/sys/dev/usb/usb_subr.c:1.194 --- src/sys/dev/usb/usb_subr.c:1.193 Sat Sep 14 00:40:31 2013 +++ src/sys/dev/usb/usb_subr.c Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.193 2013/09/14 00:40:31 jakllsch Exp $ */ +/* $NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.193 2013/09/14 00:40:31 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -770,7 +770,7 @@ usbd_setup_pipe_flags(usbd_device_handle free(p, M_USB); return (err); } - usb_init_task(&p->async_task, usbd_clear_endpoint_stall_async_cb, p, + usb_init_task(&p->async_task, usbd_clear_endpoint_stall_task, p, USB_TASKQ_MPSAFE); *pipe = p; return (USBD_NORMAL_COMPLETION); Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.155 src/sys/dev/usb/usbdi.c:1.156 --- src/sys/dev/usb/usbdi.c:1.155 Thu Aug 22 20:00:43 2013 +++ src/sys/dev/usb/usbdi.c Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $ */ +/* $NetBSD: usbdi.c,v 1.156 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.156 2013/09/26 07:25:31 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -608,7 +608,7 @@ XXX should we do this? } void -usbd_clear_endpoint_stall_async_cb(void *arg) +usbd_clear_endpoint_stall_task(void *arg) { usbd_pipe_handle pipe = arg; usbd_device_handle dev = pipe->device; @@ -621,7 +621,7 @@ usbd_clear_endpoint_stall_async_cb(void USETW(req.wValue, UF_ENDPOINT_HALT); USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress); USETW(req.wLength, 0); - (void)usbd_do_request_async(dev, &req, 0); + (void)usbd_do_request(dev, &req, 0); } void @@ -1085,49 +1085,6 @@ usbd_do_request_flags_pipe(usbd_device_h return (err); } -void -usbd_do_request_async_cb(usbd_xfer_handle xfer, - usbd_private_handle priv, usbd_status status) -{ -#if defined(USB_DEBUG) || defined(DIAGNOSTIC) - if (xfer->actlen > xfer->length) { - DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x" - "%02x val=%d index=%d rlen=%d length=%d actlen=%d\n", - xfer->pipe->device->address, - xfer->request.bmRequestType, - xfer->request.bRequest, UGETW(xfer->request.wValue), - UGETW(xfer->request.wIndex), - UGETW(xfer->request.wLength), - xfer->length, xfer->actlen)); - } -#endif - usbd_free_xfer(xfer); -} - -/* - * Execute a request without waiting for completion. - * Can be used from interrupt context. - */ -usbd_status -usbd_do_request_async(usbd_device_handle dev, usb_device_request_t *req, - void *data) -{ - usbd_xfer_handle xfer; - usbd_status err; - - xfer = usbd_alloc_xfer(dev); - if (xfer == NULL) - return (USBD_NOMEM); - usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req, - data, UGETW(req->wLength), 0, usbd_do_request_async_cb); - err = usbd_transfer(xfer); - if (err != USBD_IN_PROGRESS) { - usbd_free_xfer(xfer); - return (err); - } - return (USBD_NORMAL_COMPLETION); -} - const struct usbd_quirks * usbd_get_quirks(usbd_device_handle dev) { Index: src/sys/dev/usb/usbdi.h diff -u src/sys/dev/usb/usbdi.h:1.88 src/sys/dev/usb/usbdi.h:1.89 --- src/sys/dev/usb/usbdi.h:1.88 Sat Sep 7 16:47:23 2013 +++ src/sys/dev/usb/usbdi.h Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.h,v 1.88 2013/09/07 16:47:23 skrll Exp $ */ +/* $NetBSD: usbdi.h,v 1.89 2013/09/26 07:25:31 skrll Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ /* @@ -190,7 +190,7 @@ void usb_desc_iter_init(usbd_device_hand const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *); /* Used to clear endpoint stalls from the softint */ -void usbd_clear_endpoint_stall_async_cb(void *); +void usbd_clear_endpoint_stall_task(void *); /* * The usb_task structs form a queue of things to run in the USB event Index: src/sys/dev/usb/usbdi_util.c diff -u src/sys/dev/usb/usbdi_util.c:1.61 src/sys/dev/usb/usbdi_util.c:1.62 --- src/sys/dev/usb/usbdi_util.c:1.61 Fri Aug 30 12:59:19 2013 +++ src/sys/dev/usb/usbdi_util.c Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi_util.c,v 1.61 2013/08/30 12:59:19 skrll Exp $ */ +/* $NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.61 2013/08/30 12:59:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -273,26 +273,6 @@ usbd_set_report(usbd_interface_handle if } usbd_status -usbd_set_report_async(usbd_interface_handle iface, int type, int id, void *data, - int len) -{ - usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface); - usbd_device_handle dev; - usb_device_request_t req; - - DPRINTFN(4, ("usbd_set_report_async: len=%d\n", len)); - if (ifd == NULL) - return (USBD_IOERROR); - usbd_interface2device_handle(iface, &dev); - req.bmRequestType = UT_WRITE_CLASS_INTERFACE; - req.bRequest = UR_SET_REPORT; - USETW2(req.wValue, type, id); - USETW(req.wIndex, ifd->bInterfaceNumber); - USETW(req.wLength, len); - return (usbd_do_request_async(dev, &req, data)); -} - -usbd_status usbd_get_report(usbd_interface_handle iface, int type, int id, void *data, int len) { Index: src/sys/dev/usb/usbdi_util.h diff -u src/sys/dev/usb/usbdi_util.h:1.44 src/sys/dev/usb/usbdi_util.h:1.45 --- src/sys/dev/usb/usbdi_util.h:1.44 Sun Jun 10 06:15:55 2012 +++ src/sys/dev/usb/usbdi_util.h Thu Sep 26 07:25:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi_util.h,v 1.44 2012/06/10 06:15:55 mrg Exp $ */ +/* $NetBSD: usbdi_util.h,v 1.45 2013/09/26 07:25:31 skrll Exp $ */ /* * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -58,8 +58,6 @@ usbd_status usbd_get_report_descriptor(u usb_hid_descriptor_t *usbd_get_hid_descriptor(usbd_interface_handle ifc); usbd_status usbd_set_report(usbd_interface_handle iface, int type, int id, void *data,int len); -usbd_status usbd_set_report_async(usbd_interface_handle iface, int type, - int id, void *data, int len); usbd_status usbd_get_report(usbd_interface_handle iface, int type, int id, void *data, int len); usbd_status usbd_set_idle(usbd_interface_handle iface, int duration,int id);