From owner-freebsd-current@FreeBSD.ORG Thu Sep 11 09:05:03 2008 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 2F87B106564A; Thu, 11 Sep 2008 09:05:03 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id C12638FC0C; Thu, 11 Sep 2008 09:05:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1Kdi6n-0006Qr-0d; Thu, 11 Sep 2008 12:05:01 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8B94oF6020270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 11 Sep 2008 12:04:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m8B94ow1053002; Thu, 11 Sep 2008 12:04:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id m8B94oHj053001; Thu, 11 Sep 2008 12:04:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 11 Sep 2008 12:04:49 +0300 From: Kostik Belousov To: vehemens Message-ID: <20080911090449.GV39652@deviant.kiev.zoral.com.ua> References: <200809080202.00664.vehemens@verizon.net> <200809080950.55528.vehemens@verizon.net> <200809102307.31209.vehemens@verizon.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KJvkvZqQCzHgjKcr" Content-Disposition: inline In-Reply-To: <200809102307.31209.vehemens@verizon.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1Kdi6n-0006Qr-0d 5e6c9e80b1df4e6076b7281f4c1bf120 X-Terabit: YES Cc: freebsd-current@freebsd.org, Robert Watson Subject: Re: cdefpriv usage (was: bsd versus linux device drivers) 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: Thu, 11 Sep 2008 09:05:03 -0000 --KJvkvZqQCzHgjKcr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 10, 2008 at 11:07:31PM -0700, vehemens wrote: > On Monday 08 September 2008 09:50:55 am vehemens wrote: > > On Monday 08 September 2008 06:41:53 am Robert Watson wrote: > > > On Mon, 8 Sep 2008, vehemens wrote: > > > > On Monday 08 September 2008 03:04:15 am Kostik Belousov wrote: > > > >> On Mon, Sep 08, 2008 at 02:02:00AM -0700, vehemens wrote: > > > >>> In linux drivers, there is a one to one relationship to an open a= nd a > > > >>> calling argument structure called struct file. It provides a pri= vate > > > >>> data pointer that allows the driver to preserve unique state > > > >>> information across other calls such as read/write/ioctl/mmap/close > > > >>> etc. > > > >>> > > > >>> For bsd drivers, my understanding there is not an equivalent. As= a > > > >>> result it is not possible to preserve different state information= for > > > >>> multiple opens by the same thread of the same device major/minor = #'s. > > > >>> > > > >>> Is this correct, or did i miss something? > > > >> > > > >> There is devfs_{get,set}_cdevpriv() KPI. Still no manpage, I shall= fix > > > >> this ASAP. > > > > > > > > Just started looking at the firewire driver which has clone. It lo= oks > > > > like it hooks into the event handler. > > > > > > > > Don't quite understand it all yet, so I'm going to look forward to = that > > > > man page. > > > > > > Many device drivers continue to use the old clone interface, but are > > > gradually being converted over. You can look at the definitions and = list > > > of converted drivers here: > > > > > > http://fxr.watson.org/fxr/ident?im=3Dbigexcerpts;i=3Ddevfs_set_cde= vpriv > > > > > > Looking at some of the converted drivers, I find myself a bit worried= by > > > the extra error handling: in what situations do we expect that bpfioc= tl() > > > might be called without its cdev-private data? > > > > Got it now. Looks like the converted drivers are only in current, but = the > > KPI is in at least 7.x as well. >=20 > My first impression based on the modified drivers, was that I only needed= to=20 > add a get to open, and set's to ioctl, mmap, read, write, close etc. Als= o=20 > that the data release would occur after the close call via the function= =20 > provided to get. I do not know whether this is an slip of keyboard, but most typically, you need set in open, and get in the read/write/mmap. > Don't have a problem with set, but some or all of the get's fail. I see= =20 > lot's of error=3D2 in ioctl, and error=3D9 in mmap, Going to instrument = the code=20 > next. Any suggestions would be helpful. >=20 > On a side note, I had to first upgrade my 7.x system and was wondering if= =20 > there was a FreeBSD_version number for this feature? I do not remember, and in fact I do not see a reason for bumping version for this feature. In-tree drivers do not need the check, since they are in _the_ tree. Moreover, the cdevpriv does not change existing KPI, it only adds a bunch of functions. Increasing version for each KPI addition is rather pointless, IMHO. Also, see man(9) update at http://people.freebsd.org/~kib/misc/man9.1.patch that, among other items, contains start of the cdevpriv documentation. --KJvkvZqQCzHgjKcr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjI3zEACgkQC3+MBN1Mb4jL8QCfQn7VKYvvmQr8V9EVODyX4E19 lxYAoNLFnwyC1DOTE9b2QWwS7sVIY3Hk =4oHt -----END PGP SIGNATURE----- --KJvkvZqQCzHgjKcr--