[33/74] iommu/amd: Make sure dma_ops are set for hotplug devices

2013-04-07 Thread Ben Hutchings
3.2.43-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Joerg Roedel 

commit c2a2876e863356b092967ea62bebdb4dd663af80 upstream.

There is a bug introduced with commit 27c2127 that causes
devices which are hot unplugged and then hot-replugged to
not have per-device dma_ops set. This causes these devices
to not function correctly. Fixed with this patch.

Reported-by: Andreas Degert 
Signed-off-by: Joerg Roedel 
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings 
---
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1874,16 +1874,16 @@ static int device_change_notifier(struct
 
/* allocate a protection domain if a device is added */
dma_domain = find_protection_domain(devid);
-   if (dma_domain)
-   goto out;
-   dma_domain = dma_ops_domain_alloc();
-   if (!dma_domain)
-   goto out;
-   dma_domain->target_dev = devid;
+   if (!dma_domain) {
+   dma_domain = dma_ops_domain_alloc();
+   if (!dma_domain)
+   goto out;
+   dma_domain->target_dev = devid;
 
-   spin_lock_irqsave(_pd_list_lock, flags);
-   list_add_tail(_domain->list, _pd_list);
-   spin_unlock_irqrestore(_pd_list_lock, flags);
+   spin_lock_irqsave(_pd_list_lock, flags);
+   list_add_tail(_domain->list, _pd_list);
+   spin_unlock_irqrestore(_pd_list_lock, flags);
+   }
 
dev->archdata.dma_ops = _iommu_dma_ops;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[33/74] iommu/amd: Make sure dma_ops are set for hotplug devices

2013-04-07 Thread Ben Hutchings
3.2.43-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Joerg Roedel j...@8bytes.org

commit c2a2876e863356b092967ea62bebdb4dd663af80 upstream.

There is a bug introduced with commit 27c2127 that causes
devices which are hot unplugged and then hot-replugged to
not have per-device dma_ops set. This causes these devices
to not function correctly. Fixed with this patch.

Reported-by: Andreas Degert andreas.deg...@googlemail.com
Signed-off-by: Joerg Roedel j...@8bytes.org
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings b...@decadent.org.uk
---
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1874,16 +1874,16 @@ static int device_change_notifier(struct
 
/* allocate a protection domain if a device is added */
dma_domain = find_protection_domain(devid);
-   if (dma_domain)
-   goto out;
-   dma_domain = dma_ops_domain_alloc();
-   if (!dma_domain)
-   goto out;
-   dma_domain-target_dev = devid;
+   if (!dma_domain) {
+   dma_domain = dma_ops_domain_alloc();
+   if (!dma_domain)
+   goto out;
+   dma_domain-target_dev = devid;
 
-   spin_lock_irqsave(iommu_pd_list_lock, flags);
-   list_add_tail(dma_domain-list, iommu_pd_list);
-   spin_unlock_irqrestore(iommu_pd_list_lock, flags);
+   spin_lock_irqsave(iommu_pd_list_lock, flags);
+   list_add_tail(dma_domain-list, iommu_pd_list);
+   spin_unlock_irqrestore(iommu_pd_list_lock, flags);
+   }
 
dev-archdata.dma_ops = amd_iommu_dma_ops;
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/