[PATCH 05/10] iommu/ioasid: Create an IOASID set for host SVA use

2020-03-25 Thread Jacob Pan
Bare metal SVA allocates IOASIDs for native process addresses. This should be separated from VM allocated IOASIDs thus under its own set. This patch creates a system IOASID set with its quota set to PID_MAX. This is a reasonable default in that SVM capable devices can only bind to limited user

[PATCH 08/10] iommu/ioasid: Introduce notifier APIs

2020-03-25 Thread Jacob Pan
IOASID users fit into the publisher-subscriber pattern, a system wide blocking notifier chain can be used to inform subscribers of state changes. Notifier mechanism also abstracts publisher from knowing the private context each subcriber may have. This patch adds APIs and a global notifier chain,

[PATCH 04/10] iommu/ioasid: Rename ioasid_set_data to avoid confusion with ioasid_set

2020-03-25 Thread Jacob Pan
IOASID set refers to a group of IOASIDs that shares the same token. ioasid_set_data() function is used to attach a private data to an IOASID, rename it to ioasid_attach_data() avoid being confused with the group/set concept. Signed-off-by: Jacob Pan --- drivers/iommu/intel-svm.c | 11

[PATCH 10/10] iommu/vt-d: Register PASID notifier for status change

2020-03-25 Thread Jacob Pan
In bare metal SVA, IOMMU driver ensures that IOASID free call always comes after IOASID unbind operation. However, for guest SVA the unbind and free call come from user space via VFIO, which could be out of order. This patch registers a notifier block in case IOASID free() comes before unbind

[PATCH 00/10] IOASID extensions for guest SVA

2020-03-25 Thread Jacob Pan
IOASID was introduced in v5.5 as a generic kernel allocator service for both PCIe Process Address Space ID (PASID) and ARM SMMU's Sub Stream ID. In addition to basic ID allocation, ioasid_set was introduced as a token that is shared by a group of IOASIDs. This set token can be used for permission

[PATCH 03/10] iommu/ioasid: Introduce per set allocation APIs

2020-03-25 Thread Jacob Pan
IOASID set defines a group of IDs that share the same token. The ioasid_set concept helps to do permission checking among users as in the current code. With guest SVA usage, each VM has its own IOASID set. More functionalities are needed: 1. Enforce quota, each guest may be assigned limited quota

[PATCH 06/10] iommu/ioasid: Convert to set aware allocations

2020-03-25 Thread Jacob Pan
The current ioasid_alloc function takes a token/ioasid_set then record it on the IOASID being allocated. There is no alloc/free on the ioasid_set. With the IOASID set APIs, callers must allocate an ioasid_set before allocate IOASIDs within the set. Quota and other ioasid_set level activities can

[PATCH 07/10] iommu/ioasid: Use mutex instead of spinlock

2020-03-25 Thread Jacob Pan
Each IOASID or set could have multiple users with its own HW context to maintain. Often times access to the HW context requires thread context. For example, consumers of IOASIDs can register notification blocks to sync up its states. Having an atomic notifier is not feasible for these update

[PATCH 02/10] iommu/vt-d: Set IOASID capacity when SVM is enabled

2020-03-25 Thread Jacob Pan
Assign system-wide PASID capacity with enumerated max value. Currently, all Intel SVM capable devices should support full 20 bits of PASID value. Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/intel-iommu.c

[PATCH 09/10] iommu/ioasid: Support ioasid_set quota adjustment

2020-03-25 Thread Jacob Pan
IOASID set is allocated with an initial quota, at runtime there may be needs to balance IOASID resources among different VMs/sets. This patch adds a new API to adjust per set quota. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 44

[PATCH 01/10] iommu/ioasid: Introduce system-wide capacity

2020-03-25 Thread Jacob Pan
IOASID is a limited system-wide resource that can be allocated at runtime. This limitation can be enumerated during boot. For example, on x86 platforms, PCI Process Address Space ID (PASID) allocation uses IOASID service. The number of supported PASID bits are enumerated by extended capability

Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure implementation

2020-03-25 Thread Laurentiu Tudor
Hi Lorenzo, On 3/25/2020 2:51 PM, Lorenzo Pieralisi wrote: > On Thu, Feb 27, 2020 at 12:05:39PM +0200, laurentiu.tu...@nxp.com wrote: >> From: Laurentiu Tudor >> >> The devices on this bus are not discovered by way of device tree >> but by queries to the firmware. It makes little sense to trick

[PATCH v2 0/3] IOMMU user API enhancement

2020-03-25 Thread Jacob Pan
IOMMU user API header was introduced to support nested DMA translation and related fault handling. The current UAPI data structures consist of three areas that cover the interactions between host kernel and guest: - fault handling - cache invalidation - bind guest page tables, i.e. guest PASID

[PATCH v2 3/3] iommu/uapi: Add helper function for size lookup

2020-03-25 Thread Jacob Pan
IOMMU UAPI can be extended in the future by adding new fields at the end of each user data structure. Since we use a unified UAPI version for compatibility checking, a lookup function is needed to find the correct user data size to copy from user. This patch adds a helper function based on a 2D

[PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-03-25 Thread Jacob Pan
Having a single UAPI version to govern the user-kernel data structures makes compatibility check straightforward. On the contrary, supporting combinations of multiple versions of the data can be a nightmare to maintain. This patch defines a unified UAPI version to be used for compatibility checks

[PATCH v2 2/3] iommu/uapi: Use unified UAPI version

2020-03-25 Thread Jacob Pan
Reuse UAPI version for each UAPI data structure. This is to avoid supporting multiple version combinations, simplify support model as we bump up the versions. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 3 ++- drivers/iommu/intel-svm.c | 2 +-

Re: [PATCH] iommu/virtio: Reject IOMMU page granule larger than PAGE_SIZE

2020-03-25 Thread Auger Eric
Hi Jean, On 3/18/20 12:40 PM, Jean-Philippe Brucker wrote: > We don't currently support IOMMUs with a page granule larger than the > system page size. The IOVA allocator has a BUG_ON() in this case, and > VFIO has a WARN_ON(). > > It might be possible to remove these obstacles if necessary. If

Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device

2020-03-25 Thread Alexey Kardashevskiy
On 25/03/2020 19:37, Christoph Hellwig wrote: > On Wed, Mar 25, 2020 at 03:51:36PM +1100, Alexey Kardashevskiy wrote: This is for persistent memory which you can DMA to/from but yet it does not appear in the system as a normal memory and therefore requires special handling anyway

Re: [PATCH 03/10] iommu/ioasid: Introduce per set allocation APIs

2020-03-25 Thread Lu Baolu
On 2020/3/26 1:55, Jacob Pan wrote: IOASID set defines a group of IDs that share the same token. The ioasid_set concept helps to do permission checking among users as in the current code. With guest SVA usage, each VM has its own IOASID set. More functionalities are needed: 1. Enforce quota,

[PATCH RESEND] iommu/arm-smmu: Refactor master_cfg/fwspec usage

2020-03-25 Thread Robin Murphy
In preparation for restructuring iommu_fwspec, refactor the way we access the arm_smmu_master_cfg private data to be less dependent on the current layout. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu.c | 42 +--- 1 file changed, 22 insertions(+), 20

Re: arm-smmu-v3 high cpu usage for NVMe

2020-03-25 Thread John Garry
FWIW I believe is is still on the plan for someone here to dust off the PMU pNMI patches at some point. Cool. Well I can try to experiment with what Julien had at v4 for now. JFYI, I have done some more perf record capturing, and updated the "annotate" and "report" output here

Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure implementation

2020-03-25 Thread Lorenzo Pieralisi
On Thu, Feb 27, 2020 at 12:05:39PM +0200, laurentiu.tu...@nxp.com wrote: > From: Laurentiu Tudor > > The devices on this bus are not discovered by way of device tree > but by queries to the firmware. It makes little sense to trick the > generic of layer into thinking that these devices are of

Re: [PATCH v3 10/15] iommu/arm-smmu: Use accessor functions for iommu private data

2020-03-25 Thread Robin Murphy
On 2020-03-24 10:08 am, Joerg Roedel wrote: Hey Robin, On Mon, Mar 23, 2020 at 04:02:33PM +, Robin Murphy wrote: Yikes, this ends up pretty ugly, and I'd prefer not have this much complexity hidden in macros that were intended just to be convenient shorthand. Would you mind pulling in the

Re: [PATCH 1/2] dma-mapping: add a dma_ops_bypass flag to struct device

2020-03-25 Thread Christoph Hellwig
On Wed, Mar 25, 2020 at 03:51:36PM +1100, Alexey Kardashevskiy wrote: > >> This is for persistent memory which you can DMA to/from but yet it does > >> not appear in the system as a normal memory and therefore requires > >> special handling anyway (O_DIRECT or DAX, I do not know the exact > >>