mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu
@ 2009-06-09 13:57 Joerg Roedel
  2009-06-09 13:57 ` [PATCH 1/4] amd_iommu: fix lock imbalance Joerg Roedel
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Joerg Roedel @ 2009-06-09 13:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: iommu, linux-kernel

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] amd_iommu: fix lock imbalance
  2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
@ 2009-06-09 13:57 ` Joerg Roedel
  2009-06-09 13:57 ` [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling Joerg Roedel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2009-06-09 13:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: iommu, linux-kernel, Jiri Slaby, Joerg Roedel

From: Jiri Slaby <jirislaby@gmail.com>

In alloc_coherent there is an omitted unlock on the path where mapping
fails. Add the unlock.

[ Impact: fix lock imbalance in alloc_coherent ]

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/amd_iommu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index d689883..9f89bb6 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -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);
 
-- 
1.6.3.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
  2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
  2009-06-09 13:57 ` [PATCH 1/4] amd_iommu: fix lock imbalance Joerg Roedel
@ 2009-06-09 13:57 ` Joerg Roedel
  2009-06-09 14:15   ` Chris Wright
  2009-06-09 13:57 ` [PATCH 3/4] amd-iommu: detach device explicitly before attaching it to a new domain Joerg Roedel
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2009-06-09 13:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel

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 <joerg.roedel@amd.com>
---
 arch/x86/kernel/amd_iommu.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 8510e90..8187260 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -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;
-- 
1.6.3.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/4] amd-iommu: detach device explicitly before attaching it to a new domain
  2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
  2009-06-09 13:57 ` [PATCH 1/4] amd_iommu: fix lock imbalance Joerg Roedel
  2009-06-09 13:57 ` [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling Joerg Roedel
@ 2009-06-09 13:57 ` Joerg Roedel
  2009-06-09 13:57 ` [PATCH 4/4] amd-iommu: remove unnecessary "AMD IOMMU: " prefix Joerg Roedel
  2009-06-09 14:21 ` [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Ingo Molnar
  4 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2009-06-09 13:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel, Chris Wright

This 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]

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/amd_iommu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 8187260..772e910 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -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);
 
-- 
1.6.3.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/4] amd-iommu: remove unnecessary "AMD IOMMU: " prefix
  2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
                   ` (2 preceding siblings ...)
  2009-06-09 13:57 ` [PATCH 3/4] amd-iommu: detach device explicitly before attaching it to a new domain Joerg Roedel
@ 2009-06-09 13:57 ` Joerg Roedel
  2009-06-09 14:21 ` [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Ingo Molnar
  4 siblings, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2009-06-09 13:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel

That prefix is already included in the DUMP_printk macro. So there is no
need to repeat it in the format string.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/amd_iommu.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 772e910..1c60554 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -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)
-- 
1.6.3.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
  2009-06-09 13:57 ` [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling Joerg Roedel
@ 2009-06-09 14:15   ` Chris Wright
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Wright @ 2009-06-09 14:15 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Ingo Molnar, iommu, linux-kernel

* Joerg Roedel (joerg.roedel@amd.com) 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 <joerg.roedel@amd.com>

Yep, makes good sense, will get picked up from get_device_resources.

Acked-by: Chris Wright <chrisw@sous-sol.org>

thanks,
-chris

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu
  2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
                   ` (3 preceding siblings ...)
  2009-06-09 13:57 ` [PATCH 4/4] amd-iommu: remove unnecessary "AMD IOMMU: " prefix Joerg Roedel
@ 2009-06-09 14:21 ` Ingo Molnar
  4 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2009-06-09 14:21 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel


* Joerg Roedel <joerg.roedel@amd.com> wrote:

> 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.

Pulled into tip:core/iommu, thanks a lot Joerg!

	Ingo

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-06-09 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-09 13:57 [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Joerg Roedel
2009-06-09 13:57 ` [PATCH 1/4] amd_iommu: fix lock imbalance Joerg Roedel
2009-06-09 13:57 ` [PATCH 2/4] amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling Joerg Roedel
2009-06-09 14:15   ` Chris Wright
2009-06-09 13:57 ` [PATCH 3/4] amd-iommu: detach device explicitly before attaching it to a new domain Joerg Roedel
2009-06-09 13:57 ` [PATCH 4/4] amd-iommu: remove unnecessary "AMD IOMMU: " prefix Joerg Roedel
2009-06-09 14:21 ` [git pull][PATCH 0/4] amd-iommu fixes for tip/core/iommu Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®