Skip to content

Commit

Permalink
iommu: add iommu_num_pages helper function
Browse files Browse the repository at this point in the history
Calculating the number of pages from given address and length numbers is a task
required in multiple IOMMU implementations. So implement this as a generic
function into the IOMMU helper code.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: robert.richter@amd.com
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Joerg Roedel authored and Ingo Molnar committed Jul 26, 2008
1 parent 024e8ac commit 3bc9f79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/iommu-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
unsigned long align_mask);
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);
8 changes: 8 additions & 0 deletions lib/iommu-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@ 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 size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);

return size >> PAGE_SHIFT;
}
EXPORT_SYMBOL(iommu_num_pages);

0 comments on commit 3bc9f79

Please sign in to comment.