Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754144AbbGIUiF (ORCPT ); Thu, 9 Jul 2015 16:38:05 -0400 Received: from mail-by2on0124.outbound.protection.outlook.com ([207.46.100.124]:25938 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754025AbbGIUht (ORCPT ); Thu, 9 Jul 2015 16:37:49 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Roy Pledge To: , CC: , Subject: [PATCH 07/11] soc/bman: Add debugfs support for the BMan driver Date: Thu, 9 Jul 2015 16:21:58 -0400 Message-ID: <1436473322-21247-8-git-send-email-Roy.Pledge@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1436473322-21247-1-git-send-email-Roy.Pledge@freescale.com> References: <1436473322-21247-1-git-send-email-Roy.Pledge@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD026;1:dwabanS9cl8E7uZNBlIZSXSL12S/yeE1q99zDvjyiDrpeNTudgLmncG7jfvz67Q5396MbLb6oGLL5udnZZyKppaG//iDGUfwdjpYgduz3ArLN2tGsWjpOGd6yEytMLPn653E+cGB3VN1OhQLxghAHKudvlzonAag04B6JkmEYbr3U8yH/C4AnRRl5Tm0gMKuFs0qCQiGIwlY7sOivkfBht6RiBJYj5Qwcaf2Dvzulduyx6BvTJ+CaijN8G1qnUeEazE4+paUeXNfSH3JIOPfWeOWLPWBTjwhIQZUN2ry0YCwFWy8ZU1704eWzjVM8SnOeWF3BM4xktNY0D1rIW8xUCOmEL3NVmW+ckp6osQyPvzwY1VK6wHBJMyyOFLzyZgydBScAQTznklUQzwwL0Dpo0U/L+/1wKAVRcKSxoPmdn/vqnB4u+nfASIuQ52L2asI X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(106466001)(5003940100001)(46102003)(5001960100002)(86362001)(77156002)(189998001)(62966003)(5001770100001)(77096005)(50226001)(48376002)(92566002)(19580405001)(19580395003)(6806004)(104016003)(105606002)(2950100001)(36756003)(87936001)(50466002)(229853001)(47776003)(76176999)(50986999)(85426001)(2004002)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR03MB1484;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1484;2:mVDYW95133NzYedmhIvYGcyV6UCyvtbqu5MrQz0Jxj3W0qkhqHBD/LCe7A+PzCAh;3:BPuCPGM9DKvyNuWQIadVEtYL7zS49HY2KPh5L/yVQBxlTHDA23eFppMDqP7fz4VT5CKJFTKkz9xgUlAqWwyfaZ6YgnYw0tO89YiD44i079sltb7131NLb9uOGlVkbwWBwLQaMjQ2Ynts10M65QTPpiWvOFPxtulXZfjq9yJCBJTzVb4bgtOSMbX2DRnfXjaZXXqke03Q+f4uIMr9QAk/AIbDniMHTR1jDqligpe96G4=;25:JjiTk/8lkhkXaASH+6ahPvvKyBeZm2SC70V7rRSyjG+yQfilQv4KWD1l3bic/2wC87rH7wAncfonA3En59xrDXGz9AiN21hjUUmcAn61nJB70iQWKbeZyvFCEIy7dG+4n4aHNBFOlHkCZSD9DbQxMQ8Y+NvaYIrTXbEV1idbprtbhwb1DRBZmKQ5b0BlmN5qUJm8B1/f1ZazXNIycnEWMPj0TwoF9icX/ziXKPHf4ueDNlER5S+GcKi4y7xGo05R;20:1NCZ9ajVbR9Ba+Jz0YiSpy62zArdyb7xrd5/H2Nn3kisBN7MbdHfy4IDrbu8FLx0GDwLqae4pN+LBkGJRQTyblI72Ud/vTQqkdznkhkcf6pWsTqw+HmPuiRuOMasiEa52Bxrzg4c8ZjPgitqTXgrz+2GHY9tzV7SROOOEu8c6vrZa6kjQ28eZ97hL7Kc2bdr0LFzy9WG6Y9s60FgDuhX7MuUAAX0zOZQXLPxiXZFek7/Mx+yMmOqyLfOBJVp4brbC2AWHC3aKbT49gqiFBUjJ7daKatgTZ5iJxfq+UjEy7P4J69YI6XVRPXh3x+J68fcLM/cqGqUznVSJr7XKy75QWQHEv9YH7rE4VtUtSAacJI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1484; BY1PR03MB1484: X-MS-Exchange-Organization-RulesExecuted 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:BY1PR03MB1484;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1484; X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1484;4:hIF9q0ujf+ScQOrkjQK4PG7VeH1KAd4Tv7Py4BI0wcVIMmzOFk5ML6dnKQk48pOxi7qJENzmpy9hm3DKjQxb5KLRqnqei5Jx9Xq1XyuNkMOaw/oBExUA3sklh7l550HFMYpCNhtzrMkmSQ22y3r+/9uHmaqMbXr/CahjKecdJIuuLNXqxqsydZw7mDvyq4DHDR7LDGCNnIAZOx/Y2tjLWX6i/wNZI9Twas6AYt3HiPbiOh7PnrpPmQBQAMCmqhhnA8dmdJ10glmZPndaLC8rz5mTa7+2BWaTytQnOswfR/A= X-Forefront-PRVS: 0632519F33 X-Microsoft-Exchange-Diagnostics: 1;BY1PR03MB1484;23:dREbzN3fgjFPpRkIjAHl8mdSMErIUguovOBsOMxhZmOImwPh3Tg1AhzouNX2GN9KnGSxvm1Qb5xvW8G+TqSg8MciQP4KSzIy7G87qZa/YSGkTe1TCnyU7QBUl29pl9K+k8Lhi42jM/z7ARQyuSCuYs03SNGUS4ViCG6OrZeaBC2gwnZ8qEsf4KaVbhXmqoVuLbmBLmVcLbp9AA1hArZ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wm25BYEcRMmLccw9ppCXBvenWjoFZg3TlOoMjFw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2015 20:22:09.5068 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1484 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8222 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 8259eb8..35947e7 100644 --- a/drivers/soc/fsl/qbman/Kconfig +++ b/drivers/soc/fsl/qbman/Kconfig @@ -75,6 +75,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 tristate "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 fe1c593..781d969 100644 --- a/drivers/soc/fsl/qbman/bman_api.c +++ b/drivers/soc/fsl/qbman/bman_api.c @@ -1012,6 +1012,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 c8d7aad..31ff7a8 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 @@ -187,9 +186,7 @@ static inline void copy_bytes(void *dest, const void *src, size_t sz) #define copy_bytes 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 @@ -245,9 +242,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/