[PATCH v3 11/24] powerpc/powernv/ioda/ioda2: Rework tce_build()/tce_free()

2015-01-29 Thread Alexey Kardashevskiy
are PCI addresses shifted by IOMMU page shift. The patch is pretty mechanical and behaviour is not expected to change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 92 ++--- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 8 ++- arch

[PATCH v3 12/24] powerpc/iommu/powernv: Release replaced TCE

2015-01-29 Thread Alexey Kardashevskiy
replaces iommu_tce_build() and iommu_clear_tce() with a single iommu_tce_xchg(). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 13 +--- arch/powerpc/kernel/iommu.c | 50 +++ arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH v3 07/24] powerpc/iommu: Introduce iommu_table_alloc() helper

2015-01-29 Thread Alexey Kardashevskiy
This replaces multiple calls of kzalloc_node() with a new iommu_table_alloc() helper. Right now it calls kzalloc_node() but later it will be modified to allocate a powerpc_iommu struct with a single iommu_table in it. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h

[PATCH v3 10/24] powerpc/powernv/ioda2: Rework IOMMU ownership control

2015-01-29 Thread Alexey Kardashevskiy
rship()/iommu_release_ownership() if needed. Next patches will remove these calls from IODA2 code. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 18 +-- arch/powerpc/kernel/iommu.c | 53 +++ arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH v3 13/24] powerpc/pseries/lpar: Enable VFIO

2015-01-29 Thread Alexey Kardashevskiy
so VFIO performance in guests running under PR KVM is expected to be slower than in guests running under HV KVM or bare metal hosts. Signed-off-by: Alexey Kardashevskiy --- Changes: v5: * added global lock for xchg operations * added missing be64_to_cpu(oldtce) --- arch/powerpc/platforms/pseries

[PATCH v3 09/24] powerpc/iommu: Fix IOMMU ownership control functions

2015-01-29 Thread Alexey Kardashevskiy
it_map. Clearing must be done outside of the table locks as iommu_clear_tce() called from iommu_clear_tces_and_put_pages() does this. Signed-off-by: Alexey Kardashevskiy --- Note: we might want to get rid of it as this patchset removes it_map from tables passed to VFIO. Changes: v5: * do not store bit

[PATCH v3 14/24] vfio: powerpc/spapr: Register memory

2015-01-29 Thread Alexey Kardashevskiy
-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 333 include/uapi/linux/vfio.h | 29 2 files changed, 331 insertions(+), 31 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c

[PATCH v3 15/24] poweppc/powernv/ioda2: Rework iommu_table creation

2015-01-29 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 31 +-- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/powernv

[PATCH v3 16/24] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_create_table

2015-01-29 Thread Alexey Kardashevskiy
This is a part of moving TCE table allocation into an iommu_ops callback to support multiple IOMMU groups per one VFIO container. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 88 +++ 1 file changed

[PATCH v3 17/24] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-01-29 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 84 --- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/arch

[PATCH v3 08/24] powerpc/spapr: vfio: Switch from iommu_table to new powerpc_iommu

2015-01-29 Thread Alexey Kardashevskiy
Modern IBM POWERPC systems support multiple (currently two) TCE tables per IOMMU group (a.k.a. PE). This adds a powerpc_iommu container for TCE tables. Right now just one table is supported. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 18 ++-- arch

[PATCH v3 06/24] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-01-29 Thread Alexey Kardashevskiy
ot; callbacks with single ones. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 17 +++ arch/powerpc/include/asm/machdep.h | 25 arch/powerpc/kernel/iommu.c | 46 +++---

[PATCH v3 19/24] powerpc/powernv: Implement multilevel TCE tables

2015-01-29 Thread Alexey Kardashevskiy
This adds multi-level TCE tables support to pnv_pci_ioda2_create_table() and pnv_pci_ioda2_free_table() callbacks. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 4 + arch/powerpc/platforms/powernv/pci-ioda.c | 125 +++--- arch

[PATCH v3 18/24] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-01-29 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch

[PATCH v3 20/24] powerpc/powernv: Change prototypes to receive iommu

2015-01-29 Thread Alexey Kardashevskiy
This changes few functions to receive a powerpc_iommu pointer rather than PE as they are going to be a part of upcoming powerpc_iommu_ops callback set. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 13 - 1 file changed, 8 insertions(+), 5

[PATCH v3 21/24] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-01-29 Thread Alexey Kardashevskiy
user is expected to unprogram DMA windows on PHBs before returning ownership back to the kernel. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 31 ++ arch/powerpc/platforms/powernv/pci-ioda.c | 98 ++- 2 files changed, 113

[PATCH v3 23/24] vfio/spapr: Enable multiple groups in a container

2015-01-29 Thread Alexey Kardashevskiy
Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 243 +++- 1 file changed, 155 insertions(+), 88 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index d0987ae..8bcafb7 100644 --- a

[PATCH v3 22/24] powerpc/iommu: Get rid of ownership helpers

2015-01-29 Thread Alexey Kardashevskiy
iommu_take_ownership/iommu_release_ownership used to be used to mark bits in iommu_table::it_map. Since the IOMMU tables are recreated for VFIO, it_map is always NULL. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 2 - arch/powerpc/kernel/iommu.c | 96

[PATCH v3 24/24] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-01-29 Thread Alexey Kardashevskiy
This adds create/remove window ioctls to create and remove DMA windows. This changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional information such as a number of supported windows and maximum number levels of TCE tables. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc

[PATCH v3 01/24] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-01-29 Thread Alexey Kardashevskiy
only. This removes page unpinning from iommu_take_ownership() as the actual TCE table might contain garbage and doing put_page() on it is undefined behaviour. Besides the last part, the rest of the patch is mechanical. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h

Re: [PATCH v3 14/24] vfio: powerpc/spapr: Register memory

2015-02-02 Thread Alexey Kardashevskiy
On 02/03/2015 11:11 AM, Alex Williamson wrote: > On Thu, 2015-01-29 at 20:21 +1100, Alexey Kardashevskiy wrote: >> The existing implementation accounts the whole DMA window in >> the locked_vm counter which is going to be even worse with multiple >> containers and huge DM

Re: [PATCH v3 12/24] powerpc/iommu/powernv: Release replaced TCE

2015-02-04 Thread Alexey Kardashevskiy
On 02/04/2015 05:08 PM, Paul Mackerras wrote: > On Thu, Jan 29, 2015 at 08:21:53PM +1100, Alexey Kardashevskiy wrote: >> At the moment writing new TCE value to the IOMMU table fails with EBUSY >> if there is a valid entry already. However PAPR specification allows >> the g

Re: [PATCH v3 08/24] powerpc/spapr: vfio: Switch from iommu_table to new powerpc_iommu

2015-02-04 Thread Alexey Kardashevskiy
On 02/05/2015 12:32 AM, Alexander Graf wrote: > > > On 03.02.15 01:12, Alex Williamson wrote: >> On Thu, 2015-01-29 at 20:21 +1100, Alexey Kardashevskiy wrote: >>> Modern IBM POWERPC systems support multiple (currently two) TCE tables >>> per IOMMU group (a.k.

[PATCH v4 01/28] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-02-16 Thread Alexey Kardashevskiy
only. This removes page unpinning from iommu_take_ownership() as the actual TCE table might contain garbage and doing put_page() on it is undefined behaviour. Besides the last part, the rest of the patch is mechanical. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * s/iommu_tce_build(tbl

[PATCH v4 03/28] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-02-16 Thread Alexey Kardashevskiy
compound_order() and compound_head() work correctly on non-huge pages, there is no need for additional check whether the page is huge. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * s/tce_check_page_size/tce_page_is_contained/ --- drivers/vfio/vfio_iommu_spapr_tce.c | 22

[PATCH v4 04/28] vfio: powerpc/spapr: Use it_page_size

2015-02-16 Thread Alexey Kardashevskiy
This makes use of the it_page_size from the iommu_table struct as page size can differ. This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code as recently introduced IOMMU_PAGE_XXX macros do not include IOMMU_PAGE_SHIFT. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David

[PATCH v4 00/28] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-02-16 Thread Alexey Kardashevskiy
o we do not bother with iommu_table::it_map anymore * added multilevel TCE tables support to support really huge guests v2: * added missing __pa() in "powerpc/powernv: Release replaced TCE" * reposted to make some noise Alexey Kardashevskiy (28): vfio: powerpc/spapr: Move page pin

[PATCH v4 02/28] vfio: powerpc/spapr: Do cleanup when releasing the group

2015-02-16 Thread Alexey Kardashevskiy
This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++--- 1 file changed, 11 insertions(+), 3

[PATCH v4 19/28] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_create_table

2015-02-16 Thread Alexey Kardashevskiy
This is a part of moving TCE table allocation into an iommu_ops callback to support multiple IOMMU groups per one VFIO container. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 88 +++ 1 file changed

[PATCH v4 23/28] powerpc/powernv: Change prototypes to receive iommu

2015-02-16 Thread Alexey Kardashevskiy
This changes few functions to receive a powerpc_iommu pointer rather than PE as they are going to be a part of upcoming powerpc_iommu_ops callback set. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 13 - 1 file changed, 8 insertions(+), 5

[PATCH v4 20/28] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-02-16 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 84 --- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/arch

[PATCH v4 06/28] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-02-16 Thread Alexey Kardashevskiy
At the moment DMA map/unmap requests are handled irrespective to the container's state. This allows the user space to pin memory which it might not be allowed to pin. This adds checks to MAP/UNMAP that the container is enabled, otherwise -EPERM is returned. Signed-off-by: Alexey Kardashe

[PATCH v4 08/28] vfio: powerpc/spapr: Register memory

2015-02-16 Thread Alexey Kardashevskiy
locked_vm accounting. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * updated docs * s/kzmalloc/vzalloc/ * in tce_pin_pages()/tce_unpin_pages() removed @vaddr, @size and replaced offset with index * renamed vfio_iommu_type_register_memory to vfio_iommu_spapr_register_memory and removed

[PATCH v4 28/28] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-02-16 Thread Alexey Kardashevskiy
changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional information such as a number of supported windows and maximum number levels of TCE tables. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * moved code to tce_iommu_create_window()/tce_iommu_remove_window() helpers * added

[PATCH v4 07/28] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-02-16 Thread Alexey Kardashevskiy
return NULL. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 59 +++-- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 67ea392..7fd60f9

[PATCH v4 09/28] powerpc/powernv: Do not set "read" flag if direction==DMA_NONE

2015-02-16 Thread Alexey Kardashevskiy
Normally a bitmap from the iommu_table is used to track what TCE entry is in use. Since we are going to use iommu_table without its locks and do xchg() instead, it becomes essential not to put bits which are not implied in the direction flag. Signed-off-by: Alexey Kardashevskiy Reviewed-by

[PATCH v4 05/28] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-02-16 Thread Alexey Kardashevskiy
might be required to be bigger than the guest RAM. This also prints pid of the current process in pr_warn/pr_debug. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * new helpers do nothing if @npages == 0 * tce_iommu_disable() now can decrement the counter if the group was detached (not possibl

[PATCH v4 13/28] powerpc/iommu: Fix IOMMU ownership control functions

2015-02-16 Thread Alexey Kardashevskiy
it_map. Clearing must be done outside of the table locks as iommu_clear_tce() called from iommu_clear_tces_and_put_pages() does this. Signed-off-by: Alexey Kardashevskiy --- Note: we might want to get rid of it as this patchset removes it_map from tables passed to VFIO. Changes: v5: * do not store bit

[PATCH v4 10/28] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-02-16 Thread Alexey Kardashevskiy
ot; callbacks with single ones. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 17 +++ arch/powerpc/include/asm/machdep.h | 25 arch/powerpc/kernel/iommu.c | 46 +++---

[PATCH v4 11/28] powerpc/iommu: Introduce iommu_table_alloc() helper

2015-02-16 Thread Alexey Kardashevskiy
table(s). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/iommu.c| 9 + arch/powerpc/platforms/powernv/pci.c | 2 +- arch/powerpc/platforms/pseries/iommu.c | 12 4 files changed, 15 insertions(+), 9

[PATCH v4 15/28] powerpc/powernv/ioda/ioda2: Rework tce_build()/tce_free()

2015-02-16 Thread Alexey Kardashevskiy
are PCI addresses shifted by IOMMU page shift. The patch is pretty mechanical and behaviour is not expected to change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 92 ++--- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 8 ++- arch

[PATCH v4 25/28] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework ownership

2015-02-16 Thread Alexey Kardashevskiy
unprogram DMA windows on PHBs before returning ownership back to the kernel. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 30 ++ drivers/vfio/vfio_iommu_spapr_tce.c | 8 2 files changed, 34 insertions(+), 4 deletions

[PATCH v4 16/28] powerpc/iommu/powernv: Release replaced TCE

2015-02-16 Thread Alexey Kardashevskiy
. This adds a requirement for a platform to have exchange() implemented so from now on IODA2 is the only supported PHB for VFIO-SPAPR. This replaces iommu_tce_build() and iommu_clear_tce() with a single iommu_tce_xchg(). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h

[PATCH v4 24/28] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-02-16 Thread Alexey Kardashevskiy
way it works on x86. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 31 + arch/powerpc/platforms/powernv/pci-ioda.c | 75 +-- 2 files changed, 92 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm

[PATCH v4 14/28] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework IOMMU ownership control

2015-02-16 Thread Alexey Kardashevskiy
rship()/iommu_release_ownership() if needed. Next patches will remove these calls from IODA2 code. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 18 +-- arch/powerpc/kernel/iommu.c | 53 +++ arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH v4 12/28] powerpc/spapr: vfio: Switch from iommu_table to new powerpc_iommu

2015-02-16 Thread Alexey Kardashevskiy
Modern IBM POWERPC systems support multiple (currently two) TCE tables per IOMMU group (a.k.a. PE). This adds a powerpc_iommu container for TCE tables. Right now just one table is supported. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 18 +++-- arch

[PATCH v4 26/28] vfio: powerpc/spapr: Rework an IOMMU group attach/detach

2015-02-16 Thread Alexey Kardashevskiy
Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 62 +++-- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index fdcc04c..4ff8289 100644 --- a

[PATCH v4 17/28] powerpc/pseries/lpar: Enable VFIO

2015-02-16 Thread Alexey Kardashevskiy
so VFIO performance in guests running under PR KVM is expected to be slower than in guests running under HV KVM or bare metal hosts. Signed-off-by: Alexey Kardashevskiy --- Changes: v5: * added global lock for xchg operations * added missing be64_to_cpu(oldtce) --- arch/powerpc/platforms/pseries

[PATCH v4 27/28] vfio: powerpc/spapr: Register memory

2015-02-16 Thread Alexey Kardashevskiy
-by: Alexey Kardashevskiy --- Changes: v4: * updated docs * s/kzmalloc/vzalloc/ * in tce_pin_pages()/tce_unpin_pages() removed @vaddr, @size and replaced offset with index * renamed vfio_iommu_type_register_memory to vfio_iommu_spapr_register_memory and removed duplicating

[PATCH v4 22/28] powerpc/powernv: Implement multilevel TCE tables

2015-02-16 Thread Alexey Kardashevskiy
This adds multi-level TCE tables support to pnv_pci_ioda2_create_table() and pnv_pci_ioda2_free_table() callbacks. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 4 + arch/powerpc/platforms/powernv/pci-ioda.c | 125 +++--- arch

[PATCH v4 21/28] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-02-16 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch

[PATCH v4 18/28] poweppc/powernv/ioda2: Rework iommu_table creation

2015-02-16 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 31 +-- drivers/vfio/vfio_iommu_spapr_tce.c | 4 +++- 2 files changed, 20 insertions(+), 15

Re: [PATCH] pseries/iommu: remove iommu device references via bus notifier

2015-02-19 Thread Alexey Kardashevskiy
amudan Cc: sta...@kernel.org (3.13+) Reviewed-by: Alexey Kardashevskiy diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1d3d52dc3ff3..f77fb02f4710 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.

Re: [PATCH v4 27/28] vfio: powerpc/spapr: Register memory

2015-02-19 Thread Alexey Kardashevskiy
Just noticed - this patch should be split into two, they were squashed by mistake, my bad. On 02/16/2015 09:06 PM, Alexey Kardashevskiy wrote: The existing implementation accounts the whole DMA window in the locked_vm counter which is going to be even worse with multiple containers and huge

[PATCH v5 00/29] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-03-09 Thread Alexey Kardashevskiy
in "powerpc/powernv: Release replaced TCE" * reposted to make some noise Alexey Kardashevskiy (29): vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver vfio: powerpc/spapr: Do cleanup when releasing the group vfio: powerpc/spapr: Check that TCE page

[PATCH v5 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-09 Thread Alexey Kardashevskiy
compound_order() and compound_head() work correctly on non-huge pages, there is no need for additional check whether the page is huge. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * s/tce_check_page_size/tce_page_is_contained/ --- drivers/vfio/vfio_iommu_spapr_tce.c | 22

[PATCH v5 02/29] vfio: powerpc/spapr: Do cleanup when releasing the group

2015-03-09 Thread Alexey Kardashevskiy
This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++--- 1 file changed, 11 insertions(+), 3

[PATCH v5 04/29] vfio: powerpc/spapr: Use it_page_size

2015-03-09 Thread Alexey Kardashevskiy
This makes use of the it_page_size from the iommu_table struct as page size can differ. This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code as recently introduced IOMMU_PAGE_XXX macros do not include IOMMU_PAGE_SHIFT. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David

[PATCH v5 05/29] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-03-09 Thread Alexey Kardashevskiy
might be required to be bigger than the guest RAM. This also prints pid of the current process in pr_warn/pr_debug. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * new helpers do nothing if @npages == 0 * tce_iommu_disable() now can decrement the counter if the group was detached (not possibl

[PATCH v5 06/29] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-03-09 Thread Alexey Kardashevskiy
At the moment DMA map/unmap requests are handled irrespective to the container's state. This allows the user space to pin memory which it might not be allowed to pin. This adds checks to MAP/UNMAP that the container is enabled, otherwise -EPERM is returned. Signed-off-by: Alexey Kardashe

[PATCH v5 19/29] poweppc/powernv/ioda2: Rework iommu_table creation

2015-03-09 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci

[PATCH v5 16/29] powerpc/iommu: Fix IOMMU ownership control functions

2015-03-09 Thread Alexey Kardashevskiy
it_map. Clearing must be done outside of the table locks as iommu_clear_tce() called from iommu_clear_tces_and_put_pages() does this. Signed-off-by: Alexey Kardashevskiy --- Changes: v5: * do not store bit#0 value, it has to be set for zero-based table anyway * removed test_and_clear_bit --- arch

[PATCH v5 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-09 Thread Alexey Kardashevskiy
changes VFIO_IOMMU_SPAPR_TCE_GET_INFO handler to return additional information such as a number of supported windows and maximum number levels of TCE tables. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * moved code to tce_iommu_create_window()/tce_iommu_remove_window() helpers * added

[PATCH v5 23/29] powerpc/powernv: Implement multilevel TCE tables

2015-03-09 Thread Alexey Kardashevskiy
5 levels which splits the table into a tree of smaller subtables. This adds multi-level TCE tables support to pnv_pci_ioda2_create_table() and pnv_pci_ioda2_free_table() callbacks. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 2 + arch/powerpc/platforms

[PATCH v5 15/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework IOMMU ownership control

2015-03-09 Thread Alexey Kardashevskiy
else/more so let's give it more generic name. The bool parameter is inverted. The callback is implemented for IODA2 only. Other platforms (P5IOC2, IODA1) will use the old iommu_take_ownership/iommu_release_ownership API. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/io

[PATCH v5 12/29] powerpc/iommu: Introduce iommu_table_alloc() helper

2015-03-09 Thread Alexey Kardashevskiy
iommu table(s). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/iommu.c| 9 + arch/powerpc/platforms/powernv/pci.c | 2 +- arch/powerpc/platforms/pseries/iommu.c | 12 4 files changed, 15 insertions

[PATCH v5 26/29] vfio: powerpc/spapr: Define v2 IOMMU

2015-03-09 Thread Alexey Kardashevskiy
nting will be done by VFIO_IOMMU_SPAPR_REGISTER_MEMORY. In order to inform the userspace that VFIO supports new capabilities, this adds a new SPAPR TCE IOMMU v2 type. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 3 ++- include/uapi/linux/vfio.h | 2 ++ 2

[PATCH v5 13/29] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-03-09 Thread Alexey Kardashevskiy
Modern IBM POWERPC systems support multiple (currently two) TCE tables per IOMMU group (a.k.a. PE). This adds a iommu_table_group container for TCE tables. Right now just one table is supported. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 18

[PATCH v5 09/29] vfio: powerpc/spapr: Rework attach/detach

2015-03-09 Thread Alexey Kardashevskiy
This is to make extended ownership and multiple groups support patches simpler for review. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 38 ++--- 1 file changed, 23 insertions(+), 15 deletions(-) diff

[PATCH v5 01/29] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-03-09 Thread Alexey Kardashevskiy
only. This removes page unpinning from iommu_take_ownership() as the actual TCE table might contain garbage and doing put_page() on it is undefined behaviour. Besides the last part, the rest of the patch is mechanical. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * s/iommu_tce_build(tbl

[PATCH v5 07/29] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-03-09 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 70 - 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index d3ab34f..ca396e5 100644 --- a/drivers

[PATCH v5 10/29] powerpc/powernv: Do not set "read" flag if direction==DMA_NONE

2015-03-09 Thread Alexey Kardashevskiy
counterpart is there already) and uses it for powernv's pnv_tce_build(). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/iommu.c | 15 +++ arch/powerpc/platforms/powernv/pci.c | 7 +-- 3 files changed, 17 insertions(

[PATCH v5 20/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_create_table/pnc_pci_free_table

2015-03-09 Thread Alexey Kardashevskiy
This is a part of moving TCE table allocation into an iommu_ops callback to support multiple IOMMU groups per one VFIO container. This enforce window size to be a power of two. This is a pretty mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH v5 14/29] vfio: powerpc/spapr: powerpc/iommu: Rework IOMMU ownership control

2015-03-09 Thread Alexey Kardashevskiy
This replaces iommu_take_ownership()/iommu_release_ownership() calls with the callback calls and it is up to the platform code to call iommu_take_ownership()/iommu_release_ownership() if needed. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 4 +-- arch/powerpc

[PATCH v5 25/29] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-03-09 Thread Alexey Kardashevskiy
container and set_window()/unset_window() are supposed to be called for every group in a container. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 32 +++ arch/powerpc/platforms/powernv/pci-ioda.c | 87 - arch/powerpc

[PATCH v5 08/29] vfio: powerpc/spapr: Register memory

2015-03-09 Thread Alexey Kardashevskiy
locked_vm accounting. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * updated docs * s/kzmalloc/vzalloc/ * in tce_pin_pages()/tce_unpin_pages() removed @vaddr, @size and replaced offset with index * renamed vfio_iommu_type_register_memory to vfio_iommu_spapr_register_memory and removed

[PATCH v5 17/29] powerpc/powernv/ioda/ioda2: Rework tce_build()/tce_free()

2015-03-09 Thread Alexey Kardashevskiy
are PCI addresses shifted by IOMMU page shift. The patch is pretty mechanical and behaviour is not expected to change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 92 ++--- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 9 ++- arch

[PATCH v5 22/29] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-03-09 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch

[PATCH v5 11/29] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-03-09 Thread Alexey Kardashevskiy
uot;multi" callbacks with single ones. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 17 +++ arch/powerpc/include/asm/machdep.h | 25 arch/powerpc/kernel/iommu.c | 46 +++---

[PATCH v5 21/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-03-09 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 85 --- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/arch

[PATCH v5 24/29] powerpc/powernv: Change prototypes to receive iommu

2015-03-09 Thread Alexey Kardashevskiy
This changes few functions to receive a iommu_table_group pointer rather than PE as they are going to be a part of upcoming iommu_table_group_ops callback set. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 13 - 1 file changed, 8 insertions

[PATCH v5 27/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework ownership

2015-03-09 Thread Alexey Kardashevskiy
platform code, the user has to unprogram and remove all the tables it created. Old-style ownership is still supported allowing VFIO to run on older P5IOC2 and IODA IO controllers. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 30 +++--- drivers/vfio

[PATCH v5 28/29] vfio: powerpc/spapr: Support multiple groups in one container if possible

2015-03-09 Thread Alexey Kardashevskiy
create/set DMA windows on IOMMU groups so the same TCE tables will be shared between several IOMMU groups. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 252 1 file changed, 170 insertions(+), 82 deletions(-) diff --git a

[PATCH v5 18/29] powerpc/iommu/powernv: Release replaced TCE

2015-03-09 Thread Alexey Kardashevskiy
be calculated by platform code from DMA direction. This moves SetPageDirty() to the IOMMU code to make it work for both VFIO ioctl interface in in-kernel TCE acceleration (when it becomes available later). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 15

Re: [PATCH v5 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-10 Thread Alexey Kardashevskiy
On 03/11/2015 06:56 AM, Alex Williamson wrote: On Tue, 2015-03-10 at 01:06 +1100, Alexey Kardashevskiy wrote: This checks that the TCE table page size is not bigger that the size of a page we just pinned and going to put its physical address to the table. Otherwise the hardware gets unwanted

Re: [PATCH v5 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-10 Thread Alexey Kardashevskiy
On 03/11/2015 10:03 AM, Alex Williamson wrote: On Wed, 2015-03-11 at 09:57 +1100, Alexey Kardashevskiy wrote: On 03/11/2015 06:56 AM, Alex Williamson wrote: On Tue, 2015-03-10 at 01:06 +1100, Alexey Kardashevskiy wrote: This checks that the TCE table page size is not bigger that the size of a

Re: [PATCH v5 27/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework ownership

2015-03-10 Thread Alexey Kardashevskiy
On 03/11/2015 11:09 AM, Alex Williamson wrote: On Tue, 2015-03-10 at 01:07 +1100, Alexey Kardashevskiy wrote: Before the IOMMU user would take control over the IOMMU table belonging to a specific IOMMU group. This approach did not allow sharing tables between IOMMU groups attached to the same

[PATCH SLOF] pci-properties: Remove redundant call to device-type

2015-03-10 Thread Alexey Kardashevskiy
itself but disks on its bus do. virtio-ballon won't get the device_type property as there is no driver for it. Signed-off-by: Alexey Kardashevskiy --- I'll wait for a couple of days and push it to github if nobody objects. Ben suggested that the linux guest must not rely on device_ty

Re: [PATCH v5 25/29] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-03-11 Thread Alexey Kardashevskiy
On 03/10/2015 01:07 AM, Alexey Kardashevskiy wrote: This extends iommu_table_group_ops by a set of callbacks to support dynamic DMA windows management. query() returns IOMMU capabilities such as default DMA window address and supported number of DMA windows and TCE table levels. create_table

Re: [PATCH SLOF] pci-properties: Remove redundant call to device-type

2015-03-11 Thread Alexey Kardashevskiy
On 03/11/2015 07:21 PM, Benjamin Herrenschmidt wrote: On Wed, 2015-03-11 at 08:50 +0100, Thomas Huth wrote: - Graphic cards should get the "display" device_type ... I guess that's missing now? At least the code for qemu-vga does it - pci bus nodes (like bridges) should get the "pci" devi

[PATCH slof v2] pci-properties: Remove redundant call to device-type

2015-03-12 Thread Alexey Kardashevskiy
itself but disks on its bus do. virtio-ballon won't get the device_type property as there is no driver for it. While we are here, remove device-type from usb-mouse as well. Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * removed usb mouse as well - slof does not implement it --- slof/f

[PATCH kernel v6 00/29] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-03-13 Thread Alexey Kardashevskiy
required for DDW * PEs (IOMMU groups) are passed to VFIO with no DMA windows at all so we do not bother with iommu_table::it_map anymore * added multilevel TCE tables support to support really huge guests v2: * added missing __pa() in "powerpc/powernv: Release replaced TCE"

[PATCH kernel v6 04/29] vfio: powerpc/spapr: Use it_page_size

2015-03-13 Thread Alexey Kardashevskiy
This makes use of the it_page_size from the iommu_table struct as page size can differ. This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code as recently introduced IOMMU_PAGE_XXX macros do not include IOMMU_PAGE_SHIFT. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David

[PATCH kernel v6 02/29] vfio: powerpc/spapr: Do cleanup when releasing the group

2015-03-13 Thread Alexey Kardashevskiy
This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++--- 1 file changed, 11 insertions(+), 3

[PATCH kernel v6 01/29] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-03-13 Thread Alexey Kardashevskiy
only. This removes page unpinning from iommu_take_ownership() as the actual TCE table might contain garbage and doing put_page() on it is undefined behaviour. Besides the last part, the rest of the patch is mechanical. Signed-off-by: Alexey Kardashevskiy --- Changes: v4: * s/iommu_tce_build(tbl

[PATCH kernel v6 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-13 Thread Alexey Kardashevskiy
compound_order() and compound_head() work correctly on non-huge pages, there is no need for additional check whether the page is huge. Signed-off-by: Alexey Kardashevskiy --- Changes: v6: * the helper is simplified to one line v4: * s/tce_check_page_size/tce_page_is_contained/ --- drivers/vfio

[PATCH kernel v6 16/29] powerpc/iommu: Fix IOMMU ownership control functions

2015-03-13 Thread Alexey Kardashevskiy
it_map. Clearing must be done outside of the table locks as iommu_clear_tce() called from iommu_clear_tces_and_put_pages() does this. Signed-off-by: Alexey Kardashevskiy --- Changes: v5: * do not store bit#0 value, it has to be set for zero-based table anyway * removed test_and_clear_bit --- arch

[PATCH kernel v6 22/29] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-03-13 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch

[PATCH kernel v6 18/29] powerpc/iommu/powernv: Release replaced TCE

2015-03-13 Thread Alexey Kardashevskiy
be calculated by platform code from DMA direction. This moves SetPageDirty() to the IOMMU code to make it work for both VFIO ioctl interface in in-kernel TCE acceleration (when it becomes available later). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 15

[PATCH kernel v6 08/29] vfio: powerpc/spapr: Register memory

2015-03-13 Thread Alexey Kardashevskiy
locked_vm accounting. Signed-off-by: Alexey Kardashevskiy --- Changes: v6: * tce_get_hva_cached() returns hva via a pointer v4: * updated docs * s/kzmalloc/vzalloc/ * in tce_pin_pages()/tce_unpin_pages() removed @vaddr, @size and replaced offset with index * renamed vfio_iommu_type_register_memory

<    3   4   5   6   7   8   9   10   11   12   >