lkml.org 
[lkml]   [2008]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] add iommu_num_pages helper function
From
On Fri, 25 Jul 2008 15:21:21 +0200
Joerg Roedel <joerg.roedel@amd.com> wrote:

> On Fri, Jul 25, 2008 at 10:15:06PM +0900, FUJITA Tomonori wrote:
> > On Fri, 25 Jul 2008 14:57:58 +0200
> > Joerg Roedel <joerg.roedel@amd.com> wrote:
> >
> > > 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.
> > >
> > > Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > > Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> > > ---
> > > include/linux/iommu-helper.h | 1 +
> > > lib/iommu-helper.c | 8 ++++++++
> > > 2 files changed, 9 insertions(+), 0 deletions(-)
> >
> > Thanks. I planed to work on this after rc1. You beat me. :)
> >
> >
> > > diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
> > > index c975caf..f8598f5 100644
> > > --- a/include/linux/iommu-helper.h
> > > +++ b/include/linux/iommu-helper.h
> > > @@ -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);
> > > diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c
> > > index a3b8d4c..889ddce 100644
> > > --- a/lib/iommu-helper.c
> > > +++ b/lib/iommu-helper.c
> > > @@ -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);
> >
> > This doesn't work since PAGE_SIZE != IOMMU_PAGE_SIZE on the majority
> > of architectures.
>
> A quick grep in include/ tells me that only powerpc is declaring
> IOMMU_PAGE_SIZE by now.

Ah, I just meant the I/O size of IOMMUs.

This macro doesn't work for IA64, POWER, and SPARC.


\
 
 \ /
  Last update: 2008-07-25 15:39    [W:0.104 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site