From patchwork Fri Mar 13 17:37:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Horia_Geant=C4=83?= X-Patchwork-Id: 6007521 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84C7EBF90F for ; Fri, 13 Mar 2015 17:37:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B513B20218 for ; Fri, 13 Mar 2015 17:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D50EC201FA for ; Fri, 13 Mar 2015 17:37:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752393AbbCMRhx (ORCPT ); Fri, 13 Mar 2015 13:37:53 -0400 Received: from mail-bn1bon0132.outbound.protection.outlook.com ([157.56.111.132]:37856 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752656AbbCMRhw (ORCPT ); Fri, 13 Mar 2015 13:37:52 -0400 Received: from BY2PR03CA006.namprd03.prod.outlook.com (10.255.93.23) by BL2PR03MB387.namprd03.prod.outlook.com (10.141.91.152) with Microsoft SMTP Server (TLS) id 15.1.112.13; Fri, 13 Mar 2015 17:37:50 +0000 Received: from BN1BFFO11FD006.protection.gbl (10.255.93.4) by BY2PR03CA006.outlook.office365.com (10.255.93.23) with Microsoft SMTP Server (TLS) id 15.1.112.19 via Frontend Transport; Fri, 13 Mar 2015 17:37:50 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) with Microsoft SMTP Server (TLS) id 15.1.112.13 via Frontend Transport; Fri, 13 Mar 2015 17:37:50 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t2DHblPD009703; Fri, 13 Mar 2015 10:37:48 -0700 From: Horia Geanta To: , Herbert Xu CC: Kim Phillips , Horia Geanta Subject: [PATCH v2 1/4] crypto: add CRYPTO_TFM_REQ_DMA flag Date: Fri, 13 Mar 2015 19:37:40 +0200 Message-ID: <1426268260-20824-1-git-send-email-horia.geanta@freescale.com> X-Mailer: git-send-email 1.8.3.1 X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=horia.geanta@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(50466002)(50226001)(48376002)(47776003)(229853001)(106466001)(105606002)(33646002)(104016003)(77096005)(87936001)(77156002)(62966003)(92566002)(6806004)(85426001)(19580395003)(19580405001)(46102003)(50986999)(86362001)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB387; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB387; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002009)(5005006); SRVR:BL2PR03MB387; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB387; X-Forefront-PRVS: 05143A8241 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2015 17:37:50.0471 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB387 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The CRYPTO_TFM_REQ_DMA flag can be used by backend implementations to indicate to crypto API the need to allocate GFP_DMA memory for private contexts of the crypto requests. Signed-off-by: Horia Geanta --- include/crypto/hash.h | 4 ++++ include/linux/crypto.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 98abda9ed3aa..6e23b27862cd 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -507,6 +507,10 @@ static inline struct ahash_request *ahash_request_alloc( { struct ahash_request *req; + if (crypto_ahash_reqsize(tfm) && + (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_REQ_DMA)) + gfp |= GFP_DMA; + req = kmalloc(sizeof(struct ahash_request) + crypto_ahash_reqsize(tfm), gfp); diff --git a/include/linux/crypto.h b/include/linux/crypto.h index fb5ef16d6a12..64258c9198d5 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -103,6 +103,7 @@ #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 #define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200 #define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400 +#define CRYPTO_TFM_REQ_DMA 0x00000800 #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 #define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 #define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 @@ -1108,6 +1109,10 @@ static inline struct ablkcipher_request *ablkcipher_request_alloc( { struct ablkcipher_request *req; + if (crypto_ablkcipher_reqsize(tfm) && + (crypto_ablkcipher_get_flags(tfm) & CRYPTO_TFM_REQ_DMA)) + gfp |= GFP_DMA; + req = kmalloc(sizeof(struct ablkcipher_request) + crypto_ablkcipher_reqsize(tfm), gfp); @@ -1471,6 +1476,10 @@ static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, { struct aead_request *req; + if (crypto_aead_reqsize(tfm) && + (crypto_aead_get_flags(tfm) & CRYPTO_TFM_REQ_DMA)) + gfp |= GFP_DMA; + req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp); if (likely(req))