In fast_smmu_alloc size_t variable size is type casted to int
variable count, this variable count can get truncated and can
result in memory corruption during unmap, make count as size_t
and also add a check for count as sg_alloc_table_from_pages
accepts unsigned int value for count.
Change-Id: I4780a554c5c062fd9dd229e5cc0ac804b1ba31d8
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
Allow clients to specify the IOVA range for fastmap clients
via the DOMAIN_ATTR_GEOMETRY domain attribute.
Presently fastmap only allocates page tables for the IOVA
range specified during the create mapping call. However
clients may want to use IOVA addresses outside this range,
such as for their calls to iommu_map.
So allow clients to extend the available IOVA space by setting
the DOMAIN_ATTR_GEOMETRY domain attribute's
iommu_domain_geometry.aperture_start to
the new start address of the IOVA space and by setting
iommu_domain_geometry.aperture_end to the new end address of the
IOVA space.
The new IOVA space created by iommu_domain_geometry.aperture_start
and iommu_domain_geometry.aperture_end will be a superset of the
IOVA range which was created through the create mapping call.
The DOMAIN_ATTR_GEOMETRY domain attribute can only be set before
attaching.
Calls to set the DOMAIN_ATTR_GEOMETRY domain attribute can only
be used to extend the IOVA space, it cannot shrink the range.
Note that extending the IOVA range will not change the range of
IOVA addresses which will be available to the DMA APIs.
Change-Id: Ib389e019a022d98417884002de08115fb0fc9384
Signed-off-by: Liam Mark <lmark@codeaurora.org>
For "fast" stage 1 mappings add support to either force a buffer to
be mapped as coherent through the DMA_ATTR_FORCE_COHERENT DMA
attribute, or to force a buffer to not be mapped as coherent by
using the DMA_ATTR_FORCE_NON_COHERENT DMA attribute.
Both the DMA_ATTR_FORCE_COHERENT and DMA_ATTR_FORCE_NON_COHERENT DMA
attributes override the buffer coherency configuration set by making
the device coherent.
Change-Id: I465a88ee568fb6cd8206c26a62cbf02ac40328fa
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Presently fastmap iommu feature allocates page tables for
full 4GB virtual address space. This can be optimized to
consider virtual address range [base, size] needed by
client and prepare page tables only for applicable
region.
Change-Id: Ie6c23cb8e1702a823567e126f452b1e72d851f71
Signed-off-by: Shiraz Hashim <shashim@codeaurora.org>
io-pgtable-fast was implemented to achieve
better performance for IOMMU map/un-map. Add
DMA API support that goes through io-pgtable-fast
for 32 bit targets.
Change-Id:I3d0560a4331f6b7b87c70d0885df11d12cb1d6ec
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
The bitmap size can be on the order of several pages.
In a fragmented system it may not be possible to allocate the
memory as contiguous.
Handle fragmentation by falling back to vzalloc.
Change-Id: Ie93c92705eed1bbe966d5f121b3393d8909982a6
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Coherent devices can make use of the CPU cache, so they should get
coherent IOMMU mappings and should have their cache maintenance
operations skipped. Implement this for the "fast" arm64 IOMMU mapper.
Change-Id: I30db64cae2cc4cda0baa3cdd3860dc079f22bf71
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Some SMMUs can walk page tables in the CPU cache, avoiding the need to
do cache maintenance operations on the page table memory. Don't do
cache maintenance on SMMUs with coherent page tables.
Change-Id: I47e00e72548212209b59c13a0d7d59cb0ab964ff
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
The DOMAIN_ATTR_COHERENT_HTW_DISABLE IOMMU domain attribute is being
removed. SMMU coherency will be configured through the SMMU device tree
nodes moving forward. Remove the obsolete option.
Change-Id: I0e3d3a134b686dd5b639827ef4ee80c4d31df613
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Clients may use dma_mmap_coherent to map buffers allocated through
dma_alloc_coherent() to userspace. Support this.
Change-Id: Ibf1f086be4c6692479c11cb4585954c5d3c91707
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
There's a stray #define left over from initial development of the fast
map feature. Rip it out.
CRs-Fixed: 1035430
Change-Id: Iae0649dc3fe878f948ad872803317eb4bf7ec1c6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
A common software error when it comes to page table code is missing TLB
maintenance. Add some checks to the io-pgtable-fast code to detect when
an address that might be stale in the TLB is being re-used. This can be
accomplished by writing a "stale TLB" flag value to the reserved bits of
the PTE during unmap and then removing the flag value when the TLBs are
invalidated (by sweeping the entire page table). That way, whenever we
map we can know that there might be a stale TLB in the location being
mapped into if it contains the "stale TLB" flag value.
CRs-Fixed: 997751
Change-Id: Icf9c1e41977cb71e8b137190adb3b4a201c339da
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
io-pgtable-fast does some underhanded tricks to achieve performance.
One of those tricks is that it expects clients to call its map function
directly, rather than going through the IOMMU framework. Add a DMA API
implementation that goes through io-pgtable-fast.
CRs-Fixed: 997751
Change-Id: Iebcafeb630d9023f666078604898069e9f26dfdd
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>