[openib-general] [PATCH 2/2] port the fmr pool to use the max_map_per_fmr device attribute

Or Gerlitz ogerlitz at voltaire.com
Tue May 23 02:12:38 PDT 2006


This patch ports the generic fmr pool to query the ib device and use the
device attribute as for the max number of fmr remaps. If the device does
not suport the attribute, the code reverts to use the IB_FMR_MAX_REMAPS 
(32) default.

Or.

Signed-off-by: Or Gerlitz <ogerlitz at voltaire.com>

Index: core/fmr_pool.c
===================================================================
--- core/fmr_pool.c	(revision 7031)
+++ core/fmr_pool.c	(working copy)
@@ -54,7 +54,7 @@ enum {
 /*
  * If an FMR is not in use, then the list member will point to either
  * its pool's free_list (if the FMR can be mapped again; that is,
- * remap_count < IB_FMR_MAX_REMAPS) or its pool's dirty_list (if the
+ * remap_count < device_attr.max_map_per_fmr) or its pool's dirty_list (if the
  * FMR needs to be unmapped before being remapped).  In either of
  * these cases it is a bug if the ref_count is not 0.  In other words,
  * if ref_count is > 0, then the list member must not be linked into
@@ -84,6 +84,7 @@ struct ib_fmr_pool {
 
 	int                       pool_size;
 	int                       max_pages;
+	int			  max_remaps;
 	int                       dirty_watermark;
 	int                       dirty_len;
 	struct list_head          free_list;
@@ -214,6 +215,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 {
 	struct ib_device   *device;
 	struct ib_fmr_pool *pool;
+	struct ib_device_attr device_attr;
 	int i;
 	int ret;
 
@@ -228,6 +230,15 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 		return ERR_PTR(-ENOSYS);
 	}
 
+	ret = ib_query_device(device, &device_attr); 
+	if (ret) {
+		printk(KERN_WARNING "couldn't query device");
+		return ERR_PTR(ret);
+	}
+	/* use the default max remaps for drivers not setting the attribute */
+	if (!device_attr.max_map_per_fmr)
+		device_attr.max_map_per_fmr = IB_FMR_MAX_REMAPS;
+
 	pool = kmalloc(sizeof *pool, GFP_KERNEL);
 	if (!pool) {
 		printk(KERN_WARNING "couldn't allocate pool struct");
@@ -258,6 +269,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 
 	pool->pool_size       = 0;
 	pool->max_pages       = params->max_pages_per_fmr;
+	pool->max_remaps      = device_attr.max_map_per_fmr;
 	pool->dirty_watermark = params->dirty_watermark;
 	pool->dirty_len       = 0;
 	spin_lock_init(&pool->pool_lock);
@@ -279,7 +291,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(s
 		struct ib_pool_fmr *fmr;
 		struct ib_fmr_attr attr = {
 			.max_pages  = params->max_pages_per_fmr,
-			.max_maps   = IB_FMR_MAX_REMAPS,
+			.max_maps   = device_attr.max_map_per_fmr,
 			.page_shift = params->page_shift
 		};
 
@@ -489,7 +501,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr
 
 	--fmr->ref_count;
 	if (!fmr->ref_count) {
-		if (fmr->remap_count < IB_FMR_MAX_REMAPS) {
+		if (fmr->remap_count < pool->max_remaps) {
 			list_add_tail(&fmr->list, &pool->free_list);
 		} else {
 			list_add_tail(&fmr->list, &pool->dirty_list);




More information about the general mailing list