Skip to content

Commit

Permalink
generic, x86: fix add iommu_num_pages helper function
Browse files Browse the repository at this point in the history
This IOMMU helper function doesn't work for some architectures:

  http://marc.info/?l=linux-kernel&m=121699304403202&w=2

It also breaks POWER and SPARC builds:

  http://marc.info/?l=linux-kernel&m=121730388001890&w=2

Currently, only x86 IOMMUs use this so let's move it to x86 for
now.

Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: FUJITA Tomonori <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
fujita authored and Ingo Molnar committed Jul 29, 2008
1 parent 35780c8 commit 8978b74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 8 additions & 0 deletions arch/x86/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ void __init pci_iommu_alloc(void)

pci_swiotlb_init();
}

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);
#endif

/*
Expand Down
2 changes: 2 additions & 0 deletions include/asm-x86/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extern struct dma_mapping_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;

extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len);

#ifdef CONFIG_GART_IOMMU
extern int gart_iommu_aperture;
extern int gart_iommu_aperture_allowed;
Expand Down
1 change: 0 additions & 1 deletion include/linux/iommu-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ 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: 0 additions & 8 deletions lib/iommu-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,3 @@ 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 8978b74

Please sign in to comment.