[RFC PATCH v2 10/10] vfio/type1: Attach domain for mdev group

2018-08-29 Thread Lu Baolu
When attaching domain to a group of mediated devices which all have the domain type attributes set to ATTACH_PARENT, we should attach domain to the parent PCI device instead of mdev device itself. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar

[RFC PATCH v2 06/10] iommu/vt-d: Return ID associated with an auxiliary domain

2018-08-29 Thread Lu Baolu
This adds support to return the default pasid associated with an auxiliary domain. The PCI device which is bound with this domain should use this value as the pasid for all DMA requests of the subset of device which is isolated and protected with this domain. Cc: Ashok Raj Cc: Jacob Pan Cc:

[RFC PATCH v2 07/10] vfio/mdev: Add mediated device domain type

2018-08-29 Thread Lu Baolu
A parent device might create different types of mediated devices. For example, a mediated device could be created by the parent device with full isolation and protection provided by the IOMMU. One usage case could be found on Intel platforms where a mediated device is an assignable subset of a

[RFC PATCH v2 09/10] vfio/type1: Determine domain type of an mdev group

2018-08-29 Thread Lu Baolu
This adds the support to determine the domain type of a group of mediated devices according to the domain type attribute of each device. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 47

[RFC PATCH v2 08/10] vfio/type1: Add domain at(de)taching group helpers

2018-08-29 Thread Lu Baolu
If a domain is attaching to a group which includes the mediated devices, it should attach to the mdev parent of each mdev. This adds a helper for attaching domain to group, no matter a PCI physical device or mediated devices which are derived from a PCI physical device. Cc: Ashok Raj Cc: Jacob

[RFC PATCH v2 05/10] iommu/vt-d: Attach/detach domains in auxiliary mode

2018-08-29 Thread Lu Baolu
When multiple domains per device has been enabled by the device driver, the device will tag the default PASID for the domain to all DMA traffics out of the subset of this device; and the IOMMU should translate the DMA requests in PASID granularity. This extends the

[RFC PATCH v2 04/10] iommu/vt-d: Enable/disable multiple domains per device

2018-08-29 Thread Lu Baolu
Add iommu ops for enabling and disabling multiple domains for a device. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 36 include/linux/intel-iommu.h | 1 + 2 files changed, 37

[RFC PATCH v2 03/10] iommu/amd: Add default branch in amd_iommu_capable()

2018-08-29 Thread Lu Baolu
Otherwise, there will be a build warning: drivers/iommu/amd_iommu.c:3083:2: warning: enumeration value 'IOMMU_CAP_AUX_DOMAIN' not handled in switch [-Wswitch] There is no functional change. Signed-off-by: Lu Baolu --- drivers/iommu/amd_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff

[RFC PATCH v2 01/10] iommu: Add APIs for multiple domains per device

2018-08-29 Thread Lu Baolu
Sharing a physical PCI device in a finer-granularity way is becoming a consensus in the industry. IOMMU vendors are also engaging efforts to support such sharing as well as possible. Among the efforts, the capability of support finer-granularity DMA isolation is a common requirement due to the

[RFC PATCH v2 00/10] vfio/mdev: IOMMU aware mediated device

2018-08-29 Thread Lu Baolu
Hi, The Mediate Device is a framework for fine-grained physical device sharing across the isolated domains. Currently the mdev framework is designed to be independent of the platform IOMMU support. As the result, the DMA isolation relies on the mdev parent device in a vendor specific way. There

[RFC PATCH v2 02/10] iommu/vt-d: Add multiple domains per device query

2018-08-29 Thread Lu Baolu
Add the response to IOMMU_CAP_AUX_DOMAIN capability query through iommu_capable(). Return true if IOMMUs support the scalable mode, return false otherwise. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-iommu.c | 31

[PATCH v2 12/12] iommu/vt-d: Remove deferred invalidation

2018-08-29 Thread Lu Baolu
Deferred invalidation is an ECS specific feature. It will not be supported when IOMMU works in scalable mode. As we deprecated the ECS support, remove deferred invalidation and cleanup the code. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu Reviewed-by:

[PATCH v2 11/12] iommu/vt-d: Shared virtual address in scalable mode

2018-08-29 Thread Lu Baolu
This patch enables the current SVA (Shared Virtual Address) implementation to work in the scalable mode. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-iommu.c | 40

[PATCH v2 10/12] iommu/vt-d: Add first level page table interface

2018-08-29 Thread Lu Baolu
This adds the interfaces to setup or tear down the structures for first level page table translation. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-pasid.c | 89

[PATCH v2 09/12] iommu/vt-d: Setup context and enable RID2PASID support

2018-08-29 Thread Lu Baolu
This patch enables the translation for requests without PASID in the scalable mode by setting up the root and context entries. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-iommu.c

[PATCH v2 08/12] iommu/vt-d: Pass pasid table to context mapping

2018-08-29 Thread Lu Baolu
So that the pasid related info, such as the pasid table and the maximum of pasid could be used during setting up scalable mode context. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-iommu.c | 14 +++---

[PATCH v2 07/12] iommu/vt-d: Setup pasid entry for RID2PASID support

2018-08-29 Thread Lu Baolu
when the scalable mode is enabled, there is no second level page translation pointer in the context entry any more (for DMA request without PASID). Instead, a new RID2PASID field is introduced in the context entry. Software can choose any PASID value to set RID2PASID and then setup the translation

[PATCH v2 05/12] iommu/vt-d: Reserve a domain id for FL and PT modes

2018-08-29 Thread Lu Baolu
Vt-d spec rev3.0 (section 6.2.3.1) requires that each pasid entry for first-level or pass-through translation should be programmed with a domain id different from those used for second-level or nested translation. It is recommended that software could use a same domain id for all first-only and

[PATCH v2 06/12] iommu/vt-d: Add second level page table interface

2018-08-29 Thread Lu Baolu
This adds the interfaces to setup or tear down the structures for second level page table translations. This includes types of second level only translation and pass through. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Sanjay Kumar Signed-off-by: Lu Baolu

[PATCH v2 03/12] iommu/vt-d: Move page table helpers into header

2018-08-29 Thread Lu Baolu
So that they could also be used in other source files. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Cc: Liu Yi L Signed-off-by: Lu Baolu Reviewed-by: Ashok Raj --- drivers/iommu/intel-iommu.c | 43 - include/linux/intel-iommu.h | 43

[PATCH v2 02/12] iommu/vt-d: Manage scalalble mode PASID tables

2018-08-29 Thread Lu Baolu
In scalable mode, pasid structure is a two level table with a pasid directory table and a pasid table. Any pasid entry can be identified by a pasid value in below way. 1 9 6 5 0 .---.---. | PASID| |

[PATCH v2 04/12] iommu/vt-d: Add 256-bit invalidation descriptor support

2018-08-29 Thread Lu Baolu
Intel vt-d spec rev3.0 requires software to use 256-bit descriptors in invalidation queue. As the spec reads in section 6.5.2: Remapping hardware supporting Scalable Mode Translations (ECAP_REG.SMTS=1) allow software to additionally program the width of the descriptors (128-bits or 256-bits) that

[PATCH v2 00/12] iommu/vt-d: Add scalable mode support

2018-08-29 Thread Lu Baolu
Hi, Intel vt-d rev3.0 [1] introduces a new translation mode called 'scalable mode', which enables PASID-granular translations for first level, second level, nested and pass-through modes. The vt-d scalable mode is the key ingredient to enable Scalable I/O Virtualization (Scalable IOV) [2] [3],

[PATCH v2 01/12] iommu/vt-d: Enumerate the scalable mode capability

2018-08-29 Thread Lu Baolu
The Intel vt-d spec rev3.0 introduces a new translation mode called scalable mode, which enables PASID-granular translations for first level, second level, nested and pass-through modes. At the same time, the previous Extended Context (ECS) mode is deprecated (no production ever implements ECS).

Re: [Patch v15 4/5] dt-bindings: arm-smmu: Add bindings for qcom, smmu-v2

2018-08-29 Thread Rob Herring
On Wed, Aug 29, 2018 at 6:23 AM Vivek Gautam wrote: > > On Wed, Aug 29, 2018 at 2:05 PM Vivek Gautam > wrote: > > > > Hi Rob, > > > > > > On 8/29/2018 2:04 AM, Rob Herring wrote: > > > On Mon, Aug 27, 2018 at 04:25:50PM +0530, Vivek Gautam wrote: > > >> Add bindings doc for Qcom's smmu-v2

Re: various dma_mask fixups

2018-08-29 Thread Guenter Roeck
On Wed, Aug 29, 2018 at 08:23:58AM +0200, Christoph Hellwig wrote: > Fix warnings and regressions from requiring a dma mask. With this series applied, I see the following in my sh4 boot tests. sb 1-1: new full-speed USB device number 2 using sm501-usb sm501-usb sm501-usb: OHCI Unrecoverable

[PATCH] dma-mapping: fix return type of dma_set_max_seg_size()

2018-08-29 Thread Niklas Söderlund
The function dma_set_max_seg_size() can return either 0 on success or -EIO on error. Change its return type from unsigned int to int to capture this. Signed-off-by: Niklas Söderlund --- include/linux/dma-mapping.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git

Re: [PATCH 1/2] kernel/dma/direct: take DMA offset into account in dma_direct_supported

2018-08-29 Thread Christoph Hellwig
On Fri, Aug 24, 2018 at 12:11:23PM +0100, Robin Murphy wrote: > On 24/08/18 07:53, Christoph Hellwig wrote: >> When a device has a DMA offset the dma capable result will change due >> to the difference between the physical and DMA address. Take that into >> account. > > The "phys_to_dma(...,

Re: [Patch v15 4/5] dt-bindings: arm-smmu: Add bindings for qcom, smmu-v2

2018-08-29 Thread Vivek Gautam
On Wed, Aug 29, 2018 at 2:05 PM Vivek Gautam wrote: > > Hi Rob, > > > On 8/29/2018 2:04 AM, Rob Herring wrote: > > On Mon, Aug 27, 2018 at 04:25:50PM +0530, Vivek Gautam wrote: > >> Add bindings doc for Qcom's smmu-v2 implementation. > >> > >> Signed-off-by: Vivek Gautam > >> Reviewed-by: Tomasz

Re: [Patch v15 4/5] dt-bindings: arm-smmu: Add bindings for qcom,smmu-v2

2018-08-29 Thread Vivek Gautam
Hi Rob, On 8/29/2018 2:04 AM, Rob Herring wrote: On Mon, Aug 27, 2018 at 04:25:50PM +0530, Vivek Gautam wrote: Add bindings doc for Qcom's smmu-v2 implementation. Signed-off-by: Vivek Gautam Reviewed-by: Tomasz Figa Tested-by: Srinivas Kandagatla --- Changes since v14: - This is a new

Re: various dma_mask fixups

2018-08-29 Thread Linus Walleij
On Wed, Aug 29, 2018 at 8:24 AM Christoph Hellwig wrote: > Fix warnings and regressions from requiring a dma mask. Applied all three patches and took a few ARM systems for a test ride: Tested-by: Linus Walleij Yours, Linus Walleij ___ iommu mailing

[PATCH 1/3] driver core: initialize a default DMA mask for platform device

2018-08-29 Thread Christoph Hellwig
We still treat devices without a DMA mask as defaulting to 32-bits for both mask, but a few releases ago we've started warning about such cases, as they require special cases to work around this sloppyness. Add a dma_mask field to struct platform_object so that we can initialize the dma_mask

various dma_mask fixups

2018-08-29 Thread Christoph Hellwig
Fix warnings and regressions from requiring a dma mask. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH 3/3] of/platform: initialise AMBA default DMA masks

2018-08-29 Thread Christoph Hellwig
From: Linus Walleij commit a5516219b102 ("of/platform: Initialise default DMA masks") sets up the coherent_dma_mask of platform devices created from the device tree, but fails to do the same for AMBA (PrimeCell) devices. This leads to a regression in kernel v4.19-rc1 triggering the

[PATCH 2/3] sparc: set a default 32-bit dma mask for OF devices

2018-08-29 Thread Christoph Hellwig
This keeps the historic default behavior for devices without a DMA mask, but removes the warning about a lacking DMA mask for doing DMA without a mask. Reported-by: Meelis Roos Tested-by: Meelis Roos Signed-off-by: Christoph Hellwig --- arch/sparc/kernel/of_device_32.c | 5 +