Skip to content

Commit 7a0e7d5

Browse files
a3fjarkkojs
authored andcommitted
crypto: caam - determine whether CAAM supports blob encap/decap
Depending on SoC variant, a CAAM may be available, but with some futures fused out. The LS1028A (non-E) SoC is one such SoC and while it indicates BLOB support, BLOB operations will ultimately fail, because there is no AES support. Add a new blob_present member to reflect whether both BLOB support and the AES support it depends on is available. These will be used in a follow-up commit to allow blob driver initialization to error out on SoCs without the necessary hardware support instead of failing at runtime with a cryptic caam_jr 8020000.jr: 20000b0f: CCB: desc idx 11: : Invalid CHA selected. Co-developed-by: Michael Walle <michael@walle.cc> Signed-off-by: Michael Walle <michael@walle.cc> Tested-by: Michael Walle <michael@walle.cc> # on ls1028a (non-E and E) Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Pankaj Gupta <pankaj.gupta@nxp.com> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent fcd7c26 commit 7a0e7d5

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

drivers/crypto/caam/ctrl.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,25 @@ static int caam_probe(struct platform_device *pdev)
820820
return -ENOMEM;
821821
}
822822

823-
if (ctrlpriv->era < 10)
823+
comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ls);
824+
ctrlpriv->blob_present = !!(comp_params & CTPR_LS_BLOB);
825+
826+
/*
827+
* Some SoCs like the LS1028A (non-E) indicate CTPR_LS_BLOB support,
828+
* but fail when actually using it due to missing AES support, so
829+
* check both here.
830+
*/
831+
if (ctrlpriv->era < 10) {
824832
rng_vid = (rd_reg32(&ctrl->perfmon.cha_id_ls) &
825833
CHA_ID_LS_RNG_MASK) >> CHA_ID_LS_RNG_SHIFT;
826-
else
834+
ctrlpriv->blob_present = ctrlpriv->blob_present &&
835+
(rd_reg32(&ctrl->perfmon.cha_num_ls) & CHA_ID_LS_AES_MASK);
836+
} else {
827837
rng_vid = (rd_reg32(&ctrl->vreg.rng) & CHA_VER_VID_MASK) >>
828838
CHA_VER_VID_SHIFT;
839+
ctrlpriv->blob_present = ctrlpriv->blob_present &&
840+
(rd_reg32(&ctrl->vreg.aesa) & CHA_VER_MISC_AES_NUM_MASK);
841+
}
829842

830843
/*
831844
* If SEC has RNG version >= 4 and RNG state handle has not been

drivers/crypto/caam/intern.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct caam_drv_private {
9292
*/
9393
u8 total_jobrs; /* Total Job Rings in device */
9494
u8 qi_present; /* Nonzero if QI present in device */
95+
u8 blob_present; /* Nonzero if BLOB support present in device */
9596
u8 mc_en; /* Nonzero if MC f/w is active */
9697
int secvio_irq; /* Security violation interrupt number */
9798
int virt_en; /* Virtualization enabled in CAAM */

drivers/crypto/caam/regs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ struct version_regs {
320320
#define CHA_VER_VID_MASK (0xffull << CHA_VER_VID_SHIFT)
321321

322322
/* CHA Miscellaneous Information - AESA_MISC specific */
323-
#define CHA_VER_MISC_AES_GCM BIT(1 + CHA_VER_MISC_SHIFT)
323+
#define CHA_VER_MISC_AES_NUM_MASK GENMASK(7, 0)
324+
#define CHA_VER_MISC_AES_GCM BIT(1 + CHA_VER_MISC_SHIFT)
324325

325326
/* CHA Miscellaneous Information - PKHA_MISC specific */
326327
#define CHA_VER_MISC_PKHA_NO_CRYPT BIT(7 + CHA_VER_MISC_SHIFT)
@@ -414,6 +415,7 @@ struct caam_perfmon {
414415
#define CTPR_MS_PG_SZ_MASK 0x10
415416
#define CTPR_MS_PG_SZ_SHIFT 4
416417
u32 comp_parms_ms; /* CTPR - Compile Parameters Register */
418+
#define CTPR_LS_BLOB BIT(1)
417419
u32 comp_parms_ls; /* CTPR - Compile Parameters Register */
418420
u64 rsvd1[2];
419421

0 commit comments

Comments
 (0)