On 12/10/08 09:00, Dana H. Myers wrote: > Garrett D'Amore wrote: >> On 12/10/08 08:18, Andrew Gallatin wrote: >>> Paul Durrant wrote: >>> >>>> Andrew Gallatin wrote: >>>> >>>>> The above suggests that all my allocation requests should fail, >>>>> since all my allocation requests are for 1520 bytes, and that's >>>>> not a multiple of 4095... >>>>> >>>>> >>>> Drew, >>>> >>>> I didn't notice the 'multiple' rule when I started using it; to be >>>> honest I just went off what I found in the source code ;-) (The >>>> relevant bits of code are in the rootnex driver, if I remember >>>> correctly). >>>> >>> >>> Let's hope nobody "fixes" the code to match the man page :) >>> >> >> Be very very careful here. The different platforms have different >> implementations of the rootnex stuff, as I recently discovered on >> 32-bit platforms. (Apparently I discovered a strange failure mode >> when align == 2, but minxfer == 4. It worked on amd64, but caused an >> allocation failure on 32-bit systems. Bumping align up to 4 fixed >> the problem in my driver, although to be fair the problem was >> *probably* a bug in the DDI DMA code for the i386.) >> >> I would avoid depending too much on specific allocation behaviors >> like this, if I had a choice. Better, I think to just allocate one >> or more pages and manage the the division yourself internally. > ... and thus push complication into individual drivers? The desired > functionality is > reasonable, and the DMA API is demonstrably opaque here, since > multiple people > are looking at the man page, the code and empirically trying to get > the API > to do something it seems like it ought to be able to do easily.
The desired functionality is "efficiency of packing" of allocations. There may be good reasons why a specific platform won't pack things in the same way. The behavior of how DMA allocates objects is not documented, other than they will conform to *at least* the constraints specified by the dma_attr. If some specific relationship (such as putting multiple objects in a physical page) is desired or required, then I believe the better approach is for the driver to manage the object allocations within a larger DMA object. Relying on platform-specific behaviors just seems like a bad idea, to me. -- Garrett _______________________________________________ driver-discuss mailing list driver-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/driver-discuss