Re: [RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2020-02-24 Thread chao hao
On Sat, 2020-02-15 at 20:17 +0800, Yong Wu wrote: > On Tue, 2019-12-31 at 17:39 +0800, chao hao wrote: > > On Mon, 2019-12-16 at 20:13 +0800, Yong Wu wrote: > > > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > > > Start with this patch, we will change the SW architecture > > > > to support

Re: [linux-next/mainline][bisected 3acac06][ppc] Oops when unloading mpt3sas driver

2020-02-24 Thread Sreekanth Reddy via iommu
On Tue, Feb 25, 2020 at 11:51 AM Abdul Haleem wrote: > > On Fri, 2020-01-17 at 18:21 +0530, Abdul Haleem wrote: > > On Thu, 2020-01-16 at 09:44 -0800, Christoph Hellwig wrote: > > > Hi Abdul, > > > > > > I think the problem is that mpt3sas has some convoluted logic to do > > > some DMA

Re: [linux-next/mainline][bisected 3acac06][ppc] Oops when unloading mpt3sas driver

2020-02-24 Thread Abdul Haleem
On Fri, 2020-01-17 at 18:21 +0530, Abdul Haleem wrote: > On Thu, 2020-01-16 at 09:44 -0800, Christoph Hellwig wrote: > > Hi Abdul, > > > > I think the problem is that mpt3sas has some convoluted logic to do > > some DMA allocations with a 32-bit coherent mask, and then switches > > to a 63 or 64

[PATCH] MAINTAINERS: add maintainers for uacce

2020-02-24 Thread Zhangfei Gao
Add Zhangfei Gao and Zhou Wang as maintainers for uacce Signed-off-by: Zhangfei Gao Signed-off-by: Zhou Wang --- MAINTAINERS | 10 ++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 38fe2f3..22e647f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17039,6

Re: [PATCH v2] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-24 Thread Lu Baolu
Hi, On 2020/2/21 3:44, Yonghyun Hwang wrote: intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page onto its corresponding physical address. This commit fixes the bug by accomodating the level of page entry for the IOVA and adds IOVA's lower address to the physical

Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM

2020-02-24 Thread Jason Wang
On 2020/2/24 下午9:40, Michael S. Tsirkin wrote: Subject: [PATCH] vhost: do not set VIRTIO_F_IOMMU_PLATFORM when IOMMU is not used We enable device IOTLB unconditionally when VIRTIO_F_IOMMU_PLATFORM is negotiated. This lead unnecessary IOTLB miss/update transactions when IOMMU is used. This

Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM

2020-02-24 Thread Jason Wang
On 2020/2/24 下午9:56, Halil Pasic wrote: On Mon, 24 Feb 2020 17:26:20 +0800 Jason Wang wrote: That's better. How about attached? Thanks Thanks Jason! It does avoid the translation overhead in vhost. Tested-by: Halil Pasic Regarding the code, you fence it in virtio-net.c, but AFAIU this

Re: [PATCH v4 03/26] iommu: Add a page fault handler

2020-02-24 Thread Xu Zaibo
Hi, On 2020/2/25 2:23, Jean-Philippe Brucker wrote: From: Jean-Philippe Brucker Some systems allow devices to handle I/O Page Faults in the core mm. For example systems implementing the PCI PRI extension or Arm SMMU stall model. Infrastructure for reporting these recoverable page faults was

Re: [PATCH 1/2] iommu/vt-d: report SVA feature with generic flag

2020-02-24 Thread Jacob Pan
Please ignore this one, use "[PATCH 1/2] iommu/vt-d: Report SVA feature with generic flag" instead. Sorry about the noise. On Mon, 24 Feb 2020 15:26:35 -0800 Jacob Pan wrote: > Query Shared Virtual Address/Memory capability is a generic feature. > Report Intel SVM as SVA feature such that

[PATCH 1/2] iommu/vt-d: Report SVA feature with generic flag

2020-02-24 Thread Jacob Pan
Query Shared Virtual Address/Memory capability is a generic feature. SVA feature check is the required first step before calling iommu_sva_bind_device(). VT-d checks SVA feature enabling at per IOMMU level during this step, SVA bind device will check and enable PCI ATS, PRS, and PASID

[PATCH 2/2] iommu/vt-d: Replace intel SVM APIs with generic SVA APIs

2020-02-24 Thread Jacob Pan
This patch is an initial step to replace Intel SVM code with the following IOMMU SVA ops: intel_svm_bind_mm() => iommu_sva_bind_device() intel_svm_unbind_mm() => iommu_sva_unbind_device() intel_svm_is_pasid_valid() => iommu_sva_get_pasid() The features below will continue to work but are not

[PATCH 0/2] Replace Intel SVM with IOMMU SVA APIs

2020-02-24 Thread Jacob Pan
Shared virtual address (SVA) capable accelerator device drivers on Intel platform are required to call VT-d driver directly to bind a device with a given address space. It is conceptually incorrect with the following reasons: - A device driver is bypassing IOMMU generic layer - Device driver

[PATCH 1/2] iommu/vt-d: report SVA feature with generic flag

2020-02-24 Thread Jacob Pan
Query Shared Virtual Address/Memory capability is a generic feature. Report Intel SVM as SVA feature such that generic code such as Uacce [1] can use it. [1] https://lkml.org/lkml/2020/1/15/604 Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 5 + 1 file changed, 5 insertions(+)

Re: [PATCH V9 03/10] iommu/vt-d: Add nested translation helper function

2020-02-24 Thread Jacob Pan
Hi Eric, Appreciated your review. Comments below. On Wed, 12 Feb 2020 13:43:17 +0100 Auger Eric wrote: > Hi Jacob, > On 1/29/20 7:01 AM, Jacob Pan wrote: > > Nested translation mode is supported in VT-d 3.0 Spec.CH 3.8. > > With PASID granular translation type set to 0x11b, translation > >

[PATCH v3] iommu/arm-smmu-v3: Add SMMUv3.2 range invalidation support

2020-02-24 Thread Rob Herring
Arm SMMUv3.2 adds support for TLB range invalidate operations. Support for range invalidate is determined by the RIL bit in the IDR3 register. The range invalidate is in units of the leaf page size and operates on 1-32 chunks of a power of 2 multiple pages. First, we determine from the size what

Re: [PATCH 4/5] dma-direct: provide a arch_dma_clear_uncached hook

2020-02-24 Thread Christoph Hellwig
On Mon, Feb 24, 2020 at 01:53:28PM -0800, Ira Weiny wrote: > > + else if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CLEAR_UNCACHED)) > > + arch_dma_clear_uncached(cpu_addr, size); > > Isn't using arch_dma_clear_uncached() before patch 5 going to break > bisectability? Only if

Re: [PATCH 4/5] dma-direct: provide a arch_dma_clear_uncached hook

2020-02-24 Thread Ira Weiny
On Mon, Feb 24, 2020 at 11:44:44AM -0800, Christoph Hellwig wrote: > This allows the arch code to reset the page tables to cached access when > freeing a dma coherent allocation that was set to uncached using > arch_dma_set_uncached. > > Signed-off-by: Christoph Hellwig > --- > arch/Kconfig

[PATCH 2/5] dma-direct: consolidate the error handling in dma_direct_alloc_pages

2020-02-24 Thread Christoph Hellwig
Use a goto label to merge two error return cases. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index ac7956c38f69..9dfcc7be4903 100644 ---

[PATCH 3/5] dma-direct: make uncached_kernel_address more general

2020-02-24 Thread Christoph Hellwig
Rename the symbol to arch_dma_set_uncached, and pass a size to it as well as allow an error return. That will allow reusing this hook for in-place pagetable remapping. As the in-place remap doesn't always require an explicit cache flush, also detangle ARCH_HAS_DMA_PREP_COHERENT from

Re: [PATCH 2/2] openrisc: use the generic in-place uncached DMA allocator

2020-02-24 Thread Christoph Hellwig
On Sat, Feb 22, 2020 at 07:14:47AM +0900, Stafford Horne wrote: > On Thu, Feb 20, 2020 at 09:01:39AM -0800, Christoph Hellwig wrote: > > Switch openrisc to use the dma-direct allocator and just provide the > > hooks for setting memory uncached or cached. > > > > Signed-off-by: Christoph Hellwig

[PATCH 4/5] dma-direct: provide a arch_dma_clear_uncached hook

2020-02-24 Thread Christoph Hellwig
This allows the arch code to reset the page tables to cached access when freeing a dma coherent allocation that was set to uncached using arch_dma_set_uncached. Signed-off-by: Christoph Hellwig --- arch/Kconfig| 7 +++ include/linux/dma-noncoherent.h | 1 +

[PATCH 1/5] dma-direct: remove the cached_kernel_address hook

2020-02-24 Thread Christoph Hellwig
dma-direct now finds the kernel address for coherent allocations based on the dma address, so the cached_kernel_address hooks is unused and can be removed entirely. Signed-off-by: Christoph Hellwig --- arch/Kconfig| 2 +- arch/microblaze/mm/consistent.c | 7 ---

provide in-place uncached remapping for dma-direct v2

2020-02-24 Thread Christoph Hellwig
Hi all, this series provides support for remapping places uncached in-place in the generic dma-direct code, and moves openrisc over from its own in-place remapping scheme. The arm64 folks also had interest in such a scheme to avoid problems with speculating into cache aliases. Also all

[PATCH 5/5] openrisc: use the generic in-place uncached DMA allocator

2020-02-24 Thread Christoph Hellwig
Switch openrisc to use the dma-direct allocator and just provide the hooks for setting memory uncached or cached. Signed-off-by: Christoph Hellwig --- arch/openrisc/Kconfig | 2 ++ arch/openrisc/kernel/dma.c | 55 +++--- 2 files changed, 12 insertions(+),

Re: [PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-24 Thread Jason Gunthorpe
On Mon, Feb 24, 2020 at 07:23:36PM +0100, Jean-Philippe Brucker wrote: > The new allocation scheme introduced by 2c7933f53f6b ("mm/mmu_notifiers: > add a get/put scheme for the registration") provides a convenient way > for users to attach notifier data to an mm. However, it would be even > better

Re: [PATCH 2/2] virtio: let virtio use DMA API when guest RAM is protected

2020-02-24 Thread Halil Pasic
On Fri, 21 Feb 2020 17:36:45 +0100 Christoph Hellwig wrote: > > By "legacy devices" I assume you mean pre-virtio-1.0 devices, that > > lack the F_VERSION_1 feature flag. Is that right? Because I don't > > see how being a legacy device or not relates to use of the DMA API. > > No. "legacy"

Re: [PATCH 1/2] mm: move force_dma_unencrypted() to mem_encrypt.h

2020-02-24 Thread Halil Pasic
On Mon, 24 Feb 2020 14:33:14 +1100 David Gibson wrote: > On Fri, Feb 21, 2020 at 07:07:02PM +0100, Halil Pasic wrote: > > On Fri, 21 Feb 2020 10:48:15 -0500 > > "Michael S. Tsirkin" wrote: > > > > > On Fri, Feb 21, 2020 at 02:06:39PM +0100, Halil Pasic wrote: > > > > On Fri, 21 Feb 2020

[PATCH v4 22/26] dt-bindings: document stall property for IOMMU masters

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker On ARM systems, some platform devices behind an IOMMU may support stall, which is the ability to recover from page faults. Let the firmware tell us when a device supports stall. Reviewed-by: Rob Herring Signed-off-by: Jean-Philippe Brucker ---

[PATCH v4 24/26] PCI/ATS: Add PRI stubs

2020-02-24 Thread Jean-Philippe Brucker
The SMMUv3 driver, which can be built without CONFIG_PCI, will soon gain support for PRI. Partially revert commit c6e9aefbf9db ("PCI/ATS: Remove unused PRI and PASID stubs") to re-introduce the PRI stubs, and avoid adding more #ifdefs to the SMMU driver. Cc: Bjorn Helgaas Signed-off-by:

[PATCH v4 18/26] iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker The core calls us when an mm is modified. Perform the required ATC invalidations. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 44 - 1 file changed, 38 insertions(+), 6 deletions(-) diff --git

[PATCH v4 25/26] PCI/ATS: Export symbols of PRI functions

2020-02-24 Thread Jean-Philippe Brucker
The SMMUv3 driver uses pci_{enable,disable}_pri() and related functions. Export those functions to allow the driver to be built as a module. Cc: Bjorn Helgaas Signed-off-by: Jean-Philippe Brucker --- drivers/pci/ats.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/ats.c

[PATCH v4 23/26] iommu/arm-smmu-v3: Add stall support for platform devices

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker The SMMU provides a Stall model for handling page faults in platform devices. It is similar to PCI PRI, but doesn't require devices to have their own translation cache. Instead, faulting transactions are parked and the OS is given a chance to fix the page tables and

[PATCH v4 15/26] iommu/arm-smmu-v3: Add SVA feature checking

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker Aggregate all sanity-checks for sharing CPU page tables with the SMMU under a single ARM_SMMU_FEAT_SVA bit. For PCIe SVA, users also need to check FEAT_ATS and FEAT_PRI. For platform SVA, they will most likely have to check FEAT_STALLS. Signed-off-by: Jean-Philippe

[PATCH v4 21/26] iommu/arm-smmu-v3: Ratelimit event dump

2020-02-24 Thread Jean-Philippe Brucker
When a device or driver misbehaves, it is possible to receive events much faster than we can print them out. Ratelimit the printing of events. Signed-off-by: Jean-Philippe Brucker --- During the SVA tests when the device driver didn't properly stop DMA before unbinding, the event queue thread

[PATCH v4 14/26] iommu/arm-smmu-v3: Enable broadcast TLB maintenance

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker The SMMUv3 can handle invalidation targeted at TLB entries with shared ASIDs. If the implementation supports broadcast TLB maintenance, enable it and keep track of it in a feature bit. The SMMU will then be affected by inner-shareable TLB invalidations from other

[PATCH v4 26/26] iommu/arm-smmu-v3: Add support for PRI

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker For PCI devices that support it, enable the PRI capability and handle PRI Page Requests with the generic fault handler. It is enabled on demand by iommu_sva_device_init(). Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 278

[PATCH v4 20/26] iommu/arm-smmu-v3: Maintain a SID->device structure

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 177 +--- 1 file

[PATCH v4 19/26] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. We can enable HTTU even if CPUs don't support it,

[PATCH v4 06/26] iommu/sva: Register page fault handler

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker When enabling SVA, register the fault handler. Device driver will register an I/O page fault queue before or after calling iommu_sva_enable. The fault queue must be flushed before any io_mm is freed, to make sure that its PASID isn't used in any fault queue, and can

[PATCH v4 01/26] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-02-24 Thread Jean-Philippe Brucker
The new allocation scheme introduced by 2c7933f53f6b ("mm/mmu_notifiers: add a get/put scheme for the registration") provides a convenient way for users to attach notifier data to an mm. However, it would be even better to create this notifier data atomically. Since the alloc_notifier() callback

[PATCH v4 16/26] iommu/arm-smmu-v3: Add dev_to_master() helper

2020-02-24 Thread Jean-Philippe Brucker
We'll need to frequently find the SMMU master associated to a device when implementing SVA. Move it to a separate function. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git

[PATCH v4 03/26] iommu: Add a page fault handler

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker Some systems allow devices to handle I/O Page Faults in the core mm. For example systems implementing the PCI PRI extension or Arm SMMU stall model. Infrastructure for reporting these recoverable page faults was recently added to the IOMMU core. Add a page fault

[PATCH v4 13/26] iommu/arm-smmu-v3: Add support for VHE

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker ARMv8.1 extensions added Virtualization Host Extensions (VHE), which allow to run a host kernel at EL2. When using normal DMA, Device and CPU address spaces are dissociated, and do not need to implement the same capabilities, so VHE hasn't been used in the SMMU until

[PATCH v4 09/26] iommu/arm-smmu-v3: Manage ASIDs with xarray

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker In preparation for sharing some ASIDs with the CPU, use a global xarray to store ASIDs and their context. ASID#1 is not reserved, and the ASID space is global. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 27 ++- 1

[PATCH v4 17/26] iommu/arm-smmu-v3: Implement mm operations

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker Hook SVA operations to support sharing page tables with the SMMUv3: * dev_enable/disable/has_feature for device drivers to modify the SVA state. * sva_bind/unbind and sva_get_pasid to bind device and address spaces. * The mm_attach/detach/invalidate/free callbacks

[PATCH v4 00/26] iommu: Shared Virtual Addressing and SMMUv3 support

2020-02-24 Thread Jean-Philippe Brucker
Shared Virtual Addressing (SVA) allows to share process page tables with devices using the IOMMU. Add a generic implementation of the IOMMU SVA API, and add support in the Arm SMMUv3 driver. Previous versions of this patchset were sent over a year ago [1][2] but we've made a lot of progress since

[PATCH v4 12/26] iommu/arm-smmu-v3: Seize private ASID

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker The SMMU has a single ASID space, the union of shared and private ASID sets. This means that the SMMU driver competes with the arch allocator for ASIDs. Shared ASIDs are those of Linux processes, allocated by the arch, and contribute in broadcast TLB maintenance.

[PATCH v4 10/26] arm64: cpufeature: Export symbol read_sanitised_ftr_reg()

2020-02-24 Thread Jean-Philippe Brucker
The SMMUv3 driver would like to read the MMFR0 PARANGE field in order to share CPU page tables with devices. Allow the driver to be built as module by exporting the read_sanitized_ftr_reg() cpufeature symbol. Signed-off-by: Jean-Philippe Brucker --- arch/arm64/kernel/cpufeature.c | 1 + 1 file

[PATCH v4 07/26] arm64: mm: Pin down ASIDs for sharing mm with devices

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker To enable address space sharing with the IOMMU, introduce mm_context_get() and mm_context_put(), that pin down a context and ensure that it will keep its ASID after a rollover. Export the symbols to let the modular SMMUv3 driver use them. Pinning is necessary because

[PATCH v4 02/26] iommu/sva: Manage process address spaces

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker Add a small library to help IOMMU drivers manage process address spaces bound to their devices. Register an MMU notifier to track modification on each address space bound to one or more devices. IOMMU drivers must implement the io_mm_ops and can then use the helpers

[PATCH v4 08/26] iommu/io-pgtable-arm: Move some definitions to a header

2020-02-24 Thread Jean-Philippe Brucker
Extract some of the most generic TCR defines, so they can be reused by the page table sharing code. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/io-pgtable-arm.c | 27 ++- drivers/iommu/io-pgtable-arm.h | 30 ++ 2 files changed, 32

[PATCH v4 11/26] iommu/arm-smmu-v3: Share process page tables

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker With Shared Virtual Addressing (SVA), we need to mirror CPU TTBR, TCR, MAIR and ASIDs in SMMU contexts. Each SMMU has a single ASID space split into two sets, shared and private. Shared ASIDs correspond to those obtained from the arch ASID allocator, and private ASIDs

[PATCH v4 05/26] iommu/iopf: Handle mm faults

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker When a recoverable page fault is handled by the fault workqueue, find the associated mm and call handle_mm_fault. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/io-pgfault.c | 86 +- 1 file changed, 84 insertions(+), 2

[PATCH v4 04/26] iommu/sva: Search mm by PASID

2020-02-24 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker The fault handler will need to find an mm given its PASID. This is the reason we have an IDR for storing address spaces, so hook it up. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/iommu-sva.c | 19 +++ include/linux/iommu.h | 9

Re: [PATCH v12 2/4] uacce: add uacce driver

2020-02-24 Thread Raj, Ashok
Hi Kenneth, sorry for waking up late on this patchset. On Wed, Jan 15, 2020 at 10:12:46PM +0800, Zhangfei Gao wrote: [... trimmed] > + > +static int uacce_fops_open(struct inode *inode, struct file *filep) > +{ > + struct uacce_mm *uacce_mm = NULL; > + struct uacce_device *uacce; > +

Re: [PATCH 2/2] virtio: let virtio use DMA API when guest RAM is protected

2020-02-24 Thread Christoph Hellwig
On Sat, Feb 22, 2020 at 02:07:58PM -0500, Michael S. Tsirkin wrote: > On Fri, Feb 21, 2020 at 03:33:40PM +0100, Halil Pasic wrote: > > AFAIU you have a positive attitude towards the idea, that > > !F_VIRTIO_PLATFORM implies 'no DMA API is used by virtio' > > should be scrapped. > > > > I would

[PATCH v2 4/6] iommu/arm-smmu-v3: Add command queue batching helpers

2020-02-24 Thread Jean-Philippe Brucker
As more functions will implement command queue batching, add two helpers to simplify building a command list. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 37 ++--- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git

[PATCH v2 6/6] iommu/arm-smmu-v3: Batch ATC invalidation commands

2020-02-24 Thread Jean-Philippe Brucker
From: Rob Herring Similar to commit 2af2e72b18b4 ("iommu/arm-smmu-v3: Defer TLB invalidation until ->iotlb_sync()"), build up a list of ATC invalidation commands and submit them all at once to the command queue instead of one-by-one. As there is only one caller of arm_smmu_atc_inv_master()

[PATCH v2 2/6] iommu/arm-smmu-v3: Add support for PCI PASID

2020-02-24 Thread Jean-Philippe Brucker
Enable PASID for PCI devices that support it. Initialize PASID early in add_device() because it must be enabled before ATS. Tested-by: Zhangfei Gao Reviewed-by: Jonathan Cameron Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 62 - 1

[PATCH v2 1/6] PCI/ATS: Export symbols of PASID functions

2020-02-24 Thread Jean-Philippe Brucker
The Arm SMMUv3 driver uses pci_{enable,disable}_pasid() and related functions. Export them to allow the driver to be built as a module. Signed-off-by: Jean-Philippe Brucker --- drivers/pci/ats.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index

[PATCH v2 0/6] iommu/arm-smmu-v3: Finish PASID support and command queue batching

2020-02-24 Thread Jean-Philippe Brucker
Finish off PASID support for SMMUv3, and batch command queue. Since v1 [1]: * Added patch 4 to factor command queue batching * Included patch 6 from Rob [2] [1] https://lore.kernel.org/linux-iommu/20200213101435.229932-1-jean-phili...@linaro.org/ [2]

[PATCH v2 5/6] iommu/arm-smmu-v3: Batch context descriptor invalidation

2020-02-24 Thread Jean-Philippe Brucker
Rather than publishing one command at a time when invalidating a context descriptor, batch the commands for all SIDs in the domain. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git

[PATCH v2 3/6] iommu/arm-smmu-v3: Write level-1 descriptors atomically

2020-02-24 Thread Jean-Philippe Brucker
Use WRITE_ONCE() to make sure that the SMMU doesn't read incomplete stream table descriptors. Refer to the comment about 64-bit accesses, and add the comment to the equivalent context descriptor code. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 4 +++- 1 file changed,

Re: [PATCH v2] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-24 Thread Lu Baolu
Hi Joerg and Yonghyun, I found a problem in the test. I am still working on this. Please hold on for a while. Best regards, baolu On 2020/2/22 21:05, Lu Baolu wrote: Hi, On 2020/2/21 3:44, Yonghyun Hwang wrote: intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page

Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM

2020-02-24 Thread Halil Pasic
On Mon, 24 Feb 2020 17:26:20 +0800 Jason Wang wrote: > That's better. > > How about attached? > > Thanks Thanks Jason! It does avoid the translation overhead in vhost. Tested-by: Halil Pasic Regarding the code, you fence it in virtio-net.c, but AFAIU this feature has relevance for other

Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM

2020-02-24 Thread Michael S. Tsirkin
On Mon, Feb 24, 2020 at 05:26:20PM +0800, Jason Wang wrote: > > On 2020/2/24 下午3:48, Michael S. Tsirkin wrote: > > On Mon, Feb 24, 2020 at 02:45:03PM +0800, Jason Wang wrote: > > > On 2020/2/24 下午2:06, Michael S. Tsirkin wrote: > > > > On Mon, Feb 24, 2020 at 12:01:57PM +0800, Jason Wang wrote: >

Re: [RFC PATCH 01/11] vfio: Remove Calxeda XGMAC reset driver

2020-02-24 Thread Auger Eric
Hi Rob, Alex, On 2/18/20 6:13 PM, Rob Herring wrote: > Cc: Eric Auger > Cc: Alex Williamson > Cc: Cornelia Huck > Cc: k...@vger.kernel.org > Signed-off-by: Rob Herring > --- > Do not apply yet. > > drivers/vfio/platform/reset/Kconfig | 8 -- > drivers/vfio/platform/reset/Makefile

Re: [PATCH v2] iommu/arm-smmu-v3: Add SMMUv3.2 range invalidation support

2020-02-24 Thread Auger Eric
Hi Rob, On 2/13/20 8:54 PM, Rob Herring wrote: > On Thu, Jan 30, 2020 at 9:06 AM Auger Eric wrote: >> >> Hi Rob, >> On 1/17/20 10:16 PM, Rob Herring wrote: >>> Arm SMMUv3.2 adds support for TLB range invalidate operations. >>> Support for range invalidate is determined by the RIL bit in the IDR3

Re: [PATCH 0/2] virtio: decouple protected guest RAM form VIRTIO_F_IOMMU_PLATFORM

2020-02-24 Thread Jason Wang
On 2020/2/24 下午3:48, Michael S. Tsirkin wrote: On Mon, Feb 24, 2020 at 02:45:03PM +0800, Jason Wang wrote: On 2020/2/24 下午2:06, Michael S. Tsirkin wrote: On Mon, Feb 24, 2020 at 12:01:57PM +0800, Jason Wang wrote: On 2020/2/21 下午10:56, Halil Pasic wrote: On Fri, 21 Feb 2020 14:22:26 +0800

RE: [PATCH V2 3/5] iommu: Add support to change default domain of an iommu_group

2020-02-24 Thread Prakhya, Sai Praneeth
> On 2020/2/24 16:12, Lu Baolu wrote: > > On 2020/2/24 15:57, Prakhya, Sai Praneeth wrote: > >>> On 2020/2/24 15:03, Prakhya, Sai Praneeth wrote: > > On 2020/2/24 11:20, Prakhya, Sai Praneeth wrote: > +    list_for_each_entry_safe(grp_dev, temp, >devices, > list) { >

Re: [PATCH V2 3/5] iommu: Add support to change default domain of an iommu_group

2020-02-24 Thread Lu Baolu
On 2020/2/24 16:12, Lu Baolu wrote: On 2020/2/24 15:57, Prakhya, Sai Praneeth wrote: On 2020/2/24 15:03, Prakhya, Sai Praneeth wrote: On 2020/2/24 11:20, Prakhya, Sai Praneeth wrote: +    list_for_each_entry_safe(grp_dev, temp, >devices, list) { +    struct device *dev; + +    dev =

Re: [PATCH V2 3/5] iommu: Add support to change default domain of an iommu_group

2020-02-24 Thread Lu Baolu
On 2020/2/24 15:57, Prakhya, Sai Praneeth wrote: On 2020/2/24 15:03, Prakhya, Sai Praneeth wrote: On 2020/2/24 11:20, Prakhya, Sai Praneeth wrote: + list_for_each_entry_safe(grp_dev, temp, >devices, list) { + struct device *dev; + + dev = grp_dev->dev; +