From owner-freebsd-scsi Sun Dec 8 22:12:17 2002 Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BF3337B401; Sun, 8 Dec 2002 22:12:16 -0800 (PST) Received: from aslan.scsiguy.com (aslan.scsiguy.com [63.229.232.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5FA4A43E4A; Sun, 8 Dec 2002 22:12:13 -0800 (PST) (envelope-from gibbs@scsiguy.com) Received: from aslan.scsiguy.com (aslan.scsiguy.com [63.229.232.106]) by aslan.scsiguy.com (8.12.6/8.12.5) with ESMTP id gB96BFMj039525; Sun, 8 Dec 2002 23:11:15 -0700 (MST) (envelope-from gibbs@scsiguy.com) Date: Sun, 08 Dec 2002 23:11:15 -0700 From: "Justin T. Gibbs" To: "Kenneth D. Merry" , Nate Lawson Cc: Yar Tikhiy , freebsd-scsi@FreeBSD.ORG Subject: Re: {da,sa,...}open bug? Message-ID: <2179138112.1039414275@aslan.scsiguy.com> In-Reply-To: <20021206123401.A23249@panzer.kdm.org> References: <20021206145942.I80257@comp.chem.msu.su> <20021206123401.A23249@panzer.kdm.org> X-Mailer: Mulberry/3.0.0a5 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > Yar asked me to review his previous patch to a number of peripheral > drivers that modifed the acquire/unlock/etc. order. I've asked Justin to > take a look at it as well (thus the reason I haven't completed the review > yet), ... The patches look okay to me. Although the lock API was never fully implemented, it was indended to guarantee exclusive access to an underlying device while the lock is held. This is exactly what you might want during a device driver probe where multiple device drivers can attach simultaneously to the same device (e.g. pass and da both attach to direct access devices). If we were to follow the indended use of the API, the probe code would probably look like this: /* * Ensure periph is not de-allocated * out from under us. */ cam_periph_acquire(); /* * Gain exclusive access to the periph. */ cam_periph_lock(); /* * Perform probe. */ /* * Play nice with others. */ cam_periph_unlock(); return (0); with the appropriate release's and unlocks in the error cases of course. The lock and unlock calls would also be used in open during any device validation checks that require exclusive access. -- Justin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message