aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-22 14:02:46 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-22 15:19:59 -0400
commit58b053e4ce9d2fc3023645c1b96e537c72aa8d9a (patch)
tree35fbd72eb62a37375bc06c01e356afd7da0c9693
parentf9527f121bd42c5d300815fbf12216bc1a63f60f (diff)
Update arch/ to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--arch/alpha/kernel/pci_iommu.c2
-rw-r--r--arch/arm/common/dmabounce.c2
-rw-r--r--arch/blackfin/kernel/dma-mapping.c3
-rw-r--r--arch/ia64/hp/common/sba_iommu.c2
-rw-r--r--arch/ia64/hp/sim/simscsi.c4
-rw-r--r--arch/ia64/sn/pci/pci_dma.c2
-rw-r--r--arch/m68k/kernel/dma.c2
-rw-r--r--arch/mips/mm/dma-default.c16
-rw-r--r--arch/powerpc/kernel/dma_64.c3
-rw-r--r--arch/powerpc/kernel/ibmebus.c3
-rw-r--r--arch/powerpc/kernel/iommu.c2
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c5
-rw-r--r--arch/sparc/kernel/ioport.c17
-rw-r--r--arch/sparc/mm/io-unit.c2
-rw-r--r--arch/sparc/mm/iommu.c8
-rw-r--r--arch/sparc/mm/sun4c.c2
-rw-r--r--arch/sparc64/kernel/iommu.c7
-rw-r--r--arch/sparc64/kernel/iommu_common.c13
-rw-r--r--arch/sparc64/kernel/ldc.c2
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c7
-rw-r--r--arch/x86/kernel/pci-calgary_64.c10
-rw-r--r--arch/x86/kernel/pci-gart_64.c4
-rw-r--r--arch/x86/kernel/pci-nommu_64.c4
23 files changed, 55 insertions, 67 deletions
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index e1c470752ebc..ee07dceae1d4 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -465,7 +465,7 @@ EXPORT_SYMBOL(pci_free_consistent);
465 Write dma_length of each leader with the combined lengths of 465 Write dma_length of each leader with the combined lengths of
466 the mergable followers. */ 466 the mergable followers. */
467 467
468#define SG_ENT_VIRT_ADDRESS(SG) (page_address((SG)->page) + (SG)->offset) 468#define SG_ENT_VIRT_ADDRESS(SG) (sg_virt((SG)))
469#define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG)) 469#define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG))
470 470
471static void 471static void
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 44ab0dad4035..9d371e476552 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -442,7 +442,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
442 BUG_ON(dir == DMA_NONE); 442 BUG_ON(dir == DMA_NONE);
443 443
444 for (i = 0; i < nents; i++, sg++) { 444 for (i = 0; i < nents; i++, sg++) {
445 struct page *page = sg->page; 445 struct page *page = sg_page(sg);
446 unsigned int offset = sg->offset; 446 unsigned int offset = sg->offset;
447 unsigned int length = sg->length; 447 unsigned int length = sg->length;
448 void *ptr = page_address(page) + offset; 448 void *ptr = page_address(page) + offset;
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index 94d7b119b71e..a16cb03c5291 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -160,8 +160,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
160 BUG_ON(direction == DMA_NONE); 160 BUG_ON(direction == DMA_NONE);
161 161
162 for (i = 0; i < nents; i++, sg++) { 162 for (i = 0; i < nents; i++, sg++) {
163 sg->dma_address = (dma_addr_t)(page_address(sg->page) + 163 sg->dma_address = (dma_addr_t) sg_virt(sg);
164 sg->offset);
165 164
166 invalidate_dcache_range(sg_dma_address(sg), 165 invalidate_dcache_range(sg_dma_address(sg),
167 sg_dma_address(sg) + 166 sg_dma_address(sg) +
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 3c95f4184b99..bc859a311eaf 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -246,7 +246,7 @@ static int reserve_sba_gart = 1;
246static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); 246static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
247static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t); 247static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t);
248 248
249#define sba_sg_address(sg) (page_address((sg)->page) + (sg)->offset) 249#define sba_sg_address(sg) sg_virt((sg))
250 250
251#ifdef FULL_VALID_PDIR 251#ifdef FULL_VALID_PDIR
252static u64 prefetch_spill_page; 252static u64 prefetch_spill_page;
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index a3a558a06757..6ef9b5219930 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -131,7 +131,7 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
131 stat.fd = desc[sc->device->id]; 131 stat.fd = desc[sc->device->id];
132 132
133 scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) { 133 scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) {
134 req.addr = __pa(page_address(sl->page) + sl->offset); 134 req.addr = __pa(sg_virt(sl));
135 req.len = sl->length; 135 req.len = sl->length;
136 if (DBG) 136 if (DBG)
137 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n", 137 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n",
@@ -212,7 +212,7 @@ static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len)
212 if (!len) 212 if (!len)
213 break; 213 break;
214 thislen = min(len, slp->length); 214 thislen = min(len, slp->length);
215 memcpy(page_address(slp->page) + slp->offset, buf, thislen); 215 memcpy(sg_virt(slp), buf, thislen);
216 len -= thislen; 216 len -= thislen;
217 } 217 }
218} 218}
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index ecd8a52b9b9e..511db2fd7bff 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -16,7 +16,7 @@
16#include <asm/sn/pcidev.h> 16#include <asm/sn/pcidev.h>
17#include <asm/sn/sn_sal.h> 17#include <asm/sn/sn_sal.h>
18 18
19#define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) 19#define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg)))
20#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG)) 20#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
21 21
22/** 22/**
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index 9d4e4b5b6bd8..ef490e1ce600 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -121,7 +121,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
121 int i; 121 int i;
122 122
123 for (i = 0; i < nents; sg++, i++) { 123 for (i = 0; i < nents; sg++, i++) {
124 sg->dma_address = page_to_phys(sg->page) + sg->offset; 124 sg->dma_address = sg_phys(sg);
125 dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir); 125 dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir);
126 } 126 }
127 return nents; 127 return nents;
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 98b5e5bac02e..b0b034c4654f 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -165,12 +165,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
165 for (i = 0; i < nents; i++, sg++) { 165 for (i = 0; i < nents; i++, sg++) {
166 unsigned long addr; 166 unsigned long addr;
167 167
168 addr = (unsigned long) page_address(sg->page); 168 addr = (unsigned long) sg_virt(sg);
169 if (!plat_device_is_coherent(dev) && addr) 169 if (!plat_device_is_coherent(dev) && addr)
170 __dma_sync(addr + sg->offset, sg->length, direction); 170 __dma_sync(addr, sg->length, direction);
171 sg->dma_address = plat_map_dma_mem(dev, 171 sg->dma_address = plat_map_dma_mem(dev,
172 (void *)(addr + sg->offset), 172 (void *)addr, sg->length);
173 sg->length);
174 } 173 }
175 174
176 return nents; 175 return nents;
@@ -223,10 +222,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
223 for (i = 0; i < nhwentries; i++, sg++) { 222 for (i = 0; i < nhwentries; i++, sg++) {
224 if (!plat_device_is_coherent(dev) && 223 if (!plat_device_is_coherent(dev) &&
225 direction != DMA_TO_DEVICE) { 224 direction != DMA_TO_DEVICE) {
226 addr = (unsigned long) page_address(sg->page); 225 addr = (unsigned long) sg_virt(sg);
227 if (addr) 226 if (addr)
228 __dma_sync(addr + sg->offset, sg->length, 227 __dma_sync(addr, sg->length, direction);
229 direction);
230 } 228 }
231 plat_unmap_dma_mem(sg->dma_address); 229 plat_unmap_dma_mem(sg->dma_address);
232 } 230 }
@@ -304,7 +302,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
304 /* Make sure that gcc doesn't leave the empty loop body. */ 302 /* Make sure that gcc doesn't leave the empty loop body. */
305 for (i = 0; i < nelems; i++, sg++) { 303 for (i = 0; i < nelems; i++, sg++) {
306 if (cpu_is_noncoherent_r10000(dev)) 304 if (cpu_is_noncoherent_r10000(dev))
307 __dma_sync((unsigned long)page_address(sg->page), 305 __dma_sync((unsigned long)page_address(sg_page(sg)),
308 sg->length, direction); 306 sg->length, direction);
309 plat_unmap_dma_mem(sg->dma_address); 307 plat_unmap_dma_mem(sg->dma_address);
310 } 308 }
@@ -322,7 +320,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
322 /* Make sure that gcc doesn't leave the empty loop body. */ 320 /* Make sure that gcc doesn't leave the empty loop body. */
323 for (i = 0; i < nelems; i++, sg++) { 321 for (i = 0; i < nelems; i++, sg++) {
324 if (!plat_device_is_coherent(dev)) 322 if (!plat_device_is_coherent(dev))
325 __dma_sync((unsigned long)page_address(sg->page), 323 __dma_sync((unsigned long)page_address(sg_page(sg)),
326 sg->length, direction); 324 sg->length, direction);
327 plat_unmap_dma_mem(sg->dma_address); 325 plat_unmap_dma_mem(sg->dma_address);
328 } 326 }
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 9001104b56b0..14206e3f0819 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -161,8 +161,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
161 int i; 161 int i;
162 162
163 for_each_sg(sgl, sg, nents, i) { 163 for_each_sg(sgl, sg, nents, i) {
164 sg->dma_address = (page_to_phys(sg->page) + sg->offset) | 164 sg->dma_address = sg_phys(sg) | dma_direct_offset;
165 dma_direct_offset;
166 sg->dma_length = sg->length; 165 sg->dma_length = sg->length;
167 } 166 }
168 167
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 289d7e935918..72fd87156b24 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -102,8 +102,7 @@ static int ibmebus_map_sg(struct device *dev,
102 int i; 102 int i;
103 103
104 for_each_sg(sgl, sg, nents, i) { 104 for_each_sg(sgl, sg, nents, i) {
105 sg->dma_address = (dma_addr_t)page_address(sg->page) 105 sg->dma_address = (dma_addr_t) sg_virt(sg);
106 + sg->offset;
107 sg->dma_length = sg->length; 106 sg->dma_length = sg->length;
108 } 107 }
109 108
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 306a6f75b6c5..2d0c9ef555e9 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -307,7 +307,7 @@ int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
307 continue; 307 continue;
308 } 308 }
309 /* Allocate iommu entries for that segment */ 309 /* Allocate iommu entries for that segment */
310 vaddr = (unsigned long)page_address(s->page) + s->offset; 310 vaddr = (unsigned long) sg_virt(s);
311 npages = iommu_num_pages(vaddr, slen); 311 npages = iommu_num_pages(vaddr, slen);
312 entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0); 312 entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0);
313 313
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 07e64b48e7fc..6405f4a36763 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -628,9 +628,8 @@ static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
628 int i; 628 int i;
629 629
630 for_each_sg(sgl, sg, nents, i) { 630 for_each_sg(sgl, sg, nents, i) {
631 int result = ps3_dma_map(dev->d_region, 631 int result = ps3_dma_map(dev->d_region, sg_phys(sg),
632 page_to_phys(sg->page) + sg->offset, sg->length, 632 sg->length, &sg->dma_address, 0);
633 &sg->dma_address, 0);
634 633
635 if (result) { 634 if (result) {
636 pr_debug("%s:%d: ps3_dma_map failed (%d)\n", 635 pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 9c3ed88853f3..97aa50d1e4ae 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -727,9 +727,8 @@ int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents,
727 BUG_ON(direction == PCI_DMA_NONE); 727 BUG_ON(direction == PCI_DMA_NONE);
728 /* IIep is write-through, not flushing. */ 728 /* IIep is write-through, not flushing. */
729 for_each_sg(sgl, sg, nents, n) { 729 for_each_sg(sgl, sg, nents, n) {
730 BUG_ON(page_address(sg->page) == NULL); 730 BUG_ON(page_address(sg_page(sg)) == NULL);
731 sg->dvma_address = 731 sg->dvma_address = virt_to_phys(sg_virt(sg));
732 virt_to_phys(page_address(sg->page)) + sg->offset;
733 sg->dvma_length = sg->length; 732 sg->dvma_length = sg->length;
734 } 733 }
735 return nents; 734 return nents;
@@ -748,9 +747,9 @@ void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents,
748 BUG_ON(direction == PCI_DMA_NONE); 747 BUG_ON(direction == PCI_DMA_NONE);
749 if (direction != PCI_DMA_TODEVICE) { 748 if (direction != PCI_DMA_TODEVICE) {
750 for_each_sg(sgl, sg, nents, n) { 749 for_each_sg(sgl, sg, nents, n) {
751 BUG_ON(page_address(sg->page) == NULL); 750 BUG_ON(page_address(sg_page(sg)) == NULL);
752 mmu_inval_dma_area( 751 mmu_inval_dma_area(
753 (unsigned long) page_address(sg->page), 752 (unsigned long) page_address(sg_page(sg)),
754 (sg->length + PAGE_SIZE-1) & PAGE_MASK); 753 (sg->length + PAGE_SIZE-1) & PAGE_MASK);
755 } 754 }
756 } 755 }
@@ -798,9 +797,9 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sgl, int
798 BUG_ON(direction == PCI_DMA_NONE); 797 BUG_ON(direction == PCI_DMA_NONE);
799 if (direction != PCI_DMA_TODEVICE) { 798 if (direction != PCI_DMA_TODEVICE) {
800 for_each_sg(sgl, sg, nents, n) { 799 for_each_sg(sgl, sg, nents, n) {
801 BUG_ON(page_address(sg->page) == NULL); 800 BUG_ON(page_address(sg_page(sg)) == NULL);
802 mmu_inval_dma_area( 801 mmu_inval_dma_area(
803 (unsigned long) page_address(sg->page), 802 (unsigned long) page_address(sg_page(sg)),
804 (sg->length + PAGE_SIZE-1) & PAGE_MASK); 803 (sg->length + PAGE_SIZE-1) & PAGE_MASK);
805 } 804 }
806 } 805 }
@@ -814,9 +813,9 @@ void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sgl,
814 BUG_ON(direction == PCI_DMA_NONE); 813 BUG_ON(direction == PCI_DMA_NONE);
815 if (direction != PCI_DMA_TODEVICE) { 814 if (direction != PCI_DMA_TODEVICE) {
816 for_each_sg(sgl, sg, nents, n) { 815 for_each_sg(sgl, sg, nents, n) {
817 BUG_ON(page_address(sg->page) == NULL); 816 BUG_ON(page_address(sg_page(sg)) == NULL);
818 mmu_inval_dma_area( 817 mmu_inval_dma_area(
819 (unsigned long) page_address(sg->page), 818 (unsigned long) page_address(sg_page(sg)),
820 (sg->length + PAGE_SIZE-1) & PAGE_MASK); 819 (sg->length + PAGE_SIZE-1) & PAGE_MASK);
821 } 820 }
822 } 821 }
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index 375b4db63704..1666087c5b80 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -144,7 +144,7 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus
144 spin_lock_irqsave(&iounit->lock, flags); 144 spin_lock_irqsave(&iounit->lock, flags);
145 while (sz != 0) { 145 while (sz != 0) {
146 --sz; 146 --sz;
147 sg->dvma_address = iounit_get_area(iounit, (unsigned long)page_address(sg->page) + sg->offset, sg->length); 147 sg->dvma_address = iounit_get_area(iounit, sg_virt(sg), sg->length);
148 sg->dvma_length = sg->length; 148 sg->dvma_length = sg->length;
149 sg = sg_next(sg); 149 sg = sg_next(sg);
150 } 150 }
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 283656d9f6ea..4b934270f05e 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -238,7 +238,7 @@ static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sb
238 while (sz != 0) { 238 while (sz != 0) {
239 --sz; 239 --sz;
240 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 240 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
241 sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; 241 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
242 sg->dvma_length = (__u32) sg->length; 242 sg->dvma_length = (__u32) sg->length;
243 sg = sg_next(sg); 243 sg = sg_next(sg);
244 } 244 }
@@ -252,7 +252,7 @@ static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbu
252 while (sz != 0) { 252 while (sz != 0) {
253 --sz; 253 --sz;
254 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; 254 n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
255 sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; 255 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
256 sg->dvma_length = (__u32) sg->length; 256 sg->dvma_length = (__u32) sg->length;
257 sg = sg_next(sg); 257 sg = sg_next(sg);
258 } 258 }
@@ -273,7 +273,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
273 * XXX Is this a good assumption? 273 * XXX Is this a good assumption?
274 * XXX What if someone else unmaps it here and races us? 274 * XXX What if someone else unmaps it here and races us?
275 */ 275 */
276 if ((page = (unsigned long) page_address(sg->page)) != 0) { 276 if ((page = (unsigned long) page_address(sg_page(sg))) != 0) {
277 for (i = 0; i < n; i++) { 277 for (i = 0; i < n; i++) {
278 if (page != oldpage) { /* Already flushed? */ 278 if (page != oldpage) { /* Already flushed? */
279 flush_page_for_dma(page); 279 flush_page_for_dma(page);
@@ -283,7 +283,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
283 } 283 }
284 } 284 }
285 285
286 sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; 286 sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
287 sg->dvma_length = (__u32) sg->length; 287 sg->dvma_length = (__u32) sg->length;
288 sg = sg_next(sg); 288 sg = sg_next(sg);
289 } 289 }
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index ee6708fc4492..a2cc141291c7 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -1228,7 +1228,7 @@ static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *
1228{ 1228{
1229 while (sz != 0) { 1229 while (sz != 0) {
1230 --sz; 1230 --sz;
1231 sg->dvma_address = (__u32)sun4c_lockarea(page_address(sg->page) + sg->offset, sg->length); 1231 sg->dvma_address = (__u32)sun4c_lockarea(sg_virt(sg), sg->length);
1232 sg->dvma_length = sg->length; 1232 sg->dvma_length = sg->length;
1233 sg = sg_next(sg); 1233 sg = sg_next(sg);
1234 } 1234 }
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index 29af777d7ac9..070a4846c0cb 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -472,8 +472,7 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
472 spin_unlock_irqrestore(&iommu->lock, flags); 472 spin_unlock_irqrestore(&iommu->lock, flags);
473} 473}
474 474
475#define SG_ENT_PHYS_ADDRESS(SG) \ 475#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
476 (__pa(page_address((SG)->page)) + (SG)->offset)
477 476
478static void fill_sg(iopte_t *iopte, struct scatterlist *sg, 477static void fill_sg(iopte_t *iopte, struct scatterlist *sg,
479 int nused, int nelems, 478 int nused, int nelems,
@@ -565,9 +564,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
565 /* Fast path single entry scatterlists. */ 564 /* Fast path single entry scatterlists. */
566 if (nelems == 1) { 565 if (nelems == 1) {
567 sglist->dma_address = 566 sglist->dma_address =
568 dma_4u_map_single(dev, 567 dma_4u_map_single(dev, sg_virt(sglist),
569 (page_address(sglist->page) +
570 sglist->offset),
571 sglist->length, direction); 568 sglist->length, direction);
572 if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) 569 if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
573 return 0; 570 return 0;
diff --git a/arch/sparc64/kernel/iommu_common.c b/arch/sparc64/kernel/iommu_common.c
index d7ca900ec51d..78e8277df655 100644
--- a/arch/sparc64/kernel/iommu_common.c
+++ b/arch/sparc64/kernel/iommu_common.c
@@ -73,7 +73,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg,
73 73
74 daddr = dma_sg->dma_address; 74 daddr = dma_sg->dma_address;
75 sglen = sg->length; 75 sglen = sg->length;
76 sgaddr = (unsigned long) (page_address(sg->page) + sg->offset); 76 sgaddr = (unsigned long) sg_virt(sg);
77 while (dlen > 0) { 77 while (dlen > 0) {
78 unsigned long paddr; 78 unsigned long paddr;
79 79
@@ -123,7 +123,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg,
123 sg = sg_next(sg); 123 sg = sg_next(sg);
124 if (--nents <= 0) 124 if (--nents <= 0)
125 break; 125 break;
126 sgaddr = (unsigned long) (page_address(sg->page) + sg->offset); 126 sgaddr = (unsigned long) sg_virt(sg);
127 sglen = sg->length; 127 sglen = sg->length;
128 } 128 }
129 if (dlen < 0) { 129 if (dlen < 0) {
@@ -191,7 +191,7 @@ void verify_sglist(struct scatterlist *sglist, int nents, iopte_t *iopte, int np
191 printk("sg(%d): page_addr(%p) off(%x) length(%x) " 191 printk("sg(%d): page_addr(%p) off(%x) length(%x) "
192 "dma_address[%016x] dma_length[%016x]\n", 192 "dma_address[%016x] dma_length[%016x]\n",
193 i, 193 i,
194 page_address(sg->page), sg->offset, 194 page_address(sg_page(sg)), sg->offset,
195 sg->length, 195 sg->length,
196 sg->dma_address, sg->dma_length); 196 sg->dma_address, sg->dma_length);
197 } 197 }
@@ -207,15 +207,14 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents)
207 unsigned long prev; 207 unsigned long prev;
208 u32 dent_addr, dent_len; 208 u32 dent_addr, dent_len;
209 209
210 prev = (unsigned long) (page_address(sg->page) + sg->offset); 210 prev = (unsigned long) sg_virt(sg);
211 prev += (unsigned long) (dent_len = sg->length); 211 prev += (unsigned long) (dent_len = sg->length);
212 dent_addr = (u32) ((unsigned long)(page_address(sg->page) + sg->offset) 212 dent_addr = (u32) ((unsigned long)(sg_virt(sg)) & (IO_PAGE_SIZE - 1UL));
213 & (IO_PAGE_SIZE - 1UL));
214 while (--nents) { 213 while (--nents) {
215 unsigned long addr; 214 unsigned long addr;
216 215
217 sg = sg_next(sg); 216 sg = sg_next(sg);
218 addr = (unsigned long) (page_address(sg->page) + sg->offset); 217 addr = (unsigned long) sg_virt(sg);
219 if (! VCONTIG(prev, addr)) { 218 if (! VCONTIG(prev, addr)) {
220 dma_sg->dma_address = dent_addr; 219 dma_sg->dma_address = dent_addr;
221 dma_sg->dma_length = dent_len; 220 dma_sg->dma_length = dent_len;
diff --git a/arch/sparc64/kernel/ldc.c b/arch/sparc64/kernel/ldc.c
index 85a2be0b0962..c8313cb60f0a 100644
--- a/arch/sparc64/kernel/ldc.c
+++ b/arch/sparc64/kernel/ldc.c
@@ -2057,7 +2057,7 @@ static void fill_cookies(struct cookie_state *sp, unsigned long pa,
2057 2057
2058static int sg_count_one(struct scatterlist *sg) 2058static int sg_count_one(struct scatterlist *sg)
2059{ 2059{
2060 unsigned long base = page_to_pfn(sg->page) << PAGE_SHIFT; 2060 unsigned long base = page_to_pfn(sg_page(sg)) << PAGE_SHIFT;
2061 long len = sg->length; 2061 long len = sg->length;
2062 2062
2063 if ((sg->offset | len) & (8UL - 1)) 2063 if ((sg->offset | len) & (8UL - 1))
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index fe46ace3e59f..8c4875bdb4a8 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -365,8 +365,7 @@ static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr,
365 spin_unlock_irqrestore(&iommu->lock, flags); 365 spin_unlock_irqrestore(&iommu->lock, flags);
366} 366}
367 367
368#define SG_ENT_PHYS_ADDRESS(SG) \ 368#define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
369 (__pa(page_address((SG)->page)) + (SG)->offset)
370 369
371static long fill_sg(long entry, struct device *dev, 370static long fill_sg(long entry, struct device *dev,
372 struct scatterlist *sg, 371 struct scatterlist *sg,
@@ -477,9 +476,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
477 /* Fast path single entry scatterlists. */ 476 /* Fast path single entry scatterlists. */
478 if (nelems == 1) { 477 if (nelems == 1) {
479 sglist->dma_address = 478 sglist->dma_address =
480 dma_4v_map_single(dev, 479 dma_4v_map_single(dev, sg_virt(sglist),
481 (page_address(sglist->page) +
482 sglist->offset),
483 sglist->length, direction); 480 sglist->length, direction);
484 if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) 481 if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
485 return 0; 482 return 0;
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 5098f58063a5..1a20fe31338b 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -411,8 +411,10 @@ static int calgary_nontranslate_map_sg(struct device* dev,
411 int i; 411 int i;
412 412
413 for_each_sg(sg, s, nelems, i) { 413 for_each_sg(sg, s, nelems, i) {
414 BUG_ON(!s->page); 414 struct page *p = sg_page(s);
415 s->dma_address = virt_to_bus(page_address(s->page) +s->offset); 415
416 BUG_ON(!p);
417 s->dma_address = virt_to_bus(sg_virt(s));
416 s->dma_length = s->length; 418 s->dma_length = s->length;
417 } 419 }
418 return nelems; 420 return nelems;
@@ -432,9 +434,9 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
432 return calgary_nontranslate_map_sg(dev, sg, nelems, direction); 434 return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
433 435
434 for_each_sg(sg, s, nelems, i) { 436 for_each_sg(sg, s, nelems, i) {
435 BUG_ON(!s->page); 437 BUG_ON(!sg_page(s));
436 438
437 vaddr = (unsigned long)page_address(s->page) + s->offset; 439 vaddr = (unsigned long) sg_virt(s);
438 npages = num_dma_pages(vaddr, s->length); 440 npages = num_dma_pages(vaddr, s->length);
439 441
440 entry = iommu_range_alloc(tbl, npages); 442 entry = iommu_range_alloc(tbl, npages);
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 5cdfab65e93f..c56e9ee64964 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -302,7 +302,7 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
302#endif 302#endif
303 303
304 for_each_sg(sg, s, nents, i) { 304 for_each_sg(sg, s, nents, i) {
305 unsigned long addr = page_to_phys(s->page) + s->offset; 305 unsigned long addr = sg_phys(s);
306 if (nonforced_iommu(dev, addr, s->length)) { 306 if (nonforced_iommu(dev, addr, s->length)) {
307 addr = dma_map_area(dev, addr, s->length, dir); 307 addr = dma_map_area(dev, addr, s->length, dir);
308 if (addr == bad_dma_address) { 308 if (addr == bad_dma_address) {
@@ -397,7 +397,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
397 start_sg = sgmap = sg; 397 start_sg = sgmap = sg;
398 ps = NULL; /* shut up gcc */ 398 ps = NULL; /* shut up gcc */
399 for_each_sg(sg, s, nents, i) { 399 for_each_sg(sg, s, nents, i) {
400 dma_addr_t addr = page_to_phys(s->page) + s->offset; 400 dma_addr_t addr = sg_phys(s);
401 s->dma_address = addr; 401 s->dma_address = addr;
402 BUG_ON(s->length == 0); 402 BUG_ON(s->length == 0);
403 403
diff --git a/arch/x86/kernel/pci-nommu_64.c b/arch/x86/kernel/pci-nommu_64.c
index e85d4360360c..faf70bdca335 100644
--- a/arch/x86/kernel/pci-nommu_64.c
+++ b/arch/x86/kernel/pci-nommu_64.c
@@ -62,8 +62,8 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
62 int i; 62 int i;
63 63
64 for_each_sg(sg, s, nents, i) { 64 for_each_sg(sg, s, nents, i) {
65 BUG_ON(!s->page); 65 BUG_ON(!sg_page(s));
66 s->dma_address = virt_to_bus(page_address(s->page) +s->offset); 66 s->dma_address = virt_to_bus(sg_virt(s));
67 if (!check_addr("map_sg", hwdev, s->dma_address, s->length)) 67 if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
68 return 0; 68 return 0;
69 s->dma_length = s->length; 69 s->dma_length = s->length;