Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <joerg.roedel@amd.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: Dave Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joerg Roedel and committed by
Linus Torvalds
56d93660 3400001c

+12
+3
include/linux/iommu-helper.h
··· 23 23 extern void iommu_area_free(unsigned long *map, unsigned long start, 24 24 unsigned int nr); 25 25 26 + extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len, 27 + unsigned long io_page_size); 28 + 26 29 #endif
+9
lib/iommu-helper.c
··· 79 79 } 80 80 } 81 81 EXPORT_SYMBOL(iommu_area_free); 82 + 83 + unsigned long iommu_num_pages(unsigned long addr, unsigned long len, 84 + unsigned long io_page_size) 85 + { 86 + unsigned long size = (addr & (io_page_size - 1)) + len; 87 + 88 + return DIV_ROUND_UP(size, io_page_size); 89 + } 90 + EXPORT_SYMBOL(iommu_num_pages);