From: Allen Hubbe <allenbh@gmail.com>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: Jon Mason <jdmason@kudzu.us>, Dave Jiang <dave.jiang@intel.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 7/8] ntb_pingpong: Add a debugfs file to get the ping count
Date: Fri, 10 Jun 2016 22:46:06 -0400 [thread overview]
Message-ID: <CAJ80savOTsXePsDQqhaXDuXFx7jBMACkUbztzHnkCEDrpLWXjw@mail.gmail.com> (raw)
In-Reply-To: <a326e5cfecc9c780e97d9ce1665d13474b7367c3.1465598632.git.logang@deltatee.com>
On Fri, Jun 10, 2016 at 6:54 PM, Logan Gunthorpe <logang@deltatee.com> wrote:
> This commit adds a debugfs 'count' file to ntb_pingpong. This is so
> testing with ntb_pingpong can be automated beyond just checking the
> logs for pong messages.
>
> The count file returns a number which increments every pong. The
> counter can be cleared by writing a zero.
>
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> ---
> drivers/ntb/test/ntb_pingpong.c | 68 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c
> index fe16005..34bbf5a 100644
> --- a/drivers/ntb/test/ntb_pingpong.c
> +++ b/drivers/ntb/test/ntb_pingpong.c
> @@ -61,6 +61,7 @@
> #include <linux/pci.h>
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> +#include <linux/debugfs.h>
>
> #include <linux/ntb.h>
>
> @@ -96,8 +97,13 @@ struct pp_ctx {
> spinlock_t db_lock;
> struct timer_list db_timer;
> unsigned long db_delay;
> + struct dentry *debugfs_node_dir;
> + struct dentry *debugfs_count;
> + atomic_t count;
> };
>
> +static struct dentry *pp_debugfs_dir;
> +
> static void pp_ping(unsigned long ctx)
> {
> struct pp_ctx *pp = (void *)ctx;
> @@ -171,10 +177,38 @@ static void pp_db_event(void *ctx, int vec)
> dev_dbg(&pp->ntb->dev,
> "Pong vec %d bits %#llx\n",
> vec, db_bits);
> + atomic_inc(&pp->count);
> }
> spin_unlock_irqrestore(&pp->db_lock, irqflags);
> }
>
> +static int pp_debugfs_setup(struct pp_ctx *pp)
> +{
> + struct pci_dev *pdev = pp->ntb->pdev;
> +
> + if (!debugfs_initialized())
> + return -ENODEV;
> +
> + if (!pp_debugfs_dir) {
> + pp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
The pp_debugfs_dir is already initialized by the module init function.
If it doesn't exist here, I think we should just return instead of
trying again. It's also worth noting, though it is probably no harm,
the code here does not check debugfs_initialized().
> + if (!pp_debugfs_dir)
> + return -ENODEV;
> + }
> +
> + pp->debugfs_node_dir = debugfs_create_dir(pci_name(pdev),
> + pp_debugfs_dir);
> + if (!pp->debugfs_node_dir)
> + return -ENODEV;
> +
> + pp->debugfs_count = debugfs_create_atomic_t("count", S_IRUSR | S_IWUSR,
> + pp->debugfs_node_dir,
> + &pp->count);
> + if (!pp->debugfs_count)
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> static const struct ntb_ctx_ops pp_ops = {
> .link_event = pp_link_event,
> .db_event = pp_db_event,
> @@ -210,6 +244,7 @@ static int pp_probe(struct ntb_client *client,
>
> pp->ntb = ntb;
> pp->db_bits = 0;
> + atomic_set(&pp->count, 0);
> spin_lock_init(&pp->db_lock);
> setup_timer(&pp->db_timer, pp_ping, (unsigned long)pp);
> pp->db_delay = msecs_to_jiffies(delay_ms);
> @@ -218,6 +253,10 @@ static int pp_probe(struct ntb_client *client,
> if (rc)
> goto err_ctx;
>
> + rc = pp_debugfs_setup(pp);
> + if (rc)
> + goto err_ctx;
> +
> ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
> ntb_link_event(ntb);
>
> @@ -234,6 +273,8 @@ static void pp_remove(struct ntb_client *client,
> {
> struct pp_ctx *pp = ntb->ctx;
>
> + debugfs_remove_recursive(pp->debugfs_node_dir);
> +
> ntb_clear_ctx(ntb);
> del_timer_sync(&pp->db_timer);
> ntb_link_disable(ntb);
> @@ -247,4 +288,29 @@ static struct ntb_client pp_client = {
> .remove = pp_remove,
> },
> };
> -module_ntb_client(pp_client);
> +
> +static int __init tool_init(void)
This should be pp_init() not tool_init().
> +{
> + int rc;
> +
> + if (debugfs_initialized())
> + pp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> +
> + rc = ntb_register_client(&pp_client);
> + if (rc)
> + goto err_client;
> +
> + return 0;
> +
> +err_client:
> + debugfs_remove_recursive(pp_debugfs_dir);
> + return rc;
> +}
> +module_init(tool_init);
> +
> +static void __exit tool_exit(void)
> +{
> + ntb_unregister_client(&pp_client);
> + debugfs_remove_recursive(pp_debugfs_dir);
> +}
> +module_exit(tool_exit);
next prev parent reply other threads:[~2016-06-11 2:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1465598632.git.logang@deltatee.com>
[not found] ` <e447cedb6197b62f141e7688ed2329c259f33eb9.1465598632.git.logang@deltatee.com>
2016-06-11 2:27 ` [PATCH 6/8] ntb_tool: Add link status file to debugfs Allen Hubbe
2016-06-11 15:28 ` Logan Gunthorpe
2016-06-12 1:28 ` Allen Hubbe
2016-06-14 15:45 ` Allen Hubbe
2016-06-14 15:48 ` Logan Gunthorpe
2016-06-14 15:54 ` Allen Hubbe
[not found] ` <d9488f2c946644c2b1258a78929d3543747283ec.1465598632.git.logang@deltatee.com>
2016-06-11 2:35 ` [PATCH 5/8] ntb_tool: BUG: Ensure the buffer size is large enough to return all spads Allen Hubbe
2016-06-11 15:29 ` Logan Gunthorpe
[not found] ` <a326e5cfecc9c780e97d9ce1665d13474b7367c3.1465598632.git.logang@deltatee.com>
2016-06-11 2:46 ` Allen Hubbe [this message]
2016-06-11 15:30 ` [PATCH 7/8] ntb_pingpong: Add a debugfs file to get the ping count Logan Gunthorpe
[not found] ` <03a622a20a667b17046fbd45bb952f8dbd235653.1465598632.git.logang@deltatee.com>
2016-06-13 18:05 ` [PATCH 1/8] ntb_perf: Schedule based on time not on performance Jiang, Dave
[not found] ` <65833d43bfcc3e37cbd136fa2a033b8948982629.1465598632.git.logang@deltatee.com>
2016-06-13 18:16 ` [PATCH 2/8] ntb_perf: Improve thread handling to increase robustness Jiang, Dave
[not found] ` <c859fa29b84c39cb952611904ecbf0ca02077840.1465598632.git.logang@deltatee.com>
2016-06-13 20:09 ` [PATCH 3/8] ntb_perf: Return results by reading the run file Jiang, Dave
[not found] ` <71664260d670af5f24beb9c825791802659f3cd2.1465598632.git.logang@deltatee.com>
2016-06-13 20:14 ` [PATCH 4/8] ntb_perf: Wait for link before running test Jiang, Dave
[not found] ` <773161e84a4447a0a91edb42fe18171819ef2319.1465598632.git.logang@deltatee.com>
2016-06-14 14:06 ` [PATCH 8/8] ntb_test: Add a selftest script for the NTB subsystem Jon Mason
2016-06-14 14:16 ` Shuah Khan
2016-06-14 15:45 ` Logan Gunthorpe
2016-06-14 15:47 ` Allen Hubbe
2016-06-14 15:49 ` Logan Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJ80savOTsXePsDQqhaXDuXFx7jBMACkUbztzHnkCEDrpLWXjw@mail.gmail.com \
--to=allenbh@gmail.com \
--cc=arnd@arndb.de \
--cc=dave.jiang@intel.com \
--cc=jdmason@kudzu.us \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-ntb@googlegroups.com \
--cc=logang@deltatee.com \
--cc=shuahkh@osg.samsung.com \
--cc=sudipm.mukherjee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).