aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ehca/ehca_cq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/ehca/ehca_cq.c')
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 81aff36101b..79c25f51c21 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -166,7 +166,6 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
166 write_lock_irqsave(&ehca_cq_idr_lock, flags); 166 write_lock_irqsave(&ehca_cq_idr_lock, flags);
167 ret = idr_get_new(&ehca_cq_idr, my_cq, &my_cq->token); 167 ret = idr_get_new(&ehca_cq_idr, my_cq, &my_cq->token);
168 write_unlock_irqrestore(&ehca_cq_idr_lock, flags); 168 write_unlock_irqrestore(&ehca_cq_idr_lock, flags);
169
170 } while (ret == -EAGAIN); 169 } while (ret == -EAGAIN);
171 170
172 if (ret) { 171 if (ret) {
@@ -176,6 +175,12 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
176 goto create_cq_exit1; 175 goto create_cq_exit1;
177 } 176 }
178 177
178 if (my_cq->token > 0x1FFFFFF) {
179 cq = ERR_PTR(-ENOMEM);
180 ehca_err(device, "Invalid number of cq. device=%p", device);
181 goto create_cq_exit2;
182 }
183
179 /* 184 /*
180 * CQs maximum depth is 4GB-64, but we need additional 20 as buffer 185 * CQs maximum depth is 4GB-64, but we need additional 20 as buffer
181 * for receiving errors CQEs. 186 * for receiving errors CQEs.
@@ -185,7 +190,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
185 190
186 if (h_ret != H_SUCCESS) { 191 if (h_ret != H_SUCCESS) {
187 ehca_err(device, "hipz_h_alloc_resource_cq() failed " 192 ehca_err(device, "hipz_h_alloc_resource_cq() failed "
188 "h_ret=%lx device=%p", h_ret, device); 193 "h_ret=%li device=%p", h_ret, device);
189 cq = ERR_PTR(ehca2ib_return_code(h_ret)); 194 cq = ERR_PTR(ehca2ib_return_code(h_ret));
190 goto create_cq_exit2; 195 goto create_cq_exit2;
191 } 196 }
@@ -193,7 +198,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
193 ipz_rc = ipz_queue_ctor(NULL, &my_cq->ipz_queue, param.act_pages, 198 ipz_rc = ipz_queue_ctor(NULL, &my_cq->ipz_queue, param.act_pages,
194 EHCA_PAGESIZE, sizeof(struct ehca_cqe), 0, 0); 199 EHCA_PAGESIZE, sizeof(struct ehca_cqe), 0, 0);
195 if (!ipz_rc) { 200 if (!ipz_rc) {
196 ehca_err(device, "ipz_queue_ctor() failed ipz_rc=%x device=%p", 201 ehca_err(device, "ipz_queue_ctor() failed ipz_rc=%i device=%p",
197 ipz_rc, device); 202 ipz_rc, device);
198 cq = ERR_PTR(-EINVAL); 203 cq = ERR_PTR(-EINVAL);
199 goto create_cq_exit3; 204 goto create_cq_exit3;
@@ -221,7 +226,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
221 226
222 if (h_ret < H_SUCCESS) { 227 if (h_ret < H_SUCCESS) {
223 ehca_err(device, "hipz_h_register_rpage_cq() failed " 228 ehca_err(device, "hipz_h_register_rpage_cq() failed "
224 "ehca_cq=%p cq_num=%x h_ret=%lx counter=%i " 229 "ehca_cq=%p cq_num=%x h_ret=%li counter=%i "
225 "act_pages=%i", my_cq, my_cq->cq_number, 230 "act_pages=%i", my_cq, my_cq->cq_number,
226 h_ret, counter, param.act_pages); 231 h_ret, counter, param.act_pages);
227 cq = ERR_PTR(-EINVAL); 232 cq = ERR_PTR(-EINVAL);
@@ -233,7 +238,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
233 if ((h_ret != H_SUCCESS) || vpage) { 238 if ((h_ret != H_SUCCESS) || vpage) {
234 ehca_err(device, "Registration of pages not " 239 ehca_err(device, "Registration of pages not "
235 "complete ehca_cq=%p cq_num=%x " 240 "complete ehca_cq=%p cq_num=%x "
236 "h_ret=%lx", my_cq, my_cq->cq_number, 241 "h_ret=%li", my_cq, my_cq->cq_number,
237 h_ret); 242 h_ret);
238 cq = ERR_PTR(-EAGAIN); 243 cq = ERR_PTR(-EAGAIN);
239 goto create_cq_exit4; 244 goto create_cq_exit4;
@@ -241,7 +246,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
241 } else { 246 } else {
242 if (h_ret != H_PAGE_REGISTERED) { 247 if (h_ret != H_PAGE_REGISTERED) {
243 ehca_err(device, "Registration of page failed " 248 ehca_err(device, "Registration of page failed "
244 "ehca_cq=%p cq_num=%x h_ret=%lx" 249 "ehca_cq=%p cq_num=%x h_ret=%li"
245 "counter=%i act_pages=%i", 250 "counter=%i act_pages=%i",
246 my_cq, my_cq->cq_number, 251 my_cq, my_cq->cq_number,
247 h_ret, counter, param.act_pages); 252 h_ret, counter, param.act_pages);
@@ -276,6 +281,8 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
276 resp.ipz_queue.queue_length = ipz_queue->queue_length; 281 resp.ipz_queue.queue_length = ipz_queue->queue_length;
277 resp.ipz_queue.pagesize = ipz_queue->pagesize; 282 resp.ipz_queue.pagesize = ipz_queue->pagesize;
278 resp.ipz_queue.toggle_state = ipz_queue->toggle_state; 283 resp.ipz_queue.toggle_state = ipz_queue->toggle_state;
284 resp.fw_handle_ofs = (u32)
285 (my_cq->galpas.user.fw_handle & (PAGE_SIZE - 1));
279 if (ib_copy_to_udata(udata, &resp, sizeof(resp))) { 286 if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
280 ehca_err(device, "Copy to udata failed."); 287 ehca_err(device, "Copy to udata failed.");
281 goto create_cq_exit4; 288 goto create_cq_exit4;
@@ -291,7 +298,7 @@ create_cq_exit3:
291 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 1); 298 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 1);
292 if (h_ret != H_SUCCESS) 299 if (h_ret != H_SUCCESS)
293 ehca_err(device, "hipz_h_destroy_cq() failed ehca_cq=%p " 300 ehca_err(device, "hipz_h_destroy_cq() failed ehca_cq=%p "
294 "cq_num=%x h_ret=%lx", my_cq, my_cq->cq_number, h_ret); 301 "cq_num=%x h_ret=%li", my_cq, my_cq->cq_number, h_ret);
295 302
296create_cq_exit2: 303create_cq_exit2:
297 write_lock_irqsave(&ehca_cq_idr_lock, flags); 304 write_lock_irqsave(&ehca_cq_idr_lock, flags);
@@ -355,7 +362,7 @@ int ehca_destroy_cq(struct ib_cq *cq)
355 cq_num); 362 cq_num);
356 } 363 }
357 if (h_ret != H_SUCCESS) { 364 if (h_ret != H_SUCCESS) {
358 ehca_err(device, "hipz_h_destroy_cq() failed h_ret=%lx " 365 ehca_err(device, "hipz_h_destroy_cq() failed h_ret=%li "
359 "ehca_cq=%p cq_num=%x", h_ret, my_cq, cq_num); 366 "ehca_cq=%p cq_num=%x", h_ret, my_cq, cq_num);
360 return ehca2ib_return_code(h_ret); 367 return ehca2ib_return_code(h_ret);
361 } 368 }