From patchwork Wed Jul 27 00:10:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9249145 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 2AF9A607F2 for ; Wed, 27 Jul 2016 00:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A37C26A4D for ; Wed, 27 Jul 2016 00:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8C9276AE; Wed, 27 Jul 2016 00:26:39 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3BD3F26A4D for ; Wed, 27 Jul 2016 00:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756823AbcG0A0h (ORCPT ); Tue, 26 Jul 2016 20:26:37 -0400 Received: from mail-dm3nam03on0078.outbound.protection.outlook.com ([104.47.41.78]:43648 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751583AbcG0A0g (ORCPT ); Tue, 26 Jul 2016 20:26:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vX4XSHrvAHHUAIRmvEqS9W6gahP1TUhDnCKp4dE4KYQ=; b=AwuhcfKR1BIckCP5oNzvDq8ZuxdHtFGaZNfoaa7lqPKm6+l65DNhk0ZFHmfAMfdECk0F6u26H6q2u4GfHbNXdt+c8CxYNn+R02XPkgisn7TucH4Z+EBdRQ4Xh7y9Xu4IcrWkGGPP4lNxlqNKSQuay+oB4dXi8/6W6daXAINrnGY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by BY2PR12MB0338.namprd12.prod.outlook.com (10.162.84.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.10; Wed, 27 Jul 2016 00:10:34 +0000 Subject: [PATCH 08/10] crypto: ccp - Add support for the RNG in a version 5 CCP From: Gary R Hook To: CC: , , Date: Tue, 26 Jul 2016 19:10:31 -0500 Message-ID: <20160727001031.24944.90779.stgit@taos> In-Reply-To: <20160727000652.24944.44919.stgit@taos> References: <20160727000652.24944.44919.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY2PR21CA0038.namprd21.prod.outlook.com (10.162.74.176) To BY2PR12MB0338.namprd12.prod.outlook.com (10.162.84.13) X-MS-Office365-Filtering-Correlation-Id: cecfd7be-aa5b-4ab5-7761-08d3b5b26e3a X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0338; 2:qVEQ3OfH/t8/+UfTUfpE/11W2/VfNopXmzilfzYviGx43vBFWrboTIcda9eX772SrPVccY07n3S9Uzs72D+4Ef1MlEu6EF6OhS4+2c1na0jsSaSXZFt4D5Qab4RgWOSa0Rxi+9YTL2KJiYUsxFh7xgjkk91aSq+SJknMBEORFgpD90p5b3acQJdJopG4x6iZ; 3:Ixd4xKe8cIa8TFL6dGXmzRKMcyooVncbP4toWW8IUQdn+RYqKnczrg68k9Exe6uP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S/M3WAT0tdh1YcaG6nKp4mfpAFll9263bshPt/eDto+s0mFTrwqBdXhFUqvJkwHtSD39uds/8SbxcoHO+t620iVJ2Q8usCHi4l5MHJINd7PrgSWwSHGnuOL1rtBoSpbQ8zGORmzC231FoCb2/UgR65xEPYgSWUbFo/xW8fR9FscBaew/0cPjR5877ZwooDFPyFmFid0qOt5VrNLu5gOMHZrYJligmGUp8VNQ+d7E2AA1dj0HmSKtg6ChQ; 4:6olj1nwAJO2EY1TVvexU8NoDkezLEnh1pCv+efBJLsg0z/q8EU3GUJrH8L6WRk3psaGVwnhSecV9Kg+EOBfJIRtjUYsSrVY6Ikl2I0VUJDuiKWooa5MES3sRfz7zncD1f4iEtjPWfHkwbOWafu+coMJLNoWXYz8KG1P/1AgkjvZF5sSEsHBYeTt1JoFzGuv+yM8y71VOUZzqruTW2Lghe7SI3Yv+eIRCV1rSY8dPEl+9fMN6vA8atwYN6OgG9WZ4yxuaufAED2TKFxtRo+diAQIoV3G0PjQdaYLqpiINTTg76tavqKScZ8k4Xqx6fL8IkUxRlDrrv2hEJW0LT0z2v0e2i3lcXPsnynAZ/kIx0+UaAeKHMvzP8yDDzcIWxTWsgUCEehnpPBAFBWL4WPwK2AEEt9XZPybMILxzvC ZHI1hkFEBd1jGlxr+pzOfIC3Vq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR12MB0338; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0338; X-Forefront-PRVS: 0016DEFF96 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(6049001)(7916002)(199003)(189002)(105586002)(42186005)(47776003)(50466002)(1076002)(9686002)(103116003)(86362001)(54356999)(50986999)(23676002)(97746001)(19580395003)(76176999)(19580405001)(68736007)(189998001)(3846002)(586003)(6116002)(83506001)(2906002)(8676002)(66066001)(4326007)(230700001)(4001350100001)(110136002)(97736004)(2950100001)(33716001)(7846002)(77096005)(7736002)(305945005)(2351001)(229853001)(33646002)(106356001)(81166006)(81156014)(92566002)(101416001)(71626007)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0338; H:[10.236.19.42]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwMzM4OzIzOmhTSldNcTVoS2JGQWQ2SVR4cnZYNmovOThp?= =?utf-8?B?emNFZXdXZ0xDaFdzcHMwc0JsL09GZng4TDZuNzE2cG90TWJvTkFQZEUybU5L?= =?utf-8?B?OXRHM2h1dndpa3VoRXBKeFlSNXRkaEhSbGNGTmNnTkNBZGhRZ0JaeVdCT0Jz?= =?utf-8?B?TXhHMFRvL0JBbWdtaGYwKzcxY1UwOXZQMmgxakhJdE5hYlY1ZW1HdXpsR0FZ?= =?utf-8?B?Q1JwU09FOEVHNkI5VHE5NEFRVHZ2bk1DSHBndDJvMzdsdkErTk40Y1NuV0Ja?= =?utf-8?B?aTArUnE5QjF3VVdBZmd0Z1JlMDlHbjJNWWlMWWRUSTF3amxJWU9mbURsbk1q?= =?utf-8?B?NHFUSmdHeUIvbkRBU1Q4cCtXelNMeDNrYU9SQW1XbFc3VHhaSEhZTnpPUWtt?= =?utf-8?B?bzRpS1l4QzdNQVgvRXpKWjRxV2xsK0NzalhjSWJVdnlMZ3MvL1FNN2Z3aVJx?= =?utf-8?B?SnJSejZTZkZHK1NzN1drQUJYejlET3FrRE5iYm9pcWdKbDkvZUxVdHRTWDFE?= =?utf-8?B?ckhoUHlkVzhMRUFBS3ZqcnhIclM4MTVOQ0hZM2R3Y05PdVFHUGVNSmQ3cG13?= =?utf-8?B?YjRaM2F4RllVZzYvbENVWnA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DeHubU7bLkRXzK99q/mBTj13kBTB/doa4ukAqxZ2bMcs7BEQftfNda/bDUQfZuJ6reRPz2bdYAP8tsQIFXFURd3WnEeopTo/1LEiAEVVzUrW1/nbxv9Vk+s8tvzGC3EPaGW4L72Z5VMRTGrMLTDZmKr9JH2d4jaKj+u0RTKK9X28p+oBh1hdoe4l/kDMZ/rqyFHcPJvuGKK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0338; 20:/nEzmJS9R9PPUMTmPt/UM+aoTXoRLEj8MnaqrZW7OhMjZLlm5R8fPJUqsha75Vqp2KohctXWD+nww4qt6/2JHnFpbWIagNPjna/ahBAHQmqN8TkCA7WGr8sQHO0BYxsDei9c6q3kpWsTpYdMkC4+L3v9VZLfz41Ej1LcuR/QisaY+xHW9mtaLhdVfdpt1J3eI63MwAF+PpHhWQ0Ss4xqfIdmEYzGtICzrKZBX63cgitZpoWsmHzUAGU9ogZ2MAP6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2016 00:10:34.4060 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0338 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 Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v3.c | 13 ++++--------- drivers/crypto/ccp/ccp-dev-v5.c | 7 +++++++ drivers/crypto/ccp/ccp-dev.c | 23 +++++++++++++++++++++++ drivers/crypto/ccp/ccp-dev.h | 2 ++ 4 files changed, 36 insertions(+), 9 deletions(-) -- 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/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c index ff2d2a4..578522d 100644 --- a/drivers/crypto/ccp/ccp-dev-v3.c +++ b/drivers/crypto/ccp/ccp-dev-v3.c @@ -432,14 +432,9 @@ static int ccp_init(struct ccp_device *ccp) dev_dbg(dev, "Registering device...\n"); ccp_add_device(ccp); - /* Register the RNG */ - ccp->hwrng.name = ccp->rngname; - ccp->hwrng.read = ccp_trng_read; - ret = hwrng_register(&ccp->hwrng); - if (ret) { - dev_err(dev, "error registering hwrng (%d)\n", ret); + ret = ccp_register_rng(ccp); + if (ret) goto e_kthread; - } /* Register the DMA engine support */ ret = ccp_dmaengine_register(ccp); @@ -449,7 +444,7 @@ static int ccp_init(struct ccp_device *ccp) return 0; e_hwrng: - hwrng_unregister(&ccp->hwrng); + ccp_unregister_rng(ccp); e_kthread: for (i = 0; i < ccp->cmd_q_count; i++) @@ -475,7 +470,7 @@ static void ccp_destroy(struct ccp_device *ccp) ccp_dmaengine_unregister(ccp); /* Unregister the RNG */ - hwrng_unregister(&ccp->hwrng); + ccp_unregister_rng(ccp); /* Remove this device from the list of available units */ ccp_del_device(ccp); diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c index 16dad96..ddce220 100644 --- a/drivers/crypto/ccp/ccp-dev-v5.c +++ b/drivers/crypto/ccp/ccp-dev-v5.c @@ -828,6 +828,10 @@ static int ccp5_init(struct ccp_device *ccp) /* Put this on the unit list to make it available */ ccp_add_device(ccp); + ret = ccp_register_rng(ccp); + if (ret) + goto e_kthread; + return 0; e_kthread: @@ -852,6 +856,9 @@ static void ccp5_destroy(struct ccp_device *ccp) struct ccp_cmd *cmd; unsigned int i; + /* Unregister the RNG */ + ccp_unregister_rng(ccp); + /* Remove this device from the list of available units first */ ccp_del_device(ccp); diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index 6b44730..38a98d8 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -119,6 +119,29 @@ void ccp_del_device(struct ccp_device *ccp) write_unlock_irqrestore(&ccp_unit_lock, flags); } + + +int ccp_register_rng(struct ccp_device *ccp) +{ + int ret = 0; + + dev_dbg(ccp->dev, "Registering RNG...\n"); + /* Register an RNG */ + ccp->hwrng.name = ccp->rngname; + ccp->hwrng.read = ccp_trng_read; + ret = hwrng_register(&ccp->hwrng); + if (ret) + dev_err(ccp->dev, "error registering hwrng (%d)\n", ret); + + return ret; +} + +void ccp_unregister_rng(struct ccp_device *ccp) +{ + if (ccp->hwrng.name) + hwrng_unregister(&ccp->hwrng); +} + static struct ccp_device *ccp_get_device(void) { unsigned long flags; diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h index 5ff4a73..d04bd61 100644 --- a/drivers/crypto/ccp/ccp-dev.h +++ b/drivers/crypto/ccp/ccp-dev.h @@ -601,6 +601,8 @@ int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait); int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd); +int ccp_register_rng(struct ccp_device *ccp); +void ccp_unregister_rng(struct ccp_device *ccp); int ccp_dmaengine_register(struct ccp_device *ccp); void ccp_dmaengine_unregister(struct ccp_device *ccp);