If L2 redirection is disabled, clean page tables upon
allocation to prevent hardware table walks into unmapped
areas from accessing stale data.
Change-Id: If1e70bfa52f86d9ddc5a001a699050667b075631
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Provide the ability to report IOMMU fault events through
the IOMMU API. The driver will fall back on the previous
behavior of printing the fault information registers if no
domain fault handler is registered, or if the handler
returns -ENOSYS.
Change-Id: I9144e9b4bba117b67c7d81609e986ea716b34882
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Add support for the IOMMU_READ and IOMMU_WRITE attributes
for mappings. Read-only and read-write mappings are fully
supported. Write-only mappings are not supported in
hardware and will fall back to read-write. Specifying
neither attribute in iommu_map will result in a warning on
the first call, and the mapping will be treated as
read-write.
Change-Id: Ibe9bd340d0743f37c91580c7db4f199fb4afba8b
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Add a new platform data in iommu devices to indicate whether ttbr1
should be used which also dictates how the address space should be
split between ttbr0 and ttbr1.
Change-Id: Iab3aac74256bd4d49f47f89e6638f014e6e539e9
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Ion carveout and content protect buffers do not have
a struct page and thus sg_phys() cannot be used on them.
Try sg_dma_address() first and if it returns 0 then
use sg_phys().
Change-Id: I95ccb8f5a3c86cd09ecf2a2737c260f4996059ac
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Use a mutex to protect the IOMMU data structures to allow
use of the new clock APIs from within lock-protected
regions.
Change-Id: I89a932d42e37d7860485add1b857288fd5947aea
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Instead of specifying a shareability attribute and a cache
policy, add support for the IOMMU_CACHE attribute to allow
cacheable mappings using the default memory cache policy.
Change-Id: I78442770e4e64fd72d9314d343223757593d3529
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Allow specifying the cacheability flags for IOMMU page
tables on a per-domain basis.
Change-Id: I03c4c1b08b03bbc5a1ba9931ed117518ff772ce5
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
In addition to not registering IOMMU devices, do not
register the IOMMU API on SoC versions which do not support
it. This will allow iommu_found to work properly.
Change-Id: I103fc4ff910bee3eb4039e19de52f36cd1778861
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Don't flush the entire TLB on attach/detach. Only flush the
TLB entries associated with a specific context when the
domain is detached from that context.
Change-Id: I1690f0f7a01598e67edf76472645abf6e15ef4ad
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
When mapping or unmapping within a domain, only invalidate
the TLB entries associated with the VA of the mapping being
modified (and the ASID associated with the related context)
rather than invalidating the entire TLB.
Change-Id: Ic2002a4a0edc14a01a29bedde2b7e2903cd74ffe
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
When modifying the page tables, only clean the modified
entries in the cache, rather than cleaning the entire
first-level page table and all second-level tables.
Change-Id: I53f38eacf88a0864b20b3c87ea4ecb35f913e19d
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Reuse ASID values within an SMMU if multiple contexts
within that SMMU are using the same page table. This
should improve TLB performance by eliminating duplicate
TLB entries for the same page table but with different ASID
tags.
Change-Id: I61e3c4c3edcbc42abab0e64dcecab3d8744dc3d6
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Add the human readable name of the iommu device to drvdata.
This makes debugging iommu page faults much easier since
the faulting device name is immediately present. The
context where the fault occured can the be derived from
existing information.
Change-Id: I63b6f05dea155e40f1176f2bebb5eb3cee69a412
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Forbid mappings that overwrite previous mappings,
regardless of size, unless they had been unmapped first.
Change-Id: I54577ce3a34c7f753fc893471ce11e9ac4dd0f1d
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Use the relaxed versions of readl/writel for IOMMU register
access, inserting barriers where appropriate.
Change-Id: I06b54c3eb327a7fe3d9d3850d7906164b96f4363
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Create a new iommu api to return the base address of the domain's
pagetable.
Change-Id: Ibf5425fa7ae253b16bfe795614bd7943efd7e3e3
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Add the ability to pass flags into the iommu_domain_alloc
function to specify domain attributes.
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Error handling in msm_iommu_unmap() is broken. On some error
conditions retval is set to a non-zero value which causes
the function to return 'len' at the end. This hides the
error from the user. Zero should be returned in those error
cases.
Cc: David Brown <davidb@codeaurora.org>
Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: stable@vger.kernel.org # >= 3.1
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Acked-by: David Brown <davidb@codeaurora.org>
Let the IOMMU core know we support 4KiB, 64KiB, 1MiB and 16MiB page sizes.
This way the IOMMU core can split any arbitrary-sized physically
contiguous regions (that it needs to map) as needed.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: David Brown <davidb@codeaurora.org>
Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Express sizes in bytes rather than in page order, to eliminate the
size->order->size conversions we have whenever the IOMMU API is calling
the low level drivers' map/unmap methods.
Adopt all existing drivers.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: David Brown <davidb@codeaurora.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <Joerg.Roedel@amd.com>
Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: KyongHo Cho <pullip.cho@samsung.com>
Cc: Hiroshi DOYU <hdoyu@nvidia.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Convert the MSM IOMMU driver for ARM to use the new
interface for publishing the iommu_ops.
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Users of the IOMMU API (kvm specifically) assume that iommu_unmap()
returns the order of the unmapped page (on success).
Fix msm_iommu_unmap() accordingly.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: David Brown <davidb@codeaurora.org>
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
This should ease finding similarities with different platforms,
with the intention of solving problems once in a generic framework
which everyone can use.
Compile-tested for MSM8X60.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>