Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2010 21:44:26 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r210139 - projects/ofed/head/sys/ofed/include/linux
Message-ID:  <201007152144.o6FLiQ3P009711@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Thu Jul 15 21:44:26 2010
New Revision: 210139
URL: http://svn.freebsd.org/changeset/base/210139

Log:
   - Add a dma pool implementation which simply uses uma.  This is not fully
     compatible with the linux implementation but satisfies the needs of
     existing consumers.  Any further requirements can be met by using
     contigmalloc as the backing for the zone.
  
  Sponsored by:	Isilon Systems, iX Systems, and Panasas.

Modified:
  projects/ofed/head/sys/ofed/include/linux/dmapool.h

Modified: projects/ofed/head/sys/ofed/include/linux/dmapool.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/dmapool.h	Thu Jul 15 20:24:37 2010	(r210138)
+++ projects/ofed/head/sys/ofed/include/linux/dmapool.h	Thu Jul 15 21:44:26 2010	(r210139)
@@ -29,15 +29,57 @@
 #ifndef _LINUX_DMAPOOL_H_
 #define	_LINUX_DMAPOOL_H_
 
+#include <linux/types.h>
 #include <linux/io.h>
 #include <linux/scatterlist.h>
 #include <linux/device.h>
+#include <linux/slab.h>
+
+struct dma_pool {
+	uma_zone_t	pool_zone;
+};
+
+static inline struct dma_pool *
+dma_pool_create(char *name, struct linux_device *dev, size_t size,
+    size_t align, size_t boundary)
+{
+	struct dma_pool *pool;
+
+	pool = kmalloc(sizeof(*pool), GFP_KERNEL);
+	align--;
+	/*
+	 * XXX Eventually this could use a seperate allocf to honor boundary
+	 * and physical address requirements of the device.
+	 */
+	pool->pool_zone = uma_zcreate(name, size, NULL, NULL, NULL, NULL,
+	    align, UMA_ZONE_OFFPAGE);
+
+	return (pool);
+}
+
+static inline void
+dma_pool_destroy(struct dma_pool *pool)
+{
+	uma_zdestroy(pool->pool_zone);
+	kfree(pool);
+}
+
+static inline void *
+dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle)
+{
+	void *vaddr;
+
+	vaddr = uma_zalloc(pool->pool_zone, mem_flags);
+	if (vaddr)
+		*handle = vtophys(vaddr);
+	return (vaddr);
+}
+
+static inline void
+dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr)
+{
+	uma_zfree(pool->pool_zone, vaddr);
+}
 
-struct dma_pool *dma_pool_create(const char *name, struct linux_device *dev,
-	    size_t size, size_t align, size_t allocation);
-void	dma_pool_destroy(struct dma_pool *pool);
-void	*dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
-	    dma_addr_t *handle);
-void	dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
 
 #endif /* _LINUX_DMAPOOL_H_ */



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