From patchwork Mon Mar 9 14:41:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Medve X-Patchwork-Id: 448064 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B355D14011D for ; Tue, 10 Mar 2015 01:58:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 888FE1A25C0 for ; Tue, 10 Mar 2015 01:58:30 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0114.outbound.protection.outlook.com [157.56.111.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 784821A30B3 for ; Tue, 10 Mar 2015 01:47:50 +1100 (AEDT) Received: from CO2PR03CA0012.namprd03.prod.outlook.com (10.141.194.139) by BN1PR0301MB0724.namprd03.prod.outlook.com (25.160.78.143) with Microsoft SMTP Server (TLS) id 15.1.106.15; Mon, 9 Mar 2015 14:47:43 +0000 Received: from BN1BFFO11FD031.protection.gbl (2a01:111:f400:7c10::1:174) by CO2PR03CA0012.outlook.office365.com (2a01:111:e400:1414::11) with Microsoft SMTP Server (TLS) id 15.1.106.15 via Frontend Transport; Mon, 9 Mar 2015 14:47:43 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD031.mail.protection.outlook.com (10.58.144.94) with Microsoft SMTP Server (TLS) id 15.1.112.13 via Frontend Transport; Mon, 9 Mar 2015 14:47:42 +0000 Received: from right.am.freescale.net (right.am.freescale.net [10.81.116.70]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t29ElcYs024469; Mon, 9 Mar 2015 07:47:41 -0700 From: Emil Medve To: , , Subject: [RFC v3 07/10] fsl_bman: Add debugfs support Date: Mon, 9 Mar 2015 09:41:52 -0500 Message-ID: <1425912115-27398-8-git-send-email-Emilian.Medve@Freescale.com> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1425912115-27398-1-git-send-email-Emilian.Medve@Freescale.com> References: <1425912115-27398-1-git-send-email-Emilian.Medve@Freescale.com> X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of Freescale.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; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Emilian.Medve@Freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(46102003)(87936001)(19580395003)(19580405001)(6806004)(575784001)(86362001)(76176999)(2201001)(104016003)(50466002)(85426001)(50226001)(77096005)(92566002)(105606002)(229853001)(36756003)(62966003)(77156002)(48376002)(2950100001)(50986999)(47776003)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0724; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0724; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5002009)(5005006); SRVR:BN1PR0301MB0724; BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0724; X-Forefront-PRVS: 05102978A2 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2015 14:47:42.3585 (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: BN1PR0301MB0724 Cc: Geoff Thorpe X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Geoff Thorpe Signed-off-by: Geoff Thorpe --- drivers/soc/fsl/Kconfig | 7 +++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/bman_api.c | 19 +++++++ drivers/soc/fsl/bman_debugfs.c | 118 +++++++++++++++++++++++++++++++++++++++++ drivers/soc/fsl/dpaa_sys.h | 1 + include/soc/fsl/bman.h | 6 +++ 6 files changed, 152 insertions(+) create mode 100644 drivers/soc/fsl/bman_debugfs.c diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index e00f2bf..eaede8b 100644 --- a/drivers/soc/fsl/Kconfig +++ b/drivers/soc/fsl/Kconfig @@ -73,6 +73,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 interface" + depends on DEBUG_FS + default y + ---help--- + This option compiles debugfs code for BMan. + endif # FSL_BMAN config FSL_QMAN diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index bd0fd91..a991e18 100644 --- a/drivers/soc/fsl/Makefile +++ b/drivers/soc/fsl/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_FSL_BMAN_TEST) += bman_tester.o bman_tester-y = bman_test.o bman_tester-$(CONFIG_FSL_BMAN_TEST_API) += bman_test_api.o bman_tester-$(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 obj-$(CONFIG_FSL_QMAN_CONFIG) += qman.o qman_portal.o diff --git a/drivers/soc/fsl/bman_api.c b/drivers/soc/fsl/bman_api.c index 8de4973..1a6a440 100644 --- a/drivers/soc/fsl/bman_api.c +++ b/drivers/soc/fsl/bman_api.c @@ -996,6 +996,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_CONFIG u32 bman_query_free_buffers(struct bman_pool *pool) { diff --git a/drivers/soc/fsl/bman_debugfs.c b/drivers/soc/fsl/bman_debugfs.c new file mode 100644 index 0000000..df451de --- /dev/null +++ b/drivers/soc/fsl/bman_debugfs.c @@ -0,0 +1,118 @@ +/* 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 +#include +#include +#include +#include + +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(struct bm_pool_state)); + ret = bman_query_pools(&state); + if (ret) { + seq_printf(file, "Error %d\n", ret); + return 0; + } + 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_module_init(void) +{ + int ret = 0; + struct dentry *d; + + dfs_root = debugfs_create_dir("bman", NULL); + + if (dfs_root == NULL) { + ret = -ENOMEM; + pr_err("Cannot create bman debugfs dir\n"); + goto _return; + } + 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_module_exit(void) +{ + debugfs_remove_recursive(dfs_root); +} + + +module_init(bman_debugfs_module_init); +module_exit(bman_debugfs_module_exit); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/soc/fsl/dpaa_sys.h b/drivers/soc/fsl/dpaa_sys.h index 4230021..0913dd4 100644 --- a/drivers/soc/fsl/dpaa_sys.h +++ b/drivers/soc/fsl/dpaa_sys.h @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h index 1eab818..6e58168 100644 --- a/include/soc/fsl/bman.h +++ b/include/soc/fsl/bman.h @@ -480,6 +480,12 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num, */ int bman_flush_stockpile(struct bman_pool *pool, u32 flags); +/** + * bman_query_pools - Query all buffer pool states + * @state: storage for the queried availability and depletion states + */ +int bman_query_pools(struct bm_pool_state *state); + #ifdef CONFIG_FSL_BMAN_CONFIG /** * bman_query_free_buffers - Query how many free buffers are in buffer pool