amd-iommu fixes for tip/core/iommu
Hi Ingo,
The following changes since commit 62a6f465f6572e1f28765c583c12753bb3e23715:
Ingo Molnar (1):
Merge branch 'dma-debug/2.6.31' of git://git.kernel.org/.../joro/linux-2.6-iommu into core/iommu
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.git amd-iommu/fixes
Jiri Slaby (1):
amd_iommu: fix lock imbalance
Joerg Roedel (4):
Merge commit 'tip/core/iommu' into amd-iommu/fixes
amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
amd-iommu: detach device explicitly before attaching it to a new domain
amd-iommu: remove unnecessary "AMD IOMMU: " prefix
arch/x86/kernel/amd_iommu.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-)
These patches fix issues with device assignment to KVM, a possible deadlock due to an unreleased lock and a minor printk style issue. Please pull.
Thanks,
Joerg
PATCH 1/4 amd_iommu: fix lock imbalance
From: Jiri Slaby <[email protected]>
In alloc_coherent there is an omitted unlock on the path where mapping fails. Add the unlock.
[ Impact: fix lock imbalance in alloc_coherent ]
--- arch/x86/kernel/amd_iommu.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/kernel/amd_iommu.c +3 -1
@@ -1541,8 +1541,10 @@ static void *alloc_coherent(struct device *dev, size_t size, *dma_addr =__map_single (dev, iommu, domain->priv, paddr, size,DMA_BIDIRECTIONAL , true, dma_mask); -if (*dma_addr == bad_dma_address) +if (*dma_addr == bad_dma_address) { +spin_unlock_irqrestore (&domain->lock, flags); goto out_free; + }iommu_completion_wait (iommu);
Signature · 1 line
1.6.3.1
PATCH 2/4 amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
In reply to Joerg RoedelHandling this event causes device assignment in KVM to fail because the device gets re-attached as soon as the pci-stub registers as the driver for the device.
--- arch/x86/kernel/amd_iommu.c | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
arch/x86/kernel/amd_iommu.c +0 -11
@@ -1145,17 +1145,6 @@ static int device_change_notifier(struct notifier_block *nb, "to a non-dma-ops domain\n", dev_name(dev));switch (action) { -case BUS_NOTIFY_BOUND_DRIVER : -if (domain) - goto out; - dma_domain =find_protection_domain (devid); -if (!dma_domain) - dma_domain = iommu->default_dom; -attach_device (iommu, &dma_domain->domain, devid); -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_UNBOUND_DRIVER :if (!domain) goto out;
Signature · 1 line
1.6.3.1
Re: [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
Quoted 5 lines · * Joerg Roedel ([email protected]) wrote:
Handling this event causes device assignment in KVM to fail because the device gets re-attached as soon as the pci-stub registers as the driver for the device.
Signed-off-by Joerg Roedel <[email protected]>
Yep, makes good sense, will get picked up from get_device_resources.
thanks,
-chris
PATCH 3/4 amd-iommu: detach device explicitly before attaching it to a new domain
In reply to Joerg RoedelThis fixes a bug with a device that could not be assigned to a KVM guest because it is still assigned to a dma_ops protection domain.
[chrisw: simply remove WARN_ON(), will always fire since dev->driver will be pci-sub]
--- arch/x86/kernel/amd_iommu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/amd_iommu.c +1 -1
@@ -2073,7 +2073,7 @@ static int amd_iommu_attach_device(struct iommu_domain *dom, old_domain =domain_for_device (devid);if (old_domain) -return -EBUSY ; +detach_device (old_domain, devid);attach_device (iommu, domain, devid);
Signature · 1 line
1.6.3.1
PATCH 4/4 amd-iommu: remove unnecessary "AMD IOMMU: " prefix
In reply to Joerg RoedelThat prefix is already included in the DUMP_printk macro. So there is no need to repeat it in the format string.
--- arch/x86/kernel/amd_iommu.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/amd_iommu.c +2 -3
@@ -1266,9 +1266,8 @@ static int get_device_resources(struct device *dev, dma_dom = (*iommu)->default_dom; *domain = &dma_dom->domain;attach_device (*iommu, *domain, *bdf); -DUMP_printk (KERN_INFO "AMD IOMMU: Using protection domain " -"%d for device %s\n" , - (*domain)->id,dev_name (dev)); +DUMP_printk ("Using protection domain %d for device %s\n" , + (*domain)->id,dev_name (dev)); }if (domain_for_device (_bdf) ==NULL )
Signature · 1 line
1.6.3.1
Quoted 19 lines · Joerg Roedel
Hi Ingo,
The following changes since commit
62a6f465f6572e1f28765c583c12753bb3e23715:
Ingo Molnar (1):Merge branch 'dma-debug/2.6.31' of git://git.kernel.org/.../joro/linux-2.6-iommu into core/iommuare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.gitamd-iommu/fixesJiri Slaby (1):
amd_iommu: fix lock imbalanceJoerg Roedel (4):
Merge commit 'tip/core/iommu' into amd-iommu/fixes
amd-iommu: removeBUS_NOTIFY_BOUND_DRIVERhandling
amd-iommu: detach device explicitly before attaching it to a new domain
amd-iommu: remove unnecessary "AMD IOMMU: " prefix
Quoted 6 lines
arch/x86/kernel/amd_iommu.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-)These patches fix issues with device assignment to KVM, a possible deadlock due to an unreleased lock and a minor printk style issue. Please pull.
Pulled into tip:core/iommu, thanks a lot Joerg!
Ingo