Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbdIRUmv (ORCPT ); Mon, 18 Sep 2017 16:42:51 -0400 Received: from mail-by2nam01on0052.outbound.protection.outlook.com ([104.47.34.52]:47731 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751074AbdIRUjz (ORCPT ); Mon, 18 Sep 2017 16:39:55 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Roy Pledge To: , , , , CC: , , , , , , Roy Pledge Subject: [v5 03/12] soc/fsl/qbman: Use shared-dma-pool for QMan private memory allocations Date: Mon, 18 Sep 2017 16:39:38 -0400 Message-ID: <1505767187-4596-4-git-send-email-roy.pledge@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505767187-4596-1-git-send-email-roy.pledge@nxp.com> References: <1505767187-4596-1-git-send-email-roy.pledge@nxp.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131502407940223129;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7966004)(336005)(39380400002)(39860400002)(376002)(346002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(50986999)(3450700001)(189998001)(5003940100001)(48376002)(50466002)(33646002)(2950100002)(105606002)(6666003)(106466001)(54906002)(53936002)(104016004)(2906002)(76176999)(43066003)(305945005)(36756003)(50226002)(85426001)(230783001)(8936002)(356003)(97736004)(498600001)(8656003)(47776003)(81166006)(4326008)(5660300001)(81156014)(77096006)(2201001)(8676002)(86362001)(316002)(7416002)(68736007)(110136005)(16586007)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2702;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD039;1:z5Y/W1Bels9i+qeuHn8hJPwfUyLs6rYhXsTOTqyTLBpiwARkw0aMubfzed/Q6v7+P64h1L+FnfzW4X/S+R9Lmf+jN6qj3BEOUdzYtfZtS8Kz4bhNEUAAJHBRlwvXgkye MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 344648fd-038a-417a-b099-08d4fed56ad9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR03MB2702; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2702;3:ce6oIERqMjkVb2CVt7du4r69JcmhjL+geUT8kYgQKowvNksYiLWIvWndhd1ZxUv0K4/H7z9t+tAhuCWt1mGUS+rwLQOWLhJe50qwYVgKRLFGQ35mDrrd9nfNRzDUY2FzWxHdeUHZ/TjODIk5McmfBEJBVC6Pl85R5St3xbkG3rq1mfO3zYKJsslYpSZH4QHpzJ2C7T1YZqTT1WjPlA446SKRM7jsSrU0xxHHirpKAk1KNyuQ9Amak5jkkAS9vK25UgeJLz6jytuKuYmv0SZRiRG236BilvxDyiYm4lH3OByhjkAOfXSkCbBnNZwnCd6RvNZoQVQUYZY1yWIfdiWC0cypyKH0rDs0awbbMAbAJQ8=;25:A49Vadxe6aEpmLU80h7Bd8KoK7aBlLKRbEWv7aF4aN+XNbFFZE4BRnPC5ftow64oA5ZPobKrsfe1THdRNlCPdW2O5lG1n5L+F5Z9pI2QdO0KY0gCFhehvwMdz1XvW02LY1Q9cjg+MWEaVhynutC4sprHlBlVWEK7aYwp/e++xJ02stwGFQZ36JBldP4Jie4UO7CRFOc7RwQvZOvDBJIUTvtCpU9NZV9nrCbkR+I7fD320ZGcBNiHJpE/KZLtOQF4T4FlXfzj/ZutrqBF+7rOuTWzIkCr92u1nHtsu9HbhJnoQchlu7lmbeWAe+yjfAmdY57UrnL9kArLUqGHisnPAg== X-MS-TrafficTypeDiagnostic: MWHPR03MB2702: X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2702;31:TAxbZZdR9uMBoQHPw+Do/ezdE4en6Xe3hnQTgrso+U7Q0GkNaA97gwZd4lmOfM1d6Z8aU4xbBC63EGSIVW/WMFncjZ/+ZaaNrXnHnbgMfkublr4Zx2Jndbokl8fwgB8ri6jCqk7I3R15MtP/qu0t+wcIHfOXgsiujG4ErMz7VqrrL3JQKw6XsSyn4fWWYPBEcacKqeaUqQw21l4juQJXQwsW9lb57WJBRpFWUxFX2so=;4:G0PAtnXK6S0xch4XNSBVrfgFKMvggO6bCp+zY/as/TD4d+QOIdiQVr/E0OmfcFqlx9BtNftF/SY8pE0iHeXl81YXUekhref2oEeYS/wJeByHgLlF3PO+uijbNcsbMHLJtRN7vbzBa8hKNjXMyNNgz+YnzqWSz1g6vx26zNPkRowlVWpfQa3cJJxOHCBNRKgKxNzECTKbY7ZU4YovZy3JiiUfZcbpcZeOk+dESKj8Wyet8HPO/lxw4y89K9b48R9cwhDozxym0xdAmF7wG0lYqIbWv/b7CYB48CWEVjU8lg4= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123563025)(20161123559100)(20161123565025)(20161123556025)(20161123561025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR03MB2702;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR03MB2702; X-Forefront-PRVS: 04347F8039 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2702;23:hW2N19zzJ911RW/gHDX4C2229ohEcYfipXbiQdHJf?= =?us-ascii?Q?NUj/xdyVI9W2d7TuapV5nf05yx+mroKWmJ7SmXhfFiS3iKl/7d7mp6o0nqjs?= =?us-ascii?Q?fc5Sm4mzcp6FhHzhdWR03XverCTXs1tdizGfU5c0tzBPp86XiHw2YYTyF4sN?= =?us-ascii?Q?u76HF3LA4vqKgqoDS7dmrXK9l+0/Xnuiz9mzkRqdLUXBxhTbjvEqOnzblSUe?= =?us-ascii?Q?ylcRGph6QLivAx8oELu2eKg/79NmQHWdEmGlMrb0Kx6d3byyEfQr07jQcTqb?= =?us-ascii?Q?RQvupHbj18pthNf6oaC5DXBIM3VXHkncFxwFvJ7S+RXtevlNIOXIazsdiUXM?= =?us-ascii?Q?J6TLqQEOyvGLe8H6MLGL+bKFkveXGFnNI/6aP1HAHJTuHk0U16kgB5lol7H4?= =?us-ascii?Q?vOPXB4sulTK697XxReQfvu55dguC1URWCpkmgRn+QwcwQDiZwWS4VAfSwnie?= =?us-ascii?Q?uZmgOOQr1nN7uqremq9MwC5lK1zBiZ8Vz3ntBXE0Why2eSyGALmGJYnPQ19s?= =?us-ascii?Q?cnj30s0N5Y9N1Z/UkJKGxeMyLAeyr55LaEw1X1Yx/hrpSLToV6O3TvrV1Iuo?= =?us-ascii?Q?5kBWPfDnLzm0KzXYPjANVBR30v7x0s0yC7TIO7JlI3hndAirU/2Nic6eQUD6?= =?us-ascii?Q?r/79AP/lODF0lDtTy4xkx4G7WtMLNpQK0ON1DvZOwD9SJlbvwFeKdV2s/zsd?= =?us-ascii?Q?NW8TgQzz5PmC4AOnn+7MzDy76XVXWxqfewD2ouF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VMqxQv7Lr8RiRIQ==;5:VSNerCgS6X8cfz9l9biYFJ0c+bGy8NDXyfOYUD/Z9wLx59P5CACB3ffFB5zcxJ7B4sKSHjMRQiNcpwQ6wXA6DNBIWMRw/sn7hXCgrbRET0lgyRqNL9exZ7YbmXj08VZh96mioeyt6aSEyJ0uhDdNdQ==;24:uHKBc22kX1vWoGR3qkODFeFUdy2XEqv87CTGo65xtUCrRLaDlWasaKPYgqQfGOBmi+qvQ90WcBvkS+eBo9xmk01f8RZz1O41jPAmrukrhhw=;7:66Kk2N6qsIPdbQPcKEdI5+8wYtx114d3sbzrzxmPWrWLp9171DB1CrvkB6MU33G6jrTHSqut4imAybrnfcJDk8XYvoVBVuk4oGHYlqba36ExblGXatlMoIecPRGiLXRw9fYnPlo8m/6slmBgMFTzWlSIejXTEiyRJgAwypmqtOWqHFtXt7u+FxA5qpCJt7J34JAvwyJsvn/yKJtP2/PvoThRb2iLjAEvqsMT0mmwBlk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 20:39:53.8507 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2702 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4887 Lines: 170 Use the shared-memory-pool mechanism for frame queue descriptor and packed frame descriptor record area allocations. Signed-off-by: Roy Pledge --- drivers/soc/fsl/qbman/qman_ccsr.c | 93 ++++++++++++++++++++++++++------------- drivers/soc/fsl/qbman/qman_priv.h | 2 - drivers/soc/fsl/qbman/qman_test.h | 2 - 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c index 835ce94..607355b9 100644 --- a/drivers/soc/fsl/qbman/qman_ccsr.c +++ b/drivers/soc/fsl/qbman/qman_ccsr.c @@ -401,21 +401,42 @@ static int qm_init_pfdr(struct device *dev, u32 pfdr_start, u32 num) } /* - * Ideally we would use the DMA API to turn rmem->base into a DMA address - * (especially if iommu translations ever get involved). Unfortunately, the - * DMA API currently does not allow mapping anything that is not backed with - * a struct page. + * QMan needs two global memory areas initialized at boot time: + * 1) FQD: Frame Queue Descriptors used to manage frame queues + * 2) PFDR: Packed Frame Queue Descriptor Records used to store frames + * Both areas are reserved using the device tree reserved memory framework + * and the addresses and sizes are initialized when the QMan device is probed */ static dma_addr_t fqd_a, pfdr_a; static size_t fqd_sz, pfdr_sz; +#ifdef CONFIG_PPC +/* + * Support for PPC Device Tree backward compatibility when compatible + * string is set to fsl-qman-fqd and fsl-qman-pfdr + */ +static int zero_priv_mem(phys_addr_t addr, size_t sz) +{ + /* map as cacheable, non-guarded */ + void __iomem *tmpp = ioremap_prot(addr, sz, 0); + + if (!tmpp) + return -ENOMEM; + + memset_io(tmpp, 0, sz); + flush_dcache_range((unsigned long)tmpp, + (unsigned long)tmpp + sz); + iounmap(tmpp); + + return 0; +} + static int qman_fqd(struct reserved_mem *rmem) { fqd_a = rmem->base; fqd_sz = rmem->size; WARN_ON(!(fqd_a && fqd_sz)); - return 0; } RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); @@ -431,32 +452,13 @@ static int qman_pfdr(struct reserved_mem *rmem) } RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr); +#endif + static unsigned int qm_get_fqid_maxcnt(void) { return fqd_sz / 64; } -/* - * Flush this memory range from data cache so that QMAN originated - * transactions for this memory region could be marked non-coherent. - */ -static int zero_priv_mem(struct device *dev, struct device_node *node, - phys_addr_t addr, size_t sz) -{ - /* map as cacheable, non-guarded */ - void __iomem *tmpp = ioremap_prot(addr, sz, 0); - - if (!tmpp) - return -ENOMEM; - - memset_io(tmpp, 0, sz); - flush_dcache_range((unsigned long)tmpp, - (unsigned long)tmpp + sz); - iounmap(tmpp); - - return 0; -} - static void log_edata_bits(struct device *dev, u32 bit_count) { u32 i, j, mask = 0xffffffff; @@ -727,10 +729,41 @@ static int fsl_qman_probe(struct platform_device *pdev) qm_channel_caam = QMAN_CHANNEL_CAAM_REV3; } - ret = zero_priv_mem(dev, node, fqd_a, fqd_sz); - WARN_ON(ret); - if (ret) - return -ENODEV; + if (fqd_a) { +#ifdef CONFIG_PPC + /* + * For PPC backward DT compatibility + * FQD memory MUST be zero'd by software + */ + zero_priv_mem(fqd_a, fqd_sz); +#else + WARN(1, "Unexpected architecture using non shared-dma-mem reservations"); +#endif + } else { + /* + * Order of memory regions is assumed as FQD followed by PFDR + * in order to ensure allocations from the correct regions the + * driver initializes then allocates each piece in order + */ + ret = qbman_init_private_mem(dev, 0, &fqd_a, &fqd_sz); + if (ret) { + dev_err(dev, "qbman_init_private_mem() for FQD failed 0x%x\n", + ret); + return -ENODEV; + } + } + dev_dbg(dev, "Allocated FQD 0x%llx 0x%zx\n", fqd_a, fqd_sz); + + if (!pfdr_a) { + /* Setup PFDR memory */ + ret = qbman_init_private_mem(dev, 1, &pfdr_a, &pfdr_sz); + if (ret) { + dev_err(dev, "qbman_init_private_mem() for PFDR failed 0x%x\n", + ret); + return -ENODEV; + } + } + dev_dbg(dev, "Allocated PFDR 0x%llx 0x%zx\n", pfdr_a, pfdr_sz); ret = qman_init_ccsr(dev); if (ret) { diff --git a/drivers/soc/fsl/qbman/qman_priv.h b/drivers/soc/fsl/qbman/qman_priv.h index 5fe9faf..b1e2cbf 100644 --- a/drivers/soc/fsl/qbman/qman_priv.h +++ b/drivers/soc/fsl/qbman/qman_priv.h @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include "dpaa_sys.h" #include diff --git a/drivers/soc/fsl/qbman/qman_test.h b/drivers/soc/fsl/qbman/qman_test.h index d5f8cb2..41bdbc48 100644 --- a/drivers/soc/fsl/qbman/qman_test.h +++ b/drivers/soc/fsl/qbman/qman_test.h @@ -30,7 +30,5 @@ #include "qman_priv.h" -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - int qman_test_stash(void); int qman_test_api(void); -- 2.7.4