dmaengine: Add debugfs entries for PTDMA information
PATCH 4/4 dmaengine: Add debugfs entries for PTDMA information
From: Sanjay R Mehta <[email protected]>
Expose data about the configuration and operation of the PTDMA through debugfs entries: device name, capabilities, configuration, statistics.
--- drivers/dma/ptdma/Makefile | 3 +- drivers/dma/ptdma/ptdma-debugfs.c | 249 ++++++++++++++++++++++++++++++++++++++ drivers/dma/ptdma/ptdma-dev.c | 15 +++ drivers/dma/ptdma/ptdma.h | 14 +++ 4 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/ptdma/ptdma-debugfs.c
drivers/dma/ptdma/Makefile +2 -1
@@ -7,6 +7,7 @@ obj-$(CONFIG_AMD_PTDMA) += ptdma.o ptdma-objs := ptdma-ops.o \ ptdma-dev.o \ - ptdma-dmaengine.o + ptdma-dmaengine.o \ + ptdma-debugfs.o ptdma-$(CONFIG_PCI) += ptdma-pci.o
drivers/dma/ptdma/ptdma-debugfs.c new file +249 -0
249 lines not on this page · raw message
drivers/dma/ptdma/ptdma-dev.c +15 -0
@@ -18,6 +18,7 @@#include <linux/kernel.h> #include <linux/pci.h> #include <linux/kthread.h> +#include <linux/debugfs.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h>
@@ -102,6 +103,8 @@ static int pt_core_execute_cmd(struct ptdma_desc *desc,int i;int ret =0 ; + cmd_q->total_ops++; +if (PT_CMD_SOC (desc)) {PT_CMD_IOC (desc) =1 ;PT_CMD_SOC (desc) =0 ;
@@ -153,6 +156,8 @@ int pt_core_perform_passthru(struct pt_op *op)union pt_function function;struct pt_dma_info *saddr = &op->src.u.dma; + op->cmd_q->total_pt_ops++; +memset (&desc,0 ,Q_DESC_SIZE );PT_CMD_ENGINE (&desc) =PT_ENGINE_PASSTHRU ;
@@ -222,6 +227,7 @@ static irqreturn_t pt_core_irq_handler(int irq, void *data)struct pt_device *pt = (struct pt_device *)data;pt_core_disable_queue_interrupts (pt); + pt->total_interrupts++;tasklet_schedule (&pt->irq_tasklet);return IRQ_HANDLED ;
@@ -362,6 +368,9 @@ int pt_core_init(struct pt_device *pt)if (ret) goto e_kthread; +/* Set up debugfs entries */ +ptdma_debugfs_setup (pt); +return 0 ;
@@ -393,6 +402,12 @@ void pt_core_destroy(struct pt_device *pt)/* Remove this device from the list of available units first */ pt_del_device (pt); +/* We're in the process of tearing down the entire driver; +* when all the devices are gone clean up debugfs +*/ +if (pt_present ()) +ptdma_debugfs_destroy (); +/* Disable and clear interrupts */ pt_core_disable_queue_interrupts (pt);
drivers/dma/ptdma/ptdma.h +14 -0
@@ -53,6 +53,7 @@#define CMD_QUEUE_PRIO_OFFSET 0x00#define CMD_REQID_CONFIG_OFFSET 0x04#define CMD_TIMEOUT_OFFSET 0x08 +#define CMD_PT_VERSION 0x10#define CMD_Q_CONTROL_BASE 0x0000#define CMD_Q_TAIL_LO_BASE 0x0004
@@ -312,6 +313,10 @@ struct pt_cmd_queue {/* Interrupt wait queue */ wait_queue_head_t int_queue;unsigned int int_rcvd; + +/* Per-queue Statistics */ +unsigned long total_ops; +unsigned long total_pt_ops; }____cacheline_aligned ;struct pt_device {
@@ -357,6 +362,12 @@ struct pt_device {/* Suspend support */ unsigned int suspending;wait_queue_head_t suspend_queue; + +/* Device Statistics */ +unsigned long total_interrupts; + +/* DebugFS info */ +struct dentry *debugfs_instance; };struct pt_dma_info {
@@ -503,6 +514,9 @@ int pt_run_cmd(struct pt_cmd_queue *cmd_q, struct pt_cmd *cmd);int pt_dmaengine_register (struct pt_device *pt);void pt_dmaengine_unregister (struct pt_device *pt); +void ptdma_debugfs_setup (struct pt_device *pt); +void ptdma_debugfs_destroy (void ); +int pt_core_init (struct pt_device *pt);void pt_core_destroy (struct pt_device *pt);
Signature · 1 line
2.7.4
Quoted 10 lines · Sanju
drivers/dma/ptdma/ptdma-debugfs.c new file +10
-0+static const struct file_operations pt_debugfs_info_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_info_read, + .write =NULL , +}; + +static const struct file_operations pt_debugfs_queue_ops = { + .owner =THIS_MODULE , + .open = simple_open,
drivers/dma/ptdma/ptdma-debugfs.c line 211
Quoted 10 lines
drivers/dma/ptdma/ptdma-debugfs.c new file +10
-0+ .read = ptdma_debugfs_queue_read, + .write = ptdma_debugfs_queue_write, +}; + +static const struct file_operations pt_debugfs_stats_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_stats_read, + .write = ptdma_debugfs_stats_write, +};
Can you use DEFINE_SIMPLE_ATTRIBUTE() here intead of these?
thanks,
greg k-h
Quoted 16 lines · On 9/24/2019 1:35 PM, [email protected] wrote:
[CAUTION: External Email]
Quoted 13 lines · Sanju
drivers/dma/ptdma/ptdma-debugfs.c new file +13
-0+static const struct file_operations pt_debugfs_info_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_info_read, + .write =NULL , +}; + +static const struct file_operations pt_debugfs_queue_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_queue_read, + .write = ptdma_debugfs_queue_write, +};
Quoted 8 lines
drivers/dma/ptdma/ptdma-debugfs.c line 211
Quoted 7 lines
drivers/dma/ptdma/ptdma-debugfs.c new file +7
-0+ +static const struct file_operations pt_debugfs_stats_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_stats_read, + .write = ptdma_debugfs_stats_write, +};Can you use
DEFINE_SIMPLE_ATTRIBUTE()here intead of these?
Okay Greg, noted. This will be resolved in next set of patches.
Quoted 4 lines
thanks,
greg k-h
Quoted 16 lines · On 9/24/2019 1:35 PM, [email protected] wrote:
[CAUTION: External Email]
Quoted 13 lines · Sanju
drivers/dma/ptdma/ptdma-debugfs.c new file +13
-0+static const struct file_operations pt_debugfs_info_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_info_read, + .write =NULL , +}; + +static const struct file_operations pt_debugfs_queue_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_queue_read, + .write = ptdma_debugfs_queue_write, +};
Quoted 8 lines
drivers/dma/ptdma/ptdma-debugfs.c line 211
Quoted 7 lines
drivers/dma/ptdma/ptdma-debugfs.c new file +7
-0+ +static const struct file_operations pt_debugfs_stats_ops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ptdma_debugfs_stats_read, + .write = ptdma_debugfs_stats_write, +};Can you use
DEFINE_SIMPLE_ATTRIBUTE()here intead of these?
Okay Greg, noted. This will be resolved in next set of patches.
Quoted 4 lines
thanks,
greg k-h