Commit graph

27 commits

Author SHA1 Message Date
Stepan Moskovchenko
2d434f9b55 msm: iommu: Clean newly-allocated page tables
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>
2013-02-25 11:40:10 -08:00
Stepan Moskovchenko
e6b397c193 msm: iommu: Support IOMMU page fault reporting
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>
2013-02-25 11:40:09 -08:00
Stepan Moskovchenko
1662778ef7 msm: iommu: Support mapping attributes
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>
2013-02-25 11:40:02 -08:00
Shubhraprakash Das
afc49f2eab msm: iommu: Enable use of TTBR1 register of IOMMU
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>
2013-02-25 11:40:01 -08:00
Jeremy Gebben
40223bb0a4 msm: iommu: use sg_dma_address() in iommu_map_range()
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>
2013-02-25 11:40:00 -08:00
Stepan Moskovchenko
91f92f6db6 msm: iommu: Switch to the new clock APIs
Change-Id: I26521f28bc0217eaf394ff4c133bb3266b7582b5
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2013-02-25 11:39:56 -08:00
Stepan Moskovchenko
01ba7c635d msm: iommu: Convert spinlocks to mutexes
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>
2013-02-25 11:39:56 -08:00
Stepan Moskovchenko
f801c0c220 msm: iommu: Support the IOMMU_CACHE attribute
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>
2013-02-25 11:39:55 -08:00
Stepan Moskovchenko
3b878935d8 msm: iommu: Support page table cacheability attribute
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>
2013-02-25 11:39:54 -08:00
Stepan Moskovchenko
56ee64d14c msm: iommu: Do not register API on unsupported SoC versions
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>
2013-02-25 11:39:53 -08:00
Stepan Moskovchenko
3d28e708a1 msm: iommu: Use the non-secure interrupts for page faults
Configure page faults to trigger the non-secure interrupt
line.

Change-Id: I094cd1cfbed9e71d4f714adc938594bbb54fa89c
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2013-02-25 11:39:50 -08:00
Stepan Moskovchenko
23a39d9b8d msm: iommu: Add functions to map/unmap an address range
Implement the iommu_map_range / iommu_unmap_range ops in
the MSM IOMMU driver.

Change-Id: I87da7b9ec3a3c1f7e6c45ad5d9de497b12e6595f
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2013-02-25 11:39:48 -08:00
Stepan Moskovchenko
3f01076f60 msm: iommu: Remove extra TLB flushing
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>
2013-02-25 11:39:47 -08:00
Stepan Moskovchenko
3f1cfeeaf8 msm: iommu: Selectively invalidate TLB entries
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>
2013-02-25 11:39:47 -08:00
Stepan Moskovchenko
702b8163e3 msm: iommu: Selectively clean PTEs in the cache
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>
2013-02-25 11:39:46 -08:00
Stepan Moskovchenko
5d404c5861 msm: iommu: Re-use ASIDs within an IOMMU
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>
2013-02-25 11:39:45 -08:00
Laura Abbott
12ee374a2f msm: iommu: Add device name to drvdata
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>
2013-02-25 11:39:44 -08:00
Stepan Moskovchenko
62965108ee msm: iommu: Disallow replacement mappings
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>
2013-02-25 11:39:43 -08:00
Stepan Moskovchenko
eea04ff5a0 msm: iommu: Use relaxed register access functions
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>
2013-02-25 11:39:42 -08:00
Shubhraprakash Das
5c0b9cbdf9 msm: iommu: Create iommu api to return the page table address
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>
2013-02-25 11:39:41 -08:00
Stepan Moskovchenko
41b03a2df8 drivers: iommu: Add flags to iommu_domain_alloc
Add the ability to pass flags into the iommu_domain_alloc
function to specify domain attributes.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2013-02-25 11:39:41 -08:00
Joerg Roedel
05df1f3c2a iommu/msm: Fix error handling in msm_iommu_unmap()
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>
2012-01-30 12:53:14 +01:00
Ohad Ben-Cohen
8342727554 iommu/msm: announce supported page sizes
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>
2011-11-10 11:40:37 +01:00
Ohad Ben-Cohen
5009065d38 iommu/core: stop converting bytes to page order back and forth
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>
2011-11-10 11:40:37 +01:00
Joerg Roedel
85eebbc5e4 iommu/msm: Use bus_set_iommu instead of register_iommu
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>
2011-10-21 14:37:23 +02:00
Ohad Ben-Cohen
9e28547f88 iommu/msm: ->unmap() should return order of unmapped page
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>
2011-09-05 15:15:14 +02:00
Ohad Ben-Cohen
b10f127e1a msm: iommu: move to drivers/iommu/
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>
2011-06-21 10:48:50 +02:00
Renamed from arch/arm/mach-msm/iommu.c (Browse further)