diff options
author | Or Gerlitz <ogerlitz@voltaire.com> | 2006-06-17 23:37:37 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-06-17 23:37:37 -0400 |
commit | 6c8c1aa25d213a288df381f431ce5b6a155146ec (patch) | |
tree | 379670131076d3ca0af68f9e91f6f038e86e0e96 /drivers | |
parent | d4cb0784fd1ea99ef3d20526811bd5608146fe60 (diff) |
IB/fmr: Use device's max_map_map_per_fmr attribute in FMR pool.
When creating a FMR pool, query the IB device and use the returned
max_map_map_per_fmr attribute as for the max number of FMR remaps. If
the device does not suport querying this attribute, use the original
IB_FMR_MAX_REMAPS (32) default.
Signed-off-by: Or Gerlitz <ogerlitz@voltaire.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/fmr_pool.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c index 838bf54458d2..615fe9cc6c56 100644 --- a/drivers/infiniband/core/fmr_pool.c +++ b/drivers/infiniband/core/fmr_pool.c | |||
@@ -54,7 +54,7 @@ enum { | |||
54 | /* | 54 | /* |
55 | * If an FMR is not in use, then the list member will point to either | 55 | * If an FMR is not in use, then the list member will point to either |
56 | * its pool's free_list (if the FMR can be mapped again; that is, | 56 | * its pool's free_list (if the FMR can be mapped again; that is, |
57 | * remap_count < IB_FMR_MAX_REMAPS) or its pool's dirty_list (if the | 57 | * remap_count < pool->max_remaps) or its pool's dirty_list (if the |
58 | * FMR needs to be unmapped before being remapped). In either of | 58 | * FMR needs to be unmapped before being remapped). In either of |
59 | * these cases it is a bug if the ref_count is not 0. In other words, | 59 | * these cases it is a bug if the ref_count is not 0. In other words, |
60 | * if ref_count is > 0, then the list member must not be linked into | 60 | * if ref_count is > 0, then the list member must not be linked into |
@@ -84,6 +84,7 @@ struct ib_fmr_pool { | |||
84 | 84 | ||
85 | int pool_size; | 85 | int pool_size; |
86 | int max_pages; | 86 | int max_pages; |
87 | int max_remaps; | ||
87 | int dirty_watermark; | 88 | int dirty_watermark; |
88 | int dirty_len; | 89 | int dirty_len; |
89 | struct list_head free_list; | 90 | struct list_head free_list; |
@@ -214,8 +215,10 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
214 | { | 215 | { |
215 | struct ib_device *device; | 216 | struct ib_device *device; |
216 | struct ib_fmr_pool *pool; | 217 | struct ib_fmr_pool *pool; |
218 | struct ib_device_attr *attr; | ||
217 | int i; | 219 | int i; |
218 | int ret; | 220 | int ret; |
221 | int max_remaps; | ||
219 | 222 | ||
220 | if (!params) | 223 | if (!params) |
221 | return ERR_PTR(-EINVAL); | 224 | return ERR_PTR(-EINVAL); |
@@ -228,6 +231,26 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
228 | return ERR_PTR(-ENOSYS); | 231 | return ERR_PTR(-ENOSYS); |
229 | } | 232 | } |
230 | 233 | ||
234 | attr = kmalloc(sizeof *attr, GFP_KERNEL); | ||
235 | if (!attr) { | ||
236 | printk(KERN_WARNING "couldn't allocate device attr struct"); | ||
237 | return ERR_PTR(-ENOMEM); | ||
238 | } | ||
239 | |||
240 | ret = ib_query_device(device, attr); | ||
241 | if (ret) { | ||
242 | printk(KERN_WARNING "couldn't query device"); | ||
243 | kfree(attr); | ||
244 | return ERR_PTR(ret); | ||
245 | } | ||
246 | |||
247 | if (!attr->max_map_per_fmr) | ||
248 | max_remaps = IB_FMR_MAX_REMAPS; | ||
249 | else | ||
250 | max_remaps = attr->max_map_per_fmr; | ||
251 | |||
252 | kfree(attr); | ||
253 | |||
231 | pool = kmalloc(sizeof *pool, GFP_KERNEL); | 254 | pool = kmalloc(sizeof *pool, GFP_KERNEL); |
232 | if (!pool) { | 255 | if (!pool) { |
233 | printk(KERN_WARNING "couldn't allocate pool struct"); | 256 | printk(KERN_WARNING "couldn't allocate pool struct"); |
@@ -258,6 +281,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
258 | 281 | ||
259 | pool->pool_size = 0; | 282 | pool->pool_size = 0; |
260 | pool->max_pages = params->max_pages_per_fmr; | 283 | pool->max_pages = params->max_pages_per_fmr; |
284 | pool->max_remaps = max_remaps; | ||
261 | pool->dirty_watermark = params->dirty_watermark; | 285 | pool->dirty_watermark = params->dirty_watermark; |
262 | pool->dirty_len = 0; | 286 | pool->dirty_len = 0; |
263 | spin_lock_init(&pool->pool_lock); | 287 | spin_lock_init(&pool->pool_lock); |
@@ -279,7 +303,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
279 | struct ib_pool_fmr *fmr; | 303 | struct ib_pool_fmr *fmr; |
280 | struct ib_fmr_attr attr = { | 304 | struct ib_fmr_attr attr = { |
281 | .max_pages = params->max_pages_per_fmr, | 305 | .max_pages = params->max_pages_per_fmr, |
282 | .max_maps = IB_FMR_MAX_REMAPS, | 306 | .max_maps = pool->max_remaps, |
283 | .page_shift = params->page_shift | 307 | .page_shift = params->page_shift |
284 | }; | 308 | }; |
285 | 309 | ||
@@ -489,7 +513,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr) | |||
489 | 513 | ||
490 | --fmr->ref_count; | 514 | --fmr->ref_count; |
491 | if (!fmr->ref_count) { | 515 | if (!fmr->ref_count) { |
492 | if (fmr->remap_count < IB_FMR_MAX_REMAPS) { | 516 | if (fmr->remap_count < pool->max_remaps) { |
493 | list_add_tail(&fmr->list, &pool->free_list); | 517 | list_add_tail(&fmr->list, &pool->free_list); |
494 | } else { | 518 | } else { |
495 | list_add_tail(&fmr->list, &pool->dirty_list); | 519 | list_add_tail(&fmr->list, &pool->dirty_list); |