From owner-p4-projects@FreeBSD.ORG Tue Dec 2 07:26:59 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C293E1065673; Tue, 2 Dec 2008 07:26:59 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E70A106564A for ; Tue, 2 Dec 2008 07:26:59 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3EA8FC12 for ; Tue, 2 Dec 2008 07:26:59 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mB27QxkI004366 for ; Tue, 2 Dec 2008 07:26:59 GMT (envelope-from weongyo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mB27QxGd004364 for perforce@freebsd.org; Tue, 2 Dec 2008 07:26:59 GMT (envelope-from weongyo@FreeBSD.org) Date: Tue, 2 Dec 2008 07:26:59 GMT Message-Id: <200812020726.mB27QxGd004364@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to weongyo@FreeBSD.org using -f From: Weongyo Jeong To: Perforce Change Reviews Cc: Subject: PERFORCE change 153941 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2008 07:27:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=153941 Change 153941 by weongyo@weongyo_ws on 2008/12/02 07:26:56 until now there was a serious problem when the driver try to detach like system hangs. I think this problem is fixed with this commit. Changelogs are as follows: - the return type of irp_cancelfunc which is a function pointer should be `void' not `int32_t' - always set irp_cancel value as TRUE except we encounter out of memory. I missed a case not setting it that it was a critical. - at usbd_xfertask() even if USB xfer faced errors notify it to the driver. In the previous it didn't do it so the driver never knows about it; the driver alwasy tried to wait a signal coming in forever. Affected files ... .. //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#19 edit Differences ... ==== //depot/projects/ndisusb/sys/compat/ndis/subr_usbd.c#19 (text+ko) ==== @@ -89,9 +89,9 @@ usbd_status); static int32_t usbd_iodispatch(device_object *, irp *); static int32_t usbd_ioinvalid(device_object *, irp *); -static int32_t usbd_irpcancel(device_object *, irp *); +static void usbd_irpcancel(device_object *, irp *); static void usbd_irpcancel_cb(void *); -static int32_t usbd_irpcancel_iin(device_object *, irp *); +static void usbd_irpcancel_iin(device_object *, irp *); static void usbd_irpcancel_iin_cb(void *); static int32_t usbd_submit_urb(irp *); static int32_t usbd_urb2nt(int32_t); @@ -616,7 +616,7 @@ free(nc, M_USBDEV); } -static int32_t +static void usbd_irpcancel_iin(dobj, ip) device_object *dobj; irp *ip; @@ -630,7 +630,7 @@ if (nc == NULL) { ip->irp_cancel = FALSE; IoReleaseCancelSpinLock(ip->irp_cancelirql); - return (-1); + return; } nc->dev = dev; @@ -640,9 +640,8 @@ IRP_NDISUSB_XFER(ip) = NULL; usb_add_task(uaa->device, &nc->task, USB_TASKQ_DRIVER); + ip->irp_cancel = TRUE; IoReleaseCancelSpinLock(ip->irp_cancelirql); - - return (0); } static int32_t @@ -809,7 +808,7 @@ free(nc, M_USBDEV); } -static int32_t +static void usbd_irpcancel(dobj, ip) device_object *dobj; irp *ip; @@ -819,8 +818,9 @@ struct usb_attach_arg *uaa = device_get_ivars(dev); if (IRP_NDISUSB_XFER(ip) == NULL) { + ip->irp_cancel = TRUE; IoReleaseCancelSpinLock(ip->irp_cancelirql); - return (0); + return; } /* @@ -839,7 +839,7 @@ if (nc == NULL) { ip->irp_cancel = FALSE; IoReleaseCancelSpinLock(ip->irp_cancelirql); - return (-1); + return; } nc->dev = dev; @@ -849,9 +849,8 @@ IRP_NDISUSB_XFER(ip) = NULL; usb_add_task(uaa->device, &nc->task, USB_TASKQ_DRIVER); + ip->irp_cancel = TRUE; IoReleaseCancelSpinLock(ip->irp_cancelirql); - - return (0); } static usbd_xfer_handle @@ -980,12 +979,15 @@ } if (status == USBD_STALLED) usbd_clear_endpoint_stall_async(xfer->pipe); - if (status != USBD_CANCELLED) { - device_printf(dev, "can't process status (%s)\n", - usbd_errstr(status)); - error = 1; - goto next; - } + /* + * NB: just for notice. We must handle error cases also + * because if we just return without notifying to the + * NDIS driver the driver never knows about that there + * was a error. This can cause a lot of problems like + * system hangs. + */ + device_printf(dev, "usb xfer warning (%s)\n" + usbd_errstr(status)); } urb = usbd_geturb(ip);