Lines Matching refs:pgdir
74 struct hns_roce_db_pgdir *pgdir; in hns_roce_alloc_db_pgdir() local
76 pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); in hns_roce_alloc_db_pgdir()
77 if (!pgdir) in hns_roce_alloc_db_pgdir()
80 bitmap_fill(pgdir->order1, in hns_roce_alloc_db_pgdir()
82 pgdir->bits[0] = pgdir->order0; in hns_roce_alloc_db_pgdir()
83 pgdir->bits[1] = pgdir->order1; in hns_roce_alloc_db_pgdir()
84 pgdir->page = dma_alloc_coherent(dma_device, PAGE_SIZE, in hns_roce_alloc_db_pgdir()
85 &pgdir->db_dma, GFP_KERNEL); in hns_roce_alloc_db_pgdir()
86 if (!pgdir->page) { in hns_roce_alloc_db_pgdir()
87 kfree(pgdir); in hns_roce_alloc_db_pgdir()
91 return pgdir; in hns_roce_alloc_db_pgdir()
94 static int hns_roce_alloc_db_from_pgdir(struct hns_roce_db_pgdir *pgdir, in hns_roce_alloc_db_from_pgdir() argument
101 i = find_first_bit(pgdir->bits[o], HNS_ROCE_DB_PER_PAGE >> o); in hns_roce_alloc_db_from_pgdir()
109 clear_bit(i, pgdir->bits[o]); in hns_roce_alloc_db_from_pgdir()
114 set_bit(i ^ 1, pgdir->bits[order]); in hns_roce_alloc_db_from_pgdir()
116 db->u.pgdir = pgdir; in hns_roce_alloc_db_from_pgdir()
118 db->db_record = pgdir->page + db->index; in hns_roce_alloc_db_from_pgdir()
119 db->dma = pgdir->db_dma + db->index * HNS_ROCE_DB_UNIT_SIZE; in hns_roce_alloc_db_from_pgdir()
128 struct hns_roce_db_pgdir *pgdir; in hns_roce_alloc_db() local
133 list_for_each_entry(pgdir, &hr_dev->pgdir_list, list) in hns_roce_alloc_db()
134 if (!hns_roce_alloc_db_from_pgdir(pgdir, db, order)) in hns_roce_alloc_db()
137 pgdir = hns_roce_alloc_db_pgdir(hr_dev->dev); in hns_roce_alloc_db()
138 if (!pgdir) { in hns_roce_alloc_db()
143 list_add(&pgdir->list, &hr_dev->pgdir_list); in hns_roce_alloc_db()
146 WARN_ON(hns_roce_alloc_db_from_pgdir(pgdir, db, order)); in hns_roce_alloc_db()
164 if (db->order == 0 && test_bit(i ^ 1, db->u.pgdir->order0)) { in hns_roce_free_db()
165 clear_bit(i ^ 1, db->u.pgdir->order0); in hns_roce_free_db()
170 set_bit(i, db->u.pgdir->bits[o]); in hns_roce_free_db()
172 if (bitmap_full(db->u.pgdir->order1, in hns_roce_free_db()
174 dma_free_coherent(hr_dev->dev, PAGE_SIZE, db->u.pgdir->page, in hns_roce_free_db()
175 db->u.pgdir->db_dma); in hns_roce_free_db()
176 list_del(&db->u.pgdir->list); in hns_roce_free_db()
177 kfree(db->u.pgdir); in hns_roce_free_db()