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

2020-06-22 Thread Leonardo Bras
Hello Alexey, thank you for the feedback! On Mon, 2020-06-22 at 20:02 +1000, Alexey Kardashevskiy wrote: > > On 19/06/2020 15:06, Leonardo Bras wrote: > > From LoPAR level 2.8, "ibm,ddw-extensions" index 3 can make the number of > > outputs from "ibm,que

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

2020-06-22 Thread Leonardo Bras
" returned %d\n", ddw_avail[0], cfg_addr, BUID_HI(buid), > > > > - BUID_LO(buid), ret); > > > > return ret; > > > > } > > > > > > > > @@ -1040,7 +1075,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct > > > > device_node *pdn) > > > > * of page sizes: supported and supported for migrate-dma. > > > > */ > > > > dn = pci_device_to_OF_node(dev); > > > > - ret = query_ddw(dev, ddw_avail, ); > > > > + ret = query_ddw(dev, ddw_avail, , pdn); > > > > if (ret != 0) > > > > goto out_failed; > > > > > > > > @@ -1068,7 +1103,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct > > > > device_node *pdn) > > > > /* check largest block * page size > max memory hotplug addr */ > > > > max_addr = ddw_memory_hotplug_max(); > > > > if (query.largest_available_block < (max_addr >> page_shift)) { > > > > - dev_dbg(>dev, "can't map partition max 0x%llx with > > > > %u " > > > > + dev_dbg(>dev, "can't map partition max 0x%llx with > > > > %llu " > > > > "%llu-sized pages\n", max_addr, > > > > query.largest_available_block, > > > > 1ULL << page_shift); > > > > goto out_failed; > > > > > > > > Best regards, > > Leonardo > > Best regards, Leonardo Bras

Re: [PATCH 2/4] powerpc/pseries/iommu: Implement ibm,reset-pe-dma-windows rtas call

2020-06-22 Thread Leonardo Bras
On Tue, 2020-06-23 at 11:11 +1000, Alexey Kardashevskiy wrote: > > On 23/06/2020 04:58, Leonardo Bras wrote: > > Hello Alexey, thanks for the feedback! > > > > On Mon, 2020-06-22 at 20:02 +1000, Alexey Kardashevskiy wrote: > > > On 19/06/2020 15:06, Leona

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 11:11 +1000, Alexey Kardashevskiy wrote: > > On 23/06/2020 04:59, Leonardo Bras wrote: > > Hello Alexey, thanks for the feedback! > > > > On Mon, 2020-06-22 at 20:02 +1000, Alexey Kardashevskiy wrote: > > > On 19/06/2020 15:06, Leonardo

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

2020-06-22 Thread Leonardo Bras
On Tue, 2020-06-23 at 11:33 +1000, Oliver O'Halloran wrote: > On Tue, Jun 23, 2020 at 11:12 AM Alexey Kardashevskiy wrote: > > On 23/06/2020 04:59, Leonardo Bras wrote: > > > > Also, despite this particular file, the "pdn" name is usually used for > > >

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

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

2020-06-22 Thread Leonardo Bras
On Tue, 2020-06-23 at 11:12 +1000, Alexey Kardashevskiy wrote: > > On 23/06/2020 04:59, Leonardo Bras wrote: > > Hello Alexey, thanks for the feedback! > > > > On Mon, 2020-06-22 at 20:02 +1000, Alexey Kardashevskiy wrote: > > > On 19/06/2020 15:06, Leonardo Br

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

2020-06-24 Thread Leonardo Bras
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/arch/powerpc/platf

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

2020-06-24 Thread Leonardo Bras
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 for operations in ibm,ddw-applicable powerpc

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

2020-06-24 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 Bras --- ar

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

2020-06-24 Thread Leonardo Bras
if the 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 1/6] powerpc/pseries/iommu: Create defines for operations in ibm, ddw-applicable

2020-06-24 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 3/6] powerpc/pseries/iommu: Move window-removing part of remove_ddw into remove_dma_window

2020-06-24 Thread Leonardo Bras
;. 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..a8840d9e1c35 100644

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

2020-06-24 Thread Leonardo Bras
s up 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

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

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 instead.

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

2020-06-18 Thread Leonardo Bras
to remove the default DMA window before query_ddw() and the rtas call from patch #2 to recover it if something goes wrong. All patches were tested into an LPAR with an Ethernet VF: 4005:01:00.0 Ethernet controller: Mellanox Technologies MT27700 Family [ConnectX-4 Virtual Function] Leonardo Bras (4

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

2020-06-18 Thread Leonardo Bras
they only allow one DMA window. If setting up a new DDW fails anywhere after the removal of this default DMA window, restore it using reset_dma_window. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletion

[PATCH 2/4] powerpc/pseries/iommu: Implement ibm, reset-pe-dma-windows rtas call

2020-06-18 Thread Leonardo Bras
by resetting the TCE table allocation for the PE to it's boot time value, available in "ibm,dma-window" device tree node. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 33 ++ 1 file changed, 33 insertions(+) diff --git a/arch/powerpc

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

2020-06-18 Thread Leonardo Bras
;. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 53 +++--- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 5e1fbc176a37..de633f6ae093 100644

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

2020-06-18 Thread Leonardo Bras
s up 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

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-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

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

2020-07-16 Thread Leonardo Bras
://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=184420=%2A=both Special thanks for Alexey Kardashevskiy, Brian King and Oliver O'Halloran for the feedback provided! Leonardo Bras (7): powerpc/pseries/iommu: Create defines for operations in ibm,ddw-applicable powerpc/pseries/iommu: Update call

[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 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
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.c b/arch/power

[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 delet

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

2020-07-16 Thread Leonardo Bras
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 Bras --- ar

[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
t; 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 deletions(-) diff --

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

2020-07-16 Thread Leonardo Bras
;. 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..4e33147825cc 100644

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

2020-07-06 Thread Leonardo Bras
Signed-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

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

2020-12-08 Thread Leonardo Bras
(arg &= 0x3f) : Gets (RB) 58:63, missing bit 57 Fixes this by applying the correct mask. Signed-off-by: Leonardo Bras --- Changes since v1: - Commit message 's/LSB/MSB/', because ISA ordering is big-endian. arch/powerpc/kvm/book3s_hv.c | 6 +++--- 1 file changed, 3 insertions(+

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

2020-11-11 Thread Leonardo Bras
(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/powerpc/kvm/book3s_

[PATCH v2 3/3] powerpc/mm/hash: Avoid multiple HPT resize-downs on memory hotunplug

2021-04-30 Thread Leonardo Bras
to temporarily disable all HPT resize-downs before hotunplug, re-enable them after hotunplug ends, and then resize-down HPT to the current memory size. As an example, hotunplugging 256GB from a 385GB guest took 621s without this patch, and 100s after applied. Signed-off-by: Leonardo Bras --- arch

Re: [PATCH v2 0/3] powerpc/mm/hash: Time improvements for memory hot(un)plug

2021-04-30 Thread Leonardo Bras
CC: David Gibson http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=241574=%2A=both

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

2021-04-30 Thread Leonardo Bras
Thanks Alexey! On Fri, 2021-04-23 at 17:27 +1000, Alexey Kardashevskiy wrote: > > On 22/04/2021 17:07, Leonardo Bras wrote: > > Some functions assume IOMMU page size can only be 4K (pageshift == 12). > > Update them to accept any page size passed, so we can use 64K pages. >

[PATCH v2 1/3] powerpc/mm/hash: Avoid resizing-down HPT on first memory hotplug

2021-04-30 Thread Leonardo Bras
memory hotplug times. As an example, hotplugging 256GB on a 129GB guest took 710s without this patch, and 21s after applied. Signed-off-by: Leonardo Bras --- arch/powerpc/mm/book3s64/hash_utils.c | 36 --- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/arch

[PATCH v2 2/3] powerpc/mm/hash: Avoid multiple HPT resize-ups on memory hotplug

2021-04-30 Thread Leonardo Bras
memory: Adding 256G to a 2GB guest, for example will require 8 HPT resizes. Perform an HPT resize before memory hotplug, updating HPT to its final size (considering a successful hotplug), taking the number of HPT resizes to at most one per memory hotplug action. Signed-off-by: Leonardo Bras --- arch

[PATCH v2 0/3] powerpc/mm/hash: Time improvements for memory hot(un)plug

2021-04-30 Thread Leonardo Bras
LMB Best regards, Leonardo Bras (3): powerpc/mm/hash: Avoid resizing-down HPT on first memory hotplug powerpc/mm/hash: Avoid multiple HPT resize-ups on memory hotplug powerpc/mm/hash: Avoid multiple HPT resize-downs on memory hotunplug arch/powerpc/include/asm/book3s/64/hash.h | 4

Re: [PATCH v3 06/11] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2021-04-30 Thread Leonardo Bras
On Fri, 2021-04-23 at 19:04 +1000, Alexey Kardashevskiy wrote: > > > + win64->name = kstrdup(propname, GFP_KERNEL); > > + ddwprop = kzalloc(sizeof(*ddwprop), GFP_KERNEL); > > + win64->value = ddwprop; > > + win64->length = sizeof(*ddwprop); > > + if (!win64->name || !win64->value) { > >

[PATCH v4 00/11] DDW + Indirect Mapping

2021-04-30 Thread Leonardo Bras
201210=%2A=both Leonardo Bras (11): powerpc/pseries/iommu: Replace hard-coded page shift powerpc/kernel/iommu: Add new iommu_table_in_use() helper powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper powerpc/pseries/iommu: Add ddw_list_new_entry() helper powerpc/pseries/iommu:

[PATCH v4 05/11] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2021-04-30 Thread Leonardo Bras
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 Reviewed-by: Alexey

[PATCH v4 06/11] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2021-04-30 Thread Leonardo Bras
all memory, which looks the most expensive operation, only if everything else succeeds. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 93 -- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/

[PATCH v4 07/11] powerpc/pseries/iommu: Reorganize iommu_table_setparms*() with new helper

2021-04-30 Thread Leonardo Bras
ore used, move iommu_table_lpar_multi_ops and iommu_table_pseries_ops to before their respective iommu_table_setparms*(). Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 100 - 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/a

[PATCH v4 04/11] powerpc/pseries/iommu: Add ddw_list_new_entry() helper

2021-04-30 Thread Leonardo Bras
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 Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 32

[PATCH v4 03/11] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper

2021-04-30 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 Reviewed-by: Alexey

[PATCH v4 01/11] powerpc/pseries/iommu: Replace hard-coded page shift

2021-04-30 Thread Leonardo Bras
ift 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 Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/tce.h | 8 -- arch/powe

[PATCH v4 02/11] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2021-04-30 Thread Leonardo Bras
testing. This causes iommu_table_release_pages() to become unnecessary, given it is only used to remove reserved memory for testing. Also, only allow storing reserved memory values in tbl if they are valid in the table, so there is no need to check it in the new helper. Signed-off-by: Leonardo

[PATCH v4 09/11] powerpc/pseries/iommu: Find existing DDW with given property name

2021-04-30 Thread Leonardo Bras
DIRECT64_PROPNAME. In order to have this, find_existing_ddw_windows() needs to be able to look for different property names. Extract find_existing_ddw_windows() into find_existing_ddw_windows_named() and calls it with current property name. Signed-off-by: Leonardo Bras --- arch/powerpc

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

2021-04-30 Thread Leonardo Bras
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 Bras --- arch/powerpc/platforms/pseries/iommu.c | 21

[PATCH v4 10/11] powerpc/pseries/iommu: Make use of DDW for indirect mapping

2021-04-30 Thread Leonardo Bras
ddr-window-info" was created to represent a DDW that does not allow direct mapping. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 87 +- 1 file changed, 72 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/ar

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

2021-04-30 Thread Leonardo Bras
that it can be used for both kinds of mapping. This should cause no behavioural change, just adjust naming. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 93 +- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/arch/powerpc

Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-08 Thread Leonardo Bras
mp; CONFIG_PPC_BOOK3S_64 > > > > Or something the user need to select himself in menuconfig? > > Yeah I meant a default n thing under powerpc kernel debugging somewhere. So, IIUC all we can do is split this in 2 changes: 1 - Adding notrace to those functions 2 - Introducing a kernel debug config that reverts (1) and 'fixes' mftb If that's correct, I have some ideas we can use. For debug option, should we add the offset on get_tb() or mftb()? Another option would be to adding this tb_offset only in the routines used by tracing. But this could probably mean having to add a function in arch-generic code, but still an option. What do you think? > > Thanks, > Nick Thank you! Leonardo Bras

[PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-04 Thread Leonardo Bras
in kvmppc_guest_entry_inject_int(), which depending on last tracepoint acquired could actually cause the host to crash. Save the Timebase Offset to PACA and use it on sched_clock() to always get the correct timestamp. Signed-off-by: Leonardo Bras Suggested-by: Paul Mackerras --- Changes since v1

[PATCH 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-04 Thread Leonardo Bras
in kvmppc_guest_entry_inject_int(), which depending on last tracepoint acquired could actually cause the host to crash. Save the Timebase Offset to PACA and use it on sched_clock() to always get the correct timestamp. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/kvm_book3s_asm.h | 1

Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-04 Thread Leonardo Bras
upstream > could you put it under a debug config option? You mean something that is automatically selected whenever those configs are enabled? CONFIG_TRACEPOINT && CONFIG_KVM_BOOK3S_HANDLER && CONFIG_PPC_BOOK3S_64 Or something the user need to select himself in menuconfig?

[PATCH 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-03-22 Thread Leonardo Bras
r 32M, 64M, 128M, 256M and 16G. Enabling bigger pages would be interesting for direct mapping systems with a lot of RAM, while using less TCE entries. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/iommu.h | 8 arch/powerpc/platforms/pseries/io

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

2021-03-18 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 Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/kernel/iommu.c | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/kernel/iommu.c b/a

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

2021-03-18 Thread Leonardo Bras
mu_*_coherent() to make sure the size alignment happens only for IOMMU_PAGE_SIZE() before calling iommu_alloc() and iommu_free(). Also, on iommu_range_alloc(), replace ALIGN(n, 1 << tbl->it_page_shift) with IOMMU_PAGE_ALIGN(n, tbl), which is easier to read and does the same. Signed-off-by: L

[PATCH 2/3] powerpc/mm/hash: Avoid multiple HPT resize-ups on memory hotplug

2021-03-11 Thread Leonardo Bras
memory: Adding 256G to a 2GB guest, for example will require 8 HPT resizes. Perform an HPT resize before memory hotplug, updating HPT to its final size (considering a successful hotplug), taking the number of HPT resizes to at most one per memory hotplug action. Signed-off-by: Leonardo Bras --- arch

[PATCH 3/3] powerpc/mm/hash: Avoid multiple HPT resize-downs on memory hotunplug

2021-03-11 Thread Leonardo Bras
to temporarily disable all HPT resize-downs before hotunplug, re-enable them after hotunplug ends, and then resize-down HPT to the current memory size. As an example, hotunplugging 256GB from a 385GB guest took 621s without this patch, and 100s after applied. Signed-off-by: Leonardo Bras --- arch

[PATCH 1/3] powerpc/mm/hash: Avoid resizing-down HPT on first memory hotplug

2021-03-11 Thread Leonardo Bras
memory hotplug times. As an example, hotplugging 256GB on a 129GB guest took 710s without this patch, and 21s after applied. Signed-off-by: Leonardo Bras --- arch/powerpc/mm/book3s64/hash_utils.c | 36 --- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/arch

[PATCH 0/3] powerpc/mm/hash: Time improvements for memory hot(un)plug

2021-03-11 Thread Leonardo Bras
, hotunplug = 100s. Any feedback will be appreciated! I believe the code may not be very well placed in available files, so please give some feedback on that. Best regards, Leonardo Bras (3): powerpc/mm/hash: Avoid resizing-down HPT on first memory hotplug powerpc/mm/hash: Avoid multiple HPT

[PATCH v2 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-07 Thread Leonardo Bras
r 32M, 64M, 128M, 256M and 16G. Enabling bigger pages would be interesting for direct mapping systems with a lot of RAM, while using less TCE entries. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 49 ++ 1 file changed, 42 insertions(+), 7

Re: [PATCH 1/3] powerpc/mm/hash: Avoid resizing-down HPT on first memory hotplug

2021-04-08 Thread Leonardo Bras
e > resize attempts first. This batching is something I had thought a lot about. Problem is that there are a lot of generic interfaces between memory hotplug and actually resizing HPT. I tried a simpler approach in patches 2 & 3, so I don't touch much stuff there. Best regards, Leonardo Bras

[PATCH v3 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-08 Thread Leonardo Bras
r 32M, 64M, 128M, 256M and 16G. Enabling bigger pages would be interesting for direct mapping systems with a lot of RAM, while using less TCE entries. Signed-off-by: Leonardo Bras --- Changes since v2: - Restore 'int array & shift' strategy - Remove defines for RTAS "IO Page Size"

Re: [PATCH 3/3] powerpc/mm/hash: Avoid multiple HPT resize-downs on memory hotunplug

2021-04-08 Thread Leonardo Bras
ath is far from clear. > On hotplug, HPT is resized-up before adding LMBs. On hotunplug, HPT is resized-down after removing LMBs. And each one has it's own mechanism to batch HPT resizes... I can't understand exactly how using it on hotplug fail path can be any different than using it on hotunplug. > Can you please help me understanding this? Best regards, Leonardo Bras

Re: [PATCH v2 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-08 Thread Leonardo Bras
Em sex., 9 de abr. de 2021 01:36, Alexey Kardashevskiy escreveu: > > > On 08/04/2021 19:04, Michael Ellerman wrote: > > Alexey Kardashevskiy writes: > >> On 08/04/2021 15:37, Michael Ellerman wrote: > >>> Leonardo Bras writes: > >>>> According

Re: [PATCH 2/3] powerpc/mm/hash: Avoid multiple HPT resize-ups on memory hotplug

2021-04-08 Thread Leonardo Bras
resize to the right size for the full add, > then resize several times again as we perform the add? Or.. I guess > that will be suppressed by patch 1/3.  Correct. > That's seems kinda fragile, though. What do you mean by fragile here? What would you suggest doing different? Best regards, Leonardo Bras

Re: [PATCH 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-07 Thread Leonardo Bras
) and so on. > > OTOH the PAPR page sizes need macros as they are the ones which are > weird and screaming for macros. > > I'd steal/rework spapr_page_mask_to_query_mask() from QEMU. Thanks, > Thanks for this feedback! I just sent a v2 applying your suggestions. Best regards, Leonardo Bras

Re: [PATCH v2 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-08 Thread Leonardo Bras
Hello Michael, thank you for this feedback! Comments inline: On Thu, 2021-04-08 at 15:37 +1000, Michael Ellerman wrote: > Leonardo Bras writes: > > According to LoPAR, ibm,query-pe-dma-window output named "IO Page Sizes" > > will let the OS know all possible p

Re: [PATCH v2 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-08 Thread Leonardo Bras
On Thu, 2021-04-08 at 03:20 -0300, Leonardo Bras wrote: > > > +#define QUERY_DDW_PGSIZE_4K 0x01 > > > +#define QUERY_DDW_PGSIZE_64K 0x02 > > > +#define QUERY_DDW_PGSIZE_16M 0x04 > > > +#define QUERY_DDW_PGSIZE_32M 0x08 > > > +#define

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

2021-04-13 Thread Leonardo Bras
On Wed, 2020-09-30 at 17:29 +1000, Alexey Kardashevskiy wrote: > > On 30/09/2020 06:54, Leonardo Bras wrote: > > On Tue, 2020-09-29 at 13:55 +1000, Alexey Kardashevskiy wrote: > > > > > > On 12/09/2020 03:07, Leonardo Bras wrote: > > > > Cc

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

2021-04-13 Thread Leonardo Bras
On Tue, 2021-04-13 at 17:18 +1000, Alexey Kardashevskiy wrote: > > On 13/04/2021 15:49, Leonardo Bras wrote: > > Thanks for the feedback! > > > > On Tue, 2020-09-29 at 13:56 +1000, Alexey Kardashevskiy wrote: > > > > -static bool find_existing_ddw(st

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

2021-04-12 Thread Leonardo Bras
he correct parameters? Use the previous tbl it_reserved_start and tbl->it_reserved_end is enough? Best regards, Leonardo Bras >

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

2021-04-12 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, > > > > Update remove_dma_window() so it can be used to remove DDW with a given > >

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

2021-04-13 Thread Leonardo Bras
On Tue, 2021-04-13 at 17:41 +1000, Alexey Kardashevskiy wrote: > > On 13/04/2021 17:33, Leonardo Bras wrote: > > On Tue, 2021-04-13 at 17:18 +1000, Alexey Kardashevskiy wrote: > > > > > > On 13/04/2021 15:49, Leonardo Bras wrote: > > > > Thanks for the

Re: [PATCH v2 1/1] powerpc/iommu: Enable remaining IOMMU Pagesizes present in LoPAR

2021-04-13 Thread Leonardo Bras
e mental load a lot. You can add > a comment at the single spot you use them, explaining what this is, in a > much better way! > > Comments are *good*. > > > Segher Thanks for the feedback Alexey, Michael and Segher! I have sent a v3 for this patch.  http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210408201915.174217-1-leobra...@gmail.com/ Please let me know of your feedback in it. Best regards, Leonardo Bras

Re: [PATCH 1/1] of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses

2021-04-19 Thread Leonardo Bras
On Mon, 2021-04-19 at 10:44 -0500, Rob Herring wrote: > On Fri, Apr 16, 2021 at 3:58 PM Leonardo Bras wrote: > > > > Hello Rob, thanks for this feedback! > > > > On Thu, 2021-04-15 at 13:59 -0500, Rob Herring wrote: > > > +PPC and PCI lists > > > &

Re: [PATCH 1/1] of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses

2021-04-19 Thread Leonardo Bras
On Mon, 2021-04-19 at 20:39 -0500, Rob Herring wrote: > On Mon, Apr 19, 2021 at 7:35 PM Leonardo Bras wrote: > > > > On Mon, 2021-04-19 at 10:44 -0500, Rob Herring wrote: > > > On Fri, Apr 16, 2021 at 3:58 PM Leonardo Bras wrote: > > > > > &g

[PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem

2021-04-19 Thread Leonardo Bras
reated, being insufficient for correct usage. Fix this so the correct window size is used in this case. Fixes: bf6e2d562bbc4("powerpc/dma: Fallback to dma_ops when persistent memory present") Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 2 +- 1 file chan

Re: [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem

2021-04-19 Thread Leonardo Bras
On Tue, 2021-04-20 at 15:18 +1000, Alexey Kardashevskiy wrote: > > On 20/04/2021 14:54, Leonardo Bras wrote: > > As of today, if the DDW is big enough to fit (1 << MAX_PHYSMEM_BITS) it's > > possible to use direct DMA mapping even with pmem region. > > > > B

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

2021-04-13 Thread Leonardo Bras
On Tue, 2021-04-13 at 18:24 +1000, Alexey Kardashevskiy wrote: > > On 13/04/2021 17:58, Leonardo Bras wrote: > > On Tue, 2021-04-13 at 17:41 +1000, Alexey Kardashevskiy wrote: > > > > > > On 13/04/2021 17:33, Leonardo Bras wrote: > > > > On Tue, 2021-

Re: [PATCH 1/1] of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses

2021-04-21 Thread Leonardo Bras
On Tue, 2021-04-20 at 17:34 -0500, Rob Herring wrote: > > [...] > > I think the point here is bus resources not getting the MEM_64 flag, > > but device resources getting it correctly. Is that supposed to happen? > > I experimented with this on Arm with qemu and it seems fine there too. > Looks

Re: [PATCH 1/1] of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses

2021-04-16 Thread Leonardo Bras
Hello Rob, thanks for this feedback! On Thu, 2021-04-15 at 13:59 -0500, Rob Herring wrote: > +PPC and PCI lists > > On Thu, Apr 15, 2021 at 1:01 PM Leonardo Bras wrote: > > > > Many other resource flag parsers already add this flag when the input > > has bits 24 &

Re: [PATCH 1/1] of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses

2021-04-16 Thread Leonardo Bras
Hello Rob, thanks for this feedback! On Thu, 2021-04-15 at 13:59 -0500, Rob Herring wrote: > +PPC and PCI lists > > On Thu, Apr 15, 2021 at 1:01 PM Leonardo Bras wrote: > > > > Many other resource flag parsers already add this flag when the input > > has bits 24 &

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

2021-04-11 Thread Leonardo Bras
ay be? The less unrelated > changes the better. I changed all labels I added to have out__, I think that will allow it to stay like existing labels. Thanks for reviewing! Leonardo Bras

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

2021-04-11 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, > > > > Add a new helper _iommu_table_setparms(), and use it in

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

2021-04-11 Thread Leonardo Bras
Hello Alexey, thanks for the feedback! On Tue, 2020-09-29 at 13:57 +1000, Alexey Kardashevskiy wrote: > > On 12/09/2020 03:07, Leonardo Bras wrote: > > diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c > > index ffb2637dc82b..c838da3d8f32 100644 > > -

Re: [PATCH kernel 1/2] powerpc/iommu: Allocate it_map by vmalloc

2021-02-17 Thread Leonardo Bras
when MMU is on. > > Signed-off-by: Alexey Kardashevskiy It looks a very good change, and also makes code much simpler to read. FWIW: Reviewed-by: Leonardo Bras > --- >  arch/powerpc/kernel/iommu.c | 15 +++ >  1 file changed, 3 insertions(+), 12 deletions(-) > > diff --

Re: [PATCH kernel 2/2] powerpc/iommu: Do not immediately panic when failed IOMMU table allocation

2021-02-17 Thread Leonardo Bras
iommu_init_table() did not panic(), and pnv_pci_ioda2_set_window() returned something other than 0, it would return rc in the if (rc) clause, but now it does not happen anymore, going through if (!pnv_iommu_bypass_disabled) onwards. Is that desired? As far as I could see, returning rc there seems a good procedure after iommu_init_table returning -ENOMEM. Best regards,  Leonardo Bras

Re: [PATCH v2 1/1] powerpc/kvm: Save Timebase Offset to fix sched_clock() while running guest code.

2021-02-05 Thread Leonardo Bras
Hello Fabiano, Thanks for reviewing!  (answers inline) On Fri, 2021-02-05 at 10:09 -0300, Fabiano Rosas wrote: > Leonardo Bras writes: > > > Before guest entry, TBU40 register is changed to reflect guest timebase. > > After exitting guest, the register is reverted to i

Re: [PATCH kernel 2/2] powerpc/iommu: Do not immediately panic when failed IOMMU table allocation

2021-02-22 Thread Leonardo Bras
On Mon, 2021-02-22 at 16:24 +1100, Alexey Kardashevskiy wrote: > > On 18/02/2021 06:32, Leonardo Bras wrote: > > On Tue, 2021-02-16 at 14:33 +1100, Alexey Kardashevskiy wrote: > > > Most platforms allocate IOMMU table structures (specifically it_map) > > > at the

[PATCH v3 05/11] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2021-04-22 Thread Leonardo Bras
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 Reviewed-by: Alexey

[PATCH v3 06/11] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2021-04-22 Thread Leonardo Bras
all memory, which looks the most expensive operation, only if everything else succeeds. Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 93 -- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/

[PATCH v3 07/11] powerpc/pseries/iommu: Reorganize iommu_table_setparms*() with new helper

2021-04-22 Thread Leonardo Bras
ore used, move iommu_table_lpar_multi_ops and iommu_table_pseries_ops to before their respective iommu_table_setparms*(). Signed-off-by: Leonardo Bras --- arch/powerpc/platforms/pseries/iommu.c | 100 - 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/a

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

2021-04-22 Thread Leonardo Bras
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 Bras --- arch/powerpc/platforms/pseries/iommu.c | 21

[PATCH v3 04/11] powerpc/pseries/iommu: Add ddw_list_new_entry() helper

2021-04-22 Thread Leonardo Bras
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 Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 32

Re: [PATCH v3 00/11] DDW + Indirect Mapping

2021-04-22 Thread Leonardo Bras
renaming, - Removed some unnecessary empty lines, - Changed some code moving to forward declarations. v2 Link:  http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=201210=%2A=both On Thu, 2021-04-22 at 04:07 -0300, Leonardo Bras wrote: > So far it's assumed possible to map the guest RA

<    1   2   3   4   5   >