From owner-freebsd-current@FreeBSD.ORG Tue Oct 20 21:52:02 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0907106568B; Tue, 20 Oct 2009 21:52:02 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from pele.citylink.co.nz (pele.citylink.co.nz [202.8.44.226]) by mx1.freebsd.org (Postfix) with ESMTP id 7574A8FC18; Tue, 20 Oct 2009 21:52:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pele.citylink.co.nz (Postfix) with ESMTP id 961F8FF40; Wed, 21 Oct 2009 10:36:10 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at citylink.co.nz Received: from pele.citylink.co.nz ([127.0.0.1]) by localhost (pele.citylink.co.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b-9PXIR05qQi; Wed, 21 Oct 2009 10:36:05 +1300 (NZDT) Received: from citylink.fud.org.nz (unknown [202.8.44.45]) by pele.citylink.co.nz (Postfix) with ESMTP; Wed, 21 Oct 2009 10:36:05 +1300 (NZDT) Received: by citylink.fud.org.nz (Postfix, from userid 1001) id A8C4911475; Wed, 21 Oct 2009 10:36:04 +1300 (NZDT) Date: Wed, 21 Oct 2009 10:36:04 +1300 From: Andrew Thompson To: Alexander Motin Message-ID: <20091020213604.GA63951@citylink.fud.org.nz> References: <4ADD7683.7040907@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ADD7683.7040907@FreeBSD.org> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: FreeBSD-Current , Scott Long Subject: Re: CAM problem X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2009 21:52:02 -0000 On Tue, Oct 20, 2009 at 11:36:19AM +0300, Alexander Motin wrote: > Andrew Thompson wrote: > > I have a cam problem that is noticeable with usb devices. It relates to > > the ordering of xpt_release_device() and the CAM_DEV_UNCONFIGURED flag > > when yanking a device that has stalled. This then causes a problem with > > the usb explore thread which will end up waiting on simfree forever, > > blocking any further usb attach/detach on the controller. > > > > As I can see, you are returning CAM_TID_INVALID error here. There is no > special error handling for this error, comparing to CAM_SEL_TIMEOUT. If > you return CAM_SEL_TIMEOUT there, device will be killed immediately and > probably workaround this specific problem. Setting the error to CAM_SEL_TIMEOUT does indeed workaround the problem. I have committed this so at least it can be merged to 8.0. > > scsi_dev_async: set dev dev3 unconfigured > > > > ^^^ dev3 gets the CAM_DEV_UNCONFIGURED flag cleared here > > ... but removing configured status does not call deallocation, as > unreferencing does. > > > xpt_bus_deregister: xpt_release_bus > > xpt_release_bus: ref=4 -> 3 > > xpt_release_device dev4 OK > > xpt_release_target: xpt_release_bus > > xpt_release_bus: ref=3 -> 2 > > xpt_release_path: xpt_release_bus > > xpt_release_bus: ref=2 -> 1 > > umass_cam_detach_sim: > > umass-sim0: waiting... ref = 1 > > > > ^^^ wait on "simfree" forever. > > I think correct solution will be to additionally increment reference > counter before clearing CAM_DEV_UNCONFIGURED and decrement it back after > setting CAM_DEV_UNCONFIGURED back. Check for CAM_DEV_UNCONFIGURED inside > xpt_release_device() then could be removed or turned into assertion. I agree, this looks like the best solution. Andrew