Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 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> |
Sudeep Dutt | 4aa7996 | 2013-09-27 09:49:42 -0700 | [diff] [blame] | 26 | #include "../common/mic_dev.h" |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 27 | #include "mic_device.h" |
| 28 | #include "mic_smpt.h" |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 29 | #include "mic_virtio.h" |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 30 | |
| 31 | /* Debugfs parent dir */ |
| 32 | static struct dentry *mic_dbg; |
| 33 | |
| 34 | /** |
| 35 | * mic_log_buf_show - Display MIC kernel log buffer. |
| 36 | * |
| 37 | * log_buf addr/len is read from System.map by user space |
| 38 | * and populated in sysfs entries. |
| 39 | */ |
| 40 | static int mic_log_buf_show(struct seq_file *s, void *unused) |
| 41 | { |
| 42 | void __iomem *log_buf_va; |
| 43 | int __iomem *log_buf_len_va; |
| 44 | struct mic_device *mdev = s->private; |
| 45 | void *kva; |
| 46 | int size; |
| 47 | unsigned long aper_offset; |
| 48 | |
| 49 | if (!mdev || !mdev->log_buf_addr || !mdev->log_buf_len) |
| 50 | goto done; |
| 51 | /* |
| 52 | * Card kernel will never be relocated and any kernel text/data mapping |
| 53 | * can be translated to phys address by subtracting __START_KERNEL_map. |
| 54 | */ |
| 55 | aper_offset = (unsigned long)mdev->log_buf_len - __START_KERNEL_map; |
| 56 | log_buf_len_va = mdev->aper.va + aper_offset; |
| 57 | aper_offset = (unsigned long)mdev->log_buf_addr - __START_KERNEL_map; |
| 58 | log_buf_va = mdev->aper.va + aper_offset; |
| 59 | size = ioread32(log_buf_len_va); |
| 60 | |
| 61 | kva = kmalloc(size, GFP_KERNEL); |
| 62 | if (!kva) |
| 63 | goto done; |
| 64 | mutex_lock(&mdev->mic_mutex); |
| 65 | memcpy_fromio(kva, log_buf_va, size); |
| 66 | switch (mdev->state) { |
| 67 | case MIC_ONLINE: |
| 68 | /* Fall through */ |
| 69 | case MIC_SHUTTING_DOWN: |
| 70 | seq_write(s, kva, size); |
| 71 | break; |
| 72 | default: |
| 73 | break; |
| 74 | } |
| 75 | mutex_unlock(&mdev->mic_mutex); |
| 76 | kfree(kva); |
| 77 | done: |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | static int mic_log_buf_open(struct inode *inode, struct file *file) |
| 82 | { |
| 83 | return single_open(file, mic_log_buf_show, inode->i_private); |
| 84 | } |
| 85 | |
| 86 | static int mic_log_buf_release(struct inode *inode, struct file *file) |
| 87 | { |
| 88 | return single_release(inode, file); |
| 89 | } |
| 90 | |
| 91 | static const struct file_operations log_buf_ops = { |
| 92 | .owner = THIS_MODULE, |
| 93 | .open = mic_log_buf_open, |
| 94 | .read = seq_read, |
| 95 | .llseek = seq_lseek, |
| 96 | .release = mic_log_buf_release |
| 97 | }; |
| 98 | |
| 99 | static int mic_smpt_show(struct seq_file *s, void *pos) |
| 100 | { |
| 101 | int i; |
| 102 | struct mic_device *mdev = s->private; |
| 103 | unsigned long flags; |
| 104 | |
| 105 | seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 106 | mdev->id, "SMPT entry", "SW DMA addr", "RefCount"); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 107 | seq_puts(s, "====================================================\n"); |
| 108 | |
| 109 | if (mdev->smpt) { |
| 110 | struct mic_smpt_info *smpt_info = mdev->smpt; |
| 111 | spin_lock_irqsave(&smpt_info->smpt_lock, flags); |
| 112 | for (i = 0; i < smpt_info->info.num_reg; i++) { |
| 113 | seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 114 | " ", i, smpt_info->entry[i].dma_addr, |
| 115 | smpt_info->entry[i].ref_count); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 116 | } |
| 117 | spin_unlock_irqrestore(&smpt_info->smpt_lock, flags); |
| 118 | } |
| 119 | seq_puts(s, "====================================================\n"); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | static int mic_smpt_debug_open(struct inode *inode, struct file *file) |
| 124 | { |
| 125 | return single_open(file, mic_smpt_show, inode->i_private); |
| 126 | } |
| 127 | |
| 128 | static int mic_smpt_debug_release(struct inode *inode, struct file *file) |
| 129 | { |
| 130 | return single_release(inode, file); |
| 131 | } |
| 132 | |
| 133 | static const struct file_operations smpt_file_ops = { |
| 134 | .owner = THIS_MODULE, |
| 135 | .open = mic_smpt_debug_open, |
| 136 | .read = seq_read, |
| 137 | .llseek = seq_lseek, |
| 138 | .release = mic_smpt_debug_release |
| 139 | }; |
| 140 | |
| 141 | static int mic_soft_reset_show(struct seq_file *s, void *pos) |
| 142 | { |
| 143 | struct mic_device *mdev = s->private; |
| 144 | |
| 145 | mic_stop(mdev, true); |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static int mic_soft_reset_debug_open(struct inode *inode, struct file *file) |
| 150 | { |
| 151 | return single_open(file, mic_soft_reset_show, inode->i_private); |
| 152 | } |
| 153 | |
| 154 | static int mic_soft_reset_debug_release(struct inode *inode, struct file *file) |
| 155 | { |
| 156 | return single_release(inode, file); |
| 157 | } |
| 158 | |
| 159 | static const struct file_operations soft_reset_ops = { |
| 160 | .owner = THIS_MODULE, |
| 161 | .open = mic_soft_reset_debug_open, |
| 162 | .read = seq_read, |
| 163 | .llseek = seq_lseek, |
| 164 | .release = mic_soft_reset_debug_release |
| 165 | }; |
| 166 | |
| 167 | static int mic_post_code_show(struct seq_file *s, void *pos) |
| 168 | { |
| 169 | struct mic_device *mdev = s->private; |
| 170 | u32 reg = mdev->ops->get_postcode(mdev); |
| 171 | |
| 172 | seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff); |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static int mic_post_code_debug_open(struct inode *inode, struct file *file) |
| 177 | { |
| 178 | return single_open(file, mic_post_code_show, inode->i_private); |
| 179 | } |
| 180 | |
| 181 | static int mic_post_code_debug_release(struct inode *inode, struct file *file) |
| 182 | { |
| 183 | return single_release(inode, file); |
| 184 | } |
| 185 | |
| 186 | static const struct file_operations post_code_ops = { |
| 187 | .owner = THIS_MODULE, |
| 188 | .open = mic_post_code_debug_open, |
| 189 | .read = seq_read, |
| 190 | .llseek = seq_lseek, |
| 191 | .release = mic_post_code_debug_release |
| 192 | }; |
| 193 | |
| 194 | static int mic_dp_show(struct seq_file *s, void *pos) |
| 195 | { |
| 196 | struct mic_device *mdev = s->private; |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 197 | struct mic_device_desc *d; |
| 198 | struct mic_device_ctrl *dc; |
| 199 | struct mic_vqconfig *vqconfig; |
| 200 | __u32 *features; |
| 201 | __u8 *config; |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 202 | struct mic_bootparam *bootparam = mdev->dp; |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 203 | int i, j; |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 204 | |
| 205 | seq_printf(s, "Bootparam: magic 0x%x\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 206 | bootparam->magic); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 207 | seq_printf(s, "Bootparam: h2c_shutdown_db %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 208 | bootparam->h2c_shutdown_db); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 209 | seq_printf(s, "Bootparam: h2c_config_db %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 210 | bootparam->h2c_config_db); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 211 | seq_printf(s, "Bootparam: c2h_shutdown_db %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 212 | bootparam->c2h_shutdown_db); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 213 | seq_printf(s, "Bootparam: shutdown_status %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 214 | bootparam->shutdown_status); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 215 | seq_printf(s, "Bootparam: shutdown_card %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 216 | bootparam->shutdown_card); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 217 | |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 218 | for (i = sizeof(*bootparam); i < MIC_DP_SIZE; |
| 219 | i += mic_total_desc_size(d)) { |
| 220 | d = mdev->dp + i; |
| 221 | dc = (void *)d + mic_aligned_desc_size(d); |
| 222 | |
| 223 | /* end of list */ |
| 224 | if (d->type == 0) |
| 225 | break; |
| 226 | |
| 227 | if (d->type == -1) |
| 228 | continue; |
| 229 | |
| 230 | seq_printf(s, "Type %d ", d->type); |
| 231 | seq_printf(s, "Num VQ %d ", d->num_vq); |
| 232 | seq_printf(s, "Feature Len %d\n", d->feature_len); |
| 233 | seq_printf(s, "Config Len %d ", d->config_len); |
| 234 | seq_printf(s, "Shutdown Status %d\n", d->status); |
| 235 | |
| 236 | for (j = 0; j < d->num_vq; j++) { |
| 237 | vqconfig = mic_vq_config(d) + j; |
| 238 | seq_printf(s, "vqconfig[%d]: ", j); |
| 239 | seq_printf(s, "address 0x%llx ", vqconfig->address); |
| 240 | seq_printf(s, "num %d ", vqconfig->num); |
| 241 | seq_printf(s, "used address 0x%llx\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 242 | vqconfig->used_address); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 245 | features = (__u32 *)mic_vq_features(d); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 246 | seq_printf(s, "Features: Host 0x%x ", features[0]); |
| 247 | seq_printf(s, "Guest 0x%x\n", features[1]); |
| 248 | |
| 249 | config = mic_vq_configspace(d); |
| 250 | for (j = 0; j < d->config_len; j++) |
| 251 | seq_printf(s, "config[%d]=%d\n", j, config[j]); |
| 252 | |
| 253 | seq_puts(s, "Device control:\n"); |
| 254 | seq_printf(s, "Config Change %d ", dc->config_change); |
| 255 | seq_printf(s, "Vdev reset %d\n", dc->vdev_reset); |
| 256 | seq_printf(s, "Guest Ack %d ", dc->guest_ack); |
| 257 | seq_printf(s, "Host ack %d\n", dc->host_ack); |
| 258 | seq_printf(s, "Used address updated %d ", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 259 | dc->used_address_updated); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 260 | seq_printf(s, "Vdev 0x%llx\n", dc->vdev); |
| 261 | seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db); |
| 262 | seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db); |
| 263 | } |
| 264 | |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | static int mic_dp_debug_open(struct inode *inode, struct file *file) |
| 269 | { |
| 270 | return single_open(file, mic_dp_show, inode->i_private); |
| 271 | } |
| 272 | |
| 273 | static int mic_dp_debug_release(struct inode *inode, struct file *file) |
| 274 | { |
| 275 | return single_release(inode, file); |
| 276 | } |
| 277 | |
| 278 | static const struct file_operations dp_ops = { |
| 279 | .owner = THIS_MODULE, |
| 280 | .open = mic_dp_debug_open, |
| 281 | .read = seq_read, |
| 282 | .llseek = seq_lseek, |
| 283 | .release = mic_dp_debug_release |
| 284 | }; |
| 285 | |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 286 | static int mic_vdev_info_show(struct seq_file *s, void *unused) |
| 287 | { |
| 288 | struct mic_device *mdev = s->private; |
| 289 | struct list_head *pos, *tmp; |
| 290 | struct mic_vdev *mvdev; |
| 291 | int i, j; |
| 292 | |
| 293 | mutex_lock(&mdev->mic_mutex); |
| 294 | list_for_each_safe(pos, tmp, &mdev->vdev_list) { |
| 295 | mvdev = list_entry(pos, struct mic_vdev, list); |
| 296 | seq_printf(s, "VDEV type %d state %s in %ld out %ld\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 297 | mvdev->virtio_id, |
| 298 | mic_vdevup(mvdev) ? "UP" : "DOWN", |
| 299 | mvdev->in_bytes, |
| 300 | mvdev->out_bytes); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 301 | for (i = 0; i < MIC_MAX_VRINGS; i++) { |
| 302 | struct vring_desc *desc; |
| 303 | struct vring_avail *avail; |
| 304 | struct vring_used *used; |
| 305 | struct mic_vringh *mvr = &mvdev->mvr[i]; |
| 306 | struct vringh *vrh = &mvr->vrh; |
| 307 | int num = vrh->vring.num; |
| 308 | if (!num) |
| 309 | continue; |
| 310 | desc = vrh->vring.desc; |
| 311 | seq_printf(s, "vring i %d avail_idx %d", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 312 | i, mvr->vring.info->avail_idx & (num - 1)); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 313 | seq_printf(s, " vring i %d avail_idx %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 314 | i, mvr->vring.info->avail_idx); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 315 | seq_printf(s, "vrh i %d weak_barriers %d", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 316 | i, vrh->weak_barriers); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 317 | seq_printf(s, " last_avail_idx %d last_used_idx %d", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 318 | vrh->last_avail_idx, vrh->last_used_idx); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 319 | seq_printf(s, " completed %d\n", vrh->completed); |
| 320 | for (j = 0; j < num; j++) { |
| 321 | seq_printf(s, "desc[%d] addr 0x%llx len %d", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 322 | j, desc->addr, desc->len); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 323 | seq_printf(s, " flags 0x%x next %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 324 | desc->flags, desc->next); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 325 | desc++; |
| 326 | } |
| 327 | avail = vrh->vring.avail; |
| 328 | seq_printf(s, "avail flags 0x%x idx %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 329 | avail->flags, avail->idx & (num - 1)); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 330 | seq_printf(s, "avail flags 0x%x idx %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 331 | avail->flags, avail->idx); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 332 | for (j = 0; j < num; j++) |
| 333 | seq_printf(s, "avail ring[%d] %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 334 | j, avail->ring[j]); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 335 | used = vrh->vring.used; |
| 336 | seq_printf(s, "used flags 0x%x idx %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 337 | used->flags, used->idx & (num - 1)); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 338 | seq_printf(s, "used flags 0x%x idx %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 339 | used->flags, used->idx); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 340 | for (j = 0; j < num; j++) |
| 341 | seq_printf(s, "used ring[%d] id %d len %d\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 342 | j, used->ring[j].id, |
| 343 | used->ring[j].len); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 344 | } |
| 345 | } |
| 346 | mutex_unlock(&mdev->mic_mutex); |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | static int mic_vdev_info_debug_open(struct inode *inode, struct file *file) |
| 352 | { |
| 353 | return single_open(file, mic_vdev_info_show, inode->i_private); |
| 354 | } |
| 355 | |
| 356 | static int mic_vdev_info_debug_release(struct inode *inode, struct file *file) |
| 357 | { |
| 358 | return single_release(inode, file); |
| 359 | } |
| 360 | |
| 361 | static const struct file_operations vdev_info_ops = { |
| 362 | .owner = THIS_MODULE, |
| 363 | .open = mic_vdev_info_debug_open, |
| 364 | .read = seq_read, |
| 365 | .llseek = seq_lseek, |
| 366 | .release = mic_vdev_info_debug_release |
| 367 | }; |
| 368 | |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 369 | static int mic_msi_irq_info_show(struct seq_file *s, void *pos) |
| 370 | { |
| 371 | struct mic_device *mdev = s->private; |
| 372 | int reg; |
| 373 | int i, j; |
| 374 | u16 entry; |
| 375 | u16 vector; |
| 376 | struct pci_dev *pdev = container_of(mdev->sdev->parent, |
| 377 | struct pci_dev, dev); |
| 378 | |
| 379 | if (pci_dev_msi_enabled(pdev)) { |
| 380 | for (i = 0; i < mdev->irq_info.num_vectors; i++) { |
| 381 | if (pdev->msix_enabled) { |
| 382 | entry = mdev->irq_info.msix_entries[i].entry; |
| 383 | vector = mdev->irq_info.msix_entries[i].vector; |
| 384 | } else { |
| 385 | entry = 0; |
| 386 | vector = pdev->irq; |
| 387 | } |
| 388 | |
| 389 | reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry); |
| 390 | |
| 391 | seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 392 | "IRQ:", vector, "Entry:", entry, i, reg); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 393 | |
| 394 | seq_printf(s, "%-10s", "offset:"); |
| 395 | for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--) |
| 396 | seq_printf(s, "%4d ", j); |
| 397 | seq_puts(s, "\n"); |
| 398 | |
| 399 | |
| 400 | seq_printf(s, "%-10s", "count:"); |
| 401 | for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--) |
| 402 | seq_printf(s, "%4d ", |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 403 | (mdev->irq_info.mic_msi_map[i] & |
| 404 | BIT(j)) ? 1 : 0); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 405 | seq_puts(s, "\n\n"); |
| 406 | } |
| 407 | } else { |
| 408 | seq_puts(s, "MSI/MSIx interrupts not enabled\n"); |
| 409 | } |
| 410 | |
| 411 | return 0; |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file) |
| 415 | { |
| 416 | return single_open(file, mic_msi_irq_info_show, inode->i_private); |
| 417 | } |
| 418 | |
| 419 | static int |
| 420 | mic_msi_irq_info_debug_release(struct inode *inode, struct file *file) |
| 421 | { |
| 422 | return single_release(inode, file); |
| 423 | } |
| 424 | |
| 425 | static const struct file_operations msi_irq_info_ops = { |
| 426 | .owner = THIS_MODULE, |
| 427 | .open = mic_msi_irq_info_debug_open, |
| 428 | .read = seq_read, |
| 429 | .llseek = seq_lseek, |
| 430 | .release = mic_msi_irq_info_debug_release |
| 431 | }; |
| 432 | |
| 433 | /** |
| 434 | * mic_create_debug_dir - Initialize MIC debugfs entries. |
| 435 | */ |
| 436 | void mic_create_debug_dir(struct mic_device *mdev) |
| 437 | { |
| 438 | if (!mic_dbg) |
| 439 | return; |
| 440 | |
| 441 | mdev->dbg_dir = debugfs_create_dir(dev_name(mdev->sdev), mic_dbg); |
| 442 | if (!mdev->dbg_dir) |
| 443 | return; |
| 444 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 445 | debugfs_create_file("log_buf", 0444, mdev->dbg_dir, mdev, &log_buf_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 446 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 447 | debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev, &smpt_file_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 448 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 449 | debugfs_create_file("soft_reset", 0444, mdev->dbg_dir, mdev, |
| 450 | &soft_reset_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 451 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 452 | debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev, |
| 453 | &post_code_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 454 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 455 | debugfs_create_file("dp", 0444, mdev->dbg_dir, mdev, &dp_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 456 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 457 | debugfs_create_file("vdev_info", 0444, mdev->dbg_dir, mdev, |
| 458 | &vdev_info_ops); |
Ashutosh Dixit | f69bcbf | 2013-09-05 16:42:18 -0700 | [diff] [blame] | 459 | |
Ashutosh Dixit | ced2c60 | 2013-09-27 09:49:53 -0700 | [diff] [blame] | 460 | debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev, |
| 461 | &msi_irq_info_ops); |
Sudeep Dutt | 3a6a920 | 2013-09-05 16:41:55 -0700 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /** |
| 465 | * mic_delete_debug_dir - Uninitialize MIC debugfs entries. |
| 466 | */ |
| 467 | void mic_delete_debug_dir(struct mic_device *mdev) |
| 468 | { |
| 469 | if (!mdev->dbg_dir) |
| 470 | return; |
| 471 | |
| 472 | debugfs_remove_recursive(mdev->dbg_dir); |
| 473 | } |
| 474 | |
| 475 | /** |
| 476 | * mic_init_debugfs - Initialize global debugfs entry. |
| 477 | */ |
| 478 | void __init mic_init_debugfs(void) |
| 479 | { |
| 480 | mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 481 | if (!mic_dbg) |
| 482 | pr_err("can't create debugfs dir\n"); |
| 483 | } |
| 484 | |
| 485 | /** |
| 486 | * mic_exit_debugfs - Uninitialize global debugfs entry |
| 487 | */ |
| 488 | void mic_exit_debugfs(void) |
| 489 | { |
| 490 | debugfs_remove(mic_dbg); |
| 491 | } |