Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Intel MIC Platform Software Stack (MPSS)
3 *
4 * Copyright(c) 2013 Intel Corporation.
5 *
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.
9 *
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.
14 *
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
17 *
18 * Intel MIC Host driver.
19 *
20 */
21#include <linux/debugfs.h>
22#include <linux/pci.h>
23#include <linux/seq_file.h>
24
25#include <linux/mic_common.h>
26#include "../common/mic_dev.h"
27#include "mic_device.h"
28#include "mic_smpt.h"
29
30/* Debugfs parent dir */
31static struct dentry *mic_dbg;
32
33static int mic_smpt_show(struct seq_file *s, void *pos)
34{
35 int i;
36 struct mic_device *mdev = s->private;
37 unsigned long flags;
38
39 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
40 mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
41 seq_puts(s, "====================================================\n");
42
43 if (mdev->smpt) {
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);
50 }
51 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
52 }
53 seq_puts(s, "====================================================\n");
54 return 0;
55}
56
57DEFINE_SHOW_ATTRIBUTE(mic_smpt);
58
59static int mic_post_code_show(struct seq_file *s, void *pos)
60{
61 struct mic_device *mdev = s->private;
62 u32 reg = mdev->ops->get_postcode(mdev);
63
64 seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff);
65 return 0;
66}
67
68DEFINE_SHOW_ATTRIBUTE(mic_post_code);
69
70static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
71{
72 struct mic_device *mdev = s->private;
73 int reg;
74 int i, j;
75 u16 entry;
76 u16 vector;
77 struct pci_dev *pdev = mdev->pdev;
78
79 if (pci_dev_msi_enabled(pdev)) {
80 for (i = 0; i < mdev->irq_info.num_vectors; i++) {
81 if (pdev->msix_enabled) {
82 entry = mdev->irq_info.msix_entries[i].entry;
83 vector = mdev->irq_info.msix_entries[i].vector;
84 } else {
85 entry = 0;
86 vector = pdev->irq;
87 }
88
89 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
90
91 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
92 "IRQ:", vector, "Entry:", entry, i, reg);
93
94 seq_printf(s, "%-10s", "offset:");
95 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
96 seq_printf(s, "%4d ", j);
97 seq_puts(s, "\n");
98
99
100 seq_printf(s, "%-10s", "count:");
101 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
102 seq_printf(s, "%4d ",
103 (mdev->irq_info.mic_msi_map[i] &
104 BIT(j)) ? 1 : 0);
105 seq_puts(s, "\n\n");
106 }
107 } else {
108 seq_puts(s, "MSI/MSIx interrupts not enabled\n");
109 }
110
111 return 0;
112}
113
114DEFINE_SHOW_ATTRIBUTE(mic_msi_irq_info);
115
116/**
117 * mic_create_debug_dir - Initialize MIC debugfs entries.
118 */
119void mic_create_debug_dir(struct mic_device *mdev)
120{
121 char name[16];
122
123 if (!mic_dbg)
124 return;
125
126 scnprintf(name, sizeof(name), "mic%d", mdev->id);
127 mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
128 if (!mdev->dbg_dir)
129 return;
130
131 debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
132 &mic_smpt_fops);
133
134 debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
135 &mic_post_code_fops);
136
137 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
138 &mic_msi_irq_info_fops);
139}
140
141/**
142 * mic_delete_debug_dir - Uninitialize MIC debugfs entries.
143 */
144void mic_delete_debug_dir(struct mic_device *mdev)
145{
146 if (!mdev->dbg_dir)
147 return;
148
149 debugfs_remove_recursive(mdev->dbg_dir);
150}
151
152/**
153 * mic_init_debugfs - Initialize global debugfs entry.
154 */
155void __init mic_init_debugfs(void)
156{
157 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
158 if (!mic_dbg)
159 pr_err("can't create debugfs dir\n");
160}
161
162/**
163 * mic_exit_debugfs - Uninitialize global debugfs entry
164 */
165void mic_exit_debugfs(void)
166{
167 debugfs_remove(mic_dbg);
168}