Lines Matching refs:pgdir
73 struct hns_roce_db_pgdir *pgdir; in hns_roce_alloc_db_pgdir() local
75 pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); in hns_roce_alloc_db_pgdir()
76 if (!pgdir) in hns_roce_alloc_db_pgdir()
79 bitmap_fill(pgdir->order1, in hns_roce_alloc_db_pgdir()
81 pgdir->bits[0] = pgdir->order0; in hns_roce_alloc_db_pgdir()
82 pgdir->bits[1] = pgdir->order1; in hns_roce_alloc_db_pgdir()
83 pgdir->page = dma_alloc_coherent(dma_device, PAGE_SIZE, in hns_roce_alloc_db_pgdir()
84 &pgdir->db_dma, GFP_KERNEL); in hns_roce_alloc_db_pgdir()
85 if (!pgdir->page) { in hns_roce_alloc_db_pgdir()
86 kfree(pgdir); in hns_roce_alloc_db_pgdir()
90 return pgdir; in hns_roce_alloc_db_pgdir()
93 static int hns_roce_alloc_db_from_pgdir(struct hns_roce_db_pgdir *pgdir, in hns_roce_alloc_db_from_pgdir() argument
100 i = find_first_bit(pgdir->bits[o], HNS_ROCE_DB_PER_PAGE >> o); in hns_roce_alloc_db_from_pgdir()
108 clear_bit(i, pgdir->bits[o]); in hns_roce_alloc_db_from_pgdir()
113 set_bit(i ^ 1, pgdir->bits[order]); in hns_roce_alloc_db_from_pgdir()
115 db->u.pgdir = pgdir; in hns_roce_alloc_db_from_pgdir()
117 db->db_record = pgdir->page + db->index; in hns_roce_alloc_db_from_pgdir()
118 db->dma = pgdir->db_dma + db->index * HNS_ROCE_DB_UNIT_SIZE; in hns_roce_alloc_db_from_pgdir()
127 struct hns_roce_db_pgdir *pgdir; in hns_roce_alloc_db() local
132 list_for_each_entry(pgdir, &hr_dev->pgdir_list, list) in hns_roce_alloc_db()
133 if (!hns_roce_alloc_db_from_pgdir(pgdir, db, order)) in hns_roce_alloc_db()
136 pgdir = hns_roce_alloc_db_pgdir(hr_dev->dev); in hns_roce_alloc_db()
137 if (!pgdir) { in hns_roce_alloc_db()
142 list_add(&pgdir->list, &hr_dev->pgdir_list); in hns_roce_alloc_db()
145 WARN_ON(hns_roce_alloc_db_from_pgdir(pgdir, db, order)); in hns_roce_alloc_db()
163 if (db->order == 0 && test_bit(i ^ 1, db->u.pgdir->order0)) { in hns_roce_free_db()
164 clear_bit(i ^ 1, db->u.pgdir->order0); in hns_roce_free_db()
169 set_bit(i, db->u.pgdir->bits[o]); in hns_roce_free_db()
171 if (bitmap_full(db->u.pgdir->order1, in hns_roce_free_db()
173 dma_free_coherent(hr_dev->dev, PAGE_SIZE, db->u.pgdir->page, in hns_roce_free_db()
174 db->u.pgdir->db_dma); in hns_roce_free_db()
175 list_del(&db->u.pgdir->list); in hns_roce_free_db()
176 kfree(db->u.pgdir); in hns_roce_free_db()