Re: [PATCH v3 7/8] iommu/amd: Add debugfs support to dump IRT Table

From: Vasant Hegde
Date: Thu Mar 13 2025 - 07:04:15 EST


Hi,


On 2/6/2025 11:30 AM, Dheeraj Kumar Srivastava wrote:
> In cases where we have an issue in the device interrupt path with IOMMU
> interrupt remapping enabled, dumping valid IRT table entries for the device
> is very useful and good input for debugging the issue.
>
> eg.
> To dump irte entries for a particular device
> #echo "c4:00.0" > /sys/kernel/debug/iommu/amd/devid
> #cat /sys/kernel/debug/iommu/amd/irqtbl | less
>
> or
>
> #echo "0000:c4:00.0" > /sys/kernel/debug/iommu/amd/devid
> #cat /sys/kernel/debug/iommu/amd/irqtbl | less
>
> Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@xxxxxxx>
> ---
> drivers/iommu/amd/debugfs.c | 89 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 89 insertions(+)
>
> diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c
> index 1377795814d1..0aff1d616108 100644
> --- a/drivers/iommu/amd/debugfs.c
> +++ b/drivers/iommu/amd/debugfs.c
> @@ -11,6 +11,7 @@
> #include <linux/pci.h>
>
> #include "amd_iommu.h"
> +#include "../irq_remapping.h"
>
> static struct dentry *amd_iommu_debugfs;
>
> @@ -250,6 +251,92 @@ static int iommu_devtbl_show(struct seq_file *m, void *unused)
> }
> DEFINE_SHOW_ATTRIBUTE(iommu_devtbl);
>
> +static void dump_128_irte(struct seq_file *m, struct irq_remap_table *table)
> +{
> + struct irte_ga *ptr, *irte;
> + int index;
> +
> + for (index = 0; index < MAX_IRQS_PER_TABLE; index++) {
> + ptr = (struct irte_ga *)table->table;
> + irte = &ptr[index];
> +
> + if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
> + !irte->lo.fields_vapic.valid)
> + continue;
> + else if (!irte->lo.fields_remap.valid)
> + continue;
> + seq_printf(m, "IRT[%04d] %016llx%016llx\n", index, irte->hi.val, irte->lo.val);

Can you please space between words so that its easy to read?

-Vasant