From patchwork Thu Jul 30 03:58:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6898121 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 A9DADC05AC for ; Thu, 30 Jul 2015 04:14:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C146520544 for ; Thu, 30 Jul 2015 04:14:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 973E02053E for ; Thu, 30 Jul 2015 04:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751111AbbG3EOH (ORCPT ); Thu, 30 Jul 2015 00:14:07 -0400 Received: from mail-bl2on0122.outbound.protection.outlook.com ([65.55.169.122]:2656 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751074AbbG3EOG (ORCPT ); Thu, 30 Jul 2015 00:14:06 -0400 X-Greylist: delayed 927 seconds by postgrey-1.27 at vger.kernel.org; Thu, 30 Jul 2015 00:14:05 EDT Received: from CO2PR03CA0033.namprd03.prod.outlook.com (10.141.194.160) by BY2PR0301MB1575.namprd03.prod.outlook.com (10.163.28.17) with Microsoft SMTP Server (TLS) id 15.1.225.19; Thu, 30 Jul 2015 03:58:36 +0000 Received: from BN1BFFO11FD028.protection.gbl (2a01:111:f400:7c10::1:115) by CO2PR03CA0033.outlook.office365.com (2a01:111:e400:1414::32) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Thu, 30 Jul 2015 03:58:36 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; arm.linux.org.uk; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD028.mail.protection.outlook.com (10.58.144.91) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Thu, 30 Jul 2015 03:58:35 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6U3wUbg025418; Wed, 29 Jul 2015 20:58:34 -0700 From: Victoria Milhoan To: CC: , , , , , Subject: [PATCH 07/12] crypto: caam - Use local sg pointers to walk the scatterlist Date: Wed, 29 Jul 2015 20:58:24 -0700 Message-ID: <1438228709-27650-8-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> References: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD028; 1:iYbicpF2LatNjQFuQIqjflFguz88fk1i4pdX+jLoHdWo+aVjbxbdtH30E8rbUh2HxiMZu6xQ8EuB5rTWcC+/j4PuG5RNt0ubWP7tp9ntgHCz1s0uRTAgffPJ8ImQz4tz2oH5Gn1Vtw3WgEBqN3S8pUuEQBg8TsxUkf8PFtSFq1SlJtvoYMSpk1T+Qim0gFclWppEe/33Vo/C9L41KcXCBmqEORk4BaDzzC24cPGK204pQnEpVvWkYN10gxdp9Kols7rwSbnXEQ4+U4L3YlDXnHjakzHl1bkuDphr+TfSjnzlZANuLMZjyTlEB4vr3w3qtnMfg/1xyd4b/rAfXrbiRw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(5001960100002)(33646002)(48376002)(50466002)(189998001)(110136002)(19580395003)(19580405001)(2950100001)(50986999)(6806004)(77096005)(76176999)(46102003)(92566002)(106466001)(104016003)(105606002)(62966003)(229853001)(77156002)(2351001)(50226001)(87936001)(47776003)(85426001)(86362001)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB1575; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1575; 2:OdIoRO2ZK74Vupnpptx5/t/akMEtNU/bFuuHvKq/NVNhs5xO0dFFA+aZgZxWEAtNPz5uKYO5hXsT83G3uuZ24zjdPFLIukUO563FxkzdMICjfg+UICnJPpBzxDTRN5bM+fOra36KUCqLhzJFD5qryYSgW/DK5Jm0I6zXG9ptD+8=; 3:zpjst7ZmoOIeXCEmg1aQvmu2t5d0GDxwuScp8gnhZE8L4Iv0IN+kXo9fD41tsyIi4QGlgVpBx3+lmDP3b7ZWqsltHm7vgaDHts5EOk9MTHVk0VB4zb3zz3SwR82VJErtUeV7UeO5J2qL5zHifhkN6+razNwAmz6xJN5Ml6KDjEYLbLqFigdES8Ff+g7qI2FheLGLNZvkVApHZLenm6M1IQCduclV632WM7xia3uIqo8=; 25:ro9l+AtryFnm9KgiHElaPSGPKT/DTd4gNIPn1BIoDEfg65dtJTIt9sd1OYHZwX1c2+ibUiahLd7fYOKgfOzp3FdDll3PUN3O483K2UZgqQOabw8MwyJ+qIZRv+EZh82E87CjRDkovNXiiXBivXXBbJ6aHgYUutqyqPYaP6pxFh6+YLKhxgPOTipa7YO6/q21LXWKCTW9v8iaui19v3SJm70W6dcTDt4yoJeR49l2DxHLyY+twe4xjh1EYoUFy1Ze7SjgjqppM2+3sZyVXn9Ihw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1575; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1575; 20:XbvI9ybyd9UL+DatXufMn1HpCdTvtK0VfeRWlDqpQZXoNWsxwF7omAQkaLWYIYLhqecqqtyTghgSA7xMk8kesCSOHoQEcJqyCoj0iB8s7vSeNr4RcMnJHw10CPgjIFt0vJIRnG5AEkCHw+KLePeKcFVhOtYtY4xHiMCS8J7mkOHXhD2NVgR7Fp6vYGUA9qa+kPzLvnlzONGIZZDzL/+GWlCgX3KViMbugdEOvI+RH7sIJRi0+/FCAAX19d8Th9AWYdFhDVUpSZ/ktx+ACEMR6keB/7dIl6UI8xSiyeNfAAexSr2pjxKRhx0QafH4xXOVxRzejKVat1cSxoWPdu/hpie3QyDys/nFbfVayu0b1D8=; 4:9TACJDkUkDMMNLO3JIYkFzjLOr3Iev4ABSnxv1JM7f13fOYzZiutofl+nMLSIBGYEwKZcDmatsR6m5/EtgvTauxykrJS1aO0xDnYE+Nw3D51gyM7Mtulmrk3DqYZaHPUFuLtDOi81+2/Xm//WtR7dPpdvFqxG4FT2UwZGmxJ46hV1Gljx7n6oBl6pxKOqWiQnPLZ9whe3hcI3j7lHvOO6cg+MaLwh7QNED/SakDBQA3bRHd/fu8J0Z2cK6EbpimhqqMar1UwZAPa7eLPA5f1n8zgB3k8SjO8VNu1V25pbIw= BY2PR0301MB1575: X-MS-Exchange-Organization-RulesExecuted 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:BY2PR0301MB1575; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1575; X-Forefront-PRVS: 06530126A4 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1575; 23:bRwN3hYBpCKphxTLCDk60Yb5bjjSY2IXAg1Jv+vmZmZGCQivJc0fIT27WLA/ydUv//FqfwHFs4FUno9VPN3aHy0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vaeb2gX1NsHLEUODr558kbedVJ1z2U5JEM8bO6UQiLg7Rw=; 20:9/GRpfZ1bJAqohur3K0eTaJE67qsDPxnzkfmCuxo3Qg0VYhUEecJFJu0cabOxkFRE3nhi3JZp7bMPtMYsI47wg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2015 03:58:35.8391 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1575 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-8.3 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);