]> err.no Git - linux-2.6/blobdiff - drivers/infiniband/core/fmr_pool.c
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6] / drivers / infiniband / core / fmr_pool.c
index 6c7aa59794d4ebb248f8e16fe789e7bdace6f81d..1286dc1b98b2acda72ce158ef8abd443cc3c8dc1 100644 (file)
@@ -139,7 +139,7 @@ static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
 static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
 {
        int                 ret;
-       struct ib_pool_fmr *fmr, *next;
+       struct ib_pool_fmr *fmr;
        LIST_HEAD(unmap_list);
        LIST_HEAD(fmr_list);
 
@@ -158,22 +158,7 @@ static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
 #endif
        }
 
-       /*
-        * The free_list may hold FMRs that have been put there
-        * because they haven't reached the max_remap count.
-        * Invalidate their mapping as well.
-        */
-       list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
-               if (fmr->remap_count == 0)
-                       continue;
-               hlist_del_init(&fmr->cache_node);
-               fmr->remap_count = 0;
-               list_add_tail(&fmr->fmr->list, &fmr_list);
-               list_move(&fmr->list, &unmap_list);
-       }
-
-       list_splice(&pool->dirty_list, &unmap_list);
-       INIT_LIST_HEAD(&pool->dirty_list);
+       list_splice_init(&pool->dirty_list, &unmap_list);
        pool->dirty_len = 0;
 
        spin_unlock_irq(&pool->pool_lock);
@@ -320,10 +305,13 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd             *pd,
                        .max_maps   = pool->max_remaps,
                        .page_shift = params->page_shift
                };
+               int bytes_per_fmr = sizeof *fmr;
+
+               if (pool->cache_bucket)
+                       bytes_per_fmr += params->max_pages_per_fmr * sizeof (u64);
 
                for (i = 0; i < params->pool_size; ++i) {
-                       fmr = kmalloc(sizeof *fmr + params->max_pages_per_fmr * sizeof (u64),
-                                     GFP_KERNEL);
+                       fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
                        if (!fmr) {
                                printk(KERN_WARNING PFX "failed to allocate fmr "
                                       "struct for FMR %d\n", i);
@@ -381,6 +369,11 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
 
        i = 0;
        list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
+               if (fmr->remap_count) {
+                       INIT_LIST_HEAD(&fmr_list);
+                       list_add_tail(&fmr->fmr->list, &fmr_list);
+                       ib_unmap_fmr(&fmr_list);
+               }
                ib_dealloc_fmr(fmr->fmr);
                list_del(&fmr->list);
                kfree(fmr);
@@ -404,8 +397,23 @@ EXPORT_SYMBOL(ib_destroy_fmr_pool);
  */
 int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
 {
-       int serial = atomic_inc_return(&pool->req_ser);
+       int serial;
+       struct ib_pool_fmr *fmr, *next;
+
+       /*
+        * The free_list holds FMRs that may have been used
+        * but have not been remapped enough times to be dirty.
+        * Put them on the dirty list now so that the cleanup
+        * thread will reap them too.
+        */
+       spin_lock_irq(&pool->pool_lock);
+       list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
+               if (fmr->remap_count > 0)
+                       list_move(&fmr->list, &pool->dirty_list);
+       }
+       spin_unlock_irq(&pool->pool_lock);
 
+       serial = atomic_inc_return(&pool->req_ser);
        wake_up_process(pool->thread);
 
        if (wait_event_interruptible(pool->force_wait,