Re: [PATCH] iommu/arm-smmu-v2: Workaround for ThunderX errata#27704

2016-03-01 Thread Chalamarla, Tirumalesh
On 3/1/16, 7:07 PM, "Will Deacon" wrote: >On Wed, Feb 24, 2016 at 01:13:53PM -0800, Tirumalesh Chalamarla wrote: >> Due to Errata#27704 CN88xx SMMUv2,supports only shared ASID and VMID >> namespaces; specifically within a given node SMMU0 and SMMU1 share, >> as does SMMU2 and SMMU3. >> >>

Re: [PATCH] iommu/arm-smmu-v2: Workaround for ThunderX errata#27704

2016-03-01 Thread Will Deacon
On Wed, Feb 24, 2016 at 01:13:53PM -0800, Tirumalesh Chalamarla wrote: > Due to Errata#27704 CN88xx SMMUv2,supports only shared ASID and VMID > namespaces; specifically within a given node SMMU0 and SMMU1 share, > as does SMMU2 and SMMU3. > > This patch address these issuee by supplying asid and

Re: [PATCH] iommu/mtk: fix handling of of_count_phandle_with_args result

2016-03-01 Thread Yong Wu
On Tue, 2016-03-01 at 12:34 +0100, Joerg Roedel wrote: > On Tue, Mar 01, 2016 at 10:36:23AM +0100, Andrzej Hajda wrote: > > The function can return negative value so it should be assigned to signed > > variable. The patch changes also type of related i variable to make code > > more compact and coh

Bug: Freeing dma regions

2016-03-01 Thread David Kiarie
Hello, This patch seems to have introduced a bug - https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4eeca8c5e72fad752eba9efc293c924d65faa86e As the commit message says, it should check for regions behind the next_bit but it checks for regions beyond. David.

[PATCH] iommu/mtk: fix handling of of_count_phandle_with_args result

2016-03-01 Thread Andrzej Hajda
The function can return negative value so it should be assigned to signed variable. The patch changes also type of related i variable to make code more compact and coherent. The problem has been detected using patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci. Signed-off-by: Andrzej

[PATCH v2] iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags

2016-03-01 Thread Robin Murphy
Whilst the default SLUB allocator happily just merges the original allocation flags from kmem_cache_create() with those passed through kmem_cache_alloc(), there is a code path in the SLAB allocator which will aggressively BUG_ON() if the cache was created with SLAB_CACHE_DMA but GFP_DMA is not spec

Re: [PATCH] iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags

2016-03-01 Thread Will Deacon
On Tue, Mar 01, 2016 at 06:17:38PM +, Robin Murphy wrote: > Whilst the default SLUB allocator happily just merges the original > allocation flags from kmem_cache_create() with those passed through > kmem_cache_alloc(), there is a code path in the SLAB allocator which > will aggressively BUG_ON(

[RFC v5 15/17] vfio/type1: also check IRQ remapping capability at msi domain

2016-03-01 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

[RFC v5 13/17] vfio: introduce VFIO_IOVA_RESERVED vfio_dma type

2016-03-01 Thread Eric Auger
We introduce a vfio_dma type since we will need to discriminate legacy vfio_dma's from new reserved ones. Since those latter are not mapped at registration, some treatments need to be reworked: removal, replay. Currently they are unplugged. In subsequent patches they will be reworked. Signed-off-b

[RFC v5 16/17] iommu/arm-smmu: do not advertise IOMMU_CAP_INTR_REMAP

2016-03-01 Thread Eric Auger
Do not advertise IOMMU_CAP_INTR_REMAP for arm-smmu. 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 applied aft

[RFC v5 08/17] msi: Add a new MSI_FLAG_IRQ_REMAPPING flag

2016-03-01 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

[RFC v5 10/17] msi: export msi_get_domain_info

2016-03-01 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

[RFC v5 07/17] dma-reserved-iommu: iommu_unmap_reserved

2016-03-01 Thread Eric Auger
Introduce a new function whose role is to unmap all allocated reserved IOVAs and free the reserved iova domain Signed-off-by: Eric Auger --- v3 -> v4: - previously "iommu/arm-smmu: relinquish reserved resources on domain deletion" --- drivers/iommu/dma-reserved-iommu.c | 27 +

[RFC v5 14/17] vfio: allow the user to register reserved iova range for MSI mapping

2016-03-01 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

[RFC v5 17/17] vfio/type1: return MSI mapping requirements with VFIO_IOMMU_GET_INFO

2016-03-01 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. Also the number of IOMMU pages requested to map those is returned in msi_iova_pages field. User-spac

[RFC v5 06/17] dma-reserved-iommu: iommu_get/put_single_reserved

2016-03-01 Thread Eric Auger
This patch introduces iommu_get/put_single_reserved. iommu_get_single_reserved allows to allocate a new reserved iova page and map it onto the physical page that contains a given physical address. Page size is the IOMMU page one. It is the responsability of the system integrator to make sure the i

[RFC v5 12/17] msi: IOMMU map the doorbell address when needed

2016-03-01 Thread Eric Auger
In case the msi is emitted by a device attached to an iommu domain and this iommu domain requires MSI mapping, the msi address (aka doorbell) must be mapped in the IOMMU. Else MSI write transaction will cause a fault. We perform this action at msi message composition time. On any MSI address chang

[RFC v5 09/17] irqchip/gic-v3-its: ITS advertises MSI_FLAG_IRQ_REMAPPING

2016-03-01 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

[RFC v5 03/17] iommu: introduce a reserved iova cookie

2016-03-01 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

[RFC v5 01/17] iommu: Add DOMAIN_ATTR_MSI_MAPPING attribute

2016-03-01 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

[RFC v5 00/17] KVM PCIe/MSI passthrough on ARM/ARM64

2016-03-01 Thread Eric Auger
This series addresses KVM PCIe passthrough with MSI enabled on ARM/ARM64. It pursues the efforts done on [1], [2], [3]. It also aims at covering the same need on PowerPC platforms although the same kind of integration should be carried out. On x86 all accesses to the 1MB PA region [FEE0_h - FE

[RFC v5 11/17] msi: msi_compose wrapper

2016-03-01 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

[RFC v5 05/17] dma-reserved-iommu: reserved binding rb-tree and helpers

2016-03-01 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

[RFC v5 04/17] dma-reserved-iommu: alloc/free_reserved_iova_domain

2016-03-01 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

[RFC v5 02/17] iommu/arm-smmu: advertise DOMAIN_ATTR_MSI_MAPPING attribute

2016-03-01 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] iommu/io-pgtable-armv7s: Fix kmem_cache_alloc() flags

2016-03-01 Thread Robin Murphy
Whilst the default SLUB allocator happily just merges the original allocation flags from kmem_cache_create() with those passed through kmem_cache_alloc(), there is a code path in the SLAB allocator which will aggressively BUG_ON() if the cache was created with SLAB_CACHE_DMA but GFP_DMA is not spec

Re: [PATCH v4 3/6] PCI: Add support for multiple DMA aliases

2016-03-01 Thread Jacek Lawrynowicz
On Mon, Feb 29, 2016 at 04:44:17PM -0600, Bjorn Helgaas wrote: > On Thu, Feb 25, 2016 at 03:41:51PM +, Lawrynowicz, Jacek wrote: > > > -Original Message- > > > From: Bjorn Helgaas [mailto:helg...@kernel.org] > > > Sent: Thursday, February 25, 2016 3:39 PM > > > To: Bjorn Helgaas > > >

Re: [PATCH v3 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support

2016-03-01 Thread Robin Murphy
Hi Geert, On 01/03/16 12:01, Geert Uytterhoeven wrote: Hi Robin, On Tue, Jan 26, 2016 at 6:13 PM, Robin Murphy wrote: Add a nearly-complete ARMv7 short descriptor implementation, omitting only a few legacy and CPU-centric aspects which shouldn't be necessary for IOMMU API use anyway. Signed-

Re: [PATCH v3 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support

2016-03-01 Thread Laurent Pinchart
Hi Geert, On Tuesday 01 March 2016 13:01:39 Geert Uytterhoeven wrote: > On Tue, Jan 26, 2016 at 6:13 PM, Robin Murphy wrote: > > Add a nearly-complete ARMv7 short descriptor implementation, omitting > > only a few legacy and CPU-centric aspects which shouldn't be necessary > > for IOMMU API use a

Re: [PATCH v3 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support

2016-03-01 Thread Geert Uytterhoeven
Hi Robin, On Tue, Jan 26, 2016 at 6:13 PM, Robin Murphy wrote: > Add a nearly-complete ARMv7 short descriptor implementation, omitting > only a few legacy and CPU-centric aspects which shouldn't be necessary > for IOMMU API use anyway. > > Signed-off-by: Yong Wu > Signed-off-by: Robin Murphy >

Re: [PATCH] iommu/mtk: fix handling of of_count_phandle_with_args result

2016-03-01 Thread Joerg Roedel
On Tue, Mar 01, 2016 at 10:36:23AM +0100, Andrzej Hajda wrote: > The function can return negative value so it should be assigned to signed > variable. The patch changes also type of related i variable to make code > more compact and coherent. > > The problem has been detected using patch > scripts