Lines Matching refs:page
61 } page[0]; member
109 struct page *page; in mthca_alloc_icm_pages() local
115 page = alloc_pages(gfp_mask | __GFP_ZERO, order); in mthca_alloc_icm_pages()
116 if (!page) in mthca_alloc_icm_pages()
119 sg_set_page(mem, page, PAGE_SIZE << order, 0); in mthca_alloc_icm_pages()
283 struct page *page = NULL; in mthca_table_find() local
309 page = sg_page(&chunk->mem[i]); in mthca_table_find()
318 return page ? lowmem_page_address(page) + offset : NULL; in mthca_table_find()
439 static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int page) in mthca_uarc_virt() argument
443 page * MTHCA_ICM_PAGE_SIZE; in mthca_uarc_virt()
449 struct page *pages[1]; in mthca_map_user_db()
463 if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) || in mthca_map_user_db()
464 (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) || in mthca_map_user_db()
470 if (db_tab->page[i].refcount) { in mthca_map_user_db()
471 ++db_tab->page[i].refcount; in mthca_map_user_db()
480 sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, in mthca_map_user_db()
483 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_map_user_db()
489 ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem), in mthca_map_user_db()
492 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_map_user_db()
493 put_page(sg_page(&db_tab->page[i].mem)); in mthca_map_user_db()
497 db_tab->page[i].uvirt = uaddr; in mthca_map_user_db()
498 db_tab->page[i].refcount = 1; in mthca_map_user_db()
518 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; in mthca_unmap_user_db()
533 db_tab = kmalloc(sizeof *db_tab + npages * sizeof *db_tab->page, GFP_KERNEL); in mthca_init_user_db_tab()
539 db_tab->page[i].refcount = 0; in mthca_init_user_db_tab()
540 db_tab->page[i].uvirt = 0; in mthca_init_user_db_tab()
541 sg_init_table(&db_tab->page[i].mem, 1); in mthca_init_user_db_tab()
556 if (db_tab->page[i].uvirt) { in mthca_cleanup_user_db_tab()
558 pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); in mthca_cleanup_user_db_tab()
559 put_page(sg_page(&db_tab->page[i].mem)); in mthca_cleanup_user_db_tab()
572 struct mthca_db_page *page; in mthca_alloc_db() local
601 if (dev->db_tab->page[i].db_rec && in mthca_alloc_db()
602 !bitmap_full(dev->db_tab->page[i].used, in mthca_alloc_db()
604 page = dev->db_tab->page + i; in mthca_alloc_db()
609 if (!dev->db_tab->page[i].db_rec) { in mthca_alloc_db()
610 page = dev->db_tab->page + i; in mthca_alloc_db()
624 page = dev->db_tab->page + end; in mthca_alloc_db()
627 page->db_rec = dma_alloc_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE, in mthca_alloc_db()
628 &page->mapping, GFP_KERNEL); in mthca_alloc_db()
629 if (!page->db_rec) { in mthca_alloc_db()
633 memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE); in mthca_alloc_db()
635 ret = mthca_MAP_ICM_page(dev, page->mapping, in mthca_alloc_db()
639 page->db_rec, page->mapping); in mthca_alloc_db()
643 bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); in mthca_alloc_db()
646 j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); in mthca_alloc_db()
647 set_bit(j, page->used); in mthca_alloc_db()
654 page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5)); in mthca_alloc_db()
656 *db = (__be32 *) &page->db_rec[j]; in mthca_alloc_db()
667 struct mthca_db_page *page; in mthca_free_db() local
672 page = dev->db_tab->page + i; in mthca_free_db()
676 page->db_rec[j] = 0; in mthca_free_db()
679 clear_bit(j, page->used); in mthca_free_db()
681 if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) && in mthca_free_db()
686 page->db_rec, page->mapping); in mthca_free_db()
687 page->db_rec = NULL; in mthca_free_db()
717 dev->db_tab->page = kmalloc(dev->db_tab->npages * in mthca_init_db_tab()
718 sizeof *dev->db_tab->page, in mthca_init_db_tab()
720 if (!dev->db_tab->page) { in mthca_init_db_tab()
726 dev->db_tab->page[i].db_rec = NULL; in mthca_init_db_tab()
745 if (!dev->db_tab->page[i].db_rec) in mthca_cleanup_db_tab()
748 if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE)) in mthca_cleanup_db_tab()
754 dev->db_tab->page[i].db_rec, in mthca_cleanup_db_tab()
755 dev->db_tab->page[i].mapping); in mthca_cleanup_db_tab()
758 kfree(dev->db_tab->page); in mthca_cleanup_db_tab()