Message ID | Y4BGC2BPesy3qsEm@gondor.apana.org.au |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3764832wrr; Thu, 24 Nov 2022 20:37:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AKvrK0dSnIv71ucAekgzqMXfvED9DrOoqcy5bXsM8KHSRI2KGr+ujZ/XJec/O9WLqmk8v X-Received: by 2002:a17:906:844:b0:78c:2c03:804c with SMTP id f4-20020a170906084400b0078c2c03804cmr17584657ejd.107.1669351054718; Thu, 24 Nov 2022 20:37:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669351054; cv=none; d=google.com; s=arc-20160816; b=vFa3zQ0r0Brf6/8uGMj404mXKVbvExP/nSdfiX8PLzWP8BltZNxs82CyNEFce4DJ1T sQwErNgBNZ1yevWPvkvJx5X8KwZQJhaj0BmyeOF56i9ugLy3mYTNgCdhy6/DiEmXQjIR uInkXQN/VAAnULcH3wHDFZLqgtNpyjF3Ig+KPbKoZh7B4X2ZtNae4TA1aM7XGwnGkI+r YbOAZkZbzk5Z00rdTratDEivPDfMdfYM9PUDcG4R/ax8jzHaSnKJcNudplvsVKz5+Fvh aBx8Ecy2TQ8pHQC0dKI3uwQNDtLUnuYkKRNB1xirLThFO7yey70N2lz5ptLYOqk9ZyM6 05Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=YcTCFd/W+n+hHuzVas/lr+Pw5KPofeQ1QD4X0sSb64A=; b=EiLxT8/Yo11Y9840nOR0+3fUDs7BsF1vWPWdDTQNACN3NB4oy+GGakcVgf0uu5NIv8 Tmo4kXOAUIeXlsRA28Ws+U7RS+yeuF/qbcloUkfsjgdvzD5TwFlKNZcZI5YMFhw9vTW7 jABfZ+M7iAFY41FKctietmecWfLGUKaQ44Ew0fxSeI14/6OMiwadGu7FIZX/RpxjgLT+ VCTeWEAb9KKTF/69CF16XTpf5E0OcWxcHedycCxO4rbEUBhL6/Sdq7B1j043UOJBrVrI xBqtoaBJlCRviYlQOTCbeScsOvTbn2W0+dO6jiK6IebISdSECTqiUjoqNVO7heJ9EHud edHQ== 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 fj4-20020a1709069c8400b007ae0e8f59a6si2402984ejc.821.2022.11.24.20.37.11; Thu, 24 Nov 2022 20:37:34 -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 S229487AbiKYEgA (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 24 Nov 2022 23:36:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiKYEf5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 24 Nov 2022 23:35:57 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C02F82316F; Thu, 24 Nov 2022 20:35:55 -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 1oyQQt-000di7-JM; Fri, 25 Nov 2022 12:35:24 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 25 Nov 2022 12:35:23 +0800 Date: Fri, 25 Nov 2022 12:35:23 +0800 From: Herbert Xu <herbert@gondor.apana.org.au> To: Catalin Marinas <catalin.marinas@arm.com> Cc: Ard Biesheuvel <ardb@kernel.org>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andrew Morton <akpm@linux-foundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, Linux Memory Management List <linux-mm@kvack.org>, Linux ARM <linux-arm-kernel@lists.infradead.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org> Subject: [v2 PATCH 0/9] crypto: Add helpers for allocating with DMA alignment Message-ID: <Y4BGC2BPesy3qsEm@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750441451576488501?= X-GMAIL-MSGID: =?utf-8?q?1750441451576488501?= |
Series |
crypto: Add helpers for allocating with DMA alignment
|
|
Message
Herbert Xu
Nov. 25, 2022, 4:35 a.m. UTC
This patch series adds helpers to allow drivers to explicitly request ARCH_DMA_MINALIGN when allocating memory through the Crypto API. Note that I've only converted one file in one driver as this is only meant to show how it's done and find out what else we may need. Other drivers will be added later. Thanks,
Comments
On Fri, 25 Nov 2022 at 05:35, Herbert Xu <herbert@gondor.apana.org.au> wrote: > > This patch series adds helpers to allow drivers to explicitly > request ARCH_DMA_MINALIGN when allocating memory through the > Crypto API. > > Note that I've only converted one file in one driver as this > is only meant to show how it's done and find out what else we > may need. > > Other drivers will be added later. > Hi Herbert, This approach seems conceptually similar to what I proposed a while ago: https://lore.kernel.org/all/20220406142715.2270256-1-ardb@kernel.org/ If we agree that creating a distinction between ordinary allocations and ones that are rounded up to DMA alignment is ok, I wonder if we could minimize the churn by simply choosing between one or the other by taking the CRYPTO_ALG_ASYNC flag into account. On x86 and other arches that don't care about the distinction, none of this has any effect anyway. And on arm64, only hardware implementations use the CRYPTO_ALG_ASYNC flag, which makes its presence a reasonable heuristic to decide whether an algo implementation is backed by hardware that relies on DMA (the penalty for getting it wrong would be to use DMA ailgnment unnecessarily, which we already do today anyway) We'd still need changes in the generic crypto layer to distinguish the two cases, but we wouldn't need any changes to the drivers, which seems like a huge benefit to me
On Fri, Nov 25, 2022 at 01:17:55PM +0100, Ard Biesheuvel wrote: > > We'd still need changes in the generic crypto layer to distinguish the > two cases, but we wouldn't need any changes to the drivers, which > seems like a huge benefit to me I think we should go through the drivers anyway. Because it isn't just allocations from the Crypto API that'll bite us. When I'm working through the drivers, I'm actually looking at what they're mapping for DMA and where it's coming from. Only when the driver stores DMA-mapped data in the ctx structures am I changing the drivers to add the extra padding. Some of the drviers are doing small allocations for things like the IV or keys with the GFP_DMA flag and hoping that it gives the correct alignment. Cheers,