From patchwork Fri Mar 13 17:14:42 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: 6007441 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DC2799F54F for ; Fri, 13 Mar 2015 17:15:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0EDE20225 for ; Fri, 13 Mar 2015 17:15:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F26BC201FA for ; Fri, 13 Mar 2015 17:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751799AbbCMRPH (ORCPT ); Fri, 13 Mar 2015 13:15:07 -0400 Received: from mail-by2on0115.outbound.protection.outlook.com ([207.46.100.115]:35586 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751210AbbCMRPG (ORCPT ); Fri, 13 Mar 2015 13:15:06 -0400 Received: from DM2PR03CA0030.namprd03.prod.outlook.com (10.141.96.29) by BY2PR0301MB0709.namprd03.prod.outlook.com (25.160.63.151) with Microsoft SMTP Server (TLS) id 15.1.106.15; Fri, 13 Mar 2015 17:15:05 +0000 Received: from BY2FFO11FD024.protection.gbl (2a01:111:f400:7c0c::170) by DM2PR03CA0030.outlook.office365.com (2a01:111:e400:2428::29) with Microsoft SMTP Server (TLS) id 15.1.112.19 via Frontend Transport; Fri, 13 Mar 2015 17:15:04 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD024.mail.protection.outlook.com (10.1.15.213) with Microsoft SMTP Server (TLS) id 15.1.112.13 via Frontend Transport; Fri, 13 Mar 2015 17:15:04 +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 t2DHF1NA030989; Fri, 13 Mar 2015 10:15:02 -0700 From: Horia Geanta To: , Herbert Xu CC: Kim Phillips Subject: [PATCH 1/4] crypto: add CRYPTO_TFM_REQ_DMA flag Date: Fri, 13 Mar 2015 19:14:42 +0200 Message-ID: <1426266882-31626-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)(189002)(199003)(86362001)(6806004)(105606002)(47776003)(48376002)(33646002)(19580405001)(87936001)(77096005)(85426001)(19580395003)(92566002)(77156002)(62966003)(46102003)(50226001)(104016003)(50466002)(50986999)(106466001)(229853001)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB0709; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0709; 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:BY2PR0301MB0709; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB0709; X-Forefront-PRVS: 05143A8241 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2015 17:15:04.3518 (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: BY2PR0301MB0709 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/linux/crypto.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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))