From patchwork Wed Aug 5 18:28:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6952441 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 2F0239F402 for ; Wed, 5 Aug 2015 18:29:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48201205C2 for ; Wed, 5 Aug 2015 18:29:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26DF7205D8 for ; Wed, 5 Aug 2015 18:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753333AbbHES3H (ORCPT ); Wed, 5 Aug 2015 14:29:07 -0400 Received: from mail-bn1on0116.outbound.protection.outlook.com ([157.56.110.116]:51232 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753199AbbHES26 (ORCPT ); Wed, 5 Aug 2015 14:28:58 -0400 Received: from CO2PR03CA0044.namprd03.prod.outlook.com (10.141.194.171) by BY2PR0301MB1576.namprd03.prod.outlook.com (10.163.28.18) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 5 Aug 2015 18:28:52 +0000 Received: from BN1BFFO11FD019.protection.gbl (2a01:111:f400:7c10::1:137) by CO2PR03CA0044.outlook.office365.com (2a01:111:e400:1414::43) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 5 Aug 2015 18:28:52 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; kernel.org; dkim=none (message not signed) header.d=none; 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; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD019.mail.protection.outlook.com (10.58.144.82) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Wed, 5 Aug 2015 18:28:51 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t75ISmAB019320; Wed, 5 Aug 2015 11:28:50 -0700 From: Victoria Milhoan To: CC: , , , , , , Subject: [PATCH v2 07/14] crypto: caam - Use local sg pointers to walk the scatterlist Date: Wed, 5 Aug 2015 11:28:41 -0700 Message-ID: <1438799328-10757-8-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> References: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD019; 1:Vi69iY/M6G5ZwdE0r4ygkXlKanNvToum9OWH4/JBkXXFm+s5uUBH2H9I84H2eAXNBxtei4mMH2oiub1ek7knc2SMw0FcAkn5r9iE7Bcsb+En3wrcsGrN2EuJDdCUVJljNQEy7faYIFiDWNgSIX3f0x2drGxKf5aNln+2FQsQDz5inHnQlAqVPWt7S8ndLZf3VOjPFerSFCSdsAEWeHEooZZUFBBMs/u1Cg/aQgFEpaplvEueVEfRMPqkVPZWbaPgal3CZd38OfbsQWAV0Mrpy72KnGMmcYx5zx0Sfj3/liVT+0eSH3HYUvI3fPgHm+E5h2S/pMFXS6+dzJ5MvV1zjg== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(189998001)(76176999)(2950100001)(104016003)(50466002)(92566002)(68736005)(77096005)(105606002)(5003940100001)(48376002)(77156002)(36756003)(62966003)(97736004)(64706001)(19580395003)(4001540100001)(229853001)(106466001)(6806004)(86362001)(50226001)(19580405001)(5001960100002)(2351001)(5001860100001)(50986999)(46102003)(87936001)(33646002)(85426001)(47776003)(110136002)(5001830100001)(81156007)(69596002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB1576; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 2:vh9/N7NhbhPH6A1jDVOv6WnJwRmxwIQlucF2v5BclYL9st19G5HvD+AkK1sP8NNZVuaQN3cPs7ZKW0PxPE4pbiUqO9++mBxwwZU6aQF4/2z5HLezrHq39aZ5VEc4R8tO/8TsVsxuHA6gxNsR5jHIq0Goi+DvJTyXRUE9mUmJ0aw=; 3:M7ratT7OgOsb/0PvbqKWq5ec9pA3avQRVlC014MvxjZ3KBdSTPbLclETQQVopVvlqksXk0OUEk8aLSr8nUp8ECsWMA87DLxJ6f3vf6yJbqLpXkK+RV7kPdn9QZ4ip3RE18p3UTnineaX03naId/7ddPZK4TIGK/zR41y8vfAhlUrKtILGdr43kjdmz8IdEz3cmdGFZIOeSr2puwm47sDPj1nOLq+Fqo6ctjgijWctVM=; 25:tENZ0oz0cveEL0c8VbyXcUfixSnL1t9M2vueIkg6EwS/sj7ctxTEqt6ZtzSMJllGS5z2Szkgg+gPRQA5/aIcB8gnOZFhMXwjawydoA1/EEw6eSbC9BK+TJLctqTx9jkB97Fu8G7zxySn3NZvPEx2XCdOIRCFrdt7SpxvFOUkzwvlB+QaGcGekJzI0gFiHQ9qyFdGg/YJ2ickfTeur5tNpIaTuPmuF2sSc3LosgCYP5vU/06xcVU345MpbYzY7x/tTC2539KyO1xfVrQbJarEMw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1576; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 20:w6UQbptbaD0XYHf+xTycQLVOV119AFaMTSmBes8r9cEpHlKUNWXyEPGbMCavj/1UMnMF+V03hjahe5rGIMlyFnvmeLFra50NIhWcjQCPTlQKXrEg9A2iCqXt1yYDJl7ddIjZx2ll50apTWcR11a+rqobt61kM7T5njuua4tujLgM6p6Z5WHU/00rofDjDd48HJtA9Cj8cJetQpcaiK+rIPEafz+mxZWcY/LAQ2jMSNKqvbz8eZQSUWg5l3+mLlMihoX5gpifmjckYYAkDxqFO0vA0lV9zQiO5ps/GI6Z9tEmrxgDOINoPPhu6D3HGYRhwEZyRLxbyclYAdXrIj43zMrurzgHyEMWwa34OHuO+ks=; 4:uZ4A+n9bCzDooVoOI6Pe+9fOZ9PMgAYlbv2MM7evGjhwhdN6PIYwWMmediEhENe63EwwFIJqbnQFCw8pfxabQnudWZ7LQWgjUItdl4gGbciitWer0hjtxlN7a0zg/ecO87Mp5FwF+b6HtgU9Ft9RULyIRi6b9A/15SmKCn9bi223BhEcYS0pCBaUc0m9mgMlIiWf8dcYLRWU8GfznoMvQGw3GRXfNZnoJU89+aZTcu4JkKF5xAzoD7QmaYjxKI9weXU4LcAVQjWxX1qEtD4jcGCpUOEuUcbXIhmbkjxc8ew= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY2PR0301MB1576; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1576; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB1576; 23:erT/1jaLDgld+THIPAlrtrz3qj8ymDUQ1fGAHUP?= =?us-ascii?Q?LetqZtEY7EukRzAn1Z+H4Qslse7R4EJfbYWsRdl4vV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to8EuiZUEFyzsiH3wNdH2YwBbS+7ite8DPxgu72W/yGXXfZso529jI?= =?us-ascii?Q?nXJwI1/H/jeTDJkfOmISkHfGZgwjCYnIc06ir8N830QYFl3oHzzSAZxJtxYP?= =?us-ascii?Q?eqLHjlYnvwqTrusuFRTy0YMfZcm2T9tqLpdBRBfrUmRDNQ8OflfFLlXwYECU?= =?us-ascii?Q?ffCwEKekr+HY=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 5:I8lkK6H0q6rR63VlZAJhNyJ6ca+EJ2esfSmJrIL72A4X1XZJGFu8mMgmLiYTt7jKp64/QQVySLjplx5HV3xgQtU2ssQ0VPcsC23r5Ot7zqn0GVPuX3Z8+8UAbUWKClSLSh1oNi6VRMrW8cKHANzcyQ==; 24:9UY6dZ8Jjv71VBcv6ehONToIYxNq6bUXuBxeAbBvERqQKyOGp0WRHbxtCW/l9c+SGrOOtofD0vv4TBGmtPTJfdz8L7lGfGCsp0nm4xnXj8M=; 20:shw/z+1gP/CtKAc6r2+WM44vBP28K6hHUWAaBBsoSnQ0jwTXbhinTCaiPiURdERvrFLXxZDVyB4eb4WX9WYbPQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 18:28:51.6092 (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: BY2PR0301MB1576 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Avoid moving the head of the scatterlist entry by using temporary pointers to walk the scatterlist. Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/sg_sw_sec4.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h index 711bb39..18cd6d1 100644 --- a/drivers/crypto/caam/sg_sw_sec4.h +++ b/drivers/crypto/caam/sg_sw_sec4.h @@ -105,9 +105,15 @@ static inline void dma_unmap_sg_chained( { if (unlikely(chained)) { int i; + struct scatterlist *tsg = sg; + + /* + * Use a local copy of the sg pointer to avoid moving the + * head of the list pointed to by sg as we walk the list. + */ for (i = 0; i < nents; i++) { - dma_unmap_sg(dev, sg, 1, dir); - sg = sg_next(sg); + dma_unmap_sg(dev, tsg, 1, dir); + tsg = sg_next(tsg); } } else if (nents) { dma_unmap_sg(dev, sg, nents, dir); @@ -118,19 +124,23 @@ static inline int dma_map_sg_chained( struct device *dev, struct scatterlist *sg, unsigned int nents, enum dma_data_direction dir, bool chained) { - struct scatterlist *first = sg; - if (unlikely(chained)) { int i; + struct scatterlist *tsg = sg; + + /* + * Use a local copy of the sg pointer to avoid moving the + * head of the list pointed to by sg as we walk the list. + */ for (i = 0; i < nents; i++) { - if (!dma_map_sg(dev, sg, 1, dir)) { - dma_unmap_sg_chained(dev, first, i, dir, + if (!dma_map_sg(dev, tsg, 1, dir)) { + dma_unmap_sg_chained(dev, sg, i, dir, chained); nents = 0; break; } - sg = sg_next(sg); + tsg = sg_next(tsg); } } else nents = dma_map_sg(dev, sg, nents, dir);