powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page
PATCH 1/1 powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page
On PowerPC, currently we support different value of PAGE_SIZE and different value of IOMMU Page Size.
In case the PAGE_SIZE is 4K and the IOMMU Page Size is 16M, and driver asked for some DMA less than 16M, the current calculation would return 0 and the following allocation in iommu_alloc() would fail.
This patch uses iommu_num_pages() to calculate it.
--- arch/powerpc/kernel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/iommu.c +1 -1
@@ -842,7 +842,7 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,memset (ret,0 , size);/* Set up tces to cover the allocated range */ - nio_pages = size >> tbl->it_page_shift; + nio_pages =iommu_num_pages (0 , size,IOMMU_PAGE_SIZE (tbl)); io_order =get_iommu_order (size, tbl); mapping =iommu_alloc (dev, tbl, ret, nio_pages,DMA_BIDIRECTIONAL , mask >> tbl->it_page_shift, io_order,NULL );
Signature · 1 line
2.5.0
Hmm... some comments on this one? like it or not?
Quoted 29 lines · Wei Yang
On PowerPC, currently we support different value of
PAGE_SIZEand different value of IOMMU Page Size.In case the
PAGE_SIZEis 4K and the IOMMU Page Size is 16M, and driver asked for some DMA less than 16M, the current calculation would return 0 and the following allocation iniommu_alloc()would fail.This patch uses
iommu_num_pages()to calculate it.Signed-off-by Wei Yang <[email protected]>---
arch/powerpc/kernel/iommu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kernel/iommu.c +1
-1@@ -842,7 +842,7 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,memset (ret,0 , size);/* Set up tces to cover the allocated range */ - nio_pages = size >> tbl->it_page_shift; + nio_pages =iommu_num_pages (0 , size,IOMMU_PAGE_SIZE (tbl)); io_order =get_iommu_order (size, tbl); mapping =iommu_alloc (dev, tbl, ret, nio_pages,DMA_BIDIRECTIONAL , mask >> tbl->it_page_shift, io_order,NULL );Signature · 1 line
2.5.0
Signature · 2 lines
Richard Yang Help you, Help me
Michael Ellerman
reviewerQuoted 1 line · Wei Yang
Hmm... some comments on this one? like it or not?
It sounds like it's fixing a bug, but you don't really say. Have you seen this fail in the wild?
Which commit introduced the breakage?
cheers
Quoted 5 lines · Michael Ellerman
Quoted 1 line · Wei Yang
Hmm... some comments on this one? like it or not?
It sounds like it's fixing a bug, but you don't really say. Have you seen this fail in the wild?
Hmm... as described in the commit log, this would be a bug when PAGE_SIZE is much smaller than IOMMU Page Size. This configuration doesn't happen on current platform. So I didn't see this failure yet.
Quoted 2 lines
Which commit introduced the breakage?
Hmm... maybe we could say it is 'commit d084775738b7 <powerpc/iommu: Update the generic code to use dynamic iommu page sizes>'.
Quoted 1 line
From this commit, powerpc iommu supports dynamic iommu page size.
Before this commit, the size is aligned with PAGE_SIZE, so the value after shift would be non-zero. After this commit, when PAGE_SIZE is smaller than the IOMMU Page Size, shift right will make the size 0.
Quoted 3 lines
cheers
Signature · 2 lines
Richard Yang Help you, Help me
Someone willing to take a look?
Quoted 29 lines · Wei Yang
Quoted 5 lines · Michael Ellerman
Quoted 1 line · Wei Yang
Hmm... some comments on this one? like it or not?
It sounds like it's fixing a bug, but you don't really say. Have you seen this fail in the wild?
Hmm... as described in the commit log, this would be a bug when
PAGE_SIZEis much smaller than IOMMU Page Size. This configuration doesn't happen on current platform. So I didn't see this failure yet.Quoted 2 lines
Which commit introduced the breakage?
Hmm... maybe we could say it is 'commit
d084775738b7<powerpc/iommu: Update the generic code to use dynamic iommu page sizes>'.Quoted 1 line
From this commit, powerpc iommu supports dynamic iommu page size.
Before this commit, the size is aligned with
PAGE_SIZE, so the value after shift would be non-zero. After this commit, whenPAGE_SIZEis smaller than the IOMMU Page Size, shift right will make the size 0.Quoted 3 lines
cheers
Signature · 2 lines
Richard Yang Help you, Help me
Signature · 2 lines
Richard Yang Help you, Help me