mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gary R Hook <gary.hook@amd.com>
To: Sohil Mehta <sohil.mehta@intel.com>,
	Joerg Roedel <joro@8bytes.org>,
	Alex Williamson <alex.williamson@redhat.com>
Cc: Ravi V Shankar <ravi.v.shankar@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Gayatri Kammela <gayatri.kammela@intel.com>
Subject: Re: [PATCH v6 2/5] iommu/vt-d: Add debugfs support to show context internals
Date: Wed, 10 Jan 2018 11:02:08 -0600	[thread overview]
Message-ID: <042eb604-9ff6-1e50-2027-801cf8e59a33@amd.com> (raw)
In-Reply-To: <1515556102-34150-3-git-send-email-sohil.mehta@intel.com>

On 01/09/2018 09:48 PM, Sohil Mehta wrote:
> From: Gayatri Kammela <gayatri.kammela@intel.com>
> 
> IOMMU internals states such as root and context can be exported to the
> userspace.
> 
> Example of such dump in Kabylake:
> 
> root@OTC-KBLH-01:~# cat
> /sys/kernel/debug/intel_iommu/dmar_translation_struct
> 
> IOMMU dmar0: Extended Root Table Addr:402b9e800
> Extended Root table entries:
> Bus 0 L: 402150001 H: 0
> Lower Context table entries for Bus: 0
> [entry] DID :B :D .F    Low             High
> [80]    0000:00:0a.00   40214fa05       102
> Higher Context table entries for Bus: 0
> [80]    0000:00:0a.00   40260000c       0
> 
> IOMMU dmar1:    Root Table Addr:4558a3000
>   Root tbl entries:
> Bus 0 L: 4558aa001 H: 0
>   Context table entries for Bus: 0
> [entry] DID :B :D .F    Low             High
> [160]   0000:00:14.00   4558a9001       102
> [184]   0000:00:17.00   400eac001       302
> [248]   0000:00:1f.00   4558af001       202
> [251]   0000:00:1f.03   40070e001       502
> [254]   0000:00:1f.06   4467c9001       602
>   Root tbl entries:
> Bus 1 L: 3fc8c2001 H: 0
>   Context table entries for Bus: 1
> [entry] DID :B :D .F    Low             High
> [0]     0000:01:00.00   3fc8c3001       402
> 
> Cc: Sohil Mehta <sohil.mehta@intel.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> Cc: Ashok Raj <ashok.raj@intel.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Gayatri Kammela <gayatri.kammela@intel.com>
> ---
> 
> v6: Change the order of includes to an alphabetical order
>      Change seq_printf formatting
> 
> v5: Change to a SPDX license tag
>      Fix seq_printf formatting
> 
> v4: Remove the unused function parameter
>      Fix checkpatch.pl warnings
>      Remove error reporting for debugfs_create_file function
>      Fix unnecessary reprogramming of the context entries
>      Simplify and merge the show context and extended context patch into one
>      Remove redundant IOMMU null check under for_each_active_iommu
> 
> v3: Add a macro for seq file operations
>      Change the intel_iommu_ctx file name to dmar_translation_struct
> 
> v2: No change
> 
>   drivers/iommu/Makefile            |   1 +
>   drivers/iommu/intel-iommu-debug.c | 139 ++++++++++++++++++++++++++++++++++++++
>   drivers/iommu/intel-iommu.c       |   4 ++
>   3 files changed, 144 insertions(+)
>   create mode 100644 drivers/iommu/intel-iommu-debug.c
> 
> diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile
> index 1fb6958..fdbaf46 100644
> --- a/drivers/iommu/Makefile
> +++ b/drivers/iommu/Makefile
> @@ -15,6 +15,7 @@ obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
>   obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o
>   obj-$(CONFIG_DMAR_TABLE) += dmar.o
>   obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o
> +obj-$(CONFIG_INTEL_IOMMU_DEBUG) += intel-iommu-debug.o
>   obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o
>   obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o
>   obj-$(CONFIG_IRQ_REMAP) += intel_irq_remapping.o irq_remapping.o
> diff --git a/drivers/iommu/intel-iommu-debug.c b/drivers/iommu/intel-iommu-debug.c
> new file mode 100644
> index 0000000..d5b0eea
> --- /dev/null
> +++ b/drivers/iommu/intel-iommu-debug.c
> @@ -0,0 +1,139 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright © 2017 Intel Corporation.
> + *
> + * Authors: Gayatri Kammela <gayatri.kammela@intel.com>
> + *          Jacob Pan <jacob.jun.pan@linux.intel.com>
> + *
> + */
> +
> +#define pr_fmt(fmt)     "INTEL_IOMMU: " fmt
> +#include <linux/debugfs.h>
> +#include <linux/dmar.h>
> +#include <linux/err.h>
> +#include <linux/intel-iommu.h>
> +#include <linux/intel-svm.h>
> +#include <linux/io.h>
> +#include <linux/iommu.h>
> +#include <linux/pci.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/slab.h>
> +#include <linux/spinlock.h>
> +#include <linux/uaccess.h>
> +
> +#include "irq_remapping.h"
> +
> +#define TOTAL_BUS_NR (256) /* full bus range 256 */
> +#define DEFINE_SHOW_ATTRIBUTE(__name)					\
> +static int __name ## _open(struct inode *inode, struct file *file)	\
> +{									\
> +	return single_open(file, __name ## _show, inode->i_private);	\
> +}									\
> +static const struct file_operations __name ## _fops =			\
> +{									\
> +	.open		= __name ## _open,				\
> +	.read		= seq_read,					\
> +	.llseek		= seq_lseek,					\
> +	.release	= single_release,				\
> +	.owner		= THIS_MODULE,					\
> +}
> +
> +static void ctx_tbl_entry_show(struct seq_file *m, struct intel_iommu *iommu,
> +			       int bus, bool ext, bool new_ext)
> +{
> +	struct context_entry *context;
> +	int ctx;
> +	unsigned long flags;
> +
> +	seq_printf(m, "%s Context table entries for Bus: %d\n",
> +		   ext ? "Lower" : "", bus);
> +	seq_puts(m, "[entry]\tDID :B :D .F\tLow\t\tHigh\n");
> +
> +	spin_lock_irqsave(&iommu->lock, flags);
> +
> +	/* Publish either context entries or extended contenxt entries */

                                                       ^^^^^^^^ typo

  reply	other threads:[~2018-01-10 17:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10  3:48 [PATCH v6 0/5] Add Intel IOMMU debugfs support Sohil Mehta
2018-01-10  3:48 ` [PATCH v6 1/5] iommu/vt-d: Add debugfs support for Intel IOMMU internals Sohil Mehta
2018-01-10 13:32   ` Andy Shevchenko
2018-01-10  3:48 ` [PATCH v6 2/5] iommu/vt-d: Add debugfs support to show context internals Sohil Mehta
2018-01-10 17:02   ` Gary R Hook [this message]
2018-01-10  3:48 ` [PATCH v6 3/5] iommu/vt-d: Add debugfs support to show register contents Sohil Mehta
2018-01-10 13:35   ` Andy Shevchenko
2018-01-10  3:48 ` [PATCH v6 4/5] iommu/vt-d: Add debugfs support to show Pasid table contents Sohil Mehta
2018-01-10 13:40   ` Andy Shevchenko
2018-01-10  3:48 ` [PATCH v6 5/5] iommu/vt-d: Add debugfs support for Interrupt remapping Sohil Mehta
2018-01-10 13:43   ` Andy Shevchenko
2018-01-10 13:46 ` [PATCH v6 0/5] Add Intel IOMMU debugfs support Andy Shevchenko
2018-01-11  1:32   ` Mehta, Sohil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=042eb604-9ff6-1e50-2027-801cf8e59a33@amd.com \
    --to=gary.hook@amd.com \
    --cc=alex.williamson@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=fenghua.yu@intel.com \
    --cc=gayatri.kammela@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ravi.v.shankar@intel.com \
    --cc=sohil.mehta@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®