Re: [PATCH v3 3/6] iommu/vt-d: Add Intel IOMMU debugfs to show extended context internals

2017-12-07 Thread Mehta, Sohil
On Wed, 2017-12-06 at 16:17 +0800, Lu Baolu wrote:
> Hi,
> 
> On 12/06/2017 11:43 AM, Sohil Mehta wrote:
> > 
> > From: Gayatri Kammela 
> > 
> > +
> > +   if (new_ext) {
> > +   seq_printf(m, "Higher Context tbl entries for Bus:
> > %d\n", bus);
> > +   ctx_lo = context[0].lo;
> > +
> > +   if (!(ctx_lo & CONTEXT_PASIDE)) {
> > +   context[1].hi = (u64)virt_to_phys(
> > +   iommu->pasid_state_table);
> > +   context[1].lo = (u64)virt_to_phys(iommu-
> > >pasid_table) |
> > +   intel_iommu_get_pts(iommu)
> > ;
> Why do you change the context entries here?
> 

Thanks for catching this. The context entires were mistakenly getting
changed. We'll remove it.

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v3 3/6] iommu/vt-d: Add Intel IOMMU debugfs to show extended context internals

2017-12-06 Thread Lu Baolu
Hi,

On 12/06/2017 11:43 AM, Sohil Mehta wrote:
> From: Gayatri Kammela 
>
> Debugfs extension to dump internals such as extended context table
> entries for each IOMMU to the userspace.
>
> root@OTC-KBLH-01:~# cat
> /sys/kernel/debug/intel_iommu/dmar_translation_struct
>
> IOMMU dmar1: Extended Root Table Addr:4558a1800
> Extended Root tbl entries:
> Bus 0 L: 4558a6001 H: 0
> Lower Context table entries for Bus: 0
> [entry] DID :B :D .FLow High
> [16]:00:02.00   4558a5005   102
> Higher Context tbl entries for Bus: 0
> [16]:00:02.00   401bc   40140
>
> IOMMU dmar0: Extended Root Table Addr:4558a2800
> Extended Root tbl entries:
> Bus 0 L: 4016f4001 H: 0
> Lower Context table entries for Bus: 0
> [entry] DID :B :D .FLow High
> [80]:00:0a.00   4016f3a05   102
> Higher Context tbl entries for Bus: 0

Do you mind changing "tbl entries" to "table entries" so that
it could be consistent with above lower one?

Best regards,
Lu Baolu

> [80]:00:0a.00   4015c   671b8000
>
> Cc: Sohil Mehta 
> Cc: Fenghua Yu 
> Cc: Jacob Pan 
> Cc: Ashok Raj 
> Signed-off-by: Gayatri Kammela 
> ---
>
> v3: No change
>
> v2: No change
>
>  drivers/iommu/intel-iommu-debug.c | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu-debug.c 
> b/drivers/iommu/intel-iommu-debug.c
> index 8ae0c4d..8e7f5d2 100644
> --- a/drivers/iommu/intel-iommu-debug.c
> +++ b/drivers/iommu/intel-iommu-debug.c
> @@ -46,6 +46,38 @@ static const struct file_operations __name ## _fops =  
> \
>   .owner  = THIS_MODULE,  \
>  }
>  
> +#ifdef CONFIG_INTEL_IOMMU_SVM
> +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
> +struct intel_iommu *iommu, int bus, int ctx,
> +struct context_entry *context, bool new_ext)
> +{
> + u64 ctx_lo;
> +
> + if (new_ext) {
> + seq_printf(m, "Higher Context tbl entries for Bus: %d\n", bus);
> + ctx_lo = context[0].lo;
> +
> + if (!(ctx_lo & CONTEXT_PASIDE)) {
> + context[1].hi = (u64)virt_to_phys(
> + iommu->pasid_state_table);
> + context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
> + intel_iommu_get_pts(iommu);
> + }
> +
> + seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n", ctx,
> +iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx),
> +context[1].lo, context[1].hi);
> + }
> +}
> +#else /* CONFIG_INTEL_IOMMU_SVM */
> +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
> +struct intel_iommu *iommu, int bus, int ctx,
> +struct context_entry *context, bool new_ext)
> +{
> + return;
> +}
> +#endif /* CONFIG_INTEL_IOMMU_SVM */
> +
>  static void ctx_tbl_entry_show(struct seq_file *m, void *unused,
>  struct intel_iommu *iommu, int bus, bool ext,
>  bool new_ext)
> @@ -69,6 +101,9 @@ static void ctx_tbl_entry_show(struct seq_file *m, void 
> *unused,
>   seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n",
>  ctx, iommu->segment, bus, PCI_SLOT(ctx),
>  PCI_FUNC(ctx), context[0].lo, context[0].hi);
> +
> + ext_ctx_tbl_entry_show(m, unused, iommu, bus, ctx,
> +context, new_ext);
>   }
>   }
>  out:

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [PATCH v3 3/6] iommu/vt-d: Add Intel IOMMU debugfs to show extended context internals

2017-12-06 Thread Lu Baolu
Hi,

On 12/06/2017 11:43 AM, Sohil Mehta wrote:
> From: Gayatri Kammela 
>
> Debugfs extension to dump internals such as extended context table
> entries for each IOMMU to the userspace.
>
> root@OTC-KBLH-01:~# cat
> /sys/kernel/debug/intel_iommu/dmar_translation_struct
>
> IOMMU dmar1: Extended Root Table Addr:4558a1800
> Extended Root tbl entries:
> Bus 0 L: 4558a6001 H: 0
> Lower Context table entries for Bus: 0
> [entry] DID :B :D .FLow High
> [16]:00:02.00   4558a5005   102
> Higher Context tbl entries for Bus: 0
> [16]:00:02.00   401bc   40140
>
> IOMMU dmar0: Extended Root Table Addr:4558a2800
> Extended Root tbl entries:
> Bus 0 L: 4016f4001 H: 0
> Lower Context table entries for Bus: 0
> [entry] DID :B :D .FLow High
> [80]:00:0a.00   4016f3a05   102
> Higher Context tbl entries for Bus: 0
> [80]:00:0a.00   4015c   671b8000
>
> Cc: Sohil Mehta 
> Cc: Fenghua Yu 
> Cc: Jacob Pan 
> Cc: Ashok Raj 
> Signed-off-by: Gayatri Kammela 
> ---
>
> v3: No change
>
> v2: No change
>
>  drivers/iommu/intel-iommu-debug.c | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu-debug.c 
> b/drivers/iommu/intel-iommu-debug.c
> index 8ae0c4d..8e7f5d2 100644
> --- a/drivers/iommu/intel-iommu-debug.c
> +++ b/drivers/iommu/intel-iommu-debug.c
> @@ -46,6 +46,38 @@ static const struct file_operations __name ## _fops =  
> \
>   .owner  = THIS_MODULE,  \
>  }
>  
> +#ifdef CONFIG_INTEL_IOMMU_SVM
> +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
> +struct intel_iommu *iommu, int bus, int ctx,
> +struct context_entry *context, bool new_ext)
> +{
> + u64 ctx_lo;
> +
> + if (new_ext) {
> + seq_printf(m, "Higher Context tbl entries for Bus: %d\n", bus);
> + ctx_lo = context[0].lo;
> +
> + if (!(ctx_lo & CONTEXT_PASIDE)) {
> + context[1].hi = (u64)virt_to_phys(
> + iommu->pasid_state_table);
> + context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
> + intel_iommu_get_pts(iommu);

Why do you change the context entries here?

> + }
> +
> + seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n", ctx,
> +iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx),
> +context[1].lo, context[1].hi);
> + }
> +}
> +#else /* CONFIG_INTEL_IOMMU_SVM */
> +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
> +struct intel_iommu *iommu, int bus, int ctx,
> +struct context_entry *context, bool new_ext)
> +{
> + return;
> +}
> +#endif /* CONFIG_INTEL_IOMMU_SVM */
> +
>  static void ctx_tbl_entry_show(struct seq_file *m, void *unused,
>  struct intel_iommu *iommu, int bus, bool ext,
>  bool new_ext)
> @@ -69,6 +101,9 @@ static void ctx_tbl_entry_show(struct seq_file *m, void 
> *unused,
>   seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n",
>  ctx, iommu->segment, bus, PCI_SLOT(ctx),
>  PCI_FUNC(ctx), context[0].lo, context[0].hi);
> +
> + ext_ctx_tbl_entry_show(m, unused, iommu, bus, ctx,
> +context, new_ext);

How about

+   if (new_ext)
+   ext_ctx_tbl_entry_show(m, unused, iommu, bus, 
ctx, context);


and remove checking new_ext in ext_ctx_tbl_entry_show()?
 
Best regards,
Lu Baolu
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[PATCH v3 3/6] iommu/vt-d: Add Intel IOMMU debugfs to show extended context internals

2017-12-05 Thread Sohil Mehta
From: Gayatri Kammela 

Debugfs extension to dump internals such as extended context table
entries for each IOMMU to the userspace.

root@OTC-KBLH-01:~# cat
/sys/kernel/debug/intel_iommu/dmar_translation_struct

IOMMU dmar1: Extended Root Table Addr:4558a1800
Extended Root tbl entries:
Bus 0 L: 4558a6001 H: 0
Lower Context table entries for Bus: 0
[entry] DID :B :D .FLow High
[16]:00:02.00   4558a5005   102
Higher Context tbl entries for Bus: 0
[16]:00:02.00   401bc   40140

IOMMU dmar0: Extended Root Table Addr:4558a2800
Extended Root tbl entries:
Bus 0 L: 4016f4001 H: 0
Lower Context table entries for Bus: 0
[entry] DID :B :D .FLow High
[80]:00:0a.00   4016f3a05   102
Higher Context tbl entries for Bus: 0
[80]:00:0a.00   4015c   671b8000

Cc: Sohil Mehta 
Cc: Fenghua Yu 
Cc: Jacob Pan 
Cc: Ashok Raj 
Signed-off-by: Gayatri Kammela 
---

v3: No change

v2: No change

 drivers/iommu/intel-iommu-debug.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/iommu/intel-iommu-debug.c 
b/drivers/iommu/intel-iommu-debug.c
index 8ae0c4d..8e7f5d2 100644
--- a/drivers/iommu/intel-iommu-debug.c
+++ b/drivers/iommu/intel-iommu-debug.c
@@ -46,6 +46,38 @@ static const struct file_operations __name ## _fops =
\
.owner  = THIS_MODULE,  \
 }
 
+#ifdef CONFIG_INTEL_IOMMU_SVM
+static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
+  struct intel_iommu *iommu, int bus, int ctx,
+  struct context_entry *context, bool new_ext)
+{
+   u64 ctx_lo;
+
+   if (new_ext) {
+   seq_printf(m, "Higher Context tbl entries for Bus: %d\n", bus);
+   ctx_lo = context[0].lo;
+
+   if (!(ctx_lo & CONTEXT_PASIDE)) {
+   context[1].hi = (u64)virt_to_phys(
+   iommu->pasid_state_table);
+   context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
+   intel_iommu_get_pts(iommu);
+   }
+
+   seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n", ctx,
+  iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx),
+  context[1].lo, context[1].hi);
+   }
+}
+#else /* CONFIG_INTEL_IOMMU_SVM */
+static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused,
+  struct intel_iommu *iommu, int bus, int ctx,
+  struct context_entry *context, bool new_ext)
+{
+   return;
+}
+#endif /* CONFIG_INTEL_IOMMU_SVM */
+
 static void ctx_tbl_entry_show(struct seq_file *m, void *unused,
   struct intel_iommu *iommu, int bus, bool ext,
   bool new_ext)
@@ -69,6 +101,9 @@ static void ctx_tbl_entry_show(struct seq_file *m, void 
*unused,
seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n",
   ctx, iommu->segment, bus, PCI_SLOT(ctx),
   PCI_FUNC(ctx), context[0].lo, context[0].hi);
+
+   ext_ctx_tbl_entry_show(m, unused, iommu, bus, ctx,
+  context, new_ext);
}
}
 out:
-- 
2.7.4

___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu