| From 5301f471d3069da0fa10a5ba3c0c7038e64f1ef8 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 22 May 2025 15:36:24 +0530 |
| Subject: crypto: octeontx2 - add timeout for load_fvc completion poll |
| |
| From: Bharat Bhushan <bbhushan2@marvell.com> |
| |
| [ Upstream commit 2157e50f65d2030f07ea27ef7ac4cfba772e98ac ] |
| |
| 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> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| .../crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 16 ++++++++++++++-- |
| 1 file changed, 14 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c |
| index 1958b797a421..682e7d80adb8 100644 |
| --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c |
| +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c |
| @@ -1485,6 +1485,7 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf) |
| dma_addr_t rptr_baddr; |
| struct pci_dev *pdev; |
| u32 len, compl_rlen; |
| + int timeout = 10000; |
| int ret, etype; |
| void *rptr; |
| |
| @@ -1547,16 +1548,27 @@ int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf) |
| etype); |
| otx2_cpt_fill_inst(&inst, &iq_cmd, rptr_baddr); |
| lfs->ops->send_cmd(&inst, 1, &cptpf->lfs.lf[0]); |
| + timeout = 10000; |
| |
| while (lfs->ops->cpt_get_compcode(result) == |
| - OTX2_CPT_COMPLETION_CODE_INIT) |
| + OTX2_CPT_COMPLETION_CODE_INIT) { |
| cpu_relax(); |
| + udelay(1); |
| + timeout--; |
| + if (!timeout) { |
| + ret = -ENODEV; |
| + cptpf->is_eng_caps_discovered = false; |
| + dev_warn(&pdev->dev, "Timeout on CPT load_fvc completion poll\n"); |
| + goto error_no_response; |
| + } |
| + } |
| |
| cptpf->eng_caps[etype].u = be64_to_cpup(rptr); |
| } |
| - dma_unmap_single(&pdev->dev, rptr_baddr, len, DMA_BIDIRECTIONAL); |
| cptpf->is_eng_caps_discovered = true; |
| |
| +error_no_response: |
| + dma_unmap_single(&pdev->dev, rptr_baddr, len, DMA_BIDIRECTIONAL); |
| free_result: |
| kfree(result); |
| lf_cleanup: |
| -- |
| 2.39.5 |
| |