summaryrefslogtreecommitdiff
path: root/arch/sparc64/kernel/iommu_common.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 10:46:58 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 10:46:58 -0800
commite33f6635da037ed4d2634ee6bdf5c4d601946c18 (patch)
tree443367576b9a2e30eb32c9d1c422206c87e5a1ad /arch/sparc64/kernel/iommu_common.h
parent55850f47333c6e7d932e6426eaed863b27c9cd7f (diff)
parent38192d52f159bc06b7f523800c10b583cdd661d5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6: [SPARC64]: Temporarily remove IOMMU merging code. [SPARC64]: Update defconfig. [SPARC]: Add new timerfd syscall entries.
Diffstat (limited to 'arch/sparc64/kernel/iommu_common.h')
-rw-r--r--arch/sparc64/kernel/iommu_common.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/iommu_common.h b/arch/sparc64/kernel/iommu_common.h
index a90d046e802..4b5cafa2877 100644
--- a/arch/sparc64/kernel/iommu_common.h
+++ b/arch/sparc64/kernel/iommu_common.h
@@ -30,6 +30,32 @@
*/
#define IOMMU_PAGE_SHIFT 13
+#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
+
+static inline unsigned long iommu_num_pages(unsigned long vaddr,
+ unsigned long slen)
+{
+ unsigned long npages;
+
+ npages = IO_PAGE_ALIGN(vaddr + slen) - (vaddr & IO_PAGE_MASK);
+ npages >>= IO_PAGE_SHIFT;
+
+ return npages;
+}
+
+static inline unsigned long calc_npages(struct scatterlist *sglist, int nelems)
+{
+ unsigned long i, npages = 0;
+ struct scatterlist *sg;
+
+ for_each_sg(sglist, sg, nelems, i) {
+ unsigned long paddr = SG_ENT_PHYS_ADDRESS(sg);
+ npages += iommu_num_pages(paddr, sg->length);
+ }
+
+ return npages;
+}
+
/* You are _strongly_ advised to enable the following debugging code
* any time you make changes to the sg code below, run it for a while
* with filesystems mounted read-only before buying the farm... -DaveM