From patchwork Wed Dec 9 16:21:05 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: 7810541 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 157EA9F387 for ; Wed, 9 Dec 2015 16:36:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4149204A2 for ; Wed, 9 Dec 2015 16:36:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E72DB2012E for ; Wed, 9 Dec 2015 16:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbbLIQgH (ORCPT ); Wed, 9 Dec 2015 11:36:07 -0500 Received: from mail-bl2on0135.outbound.protection.outlook.com ([65.55.169.135]:35328 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751785AbbLIQgG (ORCPT ); Wed, 9 Dec 2015 11:36:06 -0500 Received: from BY2PR03CA071.namprd03.prod.outlook.com (10.141.249.44) by BLUPR03MB568.namprd03.prod.outlook.com (10.141.78.22) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 16:21:11 +0000 Received: from BN1AFFO11FD042.protection.gbl (2a01:111:f400:7c10::171) by BY2PR03CA071.outlook.office365.com (2a01:111:e400:2c5d::44) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Wed, 9 Dec 2015 16:21:11 +0000 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; arm.linux.org.uk; dkim=none (message not signed) header.d=none;arm.linux.org.uk; dmarc=none action=none header.from=freescale.com; Received-SPF: PermError (protection.outlook.com: domain of freescale.com used an invalid SPF mechanism) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD042.mail.protection.outlook.com (10.58.52.253) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Wed, 9 Dec 2015 16:21:10 +0000 Received: from [127.0.0.1] (B05471-01.ea.freescale.net [10.171.73.126]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id tB9GL5P2001522; Wed, 9 Dec 2015 09:21:08 -0700 Subject: Re: [PATCH RFC 10/11] crypto: caam: add ahash_edesc_add_src() To: Russell King , Fabio Estevam , Herbert Xu References: <20151207191134.GV8644@n2100.arm.linux.org.uk> CC: "David S. Miller" , From: =?UTF-8?Q?Horia_Geant=c4=83?= Message-ID: <566854F1.8020409@freescale.com> Date: Wed, 9 Dec 2015 18:21:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD042; 1:cKBABIrGjNs8anp1nLfU1MI0RW+zUOJdVqTX8r7dCPv3h1n52bfeVlwz95nzsFBbe8ytXK+5sWHf6te4Lmj8Y+SO0vEmShXHQ3VKw1pm10RvTBrLWtpys0KgGHT+zefISRK+uV6K92+gKs7YphsB5hKzUP8eRrLikrWSqccw9/lmCuX97Heilr52zmDHQLPo0gVFAZADO09pwFDQF0IafkjYYSE0i44eYsSI2LxMlHNfy87bybjLUVU2Bd+8LLfpRrG4gTmmrVp5sSWpgyL4oL9/NestAdfYuzXpSUC6lSKsYEtzss4nQpeOkSFYsJARFXP1QLJQV+dbSfDm9b8DUWQSKghxq6IbvV/zm+I6Sb7zVgkK8AtPjcuicozHHsuT X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(448002)(377454003)(479174004)(189002)(199003)(24454002)(33656002)(19580395003)(5008740100001)(87936001)(80316001)(54356999)(5001770100001)(65806001)(4001350100001)(5005550100001)(19580405001)(87266999)(23676002)(92566002)(575784001)(97736004)(83506001)(86362001)(76176999)(81156007)(77096005)(120886001)(189998001)(99136001)(59896002)(36756003)(85326001)(65956001)(47776003)(50986999)(50466002)(65816999)(5001960100002)(104016004)(106466001)(1220700001)(586003)(1096002)(2950100001)(6806005)(11100500001)(230700001)(64126003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB568; H:tx30smr01.am.freescale.net; FPR:; SPF:PermError; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB568; 2:H8BOS5x0QbmoWDdrpZ7cHBjLHEpEKDxHcXSFjXsOxrQOWTebZn3D+nP4HaCcCw3XjL9wsbQeCR8THMUXzeAfKgqEn4NhBw1COVt3ONZEWmXMLNL8v1JhzWBcsJTY1fdMlnIKEmqtkGcqP3THJEiIFg==; 3:4Z/B/NROoUh6VM67phWwL8juhx8Yg+j7WcjGhEiRUwQTJhdCczPuDhuhhYOXxrrOpLvpMe7Q7Z9RERG5I9GNPIyZpfSEEujIszUC05q+4Vi1+OO9xPZwTzE0iRU7pR2SQW80uoUU1nhWkvK4H/hKVPG0cueN58uTzzoN6FhhEL60exsAlrKSZgGX596qw6TQDS3AzJrMzspaBglurM1BkZIvu3ptkgncHtC+iwZuCpM=; 25:2RUdisCSqTI52n4hvoC250iker2UParxXNUIR4okywmxoZRUUSvd3gT+FT693otLkqQV7BXfyAGWmdHwG8raeO7AoszD5tPwZokcJjHHQ9XZ1VKKjoSvQHF7tBTjDKvv7O6XjAV+036mMoVhQfEXxFdFuxndYMcd4rNyK1JdVOUvCS1JT7TsCU3k/lm3+mgLjHDysV/6VBcpdmEQ+nDhl44e5A49BcJ+JkjU3khj3y6P0nRNwmYKElQxXgEK2cMA X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB568; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB568; 20:JXmmnNspHclXl0ikExMuE1cdzOtgW8uVoUzMfga910yvqcSaDrDxpGLI1D3JTNZr0mnqWwnRqwcjBlNXbKXDlJN/d8OqEa73OH+K+USUvED5hBZOlEr1YBUpmduLV/Z8v4kJpUGJVWPSDQeRJIjjCTizoadIDyfrfN2oxGbI41IJhfQD8/gwQm8XSrTySXvh4tDbB7af9TLX+rYg/KLJNdVMotdF4HIcHk75figeR0zyf28jCvV6eemvSmDkxb1w8DUbLNu1AEW/EWJk+1JY0r3wGyA1KX2yRYCasycjBxcrjGRbyaBsYYfUUROIIsxMzFkz9sPrL0999TsHII6o/0jt9pCaWinlMVb4pMhJUbM=; 4:aMo8aHgAc3T937ChICgG6pFJ9GeSOGfxfkN90y7Rly9thbG6ZljqLv54zi3I41DgjOcuGq0s1nSQ5xCcSQqACuT+HW3SwdJMHVggU0FdaxssacxItYp/0UnSJe3DiAP3JIoaDNb5Nwjci3cM1yV9g9uJHAlz4wteDdHScamUGJM0LyFIFfUZJGTS05SzcnQ9ad+xdpFlvGeVoH1k/a8XptQTAQpNggng/JR/yPkuqYECe3m2riPtxTn8OERvT2yzeu82r+7/hCY7hE791lxjFKzld4pEr7/QAB8a52QS/foxx8MImToOmsaHB7uLvMWTyLBSlounJbVsroTKBz/HhL8rO4rquxEH38gvyr+5PqdjjfTfsZO7OTkI10o5BP9H X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:BLUPR03MB568; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB568; X-Forefront-PRVS: 0785459C39 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?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REM3M0YzTlFRbVdRQWhSZmN1UTVyMnpz?= =?utf-8?B?NTZ1QjlyeDZhekljenR1cXpjUktjNHdBekRITDhJZXl5UT09?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB568; 5:+Yih9Ij++Z38dZ0GqegvnUJa/sEFlvbOgv5ghha5CFyuCoS1Abvu8YowNcgGgtt9Y6AZ09vqMhHdeo8ScPmhbzBdXAHTC65TnC2WxKdPpKykeUY8jUvURjeNH+9HopBWq/RugF6axX55K/6fNV222A==; 24:fwvx3LI7u3SedZGj5n+ELIJaUh9JPmY2Oa3+OPQxmTZ6smE172AhJFxSlXDwl0CTrmWl8fNZ17ofNJGR6SuGv4rNKlVS/528Xf3R7azD6dE= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 16:21:10.8380 (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: BLUPR03MB568 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 On 12/7/2015 9:12 PM, Russell King wrote: > Add a helper to map the source scatterlist into the descriptor. > > Signed-off-by: Russell King After appending 07/11 ("crypto: caam: check and use dma_map_sg() return code") as follows: u32 options; @@ -817,7 +817,7 @@ static int ahash_edesc_add_src(struct caam_hash_ctx *ctx, options = 0; } - append_seq_in_ptr(edesc->hw_desc, src_dma, first_bytes + req->nbytes, + append_seq_in_ptr(edesc->hw_desc, src_dma, req->nbytes + first_bytes, options); return 0; @@ -1521,7 +1521,8 @@ static int ahash_update_first(struct ahash_request *req) edesc->src_nents = src_nents; edesc->dst_dma = 0; - ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 0, 0); + ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 0, + -*next_buflen); if (ret) { ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_TO_DEVICE); Horia --- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 241268d108ec..00b35e763f58 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -1120,7 +1120,7 @@ static int ahash_digest(struct ahash_request *req) src_nents = sg_nents_for_len(req->src, req->nbytes); mapped_nents = dma_map_sg(jrdev, req->src, src_nents, DMA_TO_DEVICE); - if (mapped_nents == 0) { + if (src_nents && mapped_nents == 0) { dev_err(jrdev, "unable to map source for DMA\n"); return -ENOMEM; } I still see tcrypts test failures: caam_jr ffe301000.jr: 4000131c: DECO: desc idx 19: DECO Watchdog timer timeout error alt: hash: update failed on test 6 for hmac-sha1-caam: ret=-1073746716 alg: hash: Test 4 failed for sha1-caam 00000000: 75 e1 d9 26 df 3b 5c 31 d7 a3 02 ca 79 26 55 0e 00000010: 31 96 8d 9f [...] git bisect points to this commit. > --- > drivers/crypto/caam/caamhash.c | 106 +++++++++++++++++++---------------------- > 1 file changed, 49 insertions(+), 57 deletions(-) > > diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c > index 241268d108ec..4e73d3218481 100644 > --- a/drivers/crypto/caam/caamhash.c > +++ b/drivers/crypto/caam/caamhash.c > @@ -789,6 +789,40 @@ static struct ahash_edesc *ahash_edesc_alloc(struct caam_hash_ctx *ctx, > return edesc; > } > > +static int ahash_edesc_add_src(struct caam_hash_ctx *ctx, > + struct ahash_edesc *edesc, > + struct ahash_request *req, int nents, > + unsigned int first_sg, unsigned int first_bytes) > +{ > + dma_addr_t src_dma; > + u32 options; > + > + if (nents > 1 || first_sg) { > + struct sec4_sg_entry *sg = edesc->sec4_sg; > + unsigned int sgsize = sizeof(*sg) * (first_sg + nents); > + > + sg_to_sec4_sg_last(req->src, nents, sg + first_sg, 0); > + > + src_dma = dma_map_single(ctx->jrdev, sg, sgsize, DMA_TO_DEVICE); > + if (dma_mapping_error(ctx->jrdev, src_dma)) { > + dev_err(ctx->jrdev, "unable to map S/G table\n"); > + return -ENOMEM; > + } > + > + edesc->sec4_sg_bytes = sgsize; > + edesc->sec4_sg_dma = src_dma; > + options = LDST_SGF; > + } else { > + src_dma = sg_dma_address(req->src); > + options = 0; > + } > + > + append_seq_in_ptr(edesc->hw_desc, src_dma, first_bytes + req->nbytes, > + options); > + > + return 0; > +} [snip] > @@ -1471,9 +1486,7 @@ static int ahash_update_first(struct ahash_request *req) > &state->buflen_1 : &state->buflen_0; > int to_hash; > u32 *desc; > - int sec4_sg_bytes, src_nents, mapped_nents; > - dma_addr_t src_dma; > - u32 options; > + int src_nents, mapped_nents; > struct ahash_edesc *edesc; > int ret = 0; > > @@ -1490,11 +1503,6 @@ static int ahash_update_first(struct ahash_request *req) > dev_err(jrdev, "unable to map source for DMA\n"); > return -ENOMEM; > } > - if (mapped_nents > 1) > - sec4_sg_bytes = mapped_nents * > - sizeof(struct sec4_sg_entry); > - else > - sec4_sg_bytes = 0; > > /* > * allocate space for base edesc and hw desc commands, > @@ -1511,28 +1519,14 @@ static int ahash_update_first(struct ahash_request *req) > } > > edesc->src_nents = src_nents; > - edesc->sec4_sg_bytes = sec4_sg_bytes; > edesc->dst_dma = 0; > > - if (src_nents > 1) { > - sg_to_sec4_sg_last(req->src, mapped_nents, > - edesc->sec4_sg, 0); > - edesc->sec4_sg_dma = dma_map_single(jrdev, > - edesc->sec4_sg, > - sec4_sg_bytes, > - DMA_TO_DEVICE); > - if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) { > - dev_err(jrdev, "unable to map S/G table\n"); > - ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, > - DMA_TO_DEVICE); > - kfree(edesc); > - return -ENOMEM; > - } > - src_dma = edesc->sec4_sg_dma; > - options = LDST_SGF; > - } else { > - src_dma = sg_dma_address(req->src); > - options = 0; > + ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 0, 0); > + if (ret) { > + ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, > + DMA_TO_DEVICE); > + kfree(edesc); > + return ret; > } > > if (*next_buflen) > @@ -1541,8 +1535,6 @@ static int ahash_update_first(struct ahash_request *req) > > desc = edesc->hw_desc; > > - append_seq_in_ptr(desc, src_dma, to_hash, options); > - The refactoring changes the logic here: instead of hashing over "to_hash" input bytes, it will do over req->nbytes. Current patch could be fixed as follows, but I guess it's abusing the "first_bytes" param: diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 6d903398fb0d..7d40765e94c5 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -792,7 +792,7 @@ static struct ahash_edesc *ahash_edesc_alloc(struct caam_hash_ctx *ctx, static int ahash_edesc_add_src(struct caam_hash_ctx *ctx, struct ahash_edesc *edesc, struct ahash_request *req, int nents, - unsigned int first_sg, unsigned int first_bytes) + unsigned int first_sg, int first_bytes) { dma_addr_t src_dma;