From: Horia Geanta <horia.geanta@nxp.com>
To: Iuliana Prodan <iuliana.prodan@nxp.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Aymen Sghaier <aymen.sghaier@nxp.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Silvano Di Ninno <silvano.dininno@nxp.com>,
Franck Lenormand <franck.lenormand@nxp.com>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH v5 9/9] crypto: caam - add crypto_engine support for HASH algorithms
Date: Tue, 11 Feb 2020 12:25:49 +0000 [thread overview]
Message-ID: <VI1PR0402MB3485F2EA456432F03B2422FF98180@VI1PR0402MB3485.eurprd04.prod.outlook.com> (raw)
In-Reply-To: 1580345364-7606-10-git-send-email-iuliana.prodan@nxp.com
On 1/30/2020 2:49 AM, Iuliana Prodan wrote:
> @@ -123,6 +128,9 @@ struct caam_export_state {
> int (*update)(struct ahash_request *req);
> int (*final)(struct ahash_request *req);
> int (*finup)(struct ahash_request *req);
> + struct ahash_edesc *edesc;
> + void (*ahash_op_done)(struct device *jrdev, u32 *desc, u32 err,
> + void *context);
These members are used internally by the driver,
during ahash request processing.
They are recomputed each time a new request is received.
This means .import/.export callbacks don't have to deal with them.
> /* submit ahash update if it the first job descriptor after update */
> @@ -1209,9 +1280,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
> DUMP_PREFIX_ADDRESS, 16, 4, desc,
> desc_bytes(desc), 1);
>
> - ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> - if (ret != -EINPROGRESS)
> - goto unmap_ctx;
> + ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> + ctx->ctx_len, DMA_TO_DEVICE);
In case ahash_enqueue_req() fails, driver's callbacks state machine
changes since the code falls through.
>
> state->update = ahash_update_ctx;
> state->finup = ahash_finup_ctx;
> @@ -1394,9 +1459,8 @@ static int ahash_update_first(struct ahash_request *req)
> DUMP_PREFIX_ADDRESS, 16, 4, desc,
> desc_bytes(desc), 1);
>
> - ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> - if (ret != -EINPROGRESS)
> - goto unmap_ctx;
> + ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> + ctx->ctx_len, DMA_TO_DEVICE);
Same here.
>
> state->update = ahash_update_ctx;
> state->finup = ahash_finup_ctx;
> @@ -1752,7 +1820,9 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
> }
>
> dma_addr = dma_map_single_attrs(ctx->jrdev, ctx->sh_desc_update,
> - offsetof(struct caam_hash_ctx, key),
> + offsetof(struct caam_hash_ctx, key) -
> + offsetof(struct caam_hash_ctx,
> + sh_desc_update),
> ctx->dir, DMA_ATTR_SKIP_CPU_SYNC);
> if (dma_mapping_error(ctx->jrdev, dma_addr)) {
> dev_err(ctx->jrdev, "unable to map shared descriptors\n");
> @@ -1770,11 +1840,19 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
> ctx->sh_desc_update_dma = dma_addr;
> ctx->sh_desc_update_first_dma = dma_addr +
> offsetof(struct caam_hash_ctx,
> - sh_desc_update_first);
> + sh_desc_update_first) -
> + offsetof(struct caam_hash_ctx,
> + sh_desc_update);
> ctx->sh_desc_fin_dma = dma_addr + offsetof(struct caam_hash_ctx,
> - sh_desc_fin);
> + sh_desc_fin) -
> + offsetof(struct caam_hash_ctx,
> + sh_desc_update);
> ctx->sh_desc_digest_dma = dma_addr + offsetof(struct caam_hash_ctx,
> - sh_desc_digest);
> + sh_desc_digest) -
> + offsetof(struct caam_hash_ctx,
> + sh_desc_update);
offsetof(struct caam_hash_ctx, sh_desc_update) is used several times,
it deserves a local variable.
Horia
prev parent reply other threads:[~2020-02-11 12:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 0:49 [PATCH v5 0/9] crypto: caam - backlogging support Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 1/9] crypto: caam - refactor skcipher/aead/gcm/chachapoly {en,de}crypt functions Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 2/9] crypto: caam - refactor ahash_done callbacks Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 3/9] crypto: caam - refactor ahash_edesc_alloc Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 4/9] crypto: caam - refactor RSA private key _done callbacks Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 5/9] crypto: caam - change return code in caam_jr_enqueue function Iuliana Prodan
2020-01-30 0:49 ` [PATCH v5 6/9] crypto: caam - support crypto_engine framework for SKCIPHER algorithms Iuliana Prodan
2020-02-11 9:51 ` Horia Geanta
2020-01-30 0:49 ` [PATCH v5 7/9] crypto: caam - add crypto_engine support for AEAD algorithms Iuliana Prodan
2020-02-11 10:09 ` Horia Geanta
2020-01-30 0:49 ` [PATCH v5 8/9] crypto: caam - add crypto_engine support for RSA algorithms Iuliana Prodan
2020-02-11 10:23 ` Horia Geanta
2020-01-30 0:49 ` [PATCH v5 9/9] crypto: caam - add crypto_engine support for HASH algorithms Iuliana Prodan
2020-02-11 12:25 ` Horia Geanta [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=VI1PR0402MB3485F2EA456432F03B2422FF98180@VI1PR0402MB3485.eurprd04.prod.outlook.com \
--to=horia.geanta@nxp.com \
--cc=aymen.sghaier@nxp.com \
--cc=davem@davemloft.net \
--cc=franck.lenormand@nxp.com \
--cc=herbert@gondor.apana.org.au \
--cc=iuliana.prodan@nxp.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=silvano.dininno@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).