summaryrefslogtreecommitdiffstats
path: root/drivers/iommu
AgeCommit message (Collapse)AuthorFilesLines
2015-06-11iommu/amd: Put IOMMUv2 devices in a direct mapped domainJoerg Roedel1-1/+14
A device that might be used for HSA needs to be in a direct mapped domain so that all DMA-API mappings stay alive when the IOMMUv2 stack is used. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu/amd: Support IOMMU_DOMAIN_IDENTITY type allocationJoerg Roedel1-0/+7
Add support to allocate direct mapped domains through the IOMMU-API. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu/amd: Support IOMMU_DOMAIN_DMA type allocationJoerg Roedel2-241/+73
This enables allocation of DMA-API default domains from the IOMMU core and switches allocation of domain dma-api domain to the IOMMU core too. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu/amd: Implement add_device and remove_deviceJoerg Roedel2-178/+63
Implement these two iommu-ops call-backs to make use of the initialization and notifier features of the iommu core. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu/amd: Use default domain if available for DMA-APIJoerg Roedel1-0/+7
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu/amd: Implement dm_region call-backsJoerg Roedel1-0/+43
Add the get_dm_regions and put_dm_regions callbacks to the iommu_ops of the AMD IOMMU driver. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-11iommu: Introduce iommu_request_dm_for_dev()Joerg Roedel1-0/+53
This function can be called by an IOMMU driver to request that a device's default domain is direct mapped. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Add function to query the default domain of a groupJoerg Roedel1-0/+5
This will be used to handle unity mappings in the iommu drivers. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Create direct mappings in default domainsJoerg Roedel1-0/+48
Use the information exported by the IOMMU drivers to create direct mapped regions in the default domains. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Introduce direct mapped region handlingJoerg Roedel1-0/+16
Add two new functions to the IOMMU-API to allow the IOMMU drivers to export the requirements for direct mapped regions per device. This is useful for exporting the information in Intel VT-d's RMRR entries or AMD-Vi's unity mappings. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Add iommu_get_domain_for_dev functionJoerg Roedel1-0/+18
This function can be used to request the current domain a device is attached to. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Make sure a device is always attached to a domainJoerg Roedel1-8/+76
Make use of the default domain and re-attach a device to it when it is detached from another domain. Also enforce that a device has to be in the default domain before it can be attached to a different domain. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Limit iommu_attach/detach_device to devices with their own groupJoerg Roedel1-4/+67
This patch changes the behavior of the iommu_attach_device and iommu_detach_device functions. With this change these functions only work on devices that have their own group. For all other devices the iommu_group_attach/detach functions must be used. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-09iommu: Allocate a default domain for iommu groupsJoerg Roedel1-4/+27
The default domain will be used (if supported by the iommu driver) when the devices in the iommu group are not attached to any other domain. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-08Merge git://git.infradead.org/intel-iommuLinus Torvalds1-5/+8
Pull Intel IOMMU fix from David Woodhouse: "This fixes an oops when attempting to enable 1:1 passthrough mode for devices on which VT-d translation was disabled anyway. It's actually a long-standing bug but recent changes (commit 18436afdc11a: "iommu/vt-d: Allow RMRR on graphics devices too") have made it much easier to trigger with 'iommu=pt intel_iommu=igfx_off' on the command line" * git://git.infradead.org/intel-iommu: iommu/vt-d: Fix passthrough mode with translation-disabled devices
2015-06-05iommu: Call remove_device call-back after driver releaseJoerg Roedel1-1/+1
Do not remove the device from the IOMMU while the driver is still attached. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-05iommu: Clean up after a failed bus initializationJoerg Roedel1-9/+26
Make sure we call the ->remove_device call-back on all devices already initialized with ->add_device when the bus initialization fails. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-05iommu: Propagate error in add_iommu_groupJoerg Roedel1-3/+1
Make sure any errors reported from the IOMMU drivers get progapated back to the IOMMU core. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-05iommu: Add a few printk messages to group handling codeJoerg Roedel1-0/+9
Write a message to the kernel log when a device is added or removed from a group and add debug messages to group allocation and release routines. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-05iommu: Remove function name from pr_fmt()Joerg Roedel1-1/+1
Including the function name is only useful for debugging messages. They don't belong into other messages from the iommu core. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-06-02break kconfig dependency loopGerd Hoffmann1-0/+3
After adding virtio-gpu I get this funky kconfig dependency loop. scripts/kconfig/conf --oldconfig Kconfig drivers/video/fbdev/Kconfig:5:error: recursive dependency detected! drivers/video/fbdev/Kconfig:5: symbol FB is selected by DRM_KMS_FB_HELPER drivers/gpu/drm/Kconfig:34: symbol DRM_KMS_FB_HELPER is selected by DRM_VIRTIO_GPU drivers/gpu/drm/virtio/Kconfig:1: symbol DRM_VIRTIO_GPU depends on VIRTIO drivers/virtio/Kconfig:1: symbol VIRTIO is selected by REMOTEPROC drivers/remoteproc/Kconfig:4: symbol REMOTEPROC is selected by OMAP_REMOTEPROC drivers/remoteproc/Kconfig:12: symbol OMAP_REMOTEPROC depends on OMAP_IOMMU drivers/iommu/Kconfig:141: symbol OMAP_IOMMU is selected by VIDEO_OMAP3 drivers/media/platform/Kconfig:96: symbol VIDEO_OMAP3 depends on VIDEO_V4L2 drivers/media/v4l2-core/Kconfig:6: symbol VIDEO_V4L2 depends on I2C drivers/i2c/Kconfig:7: symbol I2C is selected by FB_DDC drivers/video/fbdev/Kconfig:59: symbol FB_DDC is selected by FB_CYBER2000_DDC drivers/video/fbdev/Kconfig:374: symbol FB_CYBER2000_DDC depends on FB_CYBER2000 drivers/video/fbdev/Kconfig:362: symbol FB_CYBER2000 depends on FB Making VIDEO_OMAP3 depend on OMAP_IOMMU instead of selecting it breaks the loop, which looks like the best way to handle it to me. Updated OMAP_IOMMU help text accordingly. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-06-02Revert "iommu/amd: Don't allocate with __GFP_ZERO in alloc_coherent"Joerg Roedel1-0/+1
This reverts commit 5fc872c7323534e8f7dc21bab635e7a9b9659e07. The DMA-API does not strictly require that the memory returned by dma_alloc_coherent is zeroed out. For that another function (dma_zalloc_coherent) should be used. But all other x86 DMA-API implementation I checked zero out the memory, so that some drivers rely on it and break when it is not. It seems the (driver-)world is not yet ready for this change, so revert it. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/amd: Handle integer overflow in dma_ops_area_allocJoerg Roedel1-3/+5
Handle this case to make sure boundary_size does not become 0 and trigger a BUG_ON later. Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/arm-smmu: Add initial driver support for ARM SMMUv3 devicesWill Deacon3-0/+2684
Version three of the ARM SMMU architecture introduces significant changes and improvements over previous versions of the specification, necessitating a new driver in the Linux kernel. The main change to the programming interface is that the majority of the configuration data has been moved from MMIO registers to in-memory data structures, with communication between the CPU and the SMMU being mediated via in-memory circular queues. This patch adds an initial driver for SMMUv3 to Linux. We currently support pinned stage-1 (DMA) and stage-2 (KVM VFIO) mappings using the generic IO-pgtable code. Cc: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/arm-smmu: Make force_stage module param read-only in sysfsWill Deacon1-1/+1
Changing force_stage dynamically isn't supported by the driver and it also doesn't make a whole lot of sense to change it once the SMMU is up and running. This patch makes the sysfs entry for the parameter read-only. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/arm-smmu: Fix ATS1* register writesRobin Murphy1-11/+10
The ATS1* address translation registers only support being written atomically - in SMMUv2 where they are 64 bits wide, 32-bit writes to the lower half are automatically zero-extended, whilst 32-bit writes to the upper half are ignored. Thus, the current logic of performing 64-bit writes as two 32-bit accesses is wrong. Since we already limit IOVAs to 32 bits on 32-bit ARM, the lack of a suitable writeq() implementation there is not an issue, and we only need a little preprocessor ugliness to safely hide the 64-bit case. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Add callback for initializing devices from device treeMarek Szyprowski1-0/+28
This patch adds implementation of of_xlate callback, which prepares masters device for attaching to IOMMU. This callback is called during creating devices from device tree. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Init from dt-specific callback instead of initcallMarek Szyprowski1-9/+28
This patch introduces IOMMU_OF_DECLARE-based initialization to the driver, which replaces subsys_initcall-based procedure. exynos_iommu_of_setup ensures that each sysmmu controller is probed before its master device. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Add system suspend/resume supportMarek Szyprowski1-0/+31
When system goes into suspend state, iommu should save it's state and restore after system resume. This is handled by 'late' pm ops to ensure that sysmmu will be suspended after its master devices and restored before them. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Add support for runtime_pmMarek Szyprowski1-0/+2
This patch fixes support for runtime power management for SYSMMU controllers, so they are enabled when master device is attached. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Add support for binding more than one sysmmu to master deviceMarek Szyprowski1-6/+5
This patch adds support for assigning more than one SYSMMU controller to the master device. This has been achieved simply by chaning the struct device pointer in struct exynos_iommu_owner into the list of struct sysmmu_drvdata of all controllers assigned to the given master device. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Add/remove callbacks should fail if no iommu is availableMarek Szyprowski1-0/+6
Return fail if given master device passed to add_device/remove_device callbacks doesn't has associated any sysmmu controller. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Document internal structuresMarek Szyprowski1-18/+35
Add a few words of comment to all internal structures used by the driver. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Remove excessive includes and sort others alphabeticallyMarek Szyprowski1-9/+5
Removed following unused includes: <linux/mm.h>, <linux/errno.h>, <linux/memblock.h> and <linux/export.h>. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Use struct exynos_iommu_domain in internal structuresMarek Szyprowski1-5/+5
Replace all remaining usage of struct iommu_domain with struct exynos_iommu_domain in all internal structures and functions. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Rename variables to reflect their purposeMarek Szyprowski1-93/+94
This patch renames some variables to make the code easier to understand. 'domain' is replaced by 'iommu_domain' (more generic entity) and really meaningless 'priv' by 'domain' to reflect its purpose. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Refactor function parameters to simplify codeMarek Szyprowski1-86/+48
This patch simplifies the code by: - refactoring function parameters from struct device pointer to direct pointer to struct sysmmu drvdata - moving list_head enteries from struct exynos_iommu_owner directly to struct sysmmu_drvdata After above refactoring some functions were never used, so remove also them completely. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Remove useless members from exynos_iommu_owner structureMarek Szyprowski1-19/+2
This patch removes useless spinlocks and other unused members from struct exynos_iommu_owner. There is no point is protecting this structure by spinlock because content of this structure doesn't change and other structures have their own spinlocks. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Remove unused functionsMarek Szyprowski1-31/+0
This patch removes two unneeded functions, which are not a part of generic IOMMU API and were never used by any other driver. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/exynos: Don't read version register on every tlb operationMarek Szyprowski1-8/+5
This patch removes reading of REG_MMU_VERSION register on every tlb operation and caches SYSMMU version in driver's internal data. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu: Init iommu-groups support earlier, in core_initcallMarek Szyprowski1-1/+1
iommu_group_alloc might be called very early in case of iommu controllers activated from of_iommu, so ensure that this part of subsystem is ready when devices are being populated from device-tree (core_initcall seems to be okay for this case). Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-29iommu/rockchip: Silence attaching and detaching of devicesHeiko Stuebner1-2/+2
Currently the driver emits a log line every time a device attaches or detaches - which happens at every unblank/blank of the drm for example. The message itself also has no real value to the average user and is merely useful when debugging a problem, so make it a dev_dbg instead. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-17Merge branch 'x86/asm' into x86/apic, to resolve conflictsIngo Molnar3-31/+4
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-11iommu/exynos: Tell kmemleak to ignore 2nd level page tablesColin Cross1-0/+1
The pointers to the 2nd level page tables are converted to 1st level page table entries, which means kmemleak can't find them and assumes they have been leaked. Call kmemleak_ignore on the 2nd level page tables to prevent them from showing up in kmemleak reports. Signed-off-by: Colin Cross <ccross@android.com> Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-11iommu/arm-smmu: Fix sign-extension of upstream bus addresses at stage 1Will Deacon1-28/+2
Stage 1 translation is controlled by two sets of page tables (TTBR0 and TTBR1) which grow up and down from zero respectively in the ARMv8 translation regime. For the SMMU, we only care about TTBR0 and, in the case of a 48-bit virtual space, we expect to map virtual addresses 0x0 through to 0xffff_ffff_ffff. Given that some masters may be incapable of emitting virtual addresses targetting TTBR1 (e.g. because they sit on a 48-bit bus), the SMMU architecture allows bit 47 to be sign-extended, halving the virtual range of TTBR0 but allowing TTBR1 to be used. This is controlled by the SEP field in TTBCR2. The SMMU driver incorrectly enables this sign-extension feature, which causes problems when userspace addresses are programmed into a master device with the SMMU expecting to map the incoming transactions via TTBR0; if the top bit of address is set, we will instead get a translation fault since TTBR1 walks are disabled in the TTBCR. This patch fixes the issue by disabling sign-extension of a fixed virtual address bit and instead basing the behaviour on the upstream bus size: the incoming address is zero extended unless the upstream bus is only 49 bits wide, in which case bit 48 is used as the sign bit and is replicated to the upper bits. Cc: <stable@vger.kernel.org> # v4.0+ Reported-by: Varun Sethi <varun.sethi@freescale.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-11Merge branch 'x86/asm' into x86/apic, to resolve a conflictIngo Molnar2-80/+67
Conflicts: arch/x86/kernel/apic/io_apic.c arch/x86/kernel/apic/vector.c Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-05-11iommu/vt-d: Fix passthrough mode with translation-disabled devicesDavid Woodhouse1-5/+8
When we use 'intel_iommu=igfx_off' to disable translation for the graphics, and when we discover that the BIOS has misconfigured the DMAR setup for I/OAT, we use a special DUMMY_DEVICE_DOMAIN_INFO value in dev->archdata.iommu to indicate that translation is disabled. With passthrough mode, we were attempting to dereference that as a normal pointer to a struct device_domain_info when setting up an identity mapping for the affected device. This fixes the problem by making device_to_iommu() explicitly check for the special value and indicate that no IOMMU was found to handle the devices in question. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Cc: stable@vger.kernel.org (which means you can pick up 18436afdc now too)
2015-05-05iommu/rockchip: Make sure that page table state is coherentTomasz Figa1-6/+17
To flush created mappings, current mapping code relies on the fact that during unmap the driver zaps every IOVA being unmapped and that it is enough to zap a single IOVA of page table to remove the entire page table from IOMMU cache. Based on these assumptions the driver was made to simply zap the first IOVA of the mapping being created. This is enough to invalidate first page table, which could be shared with another mapping (and thus could be already present in IOMMU cache), but unfortunately it does not do anything about the last page table that could be shared with other mappings as well. Moreover, the flushing is performed before page table contents are actually modified, so there is a race between the CPU updating the page tables and hardware that could be possibly running at the same time and triggering IOMMU look-ups, which could bring back the page tables back to the cache. To fix both issues, this patch makes the mapping code zap first and last (if they are different) IOVAs of new mapping after the page table is updated. Signed-off-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org> Tested-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-05iommu: Fix checkpatch warnings for Missing a blank line after declarationsRobert Callicotte1-0/+4
Fixed checkpatch warnings for missing blank line after declaration of struct. Signed-off-by: Robert Callicotte <rcallicotte@gmail.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
2015-05-05iommu/rockchip: Fix build without CONFIG_OFArnd Bergmann1-3/+1
The rockchip iommu driver references its of_device_id table from the init function, which fails to build when the table is undefined: iommu/rockchip-iommu.c: In function 'rk_iommu_init': iommu/rockchip-iommu.c:1029:35: error: 'rk_iommu_dt_ids' undeclared (first use in this function) np = of_find_matching_node(NULL, rk_iommu_dt_ids); This removes the #ifdef and the corresponding of_match_ptr wrapper to make it build both with CONFIG_OF enabled or disabled. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 425061b0f5074 ("iommu/rockchip: Play nice in multi-platform builds") Reviewed-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Joerg Roedel <jroedel@suse.de>