From owner-svn-src-head@FreeBSD.ORG Wed Apr 22 17:08:12 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98FCA10658C7; Wed, 22 Apr 2009 17:08:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 854AA8FC19; Wed, 22 Apr 2009 17:08:10 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3MH8A1W062765; Wed, 22 Apr 2009 17:08:10 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3MH8AaN062762; Wed, 22 Apr 2009 17:08:10 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200904221708.n3MH8AaN062762@svn.freebsd.org> From: Andrew Thompson Date: Wed, 22 Apr 2009 17:08:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191400 - in head/sys/dev/usb: . controller X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2009 17:08:13 -0000 Author: thompsa Date: Wed Apr 22 17:08:10 2009 New Revision: 191400 URL: http://svn.freebsd.org/changeset/base/191400 Log: MFp4 //depot/projects/usb@160706 Resolve possible device side mode deadlock by creating another thread. Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb/controller/usb_controller.c head/sys/dev/usb/usb_bus.h head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/controller/usb_controller.c ============================================================================== --- head/sys/dev/usb/controller/usb_controller.c Wed Apr 22 17:08:07 2009 (r191399) +++ head/sys/dev/usb/controller/usb_controller.c Wed Apr 22 17:08:10 2009 (r191400) @@ -169,6 +169,10 @@ usb2_detach(device_t dev) usb2_proc_free(&bus->explore_proc); + /* Get rid of control transfer process */ + + usb2_proc_free(&bus->control_xfer_proc); + return (0); } @@ -412,6 +416,10 @@ usb2_attach_sub(device_t dev, struct usb &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); Modified: head/sys/dev/usb/usb_bus.h ============================================================================== --- head/sys/dev/usb/usb_bus.h Wed Apr 22 17:08:07 2009 (r191399) +++ head/sys/dev/usb/usb_bus.h Wed Apr 22 17:08:10 2009 (r191400) @@ -62,7 +62,6 @@ struct usb2_sw_transfer { 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_bus { */ 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]; Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Wed Apr 22 17:08:07 2009 (r191399) +++ head/sys/dev/usb/usb_transfer.c Wed Apr 22 17:08:10 2009 (r191400) @@ -822,7 +822,16 @@ usb2_transfer_setup(struct usb2_device * 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