Skip to content

Commit 2157e50

Browse files
Bharat Bhushanherbertx
authored andcommitted
crypto: octeontx2 - add timeout for load_fvc completion poll
Adds timeout to exit from possible infinite loop, which polls on CPT instruction(load_fvc) completion. Signed-off-by: Srujana Challa <schalla@marvell.com> Signed-off-by: Bharat Bhushan <bbhushan2@marvell.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 0e801fe commit 2157e50

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,7 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf)
14941494
dma_addr_t rptr_baddr;
14951495
struct pci_dev *pdev;
14961496
u32 len, compl_rlen;
1497+
int timeout = 10000;
14971498
int ret, etype;
14981499
void *rptr;
14991500

@@ -1554,16 +1555,27 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf)
15541555
etype);
15551556
otx2_cpt_fill_inst(&inst, &iq_cmd, rptr_baddr);
15561557
lfs->ops->send_cmd(&inst, 1, &cptpf->lfs.lf[0]);
1558+
timeout = 10000;
15571559

15581560
while (lfs->ops->cpt_get_compcode(result) ==
1559-
OTX2_CPT_COMPLETION_CODE_INIT)
1561+
OTX2_CPT_COMPLETION_CODE_INIT) {
15601562
cpu_relax();
1563+
udelay(1);
1564+
timeout--;
1565+
if (!timeout) {
1566+
ret = -ENODEV;
1567+
cptpf->is_eng_caps_discovered = false;
1568+
dev_warn(&pdev->dev, "Timeout on CPT load_fvc completion poll\n");
1569+
goto error_no_response;
1570+
}
1571+
}
15611572

15621573
cptpf->eng_caps[etype].u = be64_to_cpup(rptr);
15631574
}
1564-
dma_unmap_single(&pdev->dev, rptr_baddr, len, DMA_BIDIRECTIONAL);
15651575
cptpf->is_eng_caps_discovered = true;
15661576

1577+
error_no_response:
1578+
dma_unmap_single(&pdev->dev, rptr_baddr, len, DMA_BIDIRECTIONAL);
15671579
free_result:
15681580
kfree(result);
15691581
lf_cleanup:

0 commit comments

Comments
 (0)