Re: [PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table

2015-07-23 Thread Alexey Kardashevskiy
On 07/21/2015 04:24 PM, Michael Ellerman wrote: On Mon, 2015-07-20 at 20:45 +1000, Alexey Kardashevskiy wrote: The existing code stores the amount of memory allocated for a TCE table. At the moment it uses @offset which is a virtual offset in the TCE table which is only correct for a one level

[PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table

2015-07-20 Thread Alexey Kardashevskiy
, WARN_ON in tce_iommu_create_table() prints a warning. This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages() to count actually allocated memory. Signed-off-by: Alexey Kardashevskiy --- I was sure I sent it already but could not find it anywhere so reposting. Sorry

[PATCH kernel] powerpc/powernv/ioda2: Fix calculation for memory allocated for TCE table

2015-07-20 Thread Alexey Kardashevskiy
, WARN_ON in tce_iommu_create_table() prints a warning. This adds an additional counter to pnv_pci_ioda2_table_do_alloc_pages() to count actually allocated memory. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- I was sure I sent it already but could not find it anywhere so reposting. Sorry

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-30 Thread Alexey Kardashevskiy
On 06/30/2015 04:08 PM, SF Markus Elfring wrote: than the existing one should have been renamed to "free_exit" or "free_unlock_exit" and new one would be "unlock_exit". I chose a smaller change at this place. I'd just drop this patch. How do you think about to improve the affected jump

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-30 Thread Alexey Kardashevskiy
On 06/30/2015 04:08 PM, SF Markus Elfring wrote: than the existing one should have been renamed to free_exit or free_unlock_exit and new one would be unlock_exit. I chose a smaller change at this place. I'd just drop this patch. How do you think about to improve the affected jump labels a

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-29 Thread Alexey Kardashevskiy
On 06/29/2015 04:02 PM, SF Markus Elfring wrote: tcegrp will be NULL and kfree() can handle this just fine The affected function did not show this API knowledge, did it? but you fixed this in 1/2 :) (is not it the whole point of this patchset - remove the check and just call kfree()

Re: vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-29 Thread Alexey Kardashevskiy
On 06/29/2015 04:02 PM, SF Markus Elfring wrote: tcegrp will be NULL and kfree() can handle this just fine The affected function did not show this API knowledge, did it? but you fixed this in 1/2 :) (is not it the whole point of this patchset - remove the check and just call kfree()

Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-28 Thread Alexey Kardashevskiy
On 06/29/2015 02:24 AM, SF Markus Elfring wrote: From: Markus Elfring Date: Sun, 28 Jun 2015 17:58:42 +0200 The kfree() function was called even if a previous memory allocation try failed. tcegrp will be NULL and kfree() can handle this just fine (is not it the whole point of this patchset

Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

2015-06-28 Thread Alexey Kardashevskiy
On 06/29/2015 02:24 AM, SF Markus Elfring wrote: From: Markus Elfring elfr...@users.sourceforge.net Date: Sun, 28 Jun 2015 17:58:42 +0200 The kfree() function was called even if a previous memory allocation try failed. tcegrp will be NULL and kfree() can handle this just fine (is not it the

[PATCH kernel] powerpc/iommu/ioda2: Enable compile with IOV=on and IOMMU_API=off

2015-06-15 Thread Alexey Kardashevskiy
of IOMMU_API block and enables it for either or both IOMMU_API and PCI_IOV. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 50 --- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b

[PATCH kernel] powerpc/iommu/ioda2: Enable compile with IOV=on and IOMMU_API=off

2015-06-15 Thread Alexey Kardashevskiy
of IOMMU_API block and enables it for either or both IOMMU_API and PCI_IOV. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- arch/powerpc/platforms/powernv/pci-ioda.c | 50 --- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/platforms/powernv

Re: [PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-12 Thread Alexey Kardashevskiy
On 06/13/2015 01:06 AM, Nishanth Aravamudan wrote: On 12.06.2015 [16:47:03 +1000], Gavin Shan wrote: On Fri, Jun 12, 2015 at 04:19:17PM +1000, Alexey Kardashevskiy wrote: The existing code puts all devices from a root PE to the same IOMMU group. However it is a possible situation when

[PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-12 Thread Alexey Kardashevskiy
pnv_ioda_setup_bus_dma() invocation to only PEs which own all subordinate buses. Suggested-by: Gavin Shan Signed-off-by: Alexey Kardashevskiy --- This would be nice to have together with the DDW patchset. This does not fix anything DDW patchset did, it fixes IOMMU groups management which is essential for the whole

[PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-12 Thread Alexey Kardashevskiy
pnv_ioda_setup_bus_dma() invocation to only PEs which own all subordinate buses. Suggested-by: Gavin Shan gws...@linux.vnet.ibm.com Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- This would be nice to have together with the DDW patchset. This does not fix anything DDW patchset did, it fixes IOMMU groups

Re: [PATCH kernel] powerpc/powernv/ioda2: Add devices only from buses which belong to PE

2015-06-12 Thread Alexey Kardashevskiy
On 06/13/2015 01:06 AM, Nishanth Aravamudan wrote: On 12.06.2015 [16:47:03 +1000], Gavin Shan wrote: On Fri, Jun 12, 2015 at 04:19:17PM +1000, Alexey Kardashevskiy wrote: The existing code puts all devices from a root PE to the same IOMMU group. However it is a possible situation when

[PATCH kernel v12.2] powerpc/powernv: Fix crash when CONFIG_IOMMU_API is off

2015-06-10 Thread Alexey Kardashevskiy
this case. This replaces BUG_ON with WARN_ON and removes the check as it is a wrong place for it anyway. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc

[PATCH kernel v12.2] powerpc/powernv: Fix crash when CONFIG_IOMMU_API is off

2015-06-10 Thread Alexey Kardashevskiy
BUG_ON with WARN_ON and removes the check as it is a wrong place for it anyway. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- arch/powerpc/platforms/powernv/pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc

[PATCH kernel] powerpc/powernv: Fix crash when CONFIG_IOMMU_API is off

2015-06-09 Thread Alexey Kardashevskiy
this case. This makes BUG_ON conditional. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 4b4c583..a57554a 100644 --- a/ar

[PATCH kernel] powerpc/pseries: Fix compile error when CONFIG_IOMMU_API if off

2015-06-09 Thread Alexey Kardashevskiy
This fixes compile error introduced in "[PATCH kernel v12 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group". Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc

[PATCH kernel] powerpc/pseries: Fix compile error when CONFIG_IOMMU_API if off

2015-06-09 Thread Alexey Kardashevskiy
This fixes compile error introduced in [PATCH kernel v12 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- arch/powerpc/platforms/pseries/iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc

[PATCH kernel] powerpc/powernv: Fix crash when CONFIG_IOMMU_API is off

2015-06-09 Thread Alexey Kardashevskiy
BUG_ON conditional. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- arch/powerpc/platforms/powernv/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 4b4c583..a57554a 100644

[PATCH kernel v12 10/34] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-06-05 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 Kardashevskiy

[PATCH kernel v12 20/34] powerpc/powernv/ioda2: Move TCE kill register address to PE

2015-06-05 Thread Alexey Kardashevskiy
ndows (DDW). Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v11: * s/pnv_pci_ioda2_tvt_invalidate/pnv_pci_ioda2_tce_invalidate_entire/g (cannot think of better-and-shorter name) * moved tce_inval_reg_phys/tce_inval_reg to pnv_phb v10: * fixed

[PATCH kernel v12 23/34] powerpc/iommu/powernv: Release replaced TCE

2015-06-05 Thread Alexey Kardashevskiy
are to 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 [aw: for the vfio related changes] Acked

[PATCH kernel v12 19/34] powerpc/iommu: Fix IOMMU ownership control functions

2015-06-05 Thread Alexey Kardashevskiy
to prevent buggy drivers from crashing when allocated page is bus-mapped at zero (which is correct). This restores the bit in the case of failure to bring the it_map to the state it was in when we called iommu_take_ownership(). Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed

[PATCH kernel v12 27/34] powerpc/powernv: Implement multilevel TCE tables

2015-06-05 Thread Alexey Kardashevskiy
to 5 levels which splits the table into a tree of smaller subtables. This adds multi-level TCE tables support to pnv_pci_ioda2_table_alloc_pages() and pnv_pci_ioda2_table_free_pages() helpers. Signed-off-by: Alexey Kardashevskiy --- Changes: v12: * changed pnv_pci_ioda2_table_do_alloc_pages

[PATCH kernel v12 13/34] powerpc/powernv: Do not set "read" flag if direction==DMA_NONE

2015-06-05 Thread Alexey Kardashevskiy
bits) will be used to decide whether to put the page or not. This adds iommu_direction_to_tce_perm() (its counterpart is there already) and uses it for powernv's pnv_tce_build(). Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v9: * added comment

[PATCH kernel v12 15/34] powerpc/powernv/ioda/ioda2: Rework TCE invalidation in tce_build()/tce_free()

2015-06-05 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v11: * changed type of some "ret" to int as everywhere else v10: * moved before "Switch from iommu_table to new iommu_table_group" as it adds list of groups to iommu_table

[PATCH kernel v12 09/34] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-06-05 Thread Alexey Kardashevskiy
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 [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v12: * added WARN_ON_ONCE

[PATCH kernel v12 06/34] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-06-05 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 [aw: for the vfio related changes] Acked

[PATCH kernel v12 14/34] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-06-05 Thread Alexey Kardashevskiy
lbacks for IODA1/2. No change in behaviour is expected. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v9: * pnv_tce_build/pnv_tce_free/pnv_tce_get have been made public and lost "rm" parameters to make following patches simpler (realmode

[PATCH kernel v12 07/34] vfio: powerpc/spapr: Check that IOMMU page is fully contained by system page

2015-06-05 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 [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v8

[PATCH kernel v12 25/34] powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages

2015-06-05 Thread Alexey Kardashevskiy
/free the iommu_table struct. This enforces window size to be a power of two. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan Reviewed-by: David Gibson --- Changes: v10: * removed @table_group parameter from pnv_pci_create_table

[PATCH kernel v12 18/34] vfio: powerpc/spapr/iommu/powernv/ioda2: Rework IOMMU ownership control

2015-06-05 Thread Alexey Kardashevskiy
here and touching bypass control, this removes pnv_pci_ioda2_setup_bypass_pe() as it does not do much more compared to pnv_pci_ioda2_set_bypass. This moves tce_bypass_base initialization to pnv_pci_ioda2_setup_dma_pe. Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked

[PATCH kernel v12 26/34] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-06-05 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. pnv_pci_ioda2_set_window() takes an iommu_table_group as a first parameter (not pnv_ioda_pe) as it is going to be used as a callback for VFIO DDW code. This should cause no behavioural change. Signed-off-by: Alexey

[PATCH kernel v12 22/34] powerpc/powernv: Implement accessor to TCE entry

2015-06-05 Thread Alexey Kardashevskiy
This replaces direct accesses to TCE table with a helper which returns an TCE entry address. This does not make difference now but will when multi-level TCE tables get introduces. No change in behavior is expected. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed

[PATCH kernel v12 31/34] vfio: powerpc/spapr: powerpc/powernv/ioda2: Use DMA windows API in ownership control

2015-06-05 Thread Alexey Kardashevskiy
a pnv_pci_ioda2_setup_default_config() which is called when PE is being configured at boot time and when the ownership is passed from VFIO to the platform code. Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson --- Changes: v10

[PATCH kernel v12 16/34] powerpc/spapr: vfio: Replace iommu_table with iommu_table_group

2015-06-05 Thread Alexey Kardashevskiy
-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v11: * iommu_table_group moved outside #ifdef CONFIG_IOMMU_API as iommu_table is dynamically allocated and it needs a pointer to PE and iommu_table_group

[PATCH kernel v12 04/34] powerpc/iommu: Put IOMMU group explicitly

2015-06-05 Thread Alexey Kardashevskiy
() and iommu_free_table(). Later it will be changed to receive a table_group and we will have to change less lines then. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan Reviewed-by: David Gibson --- arch/powerpc/kernel/iommu.c | 7

[PATCH kernel v12 03/34] powerpc/powernv/ioda: Clean up IOMMU group registration

2015-06-05 Thread Alexey Kardashevskiy
The existing code has 3 calls to iommu_register_group() and all 3 branches actually cover all possible cases. This replaces 3 calls with one and moves the registration earlier; the latter will make more sense when we add TCE table sharing. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin

[PATCH kernel v12 30/34] powerpc/iommu/ioda2: Add get_table_size() to calculate the size of future table

2015-06-05 Thread Alexey Kardashevskiy
. This defines an iommu_table_group_ops callback to let VFIO know how much memory will be locked if a table is created. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- Changes: v10: * s/ROUND_UP/_ALIGN_UP/ * fixed rounding up for @entries_shift (used to use ROUND_UP) v9

[PATCH kernel v12 32/34] powerpc/mmu: Add userspace-to-physical addresses translation cache

2015-06-05 Thread Alexey Kardashevskiy
mory is still pinned and unregistration needs to be retried; @used remains 1. Host physical addresses are stored in vmalloc'ed array. In order to access these in the real mode (mmu off), there is a real_vmalloc_addr() helper. In-kernel acceleration patchset will move it from KVM to MMU code. S

[PATCH kernel v12 08/34] vfio: powerpc/spapr: Use it_page_size

2015-06-05 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 v12 11/34] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-06-05 Thread Alexey Kardashevskiy
-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v9: * changed helpers to work with physical addresses rather than linear (for simplicity - later ::xchg() will receive physical and avoid

[PATCH kernel v12 12/34] vfio: powerpc/spapr: Rework groups attaching

2015-06-05 Thread Alexey Kardashevskiy
This is to make extended ownership and multiple groups support patches simpler for review. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- drivers

[PATCH kernel v12 29/34] powerpc/powernv/ioda2: Use new helpers to do proper cleanup on PE release

2015-06-05 Thread Alexey Kardashevskiy
The existing code programmed TVT#0 with some address and then immediately released that memory. This makes use of pnv_pci_ioda2_unset_window() and pnv_pci_ioda2_set_bypass() which do correct resource release and TVT update. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson

[PATCH kernel v12 05/34] powerpc/iommu: Always release iommu_table in iommu_free_table()

2015-06-05 Thread Alexey Kardashevskiy
in which case it_map is NULL so does the patch. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v11: * fixed parameter checks --- arch/powerpc/kernel/iommu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/powerpc

[PATCH kernel v12 28/34] vfio: powerpc/spapr: powerpc/powernv/ioda: Define and implement DMA windows API

2015-06-05 Thread Alexey Kardashevskiy
in a container. This adds IOMMU capabilities to iommu_table_group such as default 32bit window parameters and others. This makes use of new values in vfio_iommu_spapr_tce. IODA1/P5IOC2 do not support DDW so they do not advertise pagemasks to the userspace. Signed-off-by: Alexey Kardashevskiy Acked-by: Alex

[PATCH kernel v12 00/34] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-06-05 Thread Alexey Kardashevskiy
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 (34): powerpc/eeh/ioda2: Use device::iommu_group to check IOMMU group powerpc/iommu/powernv

[PATCH kernel v12 24/34] powerpc/powernv/ioda2: Rework iommu_table creation

2015-06-05 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning to make following changes easier to review. This starts using table parameters from the iommu_table struct. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan

[PATCH kernel v12 21/34] powerpc/powernv/ioda2: Add TCE invalidation for all attached groups

2015-06-05 Thread Alexey Kardashevskiy
pnv_pci_ioda1_tce_invalidate() as there is no plan to enable TCE table sharing on PHBs older than IODA2. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Reviewed-by: Gavin Shan --- Changes: v10: * new to the series --- arch/powerpc/platforms/powernv/pci-ioda.c | 35 --- 1

[PATCH kernel v12 02/34] powerpc/iommu/powernv: Get rid of set_iommu_table_base_and_group

2015-06-05 Thread Alexey Kardashevskiy
: - for physical PE, the device is already attached by iommu_add_device() in pnv_pci_ioda_setup_dma_pe(); - for virtual PE, the sysfs entries are not ready to create all symlinks so actual adding is happening in tce_iommu_bus_notifier. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Gavin Shan Reviewed

[PATCH kernel v12 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-06-05 Thread Alexey Kardashevskiy
and because it is not really needed in most cases. IODA2 is fixed in a later patch. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: Gavin Shan --- Changes: v12: * fixed iommu_add_device() to check

[PATCH kernel v12 33/34] vfio: powerpc/spapr: Register memory and define IOMMU v2

2015-06-05 Thread Alexey Kardashevskiy
), this creates a default DMA window for IODA2 for consistency. Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson --- Changes: v12: * tce_iommu_unregister_pages() is fixed to use mm_iommu_find() which enforces the requirement to unregister exactly

[PATCH kernel v12 34/34] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-06-05 Thread Alexey Kardashevskiy
for the sake of TCE acceleration in KVM (coming soon). Signed-off-by: Alexey Kardashevskiy [aw: for the vfio related changes] Acked-by: Alex Williamson Reviewed-by: David Gibson --- Changes: v7: * s/VFIO_IOMMU_INFO_DDW/VFIO_IOMMU_SPAPR_INFO_DDW/ * fixed typos in and updated vfio.txt * fixed

[PATCH kernel v12 01/34] powerpc/eeh/ioda2: Use device::iommu_group to check IOMMU group

2015-06-05 Thread Alexey Kardashevskiy
the @add_to_iommu_group parameter from pnv_ioda_setup_bus_dma(). Signed-off-by: Alexey Kardashevskiy Acked-by: Gavin Shan Reviewed-by: David Gibson --- arch/powerpc/kernel/eeh.c | 4 +--- arch/powerpc/platforms/powernv/pci-ioda.c | 27 +-- 2 files changed

[PATCH kernel v12 01/34] powerpc/eeh/ioda2: Use device::iommu_group to check IOMMU group

2015-06-05 Thread Alexey Kardashevskiy
the @add_to_iommu_group parameter from pnv_ioda_setup_bus_dma(). Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Acked-by: Gavin Shan gws...@linux.vnet.ibm.com Reviewed-by: David Gibson da...@gibson.dropbear.id.au --- arch/powerpc/kernel/eeh.c | 4 +--- arch/powerpc/platforms

[PATCH kernel v12 27/34] powerpc/powernv: Implement multilevel TCE tables

2015-06-05 Thread Alexey Kardashevskiy
to 5 levels which splits the table into a tree of smaller subtables. This adds multi-level TCE tables support to pnv_pci_ioda2_table_alloc_pages() and pnv_pci_ioda2_table_free_pages() helpers. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v12: * changed

[PATCH kernel v12 23/34] powerpc/iommu/powernv: Release replaced TCE

2015-06-05 Thread Alexey Kardashevskiy
are to 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 a...@ozlabs.ru [aw: for the vfio related changes

[PATCH kernel v12 19/34] powerpc/iommu: Fix IOMMU ownership control functions

2015-06-05 Thread Alexey Kardashevskiy
to prevent buggy drivers from crashing when allocated page is bus-mapped at zero (which is correct). This restores the bit in the case of failure to bring the it_map to the state it was in when we called iommu_take_ownership(). Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da

[PATCH kernel v12 09/34] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-06-05 Thread Alexey Kardashevskiy
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 a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson da

[PATCH kernel v12 06/34] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-06-05 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 a...@ozlabs.ru [aw: for the vfio related

[PATCH kernel v12 15/34] powerpc/powernv/ioda/ioda2: Rework TCE invalidation in tce_build()/tce_free()

2015-06-05 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v11: * changed type of some ret to int as everywhere else v10: * moved before Switch from iommu_table to new iommu_table_group

[PATCH kernel v12 13/34] powerpc/powernv: Do not set read flag if direction==DMA_NONE

2015-06-05 Thread Alexey Kardashevskiy
bits) will be used to decide whether to put the page or not. This adds iommu_direction_to_tce_perm() (its counterpart is there already) and uses it for powernv's pnv_tce_build(). Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed

[PATCH kernel v12 04/34] powerpc/iommu: Put IOMMU group explicitly

2015-06-05 Thread Alexey Kardashevskiy
() and iommu_free_table(). Later it will be changed to receive a table_group and we will have to change less lines then. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com Reviewed-by: David Gibson da

[PATCH kernel v12 16/34] powerpc/spapr: vfio: Replace iommu_table with iommu_table_group

2015-06-05 Thread Alexey Kardashevskiy
-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v11: * iommu_table_group moved outside #ifdef CONFIG_IOMMU_API

[PATCH kernel v12 22/34] powerpc/powernv: Implement accessor to TCE entry

2015-06-05 Thread Alexey Kardashevskiy
This replaces direct accesses to TCE table with a helper which returns an TCE entry address. This does not make difference now but will when multi-level TCE tables get introduces. No change in behavior is expected. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da

[PATCH kernel v12 31/34] vfio: powerpc/spapr: powerpc/powernv/ioda2: Use DMA windows API in ownership control

2015-06-05 Thread Alexey Kardashevskiy
a pnv_pci_ioda2_setup_default_config() which is called when PE is being configured at boot time and when the ownership is passed from VFIO to the platform code. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed

[PATCH kernel v12 03/34] powerpc/powernv/ioda: Clean up IOMMU group registration

2015-06-05 Thread Alexey Kardashevskiy
The existing code has 3 calls to iommu_register_group() and all 3 branches actually cover all possible cases. This replaces 3 calls with one and moves the registration earlier; the latter will make more sense when we add TCE table sharing. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

[PATCH kernel v12 33/34] vfio: powerpc/spapr: Register memory and define IOMMU v2

2015-06-05 Thread Alexey Kardashevskiy
), this creates a default DMA window for IODA2 for consistency. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com --- Changes: v12: * tce_iommu_unregister_pages() is fixed to use mm_iommu_find() which enforces

[PATCH kernel v12 00/34] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-06-05 Thread Alexey Kardashevskiy
() in powerpc/powernv: Release replaced TCE * reposted to make some noise Alexey Kardashevskiy (34): powerpc/eeh/ioda2: Use device::iommu_group to check IOMMU group powerpc/iommu/powernv: Get rid of set_iommu_table_base_and_group powerpc/powernv/ioda: Clean up IOMMU group registration powerpc

[PATCH kernel v12 24/34] powerpc/powernv/ioda2: Rework iommu_table creation

2015-06-05 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning to make following changes easier to review. This starts using table parameters from the iommu_table struct. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da

[PATCH kernel v12 02/34] powerpc/iommu/powernv: Get rid of set_iommu_table_base_and_group

2015-06-05 Thread Alexey Kardashevskiy
: - for physical PE, the device is already attached by iommu_add_device() in pnv_pci_ioda_setup_dma_pe(); - for virtual PE, the sysfs entries are not ready to create all symlinks so actual adding is happening in tce_iommu_bus_notifier. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: Gavin

[PATCH kernel v12 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-06-05 Thread Alexey Kardashevskiy
and because it is not really needed in most cases. IODA2 is fixed in a later patch. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: Gavin Shan gws

[PATCH kernel v12 21/34] powerpc/powernv/ioda2: Add TCE invalidation for all attached groups

2015-06-05 Thread Alexey Kardashevskiy
pnv_pci_ioda1_tce_invalidate() as there is no plan to enable TCE table sharing on PHBs older than IODA2. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v10: * new to the series --- arch/powerpc

[PATCH kernel v12 34/34] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-06-05 Thread Alexey Kardashevskiy
for the sake of TCE acceleration in KVM (coming soon). Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson da...@gibson.dropbear.id.au --- Changes: v7: * s/VFIO_IOMMU_INFO_DDW

[PATCH kernel v12 14/34] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-06-05 Thread Alexey Kardashevskiy
is expected. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v9: * pnv_tce_build/pnv_tce_free/pnv_tce_get have been made public and lost rm parameters to make following patches

[PATCH kernel v12 18/34] vfio: powerpc/spapr/iommu/powernv/ioda2: Rework IOMMU ownership control

2015-06-05 Thread Alexey Kardashevskiy
here and touching bypass control, this removes pnv_pci_ioda2_setup_bypass_pe() as it does not do much more compared to pnv_pci_ioda2_set_bypass. This moves tce_bypass_base initialization to pnv_pci_ioda2_setup_dma_pe. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related

[PATCH kernel v12 26/34] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-06-05 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. pnv_pci_ioda2_set_window() takes an iommu_table_group as a first parameter (not pnv_ioda_pe) as it is going to be used as a callback for VFIO DDW code. This should cause no behavioural change. Signed-off-by: Alexey

[PATCH kernel v12 07/34] vfio: powerpc/spapr: Check that IOMMU page is fully contained by system page

2015-06-05 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 a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson da

[PATCH kernel v12 25/34] powerpc/powernv/ioda2: Introduce helpers to allocate TCE pages

2015-06-05 Thread Alexey Kardashevskiy
/free the iommu_table struct. This enforces window size to be a power of two. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com Reviewed-by: David Gibson da...@gibson.dropbear.id.au --- Changes: v10: * removed

[PATCH kernel v12 10/34] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-06-05 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 Kardashevskiy

[PATCH kernel v12 20/34] powerpc/powernv/ioda2: Move TCE kill register address to PE

2015-06-05 Thread Alexey Kardashevskiy
). Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v11: * s/pnv_pci_ioda2_tvt_invalidate/pnv_pci_ioda2_tce_invalidate_entire/g (cannot think of better-and-shorter name) * moved

[PATCH kernel v12 28/34] vfio: powerpc/spapr: powerpc/powernv/ioda: Define and implement DMA windows API

2015-06-05 Thread Alexey Kardashevskiy
in a container. This adds IOMMU capabilities to iommu_table_group such as default 32bit window parameters and others. This makes use of new values in vfio_iommu_spapr_tce. IODA1/P5IOC2 do not support DDW so they do not advertise pagemasks to the userspace. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru

[PATCH kernel v12 32/34] powerpc/mmu: Add userspace-to-physical addresses translation cache

2015-06-05 Thread Alexey Kardashevskiy
and unregistration needs to be retried; @used remains 1. Host physical addresses are stored in vmalloc'ed array. In order to access these in the real mode (mmu off), there is a real_vmalloc_addr() helper. In-kernel acceleration patchset will move it from KVM to MMU code. Signed-off-by: Alexey

[PATCH kernel v12 08/34] vfio: powerpc/spapr: Use it_page_size

2015-06-05 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 a...@ozlabs.ru Reviewed

[PATCH kernel v12 11/34] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-06-05 Thread Alexey Kardashevskiy
-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v9: * changed helpers to work with physical

[PATCH kernel v12 30/34] powerpc/iommu/ioda2: Add get_table_size() to calculate the size of future table

2015-06-05 Thread Alexey Kardashevskiy
. This defines an iommu_table_group_ops callback to let VFIO know how much memory will be locked if a table is created. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au --- Changes: v10: * s/ROUND_UP/_ALIGN_UP/ * fixed rounding up

[PATCH kernel v12 12/34] vfio: powerpc/spapr: Rework groups attaching

2015-06-05 Thread Alexey Kardashevskiy
This is to make extended ownership and multiple groups support patches simpler for review. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru [aw: for the vfio related changes] Acked-by: Alex Williamson alex.william...@redhat.com Reviewed-by: David Gibson

[PATCH kernel v12 29/34] powerpc/powernv/ioda2: Use new helpers to do proper cleanup on PE release

2015-06-05 Thread Alexey Kardashevskiy
The existing code programmed TVT#0 with some address and then immediately released that memory. This makes use of pnv_pci_ioda2_unset_window() and pnv_pci_ioda2_set_bypass() which do correct resource release and TVT update. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David

[PATCH kernel v12 05/34] powerpc/iommu: Always release iommu_table in iommu_free_table()

2015-06-05 Thread Alexey Kardashevskiy
in which case it_map is NULL so does the patch. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru Reviewed-by: David Gibson da...@gibson.dropbear.id.au Reviewed-by: Gavin Shan gws...@linux.vnet.ibm.com --- Changes: v11: * fixed parameter checks --- arch/powerpc/kernel/iommu.c | 8 +--- 1 file

Re: [PATCH kernel v11 21/34] powerpc/powernv/ioda2: Add TCE invalidation for all attached groups

2015-06-04 Thread Alexey Kardashevskiy
On 06/05/2015 10:27 AM, Gavin Shan wrote: On Fri, May 29, 2015 at 06:44:45PM +1000, Alexey Kardashevskiy wrote: The iommu_table struct keeps a list of IOMMU groups it is used for. At the moment there is just a single group attached but further patches will add TCE table sharing. When sharing

Re: [PATCH kernel v11 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-06-04 Thread Alexey Kardashevskiy
On 06/01/2015 04:24 PM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:41PM +1000, Alexey Kardashevskiy wrote: 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

Re: [PATCH kernel v11 21/34] powerpc/powernv/ioda2: Add TCE invalidation for all attached groups

2015-06-04 Thread Alexey Kardashevskiy
On 06/05/2015 10:27 AM, Gavin Shan wrote: On Fri, May 29, 2015 at 06:44:45PM +1000, Alexey Kardashevskiy wrote: The iommu_table struct keeps a list of IOMMU groups it is used for. At the moment there is just a single group attached but further patches will add TCE table sharing. When sharing

Re: [PATCH kernel v11 17/34] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-06-04 Thread Alexey Kardashevskiy
On 06/01/2015 04:24 PM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:41PM +1000, Alexey Kardashevskiy wrote: 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

Re: [PATCH kernel v11 33/34] vfio: powerpc/spapr: Register memory and define IOMMU v2

2015-06-03 Thread Alexey Kardashevskiy
On 06/02/2015 02:17 PM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:57PM +1000, Alexey Kardashevskiy wrote: The existing implementation accounts the whole DMA window in the locked_vm counter. This is going to be worse with multiple containers and huge DMA windows. Also, real-time

Re: [PATCH kernel v11 27/34] powerpc/powernv: Implement multilevel TCE tables

2015-06-03 Thread Alexey Kardashevskiy
On 06/02/2015 09:50 AM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:51PM +1000, Alexey Kardashevskiy wrote: TCE tables might get too big in case of 4K IOMMU pages and DDW enabled on huge guests (hundreds of GB of RAM) so the kernel might be unable to allocate contiguous chunk of physical

Re: [PATCH kernel v11 26/34] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-06-03 Thread Alexey Kardashevskiy
On 06/02/2015 09:30 AM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:50PM +1000, Alexey Kardashevskiy wrote: This is a part of moving DMA window programming to an iommu_ops callback. pnv_pci_ioda2_set_window() takes an iommu_table_group as a first parameter (not pnv_ioda_pe) as it is going

Re: [PATCH kernel v11 09/34] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-06-03 Thread Alexey Kardashevskiy
On 06/01/2015 02:28 PM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:33PM +1000, Alexey Kardashevskiy wrote: There moves locked pages accounting to helpers. Later they will be reused for Dynamic DMA windows (DDW). This reworks debug messages to show the current value and the limit

Re: [PATCH kernel v11 26/34] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-06-03 Thread Alexey Kardashevskiy
On 06/02/2015 09:30 AM, David Gibson wrote: On Fri, May 29, 2015 at 06:44:50PM +1000, Alexey Kardashevskiy wrote: This is a part of moving DMA window programming to an iommu_ops callback. pnv_pci_ioda2_set_window() takes an iommu_table_group as a first parameter (not pnv_ioda_pe) as it is going

<    1   2   3   4   5   6   7   8   9   10   >