]> err.no Git - linux-2.6/commitdiff
Update arch/ to use sg helpers
authorJens Axboe <jens.axboe@oracle.com>
Mon, 22 Oct 2007 18:02:46 +0000 (20:02 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 22 Oct 2007 19:19:59 +0000 (21:19 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
23 files changed:
arch/alpha/kernel/pci_iommu.c
arch/arm/common/dmabounce.c
arch/blackfin/kernel/dma-mapping.c
arch/ia64/hp/common/sba_iommu.c
arch/ia64/hp/sim/simscsi.c
arch/ia64/sn/pci/pci_dma.c
arch/m68k/kernel/dma.c
arch/mips/mm/dma-default.c
arch/powerpc/kernel/dma_64.c
arch/powerpc/kernel/ibmebus.c
arch/powerpc/kernel/iommu.c
arch/powerpc/platforms/ps3/system-bus.c
arch/sparc/kernel/ioport.c
arch/sparc/mm/io-unit.c
arch/sparc/mm/iommu.c
arch/sparc/mm/sun4c.c
arch/sparc64/kernel/iommu.c
arch/sparc64/kernel/iommu_common.c
arch/sparc64/kernel/ldc.c
arch/sparc64/kernel/pci_sun4v.c
arch/x86/kernel/pci-calgary_64.c
arch/x86/kernel/pci-gart_64.c
arch/x86/kernel/pci-nommu_64.c

index e1c470752ebc0db7e146c2d544da50496f3076af..ee07dceae1d4737978206ac6dfaa5d19548479f5 100644 (file)
@@ -465,7 +465,7 @@ EXPORT_SYMBOL(pci_free_consistent);
    Write dma_length of each leader with the combined lengths of
    the mergable followers.  */
 
-#define SG_ENT_VIRT_ADDRESS(SG) (page_address((SG)->page) + (SG)->offset)
+#define SG_ENT_VIRT_ADDRESS(SG) (sg_virt((SG)))
 #define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG))
 
 static void
index 44ab0dad40357dc83a5bafd305b93589cd71aa67..9d371e4765529748a977c235c4665abb75498cbd 100644 (file)
@@ -442,7 +442,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
        BUG_ON(dir == DMA_NONE);
 
        for (i = 0; i < nents; i++, sg++) {
-               struct page *page = sg->page;
+               struct page *page = sg_page(sg);
                unsigned int offset = sg->offset;
                unsigned int length = sg->length;
                void *ptr = page_address(page) + offset;
index 94d7b119b71ec6637e8b49a23d4f10b98f723a02..a16cb03c52913e43ef57abe8c06a95d023b00ce1 100644 (file)
@@ -160,8 +160,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
        BUG_ON(direction == DMA_NONE);
 
        for (i = 0; i < nents; i++, sg++) {
-               sg->dma_address = (dma_addr_t)(page_address(sg->page) +
-                                       sg->offset);
+               sg->dma_address = (dma_addr_t) sg_virt(sg);
 
                invalidate_dcache_range(sg_dma_address(sg),
                                        sg_dma_address(sg) +
index 3c95f4184b996d26e98ba709acff2052d40313e8..bc859a311eaf07774379ad3daa40067cb252c304 100644 (file)
@@ -246,7 +246,7 @@ static int reserve_sba_gart = 1;
 static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
 static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t);
 
-#define sba_sg_address(sg)     (page_address((sg)->page) + (sg)->offset)
+#define sba_sg_address(sg)     sg_virt((sg))
 
 #ifdef FULL_VALID_PDIR
 static u64 prefetch_spill_page;
index a3a558a0675779e602d9bb43625646cfe2cb02b6..6ef9b52199304af2f472f92becd0216cbbe2e492 100644 (file)
@@ -131,7 +131,7 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
        stat.fd = desc[sc->device->id];
 
        scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) {
-               req.addr = __pa(page_address(sl->page) + sl->offset);
+               req.addr = __pa(sg_virt(sl));
                req.len  = sl->length;
                if (DBG)
                        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)
                if (!len)
                        break;
                thislen = min(len, slp->length);
-               memcpy(page_address(slp->page) + slp->offset, buf, thislen);
+               memcpy(sg_virt(slp), buf, thislen);
                len -= thislen;
        }
 }
index ecd8a52b9b9e23a2e9987d2703976983b30af4c0..511db2fd7bff9ad50dd92b7af192c486e73ad27b 100644 (file)
@@ -16,7 +16,7 @@
 #include <asm/sn/pcidev.h>
 #include <asm/sn/sn_sal.h>
 
-#define SG_ENT_VIRT_ADDRESS(sg)        (page_address((sg)->page) + (sg)->offset)
+#define SG_ENT_VIRT_ADDRESS(sg)        (sg_virt((sg)))
 #define SG_ENT_PHYS_ADDRESS(SG)        virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
 
 /**
index 9d4e4b5b6bd889325d274334fd6b608989440831..ef490e1ce6002bae783774c77dc13b207191962f 100644 (file)
@@ -121,7 +121,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
        int i;
 
        for (i = 0; i < nents; sg++, i++) {
-               sg->dma_address = page_to_phys(sg->page) + sg->offset;
+               sg->dma_address = sg_phys(sg);
                dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir);
        }
        return nents;
index 98b5e5bac02e8b25ad7429a28b5548629cbee407..b0b034c4654f8987f108fcf62ccf5d4e11f2ba0c 100644 (file)
@@ -165,12 +165,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
        for (i = 0; i < nents; i++, sg++) {
                unsigned long addr;
 
-               addr = (unsigned long) page_address(sg->page);
+               addr = (unsigned long) sg_virt(sg);
                if (!plat_device_is_coherent(dev) && addr)
-                       __dma_sync(addr + sg->offset, sg->length, direction);
+                       __dma_sync(addr, sg->length, direction);
                sg->dma_address = plat_map_dma_mem(dev,
-                                                  (void *)(addr + sg->offset),
-                                                  sg->length);
+                                                  (void *)addr, sg->length);
        }
 
        return nents;
@@ -223,10 +222,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
        for (i = 0; i < nhwentries; i++, sg++) {
                if (!plat_device_is_coherent(dev) &&
                    direction != DMA_TO_DEVICE) {
-                       addr = (unsigned long) page_address(sg->page);
+                       addr = (unsigned long) sg_virt(sg);
                        if (addr)
-                               __dma_sync(addr + sg->offset, sg->length,
-                                          direction);
+                               __dma_sync(addr, sg->length, direction);
                }
                plat_unmap_dma_mem(sg->dma_address);
        }
@@ -304,7 +302,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
        /* Make sure that gcc doesn't leave the empty loop body.  */
        for (i = 0; i < nelems; i++, sg++) {
                if (cpu_is_noncoherent_r10000(dev))
-                       __dma_sync((unsigned long)page_address(sg->page),
+                       __dma_sync((unsigned long)page_address(sg_page(sg)),
                                   sg->length, direction);
                plat_unmap_dma_mem(sg->dma_address);
        }
@@ -322,7 +320,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
        /* Make sure that gcc doesn't leave the empty loop body.  */
        for (i = 0; i < nelems; i++, sg++) {
                if (!plat_device_is_coherent(dev))
-                       __dma_sync((unsigned long)page_address(sg->page),
+                       __dma_sync((unsigned long)page_address(sg_page(sg)),
                                   sg->length, direction);
                plat_unmap_dma_mem(sg->dma_address);
        }
index 9001104b56b0ba983e777b66f21b83cdbdb2eeb7..14206e3f0819a963d65fc5e6d3f26846b154f336 100644 (file)
@@ -161,8 +161,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
        int i;
 
        for_each_sg(sgl, sg, nents, i) {
-               sg->dma_address = (page_to_phys(sg->page) + sg->offset) |
-                       dma_direct_offset;
+               sg->dma_address = sg_phys(sg) | dma_direct_offset;
                sg->dma_length = sg->length;
        }
 
index 289d7e93591857bdbe3230a95fb08568b57df491..72fd87156b24b662ee8abb08878197c3a6b6a02b 100644 (file)
@@ -102,8 +102,7 @@ static int ibmebus_map_sg(struct device *dev,
        int i;
 
        for_each_sg(sgl, sg, nents, i) {
-               sg->dma_address = (dma_addr_t)page_address(sg->page)
-                       + sg->offset;
+               sg->dma_address = (dma_addr_t) sg_virt(sg);
                sg->dma_length = sg->length;
        }
 
index 306a6f75b6c5a8004bf5f496cbe1d6b86ed8b589..2d0c9ef555e9e4578d9df93ff91e025697069c4e 100644 (file)
@@ -307,7 +307,7 @@ int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
                        continue;
                }
                /* Allocate iommu entries for that segment */
-               vaddr = (unsigned long)page_address(s->page) + s->offset;
+               vaddr = (unsigned long) sg_virt(s);
                npages = iommu_num_pages(vaddr, slen);
                entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0);
 
index 07e64b48e7fca2d79391466a04a7da5502bf3251..6405f4a36763b00df384c1db6153e6125db0d822 100644 (file)
@@ -628,9 +628,8 @@ static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
        int i;
 
        for_each_sg(sgl, sg, nents, i) {
-               int result = ps3_dma_map(dev->d_region,
-                       page_to_phys(sg->page) + sg->offset, sg->length,
-                                        &sg->dma_address, 0);
+               int result = ps3_dma_map(dev->d_region, sg_phys(sg),
+                                       sg->length, &sg->dma_address, 0);
 
                if (result) {
                        pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
index 9c3ed88853f3d491d09575392bdb8163eb72eef0..97aa50d1e4ae053c2d61776d5880c820a2d38635 100644 (file)
@@ -727,9 +727,8 @@ int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents,
        BUG_ON(direction == PCI_DMA_NONE);
        /* IIep is write-through, not flushing. */
        for_each_sg(sgl, sg, nents, n) {
-               BUG_ON(page_address(sg->page) == NULL);
-               sg->dvma_address =
-                       virt_to_phys(page_address(sg->page)) + sg->offset;
+               BUG_ON(page_address(sg_page(sg)) == NULL);
+               sg->dvma_address = virt_to_phys(sg_virt(sg));
                sg->dvma_length = sg->length;
        }
        return nents;
@@ -748,9 +747,9 @@ void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents,
        BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for_each_sg(sgl, sg, nents, n) {
-                       BUG_ON(page_address(sg->page) == NULL);
+                       BUG_ON(page_address(sg_page(sg)) == NULL);
                        mmu_inval_dma_area(
-                           (unsigned long) page_address(sg->page),
+                           (unsigned long) page_address(sg_page(sg)),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);
                }
        }
@@ -798,9 +797,9 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sgl, int
        BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for_each_sg(sgl, sg, nents, n) {
-                       BUG_ON(page_address(sg->page) == NULL);
+                       BUG_ON(page_address(sg_page(sg)) == NULL);
                        mmu_inval_dma_area(
-                           (unsigned long) page_address(sg->page),
+                           (unsigned long) page_address(sg_page(sg)),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);
                }
        }
@@ -814,9 +813,9 @@ void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sgl,
        BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for_each_sg(sgl, sg, nents, n) {
-                       BUG_ON(page_address(sg->page) == NULL);
+                       BUG_ON(page_address(sg_page(sg)) == NULL);
                        mmu_inval_dma_area(
-                           (unsigned long) page_address(sg->page),
+                           (unsigned long) page_address(sg_page(sg)),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);
                }
        }
index 375b4db637046964afa002d700837da448d6674d..1666087c5b80e751587785046b848a1697563a35 100644 (file)
@@ -144,7 +144,7 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus
        spin_lock_irqsave(&iounit->lock, flags);
        while (sz != 0) {
                --sz;
-               sg->dvma_address = iounit_get_area(iounit, (unsigned long)page_address(sg->page) + sg->offset, sg->length);
+               sg->dvma_address = iounit_get_area(iounit, sg_virt(sg), sg->length);
                sg->dvma_length = sg->length;
                sg = sg_next(sg);
        }
index 283656d9f6ea77ae5241ea4677b05c47c5080706..4b934270f05e062c0a3c1519b3e9a1c1a51b3632 100644 (file)
@@ -238,7 +238,7 @@ static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sb
        while (sz != 0) {
                --sz;
                n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
-               sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+               sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
                sg->dvma_length = (__u32) sg->length;
                sg = sg_next(sg);
        }
@@ -252,7 +252,7 @@ static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbu
        while (sz != 0) {
                --sz;
                n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT;
-               sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+               sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
                sg->dvma_length = (__u32) sg->length;
                sg = sg_next(sg);
        }
@@ -273,7 +273,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
                 * XXX Is this a good assumption?
                 * XXX What if someone else unmaps it here and races us?
                 */
-               if ((page = (unsigned long) page_address(sg->page)) != 0) {
+               if ((page = (unsigned long) page_address(sg_page(sg))) != 0) {
                        for (i = 0; i < n; i++) {
                                if (page != oldpage) {  /* Already flushed? */
                                        flush_page_for_dma(page);
@@ -283,7 +283,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu
                        }
                }
 
-               sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset;
+               sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset;
                sg->dvma_length = (__u32) sg->length;
                sg = sg_next(sg);
        }
index ee6708fc4492476b2d28ed7293a8fbde47c5cd94..a2cc141291c72a0a22c93b762848a888677e7d1b 100644 (file)
@@ -1228,7 +1228,7 @@ static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *
 {
        while (sz != 0) {
                --sz;
-               sg->dvma_address = (__u32)sun4c_lockarea(page_address(sg->page) + sg->offset, sg->length);
+               sg->dvma_address = (__u32)sun4c_lockarea(sg_virt(sg), sg->length);
                sg->dvma_length = sg->length;
                sg = sg_next(sg);
        }
index 29af777d7ac920d138d9c8e7598f5fbd0d14a3de..070a4846c0cb7d7dcb06be192bcd8879733f5112 100644 (file)
@@ -472,8 +472,7 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
        spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
-#define SG_ENT_PHYS_ADDRESS(SG)        \
-       (__pa(page_address((SG)->page)) + (SG)->offset)
+#define SG_ENT_PHYS_ADDRESS(SG)        (__pa(sg_virt((SG))))
 
 static void fill_sg(iopte_t *iopte, struct scatterlist *sg,
                    int nused, int nelems,
@@ -565,9 +564,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
        /* Fast path single entry scatterlists. */
        if (nelems == 1) {
                sglist->dma_address =
-                       dma_4u_map_single(dev,
-                                         (page_address(sglist->page) +
-                                          sglist->offset),
+                       dma_4u_map_single(dev, sg_virt(sglist),
                                          sglist->length, direction);
                if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
                        return 0;
index d7ca900ec51d31e1ceaae922c68bdb8327914bf9..78e8277df655063a05ce374cc0911a27e4a8e96d 100644 (file)
@@ -73,7 +73,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg,
 
        daddr = dma_sg->dma_address;
        sglen = sg->length;
-       sgaddr = (unsigned long) (page_address(sg->page) + sg->offset);
+       sgaddr = (unsigned long) sg_virt(sg);
        while (dlen > 0) {
                unsigned long paddr;
 
@@ -123,7 +123,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg,
                sg = sg_next(sg);
                if (--nents <= 0)
                        break;
-               sgaddr = (unsigned long) (page_address(sg->page) + sg->offset);
+               sgaddr = (unsigned long) sg_virt(sg);
                sglen = sg->length;
        }
        if (dlen < 0) {
@@ -191,7 +191,7 @@ void verify_sglist(struct scatterlist *sglist, int nents, iopte_t *iopte, int np
                        printk("sg(%d): page_addr(%p) off(%x) length(%x) "
                               "dma_address[%016x] dma_length[%016x]\n",
                               i,
-                              page_address(sg->page), sg->offset,
+                              page_address(sg_page(sg)), sg->offset,
                               sg->length,
                               sg->dma_address, sg->dma_length);
                }
@@ -207,15 +207,14 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents)
        unsigned long prev;
        u32 dent_addr, dent_len;
 
-       prev  = (unsigned long) (page_address(sg->page) + sg->offset);
+       prev  = (unsigned long) sg_virt(sg);
        prev += (unsigned long) (dent_len = sg->length);
-       dent_addr = (u32) ((unsigned long)(page_address(sg->page) + sg->offset)
-                          & (IO_PAGE_SIZE - 1UL));
+       dent_addr = (u32) ((unsigned long)(sg_virt(sg)) & (IO_PAGE_SIZE - 1UL));
        while (--nents) {
                unsigned long addr;
 
                sg = sg_next(sg);
-               addr = (unsigned long) (page_address(sg->page) + sg->offset);
+               addr = (unsigned long) sg_virt(sg);
                if (! VCONTIG(prev, addr)) {
                        dma_sg->dma_address = dent_addr;
                        dma_sg->dma_length = dent_len;
index 85a2be0b0962201cc9f3237287c6dcb8c9400d85..c8313cb60f0a14562f3fd2714c0bfac1c5010bec 100644 (file)
@@ -2057,7 +2057,7 @@ static void fill_cookies(struct cookie_state *sp, unsigned long pa,
 
 static int sg_count_one(struct scatterlist *sg)
 {
-       unsigned long base = page_to_pfn(sg->page) << PAGE_SHIFT;
+       unsigned long base = page_to_pfn(sg_page(sg)) << PAGE_SHIFT;
        long len = sg->length;
 
        if ((sg->offset | len) & (8UL - 1))
index fe46ace3e59f6582a185b72641363f03d2966d3a..8c4875bdb4a89d54841787141922eff02566c625 100644 (file)
@@ -365,8 +365,7 @@ static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr,
        spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
-#define SG_ENT_PHYS_ADDRESS(SG)        \
-       (__pa(page_address((SG)->page)) + (SG)->offset)
+#define SG_ENT_PHYS_ADDRESS(SG)        (__pa(sg_virt((SG))))
 
 static long fill_sg(long entry, struct device *dev,
                    struct scatterlist *sg,
@@ -477,9 +476,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
        /* Fast path single entry scatterlists. */
        if (nelems == 1) {
                sglist->dma_address =
-                       dma_4v_map_single(dev,
-                                         (page_address(sglist->page) +
-                                          sglist->offset),
+                       dma_4v_map_single(dev, sg_virt(sglist),
                                          sglist->length, direction);
                if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
                        return 0;
index 5098f58063a57d537814d5031b89465faf00931f..1a20fe31338b18ea302d5ac035fd521d458bd6e7 100644 (file)
@@ -411,8 +411,10 @@ static int calgary_nontranslate_map_sg(struct device* dev,
        int i;
 
        for_each_sg(sg, s, nelems, i) {
-               BUG_ON(!s->page);
-               s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
+               struct page *p = sg_page(s);
+
+               BUG_ON(!p);
+               s->dma_address = virt_to_bus(sg_virt(s));
                s->dma_length = s->length;
        }
        return nelems;
@@ -432,9 +434,9 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
                return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
 
        for_each_sg(sg, s, nelems, i) {
-               BUG_ON(!s->page);
+               BUG_ON(!sg_page(s));
 
-               vaddr = (unsigned long)page_address(s->page) + s->offset;
+               vaddr = (unsigned long) sg_virt(s);
                npages = num_dma_pages(vaddr, s->length);
 
                entry = iommu_range_alloc(tbl, npages);
index 5cdfab65e93f8d1c7ac67d75cfffe3dc7fd461f9..c56e9ee64964df91f8c27fbc681472716c109572 100644 (file)
@@ -302,7 +302,7 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
 #endif
 
        for_each_sg(sg, s, nents, i) {
-               unsigned long addr = page_to_phys(s->page) + s->offset; 
+               unsigned long addr = sg_phys(s);
                if (nonforced_iommu(dev, addr, s->length)) { 
                        addr = dma_map_area(dev, addr, s->length, dir);
                        if (addr == bad_dma_address) { 
@@ -397,7 +397,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents,
        start_sg = sgmap = sg;
        ps = NULL; /* shut up gcc */
        for_each_sg(sg, s, nents, i) {
-               dma_addr_t addr = page_to_phys(s->page) + s->offset;
+               dma_addr_t addr = sg_phys(s);
                s->dma_address = addr;
                BUG_ON(s->length == 0); 
 
index e85d4360360c68fe6db2166194e8a748f709f1f2..faf70bdca335c5c21dfb6e03941923234bc4deb1 100644 (file)
@@ -62,8 +62,8 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
        int i;
 
        for_each_sg(sg, s, nents, i) {
-               BUG_ON(!s->page);
-               s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
+               BUG_ON(!sg_page(s));
+               s->dma_address = virt_to_bus(sg_virt(s));
                if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
                        return 0;
                s->dma_length = s->length;