Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3382373imu; Mon, 7 Jan 2019 02:16:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/W2Ic7wKwHmjFG0dIuKvcXB95m1W9cpTivjwqPlhdZzDjn8k0bXo11GNwMyaTgDlj1D7F7b X-Received: by 2002:a62:4bcf:: with SMTP id d76mr65147670pfj.170.1546856165637; Mon, 07 Jan 2019 02:16:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546856165; cv=none; d=google.com; s=arc-20160816; b=JR6zMdffAtTLPOr7rkOyf9ntzv429FRoQCPabjR7Ul+fjFELfX7t0dWcKqnzZC+daF D43V0KHjwARmt9gE1YXZADAE08NggytZ6fHbVDl2E0AflEy1TL+CXB/DDRqPtQWBJLCI +nalzbQ0hLtS5mlgGEfa1nDA05+Zwcf+tADkhGmQ4JJSHW1jFVFuW9usxecSMxuA4eRJ YeCmWdYszNPV9oLG6a35X/Mh9WJlx8Go9jO0/y7vpxrGEJwQl9AfsIrfZ87eJknZWPt3 kw3xJEXRLaIBpvTv8Org4Wcci6m+3Eb0IsnKkMXuYWxJiRkRpkBUFni/zNMG+nnIFR+A u7yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bu0nFXgfRIpl1d7qh46UAqgGnDv6CoRNmpsbwlwwmQY=; b=OogWs+VO+HblNDYjHsS88Qry2ZxaNJe4mQYWMdH+Az4iwe4c1eHRbpQji1Qp7JqGCh s5sLP0qiNEex2rYtrIOZiV5ep4CzdNLwxFe8WsCjmMM66oqhh2oKhR3tmTuivatvzFc1 m08WB1Zvmfys5rkZ3xtGOQDYp4sJ8mKXHztoesNuMqcHovRHzXM4Zi+Au//ba8O5rdc4 9wwawISTDR0FTHRcUh7h+6z3prlZ/4HZEl+3b1yGLU67JvGUdnjcvqVFbm/sjlp6ZRC5 h9jwzGZ+1TIeBtMVeQhZdVomcq0JKDzIjzou5Qz32DDil0+U0TvxznnvBofCKP9dPLFz 3+Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IPq8R0xS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h36si42551184pgm.200.2019.01.07.02.15.48; Mon, 07 Jan 2019 02:16:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IPq8R0xS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfAGKNT (ORCPT + 99 others); Mon, 7 Jan 2019 05:13:19 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:37198 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbfAGKNS (ORCPT ); Mon, 7 Jan 2019 05:13:18 -0500 Received: by mail-ed1-f65.google.com with SMTP id h15so326074edb.4; Mon, 07 Jan 2019 02:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bu0nFXgfRIpl1d7qh46UAqgGnDv6CoRNmpsbwlwwmQY=; b=IPq8R0xSHUGBW6GABvNlAJ8LylFX+iAU1PJDymJkVEpGl7PUIBjMu8C/sGjnBzCx1g 7HoMvHesWHVbWaaDQQNken+LWKH6i5n3YuO0O35SaJxq+lPNjCzuAArnJkadrQ2/kueo h3tQuWDg++qtpym19+LpAumq8Yzt1F2pe7UHmlnb6izYMtG+xBp/tuImDEOS8PuEh9on hc2wpfseeiSywTsBe1bEbdzhFP3vyWig3P/lbbc6I/A7e1DjLFvMrZSpx0wvBRHgxKBS yhc/0LxWbcSNZAQCHuwmfMZQibv5WvtYbjT9Yd/seGk8I/X5/7ZyGgdBXfx5Y9/BBjCG bGjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bu0nFXgfRIpl1d7qh46UAqgGnDv6CoRNmpsbwlwwmQY=; b=gf/OmK2YQFhyMF1rPW5DoNsWEP6fBZPgdxnxp6GvM1G8oPCs86UYdqjo4kl/JUHag6 l/aoQBDe+EIe891CNJ4A4foYDoVU5DUeCZqIyZMPfLILEoGjf8PZs8zMxqOcpTE7iLzT 4CrzsrWDZnhwoRmO/pVuwrY58BCRjU7WTcH2ic+OhSfPUKXqOtBs90voM4UBbIiw6TDe ptIhVwbZP8gzxK98zbrbrgqXNCSMfE1k15aFTbc7hhcpTYT7O0m1LBYiua0sIfrL+ZtW 0WPs5rewwsAVc5xeJqogtLfjKaIFHG/hDNR0Jsg4ZhVd5wV6DlruFD3LQBYL8riDZv4s /NXA== X-Gm-Message-State: AA+aEWZE78mgInT+zAVROFXcg444reX682vQ4I4xnUSbsWLuii7EO0lU /pvmdLZ1SZpPKTvyKrsRJoN867Ev X-Received: by 2002:a50:b744:: with SMTP id g62mr56233518ede.14.1546855996120; Mon, 07 Jan 2019 02:13:16 -0800 (PST) Received: from Red ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id r42sm30868056edd.23.2019.01.07.02.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 02:13:15 -0800 (PST) Date: Mon, 7 Jan 2019 11:13:13 +0100 From: Corentin Labbe To: Kalyani Akula Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Kalyani Akula , Sarat Chand Savitala Subject: Re: [RFC PATCH 2/3] crypto: Add Xilinx SHA3 driver Message-ID: <20190107101313.GA17747@Red> References: <1546851776-3456-1-git-send-email-kalyani.akula@xilinx.com> <1546851776-3456-3-git-send-email-kalyani.akula@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1546851776-3456-3-git-send-email-kalyani.akula@xilinx.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 07, 2019 at 02:32:55PM +0530, Kalyani Akula wrote: > This patch adds SHA3 driver suuport for the Xilinx > ZynqMP SoC. > > Signed-off-by: Kalyani Akula Hello I have some comment below > +static int zynqmp_sha_init(struct ahash_request *req) > +{ > + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); > + struct zynqmp_sha_reqctx *ctx = ahash_request_ctx(req); > + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); > + struct zynqmp_sha_ctx *tctx = crypto_ahash_ctx(tfm); > + struct zynqmp_sha_dev *dd = NULL; > + struct zynqmp_sha_dev *tmp; > + int ret; > + > + if (!eemi_ops || !eemi_ops->sha_hash) > + return -ENOTSUPP; > + Where can I find sha_hash() ? It seems that your serie miss some patchs. > + spin_lock_bh(&zynqmp_sha.lock); > + if (!tctx->dd) { > + list_for_each_entry(tmp, &zynqmp_sha.dev_list, list) { > + dd = tmp; > + break; > + } > + tctx->dd = dd; > + } else { > + dd = tctx->dd; > + } > + spin_unlock_bh(&zynqmp_sha.lock); > + > + ctx->dd = dd; > + dev_dbg(dd->dev, "init: digest size: %d\n", > + crypto_ahash_digestsize(tfm)); > + > + ret = eemi_ops->sha_hash(0, 0, ZYNQMP_SHA3_INIT); > + > + return ret; > +} > + > +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); > + ret = eemi_ops->sha_hash(dma_addr, req->nbytes, ZYNQMP_SHA3_UPDATE); Even with the sha_hash prototype missing, I think your driver have a problem: You support having more than one device, but sha_hash lacks any reference on the device doing the request. > +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; > + > + kbuf = dma_alloc_coherent(dd->dev, dma_size, &dma_addr, GFP_KERNEL); > + if (!kbuf) > + return -ENOMEM; > + > + ret = eemi_ops->sha_hash(dma_addr, dma_size, ZYNQMP_SHA3_FINAL); > + memcpy(req->result, kbuf, 48); It is better to use SHA384_DIGEST_SIZE instead of 48 [...] > +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); You create a queue, but you didnt use it. [...] > + spin_lock(&zynqmp_sha.lock); > + list_add_tail(&sha_dd->list, &zynqmp_sha.dev_list); > + spin_unlock(&zynqmp_sha.lock); > + > + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(44)); > + if (err < 0) > + dev_err(dev, "no usable DMA configuration"); It is an error that you ignore, you miss some goto errxxx. Regards