powerpc/pseries/ddw: Fixes for persistent memory case
cover powerpc/pseries/ddw: Fixes for persistent memory case
This is based on sha1f855455dee0b Michael Ellerman "Automatic merge of 'next' into merge (2021-11-05 22:19)".
Please comment. Thanks.
Alexey Kardashevskiy (3):
powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window
for persistent memory"
powerpc/pseries/ddw: simplify enable_ddw() powerpc/pseries/ddw: Do not try direct mapping with persistent memory
and one window
arch/powerpc/platforms/pseries/iommu.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/3 powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory"
This reverts commit 54fc3c681ded9437e4548e2501dc1136b23cfa9a which does not allow 1:1 mapping even for the system RAM which is usually possible.
--- arch/powerpc/platforms/pseries/iommu.c | 9 --------- 1 file changed, 9 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +0 -9
@@ -1094,15 +1094,6 @@ static phys_addr_t ddw_memory_hotplug_max(void)phys_addr_t max_addr =memory_hotplug_max ();struct device_node *memory; -/* -* The "ibm,pmemory" can appear anywhere in the address space. -* Assuming it is still backed by page structs, set the upper limit -* for the huge DMA window as MAX_PHYSMEM_BITS. -*/ -if (of_find_node_by_type (NULL ,"ibm,pmemory" )) -return (sizeof (phys_addr_t) *8 <=MAX_PHYSMEM_BITS ) ? - (phys_addr_t) -1 : (1ULL <<MAX_PHYSMEM_BITS ); -for_each_node_by_type (memory,"memory" ) {unsigned long start, size;int n_mem_addr_cells, n_mem_size_cells, len;
Signature · 1 line
2.30.2
PATCH 2/3 powerpc/pseries/ddw: simplify enable_ddw()
In reply to Alexey KardashevskiyThis drops rather useless ddw_enabled flag as direct_mapping implies it anyway.
While at this, fix indents in enable_ddw().
This should not cause any behavioral change.
---
This replaces "powerpc/pseries/iommu: Fix indentations"
--- arch/powerpc/platforms/pseries/iommu.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -7
@@ -1229,7 +1229,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)u32 ddw_avail[DDW_APPLICABLE_SIZE ];struct dma_win *window;struct property *win64; -bool ddw_enabled = false;struct failed_ddw_pdn *fpdn;bool default_win_removed = false, direct_mapping = false;bool pmem_present;
@@ -1244,7 +1243,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)if (find_existing_ddw (pdn, &dev->dev.archdata.dma_offset, &len)) { direct_mapping = (len >= max_ram_len); - ddw_enabled = true; goto out_unlock; }
@@ -1397,8 +1395,8 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)dev_info (&dev->dev,"failed to map DMA window for %pOF: %d\n" , dn, ret); -/* Make sure to clean DDW if any TCE was set*/ -clean_dma_window (pdn, win64->value); +/* Make sure to clean DDW if any TCE was set*/ +clean_dma_window (pdn, win64->value); goto out_del_list; } }else {
@@ -1445,7 +1443,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)spin_unlock (&dma_win_list_lock); dev->dev.archdata.dma_offset = win_addr; - ddw_enabled = true; goto out_unlock; out_del_list:
@@ -1481,10 +1478,10 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)* as RAM, then we failed to create a window to cover persistent * memory and need to set the DMA limit. */ -if (pmem_present && ddw_enabled && direct_mapping && len == max_ram_len) +if (pmem_present && direct_mapping && len == max_ram_len) dev->dev.bus_dma_limit = dev->dev.archdata.dma_offset + (1ULL << len); -return ddw_enabled && direct_mapping; +return direct_mapping; }static void pci_dma_dev_setup_pSeriesLP (struct pci_dev *dev)
Signature · 1 line
2.30.2
PATCH 3/3 powerpc/pseries/ddw: Do not try direct mapping with persistent memory and one window
In reply to Alexey KardashevskiyThere is a possibility of having just one DMA window available with a limited capacity which the existing code does not handle that well. If the window is big enough for the system RAM but less than MAX_PHYSMEM_BITS (which we want when persistent memory is present), we create 1:1 window and leave persistent memory without DMA.
This disables 1:1 mapping entirely if there is persistent memory and either:
- the huge DMA window does not cover the entire address space;
- the default DMA window is removed.
This relies on reverted 54fc3c681ded
("powerpc/pseries/ddw: Extend upper limit for huge DMA window for persistent memory") to return the actual amount RAM in ddw_memory_hotplug_max() (posted separately).
--- arch/powerpc/platforms/pseries/iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -2
@@ -1356,8 +1356,10 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn) len =order_base_2 (query.largest_available_block << page_shift); win_name =DMA64_PROPNAME ; }else { - direct_mapping = true; - win_name =DIRECT64_PROPNAME ; + direct_mapping = !default_win_removed || + (len ==MAX_PHYSMEM_BITS ) || + (!pmem_present && (len == max_ram_len)); + win_name = direct_mapping ?DIRECT64_PROPNAME :DMA64_PROPNAME ; } ret =create_ddw (dev, ddw_avail, &create, page_shift, len);
Signature · 1 line
2.30.2
Michael Ellerman
AppliedQuoted 8 lines · Alexey Kardashevskiy
This is based on sha1
f855455dee0bMichael Ellerman "Automatic merge of 'next' into merge (2021-11-05 22:19)".Please comment. Thanks.
[...]
Applied to powerpc/fixes.
[1/3] powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory"
https://git.kernel.org/powerpc/c/2d33f5504490a9d90924476dbccd4a5349ee1ad0 [2/3] powerpc/pseries/ddw: simplify enable_ddw() https://git.kernel.org/powerpc/c/fb4ee2b30cd09e95524640149e4ee0d7f22c3e7b [3/3] powerpc/pseries/ddw: Do not try direct mapping with persistent memory and one window https://git.kernel.org/powerpc/c/ad3976025b311cdeb822ad3e7a7554018cb0f83f
cheers