Lines Matching refs:hem
56 static bool hns_roce_check_hem_null(struct hns_roce_hem **hem, u64 start_idx, in hns_roce_check_hem_null() argument
62 if (hem[start_idx + i]) in hns_roce_check_hem_null()
200 struct hns_roce_hem *hem; in hns_roce_alloc_hem() local
207 hem = kmalloc(sizeof(*hem), in hns_roce_alloc_hem()
209 if (!hem) in hns_roce_alloc_hem()
212 hem->refcount = 0; in hns_roce_alloc_hem()
213 INIT_LIST_HEAD(&hem->chunk_list); in hns_roce_alloc_hem()
228 list_add_tail(&chunk->list, &hem->chunk_list); in hns_roce_alloc_hem()
252 return hem; in hns_roce_alloc_hem()
255 hns_roce_free_hem(hr_dev, hem); in hns_roce_alloc_hem()
259 void hns_roce_free_hem(struct hns_roce_dev *hr_dev, struct hns_roce_hem *hem) in hns_roce_free_hem() argument
264 if (!hem) in hns_roce_free_hem()
267 list_for_each_entry_safe(chunk, tmp, &hem->chunk_list, list) { in hns_roce_free_hem()
276 kfree(hem); in hns_roce_free_hem()
326 for (hns_roce_hem_first(table->hem[i], &iter); in hns_roce_set_hem()
418 if (table->hem[hem_idx]) { in hns_roce_table_mhop_get()
419 ++table->hem[hem_idx]->refcount; in hns_roce_table_mhop_get()
475 table->hem[hem_idx] = hns_roce_alloc_hem(hr_dev, in hns_roce_table_mhop_get()
480 if (!table->hem[hem_idx]) { in hns_roce_table_mhop_get()
485 hns_roce_hem_first(table->hem[hem_idx], &iter); in hns_roce_table_mhop_get()
512 ++table->hem[hem_idx]->refcount; in hns_roce_table_mhop_get()
549 if (table->hem[i]) { in hns_roce_table_get()
550 ++table->hem[i]->refcount; in hns_roce_table_get()
554 table->hem[i] = hns_roce_alloc_hem(hr_dev, in hns_roce_table_get()
559 if (!table->hem[i]) { in hns_roce_table_get()
566 hns_roce_free_hem(hr_dev, table->hem[i]); in hns_roce_table_get()
567 table->hem[i] = NULL; in hns_roce_table_get()
573 ++table->hem[i]->refcount; in hns_roce_table_get()
625 if (check_refcount && (--table->hem[hem_idx]->refcount > 0)) { in hns_roce_table_mhop_put()
646 hns_roce_free_hem(hr_dev, table->hem[hem_idx]); in hns_roce_table_mhop_put()
647 table->hem[hem_idx] = NULL; in hns_roce_table_mhop_put()
651 if (hns_roce_check_hem_null(table->hem, start_idx, in hns_roce_table_mhop_put()
665 if (hns_roce_check_hem_null(table->hem, start_idx, in hns_roce_table_mhop_put()
709 if (--table->hem[i]->refcount == 0) { in hns_roce_table_put()
714 hns_roce_free_hem(hr_dev, table->hem[i]); in hns_roce_table_put()
715 table->hem[i] = NULL; in hns_roce_table_put()
727 struct hns_roce_hem *hem; in hns_roce_table_find() local
744 hem = table->hem[(obj & (table->num_obj - 1)) / obj_per_chunk]; in hns_roce_table_find()
758 hem = table->hem[hem_idx]; in hns_roce_table_find()
765 if (!hem) in hns_roce_table_find()
768 list_for_each_entry(chunk, &hem->chunk_list, list) { in hns_roce_table_find()
854 table->hem = kcalloc(num_hem, sizeof(*table->hem), GFP_KERNEL); in hns_roce_init_hem_table()
855 if (!table->hem) in hns_roce_init_hem_table()
921 table->hem = kcalloc(num_hem, sizeof(*table->hem), in hns_roce_init_hem_table()
923 if (!table->hem) in hns_roce_init_hem_table()
982 kfree(table->hem); in hns_roce_init_hem_table()
983 table->hem = NULL; in hns_roce_init_hem_table()
1003 if (table->hem[i]) in hns_roce_cleanup_mhop_hem_table()
1007 kfree(table->hem); in hns_roce_cleanup_mhop_hem_table()
1008 table->hem = NULL; in hns_roce_cleanup_mhop_hem_table()
1031 if (table->hem[i]) { in hns_roce_cleanup_hem_table()
1036 hns_roce_free_hem(hr_dev, table->hem[i]); in hns_roce_cleanup_hem_table()
1039 kfree(table->hem); in hns_roce_cleanup_hem_table()