Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp427341pxu; Thu, 26 Nov 2020 02:13:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfa3w+EYQDls5AJYFVdgFcQ5Qxn0mNWNHp6gM1+NgZrg7r14rbzvA+FnewjQpGTKr1tq/h X-Received: by 2002:a17:906:7cc6:: with SMTP id h6mr1926335ejp.161.1606385594240; Thu, 26 Nov 2020 02:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606385594; cv=none; d=google.com; s=arc-20160816; b=BhjNDZM+F/ouHnVdkOhn5A4+SQ+I7RArNuTu5Odymz6gJb16h7aFFFYQZ1u48G3MGu JKzqxDfNDKKm/1AztkETzMbZCXqW7jdOBxTZZjBhrNt5GucZkCbsLf8XvDqMfmsMNEZW bH1IsjIABHZefFba8xc2JdJaPiE3q7OhVmePUJPXBDoDzAf2S1xG24tHn1wONPW/olZC po6NbKUxecdEptspBACyV+nAQWOlkBVQm4E+4IxeE/+AYkhQ+Dm8sTxarkyLs/mXqkuX OJV9+eULiqFtXp22dyUkFXlMAjOmHEjrzWchOO6H2nJdbjQdTRq1BboNx9ajvkiwNGy0 YkAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jNTJvyt08Y9neqQZ7rWHW9zICRLbDmkFoEnlJ8oMAoU=; b=TQlghKv9iYcTZHI9EQc7oRVYOOofC8zU4NsZ+/6dk1xizu1AqDB87w7U2nTzl6Ubrr 5h+5q8rx6oq+Nr4aAnpiv6VxkP9tcSqL4Ur4AX1J0HtRHGmhV7AgEKaLGgXZmh/mIRjq mbYXAjP1/RE6QFE9j3I15pLWZxXchoiHejI0F4InOiWRUaOSL9h30dM9pVa4tUw7NDQs yvmWEnLOiBxIzt9eTJ7gT3biNbOmWhq9Mdg6wki87aKVluawANyn2GBSP6Dkjw3VfDfR XU3DzXfz+6Q82YNCdfi/TUXCOlqnSl3ShlMGaepJDMAn9fInahaxPO9joZIimpwT7RQt yJTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oTPKkC6T; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si2843758ejs.692.2020.11.26.02.12.50; Thu, 26 Nov 2020 02:13:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oTPKkC6T; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388298AbgKZHJh (ORCPT + 99 others); Thu, 26 Nov 2020 02:09:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:39402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732858AbgKZHJg (ORCPT ); Thu, 26 Nov 2020 02:09:36 -0500 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A9E8C2173E; Thu, 26 Nov 2020 07:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606374575; bh=gYDXlgsZWpJlTH5IBwMhLQhIJLkIkRHpENlBolMjrRQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oTPKkC6TsVMIEnC/CTomrBg//U4TJzkVKLZPJezjAholGF4ySAZnGaUHA5d8iBdkH pOgLmXiZL3XKYShAZJ36hwsdMJjtLl6CnIlCopNshGNVWqQr/si1E7f5JAixsvJMTi LDbTVjIeDjcJKPwMd1qLQuCtLnn67y/oEgOWeplg= Received: by mail-ot1-f49.google.com with SMTP id n12so1097281otk.0; Wed, 25 Nov 2020 23:09:35 -0800 (PST) X-Gm-Message-State: AOAM532/jdB2J5DKHuulFG4y0Yg7zI+BeCs5rEJGe9c5VvR16JbLaHPq Fn24QWVVA4W1iURtPjnO0RlsnsKnKb7J9A4PU9o= X-Received: by 2002:a9d:62c1:: with SMTP id z1mr1486485otk.108.1606374574919; Wed, 25 Nov 2020 23:09:34 -0800 (PST) MIME-Version: 1.0 References: <20201125211311.2179-1-iuliana.prodan@oss.nxp.com> <20b1493d-bfb6-d0bc-3b73-740b216db5f2@nxp.com> In-Reply-To: <20b1493d-bfb6-d0bc-3b73-740b216db5f2@nxp.com> From: Ard Biesheuvel Date: Thu, 26 Nov 2020 08:09:23 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag To: Iuliana Prodan Cc: "Iuliana Prodan (OSS)" , Herbert Xu , Ard Biesheuvel , "David S. Miller" , Horia Geanta , Aymen Sghaier , Silvano Di Ninno , Franck Lenormand , Linux Crypto Mailing List , Linux Kernel Mailing List , linux-imx Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, 25 Nov 2020 at 22:39, Iuliana Prodan wrote: > > On 11/25/2020 11:16 PM, Ard Biesheuvel wrote: > > On Wed, 25 Nov 2020 at 22:14, Iuliana Prodan (OSS) > > wrote: > >> > >> From: Iuliana Prodan > >> > >> Add the option to allocate the crypto request object plus any extra space > >> needed by the driver into a DMA-able memory. > >> > >> Add CRYPTO_TFM_REQ_DMA flag to be used by backend implementations to > >> indicate to crypto API the need to allocate GFP_DMA memory > >> for private contexts of the crypto requests. > >> > > > > These are always directional DMA mappings, right? So why can't we use > > bounce buffering here? > > > The idea was to avoid allocating any memory in crypto drivers. > We want to be able to use dm-crypt with CAAM, which needs DMA-able > memory and increasing reqsize is not enough. But what does 'needs DMA-able memory' mean? DMA operations are asynchronous by definition, and so the DMA layer should be able to allocate bounce buffers when needed. This will cost some performance in cases where the hardware cannot address all of memory directly, but this is a consequence of the design, and I don't think we should burden the generic API with this. > It started from here > https://lore.kernel.org/linux-crypto/71b6f739-d4a8-8b26-bf78-ce9acf9a0f99@nxp.com/T/#m39684173a2f0f4b83d8bcbec223e98169273d1e4 > > >> For IPsec use cases, CRYPTO_TFM_REQ_DMA flag is also checked in > >> esp_alloc_tmp() function for IPv4 and IPv6. > >> > >> This series includes an example of how a driver can use > >> CRYPTO_TFM_REQ_DMA flag while setting reqsize to a larger value > >> to avoid allocating memory at crypto request runtime. > >> The extra size needed by the driver is added to the reqsize field > >> that indicates how much memory could be needed per request. > >> > >> Iuliana Prodan (4): > >> crypto: add CRYPTO_TFM_REQ_DMA flag > >> net: esp: check CRYPTO_TFM_REQ_DMA flag when allocating crypto request > >> crypto: caam - avoid allocating memory at crypto request runtime for > >> skcipher > >> crypto: caam - avoid allocating memory at crypto request runtime for > >> aead > >> > >> drivers/crypto/caam/caamalg.c | 130 +++++++++++++++++++++++++--------- > >> include/crypto/aead.h | 4 ++ > >> include/crypto/akcipher.h | 21 ++++++ > >> include/crypto/hash.h | 4 ++ > >> include/crypto/skcipher.h | 4 ++ > >> include/linux/crypto.h | 1 + > >> net/ipv4/esp4.c | 7 +- > >> net/ipv6/esp6.c | 7 +- > >> 8 files changed, 144 insertions(+), 34 deletions(-) > >> > >> -- > >> 2.17.1 > >>