1 // SPDX-License-Identifier: GPL-2.0-only
3 * AMD Passthrough DMA device driver
4 * -- Based on the CCP driver
6 * Copyright (C) 2016,2021 Advanced Micro Devices, Inc.
8 * Author: Sanjay R Mehta <sanju.mehta@amd.com>
9 * Author: Gary R Hook <gary.hook@amd.com>
12 #include <linux/debugfs.h>
13 #include <linux/seq_file.h>
18 #define RI_VERSION_NUM 0x0000003F
20 #define RI_NUM_VQM 0x00078000
21 #define RI_NVQM_SHIFT 15
23 static int pt_debugfs_info_show(struct seq_file
*s
, void *p
)
25 struct pt_device
*pt
= s
->private;
28 seq_printf(s
, "Device name: %s\n", dev_name(pt
->dev
));
29 seq_printf(s
, " # Queues: %d\n", 1);
30 seq_printf(s
, " # Cmds: %d\n", pt
->cmd_count
);
32 regval
= ioread32(pt
->io_regs
+ CMD_PT_VERSION
);
34 seq_printf(s
, " Version: %d\n", regval
& RI_VERSION_NUM
);
35 seq_puts(s
, " Engines:");
37 seq_printf(s
, " Queues: %d\n", (regval
& RI_NUM_VQM
) >> RI_NVQM_SHIFT
);
43 * Return a formatted buffer containing the current
44 * statistics of queue for PTDMA
46 static int pt_debugfs_stats_show(struct seq_file
*s
, void *p
)
48 struct pt_device
*pt
= s
->private;
50 seq_printf(s
, "Total Interrupts Handled: %ld\n", pt
->total_interrupts
);
55 static int pt_debugfs_queue_show(struct seq_file
*s
, void *p
)
57 struct pt_cmd_queue
*cmd_q
= s
->private;
63 seq_printf(s
, " Pass-Thru: %ld\n", cmd_q
->total_pt_ops
);
65 regval
= ioread32(cmd_q
->reg_control
+ 0x000C);
67 seq_puts(s
, " Enabled Interrupts:");
68 if (regval
& INT_EMPTY_QUEUE
)
69 seq_puts(s
, " EMPTY");
70 if (regval
& INT_QUEUE_STOPPED
)
71 seq_puts(s
, " STOPPED");
72 if (regval
& INT_ERROR
)
73 seq_puts(s
, " ERROR");
74 if (regval
& INT_COMPLETION
)
75 seq_puts(s
, " COMPLETION");
81 DEFINE_SHOW_ATTRIBUTE(pt_debugfs_info
);
82 DEFINE_SHOW_ATTRIBUTE(pt_debugfs_queue
);
83 DEFINE_SHOW_ATTRIBUTE(pt_debugfs_stats
);
85 void ptdma_debugfs_setup(struct pt_device
*pt
)
87 struct pt_cmd_queue
*cmd_q
;
88 struct dentry
*debugfs_q_instance
;
90 if (!debugfs_initialized())
93 debugfs_create_file("info", 0400, pt
->dma_dev
.dbg_dev_root
, pt
,
94 &pt_debugfs_info_fops
);
96 debugfs_create_file("stats", 0400, pt
->dma_dev
.dbg_dev_root
, pt
,
97 &pt_debugfs_stats_fops
);
102 debugfs_create_dir("q", pt
->dma_dev
.dbg_dev_root
);
104 debugfs_create_file("stats", 0400, debugfs_q_instance
, cmd_q
,
105 &pt_debugfs_queue_fops
);