Skip to content

Commit 58b053e

Browse files
author
Jens Axboe
committed
Update arch/ to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent f9527f1 commit 58b053e

File tree

23 files changed

+55
-67
lines changed

23 files changed

+55
-67
lines changed

arch/alpha/kernel/pci_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ EXPORT_SYMBOL(pci_free_consistent);
465465
Write dma_length of each leader with the combined lengths of
466466
the mergable followers. */
467467

468-
#define SG_ENT_VIRT_ADDRESS(SG) (page_address((SG)->page) + (SG)->offset)
468+
#define SG_ENT_VIRT_ADDRESS(SG) (sg_virt((SG)))
469469
#define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG))
470470

471471
static void

arch/arm/common/dmabounce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
442442
BUG_ON(dir == DMA_NONE);
443443

444444
for (i = 0; i < nents; i++, sg++) {
445-
struct page *page = sg->page;
445+
struct page *page = sg_page(sg);
446446
unsigned int offset = sg->offset;
447447
unsigned int length = sg->length;
448448
void *ptr = page_address(page) + offset;

arch/blackfin/kernel/dma-mapping.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
160160
BUG_ON(direction == DMA_NONE);
161161

162162
for (i = 0; i < nents; i++, sg++) {
163-
sg->dma_address = (dma_addr_t)(page_address(sg->page) +
164-
sg->offset);
163+
sg->dma_address = (dma_addr_t) sg_virt(sg);
165164

166165
invalidate_dcache_range(sg_dma_address(sg),
167166
sg_dma_address(sg) +

arch/ia64/hp/common/sba_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int reserve_sba_gart = 1;
246246
static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
247247
static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t);
248248

249-
#define sba_sg_address(sg) (page_address((sg)->page) + (sg)->offset)
249+
#define sba_sg_address(sg) sg_virt((sg))
250250

251251
#ifdef FULL_VALID_PDIR
252252
static u64 prefetch_spill_page;

arch/ia64/hp/sim/simscsi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
131131
stat.fd = desc[sc->device->id];
132132

133133
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));
135135
req.len = sl->length;
136136
if (DBG)
137137
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)
212212
if (!len)
213213
break;
214214
thislen = min(len, slp->length);
215-
memcpy(page_address(slp->page) + slp->offset, buf, thislen);
215+
memcpy(sg_virt(slp), buf, thislen);
216216
len -= thislen;
217217
}
218218
}

arch/ia64/sn/pci/pci_dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <asm/sn/pcidev.h>
1717
#include <asm/sn/sn_sal.h>
1818

19-
#define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset)
19+
#define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg)))
2020
#define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG))
2121

2222
/**

arch/m68k/kernel/dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
121121
int i;
122122

123123
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);
125125
dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir);
126126
}
127127
return nents;

arch/mips/mm/dma-default.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
165165
for (i = 0; i < nents; i++, sg++) {
166166
unsigned long addr;
167167

168-
addr = (unsigned long) page_address(sg->page);
168+
addr = (unsigned long) sg_virt(sg);
169169
if (!plat_device_is_coherent(dev) && addr)
170-
__dma_sync(addr + sg->offset, sg->length, direction);
170+
__dma_sync(addr, sg->length, direction);
171171
sg->dma_address = plat_map_dma_mem(dev,
172-
(void *)(addr + sg->offset),
173-
sg->length);
172+
(void *)addr, sg->length);
174173
}
175174

176175
return nents;
@@ -223,10 +222,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
223222
for (i = 0; i < nhwentries; i++, sg++) {
224223
if (!plat_device_is_coherent(dev) &&
225224
direction != DMA_TO_DEVICE) {
226-
addr = (unsigned long) page_address(sg->page);
225+
addr = (unsigned long) sg_virt(sg);
227226
if (addr)
228-
__dma_sync(addr + sg->offset, sg->length,
229-
direction);
227+
__dma_sync(addr, sg->length, direction);
230228
}
231229
plat_unmap_dma_mem(sg->dma_address);
232230
}
@@ -304,7 +302,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
304302
/* Make sure that gcc doesn't leave the empty loop body. */
305303
for (i = 0; i < nelems; i++, sg++) {
306304
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)),
308306
sg->length, direction);
309307
plat_unmap_dma_mem(sg->dma_address);
310308
}
@@ -322,7 +320,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
322320
/* Make sure that gcc doesn't leave the empty loop body. */
323321
for (i = 0; i < nelems; i++, sg++) {
324322
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)),
326324
sg->length, direction);
327325
plat_unmap_dma_mem(sg->dma_address);
328326
}

arch/powerpc/kernel/dma_64.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
161161
int i;
162162

163163
for_each_sg(sgl, sg, nents, i) {
164-
sg->dma_address = (page_to_phys(sg->page) + sg->offset) |
165-
dma_direct_offset;
164+
sg->dma_address = sg_phys(sg) | dma_direct_offset;
166165
sg->dma_length = sg->length;
167166
}
168167

arch/powerpc/kernel/ibmebus.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ static int ibmebus_map_sg(struct device *dev,
102102
int i;
103103

104104
for_each_sg(sgl, sg, nents, i) {
105-
sg->dma_address = (dma_addr_t)page_address(sg->page)
106-
+ sg->offset;
105+
sg->dma_address = (dma_addr_t) sg_virt(sg);
107106
sg->dma_length = sg->length;
108107
}
109108

0 commit comments

Comments
 (0)