* [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem
@ 2021-04-20 4:54 Leonardo Bras
2021-04-20 5:18 ` Alexey Kardashevskiy
2021-04-21 13:08 ` Michael Ellerman
0 siblings, 2 replies; 4+ messages in thread
From: Leonardo Bras @ 2021-04-20 4:54 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Leonardo Bras, Alexey Kardashevskiy
Cc: linuxppc-dev, linux-kernel
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.
But, if that happens, the window size (len) is set to
(MAX_PHYSMEM_BITS - page_shift) instead of MAX_PHYSMEM_BITS, causing a
pagesize times smaller DDW to be created, 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 <leobras.c@gmail.com>
---
arch/powerpc/platforms/pseries/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 9fc5217f0c8e..836cbbe0ecc5 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1229,7 +1229,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
if (pmem_present) {
if (query.largest_available_block >=
(1ULL << (MAX_PHYSMEM_BITS - page_shift)))
- len = MAX_PHYSMEM_BITS - page_shift;
+ len = MAX_PHYSMEM_BITS;
else
dev_info(&dev->dev, "Skipping ibm,pmemory");
}
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem
2021-04-20 4:54 [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem Leonardo Bras
@ 2021-04-20 5:18 ` Alexey Kardashevskiy
2021-04-20 5:29 ` Leonardo Bras
2021-04-21 13:08 ` Michael Ellerman
1 sibling, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2021-04-20 5:18 UTC (permalink / raw)
To: Leonardo Bras, Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
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.
>
> But, if that happens, the window size (len) is set to
> (MAX_PHYSMEM_BITS - page_shift) instead of MAX_PHYSMEM_BITS, causing a
> pagesize times smaller DDW to be created, being insufficient for correct
> usage.
>
> Fix this so the correct window size is used in this case.
Good find indeed.
afaict this does not create a huge problem though as
query.largest_available_block is always smaller than (MAX_PHYSMEM_BITS -
page_shift) where it matters (phyp).
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Fixes: bf6e2d562bbc4("powerpc/dma: Fallback to dma_ops when persistent memory present")
> Signed-off-by: Leonardo Bras <leobras.c@gmail.com>
> ---
> arch/powerpc/platforms/pseries/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 9fc5217f0c8e..836cbbe0ecc5 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -1229,7 +1229,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
> if (pmem_present) {
> if (query.largest_available_block >=
> (1ULL << (MAX_PHYSMEM_BITS - page_shift)))
> - len = MAX_PHYSMEM_BITS - page_shift;
> + len = MAX_PHYSMEM_BITS;
> else
> dev_info(&dev->dev, "Skipping ibm,pmemory");
> }
>
--
Alexey
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem
2021-04-20 5:18 ` Alexey Kardashevskiy
@ 2021-04-20 5:29 ` Leonardo Bras
0 siblings, 0 replies; 4+ messages in thread
From: Leonardo Bras @ 2021-04-20 5:29 UTC (permalink / raw)
To: Alexey Kardashevskiy, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras
Cc: linuxppc-dev, linux-kernel
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.
> >
> > But, if that happens, the window size (len) is set to
> > (MAX_PHYSMEM_BITS - page_shift) instead of MAX_PHYSMEM_BITS, causing a
> > pagesize times smaller DDW to be created, being insufficient for correct
> > usage.
> >
> > Fix this so the correct window size is used in this case.
>
> Good find indeed.
>
> afaict this does not create a huge problem though as
> query.largest_available_block is always smaller than (MAX_PHYSMEM_BITS -
> page_shift) where it matters (phyp).
>
>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
Thanks for reviewing!
Leonardo Bras
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem
2021-04-20 4:54 [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem Leonardo Bras
2021-04-20 5:18 ` Alexey Kardashevskiy
@ 2021-04-21 13:08 ` Michael Ellerman
1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2021-04-21 13:08 UTC (permalink / raw)
To: Leonardo Bras, Michael Ellerman, Alexey Kardashevskiy,
Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
On Tue, 20 Apr 2021 01:54:04 -0300, 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.
>
> But, if that happens, the window size (len) is set to
> (MAX_PHYSMEM_BITS - page_shift) instead of MAX_PHYSMEM_BITS, causing a
> pagesize times smaller DDW to be created, being insufficient for correct
> usage.
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem
https://git.kernel.org/powerpc/c/a9d2f9bb225fd2a764aef57738ab6c7f38d782ae
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-21 13:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 4:54 [PATCH 1/1] powerpc/pseries/iommu: Fix window size for direct mapping with pmem Leonardo Bras
2021-04-20 5:18 ` Alexey Kardashevskiy
2021-04-20 5:29 ` Leonardo Bras
2021-04-21 13:08 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).