From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 17:33:35 2006 Return-Path: X-Original-To: freebsd-drivers@FreeBSD.org Delivered-To: freebsd-drivers@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F017416A4DD; Tue, 5 Sep 2006 17:33:35 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9822E43D45; Tue, 5 Sep 2006 17:33:35 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (ykq2v6x1kjxn0o2l@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k85HXZku045282; Tue, 5 Sep 2006 10:33:35 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k85HXZJ7045281; Tue, 5 Sep 2006 10:33:35 -0700 (PDT) (envelope-from jmg) Date: Tue, 5 Sep 2006 10:33:35 -0700 From: John-Mark Gurney To: freebsd-arch@FreeBSD.org, freebsd-drivers@FreeBSD.org, freebsd-current@FreeBSD.org Message-ID: <20060905173334.GH9421@funkthat.com> Mail-Followup-To: freebsd-arch@FreeBSD.org, freebsd-drivers@FreeBSD.org, freebsd-current@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: Subject: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 17:33:36 -0000 Over the weekend, I integrated some infastructure from the sun4v port. It is the ability to have different bus_dma_tag_t's for different parts of the device tree. This is necessary on systems like sparc64 and sun4v that have different IOMMU's for different pci domains. sparc64 glossed over this difference by programming both IOMMU's exactly the same, but I decided to fix this for sun4v. This means that for each call to bus_dma_tag_create, instead of passing a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that as the parent tag. I committed some example code to various drivers, such as ahc, ata, em, and ohci. There is currently no functional change to the tree w/ this change. The driver changes will need to be done by hand as the device_t of the current device is not always obviously available at the time bus_dma_tag_create is called. Patches are welcome for the remaining unconverted drivers. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 17:44:56 2006 Return-Path: X-Original-To: freebsd-drivers@FreeBSD.org Delivered-To: freebsd-drivers@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4685D16A4E0; Tue, 5 Sep 2006 17:44:56 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE34043D5F; Tue, 5 Sep 2006 17:44:51 +0000 (GMT) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id 57B8B170C5; Tue, 5 Sep 2006 17:44:49 +0000 (UTC) To: John-Mark Gurney From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 05 Sep 2006 10:33:35 MST." <20060905173334.GH9421@funkthat.com> Date: Tue, 05 Sep 2006 17:44:48 +0000 Message-ID: <14026.1157478288@critter.freebsd.dk> Cc: freebsd-current@FreeBSD.org, freebsd-drivers@FreeBSD.org, freebsd-arch@FreeBSD.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 17:44:56 -0000 In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: >This means that for each call to bus_dma_tag_create, instead of passing >a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that >as the parent tag. I committed some example code to various drivers, >such as ahc, ata, em, and ohci. If there are never any exeptions to this requirement, why not pass "yourdev" and have the magic hidden, rather than add 17 ritual characters to the API ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 17:55:24 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E01316A4E0; Tue, 5 Sep 2006 17:55:24 +0000 (UTC) (envelope-from mjacob@freebsd.org) Received: from ns1.feral.com (ns1.feral.com [192.67.166.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8932843D68; Tue, 5 Sep 2006 17:55:22 +0000 (GMT) (envelope-from mjacob@freebsd.org) Received: from ns1.feral.com (localhost [127.0.0.1]) by ns1.feral.com (8.13.6/8.13.6) with ESMTP id k85HtLjD005109; Tue, 5 Sep 2006 10:55:21 -0700 (PDT) (envelope-from mjacob@freebsd.org) Received: from localhost (mjacob@localhost) by ns1.feral.com (8.13.6/8.13.6/Submit) with ESMTP id k85HtLai005106; Tue, 5 Sep 2006 10:55:21 -0700 (PDT) (envelope-from mjacob@freebsd.org) X-Authentication-Warning: ns1.feral.com: mjacob owned process doing -bs Date: Tue, 5 Sep 2006 10:55:21 -0700 (PDT) From: mjacob@freebsd.org X-X-Sender: mjacob@ns1.feral.com To: John-Mark Gurney In-Reply-To: <20060905173334.GH9421@funkthat.com> Message-ID: <20060905105320.S4962@ns1.feral.com> References: <20060905173334.GH9421@funkthat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthew Jacob List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 17:55:24 -0000 A __FreeBSD_version value of 700020 can be used in your drivers to distinguish the OS source that has the requirement and that which doesn't. On Tue, 5 Sep 2006, John-Mark Gurney wrote: > Over the weekend, I integrated some infastructure from the sun4v port. > It is the ability to have different bus_dma_tag_t's for different > parts of the device tree. This is necessary on systems like sparc64 > and sun4v that have different IOMMU's for different pci domains. > sparc64 glossed over this difference by programming both IOMMU's > exactly the same, but I decided to fix this for sun4v. > > This means that for each call to bus_dma_tag_create, instead of passing > a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that > as the parent tag. I committed some example code to various drivers, > such as ahc, ata, em, and ohci. > > There is currently no functional change to the tree w/ this change. > > The driver changes will need to be done by hand as the device_t of the > current device is not always obviously available at the time > bus_dma_tag_create is called. > > Patches are welcome for the remaining unconverted drivers. > > -- > John-Mark Gurney Voice: +1 415 225 5579 > > "All that I will do, has been done, All that I have, has not." > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" > From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 18:31:37 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00A9E16A4E8; Tue, 5 Sep 2006 18:31:37 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 096C543D46; Tue, 5 Sep 2006 18:31:35 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [10.10.3.185] ([165.236.175.187]) (authenticated bits=0) by pooker.samsco.org (8.13.4/8.13.4) with ESMTP id k85IVRgf089221; Tue, 5 Sep 2006 12:31:33 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <44FDC278.3050902@samsco.org> Date: Tue, 05 Sep 2006 12:31:20 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060206 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Poul-Henning Kamp References: <14026.1157478288@critter.freebsd.dk> In-Reply-To: <14026.1157478288@critter.freebsd.dk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.5 required=3.8 tests=SPF_SOFTFAIL autolearn=no version=3.1.1 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on pooker.samsco.org Cc: freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 18:31:37 -0000 Poul-Henning Kamp wrote: > In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: > > >>This means that for each call to bus_dma_tag_create, instead of passing >>a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that >>as the parent tag. I committed some example code to various drivers, >>such as ahc, ata, em, and ohci. > > > If there are never any exeptions to this requirement, why not > pass "yourdev" and have the magic hidden, rather than add 17 > ritual characters to the API ? > Drivers can have their own multi-level tag heirarchy. You'd have to create a new bus_dma_tag_create() variant that expected a device_t instead of a bus_dma_tag_t. This might be a good idea. Scott From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 19:09:14 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 94E5216A501; Tue, 5 Sep 2006 19:09:14 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 542E943D53; Tue, 5 Sep 2006 19:04:27 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.4/8.13.4) with ESMTP id k85J2TUU014641; Tue, 5 Sep 2006 13:02:30 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 05 Sep 2006 13:02:47 -0600 (MDT) Message-Id: <20060905.130247.-267228160.imp@bsdimp.com> To: phk@phk.freebsd.dk From: "M. Warner Losh" In-Reply-To: <14026.1157478288@critter.freebsd.dk> References: <20060905173334.GH9421@funkthat.com> <14026.1157478288@critter.freebsd.dk> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Tue, 05 Sep 2006 13:02:31 -0600 (MDT) Cc: freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 19:09:14 -0000 In message: <14026.1157478288@critter.freebsd.dk> "Poul-Henning Kamp" writes: : In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: : : >This means that for each call to bus_dma_tag_create, instead of passing : >a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that : >as the parent tag. I committed some example code to various drivers, : >such as ahc, ata, em, and ohci. : : If there are never any exeptions to this requirement, why not : pass "yourdev" and have the magic hidden, rather than add 17 : ritual characters to the API ? As Scott pointed out, it won't always be NULL. I like his idea of having a variant that takes a device_t... Warner From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 19:11:43 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 062EC16A4DA; Tue, 5 Sep 2006 19:11:43 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id F211943D45; Tue, 5 Sep 2006 19:11:41 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: gvlK0tOCzrqh9CPROFOFPw== X-Cloudmark-Score: 0.000000 [] Received: from [193.216.91.134] (HELO [10.0.0.249]) by mailfe03.swip.net (CommuniGate Pro SMTP 5.0.8) with ESMTP id 279172218; Tue, 05 Sep 2006 21:11:37 +0200 From: Hans Petter Selasky To: freebsd-arch@freebsd.org Date: Tue, 5 Sep 2006 21:11:50 +0200 User-Agent: KMail/1.7 References: <14026.1157478288@critter.freebsd.dk> <44FDC278.3050902@samsco.org> In-Reply-To: <44FDC278.3050902@samsco.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200609052111.52304.hselasky@c2i.net> Cc: Scott Long , freebsd-current@freebsd.org, Poul-Henning Kamp , freebsd-drivers@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 19:11:43 -0000 On Tuesday 05 September 2006 20:31, Scott Long wrote: > Poul-Henning Kamp wrote: > > In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: > >>This means that for each call to bus_dma_tag_create, instead of passing > >>a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that > >>as the parent tag. I committed some example code to various drivers, > >>such as ahc, ata, em, and ohci. > > > > If there are never any exeptions to this requirement, why not > > pass "yourdev" and have the magic hidden, rather than add 17 > > ritual characters to the API ? > > Drivers can have their own multi-level tag heirarchy. You'd have to > create a new bus_dma_tag_create() variant that expected a device_t > instead of a bus_dma_tag_t. This might be a good idea. > I think it is easier to share code with NetBSD if we use "bus_get_dma_tag(yourdev)". For example I use the following prototype on NetBSD and FreeBSD: void * usbd_mem_alloc(bus_dma_tag_t parent, u_int32_t size, u_int8_t align_power); --HPS From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 19:28:00 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B516C16A4DD; Tue, 5 Sep 2006 19:28:00 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3585C43D49; Tue, 5 Sep 2006 19:28:00 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (0mnew3dcgucvscvk@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k85JRv61047416; Tue, 5 Sep 2006 12:27:57 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k85JRt1Z047415; Tue, 5 Sep 2006 12:27:55 -0700 (PDT) (envelope-from jmg) Date: Tue, 5 Sep 2006 12:27:55 -0700 From: John-Mark Gurney To: "M. Warner Losh" Message-ID: <20060905192755.GI9421@funkthat.com> Mail-Followup-To: "M. Warner Losh" , phk@phk.freebsd.dk, freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org References: <20060905173334.GH9421@funkthat.com> <14026.1157478288@critter.freebsd.dk> <20060905.130247.-267228160.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060905.130247.-267228160.imp@bsdimp.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: phk@phk.freebsd.dk, freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 19:28:00 -0000 Warner Losh wrote this message on Tue, Sep 05, 2006 at 13:02 -0600: > In message: <14026.1157478288@critter.freebsd.dk> > "Poul-Henning Kamp" writes: > : In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: > : > : >This means that for each call to bus_dma_tag_create, instead of passing > : >a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that > : >as the parent tag. I committed some example code to various drivers, > : >such as ahc, ata, em, and ohci. > : > : If there are never any exeptions to this requirement, why not > : pass "yourdev" and have the magic hidden, rather than add 17 > : ritual characters to the API ? > > As Scott pointed out, it won't always be NULL. I like his idea of > having a variant that takes a device_t... I thought of something similar. I like the idea of not having to call bus_get_dma_tag every time, but at the same time, I didn't like adding yet another function that does almost the same thing... If more arguments were effected, I'd be less inclined to argue, but all we'd be doing would change: bus_dma_tag_create(bus_get_dma_tag(dev), to: bus_dma_tag_dev_create(dev, Which though less typing, does create another entry point for creating a bus_dma_tag_t.... I'm split on which is the better way, so if someone wants to change it to the second, I have no objections.... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 22:04:00 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6121C16A4E7; Tue, 5 Sep 2006 22:04:00 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7084943D53; Tue, 5 Sep 2006 22:03:54 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (6nkq3cr4f6xiziw1@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k85M3jR5050256; Tue, 5 Sep 2006 15:03:45 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k85M3ido050254; Tue, 5 Sep 2006 15:03:44 -0700 (PDT) (envelope-from jmg) Date: Tue, 5 Sep 2006 15:03:44 -0700 From: John-Mark Gurney To: Hans Petter Selasky Message-ID: <20060905220344.GL9421@funkthat.com> Mail-Followup-To: Hans Petter Selasky , freebsd-arch@freebsd.org, freebsd-current@freebsd.org, Poul-Henning Kamp , freebsd-drivers@freebsd.org References: <14026.1157478288@critter.freebsd.dk> <44FDC278.3050902@samsco.org> <200609052111.52304.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200609052111.52304.hselasky@c2i.net> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: Poul-Henning Kamp , freebsd-current@freebsd.org, freebsd-drivers@freebsd.org, freebsd-arch@freebsd.org Subject: Re: bus_get_dma_tag now necessary for drivers using bus_dma X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 22:04:00 -0000 Hans Petter Selasky wrote this message on Tue, Sep 05, 2006 at 21:11 +0200: > On Tuesday 05 September 2006 20:31, Scott Long wrote: > > Poul-Henning Kamp wrote: > > > In message <20060905173334.GH9421@funkthat.com>, John-Mark Gurney writes: > > >>This means that for each call to bus_dma_tag_create, instead of passing > > >>a NULL pointer, you should call bus_get_dma_tag(yourdev) and use that > > >>as the parent tag. I committed some example code to various drivers, > > >>such as ahc, ata, em, and ohci. > > > > > > If there are never any exeptions to this requirement, why not > > > pass "yourdev" and have the magic hidden, rather than add 17 > > > ritual characters to the API ? > > > > Drivers can have their own multi-level tag heirarchy. You'd have to > > create a new bus_dma_tag_create() variant that expected a device_t > > instead of a bus_dma_tag_t. This might be a good idea. > > > > I think it is easier to share code with NetBSD if we use > "bus_get_dma_tag(yourdev)". > > For example I use the following prototype on NetBSD and FreeBSD: > > void * > usbd_mem_alloc(bus_dma_tag_t parent, u_int32_t size, > u_int8_t align_power); It won't prevent you from first creating a bus_dma_tag_t w/ no restrictions but the dev, and passing that to this function.. Once you have inherited the tag from the device, all children tag's will have the correct tag... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 23:44:55 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5FFE816A4E0 for ; Tue, 5 Sep 2006 23:44:55 +0000 (UTC) (envelope-from kristis.makris@asu.edu) Received: from mail.mkgnu.net (net.mkgnu.net [67.40.69.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD9E743D5D for ; Tue, 5 Sep 2006 23:44:54 +0000 (GMT) (envelope-from kristis.makris@asu.edu) Received: from syd.mkgnu.net ([::ffff:192.168.0.101]) by morpheus with esmtp; Tue, 05 Sep 2006 17:03:02 -0700 id 00015398.44FE1036.0000501B From: Kristis Makris To: freebsd-drivers@freebsd.org Date: Tue, 05 Sep 2006 16:46:45 -0700 Message-Id: <1157500005.3414.92.camel@syd.mkgnu.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Evolution 2.0.4 Subject: ioctl: uiomove, copyin, copyout X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 23:44:55 -0000 Hello, I'm trying to port a driver from Linux 2.2-2.6 to FreeBSD. I have two problems: 1) Finding the equivalent of the Linux copy_to_user and copy_from_user routines. Are those copyin, and copyout ? 2) Getting the ioctl operation to work. When issuing an ioctl from userspace I get: # dynamos_control -o 9 ioctl error for command 9: Inappropriate ioctl for device errno is 25 it's an ENOTTY ... while in the driver I have: static d_read_t dynreplace_file_operations_read; static d_ioctl_t dynreplace_file_operations_ioctl; static struct cdevsw dynreplace_cdevsw = { .d_version = D_VERSION, .d_open = dynreplace_file_operations_open, .d_close = dynreplace_file_operations_release, .d_read = dynreplace_file_operations_read, .d_ioctl = dynreplace_file_operations_ioctl, .d_name = MODULE_NAME_STR, }; int dynreplace_file_operations_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { print( "ioctl - MAIN\n"); return 0; } ... the _read operation works as expected, but I don't even see the print statement from _ioctl. The ioctl(2) manpage reads: [ENOTTY] The d argument is not associated with a character special device. This can't be true since the read operation works, and: # ls -lrta /dev/dynamos crwx------ 1 root wheel 0, 95 Sep 2 16:31 /dev/dynamos and... [ENOTTY] The specified request does not apply to the kind of object that the descriptor d references. Is this last part somehow enforced by the kernel ? I know I have an uncommon build process, since the driver is built for multiple OSs, but if I can get the read operation to work why would ioctl be so difficult ? Am I missing something ? From owner-freebsd-drivers@FreeBSD.ORG Wed Sep 6 00:01:17 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6604A16A4DE for ; Wed, 6 Sep 2006 00:01:17 +0000 (UTC) (envelope-from lydianconcepts@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.234]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE25B43D45 for ; Wed, 6 Sep 2006 00:01:16 +0000 (GMT) (envelope-from lydianconcepts@gmail.com) Received: by wr-out-0506.google.com with SMTP id 68so719274wri for ; Tue, 05 Sep 2006 17:01:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BIJpWA3g/JzvGF719WH7AGiimOK1yFvtWVQ1YIg0JauIaAdXAZpoxqdePYf+0Fzgs22ji2nGaGSt1xJRB67us9BQWcmBpI1eKD7K4+CjgQ/76NIJv38XMR/+3dym6jxRIrZjvVJUvnTOdM0iZr1yBWHWOiZfbOBYCsD0/XVK7/I= Received: by 10.90.120.13 with SMTP id s13mr2022368agc; Tue, 05 Sep 2006 17:01:16 -0700 (PDT) Received: by 10.90.70.14 with HTTP; Tue, 5 Sep 2006 17:01:16 -0700 (PDT) Message-ID: <7579f7fb0609051701u6a863428m7ec8d488ac7a8047@mail.gmail.com> Date: Tue, 5 Sep 2006 17:01:16 -0700 From: "Matthew Jacob" To: "Kristis Makris" In-Reply-To: <1157500005.3414.92.camel@syd.mkgnu.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1157500005.3414.92.camel@syd.mkgnu.net> Cc: freebsd-drivers@freebsd.org Subject: Re: ioctl: uiomove, copyin, copyout X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Sep 2006 00:01:17 -0000 > > 1) Finding the equivalent of the Linux copy_to_user and copy_from_user > routines. Are those copyin, and copyout ? Yes. > > > 2) Getting the ioctl operation to work. When issuing an ioctl from > userspace I get: > My guess is that your ioctl codes are being interpred. Check the format of your ioctl code to make sure that it follows BSD rules for getting passed to your driver w/o interpretation. Linux IIRC follows SYSV ioctl semantics, which means that the ioctl is never interpreted by the kernel above the driver. BSD ioctls semantics looks at the type nibble to decide whether the ioctl parameters can be copied directly to the kernel and presented to driver as a pointer you can just de-reference rather than a pointer you have to perform copyin on. Check sys/ioccom.h. > # dynamos_control -o 9 > ioctl error for command 9: Inappropriate ioctl for device > errno is 25 > it's an ENOTTY > > ... while in the driver I have: > > static d_read_t dynreplace_file_operations_read; > static d_ioctl_t dynreplace_file_operations_ioctl; > > static struct cdevsw dynreplace_cdevsw = { > .d_version = D_VERSION, > .d_open = dynreplace_file_operations_open, > .d_close = dynreplace_file_operations_release, > .d_read = dynreplace_file_operations_read, > .d_ioctl = dynreplace_file_operations_ioctl, > .d_name = MODULE_NAME_STR, > }; > > > int dynreplace_file_operations_ioctl(struct cdev *dev, u_long cmd, > caddr_t data, int flags, struct thread *td) > { > print( "ioctl - MAIN\n"); > return 0; > } > > ... the _read operation works as expected, but I don't even see the > print statement from _ioctl. > > > The ioctl(2) manpage reads: > > [ENOTTY] The d argument is not associated with a > character special device. > > This can't be true since the read operation works, and: > > # ls -lrta /dev/dynamos > crwx------ 1 root wheel 0, 95 Sep 2 16:31 /dev/dynamos > > and... > > [ENOTTY] The specified request does not apply to the kind > of object that the descriptor d references. > > Is this last part somehow enforced by the kernel ? > > I know I have an uncommon build process, since the driver is built for > multiple OSs, but if I can get the read operation to work why would > ioctl be so difficult ? > > Am I missing something ? > > > _______________________________________________ > freebsd-drivers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-drivers > To unsubscribe, send any mail to "freebsd-drivers-unsubscribe@freebsd.org" > From owner-freebsd-drivers@FreeBSD.ORG Wed Sep 6 02:07:15 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EEF9016A4DE for ; Wed, 6 Sep 2006 02:07:15 +0000 (UTC) (envelope-from kristis.makris@asu.edu) Received: from mail.mkgnu.net (net.mkgnu.net [67.40.69.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9319E43D4C for ; Wed, 6 Sep 2006 02:07:15 +0000 (GMT) (envelope-from kristis.makris@asu.edu) Received: from syd.mkgnu.net ([::ffff:192.168.0.101]) by morpheus with esmtp; Tue, 05 Sep 2006 19:25:24 -0700 id 0000C56D.44FE3194.00005203 From: Kristis Makris To: Matthew Jacob In-Reply-To: <7579f7fb0609051701u6a863428m7ec8d488ac7a8047@mail.gmail.com> References: <1157500005.3414.92.camel@syd.mkgnu.net> <7579f7fb0609051701u6a863428m7ec8d488ac7a8047@mail.gmail.com> Date: Tue, 05 Sep 2006 19:09:11 -0700 Message-Id: <1157508551.3275.101.camel@syd.mkgnu.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Evolution 2.0.4 Cc: freebsd-drivers@freebsd.org Subject: Re: ioctl: uiomove, copyin, copyout X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Sep 2006 02:07:16 -0000 > Check the format of your ioctl code to make sure that it follows BSD > rules for getting passed to your driver w/o interpretation. Linux IIRC > follows SYSV ioctl semantics, which means that the ioctl is never > interpreted by the kernel above the driver. BSD ioctls semantics looks > at the type nibble to decide whether the ioctl parameters can be > copied directly to the kernel and presented to driver as a pointer you > can just de-reference rather than a pointer you have to perform copyin > on. > > Check sys/ioccom.h. That was it. I learned something new today. Thanks a lot.