Commit Graph

29 Commits

Author SHA1 Message Date
Joerg Roedel 2c0ae1720c iommu/amd: Convert iommu initialization to state machine
This step makes it very easy to keep track about the current
intialization state of the iommu driver. With this change we
can initialize the IOMMU hardware to a point where it can
remap interrupts and later resume the initializion to enable
dma remapping.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:17:12 +02:00
Joerg Roedel b9b1ce707d iommu/amd: Introduce amd_iommu_init_dma routine
This function will initialize everthing necessary so that
devices can do DMA. This includes dma_ops and iommu_ops.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:17:12 +02:00
Joerg Roedel 62410eeb40 iommu/amd: Move unmap_flush message to amd_iommu_init_dma_ops()
The message belongs there anyway, so move it to that
function.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:17:07 +02:00
Joerg Roedel 11ee5ac47b iommu/amd: Split enable_iommus() routine
Split the enable_iommus() routine so that a part of it can
run in early code.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:59 +02:00
Joerg Roedel 643511b37e iommu/amd: Introduce early_amd_iommu_init routine
Split out the code to parse the ACPI table and setup
relevant data structures into a new function.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:58 +02:00
Joerg Roedel 4d121c3256 iommu/amd: Move informational prinks out of iommu_enable
This function will be called before the PCI subsystem is
initialized. Therefore dev_name doen't work and IOMMU
information can't be printed to the klog as before. Move the
code to print that information to a later point where PCI
initializtion has already happened.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:57 +02:00
Joerg Roedel 23c742db21 iommu/amd: Split out PCI related parts of IOMMU initialization
For interrupt remapping the relevant IOMMU initialization
needs to run earlier at boot when the PCI subsystem is not
yet initialized. To support that this patch splits the parts
of IOMMU initialization which need PCI accesses out of the
initial setup path so that this can be done later.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:57 +02:00
Joerg Roedel 02f3b3f544 iommu/amd: Use acpi_get_table instead of acpi_table_parse
This makes it easier to propagate errors while parsing the
IVRS table and makes the amd_iommu_init_err hack obsolete.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:56 +02:00
Joerg Roedel 98f1ad2582 iommu/amd: Fix sparse warnings
A few sparse warnings fire in drivers/iommu/amd_iommu_init.c.
Fix most of them with this patch. Also fix the sparse
warnings in drivers/iommu/irq_remapping.c while at it.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-17 12:14:55 +02:00
Dan Carpenter 3775d4818d iommu/amd: fix type bug in flush code
write_file_bool() modifies 32 bits of data, so "amd_iommu_unmap_flush"
needs to be 32 bits as well or we'll corrupt memory.  Fortunately it
looks like the data is aligned with a gap after the declaration so this
is harmless in production.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-07-02 12:11:40 +02:00
Shuah Khan f2f12b6fc0 iommu/amd: Fix missing iommu_shutdown initialization in passthrough mode
The iommu_shutdown callback is not initialized when the AMD
IOMMU driver runs in passthrough mode. Fix that by moving
the callback initialization before the check for
passthrough mode.

Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Cc: stable@vger.kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-06-07 12:11:21 +02:00
Joerg Roedel c1bf94ec1e iommu/amd: Cache pdev pointer to root-bridge
At some point pci_get_bus_and_slot started to enable
interrupts. Since this function is used in the
amd_iommu_resume path it will enable interrupts on resume
which causes a warning. The fix will use a cached pointer
to the root-bridge to re-enable the IOMMU in case the BIOS
is broken.

Cc: stable@vger.kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-06-04 12:47:44 +02:00
Joerg Roedel 7de473066f Merge branches 'iommu/fixes', 'arm/tegra' and 'x86/amd' into next 2012-03-22 19:28:39 +01:00
Gerard Snitselaar ae295142d2 iommu/amd: Fix section mismatch
amd_iommu_enable_interrupts() called in amd_iommu_resume().

Signed-off-by: Gerard Snitselaar <dev@snitselaar.org>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
2012-03-22 19:28:14 +01:00
Joerg Roedel 3d9761e7a5 iommu/amd: Move interrupt setup code into seperate function
For interrupt remapping the enablement of the IOMMU MSI
interrupt needs to be deferred because the IOMMU itself will
be initialized before the io-apics are up and running. So
the code to setup the MSI is moved seperated from the
hardware-setup routine now.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-03-15 16:39:21 +01:00
Joerg Roedel 9ddd592a19 iommu/amd: Make sure IOMMU interrupts are re-enabled on resume
Unfortunatly the interrupts for the event log and the
peripheral page-faults are only enabled at boot but not
re-enabled at resume. Fix that.

Cc: stable@vger.kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-03-15 16:31:03 +01:00
Joerg Roedel 6e930045ab iommu/amd: Fix double free of mem-region in error-path
When ioremap_nocache fails in iommu initialization the code
calls release_mem_region immediatly. But the function is
called again when the propagates into the upper init
functions leading to a double-free. Fix that.

Reported-by: Don Dutile <ddutile@redhat.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-03-09 13:37:48 +01:00
Jan Beulich 6b7f000eb6 x86/amd: iommu_set_device_table() must not be __init
This function is called from enable_iommus(), which in turn is used
from amd_iommu_resume().

Cc: stable@vger.kernel.org
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-03-08 11:36:06 +01:00
Joerg Roedel 8704a1ba47 iommu/amd: Split amd_iommu_init function
The hardware-initializtion part of the AMD IOMMU driver is
split out into a seperate function. This function can now be
called either from amd_iommu_init() itself or any other
place if the hardware needs to be ready earlier. This will
be used to implement interrupt remapping for AMD.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2012-03-01 16:14:48 +01:00
Joerg Roedel 1456e9d2c4 iommu/amd: Set IOTLB invalidation timeout
To protect the command buffer from hanging when a device
does not respond to an IOTLB invalidation, set a timeout of
1s for outstanding IOTLB invalidations.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-22 14:56:56 +01:00
Joerg Roedel 31342b58b7 iommu/amd: Remove unnecessary cache flushes in amd_iommu_resume
The caches are already flushed in enable_iommus(), so this
flush is not necessary.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-22 14:56:56 +01:00
Joerg Roedel 52815b7568 iommu/amd: Add support for IOMMUv2 domain mode
This patch adds support for protection domains that
implement two-level paging for devices.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 15:18:57 +01:00
Joerg Roedel 5abcdba4fa iommu/amd: Put IOMMUv2 capable devices in pt_domain
If the device starts to use IOMMUv2 features the dma handles
need to stay valid. The only sane way to do this is to use a
identity mapping for the device and not translate it by the
iommu. This is implemented with this patch. Since this lifts
the device-isolation there is also a new kernel parameter
which allows to disable that feature.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:58 +01:00
Joerg Roedel 400a28a05f iommu/amd: Add iommuv2 flag to struct amd_iommu
In mixed IOMMU setups this flag inidicates whether an IOMMU
supports the v2 features or not. This patch also adds a
global flag together with a function to query that flag from
other code. The flag shows if at least one IOMMUv2 is in the
system.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:52 +01:00
Joerg Roedel cbc33a9085 iommu/amd: Enable GT mode when supported by IOMMU
This feature needs to be enabled before IOMMUv2 DTEs can be
set up.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:44 +01:00
Joerg Roedel 1a29ac014a iommu/amd: Setup PPR log when supported by IOMMU
Allocate and enable a log buffer for peripheral page faults
when the IOMMU supports this feature.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:37 +01:00
Joerg Roedel 62f71abbc6 iommu/amd: Get the maximum number of PASIDs supported
Read the number of PASIDs supported by each IOMMU in the
system and take the smallest number as the maximum value
supported by the IOMMU driver.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:30 +01:00
Joerg Roedel ee6c286845 iommu/amd: Convert dev_table_entry to u64
Convert the contents of 'struct dev_table_entry' to u64 to
allow updating the DTE wit 64bit writes as required by the
spec.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-12-12 14:54:23 +01:00
Joerg Roedel 403f81d8ee iommu/amd: Move missing parts to drivers/iommu
A few parts of the driver were missing in drivers/iommu.
Move them there to have the complete driver in that
directory.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2011-06-21 10:49:31 +02:00