Skip to content

Commit

Permalink
crypto: caam - determine whether CAAM supports blob encap/decap
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Michael Walle <[email protected]>
Tested-by: Michael Walle <[email protected]> # on ls1028a (non-E and E)
Signed-off-by: Ahmad Fatoum <[email protected]>
Reviewed-by: Pankaj Gupta <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
  • Loading branch information
a3f authored and jarkkojs committed May 23, 2022
1 parent fcd7c26 commit 7a0e7d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions drivers/crypto/caam/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,25 @@ static int caam_probe(struct platform_device *pdev)
return -ENOMEM;
}

if (ctrlpriv->era < 10)
comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ls);
ctrlpriv->blob_present = !!(comp_params & CTPR_LS_BLOB);

/*
* Some SoCs like the LS1028A (non-E) indicate CTPR_LS_BLOB support,
* but fail when actually using it due to missing AES support, so
* check both here.
*/
if (ctrlpriv->era < 10) {
rng_vid = (rd_reg32(&ctrl->perfmon.cha_id_ls) &
CHA_ID_LS_RNG_MASK) >> CHA_ID_LS_RNG_SHIFT;
else
ctrlpriv->blob_present = ctrlpriv->blob_present &&
(rd_reg32(&ctrl->perfmon.cha_num_ls) & CHA_ID_LS_AES_MASK);
} else {
rng_vid = (rd_reg32(&ctrl->vreg.rng) & CHA_VER_VID_MASK) >>
CHA_VER_VID_SHIFT;
ctrlpriv->blob_present = ctrlpriv->blob_present &&
(rd_reg32(&ctrl->vreg.aesa) & CHA_VER_MISC_AES_NUM_MASK);
}

/*
* If SEC has RNG version >= 4 and RNG state handle has not been
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/caam/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct caam_drv_private {
*/
u8 total_jobrs; /* Total Job Rings in device */
u8 qi_present; /* Nonzero if QI present in device */
u8 blob_present; /* Nonzero if BLOB support present in device */
u8 mc_en; /* Nonzero if MC f/w is active */
int secvio_irq; /* Security violation interrupt number */
int virt_en; /* Virtualization enabled in CAAM */
Expand Down
4 changes: 3 additions & 1 deletion drivers/crypto/caam/regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ struct version_regs {
#define CHA_VER_VID_MASK (0xffull << CHA_VER_VID_SHIFT)

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

/* CHA Miscellaneous Information - PKHA_MISC specific */
#define CHA_VER_MISC_PKHA_NO_CRYPT BIT(7 + CHA_VER_MISC_SHIFT)
Expand Down Expand Up @@ -414,6 +415,7 @@ struct caam_perfmon {
#define CTPR_MS_PG_SZ_MASK 0x10
#define CTPR_MS_PG_SZ_SHIFT 4
u32 comp_parms_ms; /* CTPR - Compile Parameters Register */
#define CTPR_LS_BLOB BIT(1)
u32 comp_parms_ls; /* CTPR - Compile Parameters Register */
u64 rsvd1[2];

Expand Down

0 comments on commit 7a0e7d5

Please sign in to comment.