Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 25/25] powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device
       [not found] <20231013142945.1956-1-gbatra@linux.vnet.ibm.com>
@ 2023-10-13 14:29 ` Gaurav Batra
  2023-10-14  8:30   ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Batra @ 2023-10-13 14:29 UTC (permalink / raw)
  To: gbatra; +Cc: Gaurav Batra, stable

Bugzilla Number: 202953

Upstream CommitID:

Dependency-commit: d61cd13e732c0eaa7d66b45edb2d0de8eab65a1e

Description:

When a device is initialized, the driver invokes dma_supported() twice -
first for streaming mappings followed by coherent mappings. For an
SR-IOV device, default window is deleted and DDW created. With vPMEM
enabled, TCE mappings are dynamically created for both vPMEM and SR-IOV
device.  There are no direct mappings.

First time when dma_supported() is called with 64 bit mask, DDW is created
and marked as dynamic window. The second time dma_supported() is called,
enable_ddw() finds existing window for the device and incorrectly returns
it as "direct mapping".

This only happens when size of DDW is big enough to map max LPAR memory.

This results in streaming TCEs to not get dynamically mapped, since code
incorrently assumes these are already pre-mapped. The adapter initially
comes up but goes down due to EEH.

Fixes: 381ceda88c4c ("powerpc/pseries/iommu: Make use of DDW for indirect mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Gaurav Batra <gbatra@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/iommu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index efdcdf2aa42e..ce47ba64cb60 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -911,7 +911,8 @@ static int remove_ddw(struct device_node *np, bool remove_prop, const char *win_
 	return 0;
 }
 
-static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *window_shift)
+static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *window_shift,
+			      bool *direct_mapping)
 {
 	struct dma_win *window;
 	const struct dynamic_dma_window_prop *dma64;
@@ -924,6 +925,7 @@ static bool find_existing_ddw(struct device_node *pdn, u64 *dma_addr, int *windo
 			dma64 = window->prop;
 			*dma_addr = be64_to_cpu(dma64->dma_base);
 			*window_shift = be32_to_cpu(dma64->window_shift);
+			*direct_mapping = window->direct;
 			found = true;
 			break;
 		}
@@ -1278,10 +1280,8 @@ static bool enable_ddw(struct pci_dev *dev, struct device_node *pdn)
 
 	mutex_lock(&dma_win_init_mutex);
 
-	if (find_existing_ddw(pdn, &dev->dev.archdata.dma_offset, &len)) {
-		direct_mapping = (len >= max_ram_len);
+	if (find_existing_ddw(pdn, &dev->dev.archdata.dma_offset, &len, &direct_mapping))
 		goto out_unlock;
-	}
 
 	/*
 	 * If we already went through this for a previous function of
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 25/25] powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device
  2023-10-13 14:29 ` [PATCH 25/25] powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device Gaurav Batra
@ 2023-10-14  8:30   ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-10-14  8:30 UTC (permalink / raw)
  To: Gaurav Batra; +Cc: gbatra, stable

On Fri, Oct 13, 2023 at 09:29:45AM -0500, Gaurav Batra wrote:
> Bugzilla Number: 202953
> 
> Upstream CommitID:
> 
> Dependency-commit: d61cd13e732c0eaa7d66b45edb2d0de8eab65a1e

What are these values for?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-14  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20231013142945.1956-1-gbatra@linux.vnet.ibm.com>
2023-10-13 14:29 ` [PATCH 25/25] powerpc/pseries/iommu: enable_ddw incorrectly returns direct mapping for SR-IOV device Gaurav Batra
2023-10-14  8:30   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox