34 #include <linux/errno.h>
36 #include <linux/export.h>
37 #include <linux/slab.h>
45 #define PFX "fmr_pool: "
107 static inline u32 ib_fmr_hash(
u64 first_page)
109 return jhash_2words((
u32) first_page, (
u32) (first_page >> 32), 0) &
129 if (io_virtual_address == fmr->io_virtual_address &&
130 page_list_len == fmr->page_list_len &&
131 !
memcmp(page_list, fmr->page_list,
132 page_list_len *
sizeof *page_list))
145 spin_lock_irq(&pool->pool_lock);
160 list_splice_init(&pool->dirty_list, &unmap_list);
163 spin_unlock_irq(&pool->pool_lock);
165 if (list_empty(&unmap_list)) {
173 spin_lock_irq(&pool->pool_lock);
174 list_splice(&unmap_list, &pool->free_list);
175 spin_unlock_irq(&pool->pool_lock);
178 static int ib_fmr_cleanup_thread(
void *pool_ptr)
184 ib_fmr_batch_release(pool);
294 if (IS_ERR(pool->
thread)) {
296 ret = PTR_ERR(pool->
thread);
307 int bytes_per_fmr =
sizeof *
fmr;
316 "struct for FMR %d\n", i);
326 if (IS_ERR(fmr->
fmr)) {
367 ib_fmr_batch_release(pool);
372 INIT_LIST_HEAD(&fmr_list);
382 if (i < pool->pool_size)
438 u64 io_virtual_address)
445 if (list_len < 1 || list_len > pool->
max_pages)
449 fmr = ib_fmr_cache_lookup(pool,
460 spin_unlock_irqrestore(&pool->
pool_lock, flags);
466 spin_unlock_irqrestore(&pool->
pool_lock, flags);
473 spin_unlock_irqrestore(&pool->
pool_lock, flags);
475 result = ib_map_phys_fmr(fmr->
fmr, page_list, list_len,
481 spin_unlock_irqrestore(&pool->
pool_lock, flags);
485 return ERR_PTR(result);
499 spin_unlock_irqrestore(&pool->
pool_lock, flags);
541 spin_unlock_irqrestore(&pool->
pool_lock, flags);