From patchwork Fri Jan 20 05:41:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 9527387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F120D60113 for ; Fri, 20 Jan 2017 05:42:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA7E28527 for ; Fri, 20 Jan 2017 05:42:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D157128642; Fri, 20 Jan 2017 05:42:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59A9228527 for ; Fri, 20 Jan 2017 05:42:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cURxW-0001hZ-4h; Fri, 20 Jan 2017 05:41:58 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cURxR-0001XP-0x; Fri, 20 Jan 2017 05:41:54 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1026605358; Fri, 20 Jan 2017 13:41:27 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Fri, 20 Jan 2017 13:41:26 +0800 From: Ryder Lee To: Herbert Xu , "David S. Miller" Subject: [PATCH 4/8] crypto: mediatek - rework crypto request completion Date: Fri, 20 Jan 2017 13:41:11 +0800 Message-ID: <1484890875-57105-5-git-send-email-ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484890875-57105-1-git-send-email-ryder.lee@mediatek.com> References: <1484890875-57105-1-git-send-email-ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170119_214153_247156_120B1664 X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryder Lee , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces a new callback 'resume' in the struct mtk_aes_rec. This callback is run to resume/complete the processing of the crypto request when woken up by AES interrupts when DMA completion. This callback will help implementing the GCM mode support in further patches. Signed-off-by: Ryder Lee --- drivers/crypto/mediatek/mtk-aes.c | 25 +++++++++++++------------ drivers/crypto/mediatek/mtk-platform.h | 3 +++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 7e5a8e0..9c4e468 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -406,6 +406,15 @@ static int mtk_aes_handle_queue(struct mtk_cryp *cryp, u8 id, return ctx->start(cryp, aes); } +static int mtk_aes_complete(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) +{ + aes->flags &= ~AES_FLAGS_BUSY; + aes->areq->complete(aes->areq, 0); + + /* Handle new request */ + return mtk_aes_handle_queue(cryp, aes->id, NULL); +} + static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) { struct ablkcipher_request *req = ablkcipher_request_cast(aes->areq); @@ -416,6 +425,8 @@ static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) rctx->mode &= AES_FLAGS_MODE_MSK; aes->flags = (aes->flags & ~AES_FLAGS_MODE_MSK) | rctx->mode; + aes->resume = mtk_aes_complete; + err = mtk_aes_map(cryp, aes, req->src, req->dst, req->nbytes); if (err) return err; @@ -458,16 +469,6 @@ static void mtk_aes_unmap(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) aes->buf, aes->total); } -static inline void mtk_aes_complete(struct mtk_cryp *cryp, - struct mtk_aes_rec *aes) -{ - aes->flags &= ~AES_FLAGS_BUSY; - aes->areq->complete(aes->areq, 0); - - /* Handle new request */ - mtk_aes_handle_queue(cryp, aes->id, NULL); -} - /* Check and set the AES key to transform state buffer */ static int mtk_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, u32 keylen) @@ -591,7 +592,7 @@ static void mtk_aes_enc_task(unsigned long data) struct mtk_aes_rec *aes = cryp->aes[0]; mtk_aes_unmap(cryp, aes); - mtk_aes_complete(cryp, aes); + aes->resume(cryp, aes); } static void mtk_aes_dec_task(unsigned long data) @@ -600,7 +601,7 @@ static void mtk_aes_dec_task(unsigned long data) struct mtk_aes_rec *aes = cryp->aes[1]; mtk_aes_unmap(cryp, aes); - mtk_aes_complete(cryp, aes); + aes->resume(cryp, aes); } static irqreturn_t mtk_aes_enc_irq(int irq, void *dev_id) diff --git a/drivers/crypto/mediatek/mtk-platform.h b/drivers/crypto/mediatek/mtk-platform.h index 9f5210c..36d166b 100644 --- a/drivers/crypto/mediatek/mtk-platform.h +++ b/drivers/crypto/mediatek/mtk-platform.h @@ -131,6 +131,7 @@ struct mtk_aes_dma { * @dst: the structure that holds destination sg list info * @aligned_sg: the scatter list is use to alignment * @real_dst: pointer to the destination sg list + * @resume: pointer to resume function * @total: request buffer length * @buf: pointer to page buffer * @id: record identification @@ -150,6 +151,8 @@ struct mtk_aes_rec { struct scatterlist aligned_sg; struct scatterlist *real_dst; + mtk_aes_fn resume; + size_t total; void *buf;