Skip to content

Commit 354f5bd

Browse files
kadesai16rleon
authored andcommitted
RDMA/bnxt_re: add helper function __poll_for_resp
This interface will be used if the driver has not enabled interrupt and/or interrupt is disabled for a short period of time. Completion is not possible from interrupt so this interface does self-polling. Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com> Link: https://lore.kernel.org/r/1686308514-11996-10-git-send-email-selvin.xavier@broadcom.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 159cf95 commit 354f5bd

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

drivers/infiniband/hw/bnxt_re/qplib_rcfw.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,44 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw,
260260
return 0;
261261
}
262262

263+
/**
264+
* __poll_for_resp - self poll completion for rcfw command
265+
* @rcfw - rcfw channel instance of rdev
266+
* @cookie - cookie to track the command
267+
* @opcode - rcfw submitted for given opcode
268+
*
269+
* It works same as __wait_for_resp except this function will
270+
* do self polling in sort interval since interrupt is disabled.
271+
* This function can not be called from non-sleepable context.
272+
*
273+
* Returns:
274+
* -ETIMEOUT if command is not completed in specific time interval.
275+
* 0 if command is completed by firmware.
276+
*/
277+
static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie,
278+
u8 opcode)
279+
{
280+
struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq;
281+
unsigned long issue_time;
282+
u16 cbit;
283+
284+
cbit = cookie % rcfw->cmdq_depth;
285+
issue_time = jiffies;
286+
287+
do {
288+
if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags))
289+
return bnxt_qplib_map_rc(opcode);
290+
291+
usleep_range(1000, 1001);
292+
293+
bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet);
294+
if (!test_bit(cbit, cmdq->cmdq_bitmap))
295+
return 0;
296+
if (jiffies_to_msecs(jiffies - issue_time) > 10000)
297+
return -ETIMEDOUT;
298+
} while (true);
299+
};
300+
263301
static int __send_message_basic_sanity(struct bnxt_qplib_rcfw *rcfw,
264302
struct bnxt_qplib_cmdqmsg *msg)
265303
{
@@ -328,8 +366,10 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw,
328366

329367
if (msg->block)
330368
rc = __block_for_resp(rcfw, cookie, opcode);
331-
else
369+
else if (atomic_read(&rcfw->rcfw_intr_enabled))
332370
rc = __wait_for_resp(rcfw, cookie, opcode);
371+
else
372+
rc = __poll_for_resp(rcfw, cookie, opcode);
333373
if (rc) {
334374
/* timed out */
335375
dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x timedout (%d)msec\n",
@@ -796,6 +836,7 @@ void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill)
796836
kfree(creq->irq_name);
797837
creq->irq_name = NULL;
798838
creq->requested = false;
839+
atomic_set(&rcfw->rcfw_intr_enabled, 0);
799840
}
800841

801842
void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw)
@@ -857,6 +898,7 @@ int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector,
857898
creq->requested = true;
858899

859900
bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true);
901+
atomic_inc(&rcfw->rcfw_intr_enabled);
860902

861903
return 0;
862904
}

drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct bnxt_qplib_rcfw {
221221
u64 oos_prev;
222222
u32 init_oos_stats;
223223
u32 cmdq_depth;
224+
atomic_t rcfw_intr_enabled;
224225
struct semaphore rcfw_inflight;
225226
};
226227

0 commit comments

Comments
 (0)