diff options
-rw-r--r-- | drivers/infiniband/ulp/iser/iscsi_iser.h | 4 | ||||
-rw-r--r-- | drivers/infiniband/ulp/iser/iser_verbs.c | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index e34263cbecc3..4234a9c0ebfd 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h | |||
@@ -326,8 +326,6 @@ struct iser_rx_desc { | |||
326 | char pad[ISER_RX_PAD_SIZE]; | 326 | char pad[ISER_RX_PAD_SIZE]; |
327 | } __attribute__((packed)); | 327 | } __attribute__((packed)); |
328 | 328 | ||
329 | #define ISER_MAX_CQ 4 | ||
330 | |||
331 | struct iser_conn; | 329 | struct iser_conn; |
332 | struct ib_conn; | 330 | struct ib_conn; |
333 | struct iscsi_iser_task; | 331 | struct iscsi_iser_task; |
@@ -378,7 +376,7 @@ struct iser_device { | |||
378 | struct list_head ig_list; | 376 | struct list_head ig_list; |
379 | int refcount; | 377 | int refcount; |
380 | int comps_used; | 378 | int comps_used; |
381 | struct iser_comp comps[ISER_MAX_CQ]; | 379 | struct iser_comp *comps; |
382 | int (*iser_alloc_rdma_reg_res)(struct ib_conn *ib_conn, | 380 | int (*iser_alloc_rdma_reg_res)(struct ib_conn *ib_conn, |
383 | unsigned cmds_max); | 381 | unsigned cmds_max); |
384 | void (*iser_free_rdma_reg_res)(struct ib_conn *ib_conn); | 382 | void (*iser_free_rdma_reg_res)(struct ib_conn *ib_conn); |
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index ad493d285be1..5d69927e9efc 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -104,9 +104,14 @@ static int iser_create_device_ib_res(struct iser_device *device) | |||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | 106 | ||
107 | device->comps_used = min(ISER_MAX_CQ, | 107 | device->comps_used = min_t(int, num_online_cpus(), |
108 | device->ib_device->num_comp_vectors); | 108 | device->ib_device->num_comp_vectors); |
109 | 109 | ||
110 | device->comps = kcalloc(device->comps_used, sizeof(*device->comps), | ||
111 | GFP_KERNEL); | ||
112 | if (!device->comps) | ||
113 | goto comps_err; | ||
114 | |||
110 | max_cqe = min(ISER_MAX_CQ_LEN, dev_attr->max_cqe); | 115 | max_cqe = min(ISER_MAX_CQ_LEN, dev_attr->max_cqe); |
111 | 116 | ||
112 | iser_info("using %d CQs, device %s supports %d vectors max_cqe %d\n", | 117 | iser_info("using %d CQs, device %s supports %d vectors max_cqe %d\n", |
@@ -165,6 +170,8 @@ cq_err: | |||
165 | } | 170 | } |
166 | ib_dealloc_pd(device->pd); | 171 | ib_dealloc_pd(device->pd); |
167 | pd_err: | 172 | pd_err: |
173 | kfree(device->comps); | ||
174 | comps_err: | ||
168 | iser_err("failed to allocate an IB resource\n"); | 175 | iser_err("failed to allocate an IB resource\n"); |
169 | return -1; | 176 | return -1; |
170 | } | 177 | } |
@@ -190,6 +197,9 @@ static void iser_free_device_ib_res(struct iser_device *device) | |||
190 | (void)ib_dereg_mr(device->mr); | 197 | (void)ib_dereg_mr(device->mr); |
191 | (void)ib_dealloc_pd(device->pd); | 198 | (void)ib_dealloc_pd(device->pd); |
192 | 199 | ||
200 | kfree(device->comps); | ||
201 | device->comps = NULL; | ||
202 | |||
193 | device->mr = NULL; | 203 | device->mr = NULL; |
194 | device->pd = NULL; | 204 | device->pd = NULL; |
195 | } | 205 | } |