Skip to contentSkip to conversation

iommu/amd: Clean up patches

PATCH Applied Baoquan He 2 participants 10 messages Sep 15, 2016 – Sep 20, 2016 IOMMU

lore
Share & tools
lore

Baoquan He

author
#0 lore raw

cover iommu/amd: Clean up patches

These were found out when I tried to fix the kdump failure on system with AMD iommu. Pack them into this patchset since they are not related to the kdump issue and each other.

Baoquan He (4):
iommu/amd: clean up the cmpxchg64 invocation
iommu/amd: Use standard bitmap operation to set bitmap iommu/amd: Free domain id when free a domain of struct dma_ops_domain iommu/amd: No need to wait iommu completion if no dte irq entry change

 drivers/iommu/amd_iommu.c      | 12 ++++++++----
 drivers/iommu/amd_iommu_init.c |  3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
2.5.5
author
#1 lore raw

PATCH 1/4 iommu/amd: clean up the cmpxchg64 invocation

Change it as it's designed for and keep it consistent with other places.

---
 drivers/iommu/amd_iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/amd_iommu.c +2 -1
index 96de97a..160fc6a 100644
@@ -1274,7 +1274,8 @@ static u64 *alloc_pte(struct protection_domain *domain,
 
 			__npte = PM_LEVEL_PDE(level, virt_to_phys(page));
 
-			if (cmpxchg64(pte, __pte, __npte)) {
+			/* pte could have been changed somewhere. */
+			if (cmpxchg64(pte, __pte, __npte) != __pte) {
 				free_page((unsigned long)page);
 				continue;
 			}
Signature · 1 line
2.5.5
author
#2 lore raw

PATCH 2/4 iommu/amd: Use standard bitmap operation to set bitmap

In reply to Baoquan He

It will be more readable and safer than the old setting.

---
 drivers/iommu/amd_iommu_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/amd_iommu_init.c +2 -1
index 59741ea..3e810c6 100644
@@ -20,6 +20,7 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
 #include <linux/list.h>
+#include <linux/bitmap.h>
 #include <linux/slab.h>
 #include <linux/syscore_ops.h>
 #include <linux/interrupt.h>
@@ -2136,7 +2137,7 @@ static int __init early_amd_iommu_init(void)
 	 * never allocate domain 0 because its used as the non-allocated and
 	 * error value placeholder
 	 */
-	amd_iommu_pd_alloc_bitmap[0] = 1;
+	__set_bit(0, amd_iommu_pd_alloc_bitmap);
 
 	spin_lock_init(&amd_iommu_pd_lock);
 
Signature · 1 line
2.5.5
author
#3 lore raw

PATCH 3/4 iommu/amd: Free domain id when free a domain of struct dma_ops_domain

In reply to Baoquan He

The current code missed freeing domain id when free a domain of struct dma_ops_domain.

---
 drivers/iommu/amd_iommu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/amd_iommu.c +3 -0
index 160fc6a..a9f78c2 100644
@@ -1655,6 +1655,9 @@ static void dma_ops_domain_free(struct dma_ops_domain *dom)
 
 	free_pagetable(&dom->domain);
 
+	if (dom->domain.id)
+		domain_id_free(dom->domain.id);
+
 	kfree(dom);
 }
 
Signature · 1 line
2.5.5
author
#4 lore raw

PATCH 4/4 iommu/amd: No need to wait iommu completion if no dte irq entry change

In reply to Baoquan He

This is a clean up. In get_irq_table() only if DTE entry is changed iommu_completion_wait() need be called. Otherwise no need to do it.

---
 drivers/iommu/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/amd_iommu.c +3 -3
index a9f78c2..461c2fe 100644
@@ -3581,7 +3581,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 
 	table = irq_lookup_table[devid];
 	if (table)
-		goto out;
+		goto out_unlock;
 
 	alias = amd_iommu_alias_table[devid];
 	table = irq_lookup_table[alias];
@@ -3595,7 +3595,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	/* Nothing there yet, allocate new irq remapping table */
 	table = kzalloc(sizeof(*table), GFP_ATOMIC);
 	if (!table)
-		goto out;
+		goto out_unlock;
 
 	/* Initialize table spin-lock */
 	spin_lock_init(&table->lock);
@@ -3608,7 +3608,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	if (!table->table) {
 		kfree(table);
 		table = NULL;
-		goto out;
+		goto out_unlock;
 	}
 
 	memset(table->table, 0, MAX_IRQS_PER_TABLE * sizeof(u32));
Signature · 1 line
2.5.5
author
#5 lore raw

PATCH RESEND 4/4 iommu/amd: No need to wait iommu completion if no dte irq entry change

This is a clean up. In get_irq_table() only if DTE entry is changed iommu_completion_wait() need be called. Otherwise no need to do it.

---
 drivers/iommu/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/amd_iommu.c +3 -3
index b5b117b..a2479d0 100644
@@ -3634,7 +3634,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 
 	table = irq_lookup_table[devid];
 	if (table)
-		goto out;
+		goto out_unlock;
 
 	alias = amd_iommu_alias_table[devid];
 	table = irq_lookup_table[alias];
@@ -3648,7 +3648,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	/* Nothing there yet, allocate new irq remapping table */
 	table = kzalloc(sizeof(*table), GFP_ATOMIC);
 	if (!table)
-		goto out;
+		goto out_unlock;
 
 	/* Initialize table spin-lock */
 	spin_lock_init(&table->lock);
@@ -3661,7 +3661,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	if (!table->table) {
 		kfree(table);
 		table = NULL;
-		goto out;
+		goto out_unlock;
 	}
 
 	if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir))
Signature · 1 line
2.5.5
maintainer Applied
#6 lore raw

Re: [PATCH RESEND 4/4] iommu/amd: No need to wait iommu completion if no dte irq entry change

Quoted 7 lines · Baoquan He

This is a clean up. In get_irq_table() only if DTE entry is changed iommu_completion_wait() need be called. Otherwise no need to do it.

---
 drivers/iommu/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

author
#7 lore raw

Re: [PATCH RESEND 4/4] iommu/amd: No need to wait iommu completion if no dte irq entry change

Quoted 10 lines · Joerg Roedel
Quoted 7 lines · Baoquan He

This is a clean up. In get_irq_table() only if DTE entry is changed iommu_completion_wait() need be called. Otherwise no need to do it.

---
 drivers/iommu/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Thanks!

maintainer
#8 lore raw
In reply to Baoquan He

Hi Baoquan,

Quoted 9 lines · Baoquan He

These were found out when I tried to fix the kdump failure on system with AMD iommu. Pack them into this patchset since they are not related to the kdump issue and each other.

Baoquan He (4):
iommu/amd: clean up the cmpxchg64 invocation
iommu/amd: Use standard bitmap operation to set bitmap iommu/amd: Free domain id when free a domain of struct dma_ops_domain iommu/amd: No need to wait iommu completion if no dte irq entry change

I applied patches 1-3, but patch 4 had some conflicts. Can you please rebase this patch to my x86/amd branch and resend?

Thanks,

Joerg

author
#9 lore raw
Quoted 7 lines · Joerg Roedel

Hi Baoquan,

Quoted 4 lines · Baoquan He

These were found out when I tried to fix the kdump failure on system with AMD iommu. Pack them into this patchset since they are not related to the kdump issue and each other.

Quoted 8 lines
Quoted 5 lines

Baoquan He (4):
iommu/amd: clean up the cmpxchg64 invocation
iommu/amd: Use standard bitmap operation to set bitmap iommu/amd: Free domain id when free a domain of struct dma_ops_domain iommu/amd: No need to wait iommu completion if no dte irq entry change

I applied patches 1-3, but patch 4 had some conflicts. Can you please rebase this patch to my x86/amd branch and resend?

Finished, please try the resent post.

Thanks
Baoquan