LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/7] amd-iommu debug patches for 2.6.31
@ 2009-05-22 12:12 Joerg Roedel
2009-05-22 12:12 ` [PATCH 1/7] amd-iommu: add amd_iommu_dump parameter Joerg Roedel
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel
This patchset contains updates to the debugging code in the AMD IOMMU
driver for Linux. It introduces two additional features:
* A new command line parameter to let the driver dump the parsed
contents of the IVRS ACPI table to dmesg. This is a debug feature to
make it easier to find the bug for problems reported to me
* A new Kconfig entry to enable IOMMU stress testing code. I made this
Kconfig entry generic because other IOMMU implementations may pick
this up as well.
Please review.
diffstat:
arch/x86/Kconfig.debug | 8 +++
arch/x86/include/asm/amd_iommu_types.h | 6 ++
arch/x86/kernel/amd_iommu.c | 10 ++-
arch/x86/kernel/amd_iommu_init.c | 109 ++++++++++++++++++++++++++++++++
4 files changed, 129 insertions(+), 4 deletions(-)
shortlog:
Joerg Roedel (7):
amd-iommu: add amd_iommu_dump parameter
amd-iommu: add dump for iommus described in ivrs table
amd-iommu: print ivhd information to dmesg when requested
amd-iommu: print ivmd information to dmesg when requested
amd-iommu: move protection domain printk to dump code
x86/iommu: add IOMMU_STRESS Kconfig entry
amd-iommu: disable device isolation with CONFIG_IOMMU_STRESS
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/7] amd-iommu: add amd_iommu_dump parameter
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 2/7] amd-iommu: add dump for iommus described in ivrs table Joerg Roedel
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: add parameter to dump the ACPI table for AMD IOMMU ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/include/asm/amd_iommu_types.h | 6 ++++++
arch/x86/kernel/amd_iommu_init.c | 10 ++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 95c8cd9..89dfb37 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -194,6 +194,12 @@
#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */
#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops
domain for an IOMMU */
+extern bool amd_iommu_dump;
+#define DUMP_printk(format, arg...) \
+ do { \
+ if (amd_iommu_dump) \
+ printk(KERN_INFO "AMD IOMMU: " format, ## arg); \
+ } while(0);
/*
* This structure contains generic data for IOMMU protection domains
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 8c0be09..57fb7a7 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -115,6 +115,8 @@ struct ivmd_header {
u64 range_length;
} __attribute__((packed));
+bool amd_iommu_dump;
+
static int __initdata amd_iommu_detected;
u16 amd_iommu_last_bdf; /* largest PCI device id we have
@@ -1211,6 +1213,13 @@ void __init amd_iommu_detect(void)
*
****************************************************************************/
+static int __init parse_amd_iommu_dump(char *str)
+{
+ amd_iommu_dump = true;
+
+ return 1;
+}
+
static int __init parse_amd_iommu_options(char *str)
{
for (; *str; ++str) {
@@ -1235,5 +1244,6 @@ static int __init parse_amd_iommu_size_options(char *str)
return 1;
}
+__setup("amd_iommu_dump", parse_amd_iommu_dump);
__setup("amd_iommu=", parse_amd_iommu_options);
__setup("amd_iommu_size=", parse_amd_iommu_size_options);
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] amd-iommu: add dump for iommus described in ivrs table
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
2009-05-22 12:12 ` [PATCH 1/7] amd-iommu: add amd_iommu_dump parameter Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 3/7] amd-iommu: print ivhd information to dmesg when requested Joerg Roedel
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: get information about iommus described in the ivrs acpi table ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 57fb7a7..2816590 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -748,6 +748,15 @@ static int __init init_iommu_all(struct acpi_table_header *table)
h = (struct ivhd_header *)p;
switch (*p) {
case ACPI_IVHD_TYPE:
+
+ DUMP_printk("IOMMU: device: %02x:%02x.%01x cap: %04x "
+ "seg: %d flags: %01x info %04x\n",
+ PCI_BUS(h->devid), PCI_SLOT(h->devid),
+ PCI_FUNC(h->devid), h->cap_ptr,
+ h->pci_seg, h->flags, h->info);
+ DUMP_printk(" mmio-addr: %016llx\n",
+ h->mmio_phys);
+
iommu = kzalloc(sizeof(struct amd_iommu), GFP_KERNEL);
if (iommu == NULL)
return -ENOMEM;
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] amd-iommu: print ivhd information to dmesg when requested
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
2009-05-22 12:12 ` [PATCH 1/7] amd-iommu: add amd_iommu_dump parameter Joerg Roedel
2009-05-22 12:12 ` [PATCH 2/7] amd-iommu: add dump for iommus described in ivrs table Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 4/7] amd-iommu: print ivmd " Joerg Roedel
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: be able to show in dmesg whats in the acpi ivhd fields ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 73 ++++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 2816590..fe3e645 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -598,32 +598,83 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
p += sizeof(struct ivhd_header);
end += h->length;
+
while (p < end) {
e = (struct ivhd_entry *)p;
switch (e->type) {
case IVHD_DEV_ALL:
+
+ DUMP_printk(" DEV_ALL\t\t\t first devid: %02x:%02x.%x"
+ " last device %02x:%02x.%x flags: %02x\n",
+ PCI_BUS(iommu->first_device),
+ PCI_SLOT(iommu->first_device),
+ PCI_FUNC(iommu->first_device),
+ PCI_BUS(iommu->last_device),
+ PCI_SLOT(iommu->last_device),
+ PCI_FUNC(iommu->last_device),
+ e->flags);
+
for (dev_i = iommu->first_device;
dev_i <= iommu->last_device; ++dev_i)
set_dev_entry_from_acpi(iommu, dev_i,
e->flags, 0);
break;
case IVHD_DEV_SELECT:
+
+ DUMP_printk(" DEV_SELECT\t\t\t devid: %02x:%02x.%x "
+ "flags: %02x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags);
+
devid = e->devid;
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
break;
case IVHD_DEV_SELECT_RANGE_START:
+
+ DUMP_printk(" DEV_SELECT_RANGE_START\t "
+ "devid: %02x:%02x.%x flags: %02x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags);
+
devid_start = e->devid;
flags = e->flags;
ext_flags = 0;
alias = false;
break;
case IVHD_DEV_ALIAS:
+
+ DUMP_printk(" DEV_ALIAS\t\t\t devid: %02x:%02x.%x "
+ "flags: %02x devid_to: %02x:%02x.%x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags,
+ PCI_BUS(e->ext >> 8),
+ PCI_SLOT(e->ext >> 8),
+ PCI_FUNC(e->ext >> 8));
+
devid = e->devid;
devid_to = e->ext >> 8;
set_dev_entry_from_acpi(iommu, devid, e->flags, 0);
amd_iommu_alias_table[devid] = devid_to;
break;
case IVHD_DEV_ALIAS_RANGE:
+
+ DUMP_printk(" DEV_ALIAS_RANGE\t\t "
+ "devid: %02x:%02x.%x flags: %02x "
+ "devid_to: %02x:%02x.%x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags,
+ PCI_BUS(e->ext >> 8),
+ PCI_SLOT(e->ext >> 8),
+ PCI_FUNC(e->ext >> 8));
+
devid_start = e->devid;
flags = e->flags;
devid_to = e->ext >> 8;
@@ -631,17 +682,39 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
alias = true;
break;
case IVHD_DEV_EXT_SELECT:
+
+ DUMP_printk(" DEV_EXT_SELECT\t\t devid: %02x:%02x.%x "
+ "flags: %02x ext: %08x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags, e->ext);
+
devid = e->devid;
set_dev_entry_from_acpi(iommu, devid, e->flags,
e->ext);
break;
case IVHD_DEV_EXT_SELECT_RANGE:
+
+ DUMP_printk(" DEV_EXT_SELECT_RANGE\t devid: "
+ "%02x:%02x.%x flags: %02x ext: %08x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid),
+ e->flags, e->ext);
+
devid_start = e->devid;
flags = e->flags;
ext_flags = e->ext;
alias = false;
break;
case IVHD_DEV_RANGE_END:
+
+ DUMP_printk(" DEV_RANGE_END\t\t devid: %02x:%02x.%x\n",
+ PCI_BUS(e->devid),
+ PCI_SLOT(e->devid),
+ PCI_FUNC(e->devid));
+
devid = e->devid;
for (dev_i = devid_start; dev_i <= devid; ++dev_i) {
if (alias)
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] amd-iommu: print ivmd information to dmesg when requested
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
` (2 preceding siblings ...)
2009-05-22 12:12 ` [PATCH 3/7] amd-iommu: print ivhd information to dmesg when requested Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 5/7] amd-iommu: move protection domain printk to dump code Joerg Roedel
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: be able to show in dmesg whats in the acpi ivmd fields ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index fe3e645..b90a78c 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -983,6 +983,7 @@ static int __init init_exclusion_range(struct ivmd_header *m)
static int __init init_unity_map_range(struct ivmd_header *m)
{
struct unity_map_entry *e = 0;
+ char *s;
e = kzalloc(sizeof(*e), GFP_KERNEL);
if (e == NULL)
@@ -991,13 +992,16 @@ static int __init init_unity_map_range(struct ivmd_header *m)
switch (m->type) {
default:
case ACPI_IVMD_TYPE:
+ s = "IVMD_TYPEi\t\t\t";
e->devid_start = e->devid_end = m->devid;
break;
case ACPI_IVMD_TYPE_ALL:
+ s = "IVMD_TYPE_ALL\t\t";
e->devid_start = 0;
e->devid_end = amd_iommu_last_bdf;
break;
case ACPI_IVMD_TYPE_RANGE:
+ s = "IVMD_TYPE_RANGE\t\t";
e->devid_start = m->devid;
e->devid_end = m->aux;
break;
@@ -1006,6 +1010,13 @@ static int __init init_unity_map_range(struct ivmd_header *m)
e->address_end = e->address_start + PAGE_ALIGN(m->range_length);
e->prot = m->flags >> 1;
+ DUMP_printk("%s devid_start: %02x:%02x.%x devid_end: %02x:%02x.%x"
+ " range_start: %016llx range_end: %016llx flags: %x\n", s,
+ PCI_BUS(e->devid_start), PCI_SLOT(e->devid_start),
+ PCI_FUNC(e->devid_start), PCI_BUS(e->devid_end),
+ PCI_SLOT(e->devid_end), PCI_FUNC(e->devid_end),
+ e->address_start, e->address_end, m->flags);
+
list_add_tail(&e->list, &amd_iommu_unity_map);
return 0;
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] amd-iommu: move protection domain printk to dump code
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
` (3 preceding siblings ...)
2009-05-22 12:12 ` [PATCH 4/7] amd-iommu: print ivmd " Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 6/7] x86/iommu: add IOMMU_STRESS Kconfig entry Joerg Roedel
2009-05-22 12:12 ` [PATCH 7/7] amd-iommu: disable device isolation with CONFIG_IOMMU_STRESS Joerg Roedel
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: only printk protection-domain relations if requested ]
This information is only helpful for debugging. Don't print it anymore
unless explicitly requested.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index a97db99..3356599 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1009,8 +1009,9 @@ static int device_change_notifier(struct notifier_block *nb,
if (!dma_domain)
dma_domain = iommu->default_dom;
attach_device(iommu, &dma_domain->domain, devid);
- printk(KERN_INFO "AMD IOMMU: Using protection domain %d for "
- "device %s\n", dma_domain->domain.id, dev_name(dev));
+ DUMP_printk(KERN_INFO "AMD IOMMU: Using protection domain "
+ "%d for device %s\n",
+ dma_domain->domain.id, dev_name(dev));
break;
case BUS_NOTIFY_UNBIND_DRIVER:
if (!domain)
@@ -1133,8 +1134,9 @@ static int get_device_resources(struct device *dev,
dma_dom = (*iommu)->default_dom;
*domain = &dma_dom->domain;
attach_device(*iommu, *domain, *bdf);
- printk(KERN_INFO "AMD IOMMU: Using protection domain %d for "
- "device %s\n", (*domain)->id, dev_name(dev));
+ DUMP_printk(KERN_INFO "AMD IOMMU: Using protection domain "
+ "%d for device %s\n",
+ (*domain)->id, dev_name(dev));
}
if (domain_for_device(_bdf) == NULL)
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] x86/iommu: add IOMMU_STRESS Kconfig entry
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
` (4 preceding siblings ...)
2009-05-22 12:12 ` [PATCH 5/7] amd-iommu: move protection domain printk to dump code Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
2009-05-22 12:12 ` [PATCH 7/7] amd-iommu: disable device isolation with CONFIG_IOMMU_STRESS Joerg Roedel
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel, David Woodhouse, FUJITA Tomonori
[ impact: add a Kconfig option to enable stress-test code im iommu drivers ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
arch/x86/Kconfig.debug | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 5865712..33fac6b 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -159,6 +159,14 @@ config IOMMU_DEBUG
options. See Documentation/x86_64/boot-options.txt for more
details.
+config IOMMU_STRESS
+ bool "Enable IOMMU stress-test mode"
+ ---help---
+ This option disables various optimizations in IOMMU related
+ code to do real stress testing of the IOMMU code. This option
+ will cause a performance drop and should only be enabled for
+ testing.
+
config IOMMU_LEAK
bool "IOMMU leak tracing"
depends on IOMMU_DEBUG && DMA_API_DEBUG
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] amd-iommu: disable device isolation with CONFIG_IOMMU_STRESS
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
` (5 preceding siblings ...)
2009-05-22 12:12 ` [PATCH 6/7] x86/iommu: add IOMMU_STRESS Kconfig entry Joerg Roedel
@ 2009-05-22 12:12 ` Joerg Roedel
6 siblings, 0 replies; 8+ messages in thread
From: Joerg Roedel @ 2009-05-22 12:12 UTC (permalink / raw)
To: iommu, linux-kernel; +Cc: Joerg Roedel
[ impact: test for race conditions in dma_ops related code ]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index b90a78c..6694112 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -124,8 +124,14 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
we find in ACPI */
unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
+
+#ifdef CONFIG_IOMMU_STRESS
+bool amd_iommu_isolate = false;
+#else
bool amd_iommu_isolate = true; /* if true, device isolation is
enabled */
+#endif
+
bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
--
1.6.3.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-05-22 12:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-22 12:12 [PATCH 0/7] amd-iommu debug patches for 2.6.31 Joerg Roedel
2009-05-22 12:12 ` [PATCH 1/7] amd-iommu: add amd_iommu_dump parameter Joerg Roedel
2009-05-22 12:12 ` [PATCH 2/7] amd-iommu: add dump for iommus described in ivrs table Joerg Roedel
2009-05-22 12:12 ` [PATCH 3/7] amd-iommu: print ivhd information to dmesg when requested Joerg Roedel
2009-05-22 12:12 ` [PATCH 4/7] amd-iommu: print ivmd " Joerg Roedel
2009-05-22 12:12 ` [PATCH 5/7] amd-iommu: move protection domain printk to dump code Joerg Roedel
2009-05-22 12:12 ` [PATCH 6/7] x86/iommu: add IOMMU_STRESS Kconfig entry Joerg Roedel
2009-05-22 12:12 ` [PATCH 7/7] amd-iommu: disable device isolation with CONFIG_IOMMU_STRESS Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).