[PATCH] powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page

Wei Yang weiyang at linux.vnet.ibm.com
Thu Oct 1 09:50:55 AEST 2015


Hmm... some comments on this one? like it or not?

On Sat, Sep 19, 2015 at 09:04:27PM +0800, Wei Yang wrote:
>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.
>
>Signed-off-by: Wei Yang <weiyang at linux.vnet.ibm.com>
>---
> arch/powerpc/kernel/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
>index a8e3490..9885397 100644
>--- a/arch/powerpc/kernel/iommu.c
>+++ b/arch/powerpc/kernel/iommu.c
>@@ -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);
>-- 
>2.5.0

-- 
Richard Yang
Help you, Help me



More information about the Linuxppc-dev mailing list