Re: [PATCH v7 3/7] vfio/type1: specialize remove_dma and replay according to type

2016-04-19 Thread kbuild test robot
Hi, [auto build test ERROR on iommu/next] [also build test ERROR on v4.6-rc4 next-20160419] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Eric-Auger/KVM-PCIe-MSI-passthrough-on-ARM-ARM64

Re: [PATCH 0/6 v2] of: Implement iterator for phandles

2016-04-19 Thread Rob Herring
On Mon, Apr 4, 2016 at 10:49 AM, Joerg Roedel wrote: > Hi, > > here is a new version of the implementation of the iterator > over phandles concept which Rob Herring suggested to me some > time ago. My approach is a little bit different from what > the diff showed back then, but it gets rid of the

Re: [PATCH v3 0/7] Intel IOMMU scalability improvements

2016-04-19 Thread Benjamin Serebrin via iommu
On Tue, Apr 19, 2016 at 1:47 PM, Shaohua Li wrote: > On Tue, Apr 19, 2016 at 07:48:16PM +0300, Adam Morrison wrote: > > This patchset improves the scalability of the Intel IOMMU code by > > resolving two spinlock bottlenecks, yielding up to ~5x performance > > improvement and approaching iommu=of

Re: [PATCH v3 7/7] iommu: introduce per-cpu caching to iova allocation

2016-04-19 Thread Benjamin Serebrin via iommu
Thanks, Adam, looks very good! One tiny nit inline below. On Tue, Apr 19, 2016 at 9:49 AM, Adam Morrison wrote: > From: Omer Peleg > > IOVA allocation has two problems that impede high-throughput I/O. > First, it can do a linear search over the allocated IOVA ranges. > Second, the rbtree spi

Re: [PATCH v3 0/7] Intel IOMMU scalability improvements

2016-04-19 Thread Shaohua Li
On Tue, Apr 19, 2016 at 07:48:16PM +0300, Adam Morrison wrote: > This patchset improves the scalability of the Intel IOMMU code by > resolving two spinlock bottlenecks, yielding up to ~5x performance > improvement and approaching iommu=off performance. > > For example, here's the throughput obtain

Re: [PATCH v3 5/7] iommu: avoid dev iotlb logic in intel-iommu for domains with no dev iotlbs

2016-04-19 Thread David Woodhouse
On Tue, 2016-04-19 at 19:49 +0300, Adam Morrison wrote: > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -392,6 +392,7 @@ struct dmar_domain { >    * to VT-d spec, section 9.3 */ >   >   struct list_head devices; /* all devic

Re: [PATCH v7 7/8] genirq/msi: map/unmap the MSI doorbells on msi_domain_alloc/free_irqs

2016-04-19 Thread kbuild test robot
Hi, [auto build test ERROR on tip/irq/core] [also build test ERROR on v4.6-rc4 next-20160419] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Eric-Auger/KVM-PCIe-MSI-passthrough-on-ARM-ARM64

[PATCH v7 0/7] KVM PCIe/MSI passthrough on ARM/ARM64: kernel part 3/3: vfio changes

2016-04-19 Thread Eric Auger
This series allows the user-space to register a reserved IOVA domain. This completes the kernel integration of the whole functionality on top of part 1 & 2. We reuse the VFIO DMA MAP ioctl with a new flag to bridge to the dma-reserved-iommu API. The number of IOVA pages to provision for MSI bindin

[PATCH v7 7/7] vfio/type1: return MSI mapping requirements with VFIO_IOMMU_GET_INFO

2016-04-19 Thread Eric Auger
This patch allows the user-space to know whether MSI addresses need to be mapped in the IOMMU. The user-space uses VFIO_IOMMU_GET_INFO ioctl and IOMMU_INFO_REQUIRE_MSI_MAP gets set if they need to. The computation of the number of IOVA pages to be provided by the user space will be implemented in

[PATCH v7 2/7] vfio/type1: vfio_find_dma accepting a type argument

2016-04-19 Thread Eric Auger
In our RB-tree we now have slots of different types (USER and RESERVED). It becomes useful to be able to search for dma slots of a specific type or any type. This patch proposes an implementation for that modality and also changes the existing callers using the USER type. Signed-off-by: Eric Auger

[PATCH v7 3/7] vfio/type1: specialize remove_dma and replay according to type

2016-04-19 Thread Eric Auger
Before allowing the end-user to create VFIO_IOVA_RESERVED dma slots, let's implement the expected behavior for removal and replay. As opposed to user dma slots, the physical pages bound to reserved IOVA do not need to be pinned/unpinned. Also we currently handle a single reserved iova domain. Any a

[PATCH v7 1/7] vfio: introduce a vfio_dma type field

2016-04-19 Thread Eric Auger
We introduce a vfio_dma type since we will need to discriminate different types of dma slots: - VFIO_IOVA_USER: IOVA region used to map user vaddr - VFIO_IOVA_RESERVED: IOVA region reserved to map host device PA such as MSI doorbells Signed-off-by: Eric Auger --- v6 -> v7: - add VFIO_IOVA_ANY

[PATCH v7 6/7] iommu/arm-smmu: do not advertise IOMMU_CAP_INTR_REMAP

2016-04-19 Thread Eric Auger
Do not advertise IOMMU_CAP_INTR_REMAP for arm-smmu(-v3). Indeed the irq_remapping capability is abstracted on irqchip side for ARM as opposed to Intel IOMMU featuring IRQ remapping HW. So to check IRQ remapping capability, the msi domain needs to be checked instead. This commit needs to be applie

[PATCH v7 5/7] vfio/type1: also check IRQ remapping capability at msi domain

2016-04-19 Thread Eric Auger
On x86 IRQ remapping is abstracted by the IOMMU. On ARM this is abstracted by the msi controller. vfio_safe_irq_domain allows to check whether interrupts are "safe" for a given device. They are if the device does not use MSI or if the device uses MSI and the msi-parent controller supports IRQ remap

[PATCH v7 4/7] vfio: allow reserved iova registration

2016-04-19 Thread Eric Auger
The user is allowed to [un]register a reserved IOVA range by using the DMA MAP API and setting the new flag: VFIO_DMA_MAP_FLAG_MSI_RESERVED_IOVA. It provides the base address and the size. This region is stored in the vfio_dma rb tree. At that point the iova range is not mapped to any target addres

[PATCH v7 8/8] genirq/msi: use the MSI doorbell's IOVA when requested

2016-04-19 Thread Eric Auger
On MSI message composition we now use the MSI doorbell's IOVA in place of the doorbell's PA in case the device is upstream to an IOMMU that requires MSI addresses to be mapped. The doorbell's allocation and mapping happened on an early stage (pci_enable_msi). Signed-off-by: Eric Auger --- v6 ->

[PATCH v7 7/8] genirq/msi: map/unmap the MSI doorbells on msi_domain_alloc/free_irqs

2016-04-19 Thread Eric Auger
This patch handles the iommu mapping of MSI doorbells that require to be mapped in an iommu domain. This happens on msi_domain_alloc/free_irqs since this is called in code that can sleep (pci_enable/disable_msi): iommu_map/unmap is not stated as atomic. On msi_domain_(de)activate and msi_domain_set

[PATCH v7 6/8] irqchip/gicv2m: implement msi_doorbell_info callback

2016-04-19 Thread Eric Auger
This patch implements the msi_doorbell_info callback in the gicv2m driver. The driver now is able to return its doorbell characteristics (base, size, prot). A single doorbell is exposed. This will allow the msi layer to iommu_map this doorbell when requested. Signed-off-by: Eric Auger --- v7:

[PATCH v7 3/8] genirq/msi: export msi_get_domain_info

2016-04-19 Thread Eric Auger
We plan to use msi_get_domain_info in VFIO module so let's export it. Signed-off-by: Eric Auger --- v2 -> v3: - remove static implementation in case CONFIG_PCI_MSI_IRQ_DOMAIN is not set --- kernel/irq/msi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c

[PATCH v7 5/8] genirq/irq: introduce msi_doorbell's structs and related callback

2016-04-19 Thread Eric Auger
The purpose is to be able to retrieve the MSI doorbells of an irqchip. This is now needed since on some platforms those doorbells must be iommu mapped (in case the MSIs transit through an IOMMU that do not bypass those transactions). The assumption is there is a maximum of one doorbell region per

[PATCH v7 2/8] irqchip/gic-v3-its: ITS advertises MSI_FLAG_IRQ_REMAPPING

2016-04-19 Thread Eric Auger
The ITS is the first ARM MSI controller advertising the new MSI_FLAG_IRQ_REMAPPING flag. It does so because it supports interrupt translation service. This HW support offers isolation of MSIs, feature used when using KVM device passthrough. Signed-off-by: Eric Auger --- v5: new --- drivers/irq

[PATCH v7 0/8] KVM PCIe/MSI passthrough on ARM/ARM64: kernel part 2/3: msi changes

2016-04-19 Thread Eric Auger
This series implements the MSI address mapping/unmapping in the MSI layer. IOMMU binding happens on pci_enable_msi since this function can sleep and return errors. On msi_domain_set_affinity, msi_domain_(de)activate, which are not allowed to sleep, we simply look for the already existing binding.

[PATCH v7 4/8] genirq/msi: msi_compose wrapper

2016-04-19 Thread Eric Auger
Currently the MSI message is composed by directly calling irq_chip_compose_msi_msg and erased by setting the memory to zero. On some platforms, we will need to complexify this composition to properly handle MSI emission through IOMMU. Also we will need to track when the MSI message is erased. We

[PATCH v7 1/8] genirq/msi: Add a new MSI_FLAG_IRQ_REMAPPING flag

2016-04-19 Thread Eric Auger
Let's introduce a new msi_domain_info flag value, MSI_FLAG_IRQ_REMAPPING meant to tell the domain supports IRQ REMAPPING, also known as Interrupt Translation Service. On Intel HW this IRQ remapping capability is abstracted on IOMMU side while on ARM it is abstracted on MSI controller side. This fla

[PATCH v7 10/10] iommu/arm-smmu: call iommu_free_reserved_iova_domain on domain destruction

2016-04-19 Thread Eric Auger
When the domain gets destroyed, let's make sure all reserved iova resources get released. Choice is made to put that call in arm-smmu(-v3).c to do something similar to what was done for iommu_put_dma_cookie. Signed-off-by: Eric Auger --- v7: new --- drivers/iommu/arm-smmu-v3.c | 2 ++ drivers

[PATCH v7 09/10] iommu/dma-reserved-iommu: iommu_msi_mapping_translate_msg

2016-04-19 Thread Eric Auger
Introduce iommu_msi_mapping_translate_msg whose role consists in detecting whether the device's MSIs must to be mapped into an IOMMU. It case it must, the function overrides the MSI msg originally composed and replaces the doorbell's PA by a pre-allocated and pre-mapped reserved IOVA. In case the c

[PATCH v7 08/10] iommu/dma-reserved_iommu: iommu_msi_mapping_desc_to_domain

2016-04-19 Thread Eric Auger
This function checks whether - the device emitting the MSI belongs to a non default iommu domain - the iommu domain requires the MSI address to be mapped. If those conditions are met, the function returns the iommu domain to be used for mapping the MSI doorbell; else it returns NULL. Signed-off-b

[PATCH v7 07/10] iommu/dma-reserved-iommu: delete bindings in iommu_free_reserved_iova_domain

2016-04-19 Thread Eric Auger
Now reserved bindings can exist, destroy them when destroying the reserved iova domain. iommu_map is not supposed to be atomic, hence the extra complexity in the locking. Signed-off-by: Eric Auger --- v6 -> v7: - remove [PATCH v6 7/7] dma-reserved-iommu: iommu_unmap_reserved and destroy the bi

[PATCH v3 2/7] iommu: per-cpu deferred invalidation queues

2016-04-19 Thread Adam Morrison
From: Omer Peleg The IOMMU's IOTLB invalidation is a costly process. When iommu mode is not set to "strict", it is done asynchronously. Current code amortizes the cost of invalidating IOTLB entries by batching all the invalidations in the system and performing a single global invalidation instea

[PATCH v3 7/7] iommu: introduce per-cpu caching to iova allocation

2016-04-19 Thread Adam Morrison
From: Omer Peleg IOVA allocation has two problems that impede high-throughput I/O. First, it can do a linear search over the allocated IOVA ranges. Second, the rbtree spinlock that serializes IOVA allocations becomes contended. Address these problems by creating an API for caching allocated IOVA

[PATCH v7 05/10] iommu/dma-reserved-iommu: reserved binding rb-tree and helpers

2016-04-19 Thread Eric Auger
we will need to track which host physical addresses are mapped to reserved IOVA. In that prospect we introduce a new RB tree indexed by physical address. This RB tree only is used for reserved IOVA bindings. It is expected this RB tree will contain very few bindings. Those generally correspond to

[PATCH v7 04/10] iommu/dma-reserved-iommu: alloc/free_reserved_iova_domain

2016-04-19 Thread Eric Auger
Introduce alloc/free_reserved_iova_domain in the IOMMU API. alloc_reserved_iova_domain initializes an iova domain at a given iova base address and with a given size. This iova domain will be used to allocate iova within that window. Those IOVAs will be reserved for special purpose, typically MSI fr

[PATCH v7 06/10] iommu/dma-reserved-iommu: iommu_get/put_reserved_iova

2016-04-19 Thread Eric Auger
This patch introduces iommu_get/put_reserved_iova. iommu_get_reserved_iova allows to iommu map a contiguous physical region onto a reserved contiguous IOVA region. The physical region base address does not need to be iommu page size aligned. iova pages are allocated and mapped so that they cover a

[PATCH v7 01/10] iommu: Add DOMAIN_ATTR_MSI_MAPPING attribute

2016-04-19 Thread Eric Auger
Introduce a new DOMAIN_ATTR_MSI_MAPPING domain attribute. If supported, this means the MSI addresses need to be mapped in the IOMMU. x86 IOMMUs typically don't expose the attribute since on x86, MSI write transaction addresses always are within the 1MB PA region [FEE0_h - FEF0_000h] window whi

[PATCH v7 02/10] iommu/arm-smmu: advertise DOMAIN_ATTR_MSI_MAPPING attribute

2016-04-19 Thread Eric Auger
On ARM, MSI write transactions from device upstream to the smmu are conveyed through the iommu. Therefore target physical addresses must be mapped and DOMAIN_ATTR_MSI_MAPPING is set to advertise this requirement on arm-smmu and arm-smmu-v3. Signed-off-by: Eric Auger Signed-off-by: Bharat Bhushan

[PATCH v7 00/10] KVM PCIe/MSI passthrough on ARM/ARM64: kernel part 1/3: iommu changes

2016-04-19 Thread Eric Auger
This series introduces the dma-reserved-iommu api used to: - create/destroy an iova domain dedicated to reserved iova bindings - map/unmap physical addresses onto reserved IOVAs. - search for an existing reserved iova mapping matching a PA window - determine whether an msi needs to be iommu mapped

[PATCH v7 03/10] iommu: introduce a reserved iova cookie

2016-04-19 Thread Eric Auger
This patch introduces some new fields in the iommu_domain struct, dedicated to reserved iova management. In a similar way as DMA mapping IOVA window, we need to store information related to a reserved IOVA window. The reserved_iova_cookie will store the reserved iova_domain handle. An RB tree ind

[PATCH v3 5/7] iommu: avoid dev iotlb logic in intel-iommu for domains with no dev iotlbs

2016-04-19 Thread Adam Morrison
From: Omer Peleg This patch avoids taking the device_domain_lock in iommu_flush_dev_iotlb() for domains with no dev iotlb devices. Signed-off-by: Omer Peleg [g...@google.com: fixed locking issues] Signed-off-by: Godfrey van der Linden [m...@cs.technion.ac.il: rebased and reworded the commit me

[PATCH v3 6/7] iommu: change intel-iommu to use IOVA frame numbers

2016-04-19 Thread Adam Morrison
From: Omer Peleg Make intel-iommu map/unmap/invalidate work with IOVA pfns instead of pointers to "struct iova". This avoids using the iova struct from the IOVA red-black tree and the resulting explicit find_iova() on unmap. This patch will allow us to cache IOVAs in the next patch, in order to

[PATCH v3 4/7] iommu: only unmap mapped entries

2016-04-19 Thread Adam Morrison
From: Omer Peleg Current unmap implementation unmaps the entire area covered by the IOVA range, which is a power-of-2 aligned region. The corresponding map, however, only maps those pages originally mapped by the user. This discrepancy can lead to unmapping of already unmapped entries, which is u

[PATCH v3 1/7] iommu: refactoring of deferred flush entries

2016-04-19 Thread Adam Morrison
From: Omer Peleg Currently, deferred flushes' info is striped between several lists in the flush tables. Instead, move all information about a specific flush to a single entry in this table. This patch does not introduce any functional change. Signed-off-by: Omer Peleg [m...@cs.technion.ac.il:

[PATCH v3 0/7] Intel IOMMU scalability improvements

2016-04-19 Thread Adam Morrison
This patchset improves the scalability of the Intel IOMMU code by resolving two spinlock bottlenecks, yielding up to ~5x performance improvement and approaching iommu=off performance. For example, here's the throughput obtained by 16 memcached instances running on a 16-core Sandy Bridge system, ac

[PATCH v3 3/7] iommu: correct flush_unmaps pfn usage

2016-04-19 Thread Adam Morrison
From: Omer Peleg Change flush_unmaps() to correctly pass iommu_flush_iotlb_psi() dma addresses. (Intel mm and dma have the same size for pages at the moment, but this usage improves consistency.) Signed-off-by: Omer Peleg [m...@cs.technion.ac.il: rebased and reworded the commit message] Signed

Re: [RFC v6 06/10] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-04-19 Thread Yongji Xie
On 2016/4/18 19:30, David Laight wrote: From: Yongji Xie Sent: 18 April 2016 11:59 We introduce a new pci_bus_flags, PCI_BUS_FLAGS_MSI_REMAP which indicates all devices on the bus are protected by the hardware which supports IRQ remapping(intel naming). This flag will be used to know whether it

Re: [RFC PATCH 06/11] drivers: iommu: make of_xlate() interface DT agnostic

2016-04-19 Thread Lorenzo Pieralisi
Hi Marek, On Tue, Apr 19, 2016 at 10:28:02AM +0200, Marek Szyprowski wrote: > Hello, > > On 2016-04-14 19:25, Lorenzo Pieralisi wrote: > >On systems booting with ACPI, the IOMMU drivers require the same > >kind of id mapping carried out with a DT tree through the of_xlate() > >API in order to map

Re: [RFC PATCH 06/11] drivers: iommu: make of_xlate() interface DT agnostic

2016-04-19 Thread Marek Szyprowski
Hello, On 2016-04-14 19:25, Lorenzo Pieralisi wrote: On systems booting with ACPI, the IOMMU drivers require the same kind of id mapping carried out with a DT tree through the of_xlate() API in order to map devices identifiers to IOMMU ones. On ACPI systems, since DT nodes are not present (ie s