Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2983552pxu; Mon, 7 Dec 2020 23:46:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/87Ewy/znq0GBRbooK+hduNP0Ko5iTz18ygUvtaVunb+L4ldieYd3jfcPNXXil2IbUWUJ X-Received: by 2002:a17:906:b56:: with SMTP id v22mr18327440ejg.145.1607413562762; Mon, 07 Dec 2020 23:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607413562; cv=none; d=google.com; s=arc-20160816; b=I458h/DWZ9R54n4cdhCvYTIwmHPCoubgdZ66OyWMb7vfuxChlLUDqHUj78kpia+xep jz3vaILQSYoff7qIu1k0IFvt8nS2t8RAymDSugLSKFQ9YGXV0gNFLbgkQ+sH/oobWDjW 9/M1K4IcFvjNpMzFCAqun+OHirCdHUXpFLw+JOCujPNxISlqwxSEw4Ben76Gey0gapwa 4ec5niz/gApP4scHyH7ORY8lda2YwlivHSlEpQYiNxqkVcXLOIiWvFJMVWKiye3wlbJW PcX/9r3zJPsVLA3TPhvS6O0fSZ1IO1E0q4rsCwgamz34WSpHfBIdWi2WGFOqjuzuR6PH 21gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=20DbjnPlaklqjatnkgYSMVf9swPCDsVDbpGCQDuacg8=; b=E17asa/nnLi70LWanT0nYnpc1/VnVuDGZkthf2eXCEkzRKECg/vEE1+F66/B+daS9G ORwRXguj7T5WW/MLzLG2pHNBeeSXnMmlUlHAIVhz2LDLyWxZuR+hrgGaWKYD5bMPGilw Yl3WnxQo8feeDziiF5Hq9I/FiTcxgGHmgdQ6tVAgBY70vsfipEtgS1vSIJTfCDy5MkM2 aGgVIDrO/H1evcyu5jhwgocObF7fqj+r5EKo/B72YIqZTq0yjhL9Wnvn/lHe41iDT03U QYYaCjfO0FXWaAiw2+At1eL3UzCP7LX5C7eVI1JFGnjmT1fM+EJdOz6B6Kn3OwwEisXY 5zRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FldNkRWg; 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 pw18si4890716ejb.163.2020.12.07.23.45.29; Mon, 07 Dec 2020 23:46:02 -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=k20201202 header.b=FldNkRWg; 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 S1726896AbgLHHog (ORCPT + 99 others); Tue, 8 Dec 2020 02:44:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:53068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbgLHHof (ORCPT ); Tue, 8 Dec 2020 02:44:35 -0500 X-Gm-Message-State: AOAM5334J88SjrqH4GiILDyUUQw55i1LTmIS7oA2vHJY8+khCmw6H2sa BCh0PlgR9Dd6XOnNY0fOS8Am5hGz/CydeZi+bw0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607413435; bh=20DbjnPlaklqjatnkgYSMVf9swPCDsVDbpGCQDuacg8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FldNkRWgSdyCM4hOMRzZM9jxOvFQLnhRpOt2zW9GAWokS713f42KIa8B44A4gNEx6 6QRzXL5gO5H7bq+jjEyfAI0l49DGZYGzRudpKp/FVsbe1gNF4B/VbUeoO62PkOfaNQ I/V+3j2aVfUWTKlvKnHvkeoPWiPRPfc4EwvvaAlYAgkopYsC3o4c9OGCftW/xFgwyo 4adYw4VHnZyV6bLlJ+TuwKEL93TaSWURFO6SzZef9f1yhRD7IvIvNf1TRB4X0Z0L6s d/T3VOGzCUpke/jn4WRPjmyKCQNVRJS50BZmoZPeqo6mj7uMkg+cU7NeEnrqRCzWub lkBWX6Q+VRe/A== X-Received: by 2002:a9d:62c1:: with SMTP id z1mr15465189otk.108.1607413434140; Mon, 07 Dec 2020 23:43:54 -0800 (PST) MIME-Version: 1.0 References: <20201125211311.2179-1-iuliana.prodan@oss.nxp.com> <20b1493d-bfb6-d0bc-3b73-740b216db5f2@nxp.com> <6ab2e280-a699-67c6-2066-af0b7ea9b709@nxp.com> In-Reply-To: <6ab2e280-a699-67c6-2066-af0b7ea9b709@nxp.com> From: Ard Biesheuvel Date: Tue, 8 Dec 2020 08:43:42 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/4] crypto: add CRYPTO_TFM_REQ_DMA flag To: =?UTF-8?Q?Horia_Geant=C4=83?= Cc: Iuliana Prodan , "Iuliana Prodan (OSS)" , Herbert Xu , Ard Biesheuvel , "David S. Miller" , Aymen Sghaier , Silvano Di Ninno , Franck Lenormand , Linux Crypto Mailing List , Linux Kernel Mailing List , dl-linux-imx Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 7 Dec 2020 at 14:50, Horia Geant=C4=83 wrote= : > > On 11/26/2020 9:09 AM, Ard Biesheuvel wrote: > > On Wed, 25 Nov 2020 at 22:39, Iuliana Prodan w= rote: > >> > >> 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. > > > The performance loss due to bounce buffering is non-negligible. > Previous experiments we did showed a 35% gain (when forcing all data, > including I/O buffers, in ZONE_DMA32). > > I don't have the exact numbers for bounce buffering introduced by allowin= g > only by the control data structures (descriptors etc.) in high memory, > but I don't think it's fair to easily dismiss this topic, > given the big performance drop and relatively low impact > on the generic API. > It is not about the impact on the API. It is about the layering violation: all masters in a system will be affected by DMA addressing limitations, and all will be affected by the performance impact of bounce buffering when it is needed. DMA accessible memory is generally 'owned' by the DMA layer so it can be used for bounce buffering for all masters. If one device starts claiming DMA-able memory for its own use, other masters could be adversely affected, given that they may not be able to do DMA at all (not even via bounce buffers) once a single master uses up all DMA-able memory.