>>> - There's no analogue to pci_pool, and there's nothing like >>> "kmalloc" (likely built from N dma-coherent pools). >> >> I didn't want to build another memory pool re-implementation. The >> mempool API seems to me to be flexible enough for this, is there some >> reason it won't work? > > I didn't notice any way it would track, and return, DMA addresses. > It's much like a kmem_cache in that way. Here's a patch (against 2.5.53) that does it with current allocators: - adds new dma_pool calls, implemented by inlines using "kmem_cache_t *" (wrapped) or "struct pci_pool *" depending on the arch/config. struct dma_pool *dma_pool_create(char *, struct device *, size_t) void dma_pool_destroy (struct dma_pool *pool) void *dma_pool_alloc(struct dma_pool *, int mem_flags, dma_addr_t *) void dma_pool_free(struct dma_pool *, void *, dma_addr_t) - new kmalloc/kfree style calls, likewise turned by inlines into kmalloc or code that can use dma_pool (but can't yet, needs a device dma state hook), falling back to dma_alloc_coherent for page allocation otherwise. void *dma_alloc(struct device *, size_t, dma_addr_t *, int mem_flags) void dma_free(struct device *, size_t, void *, dma_addr_t) - pci_pool is now arch-specific like the rest of the pci dma calls. along with a DMA-API.txt update, this makes 2/3 of this patch. so x86 uses dma_pool instead, through An immediate effect of this patch is that on x86, both USB and Firewire will do their pci_pool allocations through kmem_cache_t, which is a smarter (and faster) allocator. (So would other drivers using pci_pool calls.) Comments? - Dave