Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Oct 2003 13:04:22 +0200 (CEST)
From:      Harti Brandt <brandt@fokus.fraunhofer.de>
To:        Jeff Roberson <jroberson@chesapeake.net>
Cc:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Subject:   Re: Alignment of disk-I/O from userland. 
Message-ID:  <20031007125450.V63760@beagle.fokus.fraunhofer.de>
In-Reply-To: <20031007063207.V99666-100000@mail.chesapeake.net>
References:  <20031007063207.V99666-100000@mail.chesapeake.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031007125450.V63760>