* [git pull] amd iommu fixes for 2.6.35-rc1
@ 2010-06-01 9:03 Joerg Roedel
2010-06-01 9:03 ` [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock Joerg Roedel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Joerg Roedel @ 2010-06-01 9:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel
Hi Ingo,
The following changes since commit 67a3e12b05e055c0415c556a315a3d3eb637e29e:
Linux 2.6.35-rc1 (2010-05-30 13:21:02 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.git amd-iommu/2.6.35
Joerg Roedel (3):
Merge commit 'v2.6.35-rc1' into amd-iommu/2.6.35
x86/amd-iommu: Fix crash when request_mem_region fails
x86/amd-iommu: Fall back to GART if initialization fails
Julia Lawall (1):
arch/x86/kernel: Add missing spin_unlock
arch/x86/kernel/amd_iommu.c | 16 +++++++++-------
arch/x86/kernel/amd_iommu_init.c | 20 +++++++++++++++++---
2 files changed, 26 insertions(+), 10 deletions(-)
These patches fix two bugs in the error-paths of the amd iommu
driver. One fix adds missing spin_unlocks and the other two patches fix
a problem with broken BIOSes where the driver can't allocate the mmio
region for the iommu hardware. Please pull.
Joerg
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
@ 2010-06-01 9:03 ` Joerg Roedel
2010-06-01 9:03 ` [PATCH 2/3] x86/amd-iommu: Fix crash when request_mem_region fails Joerg Roedel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2010-06-01 9:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Julia Lawall, stable, Joerg Roedel
From: Julia Lawall <julia@diku.dk>
Add a spin_unlock missing on the error path. The locks and unlocks are
balanced in other functions, so it seems that the same should be the case
here.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression E1;
@@
* spin_lock(E1,...);
<+... when != E1
if (...) {
... when != E1
* return ...;
}
...+>
* spin_unlock(E1,...);
// </smpl>
Cc: stable@kernel.org
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index fa5a147..8a9aaa8 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1487,6 +1487,7 @@ static int __attach_device(struct device *dev,
struct protection_domain *domain)
{
struct iommu_dev_data *dev_data, *alias_data;
+ int ret;
dev_data = get_dev_data(dev);
alias_data = get_dev_data(dev_data->alias);
@@ -1498,13 +1499,14 @@ static int __attach_device(struct device *dev,
spin_lock(&domain->lock);
/* Some sanity checks */
+ ret = -EBUSY;
if (alias_data->domain != NULL &&
alias_data->domain != domain)
- return -EBUSY;
+ goto out_unlock;
if (dev_data->domain != NULL &&
dev_data->domain != domain)
- return -EBUSY;
+ goto out_unlock;
/* Do real assignment */
if (dev_data->alias != dev) {
@@ -1520,10 +1522,14 @@ static int __attach_device(struct device *dev,
atomic_inc(&dev_data->bind);
+ ret = 0;
+
+out_unlock:
+
/* ready */
spin_unlock(&domain->lock);
- return 0;
+ return ret;
}
/*
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] x86/amd-iommu: Fix crash when request_mem_region fails
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
2010-06-01 9:03 ` [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock Joerg Roedel
@ 2010-06-01 9:03 ` Joerg Roedel
2010-06-01 9:03 ` [PATCH 3/3] x86/amd-iommu: Fall back to GART if initialization fails Joerg Roedel
2010-06-01 9:45 ` [git pull] amd iommu fixes for 2.6.35-rc1 Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2010-06-01 9:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel, stable
When request_mem_region fails the error path tries to
disable the IOMMUs. This accesses the mmio-region which was
not allocated leading to a kernel crash. This patch fixes
the issue.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 3bacb4d..1405346 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -287,8 +287,12 @@ static u8 * __init iommu_map_mmio_space(u64 address)
{
u8 *ret;
- if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu"))
+ if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {
+ pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",
+ address);
+ pr_err("AMD-Vi: This is a BIOS bug. Please contact your hardware vendor\n");
return NULL;
+ }
ret = ioremap_nocache(address, MMIO_REGION_LENGTH);
if (ret != NULL)
@@ -1314,7 +1318,7 @@ static int __init amd_iommu_init(void)
ret = amd_iommu_init_dma_ops();
if (ret)
- goto free;
+ goto free_disable;
amd_iommu_init_api();
@@ -1332,9 +1336,10 @@ static int __init amd_iommu_init(void)
out:
return ret;
-free:
+free_disable:
disable_iommus();
+free:
amd_iommu_uninit_devices();
free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] x86/amd-iommu: Fall back to GART if initialization fails
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
2010-06-01 9:03 ` [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock Joerg Roedel
2010-06-01 9:03 ` [PATCH 2/3] x86/amd-iommu: Fix crash when request_mem_region fails Joerg Roedel
@ 2010-06-01 9:03 ` Joerg Roedel
2010-06-01 9:45 ` [git pull] amd iommu fixes for 2.6.35-rc1 Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2010-06-01 9:03 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel, stable
This patch implements a fallback to the GART IOMMU if this
is possible and the AMD IOMMU initialization failed.
Otherwise the fallback would be nommu which is very
problematic on machines with more than 4GB of memory or
swiotlb which hurts io-performance.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 4 ----
arch/x86/kernel/amd_iommu_init.c | 9 +++++++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 8a9aaa8..0d20286 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2330,10 +2330,6 @@ int __init amd_iommu_init_dma_ops(void)
iommu_detected = 1;
swiotlb = 0;
-#ifdef CONFIG_GART_IOMMU
- gart_iommu_aperture_disabled = 1;
- gart_iommu_aperture = 0;
-#endif
/* Make the driver finally visible to the drivers */
dma_ops = &amd_iommu_dma_ops;
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 1405346..3cc63e2 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -1358,6 +1358,15 @@ free:
free_unity_maps();
+#ifdef CONFIG_GART_IOMMU
+ /*
+ * We failed to initialize the AMD IOMMU - try fallback to GART
+ * if possible.
+ */
+ gart_iommu_init();
+
+#endif
+
goto out;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [git pull] amd iommu fixes for 2.6.35-rc1
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
` (2 preceding siblings ...)
2010-06-01 9:03 ` [PATCH 3/3] x86/amd-iommu: Fall back to GART if initialization fails Joerg Roedel
@ 2010-06-01 9:45 ` Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2010-06-01 9:45 UTC (permalink / raw)
To: Joerg Roedel
Cc: iommu, linux-kernel, FUJITA Tomonori, Thomas Gleixner,
H. Peter Anvin
* Joerg Roedel <joerg.roedel@amd.com> wrote:
> Hi Ingo,
>
> The following changes since commit 67a3e12b05e055c0415c556a315a3d3eb637e29e:
>
> Linux 2.6.35-rc1 (2010-05-30 13:21:02 -0700)
>
> are available in the git repository at:
> git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.git amd-iommu/2.6.35
>
> Joerg Roedel (3):
> Merge commit 'v2.6.35-rc1' into amd-iommu/2.6.35
> x86/amd-iommu: Fix crash when request_mem_region fails
> x86/amd-iommu: Fall back to GART if initialization fails
>
> Julia Lawall (1):
> arch/x86/kernel: Add missing spin_unlock
>
> arch/x86/kernel/amd_iommu.c | 16 +++++++++-------
> arch/x86/kernel/amd_iommu_init.c | 20 +++++++++++++++++---
> 2 files changed, 26 insertions(+), 10 deletions(-)
>
> These patches fix two bugs in the error-paths of the amd iommu driver. One
> fix adds missing spin_unlocks and the other two patches fix a problem with
> broken BIOSes where the driver can't allocate the mmio region for the iommu
> hardware. Please pull.
Pulled, thanks Joerg!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-01 9:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01 9:03 [git pull] amd iommu fixes for 2.6.35-rc1 Joerg Roedel
2010-06-01 9:03 ` [PATCH 1/3] arch/x86/kernel: Add missing spin_unlock Joerg Roedel
2010-06-01 9:03 ` [PATCH 2/3] x86/amd-iommu: Fix crash when request_mem_region fails Joerg Roedel
2010-06-01 9:03 ` [PATCH 3/3] x86/amd-iommu: Fall back to GART if initialization fails Joerg Roedel
2010-06-01 9:45 ` [git pull] amd iommu fixes for 2.6.35-rc1 Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox