From owner-p4-projects@FreeBSD.ORG Thu Apr 16 17:14:12 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 45B111065670; Thu, 16 Apr 2009 17:14:12 +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 0338A106566B for ; Thu, 16 Apr 2009 17:14:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CC3EB8FC1D for ; Thu, 16 Apr 2009 17:14:11 +0000 (UTC) (envelope-from hselasky@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 n3GHEB6K048417 for ; Thu, 16 Apr 2009 17:14:11 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n3GHEBm4048415 for perforce@freebsd.org; Thu, 16 Apr 2009 17:14:11 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 16 Apr 2009 17:14:11 GMT Message-Id: <200904161714.n3GHEBm4048415@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 160706 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: Thu, 16 Apr 2009 17:14:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=160706 Change 160706 by hselasky@hselasky_laptop001 on 2009/04/16 17:13:34 USB CORE: - resolve possible device side mode deadlock by creating another thread. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/controller/usb_controller.c#12 edit .. //depot/projects/usb/src/sys/dev/usb/usb_bus.h#7 edit .. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#140 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/controller/usb_controller.c#12 (text+ko) ==== @@ -169,6 +169,10 @@ usb2_proc_free(&bus->explore_proc); + /* Get rid of control transfer process */ + + usb2_proc_free(&bus->control_xfer_proc); + return (0); } @@ -418,6 +422,10 @@ &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB explore " "process failed.\n"); + } else if (usb2_proc_create(&bus->control_xfer_proc, + &bus->bus_mtx, pname, USB_PRI_MED)) { + printf("WARNING: Creation of USB control transfer " + "process failed.\n"); } else { /* Get final attach going */ USB_BUS_LOCK(bus); ==== //depot/projects/usb/src/sys/dev/usb/usb_bus.h#7 (text+ko) ==== @@ -62,7 +62,6 @@ struct usb2_bus { struct usb2_bus_stat stats_err; struct usb2_bus_stat stats_ok; - struct usb2_process explore_proc; struct usb2_sw_transfer roothub_req; struct root_hold_token *bus_roothold; /* @@ -72,6 +71,13 @@ */ struct usb2_process giant_callback_proc; struct usb2_process non_giant_callback_proc; + + /* Explore process */ + struct usb2_process explore_proc; + + /* Control request process */ + struct usb2_process control_xfer_proc; + struct usb2_bus_msg explore_msg[2]; struct usb2_bus_msg detach_msg[2]; struct usb2_bus_msg attach_msg[2]; ==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#140 (text+ko) ==== @@ -822,7 +822,16 @@ info->done_m[1].hdr.pm_callback = &usb2_callback_proc; info->done_m[1].xroot = info; - if (xfer_mtx == &Giant) + /* + * In device side mode control endpoint + * requests need to run from a separate + * context, else there is a chance of + * deadlock! + */ + if (setup_start == usb2_control_ep_cfg) + info->done_p = + &udev->bus->control_xfer_proc; + else if (xfer_mtx == &Giant) info->done_p = &udev->bus->giant_callback_proc; else