Commit Graph

11 Commits

Author SHA1 Message Date
qctecmdr
a82b141d55 Merge "iommu: add a function to get MID/PID/BID info" 2021-01-14 13:05:35 -08:00
Vijayanand Jitta
2ae11214cb iommu: add a function to get MID/PID/BID info
For certain use cases SID remains same and when an
smmu page fault occurs it becomes difficult for client
to identify which of the usecases is actually causing
the fault. In such cases MID/PID/BID info can help.
So, add a function for the same so that clients can
call this from their fault handler and get the info.

Change-Id: Ia720641224f908287ae1d66908ab12def82bbbab
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
2021-01-13 22:54:19 -08:00
Patrick Daly
245792aaac arm-smmu: Implement sid switch & remove detach_device operation
Some devices support operation with different levels of security. In some
modes, HLOS is no longer responsible for managing the S1 translations for
a device. Unfortunately, the device may still use the same set of SIDS, so
to prevent a potential stream-match conflict fault, HLOS needs to remove
the SIDs fromits SMRs. Enforcement of this policy is implemented through
virtualization of the SMR/S2CR regigisters.

On previous kernels, this was implemented via the detach_device callback.
However, since upstream now implements detaching from the default_domain
as a no-op, that approach no longer works. Instead add a new function
qcom_iommu_sid_switch() which clients may call as needed.

Change-Id: I20cef4b0efda15f96d4ad807082b0dcf6099d996
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-01-13 22:54:18 -08:00
Patrick Daly
dfe77cebd7 arm-smmu: Improve iova_to_phys_hard
Previous kernel versions included a domain->is_debug_domain flag to
indicate whether the sid should be taken from the device, or from the
CBFRSYNRA fault status register.

Instead, add the sid as a function parameter to iova_to_phys_hard.

Change-Id: Icac603a8c281c9af919bd19dec0f42a2ef51fe7e
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-01-13 22:54:16 -08:00
Patrick Daly
6182e0110e arm-smmu: Add support for qcom_iommu_iova_to_phys_hard
Add a callback for debugging the page table mappings. This callback
exposes the smmu hw's capability to translate a virtual address to a
physical address.

Change-Id: If8a475aa679fb7c3bf294246e55a3dcebbccd0d3
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2021-01-13 22:54:15 -08:00
Patrick Daly
767329165c qcom_iommu_util: Add support for qcom-io-pgtable-arm
Add support for using this submodule.

Change-Id: I3658589b1d38ddcdf8bc9d2c01f6042cfeb964d5
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-01-12 18:20:32 -08:00
Isaac J. Manjarres
1ab7e2947e qcom-iommu-util: Add support for calculating the IOVA range for fastmap
Fastmap preallocates all of the page table memory that it will need
at boot. In order to know what range of the 4 GB IOVA space that
fastmap supports will be mapped, the qcom,iommu-geometry and the
qcom,iommu-dma-addr-pool properties need to be examined. Thus,
add support for generating the IOVA range to be used by a device
that uses fastmap, prior to the page table memory being allocated.

There are a few cases to consider:

1) Neither qcom,iommu-dma-addr-pool or qcom,iommu-geometry is present.
   In this case, we do not know what ranges the client will use, so
   consider the range as the entire fastmap IOVA range [0, 4 GB).

2) qcom,iommu-dma-addr-pool is present, but qcom,iommu-geometry is not
   present. In this case, we know the DMA range, but we do not know if
   the client may use the IOMMU APIs directly to map memory outside of
   the DMA range, so use the entire fastmap IOVA range [0, 4 GB).

3) qcom,iommu-geometry is present, but qcom,iommu-dma-addr-pool is not
   present. In this case, we do not know if the client will use the DMA
   APIs, which may allocate IOVAs outside of the range specified in
   qcom,iommu-geometry, so use the entire fastmap IOVA range [0, 4 GB).

4) Both qcom,iommu-geometry and qcom,iommu-dma-addr-pool are present.
   In this case, we need to specify the range as the union of both ranges,
   so the range becomes: [min(dma_base, geometry_base),
   max(dma_base + dma_size, geometry_base + geometry_size)).

Change-Id: I6901f269a00203965f220d52bc546f26bf288dce
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
2021-01-06 08:44:43 -08:00
Patrick Daly
28e5ebea75 qcom-dma-iommu-generic: Copy functions from dma-iommu
Many functions from dma-iommu can be reused by other dma layer
implemenations such as fastmap. Create a non-static copy of these
functions with minor modifications for qcom dma attributes.

Based off of commit 9c16520a33 ("Merge 5.9-rc5 into android-mainline").

Change-Id: I9762823f2c1f514df2fbf1acc9e8a7ac49e9e5d8
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2020-10-28 22:57:30 -07:00
Patrick Daly
708a5dd2f4 qcom_iommu_util: Rewrite or copy nonexported dma utility functions
Fastmap, qcom's alternative dma layer implementation, currently uses many
functions from include/linux/dma-coherent.h/dma-contiguous.h/dma-mapping.h

All of these functions are not currently exported. Therefore define
equivalents which are exported in order to support fastmap as a module.

The atomic pool feature is copied as of
commit 3acac06550 ("dma-mapping: merge the generic remapping
helpers into dma-direct").
This commit was chosen instead of the below due to having a simpler
implementation.

The cma allocation functions and page remapping functions are copied from:
commit 9c16520a33 ("Merge 5.9-rc5 into android-mainline").

Change-Id: Ia629fdca7c220161c2ac1970c683be5b5ede08b5
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2020-10-28 22:57:30 -07:00
Patrick Daly
da98ecc064 qcom-iommu-util: Add qcom_iommu_get/put_resv_regions
Allow these functions to be used by modules.

Change-Id: I785826f77ee5bc5b4f9835467be7cdb3a55688f2
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2020-10-19 22:13:55 -07:00
Patrick Daly
644613be82 qcom_iommu_util: Add iommu utility functions
Qcom iommu drivers support a standard set of additional functionality
which lives outside of the iommu framework.

This patch only adds support for parsing the qcom,iommu-dma-addr-pool
dt property. Subsequent patches will add more features.

Change-Id: Idd8dc3d8c28cf9de0905809bfe7b205bbcb51aea
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
2020-10-19 22:13:53 -07:00