Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: octeontx2 - CN10K CPT to RNM workaround

When software sets CPT_AF_CTL[RNM_REQ_EN]=1 and RNM in not producing
entropy(i.e., RNM_ENTROPY_STATUS[NORMAL_CNT] < 0x40), the first cycle of
the response may be lost due to a conditional clocking issue. Due to
this, the subsequent random number stream will be corrupted. So, this
patch adds support to ensure RNM_ENTROPY_STATUS[NORMAL_CNT] = 0x40
before writing CPT_AF_CTL[RNM_REQ_EN] = 1, as a workaround.

Signed-off-by: Srujana Challa <schalla@marvell.com>
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Srujana Challa and committed by
Herbert Xu
bd9305b0 f4f7c153

+42 -1
+42 -1
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
··· 1076 1076 delete_engine_group(&pdev->dev, &eng_grps->grp[i]); 1077 1077 } 1078 1078 1079 + #define PCI_DEVID_CN10K_RNM 0xA098 1080 + #define RNM_ENTROPY_STATUS 0x8 1081 + 1082 + static void rnm_to_cpt_errata_fixup(struct device *dev) 1083 + { 1084 + struct pci_dev *pdev; 1085 + void __iomem *base; 1086 + int timeout = 5000; 1087 + 1088 + pdev = pci_get_device(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN10K_RNM, NULL); 1089 + if (!pdev) 1090 + return; 1091 + 1092 + base = pci_ioremap_bar(pdev, 0); 1093 + if (!base) 1094 + goto put_pdev; 1095 + 1096 + while ((readq(base + RNM_ENTROPY_STATUS) & 0x7F) != 0x40) { 1097 + cpu_relax(); 1098 + udelay(1); 1099 + timeout--; 1100 + if (!timeout) { 1101 + dev_warn(dev, "RNM is not producing entropy\n"); 1102 + break; 1103 + } 1104 + } 1105 + 1106 + iounmap(base); 1107 + 1108 + put_pdev: 1109 + pci_dev_put(pdev); 1110 + } 1111 + 1079 1112 int otx2_cpt_get_eng_grp(struct otx2_cpt_eng_grps *eng_grps, int eng_type) 1080 1113 { 1081 1114 ··· 1222 1189 1223 1190 if (is_dev_otx2(pdev)) 1224 1191 goto unlock; 1192 + 1193 + /* 1194 + * Ensure RNM_ENTROPY_STATUS[NORMAL_CNT] = 0x40 before writing 1195 + * CPT_AF_CTL[RNM_REQ_EN] = 1 as a workaround for HW errata. 1196 + */ 1197 + rnm_to_cpt_errata_fixup(&pdev->dev); 1198 + 1225 1199 /* 1226 1200 * Configure engine group mask to allow context prefetching 1227 - * for the groups. 1201 + * for the groups and enable random number request, to enable 1202 + * CPT to request random numbers from RNM. 1228 1203 */ 1229 1204 otx2_cpt_write_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, 1230 1205 OTX2_CPT_ALL_ENG_GRPS_MASK << 3 | BIT_ULL(16),