From patchwork Thu Mar 23 17:53:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9641745 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 46701601E9 for ; Thu, 23 Mar 2017 17:53:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3ABA227C14 for ; Thu, 23 Mar 2017 17:53:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DA7D28433; Thu, 23 Mar 2017 17:53:46 +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,DKIM_SIGNED, DKIM_VALID,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 7B0A627C14 for ; Thu, 23 Mar 2017 17:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752310AbdCWRxp (ORCPT ); Thu, 23 Mar 2017 13:53:45 -0400 Received: from mail-bn3nam01on0066.outbound.protection.outlook.com ([104.47.33.66]:37133 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752029AbdCWRxn (ORCPT ); Thu, 23 Mar 2017 13:53:43 -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=1aYtKvbGFBGcb5VWM+N8qdyrEKcJEOI+qHF3F/nNKRk=; b=WuwK4c/+u5pdjhfsD34lOwUDl/jUXijOChsK8qFu9llM75MEQig6TIzO8yturaWwg103RlZjKJQRobO/2vbDZCcH2TOSoQT2dwsmyXhCnV6OiHkQqvDaMfZKN6VSxV1HnS+YcjYVaUVWW0AFq1B15EKX4emL378HWzzwYyp02Ts= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from [10.236.19.42] (165.204.77.1) by SN1PR12MB0479.namprd12.prod.outlook.com (10.162.105.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Thu, 23 Mar 2017 17:53:39 +0000 Subject: [PATCH] crypto: ccp - Make some CCP DMA channels private From: Gary R Hook To: CC: , , , Date: Thu, 23 Mar 2017 12:53:30 -0500 Message-ID: <20170323175330.8742.62747.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR18CA0041.namprd18.prod.outlook.com (10.173.208.27) To SN1PR12MB0479.namprd12.prod.outlook.com (10.162.105.148) X-MS-Office365-Filtering-Correlation-Id: d4e81a76-55c1-4592-634e-08d4721589d0 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:SN1PR12MB0479; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0479; 3:iAN5mk1wYH6aq1OBeCjhVPizNHFFYYoKMP1IU8YItkk6AMCV8/+Rjbu3xMAns4QZnmVP2lvs9X4BFBrhFCrHi5MwvFRmkxb9W3MLQ2q+fklTnatvQSCsOFbI4Ym7Rd++35gkXxtcUwh08w7HZJAP5ez8zB5XajwswbPkU2rDjwbLkneNnCpxlk8N50NuZDEq/N8DhQJU85oTdN2R7k36+gcKo2raU6/JENugd1rkjj5PwT3bNQYcc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IXz2X2xjI6srXDeA2NNgyk20bxbAFkK00zEoyFTVzKgMsO15iruE/xjMrEIfF4LQHW23wXVqsRKiGQ7hwlwDTjeAE/U+cpmV5d9dofW823+8MlgIxbUMJAYRKsxh1Vgkf9kpMl49+/E2WA1/ZOrkSjE5PBRxxpgDJKT/VvZDTtLMksL/JRYs/a+7PdprQ/6GhgiyBEimFazk85mHtKXikufLn0L0iTJtmTaehct+80EAj2lPiums8ox2xeuaie3quggpZQaNNdBeGKr0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(20161123564025)(6072148); SRVR:SN1PR12MB0479; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0479; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0479; 4:02+xxKebTfyBkXVWS6z7Jz6W3H8kVIvv3eCp6W+pjc0jmj/OPgeA6LguONk39S9Rk5USJDROjffwqxKXQ8FKlSbhvIN6zwMm1C8Ox7YkYbde2MukZBHvMrGeS3Nf7TylR9PZBRb+pcwZfLwr8KmZb8E/zc4TIFi1cw3CZeNhgLAIw/3l8qbE2ueBVfSpqpRCzkkBHZJnujDMznw4Yco0bSmy5Nwm+LcQDWBj+n5+/lvnfDS85fN6fnzrsm5ZGmoytoFzJtiCLa/DdIV7B1pseCJ5TgW2g7UHwpgM5fVVSufLUxx1XVaB8teRWTKH55i+Ri59lUJMlaZtrquPtZVrtuLF3wXxeOMVTC210xkihKdIlJJBPIpkA9L9Qlpk0DSabAJyWOtIsaDrBclU1eUWpNevC48ogrJQd3Clzf6FTv62D9jNWXaOJTbiwQAw1gHjmH3DrKBJFaKBASaiMLRsItX9ONcz4nckHDsmlepkJ3kwA4Dj9wNVCQo8CtnTllNa4OIQAFObtt3sBkvXyyMBD9tub9aj0y1+l/zjam2+12nRSINxEWD4756vF0EWW2/lvy0XXEQdEqyXA1GXeJgBE5ywEPqxOFl7CzR3Yh3cj88rc2gVBzLBVrq65p/L28o9T8izsueXKS9BrbR73Fy/B/jeAVIRJXIxiZDm+OKDE8q+zDn72EexJYKDqDs4dmNZ X-Forefront-PRVS: 0255DF69B9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(39410400002)(39840400002)(39850400002)(39860400002)(39450400003)(38730400002)(2351001)(50466002)(4326008)(103116003)(189998001)(110136004)(97746001)(8676002)(5660300001)(81166006)(33716001)(42186005)(54356999)(33646002)(50986999)(2906002)(23676002)(86362001)(53936002)(77096006)(54906002)(230700001)(47776003)(7736002)(6486002)(305945005)(9686003)(6916009)(90366009)(6666003)(6116002)(575784001)(1076002)(3846002)(83506001)(25786009)(66066001)(2004002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0479; H:[10.236.19.42]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjEyTUIwNDc5OzIzOnplUjF6ZnNDbXZYOGdKTmlrMUpKUjZBSnY3?= =?utf-8?B?cjlUVnBsV2hwdE9xLzhsT3hoSlErNjkrMnFPOXV1KzV0VFduWWZMdWVEck85?= =?utf-8?B?UEV4TjRRYmxDVzVlaE80WlBTYTB3cGZqOThIMzUzZXFyNFJmWFBPam11QWYw?= =?utf-8?B?VXZ6Y29ZcU85T1pMRnVoMnc4M2xScTZTRy9FZXBTenpUK0lwREVlRmRzaHZr?= =?utf-8?B?RUZZaU02RE4zcDUwaTJFUklFTFd4ZWwyaURpRmYyVW5XcUdSbHQwMHZndWor?= =?utf-8?B?RTArZ0tRd3luVWRSWUZPcWgwRXM1Nm5ENjA3b3lQZEdEUVRQc01nc1FJSFRu?= =?utf-8?B?N0F1UnlZeHUrMXRuSFBZUnl0M0FQTEpPTkdONVNHNVp1Y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zUj5IMOO9MSp6CfbHFY+PbeALea04m8+PbKPSDM/nVRkg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0479; 7:ysd+n7KhjMKvUBkNfo4rNVkpHw65kdKEXuGXekfmyV1lAWD25AmbGcEy6IO0aVmhA5DZnL9CUenrf5d3QMMfiRpicpXsaIYbzW4U0iizaXw8jn7cxBAG2AmUuDDJcfd2lft4k/daeSuFZioe3rM0iqFVAwWG1+IMtUy8UEaE0MLrWDFy3kO9fanG/cwELK725UyxFik1Z11LpmDkKWhpk9xPwg4t6mzpX4dk7CD27BagBsUtBWJ6/YaUUCsKYCuynksB5HP+N5AnsWQ/yY7O24/3o3D+ogtOO/4KTppn/o7mL2hwJmwliF6A10u3nBOnrmEkXMVmZ5LKQab8LjrLow==; 20:tJg9/ie/Rx9vYMIQ0jvKLCmxkg2Ym8OW/4OVw/8DaXycs6njsuElDIycE7T0KGZeluRH8KiIgkjymGrqXhWDeMDT4Yauz81+z3XKFqf6SRUo/A0pvXwyNvMGPcGLSNcKl1atO4SNk8O8vidJtZ+lxdULV9gy54KlBJXGQxIeDhBc06tl0o7rNfhfvF1OCcWLmOKsfNUJ9mWt3vc6DTiz6cGUQvQtW9GZ9BKzamYFjpZN8knSrB1B+IIFM4/ZpkqS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2017 17:53:39.4964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0479 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 The CCP registers its queues as channels capable of handling general DMA operations. The NTB driver will use DMA if directed, but as public channels can be reserved for use in asynchronous operations some channels should be held back as private. Since the public/private determination is handled at a device level, reserve the "other" (secondary) CCP channels as private. Add a module parameter that allows for override, to be applied to all channels on all devices. CC: # 4.10.x- Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v5.c | 1 + drivers/crypto/ccp/ccp-dev.h | 5 ++++ drivers/crypto/ccp/ccp-dmaengine.c | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c index 41cc853..fc08b4e 100644 --- a/drivers/crypto/ccp/ccp-dev-v5.c +++ b/drivers/crypto/ccp/ccp-dev-v5.c @@ -1015,6 +1015,7 @@ static void ccp5other_config(struct ccp_device *ccp) const struct ccp_vdata ccpv5b = { .version = CCP_VERSION(5, 0), + .dma_chan_attr = DMA_PRIVATE, .setup = ccp5other_config, .perform = &ccp5_actions, .bar = 2, diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h index 2b5c01f..aa36f3f 100644 --- a/drivers/crypto/ccp/ccp-dev.h +++ b/drivers/crypto/ccp/ccp-dev.h @@ -179,6 +179,10 @@ /* ------------------------ General CCP Defines ------------------------ */ +#define CCP_DMA_DFLT 0x0 +#define CCP_DMA_PRIV 0x1 +#define CCP_DMA_PUB 0x2 + #define CCP_DMAPOOL_MAX_SIZE 64 #define CCP_DMAPOOL_ALIGN BIT(5) @@ -636,6 +640,7 @@ struct ccp_actions { /* Structure to hold CCP version-specific values */ struct ccp_vdata { const unsigned int version; + const unsigned int dma_chan_attr; void (*setup)(struct ccp_device *); const struct ccp_actions *perform; const unsigned int bar; diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c index 8d0eeb4..e00be01 100644 --- a/drivers/crypto/ccp/ccp-dmaengine.c +++ b/drivers/crypto/ccp/ccp-dmaengine.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -25,6 +26,37 @@ (mask == 0) ? 64 : fls64(mask); \ }) +/* The CCP as a DMA provider can be configured for public or private + * channels. Default is specified in the vdata for the device (PCI ID). + * This module parameter will override for all channels on all devices: + * dma_chan_attr = 0x2 to force all channels public + * = 0x1 to force all channels private + * = 0x0 to defer to the vdata setting + * = any other value: warning, revert to 0x0 + */ +static unsigned int dma_chan_attr = CCP_DMA_DFLT; +module_param(dma_chan_attr, uint, 0444); +MODULE_PARM_DESC(dma_chan_attr, "Set DMA channel visibility: 0 (default) = device defaults, 1 = make private, 2 = make public"); + +unsigned int ccp_get_dma_chan_attr(struct ccp_device *ccp) +{ + switch (dma_chan_attr) { + case CCP_DMA_DFLT: + return ccp->vdata->dma_chan_attr; + + case CCP_DMA_PRIV: + return DMA_PRIVATE; + + case CCP_DMA_PUB: + return 0; + + default: + dev_info_once(ccp->dev, "Invalid value for dma_chan_attr: %d\n", + dma_chan_attr); + return ccp->vdata->dma_chan_attr; + } +} + static void ccp_free_cmd_resources(struct ccp_device *ccp, struct list_head *list) { @@ -675,6 +707,15 @@ int ccp_dmaengine_register(struct ccp_device *ccp) dma_cap_set(DMA_SG, dma_dev->cap_mask); dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask); + /* The DMA channels for this device can be set to public or private, + * and overridden by the module parameter dma_chan_attr. + * Default: according to the value in vdata (dma_chan_attr=0) + * dma_chan_attr=0x1: all channels private (override vdata) + * dma_chan_attr=0x2: all channels public (override vdata) + */ + if (ccp_get_dma_chan_attr(ccp) == DMA_PRIVATE) + dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask); + INIT_LIST_HEAD(&dma_dev->channels); for (i = 0; i < ccp->cmd_q_count; i++) { chan = ccp->ccp_dma_chan + i;