Found some issues on SRIOV enabled PHYP.
It probably should be one patch, or not?
Please comment. Thanks.
Alexey Kardashevskiy (4):
powerpc/pseries/iommu: Fix indentations
powerpc/pseries/iommu: Use correct vfree for it_map
powerpc/pseries/iommu: Check if the default window in use before
removing it
powerpc/pseries/iommu: Create huge DMA window if no MMIO32 is present
arch/powerpc/platforms/pseries/iommu.c | 33 +++++++++++++-------------
1 file changed, 17 insertions(+), 16 deletions(-)
--
2.30.2
This fixes broken indentations. The first hunk might suggest that
the introducing patch was applied incorrectly but it is correct.
Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
Signed-off-by: Alexey Kardashevskiy <redacted>
---
arch/powerpc/platforms/pseries/iommu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -1404,8 +1404,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);gotoout_del_list;}}else{
The it_map array is vzalloc'ed so use vfree() for it when creating
a huge DMA window failed for whatever reason.
While at this, write zero to it_map.
Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
Signed-off-by: Alexey Kardashevskiy <redacted>
---
arch/powerpc/platforms/pseries/iommu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
At the moment this check is performed after we remove the default window
which is late and disallows to revert whatever changes enable_ddw()
has made to DMA windows.
This moves the check and error exit before removing the window.
This raised the message severity from "debug" to "warning" as this
should not happen in practice and cannot be triggered by the userspace.
Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
Signed-off-by: Alexey Kardashevskiy <redacted>
---
arch/powerpc/platforms/pseries/iommu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -1302,6 +1302,12 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)structproperty*default_win;intreset_win_ext;+/* DDW + IOMMU on single window may fail if there is any allocation */+if(iommu_table_in_use(tbl)){+dev_warn(&dev->dev,"current IOMMU table in use, can't be replaced.\n");+gotoout_failed;+}+default_win=of_find_property(pdn,"ibm,dma-window",NULL);if(!default_win)gotoout_failed;
@@ -1356,12 +1362,6 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)query.largest_available_block,1ULL<<page_shift);-/* DDW + IOMMU on single window may fail if there is any allocation */-if(default_win_removed&&iommu_table_in_use(tbl)){-dev_dbg(&dev->dev,"current IOMMU table in use, can't be replaced.\n");-gotoout_failed;-}-len=order_base_2(query.largest_available_block<<page_shift);win_name=DMA64_PROPNAME;}else{
The iommu_init_table() helper takes an address range to reserve in
the IOMMU table being initialized to exclude MMIO addresses, this is
useful if the window stretches far beyond 4GB (although wastes some TCEs).
At the moment the code searches for such MMIO32 range and fails if none
found which is considered a problem while it really is not: it is actually
better as this says there is no MMIO32 to reserve and we can use
usually wasted TCEs. Furthermore PHYP never actually allows creating
windows starting at busaddress=0 so this MMIO32 range is never useful.
This removes error exit and initializes the table with zero range if
no MMIO32 is detected.
Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
Signed-off-by: Alexey Kardashevskiy <redacted>
---
arch/powerpc/platforms/pseries/iommu.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -1411,18 +1411,19 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)}else{structiommu_table*newtbl;inti;+unsignedlongstart=0,end=0;for(i=0;i<ARRAY_SIZE(pci->phb->mem_resources);i++){constunsignedlongmask=IORESOURCE_MEM_64|IORESOURCE_MEM;/* Look for MMIO32 */-if((pci->phb->mem_resources[i].flags&mask)==IORESOURCE_MEM)+if((pci->phb->mem_resources[i].flags&mask)==IORESOURCE_MEM){+start=pci->phb->mem_resources[i].start;+end=pci->phb->mem_resources[i].end;break;+}}-if(i==ARRAY_SIZE(pci->phb->mem_resources))-gotoout_del_list;-/* New table for using DDW instead of the default DMA window */newtbl=iommu_pseries_alloc_table(pci->phb->node);if(!newtbl){
From: Michael Ellerman <hidden> Date: 2021-11-17 13:03:37
Frederic Barrat [off-list ref] writes:
On 02/11/2021 03:43, Michael Ellerman wrote:
quoted
On Thu, 21 Oct 2021 00:23:11 +1100, Alexey Kardashevskiy wrote:
quoted
Found some issues on SRIOV enabled PHYP.
It probably should be one patch, or not?
Please comment. Thanks.
[...]
Patches 2-4 applied to powerpc/fixes.
Any reason why patch 1 was not applied? The indents are still wrong in
5.16-rc1
Just because it was late in the rc series, and it wasn't crucial that
the whitespace fix go into 5.15.
And yeah Alexey has now reposted it and I have picked that series up.
cheers