* [git pull] AMD IOMMU fixes for 3.0-rc2
@ 2011-06-07 10:06 Joerg Roedel
2011-06-07 10:06 ` [PATCH 1/3] x86/amd-iommu: Fix 3 possible endless loops Joerg Roedel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Joerg Roedel @ 2011-06-07 10:06 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel
Hi Ingo,
The following changes since commit 59c5f46fbe01a00eedf54a23789634438bb80603:
Linux 3.0-rc2 (2011-06-06 18:06:33 +0900)
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
Joerg Roedel (3):
x86/amd-iommu: Fix 3 possible endless loops
x86/amd-iommu: Use only per-device dma_ops
x86/amd-iommu: Fix boot crash with hidden PCI devices
arch/x86/kernel/amd_iommu.c | 48 +++++++++++++++++++++++++++++++++++--
arch/x86/kernel/amd_iommu_init.c | 8 +++---
2 files changed, 49 insertions(+), 7 deletions(-)
These patches fix serious issues which were discovered recently like a
boot-stall and a boot crash when a device has an alias which does not exist a
pci_dev. Please pull.
Joerg
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] x86/amd-iommu: Fix 3 possible endless loops
2011-06-07 10:06 [git pull] AMD IOMMU fixes for 3.0-rc2 Joerg Roedel
@ 2011-06-07 10:06 ` Joerg Roedel
2011-06-07 10:06 ` [PATCH 2/3] x86/amd-iommu: Use only per-device dma_ops Joerg Roedel
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2011-06-07 10:06 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel, stable
The driver contains several loops counting on an u16 value
where the exit-condition is checked against variables that
can have values up to 0xffff. In this case the loops will
never exit. This patch fixed 3 such loops.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu_init.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 9179c21..bfc8453 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -731,8 +731,8 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
{
u8 *p = (u8 *)h;
u8 *end = p, flags = 0;
- u16 dev_i, devid = 0, devid_start = 0, devid_to = 0;
- u32 ext_flags = 0;
+ u16 devid = 0, devid_start = 0, devid_to = 0;
+ u32 dev_i, ext_flags = 0;
bool alias = false;
struct ivhd_entry *e;
@@ -887,7 +887,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
/* Initializes the device->iommu mapping for the driver */
static int __init init_iommu_devices(struct amd_iommu *iommu)
{
- u16 i;
+ u32 i;
for (i = iommu->first_device; i <= iommu->last_device; ++i)
set_iommu_for_device(iommu, i);
@@ -1177,7 +1177,7 @@ static int __init init_memory_definitions(struct acpi_table_header *table)
*/
static void init_device_table(void)
{
- u16 devid;
+ u32 devid;
for (devid = 0; devid <= amd_iommu_last_bdf; ++devid) {
set_dev_entry_bit(devid, DEV_ENTRY_VALID);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] x86/amd-iommu: Use only per-device dma_ops
2011-06-07 10:06 [git pull] AMD IOMMU fixes for 3.0-rc2 Joerg Roedel
2011-06-07 10:06 ` [PATCH 1/3] x86/amd-iommu: Fix 3 possible endless loops Joerg Roedel
@ 2011-06-07 10:06 ` Joerg Roedel
2011-06-07 10:06 ` [PATCH 3/3] x86/amd-iommu: Fix boot crash with hidden PCI devices Joerg Roedel
2011-06-07 10:43 ` [git pull] AMD IOMMU fixes for 3.0-rc2 Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2011-06-07 10:06 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel, stable
Unfortunatly there are systems where the AMD IOMMU does not
cover all devices. This breaks with the current driver as it
initializes the global dma_ops variable. This patch limits
the AMD IOMMU to the devices listed in the IVRS table fixing
DMA for devices not covered by the IOMMU.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index cd8cbeb..b2c309b 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -30,6 +30,7 @@
#include <asm/proto.h>
#include <asm/iommu.h>
#include <asm/gart.h>
+#include <asm/dma.h>
#include <asm/amd_iommu_proto.h>
#include <asm/amd_iommu_types.h>
#include <asm/amd_iommu.h>
@@ -2383,6 +2384,23 @@ static struct dma_map_ops amd_iommu_dma_ops = {
.dma_supported = amd_iommu_dma_supported,
};
+static unsigned device_dma_ops_init(void)
+{
+ struct pci_dev *pdev = NULL;
+ unsigned unhandled = 0;
+
+ for_each_pci_dev(pdev) {
+ if (!check_device(&pdev->dev)) {
+ unhandled += 1;
+ continue;
+ }
+
+ pdev->dev.archdata.dma_ops = &amd_iommu_dma_ops;
+ }
+
+ return unhandled;
+}
+
/*
* The function which clues the AMD IOMMU driver into dma_ops.
*/
@@ -2395,7 +2413,7 @@ void __init amd_iommu_init_api(void)
int __init amd_iommu_init_dma_ops(void)
{
struct amd_iommu *iommu;
- int ret;
+ int ret, unhandled;
/*
* first allocate a default protection domain for every IOMMU we
@@ -2421,7 +2439,11 @@ int __init amd_iommu_init_dma_ops(void)
swiotlb = 0;
/* Make the driver finally visible to the drivers */
- dma_ops = &amd_iommu_dma_ops;
+ unhandled = device_dma_ops_init();
+ if (unhandled && max_pfn > MAX_DMA32_PFN) {
+ /* There are unhandled devices - initialize swiotlb for them */
+ swiotlb = 1;
+ }
amd_iommu_stats_init();
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] x86/amd-iommu: Fix boot crash with hidden PCI devices
2011-06-07 10:06 [git pull] AMD IOMMU fixes for 3.0-rc2 Joerg Roedel
2011-06-07 10:06 ` [PATCH 1/3] x86/amd-iommu: Fix 3 possible endless loops Joerg Roedel
2011-06-07 10:06 ` [PATCH 2/3] x86/amd-iommu: Use only per-device dma_ops Joerg Roedel
@ 2011-06-07 10:06 ` Joerg Roedel
2011-06-07 10:43 ` [git pull] AMD IOMMU fixes for 3.0-rc2 Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2011-06-07 10:06 UTC (permalink / raw)
To: Ingo Molnar; +Cc: iommu, linux-kernel, Joerg Roedel
Some PCIe cards ship with a PCI-PCIe bridge which is not
visible as a PCI device in Linux. But the device-id of the
bridge is present in the IOMMU tables which causes a boot
crash in the IOMMU driver.
This patch fixes by removing these cards from the IOMMU
handling. This is a pure -stable fix, a real fix to handle
this situation appriatly will follow for the next merge
window.
Cc: stable@kernel.org # > 2.6.32
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index b2c309b..7c3a95e 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -155,6 +155,10 @@ static int iommu_init_device(struct device *dev)
pdev = pci_get_bus_and_slot(PCI_BUS(alias), alias & 0xff);
if (pdev)
dev_data->alias = &pdev->dev;
+ else {
+ kfree(dev_data);
+ return -ENOTSUPP;
+ }
atomic_set(&dev_data->bind, 0);
@@ -164,6 +168,20 @@ static int iommu_init_device(struct device *dev)
return 0;
}
+static void iommu_ignore_device(struct device *dev)
+{
+ u16 devid, alias;
+
+ devid = get_device_id(dev);
+ alias = amd_iommu_alias_table[devid];
+
+ memset(&amd_iommu_dev_table[devid], 0, sizeof(struct dev_table_entry));
+ memset(&amd_iommu_dev_table[alias], 0, sizeof(struct dev_table_entry));
+
+ amd_iommu_rlookup_table[devid] = NULL;
+ amd_iommu_rlookup_table[alias] = NULL;
+}
+
static void iommu_uninit_device(struct device *dev)
{
kfree(dev->archdata.iommu);
@@ -193,7 +211,9 @@ int __init amd_iommu_init_devices(void)
continue;
ret = iommu_init_device(&pdev->dev);
- if (ret)
+ if (ret == -ENOTSUPP)
+ iommu_ignore_device(&pdev->dev);
+ else if (ret)
goto out_free;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [git pull] AMD IOMMU fixes for 3.0-rc2
2011-06-07 10:06 [git pull] AMD IOMMU fixes for 3.0-rc2 Joerg Roedel
` (2 preceding siblings ...)
2011-06-07 10:06 ` [PATCH 3/3] x86/amd-iommu: Fix boot crash with hidden PCI devices Joerg Roedel
@ 2011-06-07 10:43 ` Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2011-06-07 10:43 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, Thomas Gleixner, H. Peter Anvin
* Joerg Roedel <joerg.roedel@amd.com> wrote:
> Hi Ingo,
>
> The following changes since commit 59c5f46fbe01a00eedf54a23789634438bb80603:
>
> Linux 3.0-rc2 (2011-06-06 18:06:33 +0900)
>
> 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
>
> Joerg Roedel (3):
> x86/amd-iommu: Fix 3 possible endless loops
> x86/amd-iommu: Use only per-device dma_ops
> x86/amd-iommu: Fix boot crash with hidden PCI devices
>
> arch/x86/kernel/amd_iommu.c | 48 +++++++++++++++++++++++++++++++++++--
> arch/x86/kernel/amd_iommu_init.c | 8 +++---
> 2 files changed, 49 insertions(+), 7 deletions(-)
>
> These patches fix serious issues which were discovered recently like a
> boot-stall and a boot crash when a device has an alias which does not exist a
> pci_dev. Please pull.
Pulled, thanks a lot Joerg!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-06-07 10:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-07 10:06 [git pull] AMD IOMMU fixes for 3.0-rc2 Joerg Roedel
2011-06-07 10:06 ` [PATCH 1/3] x86/amd-iommu: Fix 3 possible endless loops Joerg Roedel
2011-06-07 10:06 ` [PATCH 2/3] x86/amd-iommu: Use only per-device dma_ops Joerg Roedel
2011-06-07 10:06 ` [PATCH 3/3] x86/amd-iommu: Fix boot crash with hidden PCI devices Joerg Roedel
2011-06-07 10:43 ` [git pull] AMD IOMMU fixes for 3.0-rc2 Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox