Commit 94ff7c59 authored by Leon Romanovsky's avatar Leon Romanovsky
Browse files

RDMA: Complete k[z|m|c]alloc-to-k[z|m]alloc_obj conversion

Commits bf4afc53 ("Convert 'alloc_obj' family to use the new default
GFP_KERNEL argument") and 69050f8d ("treewide: Replace kmalloc with
kmalloc_obj for non-scalar types") updated various k[z|m|c]alloc calls to their
k[z|m]alloc_obj counterparts.

This commit finalizes that transition within the RDMA subsystem.

Link: https://patch.msgid.link/20260226-complete-alloc-conversion-v1-1-ebf1df1c2518@nvidia.com


Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
parent 58409f0d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -790,7 +790,7 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res,
	if (dev_attr->max_dpi)
		dpit->max = min_t(u32, dpit->max, dev_attr->max_dpi);

	dpit->app_tbl = kcalloc(dpit->max,  sizeof(void *), GFP_KERNEL);
	dpit->app_tbl = kzalloc_objs(void *, dpit->max);
	if (!dpit->app_tbl)
		return -ENOMEM;

+4 −5
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
	if (tinfo->length == 0)
		return -EINVAL;

	tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL);
	tidbuf = kzalloc_obj(*tidbuf);
	if (!tidbuf)
		return -ENOMEM;

@@ -265,8 +265,7 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
	tidbuf->vaddr = tinfo->vaddr;
	tidbuf->length = tinfo->length;
	tidbuf->npages = num_user_pages(tidbuf->vaddr, tidbuf->length);
	tidbuf->psets = kcalloc(uctxt->expected_count, sizeof(*tidbuf->psets),
				GFP_KERNEL);
	tidbuf->psets = kzalloc_objs(*tidbuf->psets, uctxt->expected_count);
	if (!tidbuf->psets) {
		ret = -ENOMEM;
		goto fail_release_mem;
@@ -306,7 +305,7 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
	}

	ngroups = pageset_count / dd->rcv_entries.group_size;
	tidlist = kcalloc(pageset_count, sizeof(*tidlist), GFP_KERNEL);
	tidlist = kzalloc_objs(*tidlist, pageset_count);
	if (!tidlist) {
		ret = -ENOMEM;
		goto fail_unreserve;
@@ -527,7 +526,7 @@ int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd,
	 * for a long time.
	 * Copy the data to a local buffer so we can release the lock.
	 */
	array = kcalloc(uctxt->expected_count, sizeof(*array), GFP_KERNEL);
	array = kzalloc_objs(*array, uctxt->expected_count);
	if (!array)
		return -EFAULT;

+2 −5
Original line number Diff line number Diff line
@@ -771,9 +771,7 @@ int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,
			unsigned long num_bt_l1;

			num_bt_l1 = DIV_ROUND_UP(num_hem, bt_chunk_num);
			table->bt_l1 = kcalloc(num_bt_l1,
					       sizeof(*table->bt_l1),
					       GFP_KERNEL);
			table->bt_l1 = kzalloc_objs(*table->bt_l1, num_bt_l1);
			if (!table->bt_l1)
				goto err_kcalloc_bt_l1;

@@ -786,8 +784,7 @@ int hns_roce_init_hem_table(struct hns_roce_dev *hr_dev,

		if (check_whether_bt_num_2(type, hop_num) ||
			check_whether_bt_num_3(type, hop_num)) {
			table->bt_l0 = kcalloc(num_bt_l0, sizeof(*table->bt_l0),
					       GFP_KERNEL);
			table->bt_l0 = kzalloc_objs(*table->bt_l0, num_bt_l0);
			if (!table->bt_l0)
				goto err_kcalloc_bt_l0;

+4 −9
Original line number Diff line number Diff line
@@ -1023,21 +1023,16 @@ static void free_qp_db(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
static int alloc_kernel_wrid(struct hns_roce_dev *hr_dev,
			     struct hns_roce_qp *hr_qp)
{
	struct ib_device *ibdev = &hr_dev->ib_dev;
	u64 *sq_wrid = NULL;
	u64 *rq_wrid = NULL;
	u64 *sq_wrid, *rq_wrid = NULL;
	int ret;

	sq_wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64), GFP_KERNEL);
	if (!sq_wrid) {
		ibdev_err(ibdev, "failed to alloc SQ wrid.\n");
	sq_wrid = kzalloc_objs(*sq_wrid, hr_qp->sq.wqe_cnt);
	if (!sq_wrid)
		return -ENOMEM;
	}

	if (hr_qp->rq.wqe_cnt) {
		rq_wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64), GFP_KERNEL);
		rq_wrid = kzalloc_objs(*rq_wrid, hr_qp->rq.wqe_cnt);
		if (!rq_wrid) {
			ibdev_err(ibdev, "failed to alloc RQ wrid.\n");
			ret = -ENOMEM;
			goto err_sq;
		}
+2 −2
Original line number Diff line number Diff line
@@ -1033,7 +1033,7 @@ static int irdma_create_cqp(struct irdma_pci_f *rf)
	if (!cqp->cqp_requests)
		return -ENOMEM;

	cqp->scratch_array = kcalloc(sqsize, sizeof(*cqp->scratch_array), GFP_KERNEL);
	cqp->scratch_array = kzalloc_objs(*cqp->scratch_array, sqsize);
	if (!cqp->scratch_array) {
		status = -ENOMEM;
		goto err_scratch;
@@ -1942,7 +1942,7 @@ int irdma_rt_init_hw(struct irdma_device *iwdev,
	if (status)
		return status;

	stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL);
	stats_info.pestat = kzalloc_obj(*stats_info.pestat);
	if (!stats_info.pestat) {
		irdma_cleanup_cm_core(&iwdev->cm_core);
		return -ENOMEM;
Loading