2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2013 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Intel MIC Host driver.
21 #include <linux/debugfs.h>
22 #include <linux/pci.h>
23 #include <linux/seq_file.h>
25 #include <linux/mic_common.h>
26 #include "../common/mic_dev.h"
27 #include "mic_device.h"
30 /* Debugfs parent dir */
31 static struct dentry *mic_dbg;
33 static int mic_smpt_show(struct seq_file *s, void *pos)
36 struct mic_device *mdev = s->private;
39 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
40 mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
41 seq_puts(s, "====================================================\n");
44 struct mic_smpt_info *smpt_info = mdev->smpt;
45 spin_lock_irqsave(&smpt_info->smpt_lock, flags);
46 for (i = 0; i < smpt_info->info.num_reg; i++) {
47 seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
48 " ", i, smpt_info->entry[i].dma_addr,
49 smpt_info->entry[i].ref_count);
51 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
53 seq_puts(s, "====================================================\n");
57 static int mic_smpt_debug_open(struct inode *inode, struct file *file)
59 return single_open(file, mic_smpt_show, inode->i_private);
62 static int mic_smpt_debug_release(struct inode *inode, struct file *file)
64 return single_release(inode, file);
67 static const struct file_operations smpt_file_ops = {
69 .open = mic_smpt_debug_open,
72 .release = mic_smpt_debug_release
75 static int mic_post_code_show(struct seq_file *s, void *pos)
77 struct mic_device *mdev = s->private;
78 u32 reg = mdev->ops->get_postcode(mdev);
80 seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff);
84 static int mic_post_code_debug_open(struct inode *inode, struct file *file)
86 return single_open(file, mic_post_code_show, inode->i_private);
89 static int mic_post_code_debug_release(struct inode *inode, struct file *file)
91 return single_release(inode, file);
94 static const struct file_operations post_code_ops = {
96 .open = mic_post_code_debug_open,
99 .release = mic_post_code_debug_release
102 static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
104 struct mic_device *mdev = s->private;
109 struct pci_dev *pdev = mdev->pdev;
111 if (pci_dev_msi_enabled(pdev)) {
112 for (i = 0; i < mdev->irq_info.num_vectors; i++) {
113 if (pdev->msix_enabled) {
114 entry = mdev->irq_info.msix_entries[i].entry;
115 vector = mdev->irq_info.msix_entries[i].vector;
121 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
123 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
124 "IRQ:", vector, "Entry:", entry, i, reg);
126 seq_printf(s, "%-10s", "offset:");
127 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
128 seq_printf(s, "%4d ", j);
132 seq_printf(s, "%-10s", "count:");
133 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
134 seq_printf(s, "%4d ",
135 (mdev->irq_info.mic_msi_map[i] &
140 seq_puts(s, "MSI/MSIx interrupts not enabled\n");
146 static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file)
148 return single_open(file, mic_msi_irq_info_show, inode->i_private);
152 mic_msi_irq_info_debug_release(struct inode *inode, struct file *file)
154 return single_release(inode, file);
157 static const struct file_operations msi_irq_info_ops = {
158 .owner = THIS_MODULE,
159 .open = mic_msi_irq_info_debug_open,
162 .release = mic_msi_irq_info_debug_release
166 * mic_create_debug_dir - Initialize MIC debugfs entries.
168 void mic_create_debug_dir(struct mic_device *mdev)
175 scnprintf(name, sizeof(name), "mic%d", mdev->id);
176 mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
180 debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev, &smpt_file_ops);
182 debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
185 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
190 * mic_delete_debug_dir - Uninitialize MIC debugfs entries.
192 void mic_delete_debug_dir(struct mic_device *mdev)
197 debugfs_remove_recursive(mdev->dbg_dir);
201 * mic_init_debugfs - Initialize global debugfs entry.
203 void __init mic_init_debugfs(void)
205 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
207 pr_err("can't create debugfs dir\n");
211 * mic_exit_debugfs - Uninitialize global debugfs entry
213 void mic_exit_debugfs(void)
215 debugfs_remove(mic_dbg);