From owner-freebsd-arch@FreeBSD.ORG Tue Oct 7 04:04:36 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F33216A4B3; Tue, 7 Oct 2003 04:04:36 -0700 (PDT) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9D18B43FDF; Tue, 7 Oct 2003 04:04:30 -0700 (PDT) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100])h97B4MS09078; Tue, 7 Oct 2003 13:04:22 +0200 (MEST) Date: Tue, 7 Oct 2003 13:04:22 +0200 (CEST) From: Harti Brandt To: Jeff Roberson In-Reply-To: <20031007063207.V99666-100000@mail.chesapeake.net> Message-ID: <20031007125450.V63760@beagle.fokus.fraunhofer.de> References: <20031007063207.V99666-100000@mail.chesapeake.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: arch@freebsd.org cc: Poul-Henning Kamp cc: Garrett Wollman Subject: Re: Alignment of disk-I/O from userland. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2003 11:04:36 -0000 On Tue, 7 Oct 2003, Jeff Roberson wrote: JR>On Tue, 7 Oct 2003, Harti Brandt wrote: JR> JR>> On Mon, 6 Oct 2003, Scott Long wrote: JR>> JR>> SL>buffers and prepare them for transfer to/from hardware. It already JR>> SL>understands the concept of alignment, though it only applies it to JR>> SL>buffers that it allocates, not buffers that are handed to it. Fixing JR>> JR>> This seems to be not true. The alignment parameter for the busdma tag is JR>> more or less ignored in all backends. With the old malloc code you could JR>> simply make sure that the buffer you request is at least the size of JR>> alignment you need. With UMA this doesn't work anymore. I bumped into this JR>> problem while writing several ATM drivers which need alignment of 16 or 32 JR>> byte. At the moment the driver does this alignment itself by allocating a JR>> large enough dmamem buffer and fiddling with the pointers. JR> JR>I don't believe that this is the case with UMA. Too many things depended JR>on this behavior and so I left it in. Well, when UMA went in I suddenly got panics (because I checked the alignment via KASSERT() so I added the address twiddeling code. This was some time ago, but I remember that a buffer was aligned to half of its size. That was when UMA was new, maybe that this was a problem only a short time - anyway I did not remove that code just to be on the safe side. In any case it should make sense to document in malloc(9) that one either can or cannot rely on this feature. Anyway, even with the guarantee that UMA aligns to at least the size of the buffer. bus_dmamem_alloc does not allocate a 256 byte buffer to a 1k boundary even if I specify the 1k alignment in the dma tag. harti -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org