lkml.org 
[lkml]   [2008]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 21/34] AMD IOMMU: add address allocation and deallocation functions
From
On Sun, 29 Jun 2008 17:17:15 +0200
Joerg Roedel <joerg.roedel@amd.com> wrote:

> On Mon, Jun 30, 2008 at 12:07:10AM +0900, FUJITA Tomonori wrote:
> > On Thu, 26 Jun 2008 21:27:57 +0200
> > Joerg Roedel <joerg.roedel@amd.com> wrote:
> >
> > > This patch adds the address allocator to the AMD IOMMU code.
> > >
> > > Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> > > ---
> > > arch/x86/kernel/amd_iommu.c | 48 +++++++++++++++++++++++++++++++++++++++++++
> > > 1 files changed, 48 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
> > > index 1d70f5e..69d8d02 100644
> > > --- a/arch/x86/kernel/amd_iommu.c
> > > +++ b/arch/x86/kernel/amd_iommu.c
> > > @@ -266,3 +266,51 @@ static int init_unity_mappings_for_device(struct dma_ops_domain *dma_dom,
> > > return 0;
> > > }
> > >
> > > +static unsigned long dma_mask_to_pages(unsigned long mask)
> > > +{
> > > + return (mask >> PAGE_SHIFT) +
> > > + (PAGE_ALIGN(mask & ~PAGE_MASK) >> PAGE_SHIFT);
> > > +}
> > > +
> > > +static unsigned long dma_ops_alloc_addresses(struct device *dev,
> > > + struct dma_ops_domain *dom,
> > > + unsigned int pages)
> > > +{
> > > + unsigned long limit = dma_mask_to_pages(*dev->dma_mask);
> > > + unsigned long address;
> > > + unsigned long size = dom->aperture_size >> PAGE_SHIFT;
> > > + unsigned long boundary_size;
> > > +
> > > + boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> > > + PAGE_SIZE) >> PAGE_SHIFT;
> > > + limit = limit < size ? limit : size;
> > > +
> > > + if (dom->next_bit >= limit)
> > > + dom->next_bit = 0;
> > > +
> > > + address = iommu_area_alloc(dom->bitmap, limit, dom->next_bit, pages,
> > > + 0 , boundary_size, 0);
> > > + if (address == -1)
> > > + address = iommu_area_alloc(dom->bitmap, limit, 0, pages,
> > > + 0, boundary_size, 0);
> > > +
> > > + if (likely(address != -1)) {
> > > + set_bit_string(dom->bitmap, address, pages);
> >
> > Is set_bit_string() necessary here? iommu_area_alloc calls it internally.
> >
>
> Probably not. I added it during debugging because the GART driver has it
> in that code path too. I will remove it with an follow-up patch.

Oops, seems that I left set_bit_string in the GART driver when I
converted it to use the IOMMU helpers.


\
 
 \ /
  Last update: 2008-06-30 01:15    [W:0.101 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site