From: Joerg Roedel Date: Thu, 16 Oct 2008 05:02:10 +0000 (-0700) Subject: introduce generic iommu_num_pages function X-Git-Tag: firefly_0821_release~17612 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=56d936607408d71c4141b2ed501410b072f1e211;p=firefly-linux-kernel-4.4.55.git introduce generic iommu_num_pages function This patch introduces the generic iommu_num_pages function. It can be used by a given memory area. Signed-off-by: Joerg Roedel Cc: "David S. Miller" Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Ingo Molnar Cc: Thomas Gleixner Cc: FUJITA Tomonori Cc: Muli Ben-Yehuda Cc: Dave Airlie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h index a6d0586e2bf7..3b068e5b5671 100644 --- a/include/linux/iommu-helper.h +++ b/include/linux/iommu-helper.h @@ -23,4 +23,7 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, extern void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr); +extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len, + unsigned long io_page_size); + #endif diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c index 5d90074dca75..75dbda03f4fb 100644 --- a/lib/iommu-helper.c +++ b/lib/iommu-helper.c @@ -79,3 +79,12 @@ void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr) } } EXPORT_SYMBOL(iommu_area_free); + +unsigned long iommu_num_pages(unsigned long addr, unsigned long len, + unsigned long io_page_size) +{ + unsigned long size = (addr & (io_page_size - 1)) + len; + + return DIV_ROUND_UP(size, io_page_size); +} +EXPORT_SYMBOL(iommu_num_pages);