Lines Matching refs:page

60 	}                page[0];  member
108 struct page *page; in mthca_alloc_icm_pages() local
114 page = alloc_pages(gfp_mask | __GFP_ZERO, order); in mthca_alloc_icm_pages()
115 if (!page) in mthca_alloc_icm_pages()
118 sg_set_page(mem, page, PAGE_SIZE << order, 0); in mthca_alloc_icm_pages()
282 struct page *page = NULL; in mthca_table_find() local
308 page = sg_page(&chunk->mem[i]); in mthca_table_find()
317 return page ? lowmem_page_address(page) + offset : NULL; in mthca_table_find()
438 static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int page) in mthca_uarc_virt() argument
442 page * MTHCA_ICM_PAGE_SIZE; in mthca_uarc_virt()
448 struct page *pages[1]; in mthca_map_user_db()
462 if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) || in mthca_map_user_db()
463 (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) || in mthca_map_user_db()
469 if (db_tab->page[i].refcount) { in mthca_map_user_db()
470 ++db_tab->page[i].refcount; in mthca_map_user_db()
478 sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, in mthca_map_user_db()
481 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_map_user_db()
487 ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem), in mthca_map_user_db()
490 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_map_user_db()
491 put_page(sg_page(&db_tab->page[i].mem)); in mthca_map_user_db()
495 db_tab->page[i].uvirt = uaddr; in mthca_map_user_db()
496 db_tab->page[i].refcount = 1; in mthca_map_user_db()
516 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; in mthca_unmap_user_db()
531 db_tab = kmalloc(sizeof *db_tab + npages * sizeof *db_tab->page, GFP_KERNEL); in mthca_init_user_db_tab()
537 db_tab->page[i].refcount = 0; in mthca_init_user_db_tab()
538 db_tab->page[i].uvirt = 0; in mthca_init_user_db_tab()
539 sg_init_table(&db_tab->page[i].mem, 1); in mthca_init_user_db_tab()
554 if (db_tab->page[i].uvirt) { in mthca_cleanup_user_db_tab()
556 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_cleanup_user_db_tab()
557 put_page(sg_page(&db_tab->page[i].mem)); in mthca_cleanup_user_db_tab()
570 struct mthca_db_page *page; in mthca_alloc_db() local
599 if (dev->db_tab->page[i].db_rec && in mthca_alloc_db()
600 !bitmap_full(dev->db_tab->page[i].used, in mthca_alloc_db()
602 page = dev->db_tab->page + i; in mthca_alloc_db()
607 if (!dev->db_tab->page[i].db_rec) { in mthca_alloc_db()
608 page = dev->db_tab->page + i; in mthca_alloc_db()
622 page = dev->db_tab->page + end; in mthca_alloc_db()
625 page->db_rec = dma_alloc_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE, in mthca_alloc_db()
626 &page->mapping, GFP_KERNEL); in mthca_alloc_db()
627 if (!page->db_rec) { in mthca_alloc_db()
631 memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE); in mthca_alloc_db()
633 ret = mthca_MAP_ICM_page(dev, page->mapping, in mthca_alloc_db()
637 page->db_rec, page->mapping); in mthca_alloc_db()
641 bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); in mthca_alloc_db()
644 j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); in mthca_alloc_db()
645 set_bit(j, page->used); in mthca_alloc_db()
652 page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5)); in mthca_alloc_db()
654 *db = (__be32 *) &page->db_rec[j]; in mthca_alloc_db()
665 struct mthca_db_page *page; in mthca_free_db() local
670 page = dev->db_tab->page + i; in mthca_free_db()
674 page->db_rec[j] = 0; in mthca_free_db()
677 clear_bit(j, page->used); in mthca_free_db()
679 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) && in mthca_free_db()
684 page->db_rec, page->mapping); in mthca_free_db()
685 page->db_rec = NULL; in mthca_free_db()
715 dev->db_tab->page = kmalloc(dev->db_tab->npages * in mthca_init_db_tab()
716 sizeof *dev->db_tab->page, in mthca_init_db_tab()
718 if (!dev->db_tab->page) { in mthca_init_db_tab()
724 dev->db_tab->page[i].db_rec = NULL; in mthca_init_db_tab()
743 if (!dev->db_tab->page[i].db_rec) in mthca_cleanup_db_tab()
746 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE)) in mthca_cleanup_db_tab()
752 dev->db_tab->page[i].db_rec, in mthca_cleanup_db_tab()
753 dev->db_tab->page[i].mapping); in mthca_cleanup_db_tab()
756 kfree(dev->db_tab->page); in mthca_cleanup_db_tab()