linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page
@ 2015-09-19 13:04 Wei Yang
  2015-09-30 23:50 ` Wei Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Yang @ 2015-09-19 13:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Wei Yang

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@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

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

end of thread, other threads:[~2015-11-12  2:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-19 13:04 [PATCH] powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page Wei Yang
2015-09-30 23:50 ` Wei Yang
2015-10-01  4:15   ` Michael Ellerman
2015-10-01 22:51     ` Wei Yang
2015-11-12  2:32       ` Wei Yang

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).