From patchwork Fri Sep 30 09:09:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 9357889 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 103BC6075E for ; Fri, 30 Sep 2016 09:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 019D629F5F for ; Fri, 30 Sep 2016 09:43:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9EDF29F61; Fri, 30 Sep 2016 09:43:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CA6529F5F for ; Fri, 30 Sep 2016 09:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932431AbcI3Jne (ORCPT ); Fri, 30 Sep 2016 05:43:34 -0400 Received: from mail-cys01nam02on0041.outbound.protection.outlook.com ([104.47.37.41]:5332 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932413AbcI3Jnd (ORCPT ); Fri, 30 Sep 2016 05:43:33 -0400 Received: from BLUPR0301CA0042.namprd03.prod.outlook.com (10.162.113.180) by BN6PR03MB2435.namprd03.prod.outlook.com (10.168.223.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Fri, 30 Sep 2016 09:09:44 +0000 Received: from BL2FFO11FD054.protection.gbl (2a01:111:f400:7c09::124) by BLUPR0301CA0042.outlook.office365.com (2a01:111:e400:5259::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5 via Frontend Transport; Fri, 30 Sep 2016 09:09:44 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BL2FFO11FD054.mail.protection.outlook.com (10.173.161.182) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Fri, 30 Sep 2016 09:09:44 +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 u8U99frh015747; Fri, 30 Sep 2016 02:09:41 -0700 From: Tudor Ambarus To: , , CC: , Tudor Ambarus Subject: [PATCH v2] crypto: caam - treat SGT address pointer as u64 Date: Fri, 30 Sep 2016 12:09:39 +0300 Message-ID: <1475226579-2078-1-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131197001845935947; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(5001770100001)(97736004)(5660300001)(50466002)(189998001)(5003940100001)(33646002)(104016004)(48376002)(19580405001)(87936001)(2906002)(92566002)(19580395003)(4326007)(8936002)(86362001)(2201001)(85426001)(50226002)(36756003)(8666005)(11100500001)(106466001)(356003)(305945005)(586003)(50986999)(81166006)(68736007)(105606002)(8676002)(81156014)(626004)(69596002)(47776003)(229853001)(77096005)(7846002)(7059030)(4720700001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2435; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD054; 1:Xp36NZ8KFsXIM3R8vjibP1TSGfx7Vd3f0iAY8tHjA/XYfz0H6i4R4ot/ammoR4rHJ/HpPsRiqduUkAIx3s7cNw8yukhb4zvXS4sak+WdsWMYwrXC2EtAkQKFz8ux+I1kWWbMEuJT8QD8OvgUTuAbrzyN/LC3B1hs7KHL5wl26A69bQ4Z3fjFmRtKkd4huQL3J/5yMbTw/GYuVDkV21QCocgl0ammdRVTt39Cr03nHspdplAtQj+5/A1rCiBFXO5wzTt83qiStjys8Uyt+sFd1PA9pNfr2wtirshbZK3VAi0NPyVBj85Ac+Jth7rf+4YUqAdNTyXQVjPcEctY2P4vbBJ5Zm/mffDi4O14Z0C0YMHWpFQLs7NPRTllM9f98tqkeG8rhjt7cdlFqLU6jjanawII7H97sG5SZSCBrYSiJIJGCH5YxCFv00krPCsXCwixuHVah6FJBK9nQrXwRigDlbEE6MohtGNbtNCoJ1osOBXNq+IitIzD6fgMUtwURYc2bpCPaIWXLwzfXakVaK0/6zjjMHFeGcAxvlJe9GrF78BGfht9u9rWxs1EmbUQFGTvfVQpMFxNkySznb5TV9JvWrgnA46HlgcxAIkXE1fYi0ISq1Uh6+5ne9VF2S9DPpwR/RyXPkpHuf1c3t6MUKwcyGwypIQBYmv4rHK0szyinEy8n492Mls2eT/ekfBDGWDM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 57f21c05-d140-4257-8f4b-08d3e9118516 X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2435; 2:2fMeM+KYEqd6zPc1wARZ1+Xbb6TzWiSLxndmnX6gwSvm2CIzBfAe+XwlaRIQ7m6RU/ZRGQ/QU7nOfJi2XaZbWoHLCZOKv24U9xbdKJeT38aX0LdgwAxcVchlDtI1+a0pLdwOMBWe+maRK7YOqO6DAu7rFLkovSidgxmm0+FV67rQ9jwXv52ddcZh5myYAD9M; 3:MncBFAiHzpGFjS3weSr4m3aP/awK4hH3JVrECAdaa5Ia1CrwB9dS4CHBjcjPcVMObHT39Uty100KR9SnHbitenPD9dlRIijNr6SvimpgLuH0CTxuSAQL8rkQOUr9MWmq6u6/lGGeut12GFMsQ4zSDocLUGmsUdUyO1hb6G2cGtqFcSSGglN4bSj9ZBakI/GWG4zRmbuO22YNioM5q5dBhofK1QvYYnV59H6Mmz0tWBc=; 25:YSbl1gvm1y4No6g7ANHPalFk/++38mCbOEc22vkdXzw5AO3pJF+DRZiN9nhRi6l9Itu99I+LOgZHRGL7c1fD4X5i6C4sBSOWxfIzfzVloQuE6SVEgQEGxZdyZl8VpqoAZ0odJ4CpbyfJ7JqivvBtPgytKHebASRKPX0QQq27uWXXtIBB6yZguYeNwPj+egmC489IKNY/6D/R3vzvNr3MJ3LHabxYXvTD0S4LmjLNlCqdouS6RSP4oS3L6dJPdjEDpkzuwvD212G7f5WOtjYNndhfRZHenIIGw8u4B9ITrn82K9HxOj9ch89k/fj8ExNFTNdZm51cey2iDFACMt3kwmMnLBqXX7Bguh82IqHl3hW2Ve9Nh8d5XUbgfaJk9RB9lonHiCC6DmA5TvAxbSx4KaKyqvv7JRY51384SKPBNbw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR03MB2435; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2435; 31:tIruAlwNzER1qJrOWYJNkNh8hR0A1m6BBe3IxJ8F+2FIrl9xLFQoOAeHK7qbkFn1nTzcFRtf+mw2YwPu9s6vXSSzUbdXru7Q+N2htFOTI9RnfJyXMGzO4RBXpqj0gGMo1wQde31Bd0rPsdT87Ft2T9pE9/sLEv1yc3nO/qmtQXwL7YZ5KgP3j4s3aC+JgS+lCFsnPOgUzdK0K4y0CEDKCYymr01bTsbe4afr206gFXw=; 4:f+k4Ogy5w/n+29oMBJmjxFLhUn8VtI+9PzoemqkQI8P59vKNyeYwbB+oesIBvIaE5m0N5tIx1aAaGkr8WC2nwYYGaSuKXosCGLf/pRDa6Ypp6cD3q1d9OVOyqERQS7IeST1469RMg1GgPeeRy0j7eHFKL8hVHLr4sRNazhUsh7Cl3BGfxNJPzyvo78hw0dcrkB14tTY4edvwzJGlKN+hborsVaMhxOwjZiPNHCuqTWtjMAncA0GcHdFLbD6Vxxkd2qGc7IqBa1zaEHvFQQ1uv3iRQqpfIMLrzxMD4OUPHbnjXVk/8Ntz/P+w7llLhKjWlN6ZQJ2ThZxnQREoKnYkoqEoRegEYV+cqiww6sy3wgFeGzGyIN03Yg1vTBMl2f96uZyhKczspUZ5zNnHJrYY9usyZd8Z1gbNbtzPlpOcTLEtAKU2sjee9rHqPpe1UO7aOfGTfJqTMcto88MstXGzoyE2nkZN/c75pB9+YVqz/JfndWTwVULFJgH5dhrfhCVx+DDWr0SOSYdBPNwX8hMFHnfiIzKyTSJmj2sahA8ndHg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13023025)(13017025)(13015025)(13018025)(13024025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BN6PR03MB2435; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2435; X-Forefront-PRVS: 008184426E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2435; 23:xavb6GSeKMrp/8O8Gj16Y3bbN2UwfFQvKjEt+9FNU?= =?us-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te2q2oQ+Lg89J342V2mQesFPrCTwCu0/H8A5gI0pK2xzdH/00BNUpEiUyK3V85v2WHNRk09SG4r/3lhpxbk29T2y7lNpV1Tzd7CR9rpxocXSohZgMkKHmk8911lB2TWFoOLSf9muJE2NdDsb/Hr51gTgQejGSnMfU2gdlzyowZnICp/WOEtBzhwr7Yq7mpoZM+PDN13ku46c2qfRsqIRXWW3sIFglLh33su6V7Lvops0LT0XjgdLjDwbUbAQbG4jl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2016 09:09:44.3751 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2435 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even for i.MX, CAAM is able to use address pointers greater than 32 bits, the address pointer field being interpreted as a double word. Enforce u64 address pointer in the sec4_sg_entry struct. This patch fixes the SGT address pointer endianness issue for 32bit platforms where core endianness != caam endianness. Signed-off-by: Tudor Ambarus --- v2: Removed mx7d restriction. drivers/crypto/caam/desc.h | 6 ------ drivers/crypto/caam/regs.h | 8 ++++++++ drivers/crypto/caam/sg_sw_sec4.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/caam/desc.h b/drivers/crypto/caam/desc.h index 26427c1..513b664 100644 --- a/drivers/crypto/caam/desc.h +++ b/drivers/crypto/caam/desc.h @@ -23,13 +23,7 @@ #define SEC4_SG_OFFSET_MASK 0x00001fff struct sec4_sg_entry { -#if !defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) && \ - defined(CONFIG_CRYPTO_DEV_FSL_CAAM_IMX) - u32 rsvd1; - dma_addr_t ptr; -#else u64 ptr; -#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_IMX */ u32 len; u32 bpid_offset; }; diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index b3c5016..84d2f83 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -196,6 +196,14 @@ static inline u64 rd_reg64(void __iomem *reg) #define caam_dma_to_cpu(value) caam32_to_cpu(value) #endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */ +#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX +#define cpu_to_caam_dma64(value) \ + (((u64)cpu_to_caam32(lower_32_bits(value)) << 32) | \ + (u64)cpu_to_caam32(upper_32_bits(value))) +#else +#define cpu_to_caam_dma64(value) cpu_to_caam64(value) +#endif + /* * jr_outentry * Represents each entry in a JobR output ring diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h index 19dc64f..41cd5a3 100644 --- a/drivers/crypto/caam/sg_sw_sec4.h +++ b/drivers/crypto/caam/sg_sw_sec4.h @@ -15,7 +15,7 @@ struct sec4_sg_entry; static inline void dma_to_sec4_sg_one(struct sec4_sg_entry *sec4_sg_ptr, dma_addr_t dma, u32 len, u16 offset) { - sec4_sg_ptr->ptr = cpu_to_caam_dma(dma); + sec4_sg_ptr->ptr = cpu_to_caam_dma64(dma); sec4_sg_ptr->len = cpu_to_caam32(len); sec4_sg_ptr->bpid_offset = cpu_to_caam32(offset & SEC4_SG_OFFSET_MASK); #ifdef DEBUG