public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Sanjay R Mehta <sanmehta@amd.com>
To: Vinod Koul <vkoul@kernel.org>, Sanjay R Mehta <Sanju.Mehta@amd.com>
Cc: gregkh@linuxfoundation.org, dan.j.williams@intel.com,
	Thomas.Lendacky@amd.com, Shyam-sundar.S-k@amd.com,
	Nehal-bakulchandra.Shah@amd.com, robh@kernel.org,
	mchehab+samsung@kernel.org, davem@davemloft.net,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v5 3/3] dmaengine: ptdma: Add debugfs entries for PTDMA information
Date: Mon, 24 Aug 2020 13:55:16 +0530	[thread overview]
Message-ID: <16f6f41f-8a3a-ee5d-9c2c-2f2e96ae367d@amd.com> (raw)
In-Reply-To: <20200703074200.GL273932@vkoul-mobl>


> 
> On 16-06-20, 20:11, Sanjay R Mehta wrote:
>> From: Sanjay R Mehta <sanju.mehta@amd.com>
>>
>> Expose data about the configuration and operation of the
>> PTDMA through debugfs entries: device name, capabilities,
>> configuration, statistics.
>>
>> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
>> ---
>>  drivers/dma/ptdma/Makefile        |   3 +-
>>  drivers/dma/ptdma/ptdma-debugfs.c | 130 ++++++++++++++++++++++++++++++++++++++
>>  drivers/dma/ptdma/ptdma-dev.c     |   8 +++
>>  drivers/dma/ptdma/ptdma.h         |   9 +++
>>  4 files changed, 149 insertions(+), 1 deletion(-)
>>  create mode 100644 drivers/dma/ptdma/ptdma-debugfs.c
>>
>> diff --git a/drivers/dma/ptdma/Makefile b/drivers/dma/ptdma/Makefile
>> index 6fcb4ad..60e7c10 100644
>> --- a/drivers/dma/ptdma/Makefile
>> +++ b/drivers/dma/ptdma/Makefile
>> @@ -6,6 +6,7 @@
>>  obj-$(CONFIG_AMD_PTDMA) += ptdma.o
>>
>>  ptdma-objs := ptdma-dev.o \
>> -           ptdma-dmaengine.o
>> +           ptdma-dmaengine.o \
>> +           ptdma-debugfs.o
>>
>>  ptdma-$(CONFIG_PCI) += ptdma-pci.o
>> diff --git a/drivers/dma/ptdma/ptdma-debugfs.c b/drivers/dma/ptdma/ptdma-debugfs.c
>> new file mode 100644
>> index 0000000..506c148b
>> --- /dev/null
>> +++ b/drivers/dma/ptdma/ptdma-debugfs.c
>> @@ -0,0 +1,130 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * AMD Passthrough DMA device driver
>> + * -- Based on the CCP driver
>> + *
>> + * Copyright (C) 2016,2020 Advanced Micro Devices, Inc.
>> + *
>> + * Author: Sanjay R Mehta <sanju.mehta@amd.com>
>> + * Author: Gary R Hook <gary.hook@amd.com>
>> + */
>> +
>> +#include <linux/debugfs.h>
>> +#include <linux/seq_file.h>
>> +
>> +#include "ptdma.h"
>> +
>> +/* DebugFS helpers */
>> +#define      MAX_NAME_LEN    20
>> +#define      RI_VERSION_NUM  0x0000003F
>> +
>> +#define      RI_NUM_VQM      0x00078000
>> +#define      RI_NVQM_SHIFT   15
>> +
>> +static struct dentry *pt_debugfs_dir;
>> +static DEFINE_MUTEX(pt_debugfs_lock);
>> +
>> +static int pt_debugfs_info_show(struct seq_file *s, void *p)
>> +{
>> +     struct pt_device *pt = s->private;
>> +     unsigned int regval;
>> +
>> +     if (!pt)
>> +             return 0;
>> +
>> +     seq_printf(s, "Device name: %s\n", pt->name);
>> +     seq_printf(s, "   # Queues: %d\n", 1);
>> +     seq_printf(s, "     # Cmds: %d\n", pt->cmd_count);
>> +
>> +     regval = ioread32(pt->io_regs + CMD_PT_VERSION);
>> +
>> +     seq_printf(s, "    Version: %d\n", regval & RI_VERSION_NUM);
>> +     seq_puts(s, "    Engines:");
>> +     seq_puts(s, "\n");
>> +     seq_printf(s, "     Queues: %d\n", (regval & RI_NUM_VQM) >> RI_NVQM_SHIFT);
>> +
>> +     return 0;
>> +}
>> +
>> +/*
>> + * Return a formatted buffer containing the current
>> + * statistics of queue for PTDMA
>> + */
>> +static int pt_debugfs_stats_show(struct seq_file *s, void *p)
>> +{
>> +     struct pt_device *pt = s->private;
>> +
>> +     seq_printf(s, "Total Interrupts Handled: %ld\n", pt->total_interrupts);
>> +
>> +     return 0;
>> +}
>> +
>> +static int pt_debugfs_queue_show(struct seq_file *s, void *p)
>> +
>> +{
>> +     struct pt_cmd_queue *cmd_q = s->private;
>> +     unsigned int regval;
>> +
>> +     if (!cmd_q)
>> +             return 0;
>> +
>> +     seq_printf(s, "               Pass-Thru: %ld\n", cmd_q->total_pt_ops);
>> +
>> +     regval = ioread32(cmd_q->reg_int_enable);
>> +
>> +     seq_puts(s, "      Enabled Interrupts:");
>> +     if (regval & INT_EMPTY_QUEUE)
>> +             seq_puts(s, " EMPTY");
>> +     if (regval & INT_QUEUE_STOPPED)
>> +             seq_puts(s, " STOPPED");
>> +     if (regval & INT_ERROR)
>> +             seq_puts(s, " ERROR");
>> +     if (regval & INT_COMPLETION)
>> +             seq_puts(s, " COMPLETION");
>> +     seq_puts(s, "\n");
>> +
>> +     return 0;
>> +}
>> +
>> +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_info);
>> +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_queue);
>> +DEFINE_SHOW_ATTRIBUTE(pt_debugfs_stats);
>> +
>> +void ptdma_debugfs_setup(struct pt_device *pt)
>> +{
>> +     struct pt_cmd_queue *cmd_q;
>> +     char name[MAX_NAME_LEN + 1];
>> +     struct dentry *debugfs_q_instance;
>> +
>> +     if (!debugfs_initialized())
>> +             return;
>> +
>> +     mutex_lock(&pt_debugfs_lock);
>> +     if (!pt_debugfs_dir)
>> +             pt_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> 
> please do not create your own, you already have one under
> /sys/kernel/debug/dmaengine/<>/ use that :)
> 
Thanks :). Will fix this in the next version of patch.

>> +     mutex_unlock(&pt_debugfs_lock);
>> +
>> +     pt->dma_dev.dbg_dev_root = debugfs_create_dir(pt->name, pt_debugfs_dir);
> 
> argh, this is already created by core and you leaked that one and added
> your own!
> 
Will fix this in the next version of patch.

> --
> ~Vinod
> 

      reply	other threads:[~2020-08-24  8:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  1:11 [PATCH v5 0/3] Add support for AMD PTDMA controller driver Sanjay R Mehta
2020-06-17  1:11 ` [PATCH v5 1/3] dmaengine: ptdma: Initial driver for the AMD PTDMA controller Sanjay R Mehta
2020-07-03  7:18   ` Vinod Koul
2020-08-24  7:41     ` Sanjay R Mehta
2020-08-25 11:16       ` Vinod Koul
2020-08-25 11:33         ` Sanjay R Mehta
2020-06-17  1:11 ` [PATCH v5 2/3] dmaengine: ptdma: register PTDMA controller as a DMA resource Sanjay R Mehta
2020-07-03  7:37   ` Vinod Koul
2020-08-24 11:13     ` Sanjay R Mehta
2020-06-17  1:11 ` [PATCH v5 3/3] dmaengine: ptdma: Add debugfs entries for PTDMA information Sanjay R Mehta
2020-07-03  7:42   ` Vinod Koul
2020-08-24  8:25     ` Sanjay R Mehta [this message]

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=16f6f41f-8a3a-ee5d-9c2c-2f2e96ae367d@amd.com \
    --to=sanmehta@amd.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Sanju.Mehta@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=robh@kernel.org \
    --cc=vkoul@kernel.org \
    /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