[PATCH 1/1] powerpc/kvm: Fix mask size for emulated msgsndp

2020-11-11 Thread Leonardo Bras
6, missing bit 32 t: (arg &= 0x3f) : Gets (RB) 58:63, missing bit 57 Fixes this by applying the correct mask. Signed-off-by: Leonardo Bras --- arch/powerpc/kvm/book3s_hv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch

Re: [PATCH v2 14/14] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2020-09-29 Thread Leonardo Bras
On Tue, 2020-09-29 at 13:55 +1000, Alexey Kardashevskiy wrote: > > On 12/09/2020 03:07, Leonardo Bras wrote: > > Cc: linuxppc-dev@lists.ozlabs.org, linux-ker...@vger.kernel.org, > > > > A previous change introduced the usage of DDW as a bigger indirect DMA > > mappi

Re: [PATCH v2 01/14] powerpc/pseries/iommu: Replace hard-coded page shift

2020-09-29 Thread Leonardo Bras
On Tue, 2020-09-29 at 13:56 +1000, Alexey Kardashevskiy wrote: > > On 12/09/2020 03:07, Leonardo Bras wrote: > > Cc: linuxppc-dev@lists.ozlabs.org, linux-ker...@vger.kernel.org, > > These normally go right before "signed-off-by". > Yeah, it looks like somethin

[PATCH v2 14/14] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2020-09-11 Thread Leonardo Bras
ode works in any way, just adjust naming. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 102 + 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.

[PATCH v2 13/14] powerpc/pseries/iommu: Make use of DDW for indirect mapping

2020-09-11 Thread Leonardo Bras
w property name DMA64_PROPNAME "linux,dma64-ddr-window-info" was created to represent a DDW that does not allow direct mapping. Note: ddw_memory_hotplug_max() was moved up so it can be used in find_existing_ddw(). Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c

[PATCH v2 12/14] powerpc/pseries/iommu: Find existing DDW with given property name

2020-09-11 Thread Leonardo Bras
property names, like the one that will be used for indirect mapping. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc

[PATCH v2 11/14] powerpc/pseries/iommu: Update remove_dma_window() to accept property name

2020-09-11 Thread Leonardo Bras
Cc: linuxppc-dev@lists.ozlabs.org, linux-ker...@vger.kernel.org, Update remove_dma_window() so it can be used to remove DDW with a given property name. This enables the creation of new property names for DDW, so we can have different usage for it, like indirect mapping. Signed-off-by: Leonardo

[PATCH v2 10/14] powerpc/pseries/iommu: Reorganize iommu_table_setparms*() with new helper

2020-09-11 Thread Leonardo Bras
_no_kill. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 149 - 1 file changed, 72 insertions(+), 77 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 510ccb0521af..abd36b257725 100644 --

[PATCH v2 09/14] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2020-09-11 Thread Leonardo Bras
fter of_add_property(), but we get to do tce_setrange_multi_pSeriesLP_walk in all memory, which looks the most expensive operation, only if everything else succeeds. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 106 +++-- 1 file changed, 63 insertions(+)

[PATCH v2 08/14] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2020-09-11 Thread Leonardo Bras
whole partition. Signed-off-by: Leonardo Bras Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 30 -- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c

[PATCH v2 07/14] powerpc/pseries/iommu: Add ddw_list_new_entry() helper

2020-09-11 Thread Leonardo Bras
Cc: linuxppc-dev@lists.ozlabs.org, linux-ker...@vger.kernel.org, There are two functions creating direct_window_list entries in a similar way, so create a ddw_list_new_entry() to avoid duplicity and simplify those functions. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries

[PATCH v2 05/14] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2020-09-11 Thread Leonardo Bras
re is no need to check it in the new helper. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/iommu.c | 61 +++- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/arch/powerpc/include/asm/iommu.h b

[PATCH v2 06/14] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper

2020-09-11 Thread Leonardo Bras
(). Signed-off-by: Leonardo Bras Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index

[PATCH v2 04/14] powerpc/kernel/iommu: Use largepool as a last resort when !largealloc

2020-09-11 Thread Leonardo Bras
ing able to fully use all the available pages for the DMA window. Add pages on largepool as a last resort for !largealloc, making all pages of the DMA window available. Signed-off-by: Leonardo Bras Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/kernel/iommu.c | 9 + 1 file changed

[PATCH v2 03/14] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE() to save TCEs

2020-09-11 Thread Leonardo Bras
tbl), which is easier to read and does the same. Signed-off-by: Leonardo Bras --- arch/powerpc/kernel/iommu.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 9704f3f76e63..7961645a6980 10064

[PATCH v2 02/14] powerpc/pseries/iommu: Makes sure IOMMU_PAGE_SIZE <= PAGE_SIZE

2020-09-11 Thread Leonardo Bras
re (PAGE_SIZE = 4k) < (IOMMU_PAGE_SIZE() = 64k). To avoid this, make sure create_ddw() can only use pagesize <= PAGE_SIZE. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/powerp

[PATCH v2 01/14] powerpc/pseries/iommu: Replace hard-coded page shift

2020-09-11 Thread Leonardo Bras
, and tce_buildmulti_pSeriesLP(). Most places had a tbl struct, so using tbl->it_page_shift was simple. tce_free_pSeriesLP() was a special case, since callers not always have a tbl struct, so adding a tceshift parameter seems the right thing to do. Signed-off-by: Leonardo Bras --- arch/powerpc/include/a

[PATCH v2 00/14] DDW Indirect Mapping

2020-09-11 Thread Leonardo Bras
with an Ethernet VF: 4005:01:00.0 Ethernet controller: Mellanox Technologies MT27700 Family [ConnectX-4 Virtual Function] Patchset was tested with a 64GB DDW which did not map the whole partition (128G). Leonardo Bras (14): powerpc/pseries/iommu: Replace hard-coded page shift powerpc/pseries/iommu

Re: [PATCH v1 02/10] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE on iommu_*_coherent()

2020-09-03 Thread Leonardo Bras
On Thu, 2020-09-03 at 14:41 +1000, Alexey Kardashevskiy wrote: > I am new to this, so I am trying to understand how a memory page mapped > > as DMA, and used for something else could be a problem. > > From the device prospective, there is PCI space and everything from 0 > till 1<<64 is accessibl

Re: [PATCH v1 09/10] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-09-01 Thread Leonardo Bras
On Mon, 2020-08-31 at 14:35 +1000, Alexey Kardashevskiy wrote: > > On 29/08/2020 04:36, Leonardo Bras wrote: > > On Mon, 2020-08-24 at 15:17 +1000, Alexey Kardashevskiy wrote: > > > On 18/08/2020 09:40, Leonardo Bras wrote: > > > > As of today, if the biggest DDW

Re: [PATCH v1 08/10] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2020-09-01 Thread Leonardo Bras
On Mon, 2020-08-31 at 14:34 +1000, Alexey Kardashevskiy wrote: > > On 29/08/2020 01:25, Leonardo Bras wrote: > > On Mon, 2020-08-24 at 15:07 +1000, Alexey Kardashevskiy wrote: > > > On 18/08/2020 09:40, Leonardo Bras wrote: > > > > Code used to create a ddw prope

Re: [PATCH v1 02/10] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE on iommu_*_coherent()

2020-09-01 Thread Leonardo Bras
16M, 256M, 1GB, and the > > > supported set of sizes is different for P8/P9 and type of IO (PHB, > > > NVLink/CAPI). > > > > > > > > > > > > Update those functions to guarantee alignment with requested size > > > > > > usin

Re: [PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift

2020-09-01 Thread Leonardo Bras
On Mon, 2020-08-31 at 13:48 +1000, Alexey Kardashevskiy wrote: > > > > Well, I created this TCE_RPN_BITS = 52 because the previous mask was a > > > > hardcoded 40-bit mask (0xfful), for hard-coded 12-bit (4k) > > > > pagesize, and on PAPR+/LoPAR also defines TCE as having bits 0-51 > > > >

[RFC PATCH 2/2] powerpc/kernel/iommu: Introduce IOMMU DMA pagecache

2020-08-31 Thread Leonardo Bras
ded to iommu_table, have: - Both XArrays, - 2 llist for entry/removal point on FIFO, - 1 Atomic Cachesize, to manage the FIFO. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/iommu-cache.h | 31 arch/powerpc/include/asm/iommu.h | 4 + arch/powerpc/kernel/Makefile

[RFC PATCH 1/2] dma-direction: Add DMA_DIR_COMPAT() macro to test direction compability

2020-08-31 Thread Leonardo Bras
DMA_FROM_DEVICE, DMA_NONE DMA_TO_DEVICE DMA_TO_DEVICE, DMA_NONE DMA_FROM_DEVICE DMA_FROM_DEVICE, DMA_NONE DMA_NONEDMA_NONE This macro is useful for checking if a DMA mapping can be reused. Signed-off-by: Leonardo Bras --- include/linux/dma-direction.h | 3 ++

[RFC PATCH 0/2] DMA pagecache

2020-08-31 Thread Leonardo Bras
e for the FIFO is just for testing purposes. It's also very possible that it will not be a good idea in platforms other than pseries, (i have not tested them). I can plan I bypass for those cases without much work. Thank you! Leonardo Bras (2): dma-direction: Add DMA_DIR_COMPAT() mac

Re: [PATCH v1 06/10] powerpc/pseries/iommu: Add ddw_list_add() helper

2020-08-28 Thread Leonardo Bras
On Fri, 2020-08-28 at 11:58 +1000, Alexey Kardashevskiy wrote: > > On 28/08/2020 08:11, Leonardo Bras wrote: > > On Mon, 2020-08-24 at 13:46 +1000, Alexey Kardashevskiy wrote: > > > > static int find_existing_ddw_windows(void) > > > > { > > >

Re: [PATCH v1 02/10] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE on iommu_*_coherent()

2020-08-28 Thread Leonardo Bras
> > > > > > Update those functions to guarantee alignment with requested size > > > > using IOMMU_PAGE_ALIGN() before doing iommu_alloc() / iommu_free(). > > > > > > > > Also, on iommu_range_alloc(), replace ALIGN(n, 1 << tbl->it_page_sh

Re: [PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift

2020-08-28 Thread Leonardo Bras
On Fri, 2020-08-28 at 12:27 +1000, Alexey Kardashevskiy wrote: > > On 28/08/2020 01:32, Leonardo Bras wrote: > > Hello Alexey, thank you for this feedback! > > > > On Sat, 2020-08-22 at 19:33 +1000, Alexey Kardashevskiy wrote: > > > > +#define TCE_RPN_BITS

Re: [PATCH v1 09/10] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-08-28 Thread Leonardo Bras
On Mon, 2020-08-24 at 15:17 +1000, Alexey Kardashevskiy wrote: > > On 18/08/2020 09:40, Leonardo Bras wrote: > > As of today, if the biggest DDW that can be created can't map the whole > > partition, it's creation is skipped and the default DMA window > >

Re: [PATCH v1 08/10] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2020-08-28 Thread Leonardo Bras
On Mon, 2020-08-24 at 15:07 +1000, Alexey Kardashevskiy wrote: > > On 18/08/2020 09:40, Leonardo Bras wrote: > > Code used to create a ddw property that was previously scattered in > > enable_ddw() is now gathered in ddw_property_create(), which deals with > > allocation

Re: [PATCH v1 07/10] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2020-08-28 Thread Leonardo Bras
On Mon, 2020-08-24 at 13:44 +1000, Alexey Kardashevskiy wrote: > > > On 18/08/2020 09:40, Leonardo Bras wrote: > > enable_ddw() currently returns the address of the DMA window, which is > > considered invalid if has the value 0x00. > > > > Also, it only conside

Re: [PATCH v1 06/10] powerpc/pseries/iommu: Add ddw_list_add() helper

2020-08-27 Thread Leonardo Bras
On Mon, 2020-08-24 at 13:46 +1000, Alexey Kardashevskiy wrote: > > static int find_existing_ddw_windows(void) > > { > > int len; > > @@ -887,18 +905,11 @@ static int find_existing_ddw_windows(void) > > if (!direct64) > > continue; > > > > - window =

Re: [PATCH v1 05/10] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper

2020-08-27 Thread Leonardo Bras
On Mon, 2020-08-24 at 10:38 +1000, Alexey Kardashevskiy wrote: > > On 18/08/2020 09:40, Leonardo Bras wrote: > > Creates a helper to allow allocating a new iommu_table without the need > > to reallocate the iommu_group. > > > > This will be helpful for replacing t

Re: [PATCH v1 04/10] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2020-08-27 Thread Leonardo Bras
gned would cause it to become a big value and run over memory outside the bitmap. But I think you are right. That is not the place to check if the reserved values are valid. It should just trust them here. I intent to change iommu_table_reserve_pages() to only store the parameters in it_reserved_{start,end} if they are in the range, and or it_offset in both of them if they are not. What do you think? Thanks for the feedback! Leonardo Bras

Re: [PATCH v1 03/10] powerpc/kernel/iommu: Use largepool as a last resort when !largealloc

2020-08-27 Thread Leonardo Bras
On Sat, 2020-08-22 at 20:09 +1000, Alexey Kardashevskiy wrote: > > + goto again; > > + > > A nit: unnecessary new line. I was following the pattern used above. There is a newline after every "goto again" in this 'if'. > Reviewed-by: Alexey Kardashevskiy Thank you!

Re: [PATCH v1 02/10] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE on iommu_*_coherent()

2020-08-27 Thread Leonardo Bras
On Sat, 2020-08-22 at 20:07 +1000, Alexey Kardashevskiy wrote: > > On 18/08/2020 09:40, Leonardo Bras wrote: > > Both iommu_alloc_coherent() and iommu_free_coherent() assume that once > > size is aligned to PAGE_SIZE it will be aligned to IOMMU_PAGE_SIZE. > > The only cas

Re: [PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift

2020-08-27 Thread Leonardo Bras
Hello Alexey, thank you for this feedback! On Sat, 2020-08-22 at 19:33 +1000, Alexey Kardashevskiy wrote: > > +#define TCE_RPN_BITS 52 /* Bits 0-51 represent > > RPN on TCE */ > > Ditch this one and use MAX_PHYSMEM_BITS instead? I am pretty sure this > is the actual li

[PATCH v1 10/10] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2020-08-17 Thread Leonardo Bras
flect that it can be used for both kinds of mapping. Also, defines DEFAULT_DMA_WIN as "ibm,dma-window" to document that it's the name of the default DMA window. Those changes are not supposed to change how the code works in any way, just adjust naming. Signed-off-by: Leonardo Bra

[PATCH v1 09/10] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-08-17 Thread Leonardo Bras
-ddr-window-info" looks the right thing to do. To make sure the property differentiates both cases, a new u32 for flags was added at the end of the property, where BIT(0) set means direct mapping. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 108 +

[PATCH v1 08/10] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2020-08-17 Thread Leonardo Bras
sive operation, only if everything else succeeds. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 97 +++--- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c i

[PATCH v1 07/10] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2020-08-17 Thread Leonardo Bras
ow if direct mapping is possible. It can also allow a DMA window starting at 0x00 to be used. This will be helpful for using a DDW with indirect mapping, as the window address will be different than 0x00, but it will not map the whole partition. Signed-off-by: Leonardo Bras --- arch/powerpc/plat

[PATCH v1 06/10] powerpc/pseries/iommu: Add ddw_list_add() helper

2020-08-17 Thread Leonardo Bras
There are two functions adding DDW to the direct_window_list in a similar way, so create a ddw_list_add() to avoid duplicity and simplify those functions. Also, on enable_ddw(), add list_del() on out_free_window to allow removing the window from list if any error occurs. Signed-off-by: Leonardo

[PATCH v1 05/10] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper

2020-08-17 Thread Leonardo Bras
Creates a helper to allow allocating a new iommu_table without the need to reallocate the iommu_group. This will be helpful for replacing the iommu_table for the new DMA window, after we remove the old one with iommu_tce_table_put(). Signed-off-by: Leonardo Bras --- arch/powerpc/platforms

[PATCH v1 04/10] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2020-08-17 Thread Leonardo Bras
efore testing. This causes iommu_table_release_pages() to become unnecessary, given it is only used to remove reserved memory for testing. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/iommu.c | 62 ++-- 2 files ch

[PATCH v1 03/10] powerpc/kernel/iommu: Use largepool as a last resort when !largealloc

2020-08-17 Thread Leonardo Bras
Add pages on largepool as a last resort for !largealloc, making all pages of the DMA window available. Signed-off-by: Leonardo Bras --- arch/powerpc/kernel/iommu.c | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index d70860878

[PATCH v1 02/10] powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE on iommu_*_coherent()

2020-08-17 Thread Leonardo Bras
iommu_range_alloc(), replace ALIGN(n, 1 << tbl->it_page_shift) with IOMMU_PAGE_ALIGN(n, tbl), which seems easier to read. Signed-off-by: Leonardo Bras --- arch/powerpc/kernel/iommu.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arc

[PATCH v1 01/10] powerpc/pseries/iommu: Replace hard-coded page shift

2020-08-17 Thread Leonardo Bras
used. Most places had a tbl struct, so using tbl->it_page_shift was simple. tce_free_pSeriesLP() was a special case, since callers not always have a tbl struct, so adding a tceshift parameter seems the right thing to do. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/tce.h |

[PATCH v1 00/10] DDW indirect mapping

2020-08-17 Thread Leonardo Bras
patches were tested into an LPAR with an Ethernet VF: 4005:01:00.0 Ethernet controller: Mellanox Technologies MT27700 Family [ConnectX-4 Virtual Function] Patchset was tested with a 64GB DDW which did not map the whole partition (128G). Leonardo Bras (10): powerpc/pseries/iommu: Replace hard-co

Re: [PATCH v5 0/4] Allow bigger 64bit window by removing default DMA window

2020-08-11 Thread Leonardo Bras
Hello Michael, Do you suggest any change for this patchset? Any chance it can get in this merge window? Best regards, Leonardo Bras On Wed, 2020-08-05 at 00:04 -0300, Leonardo Bras wrote: > There are some devices in which a hypervisor may only allow 1 DMA window > to exist at a time,

Re: [PATCH v5 0/4] Allow bigger 64bit window by removing default DMA window

2020-08-05 Thread Leonardo Bras
Travis reported successful compilation with mpe/merge: https://travis-ci.org/github/LeoBras/linux-ppc/builds/715028857

[PATCH v5 4/4] powerpc/pseries/iommu: Allow bigger 64bit window by removing default DMA window

2020-08-04 Thread Leonardo Bras
it's boot time value, available in "ibm,dma-window" device tree node. Signed-off-by: Leonardo Bras Tested-by: David Dai --- arch/powerpc/platforms/pseries/iommu.c | 73 +++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platfo

[PATCH v5 3/4] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window

2020-08-04 Thread Leonardo Bras
indow". Signed-off-by: Leonardo Bras Tested-by: David Dai --- arch/powerpc/platforms/pseries/iommu.c | 45 +++--- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1a933c

[PATCH v5 2/4] powerpc/pseries/iommu: Update call to ibm, query-pe-dma-windows

2020-08-04 Thread Leonardo Bras
suggested by LoPAR: First reading the size of the extension array from index 0, checking if the property exists, and then returning it's value. Signed-off-by: Leonardo Bras Tested-by: David Dai --- arch/powerpc/platforms/pseries/iommu.c | 91 +++--- 1 file changed,

[PATCH v5 1/4] powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

2020-08-04 Thread Leonardo Bras
Create defines to help handling ibm,ddw-applicable values, avoiding confusion about the index of given operations. Signed-off-by: Leonardo Bras Tested-by: David Dai --- arch/powerpc/platforms/pseries/iommu.c | 43 -- 1 file changed, 26 insertions(+), 17 deletions

[PATCH v5 0/4] Allow bigger 64bit window by removing default DMA window

2020-08-04 Thread Leonardo Bras
/project/linuxppc-dev/list/?series=184420&state=%2A&archive=both Special thanks for Alexey Kardashevskiy, Brian King and Oliver O'Halloran for the feedback provided! Leonardo Bras (4): powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable powerpc/pseries/iom

Re: [PATCH v4 5/7] powerpc/iommu: Move iommu_table cleaning routine to iommu_table_clean

2020-07-22 Thread Leonardo Bras
On Tue, 2020-07-21 at 19:52 -0500, Brian King wrote: > > > > As of today, there seems to be nothing like that happening in the > > driver I am testing. > > I spoke to Brian King on slack, and he mentioned that at the point DDW > > is created there should be no allocations in place. > > I think t

Re: [PATCH v4 5/7] powerpc/iommu: Move iommu_table cleaning routine to iommu_table_clean

2020-07-22 Thread Leonardo Bras
On Wed, 2020-07-22 at 11:28 +1000, Alexey Kardashevskiy wrote: > > On 22/07/2020 08:13, Leonardo Bras wrote: > > On Tue, 2020-07-21 at 14:59 +1000, Alexey Kardashevskiy wrote: > > > On 16/07/2020 17:16, Leonardo Bras wrote: > > > > Move the part of iommu_table_fr

Re: [PATCH v4 5/7] powerpc/iommu: Move iommu_table cleaning routine to iommu_table_clean

2020-07-21 Thread Leonardo Bras
On Tue, 2020-07-21 at 14:59 +1000, Alexey Kardashevskiy wrote: > > On 16/07/2020 17:16, Leonardo Bras wrote: > > Move the part of iommu_table_free() that does struct iommu_table cleaning > > into iommu_table_clean, so we can invoke it separately. > > > > This new f

Re: [PATCH v4 6/7] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-21 Thread Leonardo Bras
On Thu, 2020-07-16 at 04:16 -0300, Leonardo Bras wrote: > +static void iommu_pseries_table_update(struct pci_dev *dev, > + struct device_node *pdn) > +{ > + const struct dynamic_dma_window_prop *ddw; > + struct pci_dn *pci; &g

[PATCH v4 7/7] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2020-07-16 Thread Leonardo Bras
flect that it can be used for both kinds of mapping. Also, defines DEFAULT_DMA_WIN as "ibm,dma-window" to document that it's the name of the default DMA window. Those changes are not supposed to change how the code works in any way, just adjust naming. Signed-off-by: Leonardo Bra

[PATCH v4 6/7] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-16 Thread Leonardo Bras
-ddr-window-info" looks the right thing to do. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/iommu.h | 3 ++ arch/powerpc/kernel/iommu.c| 15 + arch/powerpc/platforms/pseries/iommu.c | 46 +++--- 3 files changed, 52 insertions(+), 12 d

[PATCH v4 5/7] powerpc/iommu: Move iommu_table cleaning routine to iommu_table_clean

2020-07-16 Thread Leonardo Bras
-off-by: Leonardo Bras --- arch/powerpc/kernel/iommu.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 9704f3f76e63..c3242253a4e7 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch

[PATCH v4 4/7] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-16 Thread Leonardo Bras
it's boot time value, available in "ibm,dma-window" device tree node. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 73 +++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.

[PATCH v4 3/7] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window

2020-07-16 Thread Leonardo Bras
indow". Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 45 +++--- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1a933c4e8bba..4e33147825

[PATCH v4 2/7] powerpc/pseries/iommu: Update call to ibm, query-pe-dma-windows

2020-07-16 Thread Leonardo Bras
suggested by LoPAR: First reading the size of the extension array from index 0, checking if the property exists, and then returning it's value. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 91 +++--- 1 file changed, 81 insertions(+), 10

[PATCH v4 1/7] powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

2020-07-16 Thread Leonardo Bras
Create defines to help handling ibm,ddw-applicable values, avoiding confusion about the index of given operations. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 43 -- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/arch

[PATCH v4 0/7] Remove default DMA window before creating DDW

2020-07-16 Thread Leonardo Bras
Fix 'unitialized use' (found by travis mpe:ci-test) - New patches #5 and #6 - v1 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=184420&state=%2A&archive=both Special thanks for Alexey Kardashevskiy, Brian King and Oliver O'Halloran for the feedb

Re: [PATCH v3 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-13 Thread Leonardo Bras
In fact, the changes over the last patch are more complex than the current patch. Just for reference, that's how enable_ddw() currently patches: @@ -1087,7 +1119,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn) struct device_node *dn; u32 ddw_avail[DDW_APPL

Re: [PATCH v3 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-13 Thread Leonardo Bras
On Tue, 2020-07-14 at 14:52 +1000, Alexey Kardashevskiy wrote: > > On 14/07/2020 12:40, Leonardo Bras wrote: > > Thank you for this feedback Alexey! > > > > On Mon, 2020-07-13 at 17:33 +1000, Alexey Kardashevskiy wrote: > > > [...] > > > > -

Re: [PATCH v3 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-13 Thread Leonardo Bras
Thank you for this feedback Alexey! On Mon, 2020-07-13 at 17:33 +1000, Alexey Kardashevskiy wrote: > [...] > > - int len, ret; > > + int len, ret, reset_win_ext; > > Make it "reset_token". Oh, it's not a token here, it just checks if the reset_win extension exists. The token would be returne

[PATCH 1/1] KVM/PPC: Fix typo on H_DISABLE_AND_GET hcall

2020-07-06 Thread Leonardo Bras
ned-off-by: Leonardo Bras --- arch/powerpc/include/asm/hvcall.h| 2 +- arch/powerpc/kvm/trace_hv.h | 2 +- tools/perf/arch/powerpc/util/book3s_hcalls.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/i

Re: [PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-02 Thread Leonardo Bras
On Thu, 2020-07-02 at 10:31 +1000, Alexey Kardashevskiy wrote: > > On 02/07/2020 09:48, Leonardo Bras wrote: > > On Wed, 2020-07-01 at 16:57 -0300, Leonardo Bras wrote: > > > > It is not necessarily "direct" anymore as the name suggests, you may > > > &g

[PATCH v3 6/6] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2020-07-02 Thread Leonardo Bras
flect that it can be used for both kinds of mapping. Also, defines DEFAULT_DMA_WIN as "ibm,dma-window" to document that it's the name of the default DMA window. Those changes are not supposed to change how the code works in any way, just adjust naming. Signed-off-by: Leonardo Bra

[PATCH v3 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-02 Thread Leonardo Bras
linux,direct64-ddr-window-info" to define DMA64_PROPNAME "linux,dma64-ddr-window-info" looks the right thing to do. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 38 -- 1 file changed, 24 insertions(+), 14 deletions(-) diff --gi

[PATCH v3 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-02 Thread Leonardo Bras
it's boot time value, available in "ibm,dma-window" device tree node. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 83 +- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.

[PATCH v3 3/6] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window

2020-07-02 Thread Leonardo Bras
indow". Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 45 +++--- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1a933c4e8bba..4e33147825

[PATCH v3 2/6] powerpc/pseries/iommu: Update call to ibm, query-pe-dma-windows

2020-07-02 Thread Leonardo Bras
suggested by LoPAR: First reading the size of the extension array from index 0, checking if the property exists, and then returning it's value. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 91 +++--- 1 file changed, 81 insertions(+), 10

[PATCH v3 1/6] powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

2020-07-02 Thread Leonardo Bras
Create defines to help handling ibm,ddw-applicable values, avoiding confusion about the index of given operations. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 43 -- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/arch

[PATCH v3 0/6] Remove default DMA window before creating DDW

2020-07-02 Thread Leonardo Bras
removing it. - Fix 'unitialized use' (found by travis mpe:ci-test) - New patches #5 and #6 - v1 link: http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=184420&state=%2A&archive=both Special thanks for Alexey Kardashevskiy and Oliver O'Halloran for the feedback pro

Re: [PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-01 Thread Leonardo Bras
On Thu, 2020-07-02 at 10:31 +1000, Alexey Kardashevskiy wrote: > > In fact, there is a lot of places in this file where it's called direct > > window. Should I replace everything? > > Should it be in a separated patch? > > If it looks simple and you write a nice commit log explaining all that > an

Re: [PATCH v2 1/6] powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable

2020-07-01 Thread Leonardo Bras
On Thu, 2020-07-02 at 10:43 +1000, Alexey Kardashevskiy wrote: > > Or should one stick to #define in this case? > > imho a matter of taste but after some grepping it feels like #define is > mostly used which does not mean it is a good idea. Keep it enum and see > if it passed mpe's filter :) Good

Re: [PATCH v2 1/6] powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable

2020-07-01 Thread Leonardo Bras
On Thu, 2020-07-02 at 10:21 +1000, Alexey Kardashevskiy wrote: > > enum { > >DDW_QUERY_PE_DMA_WIN, > >DDW_CREATE_PE_DMA_WIN, > >DDW_REMOVE_PE_DMA_WIN, > > > >DDW_APPLICABLE_SIZE > > } > > IMO, it looks better than all the defines before. > > > > What do you think?

Re: [PATCH v2 2/6] powerpc/pseries/iommu: Update call to ibm,query-pe-dma-windows

2020-07-01 Thread Leonardo Bras
On Thu, 2020-07-02 at 10:18 +1000, Alexey Kardashevskiy wrote: > > On 02/07/2020 00:04, Leonardo Bras wrote: > > On Wed, 2020-07-01 at 18:17 +1000, Alexey Kardashevskiy wrote: > > > > +#define DDW_EXT_SIZE 0 > > > > +#define DDW_E

Re: [PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 16:57 -0300, Leonardo Bras wrote: > > It is not necessarily "direct" anymore as the name suggests, you may > > want to change that. DMA64_PROPNAME, may be. Thanks, > > > > Yeah, you are right. > I will change this for next version, also

Re: [PATCH v2 6/6] powerpc/pseries/iommu: Avoid errors when DDW starts at 0x00

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 18:04 +1000, Alexey Kardashevskiy wrote: > > On 27/06/2020 03:46, Leonardo Bras wrote: > > On Wed, 2020-06-24 at 03:24 -0300, Leonardo Bras wrote: > > > As of today, enable_ddw() will return a non-null DMA address if the > > > created DDW ma

Re: [PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 18:16 +1000, Alexey Kardashevskiy wrote: > > On 24/06/2020 16:24, Leonardo Bras wrote: > > As of today, if a DDW is created and can't map the whole partition, it's > > removed and the default DMA window "ibm,dma-window" is used instea

Re: [PATCH v2 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 18:17 +1000, Alexey Kardashevskiy wrote: > > On 24/06/2020 16:24, Leonardo Bras wrote: > > On LoPAR "DMA Window Manipulation Calls", it's recommended to remove the > > default DMA window for the device, before attempting to configure a DDW,

Re: [PATCH v2 2/6] powerpc/pseries/iommu: Update call to ibm,query-pe-dma-windows

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 18:17 +1000, Alexey Kardashevskiy wrote: > > > +#define DDW_EXT_SIZE 0 > > +#define DDW_EXT_RESET_DMA_WIN 1 > > +#define DDW_EXT_QUERY_OUT_SIZE 2 > > #define DDW_EXT_LAST (DDW_EXT_QUERY_OUT_SIZE + 1) > ... > > > > + > > static struct iommu_table_gro

Re: [PATCH v2 1/6] powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable

2020-07-01 Thread Leonardo Bras
On Wed, 2020-07-01 at 18:16 +1000, Alexey Kardashevskiy wrote: > > On 24/06/2020 16:24, Leonardo Bras wrote: > > Create defines to help handling ibm,ddw-applicable values, avoiding > > confusion about the index of given operations. > > > > Signed-off-by: Leonardo B

Re: [PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-06-26 Thread Leonardo Bras
On Fri, 2020-06-26 at 12:23 -0300, Leonardo Bras wrote: > On Wed, 2020-06-24 at 03:24 -0300, Leonardo Bras wrote: > > As of today, if a DDW is created and can't map the whole partition, it's > > removed and the default DMA window "ibm,dma-window" is used in

Re: [PATCH v2 6/6] powerpc/pseries/iommu: Avoid errors when DDW starts at 0x00

2020-06-26 Thread Leonardo Bras
On Wed, 2020-06-24 at 03:24 -0300, Leonardo Bras wrote: > As of today, enable_ddw() will return a non-null DMA address if the > created DDW maps the whole partition. If the address is valid, > iommu_bypass_supported_pSeriesLP() will consider iommu bypass enabled. > > This can cau

[PATCH v2 6/6] powerpc/pseries/iommu: Avoid errors when DDW starts at 0x00

2020-06-23 Thread Leonardo Bras
address is non-null, check directly if the DDW maps the whole partition, so it can bypass iommu. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b

[PATCH v2 5/6] powerpc/pseries/iommu: Make use of DDW even if it does not map the partition

2020-06-23 Thread Leonardo Bras
As of today, if a DDW is created and can't map the whole partition, it's removed and the default DMA window "ibm,dma-window" is used instead. Usually this DDW is bigger than the default DMA window, so it would be better to make use of it instead. Signed-off-by: Leonardo Bra

[PATCH v2 4/6] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-06-23 Thread Leonardo Bras
it's boot time value, available in "ibm,dma-window" device tree node. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 70 ++ 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arc

[PATCH v2 3/6] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window

2020-06-23 Thread Leonardo Bras
indow". Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 45 +++--- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 558e5441c355..a8840d9e1c

[PATCH v2 2/6] powerpc/pseries/iommu: Update call to ibm, query-pe-dma-windows

2020-06-23 Thread Leonardo Bras
shifting page_size and migration_capable. This ends up requiring the update of ddw_query_response->largest_available_block from u32 to u64, and manually assigning the values from the buffer into this struct, according to output size. Signed-off-by: Leonardo Bras --- arch/powerpc/plat

[PATCH v2 1/6] powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

2020-06-23 Thread Leonardo Bras
Create defines to help handling ibm,ddw-applicable values, avoiding confusion about the index of given operations. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 40 +++--- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/arch

[PATCH v2 0/6] Remove default DMA window before creating DDW

2020-06-23 Thread Leonardo Bras
default DMA window can be restored before removing it. - Fix 'unitialized use' (found by travis mpe:ci-test) - New patches #5 and #6 Special thanks for Alexey Kardashevskiy and Oliver O'Halloran for the feedback provided! Leonardo Bras (6): powerpc/pseries/iommu: Create defines

Re: [PATCH 4/4] powerpc/pseries/iommu: Remove default DMA window before creating DDW

2020-06-22 Thread Leonardo Bras
On Tue, 2020-06-23 at 12:35 +1000, Alexey Kardashevskiy wrote: > > I am not sure if this is true in general, but in this device (SR-IOV > > VF) I am testing it will return 0 windows if the default DMA window is > > not deleted, and 1 after it's deleted. > > Since pHyp can only create windows in "6

<    1   2   3   4   5   >