Commit graph

15 commits

Author SHA1 Message Date
Vijayanand Jitta
412b07f4da iommu: dma-mapping-fast: Add a check for count in fast_smmu_alloc
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>
2019-02-03 22:25:34 -08:00
Liam Mark
4f83071078 iommu/arm-smmu: add support to configure IOVA range
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>
2017-04-18 11:34:53 -07:00
Liam Mark
0bf318c247 iommu: dma-mapping-fast: per-buffer coherent mappings
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>
2017-03-15 12:47:07 -07:00
Shiraz Hashim
2e87440c3e iommu/io-pgtable-fast: optimize statically allocated pages
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>
2017-03-01 12:02:07 +05:30
Linux Build Service Account
9e0a375b5e Merge "iommu: dma-mapping: alloc bitmap while fragmented" 2017-02-15 17:01:12 -08:00
Charan Teja Reddy
f1cc7ec4c8 arm: dma-mapping: add dma mapper for io-pgtable-fast for 32 bit
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>
2017-02-13 11:05:17 +05:30
Liam Mark
335db258eb iommu: dma-mapping: alloc bitmap while fragmented
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>
2017-02-09 09:27:24 -08:00
Mitchel Humpherys
486496dc03 iommu: dma-mapping-fast: Respect device coherency in IOMMU mapper
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>
2017-01-04 14:19:09 -08:00
Mitchel Humpherys
31d36a8989 iommu: dma-mapping-fast: Only flush non-coherent page tables
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>
2017-01-04 14:19:00 -08:00
Liam Mark
3991501f31 iommu: dma-mapping-fast: add support for DMA sync single APIs
Implement the fast map DMA sync single APIs.

Change-Id: I1b785c7c441e53fa0b2e0fa784ff8afed8afceb9
Signed-off-by: Liam Mark <lmark@codeaurora.org>
2016-12-05 13:42:00 -08:00
Mitchel Humpherys
8fbe0d269f iommu: dma-mapping-fast: Remove obsolete IOMMU domain attribute
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>
2016-09-26 17:42:50 -07:00
Patrick Daly
43c871acf1 iommu: dma-mapping-fast: Add mmap support
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>
2016-08-12 18:50:36 -07:00
Mitchel Humpherys
0fa63fe11a iommu: dma-mapping-fast: Remove unused #define
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>
2016-06-30 11:09:16 -07:00
Mitchel Humpherys
94c107c426 iommu/io-pgtable-fast: Prove correctness of TLB maintenance
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>
2016-05-20 19:24:04 -07:00
Mitchel Humpherys
66bd318533 iommu: Add DMA mapper for io-pgtable-fast
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>
2016-05-20 19:24:00 -07:00