root/drivers/misc/mic/host/mic_debugfs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mic_smpt_show
  2. mic_post_code_show
  3. mic_msi_irq_info_show
  4. mic_create_debug_dir
  5. mic_delete_debug_dir
  6. mic_init_debugfs
  7. mic_exit_debugfs

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

/* [<][>][^][v][top][bottom][index][help] */