From patchwork Wed Aug 5 18:28:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6952411 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 C7FFB9F358 for ; Wed, 5 Aug 2015 18:29:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC3DA205CB for ; Wed, 5 Aug 2015 18:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9A1D205CD for ; Wed, 5 Aug 2015 18:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752632AbbHES3C (ORCPT ); Wed, 5 Aug 2015 14:29:02 -0400 Received: from mail-bn1on0138.outbound.protection.outlook.com ([157.56.110.138]:27851 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752803AbbHES24 (ORCPT ); Wed, 5 Aug 2015 14:28:56 -0400 Received: from CO2PR03CA0051.namprd03.prod.outlook.com (10.141.194.178) by SN1PR0301MB1584.namprd03.prod.outlook.com (10.162.130.18) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 5 Aug 2015 18:28:51 +0000 Received: from BL2FFO11OLC009.protection.gbl (2a01:111:f400:7c09::199) by CO2PR03CA0051.outlook.office365.com (2a01:111:e400:1414::50) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 5 Aug 2015 18:28:51 +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 BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Wed, 5 Aug 2015 18:28:50 +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 t75ISmA5019320; Wed, 5 Aug 2015 11:28:50 -0700 From: Victoria Milhoan To: CC: , , , , , , Subject: [PATCH v2 01/14] crypto: caam - Add cache coherency support Date: Wed, 5 Aug 2015 11:28:35 -0700 Message-ID: <1438799328-10757-2-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; BL2FFO11OLC009; 1:Dx3ws2RsbTjSnVRWl0u8VGcNDNZdVmsWLl8xaNB+msnqY3na7R5DpWW/eNFgepkqfKiJx8FdVvQr513QvtntQVikg4e6BSKWzXjKJpdR+B/xziXm/hI7VBet+xCuHiHXDxax76N176CXwo1mSet5nZoA01WVdsaAVo73oit0JC5p1W5GtvF+aCW7byUVMEy5t0rbjdUaaIlww9rPfHxItTIFLZgwir/ZbVZ3scuA+6B4n4w3x9xbiLCde5dDIAZYu9INjLKRjvlxiSxtIGXQQ7/vVlv/ZCd8xSth/8tb/C7ta9pmfFpkvKZVdV/+021ktMV3Tvn7CenAsCRMQC985g== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(5001830100001)(48376002)(64706001)(5001860100001)(4001540100001)(5003940100001)(50466002)(105606002)(97736004)(50986999)(104016003)(33646002)(69596002)(76176999)(62966003)(19580395003)(106466001)(85426001)(19580405001)(47776003)(5001960100002)(77156002)(229853001)(5001920100001)(6806004)(110136002)(87936001)(2950100001)(36756003)(50226001)(81156007)(46102003)(189998001)(92566002)(86362001)(77096005)(2351001)(68736005); DIR:OUT; SFP:1102; SCL:1; SRVR:SN1PR0301MB1584; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 2:mWxrAtgmTeOlVuXTIC+TZzpcLbgx69jluvf+qAlrKBIw+/N68a+yPzEnlZVUWim5ePQOX9ATUJ7dJ3JrcNWpPR3WardTp2BBxjdNvZ+0gvnqKjQlPbBzvgQIZuP8J4szOjSO/m4+bklf7JzL+Upis6sK/QmaggZoKhuMz/8o/fk=; 3:OGWhLEepdOz0K5JA/9wW5OclU8MLXj1tpd20eveoOJN8qwpN1NjOgyHxR0tko9oFTG2fRGRWoXBmi7vrRMtL9lkwU2bxgopwzYP/e0OfyO9urjofDmgrwqv5r7NGeefE/rMk2D9Cie52bh0hcB9R3wYTmYf+FDWiXIlQ8wINfWjTC6gwmJUE0VQH7yatKpr1iQ0oCsJAdVMmb9jTZ2AQrDTQ2ABcw6DszwBZczS9X7M=; 25:LrQUVAIQQVBAcNmXMt7o5+cSKrwASWlR7drMXO2RXve9miljVKe6Vs30SeSyCsu+li8kdwBVz1WvtMNRy1Y+/9fTP+W23/CdjK4RrhUF6yPrLx9BX+ocCm01BolS9IcKvuQ2zaLnF1hucPOkSz8J9dth/XWDDCpx7oGkajx1V70gWbN/l8d/mIQ9crNQxlc7NCxJzll+Tp1CGYqEDWKO2p8FkJeYet8hNHzTHiOZTyn03bf40cspZf95lcAxdhGvJVEjXvAxIvuTBOtXJ6hwBA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB1584; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 20:iPztj8CEuybsHATKMIgqWU5A4cd2LvfNFNu914Z1O+ZAAYB8mubLWAArvP6zf8lTshLTx72c3oXT9oUxZpLIDcyFhkmLuS9gLosMODeUr2cizZ2dg99NIIz9/uq4nD/T2O9bcxFAP3eDOb61TuEib6Dcae1Ct0FFyX9yqa3eYnrvZD9fuV3EwrNiuR2j6T26QsYcWBcVSwfivTF2FnJbqtYUT/Hpz/V4uKeExGTrOn3PMu7pbZtDCdWAyJzabXtBQHaVQ56gidX29o6oPhuL4gIyaSys8DgMTVNehjMRUiajLVAR3pDvaTY8slXd/zCtk/5BqzBvxySSfM6WuIclof6uK8bId4AQ2H6oMbGpWxI=; 4:21MbhhNzb/5MxE6fjoa88BJ9qKN/QAnIt3V72Vw1ABabxfgdIB03r9RSBhHNxIr/Vyjx52oKbZ3P4rAsXTAttPbrd5N0p0HdU2TgVhk4rw12T3H946jdFieGBcUV+0c4qF2anZq9MR2HDaO0C+mcURbxJBGBCmBvf8gw7Fyv05fMxr3sEQaC0/Xaie7RvMg6VJbe6C3fjwxbXL0Siu8y17l8EXZPf86Qqvi/w+fP5oC4xkkZIAgBvc7YQBGxUwgFPnfD8sF/CPdMAXju9aa1cwPL3ZZrxqw4QznSXv0aekM= 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:SN1PR0301MB1584; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0301MB1584; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1584; 23:1ZuvZfGu3nADB4diI2Ndtdnpg9aB7BjuQTO54kS?= =?us-ascii?Q?yyTxT4cpb0L1EEkddUolre5OffWl7Wz6I3v9MiwrNGI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SvRtkFHK3shMObkxvKjSD9AN7dYA96pNG2wkT3w9bNpxs?= =?us-ascii?Q?Y78uAhzE0EpRP2Iz/sika6tawpz6eys5LDyUNeuO2TNSbZA1QiNJO3pb+NE+?= =?us-ascii?Q?v5F+MntdqNBmKntvR5QpMS5KJzjKVjff0KgTonC9rMocTPim37a6DloYbImF?= =?us-ascii?Q?x6leTgWlOmDAvF/tHuUew98EOMcUPgWB6?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 5:5E18dMhI0bP5MjoVhAVSib7yM78/9Cy4Fc7b+pY+Fn2lXRQ9RzjRKTVCC7X81a/PuwhOaQ8/WVB4JSh4ZiMeE7JPoQ49mWlX8A/TjbAq8Xq+ExhluydGS6AX6Z6X3zKAJqzuNTAeSJz/et9m2KNHng==; 24:CRyX6PspOIWlckUJZVLMThMW/ja+G1FJqDQx85ou5HlejWyRmp2vuCz9Oe/DqlssWWeTCt5xFpCIFcwVJbWLnXMiF8pg5VRLouTAoYYVpFY=; 20:71nNRMUyF4qB2DwlYeasC3+tlwvOh6+xxp0vMdLV9IZb/qn7Zwpu/ILhEeJbVmWof1ucUosbV63M7HyTngg8Gg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 18:28:50.9960 (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: SN1PR0301MB1584 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=unavailable 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 Freescale i.MX6 ARM platforms do not support hardware cache coherency. This patch adds cache coherency support to the CAAM driver. Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/caamhash.c | 2 +- drivers/crypto/caam/caamrng.c | 4 ++++ drivers/crypto/caam/jr.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index dae1e80..9622a81 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -127,7 +127,7 @@ struct caam_hash_state { int buflen_0; u8 buf_1[CAAM_MAX_HASH_BLOCK_SIZE] ____cacheline_aligned; int buflen_1; - u8 caam_ctx[MAX_CTX_LEN]; + u8 caam_ctx[MAX_CTX_LEN] ____cacheline_aligned; int (*update)(struct ahash_request *req); int (*final)(struct ahash_request *req); int (*finup)(struct ahash_request *req); diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 5095337..a1d21d5 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -108,6 +108,10 @@ static void rng_done(struct device *jrdev, u32 *desc, u32 err, void *context) atomic_set(&bd->empty, BUF_NOT_EMPTY); complete(&bd->filled); + + /* Buffer refilled, invalidate cache */ + dma_sync_single_for_cpu(jrdev, bd->addr, RN_BUF_SIZE, DMA_FROM_DEVICE); + #ifdef DEBUG print_hex_dump(KERN_ERR, "rng refreshed buf@: ", DUMP_PREFIX_ADDRESS, 16, 4, bd->buf, RN_BUF_SIZE, 1); diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index b8b5d47..b7ec1ad 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -202,6 +202,13 @@ static void caam_jr_dequeue(unsigned long devarg) userdesc = jrp->entinfo[sw_idx].desc_addr_virt; userstatus = jrp->outring[hw_idx].jrstatus; + /* + * Make sure all information from the job has been obtained + * before telling CAAM that the job has been removed from the + * output ring. + */ + mb(); + /* set done */ wr_reg32(&jrp->rregs->outring_rmvd, 1); @@ -351,12 +358,23 @@ int caam_jr_enqueue(struct device *dev, u32 *desc, jrp->inpring[jrp->inp_ring_write_index] = desc_dma; + /* + * Guarantee that the descriptor's DMA address has been written to + * the next slot in the ring before the write index is updated, since + * other cores may update this index independently. + */ smp_wmb(); jrp->inp_ring_write_index = (jrp->inp_ring_write_index + 1) & (JOBR_DEPTH - 1); jrp->head = (head + 1) & (JOBR_DEPTH - 1); + /* + * Ensure that all job information has been written before + * notifying CAAM that a new job was added to the input ring. + */ + wmb(); + wr_reg32(&jrp->rregs->inpring_jobadd, 1); spin_unlock_bh(&jrp->inplock);