drm: move drm vblank initialization/cleanup to driver load/unload
[safe/jmp/linux-2.6] / drivers / infiniband / core / fmr_pool.c
index 4044fdf..4507043 100644 (file)
@@ -29,8 +29,6 @@
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- * $Id: fmr_pool.c 2730 2005-06-28 16:43:03Z sean.hefty $
  */
 
 #include <linux/errno.h>
@@ -158,8 +156,7 @@ static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
 #endif
        }
 
-       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);
@@ -398,8 +395,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,