>From 62d026842357ffdee3397fd5d9f38b68bebc3f0b Mon Sep 17 00:00:00 2001 From: Alexander Gordeev Date: Wed, 9 May 2012 07:48:53 -0400 Subject: [PATCH 3/3] x86: intremap: Dump IRTEs to /sys/kernel/intremap Signed-off-by: Alexander Gordeev --- drivers/iommu/intr_remapping.c | 26 ++++++++++++++++++++++++++ kernel/ksysfs.c | 29 +++++++++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intr_remapping.c b/drivers/iommu/intr_remapping.c index adb0818..541dc33 100644 --- a/drivers/iommu/intr_remapping.c +++ b/drivers/iommu/intr_remapping.c @@ -832,3 +832,29 @@ error: return -1; } +int sprintf_IRTE(char *p, int irq, const struct irte *irte) +{ + char *buf = p; + + p += sprintf(p, "%4d: %1d %1d %1d %1d %1d %03X %03X %04X.%04X %04X %1d %1d\n", irq, irte->present, irte->fpd, irte->dst_mode, irte->redir_hint, irte->trigger_mode, irte->dlvry_mode, irte->vector, (irte->dest_id >> 16) & 0xFFFF, irte->dest_id & 0xFFFF, irte->sid, irte->sq, irte->svt); + + return p - buf; +} + +int sprintf_IRTEs(char *p) +{ + int irq; + struct irte irte; + char *buf = p; + + p += sprintf(p, "IRQ#: P FPD DM RH TM DLM VEC --Dest-ID -SID SQ SVT\n"); + + for_each_active_irq(irq) { + if (get_irte(irq, &irte)) + continue; + p += sprintf_IRTE(p, irq, &irte); + } + + return p - buf; +} + diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 85df7bb..be4e035 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -142,7 +142,6 @@ static ssize_t fscaps_show(struct kobject *kobj, KERNEL_ATTR_RO(fscaps); #ifdef CONFIG_X86_IO_APIC - extern int sprintf_IO_APICs(char *p); static ssize_t ioapic_show(struct kobject *kobj, @@ -155,18 +154,25 @@ static ssize_t ioapic_store(struct kobject *kobj, const char *buf, size_t count) { return -EINVAL; -/* - unsigned long cnt; - int ret; +} +KERNEL_ATTR_RW(ioapic); +#endif - if (strict_strtoul(buf, 0, &cnt)) - return -EINVAL; +#ifdef CONFIG_IRQ_REMAP +extern int sprintf_IRTEs(char *p); - ret = crash_shrink_memory(cnt); - return ret < 0 ? ret : count; -*/ +static ssize_t intremap_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf_IRTEs(buf); } -KERNEL_ATTR_RW(ioapic); +static ssize_t intremap_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + return -EINVAL; +} +KERNEL_ATTR_RW(intremap); #endif /* @@ -213,6 +219,9 @@ static struct attribute * kernel_attrs[] = { #ifdef CONFIG_X86_IO_APIC &ioapic_attr.attr, #endif +#ifdef CONFIG_IRQ_REMAP + &intremap_attr.attr, +#endif NULL }; -- 1.7.6.5