From: Corentin Labbe <clabbe.montjoie@gmail.com>
To: Kalyani Akula <kalyani.akula@xilinx.com>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Kalyani Akula <kalyania@xilinx.com>,
Sarat Chand Savitala <saratcha@xilinx.com>
Subject: Re: [RFC PATCH V2 3/4] crypto: Add Xilinx SHA3 driver
Date: Thu, 10 Jan 2019 14:57:57 +0100 [thread overview]
Message-ID: <20190110135757.GA32218@Red> (raw)
In-Reply-To: <1547025985-7228-4-git-send-email-kalyani.akula@xilinx.com>
On Wed, Jan 09, 2019 at 02:56:24PM +0530, Kalyani Akula wrote:
> This patch adds SHA3 driver support for the Xilinx
> ZynqMP SoC.
>
> Signed-off-by: Kalyani Akula <kalyani.akula@xilinx.com>
> ---
> drivers/crypto/Kconfig | 10 ++
> drivers/crypto/Makefile | 1 +
> drivers/crypto/zynqmp-sha.c | 305 +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 316 insertions(+), 0 deletions(-)
> create mode 100644 drivers/crypto/zynqmp-sha.c
Hello
I have some comment below
> +static int zynqmp_sha_update(struct ahash_request *req)
> +{
> + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();
> + struct zynqmp_sha_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
> + struct zynqmp_sha_dev *dd = tctx->dd;
> + size_t dma_size = req->nbytes;
> + dma_addr_t dma_addr;
> + char *kbuf;
> + int ret;
> +
> + if (!req->nbytes)
> + return 0;
> +
> + if (!eemi_ops || !eemi_ops->sha_hash)
> + return -ENOTSUPP;
> +
> + kbuf = dma_alloc_coherent(dd->dev, dma_size, &dma_addr, GFP_KERNEL);
> + if (!kbuf)
> + return -ENOMEM;
> +
> + scatterwalk_map_and_copy(kbuf, req->src, 0, req->nbytes, 0);
> + __flush_cache_user_range((unsigned long)kbuf,
> + (unsigned long)kbuf + dma_size);
Since kbuf is in dma coherent memory, I dont understand why do you flush cache.
> + ret = eemi_ops->sha_hash(dma_addr, req->nbytes, ZYNQMP_SHA3_UPDATE);
> + dma_free_coherent(dd->dev, dma_size, kbuf, dma_addr);
Since your update function does not return/write any result, I suppose that the resulat is kept in hardware, so what happen if two hash process happen in parallel ?
Furthermore, how do you have tested import/export function ?
Anyway, I am sure they are totally buggy.
> +
> + return ret;
> +}
> +
> +static int zynqmp_sha_final(struct ahash_request *req)
> +{
> + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();
> + struct zynqmp_sha_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
> + struct zynqmp_sha_dev *dd = tctx->dd;
> + size_t dma_size = SHA384_DIGEST_SIZE;
> + dma_addr_t dma_addr;
> + char *kbuf;
> + int ret;
> +
> + if (!eemi_ops || !eemi_ops->sha_hash)
> + return -ENOTSUPP;
You can do this check at probe time.
> +static int zynqmp_sha_finup(struct ahash_request *req)
> +{
> + zynqmp_sha_update(req);
> + zynqmp_sha_final(req);
> +
> + return 0;
> +}
> +
> +static int zynqmp_sha_digest(struct ahash_request *req)
> +{
> + zynqmp_sha_init(req);
> + zynqmp_sha_update(req);
> + zynqmp_sha_final(req);
> +
> + return 0;
> +}
So you ignore the return value of zynqmp_sha_init/zynqmp_sha_update/zynqmp_sha_final().
> +static int zynqmp_sha_probe(struct platform_device *pdev)
> +{
> + struct zynqmp_sha_dev *sha_dd;
> + struct device *dev = &pdev->dev;
> + int err;
> +
> + sha_dd = devm_kzalloc(&pdev->dev, sizeof(*sha_dd), GFP_KERNEL);
> + if (!sha_dd)
> + return -ENOMEM;
> +
> + sha_dd->dev = dev;
> + platform_set_drvdata(pdev, sha_dd);
> + INIT_LIST_HEAD(&sha_dd->list);
> + spin_lock_init(&sha_dd->lock);
> + crypto_init_queue(&sha_dd->queue, ZYNQMP_SHA_QUEUE_LENGTH);
As already said in my last review, why init the queue if you do not use it ?
> + spin_lock(&zynqmp_sha.lock);
> + list_add_tail(&sha_dd->list, &zynqmp_sha.dev_list);
> + spin_unlock(&zynqmp_sha.lock);
Why do you maintain a device list ?
Clearly your current driver support only one hardware instance.
Regards
next prev parent reply other threads:[~2019-01-10 13:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 9:26 [RFC PATCH V2 0/4] Add Xilinx's ZynqMP SHA3 driver support Kalyani Akula
2019-01-09 9:26 ` [RFC PATCH V2 1/4] dt-bindings: crypto: Add bindings for ZynqMP SHA3 driver Kalyani Akula
2019-01-09 9:26 ` [RFC PATCH V2 2/4] firmware: xilinx: Add ZynqMP sha_hash API for SHA3 functionality Kalyani Akula
2019-01-09 9:26 ` [RFC PATCH V2 3/4] crypto: Add Xilinx SHA3 driver Kalyani Akula
2019-01-10 13:57 ` Corentin Labbe [this message]
2019-04-22 6:47 ` Kalyani Akula
2019-01-09 9:26 ` [RFC PATCH V2 4/4] ARM64: zynqmp: Add Xilinix SHA-384 node Kalyani Akula
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=20190110135757.GA32218@Red \
--to=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kalyani.akula@xilinx.com \
--cc=kalyania@xilinx.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=saratcha@xilinx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.