110-crypto-mxsdcp-provide-importexport.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From: Fabio Estevam <fabio.estevam@nxp.com>
  2. Currently the mxs-dcp driver fails to probe:
  3. mxs-dcp 80028000.dcp: Failed to register sha1 hash!
  4. mxs-dcp: probe of 80028000.dcp failed with error -22
  5. This happens since commit 8996eafdcbad ("crypto: ahash - ensure statesize
  6. is non-zero"), which requires statesize to be filled.
  7. Other than filling statesize, we also need to provide the import/export
  8. functions.
  9. Based on the implementation of the sahara and caam drivers.
  10. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
  11. ---
  12. Changes since v2:
  13. - Newly introduced in this series
  14. drivers/crypto/mxs-dcp.c | 24 ++++++++++++++++++++++++
  15. 1 file changed, 24 insertions(+)
  16. --- a/drivers/crypto/mxs-dcp.c
  17. +++ b/drivers/crypto/mxs-dcp.c
  18. @@ -775,6 +775,24 @@ static void dcp_sha_cra_exit(struct cryp
  19. {
  20. }
  21. +static int dcp_sha_export(struct ahash_request *req, void *out)
  22. +{
  23. + struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  24. +
  25. + memcpy(out, rctx, sizeof(struct dcp_sha_req_ctx));
  26. +
  27. + return 0;
  28. +}
  29. +
  30. +static int dcp_sha_import(struct ahash_request *req, const void *in)
  31. +{
  32. + struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  33. +
  34. + memcpy(rctx, in, sizeof(struct dcp_sha_req_ctx));
  35. +
  36. + return 0;
  37. +}
  38. +
  39. /* AES 128 ECB and AES 128 CBC */
  40. static struct crypto_alg dcp_aes_algs[] = {
  41. {
  42. @@ -834,8 +852,11 @@ static struct ahash_alg dcp_sha1_alg = {
  43. .final = dcp_sha_final,
  44. .finup = dcp_sha_finup,
  45. .digest = dcp_sha_digest,
  46. + .import = dcp_sha_import,
  47. + .export = dcp_sha_export,
  48. .halg = {
  49. .digestsize = SHA1_DIGEST_SIZE,
  50. + .statesize = sizeof(struct dcp_sha_req_ctx),
  51. .base = {
  52. .cra_name = "sha1",
  53. .cra_driver_name = "sha1-dcp",
  54. @@ -858,8 +879,11 @@ static struct ahash_alg dcp_sha256_alg =
  55. .final = dcp_sha_final,
  56. .finup = dcp_sha_finup,
  57. .digest = dcp_sha_digest,
  58. + .import = dcp_sha_import,
  59. + .export = dcp_sha_export,
  60. .halg = {
  61. .digestsize = SHA256_DIGEST_SIZE,
  62. + .statesize = sizeof(struct dcp_sha_req_ctx),
  63. .base = {
  64. .cra_name = "sha256",
  65. .cra_driver_name = "sha256-dcp",