Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbbHLUP3 (ORCPT ); Wed, 12 Aug 2015 16:15:29 -0400 Received: from mail-bn1on0146.outbound.protection.outlook.com ([157.56.110.146]:38976 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752102AbbHLUPO (ORCPT ); Wed, 12 Aug 2015 16:15:14 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Roy Pledge To: , CC: , Subject: [v2 07/11] soc/bman: Add debugfs support for the BMan driver Date: Wed, 12 Aug 2015 16:14:53 -0400 Message-ID: <1439410497-19039-8-git-send-email-Roy.Pledge@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1439410497-19039-1-git-send-email-Roy.Pledge@freescale.com> References: <1439410497-19039-1-git-send-email-Roy.Pledge@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD004;1:nSV4Wr7VqSGEDqJELpUYG4YQEQFPss7lIPnDUEAxNDRtExFsgG65dUm5QavCdHkdKP60qy1qUC2WQaH/63AoY1eUwFaL+U5UWqyY+iBWQfc8Nj7iOtA5yCFIucpnTqrCu1HKOoPtDKV3cbXRUIdpYycqH1b6PY0nHd7JbieFPuEq52y0gBrcUeaqnV6xbYyku6OmtClIniebiRzLGirW0e/BOK4xZ04OUm92Aw00aR8QUo61ruxtvpMSOImmOX2r3TNiDIkGRR3vnhYLXq6LEMRY64BgoykKHlObNF60jZ4GNad/QNIeU6xcLizVHr18mURJMDoX68I9bNe5oYVUKDQ7A0mVXz6hqNjHL9FIB8IrqPLP77R9VOxPRPxqB5KgwmAi/GJ2fPIdfCQXuLV09A== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(199003)(189002)(85426001)(6806004)(46102003)(86362001)(87936001)(19580405001)(97736004)(4001540100001)(5001860100001)(5001770100001)(2950100001)(4001450100002)(81156007)(77096005)(19580395003)(5001830100001)(5001960100002)(68736005)(5003940100001)(53806999)(43066003)(76176999)(64706001)(50986999)(48376002)(69596002)(47776003)(50226001)(36756003)(105606002)(106466001)(229853001)(77156002)(62966003)(104016003)(50466002)(189998001)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1488;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1488;2:5uNtgGSJEPLZXWGKEX1D3TIEveg2RhNLl2l7TYzK7gMPNs4v9PkHtFASOVS7RMm5s/jDWDLo/s6utH2g7NazNUu2kuGsCUYPV+O40q5KmAa7Pc3vyCc8DjivLH99L/0K8R5MSMNggAOI65Uur7yafACKzMt8vklV6pa+Z1bH/PM=;3:d88U2obZ8zIQox8jn7Q0HEGBUVppTwG5g6hgmXr9oqgsCTRbmmjOZmZT3cwVa6mCDsMrcFAa8sbCtPrTfoyMr75I9ScQB8709RrvZejtBz7pa1ZUfHJEuVekR8a72vK5OUk57Euko7bj5h7mWSW8A1MLuvNXgzYTqJq85b01OmHRXMzpFWQKWObF7dG9AKamSY8R+27Y3p/3vsIJDcV6u3GxoZCQl6z4Qh+lbo2++ms=;25:Dccezr8yZ7gEr/Q9fvW14N1ouDz5iLqJM81WQ4EtqWdh1lbHRhWbeV35tqH3wcinny9uOqF5lLUgU50KWTOixw1PyrSZLr7Xvl66KfsCW2MlDAJ6+qMXjIfbKIR7ZYVoWGdFgO0owQTRHF8GSyHDtwrHvGnRgltTxf8HLVX9PkmeI1VCmseq6XRm1nvgATwuPvPpmyEQP51hqzTNNzQic7hMM/+elS1p/NED/T64cZhob0Ska2BXXbopNHLqfkhk X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1488; X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1488;20:nDW5EqdgvAid6BLR3IVwOvR4980xZfmr6dqydYc7IXA1cSfSuIuneBFsaGxrtg0rYsCwmKKFbF3uFhMUQyAWfoKm3xV/Q0Z2eeMtzpRSsfvOTk8ETk1e7PmLoS6DvNi73CbOe1UIiXAmsJbRKxsjJF2VJ2dxw3fJFHaJKnXNzeRHEIXFrFX4M575vg2B30Yh74OIJQfbRkLACOWw3Gi6QGwoc7zP7CAvglTryeEZnPfg5cM+DW1/1oNt+5WjydOjwCU2tN90wCgS6r3nf7y2c4xN55uMK4c3xY0Il3zTWCHMgm8pSgTZVE8iYdC5gGc55uGmH71YCcrgO5walPtVFGkgAra7dg+TSS8MYkJYR7U=;4:u2FJ2o3u8Or5nIEyvKHC4FbjGdeKidfkTTqwOt1mwz2xR6BZ6sYsDb/OAyQCKqeVW9ZRx9BkpwfEBgAR/Mowuq9fjAu3Blp7sGorgMkAtBZAKxOFVdVVG1MTHPZDggt/aTzwSOeGSkO6JGW/dsywcW4bZMu7rghlBFMAaLrW0+fAmv08tLWFPcWQfq6Mh2ySg0OtGTG1LXScsoveaDtYJ+x9hdutjw0lknaQqJGdY+EIfL0gQR9iMjL9CsZF7Fcno1Fe9b1/YMZADgJ3Xn9CidfdOdBZHKNeDi5V9kDRod8= 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:CY1PR03MB1488;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1488; X-Forefront-PRVS: 0666E15D35 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR03MB1488;23:KB8JPO7tZta/W/S8IQR2QcPC+v84KrszX6xDZIkj2?= =?us-ascii?Q?WqI4iTC73AN9L3UoFGHIXLFEsIZ0uYOQ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fc5FE++4/1xgy99GX7asjecuNuPifSUp/dNzIW8hot8PGbXEv+FH?= =?us-ascii?Q?DWXXThoP2owXGNx90wIC+pyqqjCUHgXyMN8PmF3+gIKbqx9WbZK4KkjiFXMd?= =?us-ascii?Q?i2g72s46AOJUqeJ2m9NDCBMxH+QJ/5yAmPcZElhLFK1yThU4FMEOnxKoIQJ8?= =?us-ascii?Q?313lszySYqUsKCcxe8TkR8EfwetvxmKtdJfEbnUj/7TVa8+Nx2hbsZuRQCCP?= =?us-ascii?Q?i5pv7p6qw5MKjk=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR03MB1488;5:oL+4QdzZMNNbjnacpIshQxZR0ssNu5i/37fAjjGiq/tXQN6D08BhfsWkGaFOjwLIU+YKcmBNu8ye7IxSyRLLoH09tllZ8P7Dd77pFeWbOQpt8ljUYbsh+hDfN8gDz3sgARXbEjwVvaGBKHDOwvqXOw==;24:0za/tlHpDSG8c84Y9At76MwjRA9XMFzZkcElRPP27JNlP7/UmFq42z1tSvL5izC4tDcZ9keOdQHMRenWO+Sz6/UoDqiwi0mXZ/72OUXRyB8=;20:VS5O94KQhFGWJCtRkuOfLjt8Y3JLhkz42dIOia2KU+UG2Ey91qQqgDZWDuxsUWhHu4nBL9QqGK4/jW8wDdr2+w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2015 20:15:04.1702 (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: CY1PR03MB1488 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8218 Lines: 250 From: Geoff Thorpe Add debugfs support for querying the state of hardware based Buffer Manager pools used in DPAA 1.0. Signed-off-by: Geoff Thorpe Signed-off-by: Emil Medve Signed-off-by: Roy Pledge --- drivers/soc/fsl/qbman/Kconfig | 7 ++ drivers/soc/fsl/qbman/Makefile | 1 + drivers/soc/fsl/qbman/bman-debugfs.c | 117 ++++++++++++++++++++++++++++++++++ drivers/soc/fsl/qbman/bman_api.c | 19 ++++++ drivers/soc/fsl/qbman/dpaa_sys.h | 7 +- 5 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 drivers/soc/fsl/qbman/bman-debugfs.c diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig index 1f2063a..919ef15 100644 --- a/drivers/soc/fsl/qbman/Kconfig +++ b/drivers/soc/fsl/qbman/Kconfig @@ -54,6 +54,13 @@ config FSL_BMAN_TEST_THRESH "drainer" thread, and the other threads that they observe exactly the depletion state changes that are expected. +config FSL_BMAN_DEBUGFS + tristate "BMan debugfs support" + depends on DEBUG_FS + default n + help + BMan debugfs support + config FSL_QMAN bool "QMan device management" default n diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile index 82f5482..2b53fbc 100644 --- a/drivers/soc/fsl/qbman/Makefile +++ b/drivers/soc/fsl/qbman/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o bman-test-y = bman_test.o bman-test-$(CONFIG_FSL_BMAN_TEST_API) += bman_test_api.o bman-test-$(CONFIG_FSL_BMAN_TEST_THRESH) += bman_test_thresh.o +obj-$(CONFIG_FSL_BMAN_DEBUGFS) += bman-debugfs.o obj-$(CONFIG_FSL_QMAN) += qman_api.o qman_utils.o qman_driver.o obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o diff --git a/drivers/soc/fsl/qbman/bman-debugfs.c b/drivers/soc/fsl/qbman/bman-debugfs.c new file mode 100644 index 0000000..b384f47 --- /dev/null +++ b/drivers/soc/fsl/qbman/bman-debugfs.c @@ -0,0 +1,117 @@ +/* Copyright 2010 - 2015 Freescale Semiconductor, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bman_priv.h" + +static struct dentry *dfs_root; /* debugfs root directory */ + +/* Query Buffer Pool State */ + +static int query_bp_state_show(struct seq_file *file, void *offset) +{ + int ret; + struct bm_pool_state state; + int i, j; + u32 mask; + + memset(&state, 0, sizeof(state)); + ret = bman_query_pools(&state); + if (ret) { + seq_printf(file, "Error %d\n", ret); + return ret; + } + + seq_puts(file, "bp_id free_buffers_avail bp_depleted\n"); + for (i = 0; i < 2; i++) { + mask = 0x80000000; + for (j = 0; j < 32; j++) { + seq_printf(file, + " %-2u %-3s %-3s\n", + (i * 32) + j, + state.as.state.__state[i] & mask ? "no" : "yes", + state.ds.state.__state[i] & mask ? "yes" : "no"); + mask >>= 1; + } + } + + return 0; +} + +static int query_bp_state_open(struct inode *inode, struct file *file) +{ + return single_open(file, query_bp_state_show, NULL); +} + +static const struct file_operations query_bp_state_fops = { + .owner = THIS_MODULE, + .open = query_bp_state_open, + .read = seq_read, + .release = single_release, +}; + +static int __init bman_debugfs_init(void) +{ + int ret = 0; + struct dentry *d; + + dfs_root = debugfs_create_dir("bman", NULL); + if (dfs_root == NULL) { + pr_err("Cannot create dir\n"); + return -ENOMEM; + } + + d = debugfs_create_file("query_bp_state", + S_IRUGO, + dfs_root, + NULL, + &query_bp_state_fops); + if (d == NULL) { + ret = -ENOMEM; + pr_err("Cannot create query_bp_state\n"); + goto _return; + } + + return 0; + +_return: + debugfs_remove_recursive(dfs_root); + + return ret; +} + +static void __exit bman_debugfs_exit(void) +{ + debugfs_remove_recursive(dfs_root); +} + +module_init(bman_debugfs_init); +module_exit(bman_debugfs_exit); + +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/soc/fsl/qbman/bman_api.c b/drivers/soc/fsl/qbman/bman_api.c index a389db9..d8918fc 100644 --- a/drivers/soc/fsl/qbman/bman_api.c +++ b/drivers/soc/fsl/qbman/bman_api.c @@ -1014,6 +1014,25 @@ int bman_flush_stockpile(struct bman_pool *pool, u32 flags) } EXPORT_SYMBOL(bman_flush_stockpile); +int bman_query_pools(struct bm_pool_state *state) +{ + struct bman_portal *p = get_affine_portal(); + struct bm_mc_result *mcr; + __maybe_unused unsigned long irqflags; + + PORTAL_IRQ_LOCK(p, irqflags); + bm_mc_start(&p->p); + bm_mc_commit(&p->p, BM_MCC_VERB_CMD_QUERY); + while (!(mcr = bm_mc_result(&p->p))) + cpu_relax(); + DPA_ASSERT((mcr->verb & BM_MCR_VERB_CMD_MASK) == BM_MCR_VERB_CMD_QUERY); + *state = mcr->query; + PORTAL_IRQ_UNLOCK(p, irqflags); + put_affine_portal(); + return 0; +} +EXPORT_SYMBOL(bman_query_pools); + #ifdef CONFIG_FSL_BMAN u32 bman_query_free_buffers(struct bman_pool *pool) { diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h index cef9095..3cf446a 100644 --- a/drivers/soc/fsl/qbman/dpaa_sys.h +++ b/drivers/soc/fsl/qbman/dpaa_sys.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -76,9 +77,7 @@ int dpaa_resource_reserve(struct dpaa_resource *alloc, u32 base, u32 num); #define DPA_PORTAL_CE 0 #define DPA_PORTAL_CI 1 -/***********************/ /* Misc inline assists */ -/***********************/ /* TODO: NB, we currently assume that hwsync() and lwsync() imply compiler * barriers and that dcb*() won't fall victim to compiler or execution @@ -157,9 +156,7 @@ static inline void copy_words(void *dest, const void *src, size_t sz) #define copy_words memcpy #endif -/************/ /* RB-trees */ -/************/ /* We encapsulate RB-trees so that its easier to use non-linux forms in * non-linux systems. This also encapsulates the extra plumbing that linux code @@ -215,9 +212,7 @@ static inline type *name##_find(struct dpa_rbtree *tree, u32 val) \ return NULL; \ } -/************/ /* Bootargs */ -/************/ /* QMan has "qportals=" and BMan has "bportals=", they use the same syntax * though; a comma-separated list of items, each item being a cpu index and/or a -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/