From patchwork Fri Nov 25 04:36:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 25815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3768231wrr; Thu, 24 Nov 2022 20:49:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7zUR4QvIt72sX2ep+4rJbY1xaRZiriJlIBjATfgRB6nM5lnxAi1gLUuQdQeyHsu9+qUYBN X-Received: by 2002:a05:6a00:18a9:b0:572:6da6:218e with SMTP id x41-20020a056a0018a900b005726da6218emr17240833pfh.1.1669351781540; Thu, 24 Nov 2022 20:49:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669351781; cv=none; d=google.com; s=arc-20160816; b=HBfWPveaXicDDAxBMg1JA92Z3MoYKCNbWC6TQUvrM4FuM8iLnAGfboU45yu3btiQ/y qMCA60CT4R4H4SlbDvJAK6+rAB9OQVlAu0KJKGgvn0rlNWqQpF41gCtJ509AkPwHlClv JOf8sNyGKb15TxK4v9mUiUvriazLuNGKOUi8lULUIE8tvjGswsw1Te5WxWd9hCmTdOjG tI3AdsuismsY1iZue7lGcCA23qYTOfUoyss2rSY1ki1IOZFZT3yZcRuKzK5FHZv3d+gI LH1acDxmyM+bbKcFV/mXZCSQEQP/W3WpdPYzgWcr+DlO9HLQMvBknCcx2UZoswf6usXQ r8lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:to:references:subject:date:from; bh=bpHlNYxZvm9whxIrcVZ39H+7QS5Xt9rGAmz9F1hiPS4=; b=N8oumKY1vbMYaxzqSnDLwZPtviN9d6SDwWrPiI2ivq/7MspFw66/5bSCkahHWoKmoz RaAG90GpN8zchxWHDvtytmLTY0lDu/E8jIpaxct1g/gEhQqHBzNkM26dCi1NYcRRshb5 oF+TvTV3CFdnTmSczrfb7uyOPK1BHkAQpZuWJcgK4COLQUFeC5ZB+BQVTKliU4PyHcgp Tfe0hPqLPhbv4vRm50VIE+0HuBZTZZM1lQsxJqCyog4yd/eWd5gY5sgJietqmOPdO/St KEN+iML3BQ5VFHMZfPY61O5UKRnntQ1JF/9NuRpDABQ1jNNlUuunfTZ3JzNC1tpkUqP/ ErQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a170902c94900b00186b76f4655si2914740pla.358.2022.11.24.20.49.24; Thu, 24 Nov 2022 20:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbiKYEht (ORCPT + 99 others); Thu, 24 Nov 2022 23:37:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiKYEhB (ORCPT ); Thu, 24 Nov 2022 23:37:01 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1760927B00; Thu, 24 Nov 2022 20:36:56 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1oyQSB-000dkk-LW; Fri, 25 Nov 2022 12:36:44 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 25 Nov 2022 12:36:43 +0800 From: "Herbert Xu" Date: Fri, 25 Nov 2022 12:36:43 +0800 Subject: [v2 PATCH 8/9] crypto: kpp - Add ctx helpers with DMA alignment References: To: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Linux Memory Management List , Linux ARM , Linux Kernel Mailing List , "David S. Miller" , Linux Crypto Mailing List Message-Id: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750442213605119422?= X-GMAIL-MSGID: =?utf-8?q?1750442213605119422?= This patch adds helpers to access the kpp context structure and request context structure with an added alignment for DMA access. Signed-off-by: Herbert Xu --- include/crypto/internal/kpp.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/include/crypto/internal/kpp.h b/include/crypto/internal/kpp.h index 167662407e36..3c9726e89f53 100644 --- a/include/crypto/internal/kpp.h +++ b/include/crypto/internal/kpp.h @@ -50,15 +50,37 @@ static inline void *kpp_request_ctx(struct kpp_request *req) return req->__ctx; } +static inline void *kpp_request_ctx_dma(struct kpp_request *req) +{ + unsigned int align = crypto_dma_align(); + + if (align <= crypto_tfm_ctx_alignment()) + align = 1; + + return PTR_ALIGN(kpp_request_ctx(req), align); +} + static inline void kpp_set_reqsize(struct crypto_kpp *kpp, unsigned int reqsize) { kpp->reqsize = reqsize; } +static inline void kpp_set_reqsize_dma(struct crypto_kpp *kpp, + unsigned int reqsize) +{ + reqsize += crypto_dma_align() & ~(crypto_tfm_ctx_alignment() - 1); + kpp->reqsize = reqsize; +} + static inline void *kpp_tfm_ctx(struct crypto_kpp *tfm) { - return tfm->base.__crt_ctx; + return crypto_tfm_ctx(&tfm->base); +} + +static inline void *kpp_tfm_ctx_dma(struct crypto_kpp *tfm) +{ + return crypto_tfm_ctx_dma(&tfm->base); } static inline void kpp_request_complete(struct kpp_request *req, int err)