aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-01-05 09:47:23 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-06 08:06:54 -0500
commit052aedbfb6cd4fd1a73010735da88a9dcc224673 (patch)
tree2ddeb0258e85a600367c0779a53c000047361535
parent4cf37bb7d9dc6dfb5d5fca7f735ba65ba173dabc (diff)
x86, gart: add map_page and unmap_page
This is a preparation of struct dma_mapping_ops unification. We use map_page and unmap_page instead of map_single and unmap_single. We will remove map_single and unmap_single hooks in the last patch in this patchset. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/pci-gart_64.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 00c2bcd41463..e49c6dd0e8c6 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -255,10 +255,13 @@ static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
255} 255}
256 256
257/* Map a single area into the IOMMU */ 257/* Map a single area into the IOMMU */
258static dma_addr_t 258static dma_addr_t gart_map_page(struct device *dev, struct page *page,
259gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir) 259 unsigned long offset, size_t size,
260 enum dma_data_direction dir,
261 struct dma_attrs *attrs)
260{ 262{
261 unsigned long bus; 263 unsigned long bus;
264 phys_addr_t paddr = page_to_phys(page) + offset;
262 265
263 if (!dev) 266 if (!dev)
264 dev = &x86_dma_fallback_dev; 267 dev = &x86_dma_fallback_dev;
@@ -272,11 +275,19 @@ gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir)
272 return bus; 275 return bus;
273} 276}
274 277
278static dma_addr_t gart_map_single(struct device *dev, phys_addr_t paddr,
279 size_t size, int dir)
280{
281 return gart_map_page(dev, pfn_to_page(paddr >> PAGE_SHIFT),
282 paddr & ~PAGE_MASK, size, dir, NULL);
283}
284
275/* 285/*
276 * Free a DMA mapping. 286 * Free a DMA mapping.
277 */ 287 */
278static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr, 288static void gart_unmap_page(struct device *dev, dma_addr_t dma_addr,
279 size_t size, int direction) 289 size_t size, enum dma_data_direction dir,
290 struct dma_attrs *attrs)
280{ 291{
281 unsigned long iommu_page; 292 unsigned long iommu_page;
282 int npages; 293 int npages;
@@ -295,6 +306,12 @@ static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
295 free_iommu(iommu_page, npages); 306 free_iommu(iommu_page, npages);
296} 307}
297 308
309static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
310 size_t size, int direction)
311{
312 gart_unmap_page(dev, dma_addr, size, direction, NULL);
313}
314
298/* 315/*
299 * Wrapper for pci_unmap_single working with scatterlists. 316 * Wrapper for pci_unmap_single working with scatterlists.
300 */ 317 */
@@ -712,6 +729,8 @@ static struct dma_mapping_ops gart_dma_ops = {
712 .unmap_single = gart_unmap_single, 729 .unmap_single = gart_unmap_single,
713 .map_sg = gart_map_sg, 730 .map_sg = gart_map_sg,
714 .unmap_sg = gart_unmap_sg, 731 .unmap_sg = gart_unmap_sg,
732 .map_page = gart_map_page,
733 .unmap_page = gart_unmap_page,
715 .alloc_coherent = gart_alloc_coherent, 734 .alloc_coherent = gart_alloc_coherent,
716 .free_coherent = gart_free_coherent, 735 .free_coherent = gart_free_coherent,
717}; 736};