aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-25 18:44:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-25 18:44:54 -0400
commit7f1495745347bc2cb9cc4f50d0a889caeb71f1f1 (patch)
tree2402b7e52fec57cdbf16d52e5fb467044589ec31
parent2c7505570353af02e48c58ab4d109edd9bbbdd81 (diff)
parent85cdffcde0b6b831a06422413300d0f5c0e608c3 (diff)
Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
* 'sg' of git://git.kernel.dk/linux-2.6-block: fix sg_phys to use dma_addr_t ub: add sg_init_table for sense and read capacity commands x86: pci-gart fix blackfin: fix sg fallout xtensa: dma-mapping.h is using linux/scatterlist.h functions, so include it SG: audit of drivers that use blk_rq_map_sg() arch/um/drivers/ubd_kern.c: fix a building error SG: Change sg_set_page() to take length and offset argument AVR32: Fix sg_page breakage mmc: sg fallout m68k: sg fallout More SG build fixes sg: add missing sg_init_table calls to zfcp SG build fix
-rw-r--r--arch/blackfin/kernel/dma-mapping.c1
-rw-r--r--arch/m68k/kernel/dma.c2
-rw-r--r--arch/sparc64/kernel/iommu_common.c2
-rw-r--r--arch/sparc64/kernel/ldc.c2
-rw-r--r--arch/um/drivers/ubd_kern.c2
-rw-r--r--arch/x86/kernel/pci-gart_64.c3
-rw-r--r--block/ll_rw_blk.c4
-rw-r--r--crypto/hmac.c3
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/block/cryptoloop.c9
-rw-r--r--drivers/block/sunvdc.c1
-rw-r--r--drivers/block/ub.c11
-rw-r--r--drivers/block/virtio_blk.c10
-rw-r--r--drivers/cdrom/viocd.c3
-rw-r--r--drivers/ieee1394/dma.c4
-rw-r--r--drivers/infiniband/core/umem.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c9
-rw-r--r--drivers/md/dm-crypt.c8
-rw-r--r--drivers/media/common/saa7146_core.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-udma.c6
-rw-r--r--drivers/media/video/videobuf-dma-sg.c10
-rw-r--r--drivers/message/i2o/i2o_block.c1
-rw-r--r--drivers/mmc/host/au1xmmc.c2
-rw-r--r--drivers/mmc/host/mmci.c6
-rw-r--r--drivers/mmc/host/pxamci.c1
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mmc/host/wbsd.c2
-rw-r--r--drivers/net/mlx4/icm.c4
-rw-r--r--drivers/s390/scsi/zfcp_aux.c12
-rw-r--r--drivers/s390/scsi/zfcp_def.h3
-rw-r--r--drivers/s390/scsi/zfcp_erp.c7
-rw-r--r--drivers/scsi/atari_NCR5380.c5
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/iscsi_tcp.c4
-rw-r--r--drivers/scsi/osst.c6
-rw-r--r--drivers/scsi/sg.c13
-rw-r--r--drivers/scsi/st.c14
-rw-r--r--drivers/scsi/sun3x_esp.c4
-rw-r--r--fs/ecryptfs/crypto.c23
-rw-r--r--include/asm-avr32/dma-mapping.h2
-rw-r--r--include/asm-frv/scatterlist.h3
-rw-r--r--include/asm-xtensa/dma-mapping.h2
-rw-r--r--include/linux/scatterlist.h43
-rw-r--r--net/core/skbuff.c9
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c11
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c2
-rw-r--r--net/sctp/auth.c4
-rw-r--r--net/sctp/sm_make_chunk.c8
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c14
-rw-r--r--net/sunrpc/xdr.c4
-rw-r--r--net/xfrm/xfrm_algo.c9
51 files changed, 134 insertions, 189 deletions
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index a16cb03c5291..d6b61d56b656 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -35,6 +35,7 @@
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/scatterlist.h>
38#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
39#include <asm/bfin-global.h> 40#include <asm/bfin-global.h>
40 41
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c
index ef490e1ce600..6f8c080dd9f9 100644
--- a/arch/m68k/kernel/dma.c
+++ b/arch/m68k/kernel/dma.c
@@ -9,10 +9,10 @@
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/scatterlist.h>
12#include <linux/vmalloc.h> 13#include <linux/vmalloc.h>
13 14
14#include <asm/pgalloc.h> 15#include <asm/pgalloc.h>
15#include <asm/scatterlist.h>
16 16
17void *dma_alloc_coherent(struct device *dev, size_t size, 17void *dma_alloc_coherent(struct device *dev, size_t size,
18 dma_addr_t *handle, gfp_t flag) 18 dma_addr_t *handle, gfp_t flag)
diff --git a/arch/sparc64/kernel/iommu_common.c b/arch/sparc64/kernel/iommu_common.c
index b70324e0d83d..efd5dff85f60 100644
--- a/arch/sparc64/kernel/iommu_common.c
+++ b/arch/sparc64/kernel/iommu_common.c
@@ -234,7 +234,7 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents)
234 dma_sg->dma_length = dent_len; 234 dma_sg->dma_length = dent_len;
235 235
236 if (dma_sg != sg) { 236 if (dma_sg != sg) {
237 dma_sg = next_sg(dma_sg); 237 dma_sg = sg_next(dma_sg);
238 dma_sg->dma_length = 0; 238 dma_sg->dma_length = 0;
239 } 239 }
240 240
diff --git a/arch/sparc64/kernel/ldc.c b/arch/sparc64/kernel/ldc.c
index c8313cb60f0a..217478a94128 100644
--- a/arch/sparc64/kernel/ldc.c
+++ b/arch/sparc64/kernel/ldc.c
@@ -2121,7 +2121,7 @@ int ldc_map_sg(struct ldc_channel *lp,
2121 state.nc = 0; 2121 state.nc = 0;
2122 2122
2123 for (i = 0; i < num_sg; i++) 2123 for (i = 0; i < num_sg; i++)
2124 fill_cookies(&state, page_to_pfn(sg[i].page) << PAGE_SHIFT, 2124 fill_cookies(&state, page_to_pfn(sg_page(&sg[i])) << PAGE_SHIFT,
2125 sg[i].offset, sg[i].length); 2125 sg[i].offset, sg[i].length);
2126 2126
2127 return state.nc; 2127 return state.nc;
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 3a8cd3dfb51c..e184b44b1011 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -35,6 +35,7 @@
35#include "linux/genhd.h" 35#include "linux/genhd.h"
36#include "linux/spinlock.h" 36#include "linux/spinlock.h"
37#include "linux/platform_device.h" 37#include "linux/platform_device.h"
38#include "linux/scatterlist.h"
38#include "asm/segment.h" 39#include "asm/segment.h"
39#include "asm/uaccess.h" 40#include "asm/uaccess.h"
40#include "asm/irq.h" 41#include "asm/irq.h"
@@ -704,6 +705,7 @@ static int ubd_add(int n, char **error_out)
704 ubd_dev->size = ROUND_BLOCK(ubd_dev->size); 705 ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
705 706
706 INIT_LIST_HEAD(&ubd_dev->restart); 707 INIT_LIST_HEAD(&ubd_dev->restart);
708 sg_init_table(&ubd_dev->sg, MAX_SG);
707 709
708 err = -ENOMEM; 710 err = -ENOMEM;
709 ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock); 711 ubd_dev->queue = blk_init_queue(do_ubd_request, &ubd_dev->lock);
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index c56e9ee64964..ae7e0161ce46 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -338,7 +338,6 @@ static int __dma_map_cont(struct scatterlist *start, int nelems,
338 338
339 BUG_ON(s != start && s->offset); 339 BUG_ON(s != start && s->offset);
340 if (s == start) { 340 if (s == start) {
341 *sout = *s;
342 sout->dma_address = iommu_bus_base; 341 sout->dma_address = iommu_bus_base;
343 sout->dma_address += iommu_page*PAGE_SIZE + s->offset; 342 sout->dma_address += iommu_page*PAGE_SIZE + s->offset;
344 sout->dma_length = s->length; 343 sout->dma_length = s->length;
@@ -365,7 +364,7 @@ static inline int dma_map_cont(struct scatterlist *start, int nelems,
365{ 364{
366 if (!need) { 365 if (!need) {
367 BUG_ON(nelems != 1); 366 BUG_ON(nelems != 1);
368 *sout = *start; 367 sout->dma_address = start->dma_address;
369 sout->dma_length = start->length; 368 sout->dma_length = start->length;
370 return 0; 369 return 0;
371 } 370 }
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index de5ba479c224..b01dee3ae7f3 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1366,9 +1366,7 @@ new_segment:
1366 sg = sg_next(sg); 1366 sg = sg_next(sg);
1367 } 1367 }
1368 1368
1369 sg_set_page(sg, bvec->bv_page); 1369 sg_set_page(sg, bvec->bv_page, nbytes, bvec->bv_offset);
1370 sg->length = nbytes;
1371 sg->offset = bvec->bv_offset;
1372 nsegs++; 1370 nsegs++;
1373 } 1371 }
1374 bvprv = bvec; 1372 bvprv = bvec;
diff --git a/crypto/hmac.c b/crypto/hmac.c
index e4eb6ac53b5c..6691981bda11 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -160,8 +160,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,
160 160
161 sg_set_buf(sg1, ipad, bs); 161 sg_set_buf(sg1, ipad, bs);
162 162
163 sg_set_page(&sg[1], (void *) sg); 163 sg_set_page(&sg[1], (void *) sg, 0, 0);
164 sg1[1].length = 0;
165 sg_set_buf(sg2, opad, bs + ds); 164 sg_set_buf(sg2, opad, bs + ds);
166 165
167 err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); 166 err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9d10e2feb8b1..081e3dfb64d4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4689,8 +4689,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
4689 * data in this function or read data in ata_sg_clean. 4689 * data in this function or read data in ata_sg_clean.
4690 */ 4690 */
4691 offset = lsg->offset + lsg->length - qc->pad_len; 4691 offset = lsg->offset + lsg->length - qc->pad_len;
4692 sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); 4692 sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT),
4693 psg->offset = offset_in_page(offset); 4693 qc->pad_len, offset_in_page(offset));
4694 4694
4695 if (qc->tf.flags & ATA_TFLAG_WRITE) { 4695 if (qc->tf.flags & ATA_TFLAG_WRITE) {
4696 void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); 4696 void *addr = kmap_atomic(sg_page(psg), KM_IRQ0);
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 1b58b010797f..241167878edf 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
150 u32 iv[4] = { 0, }; 150 u32 iv[4] = { 0, };
151 iv[0] = cpu_to_le32(IV & 0xffffffff); 151 iv[0] = cpu_to_le32(IV & 0xffffffff);
152 152
153 sg_set_page(&sg_in, in_page); 153 sg_set_page(&sg_in, in_page, sz, in_offs);
154 sg_in.offset = in_offs; 154 sg_set_page(&sg_out, out_page, sz, out_offs);
155 sg_in.length = sz;
156
157 sg_set_page(&sg_out, out_page);
158 sg_out.offset = out_offs;
159 sg_out.length = sz;
160 155
161 desc.info = iv; 156 desc.info = iv;
162 err = encdecfunc(&desc, &sg_out, &sg_in, sz); 157 err = encdecfunc(&desc, &sg_out, &sg_in, sz);
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 7276f7d207c2..fac4c6cd04f7 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/scatterlist.h>
18 19
19#include <asm/vio.h> 20#include <asm/vio.h>
20#include <asm/ldc.h> 21#include <asm/ldc.h>
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 14143f2c484d..08e909dc7944 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1428,9 +1428,9 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1428 scmd->state = UB_CMDST_INIT; 1428 scmd->state = UB_CMDST_INIT;
1429 scmd->nsg = 1; 1429 scmd->nsg = 1;
1430 sg = &scmd->sgv[0]; 1430 sg = &scmd->sgv[0];
1431 sg_set_page(sg, virt_to_page(sc->top_sense)); 1431 sg_init_table(sg, UB_MAX_REQ_SG);
1432 sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); 1432 sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE,
1433 sg->length = UB_SENSE_SIZE; 1433 (unsigned long)sc->top_sense & (PAGE_SIZE-1));
1434 scmd->len = UB_SENSE_SIZE; 1434 scmd->len = UB_SENSE_SIZE;
1435 scmd->lun = cmd->lun; 1435 scmd->lun = cmd->lun;
1436 scmd->done = ub_top_sense_done; 1436 scmd->done = ub_top_sense_done;
@@ -1864,9 +1864,8 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
1864 cmd->state = UB_CMDST_INIT; 1864 cmd->state = UB_CMDST_INIT;
1865 cmd->nsg = 1; 1865 cmd->nsg = 1;
1866 sg = &cmd->sgv[0]; 1866 sg = &cmd->sgv[0];
1867 sg_set_page(sg, virt_to_page(p)); 1867 sg_init_table(sg, UB_MAX_REQ_SG);
1868 sg->offset = (unsigned long)p & (PAGE_SIZE-1); 1868 sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1));
1869 sg->length = 8;
1870 cmd->len = 8; 1869 cmd->len = 8;
1871 cmd->lun = lun; 1870 cmd->lun = lun;
1872 cmd->done = ub_probe_done; 1871 cmd->done = ub_probe_done;
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index a901eee64ba5..3cf7129d83e6 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -4,7 +4,9 @@
4#include <linux/hdreg.h> 4#include <linux/hdreg.h>
5#include <linux/virtio.h> 5#include <linux/virtio.h>
6#include <linux/virtio_blk.h> 6#include <linux/virtio_blk.h>
7#include <linux/virtio_blk.h> 7#include <linux/scatterlist.h>
8
9#define VIRTIO_MAX_SG (3+MAX_PHYS_SEGMENTS)
8 10
9static unsigned char virtblk_index = 'a'; 11static unsigned char virtblk_index = 'a';
10struct virtio_blk 12struct virtio_blk
@@ -23,7 +25,7 @@ struct virtio_blk
23 mempool_t *pool; 25 mempool_t *pool;
24 26
25 /* Scatterlist: can be too big for stack. */ 27 /* Scatterlist: can be too big for stack. */
26 struct scatterlist sg[3+MAX_PHYS_SEGMENTS]; 28 struct scatterlist sg[VIRTIO_MAX_SG];
27}; 29};
28 30
29struct virtblk_req 31struct virtblk_req
@@ -94,8 +96,8 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
94 if (blk_barrier_rq(vbr->req)) 96 if (blk_barrier_rq(vbr->req))
95 vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER; 97 vbr->out_hdr.type |= VIRTIO_BLK_T_BARRIER;
96 98
97 /* We have to zero this, otherwise blk_rq_map_sg gets upset. */ 99 /* This init could be done at vblk creation time */
98 memset(vblk->sg, 0, sizeof(vblk->sg)); 100 sg_init_table(vblk->sg, VIRTIO_MAX_SG);
99 sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr)); 101 sg_set_buf(&vblk->sg[0], &vbr->out_hdr, sizeof(vbr->out_hdr));
100 num = blk_rq_map_sg(q, vbr->req, vblk->sg+1); 102 num = blk_rq_map_sg(q, vbr->req, vblk->sg+1);
101 sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr)); 103 sg_set_buf(&vblk->sg[num+1], &vbr->in_hdr, sizeof(vbr->in_hdr));
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 880b5dce3a62..d8bb44b98a6a 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -41,9 +41,9 @@
41#include <linux/completion.h> 41#include <linux/completion.h>
42#include <linux/proc_fs.h> 42#include <linux/proc_fs.h>
43#include <linux/seq_file.h> 43#include <linux/seq_file.h>
44#include <linux/scatterlist.h>
44 45
45#include <asm/vio.h> 46#include <asm/vio.h>
46#include <asm/scatterlist.h>
47#include <asm/iseries/hv_types.h> 47#include <asm/iseries/hv_types.h>
48#include <asm/iseries/hv_lp_event.h> 48#include <asm/iseries/hv_lp_event.h>
49#include <asm/iseries/vio.h> 49#include <asm/iseries/vio.h>
@@ -258,6 +258,7 @@ static int send_request(struct request *req)
258 cmd = viomajorsubtype_cdio | viocdwrite; 258 cmd = viomajorsubtype_cdio | viocdwrite;
259 } 259 }
260 260
261 sg_init_table(&sg, 1);
261 if (blk_rq_map_sg(req->q, req, &sg) == 0) { 262 if (blk_rq_map_sg(req->q, req, &sg) == 0) {
262 printk(VIOCD_KERN_WARNING 263 printk(VIOCD_KERN_WARNING
263 "error setting up scatter/gather list\n"); 264 "error setting up scatter/gather list\n");
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 3051e312fdc8..f5f4983dfbf3 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes,
111 unsigned long va = 111 unsigned long va =
112 (unsigned long)dma->kvirt + (i << PAGE_SHIFT); 112 (unsigned long)dma->kvirt + (i << PAGE_SHIFT);
113 113
114 sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); 114 sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va),
115 dma->sglist[i].length = PAGE_SIZE; 115 PAGE_SIZE, 0);
116 } 116 }
117 117
118 /* map sglist to the IOMMU */ 118 /* map sglist to the IOMMU */
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 14159ff29408..4e3128ff73c1 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -171,9 +171,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
171 if (vma_list && 171 if (vma_list &&
172 !is_vm_hugetlb_page(vma_list[i + off])) 172 !is_vm_hugetlb_page(vma_list[i + off]))
173 umem->hugetlb = 0; 173 umem->hugetlb = 0;
174 sg_set_page(&chunk->page_list[i], page_list[i + off]); 174 sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0);
175 chunk->page_list[i].offset = 0;
176 chunk->page_list[i].length = PAGE_SIZE;
177 } 175 }
178 176
179 chunk->nmap = ib_dma_map_sg(context->device, 177 chunk->nmap = ib_dma_map_sg(context->device,
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 007b38157fc4..1f4d27d7c16d 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -113,9 +113,7 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m
113 if (!page) 113 if (!page)
114 return -ENOMEM; 114 return -ENOMEM;
115 115
116 sg_set_page(mem, page); 116 sg_set_page(mem, page, PAGE_SIZE << order, 0);
117 mem->length = PAGE_SIZE << order;
118 mem->offset = 0;
119 return 0; 117 return 0;
120} 118}
121 119
@@ -481,9 +479,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
481 if (ret < 0) 479 if (ret < 0)
482 goto out; 480 goto out;
483 481
484 sg_set_page(&db_tab->page[i].mem, pages[0]); 482 sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE,
485 db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; 483 uaddr & ~PAGE_MASK);
486 db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK;
487 484
488 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); 485 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
489 if (ret < 0) { 486 if (ret < 0) {
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ac54f697c508..1c159ac68c98 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -351,14 +351,10 @@ static int crypt_convert(struct crypt_config *cc,
351 struct scatterlist sg_in, sg_out; 351 struct scatterlist sg_in, sg_out;
352 352
353 sg_init_table(&sg_in, 1); 353 sg_init_table(&sg_in, 1);
354 sg_set_page(&sg_in, bv_in->bv_page); 354 sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in);
355 sg_in.offset = bv_in->bv_offset + ctx->offset_in;
356 sg_in.length = 1 << SECTOR_SHIFT;
357 355
358 sg_init_table(&sg_out, 1); 356 sg_init_table(&sg_out, 1);
359 sg_set_page(&sg_out, bv_out->bv_page); 357 sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out);
360 sg_out.offset = bv_out->bv_offset + ctx->offset_out;
361 sg_out.length = 1 << SECTOR_SHIFT;
362 358
363 ctx->offset_in += sg_in.length; 359 ctx->offset_in += sg_in.length;
364 if (ctx->offset_in >= bv_in->bv_len) { 360 if (ctx->offset_in >= bv_in->bv_len) {
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 2b1f8b4be00a..cb034ead95ab 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -118,8 +118,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
118 if (NULL == pg) 118 if (NULL == pg)
119 goto err; 119 goto err;
120 BUG_ON(PageHighMem(pg)); 120 BUG_ON(PageHighMem(pg));
121 sg_set_page(&sglist[i], pg); 121 sg_set_page(&sglist[i], pg, PAGE_SIZE, 0);
122 sglist[i].length = PAGE_SIZE;
123 } 122 }
124 return sglist; 123 return sglist;
125 124
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c
index 912b424e5204..460db03b0ba0 100644
--- a/drivers/media/video/ivtv/ivtv-udma.c
+++ b/drivers/media/video/ivtv/ivtv-udma.c
@@ -49,8 +49,6 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info
49 unsigned int len = (i == dma_page->page_count - 1) ? 49 unsigned int len = (i == dma_page->page_count - 1) ?
50 dma_page->tail : PAGE_SIZE - offset; 50 dma_page->tail : PAGE_SIZE - offset;
51 51
52 dma->SGlist[map_offset].length = len;
53 dma->SGlist[map_offset].offset = offset;
54 if (PageHighMem(dma->map[map_offset])) { 52 if (PageHighMem(dma->map[map_offset])) {
55 void *src; 53 void *src;
56 54
@@ -63,10 +61,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info
63 memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); 61 memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len);
64 kunmap_atomic(src, KM_BOUNCE_READ); 62 kunmap_atomic(src, KM_BOUNCE_READ);
65 local_irq_restore(flags); 63 local_irq_restore(flags);
66 sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); 64 sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset);
67 } 65 }
68 else { 66 else {
69 sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); 67 sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset);
70 } 68 }
71 offset = 0; 69 offset = 0;
72 map_offset++; 70 map_offset++;
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 9ab94a749d81..44ee408e145f 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -67,8 +67,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
67 if (NULL == pg) 67 if (NULL == pg)
68 goto err; 68 goto err;
69 BUG_ON(PageHighMem(pg)); 69 BUG_ON(PageHighMem(pg));
70 sg_set_page(&sglist[i], pg); 70 sg_set_page(&sglist[i], pg, PAGE_SIZE, 0);
71 sglist[i].length = PAGE_SIZE;
72 } 71 }
73 return sglist; 72 return sglist;
74 73
@@ -95,16 +94,13 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset)
95 if (PageHighMem(pages[0])) 94 if (PageHighMem(pages[0]))
96 /* DMA to highmem pages might not work */ 95 /* DMA to highmem pages might not work */
97 goto highmem; 96 goto highmem;
98 sg_set_page(&sglist[0], pages[0]); 97 sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset);
99 sglist[0].offset = offset;
100 sglist[0].length = PAGE_SIZE - offset;
101 for (i = 1; i < nr_pages; i++) { 98 for (i = 1; i < nr_pages; i++) {
102 if (NULL == pages[i]) 99 if (NULL == pages[i])
103 goto nopage; 100 goto nopage;
104 if (PageHighMem(pages[i])) 101 if (PageHighMem(pages[i]))
105 goto highmem; 102 goto highmem;
106 sg_set_page(&sglist[i], pages[i]); 103 sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0);
107 sglist[i].length = PAGE_SIZE;
108 } 104 }
109 return sglist; 105 return sglist;
110 106
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index d602ba6d5417..682406168de9 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -284,6 +284,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
284 return ERR_PTR(-ENOMEM); 284 return ERR_PTR(-ENOMEM);
285 285
286 INIT_LIST_HEAD(&ireq->queue); 286 INIT_LIST_HEAD(&ireq->queue);
287 sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
287 288
288 return ireq; 289 return ireq;
289}; 290};
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index bcbb6d247bf7..c77fadc0dfa3 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -40,13 +40,13 @@
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <scatterlist/scatterlist.h>
43 44
44#include <linux/mmc/host.h> 45#include <linux/mmc/host.h>
45#include <asm/io.h> 46#include <asm/io.h>
46#include <asm/mach-au1x00/au1000.h> 47#include <asm/mach-au1x00/au1000.h>
47#include <asm/mach-au1x00/au1xxx_dbdma.h> 48#include <asm/mach-au1x00/au1xxx_dbdma.h>
48#include <asm/mach-au1x00/au1100_mmc.h> 49#include <asm/mach-au1x00/au1100_mmc.h>
49#include <asm/scatterlist.h>
50 50
51#include <au1xxx.h> 51#include <au1xxx.h>
52#include "au1xmmc.h" 52#include "au1xmmc.h"
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index d0eb0a2abf4d..95244a7e7353 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -20,11 +20,11 @@
20#include <linux/mmc/host.h> 20#include <linux/mmc/host.h>
21#include <linux/amba/bus.h> 21#include <linux/amba/bus.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/scatterlist.h>
23 24
24#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
25#include <asm/div64.h> 26#include <asm/div64.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/scatterlist.h>
28#include <asm/sizes.h> 28#include <asm/sizes.h>
29#include <asm/mach/mmc.h> 29#include <asm/mach/mmc.h>
30 30
@@ -167,7 +167,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
167 * partially written to a page is properly coherent. 167 * partially written to a page is properly coherent.
168 */ 168 */
169 if (host->sg_len && data->flags & MMC_DATA_READ) 169 if (host->sg_len && data->flags & MMC_DATA_READ)
170 flush_dcache_page(host->sg_ptr->page); 170 flush_dcache_page(sg_page(host->sg_ptr));
171 } 171 }
172 if (status & MCI_DATAEND) { 172 if (status & MCI_DATAEND) {
173 mmci_stop_data(host); 173 mmci_stop_data(host);
@@ -319,7 +319,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
319 * page, ensure that the data cache is coherent. 319 * page, ensure that the data cache is coherent.
320 */ 320 */
321 if (status & MCI_RXACTIVE) 321 if (status & MCI_RXACTIVE)
322 flush_dcache_page(host->sg_ptr->page); 322 flush_dcache_page(sg_page(host->sg_ptr));
323 323
324 if (!mmci_next_sg(host)) 324 if (!mmci_next_sg(host))
325 break; 325 break;
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 0601e01aa2c2..a25ee71998a9 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -29,7 +29,6 @@
29 29
30#include <asm/dma.h> 30#include <asm/dma.h>
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/scatterlist.h>
33#include <asm/sizes.h> 32#include <asm/sizes.h>
34 33
35#include <asm/arch/pxa-regs.h> 34#include <asm/arch/pxa-regs.h>
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d7c5b94d8c58..6b80bf77a4ef 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -17,8 +17,6 @@
17 17
18#include <linux/mmc/host.h> 18#include <linux/mmc/host.h>
19 19
20#include <asm/scatterlist.h>
21
22#include "sdhci.h" 20#include "sdhci.h"
23 21
24#define DRIVER_NAME "sdhci" 22#define DRIVER_NAME "sdhci"
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index fa4c8c53cc7a..4d5f37421874 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -33,10 +33,10 @@
33#include <linux/pnp.h> 33#include <linux/pnp.h>
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
36#include <linux/scatterlist.h>
36 37
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/dma.h> 39#include <asm/dma.h>
39#include <asm/scatterlist.h>
40 40
41#include "wbsd.h" 41#include "wbsd.h"
42 42
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c
index 887633b207d9..2a5bef6388fe 100644
--- a/drivers/net/mlx4/icm.c
+++ b/drivers/net/mlx4/icm.c
@@ -101,9 +101,7 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma
101 if (!page) 101 if (!page)
102 return -ENOMEM; 102 return -ENOMEM;
103 103
104 sg_set_page(mem, page); 104 sg_set_page(mem, page, PAGE_SIZE << order, 0);
105 mem->length = PAGE_SIZE << order;
106 mem->offset = 0;
107 return 0; 105 return 0;
108} 106}
109 107
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index fd5d0c1570df..00118499018b 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -562,8 +562,6 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
562 sg_init_table(sg_list->sg, sg_list->count); 562 sg_init_table(sg_list->sg, sg_list->count);
563 563
564 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { 564 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
565 sg->length = min(size, PAGE_SIZE);
566 sg->offset = 0;
567 address = (void *) get_zeroed_page(GFP_KERNEL); 565 address = (void *) get_zeroed_page(GFP_KERNEL);
568 if (address == NULL) { 566 if (address == NULL) {
569 sg_list->count = i; 567 sg_list->count = i;
@@ -571,7 +569,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
571 retval = -ENOMEM; 569 retval = -ENOMEM;
572 goto out; 570 goto out;
573 } 571 }
574 zfcp_address_to_sg(address, sg); 572 zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE));
575 size -= sg->length; 573 size -= sg->length;
576 } 574 }
577 575
@@ -1518,13 +1516,13 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool)
1518 return -ENOMEM; 1516 return -ENOMEM;
1519 1517
1520 memset(data, 0, sizeof(*data)); 1518 memset(data, 0, sizeof(*data));
1519 sg_init_table(&data->req , 1);
1520 sg_init_table(&data->resp , 1);
1521 data->ct.req = &data->req; 1521 data->ct.req = &data->req;
1522 data->ct.resp = &data->resp; 1522 data->ct.resp = &data->resp;
1523 data->ct.req_count = data->ct.resp_count = 1; 1523 data->ct.req_count = data->ct.resp_count = 1;
1524 zfcp_address_to_sg(&data->ct_iu_req, &data->req); 1524 zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req));
1525 zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); 1525 zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp));
1526 data->req.length = sizeof(struct ct_iu_gid_pn_req);
1527 data->resp.length = sizeof(struct ct_iu_gid_pn_resp);
1528 1526
1529 *gid_pn = data; 1527 *gid_pn = data;
1530 return 0; 1528 return 0;
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 326e7ee232cb..0754542978b6 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -74,8 +74,7 @@ zfcp_sg_to_address(struct scatterlist *list)
74static inline void 74static inline void
75zfcp_address_to_sg(void *address, struct scatterlist *list) 75zfcp_address_to_sg(void *address, struct scatterlist *list)
76{ 76{
77 sg_set_page(list, virt_to_page(address)); 77 sg_set_buf(list, address, 0);
78 list->offset = ((unsigned long) address) & (PAGE_SIZE - 1);
79} 78}
80 79
81#define REQUEST_LIST_SIZE 128 80#define REQUEST_LIST_SIZE 128
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 9438d0b28799..5552b755c08a 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port)
322 if (address == NULL) 322 if (address == NULL)
323 goto nomem; 323 goto nomem;
324 324
325 zfcp_address_to_sg(address, send_els->req); 325 zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc));
326 address += PAGE_SIZE >> 1; 326 address += PAGE_SIZE >> 1;
327 zfcp_address_to_sg(address, send_els->resp); 327 zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc));
328 send_els->req_count = send_els->resp_count = 1; 328 send_els->req_count = send_els->resp_count = 1;
329 329
330 send_els->adapter = adapter; 330 send_els->adapter = adapter;
@@ -336,9 +336,6 @@ zfcp_erp_adisc(struct zfcp_port *port)
336 adisc = zfcp_sg_to_address(send_els->req); 336 adisc = zfcp_sg_to_address(send_els->req);
337 send_els->ls_code = adisc->code = ZFCP_LS_ADISC; 337 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
338 338
339 send_els->req->length = sizeof(struct zfcp_ls_adisc);
340 send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
341
342 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports 339 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
343 without FC-AL-2 capability, so we don't set it */ 340 without FC-AL-2 capability, so we don't set it */
344 adisc->wwpn = fc_host_port_name(adapter->scsi_host); 341 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index d1780980fb20..a9680b5e8ac6 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -477,10 +477,9 @@ static void merge_contiguous_buffers(Scsi_Cmnd *cmd)
477 477
478 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; 478 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1;
479 cmd->SCp.buffers_residual && 479 cmd->SCp.buffers_residual &&
480 virt_to_phys(page_address(cmd->SCp.buffer[1].page) + 480 virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) {
481 cmd->SCp.buffer[1].offset) == endaddr;) {
482 MER_PRINTK("VTOP(%p) == %08lx -> merging\n", 481 MER_PRINTK("VTOP(%p) == %08lx -> merging\n",
483 page_address(cmd->SCp.buffer[1].page), endaddr); 482 page_address(sg_page(&cmd->SCp.buffer[1])), endaddr);
484#if (NDEBUG & NDEBUG_MERGING) 483#if (NDEBUG & NDEBUG_MERGING)
485 ++cnt; 484 ++cnt;
486#endif 485#endif
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 439b97a6a269..0841df01bc19 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2890 return NULL; 2890 return NULL;
2891 } 2891 }
2892 2892
2893 sg_set_page(&scatterlist[i], page); 2893 sg_set_page(&scatterlist[i], page, 0, 0);
2894 } 2894 }
2895 2895
2896 return sglist; 2896 return sglist;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 6ce4109efdf3..097a136398cb 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -79,9 +79,7 @@ static inline void
79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) 79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)
80{ 80{
81 sg_init_table(&ibuf->sg, 1); 81 sg_init_table(&ibuf->sg, 1);
82 sg_set_page(&ibuf->sg, sg_page(sg)); 82 sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset);
83 ibuf->sg.offset = sg->offset;
84 ibuf->sg.length = sg->length;
85 /* 83 /*
86 * Fastpath: sg element fits into single page 84 * Fastpath: sg element fits into single page
87 */ 85 */
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 1c5c4b68f20f..4652ad22516b 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5256,8 +5256,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5256 5256
5257 STbuffer->sg[0].offset = 0; 5257 STbuffer->sg[0].offset = 0;
5258 if (page != NULL) { 5258 if (page != NULL) {
5259 sg_set_page(&STbuffer->sg[0], page); 5259 sg_set_page(&STbuffer->sg[0], page, b_size, 0);
5260 STbuffer->sg[0].length = b_size;
5261 STbuffer->b_data = page_address(page); 5260 STbuffer->b_data = page_address(page);
5262 break; 5261 break;
5263 } 5262 }
@@ -5285,8 +5284,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5285 normalize_buffer(STbuffer); 5284 normalize_buffer(STbuffer);
5286 return 0; 5285 return 0;
5287 } 5286 }
5288 sg_set_page(&STbuffer->sg[segs], page); 5287 sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0);
5289 STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size;
5290 got += STbuffer->sg[segs].length; 5288 got += STbuffer->sg[segs].length;
5291 STbuffer->buffer_size = got; 5289 STbuffer->buffer_size = got;
5292 STbuffer->sg_segs = ++segs; 5290 STbuffer->sg_segs = ++segs;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cc1971002846..b5fa4f091387 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1717,16 +1717,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1717 goto out_unlock; */ 1717 goto out_unlock; */
1718 } 1718 }
1719 1719
1720 sg_set_page(sgl, pages[0]); 1720 sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK);
1721 sgl[0].offset = uaddr & ~PAGE_MASK;
1722 if (nr_pages > 1) { 1721 if (nr_pages > 1) {
1723 sgl[0].length = PAGE_SIZE - sgl[0].offset; 1722 sgl[0].length = PAGE_SIZE - sgl[0].offset;
1724 count -= sgl[0].length; 1723 count -= sgl[0].length;
1725 for (i=1; i < nr_pages ; i++) { 1724 for (i=1; i < nr_pages ; i++)
1726 sg_set_page(&sgl[i], pages[i]); 1725 sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0);
1727 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
1728 count -= PAGE_SIZE;
1729 }
1730 } 1726 }
1731 else { 1727 else {
1732 sgl[0].length = count; 1728 sgl[0].length = count;
@@ -1854,8 +1850,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1854 scatter_elem_sz_prev = ret_sz; 1850 scatter_elem_sz_prev = ret_sz;
1855 } 1851 }
1856 } 1852 }
1857 sg_set_page(sg, p); 1853 sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0);
1858 sg->length = (ret_sz > num) ? num : ret_sz;
1859 1854
1860 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " 1855 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
1861 "ret_sz=%d\n", k, num, ret_sz)); 1856 "ret_sz=%d\n", k, num, ret_sz));
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index ce69b9efc102..98dfd6ea209c 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3797,13 +3797,11 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
3797 sg = &(STbp->sg[0]); 3797 sg = &(STbp->sg[0]);
3798 frp = STbp->frp; 3798 frp = STbp->frp;
3799 for (i=count=0; count < length; i++) { 3799 for (i=count=0; count < length; i++) {
3800 sg_set_page(&sg[i], frp[i].page);
3801 if (length - count > frp[i].length) 3800 if (length - count > frp[i].length)
3802 sg[i].length = frp[i].length; 3801 sg_set_page(&sg[i], frp[i].page, frp[i].length, 0);
3803 else 3802 else
3804 sg[i].length = length - count; 3803 sg_set_page(&sg[i], frp[i].page, length - count, 0);
3805 count += sg[i].length; 3804 count += sg[i].length;
3806 sg[i].offset = 0;
3807 } 3805 }
3808 STbp->sg_segs = i; 3806 STbp->sg_segs = i;
3809 STbp->frp_sg_current = length; 3807 STbp->frp_sg_current = length;
@@ -4446,15 +4444,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4446 } 4444 }
4447 4445
4448 /* Populate the scatter/gather list */ 4446 /* Populate the scatter/gather list */
4449 sg_set_page(&sgl[0], pages[0]); 4447 sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK);
4450 sgl[0].offset = uaddr & ~PAGE_MASK;
4451 if (nr_pages > 1) { 4448 if (nr_pages > 1) {
4452 sgl[0].length = PAGE_SIZE - sgl[0].offset; 4449 sgl[0].length = PAGE_SIZE - sgl[0].offset;
4453 count -= sgl[0].length; 4450 count -= sgl[0].length;
4454 for (i=1; i < nr_pages ; i++) { 4451 for (i=1; i < nr_pages ; i++) {
4455 sg_set_page(&sgl[i], pages[i]);; 4452 sg_set_page(&sgl[i], pages[i],
4456 sgl[i].offset = 0; 4453 count < PAGE_SIZE ? count : PAGE_SIZE, 0);;
4457 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
4458 count -= PAGE_SIZE; 4454 count -= PAGE_SIZE;
4459 } 4455 }
4460 } 4456 }
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index 80fb3f88af2e..1bc41907a038 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -332,8 +332,8 @@ static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
332 struct scatterlist *sg = sp->SCp.buffer; 332 struct scatterlist *sg = sp->SCp.buffer;
333 333
334 while (sz >= 0) { 334 while (sz >= 0) {
335 sg[sz].dma_address = dvma_map((unsigned long)page_address(sg[sz].page) + 335 sg[sz].dma_address = dvma_map((unsigned long)sg_virt(&sg[sz]),
336 sg[sz].offset, sg[sz].length); 336 sg[sz].length);
337 sz--; 337 sz--;
338 } 338 }
339 sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address); 339 sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dma_address);
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 0a9882edf562..7a472b129997 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -282,10 +282,8 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
282 while (size > 0 && i < sg_size) { 282 while (size > 0 && i < sg_size) {
283 pg = virt_to_page(addr); 283 pg = virt_to_page(addr);
284 offset = offset_in_page(addr); 284 offset = offset_in_page(addr);
285 if (sg) { 285 if (sg)
286 sg_set_page(&sg[i], pg); 286 sg_set_page(&sg[i], pg, 0, offset);
287 sg[i].offset = offset;
288 }
289 remainder_of_page = PAGE_CACHE_SIZE - offset; 287 remainder_of_page = PAGE_CACHE_SIZE - offset;
290 if (size >= remainder_of_page) { 288 if (size >= remainder_of_page) {
291 if (sg) 289 if (sg)
@@ -716,12 +714,8 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
716 sg_init_table(&src_sg, 1); 714 sg_init_table(&src_sg, 1);
717 sg_init_table(&dst_sg, 1); 715 sg_init_table(&dst_sg, 1);
718 716
719 sg_set_page(&src_sg, src_page); 717 sg_set_page(&src_sg, src_page, size, src_offset);
720 src_sg.offset = src_offset; 718 sg_set_page(&dst_sg, dst_page, size, dst_offset);
721 src_sg.length = size;
722 sg_set_page(&dst_sg, dst_page);
723 dst_sg.offset = dst_offset;
724 dst_sg.length = size;
725 return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); 719 return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
726} 720}
727 721
@@ -746,14 +740,11 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
746 struct scatterlist src_sg, dst_sg; 740 struct scatterlist src_sg, dst_sg;
747 741
748 sg_init_table(&src_sg, 1); 742 sg_init_table(&src_sg, 1);
743 sg_set_page(&src_sg, src_page, size, src_offset);
744
749 sg_init_table(&dst_sg, 1); 745 sg_init_table(&dst_sg, 1);
746 sg_set_page(&dst_sg, dst_page, size, dst_offset);
750 747
751 sg_set_page(&src_sg, src_page);
752 src_sg.offset = src_offset;
753 src_sg.length = size;
754 sg_set_page(&dst_sg, dst_page);
755 dst_sg.offset = dst_offset;
756 dst_sg.length = size;
757 return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); 748 return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
758} 749}
759 750
diff --git a/include/asm-avr32/dma-mapping.h b/include/asm-avr32/dma-mapping.h
index a7131630c057..57dc672bab8e 100644
--- a/include/asm-avr32/dma-mapping.h
+++ b/include/asm-avr32/dma-mapping.h
@@ -3,7 +3,7 @@
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/device.h> 5#include <linux/device.h>
6#include <asm/scatterlist.h> 6#include <linux/scatterlist.h>
7#include <asm/processor.h> 7#include <asm/processor.h>
8#include <asm/cacheflush.h> 8#include <asm/cacheflush.h>
9#include <asm/io.h> 9#include <asm/io.h>
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
index 99ba76edc42a..2e7143b5a7ad 100644
--- a/include/asm-frv/scatterlist.h
+++ b/include/asm-frv/scatterlist.h
@@ -16,8 +16,7 @@
16 * 16 *
17 * can be rewritten as 17 * can be rewritten as
18 * 18 *
19 * sg_set_page(virt_to_page(some_ptr)); 19 * sg_set_buf(sg, some_ptr, length);
20 * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK;
21 * 20 *
22 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens 21 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
23 */ 22 */
diff --git a/include/asm-xtensa/dma-mapping.h b/include/asm-xtensa/dma-mapping.h
index 8bd9d2c02a24..3c7d537dd15d 100644
--- a/include/asm-xtensa/dma-mapping.h
+++ b/include/asm-xtensa/dma-mapping.h
@@ -11,10 +11,10 @@
11#ifndef _XTENSA_DMA_MAPPING_H 11#ifndef _XTENSA_DMA_MAPPING_H
12#define _XTENSA_DMA_MAPPING_H 12#define _XTENSA_DMA_MAPPING_H
13 13
14#include <asm/scatterlist.h>
15#include <asm/cache.h> 14#include <asm/cache.h>
16#include <asm/io.h> 15#include <asm/io.h>
17#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/scatterlist.h>
18 18
19/* 19/*
20 * DMA-consistent mapping functions. 20 * DMA-consistent mapping functions.
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index df7ddcee7c4b..457123171389 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -1,6 +1,7 @@
1#ifndef _LINUX_SCATTERLIST_H 1#ifndef _LINUX_SCATTERLIST_H
2#define _LINUX_SCATTERLIST_H 2#define _LINUX_SCATTERLIST_H
3 3
4#include <asm/types.h>
4#include <asm/scatterlist.h> 5#include <asm/scatterlist.h>
5#include <linux/mm.h> 6#include <linux/mm.h>
6#include <linux/string.h> 7#include <linux/string.h>
@@ -26,18 +27,16 @@
26#define SG_MAGIC 0x87654321 27#define SG_MAGIC 0x87654321
27 28
28/** 29/**
29 * sg_set_page - Set sg entry to point at given page 30 * sg_assign_page - Assign a given page to an SG entry
30 * @sg: SG entry 31 * @sg: SG entry
31 * @page: The page 32 * @page: The page
32 * 33 *
33 * Description: 34 * Description:
34 * Use this function to set an sg entry pointing at a page, never assign 35 * Assign page to sg entry. Also see sg_set_page(), the most commonly used
35 * the page directly. We encode sg table information in the lower bits 36 * variant.
36 * of the page pointer. See sg_page() for looking up the page belonging
37 * to an sg entry.
38 * 37 *
39 **/ 38 **/
40static inline void sg_set_page(struct scatterlist *sg, struct page *page) 39static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
41{ 40{
42 unsigned long page_link = sg->page_link & 0x3; 41 unsigned long page_link = sg->page_link & 0x3;
43 42
@@ -52,6 +51,28 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
52 sg->page_link = page_link | (unsigned long) page; 51 sg->page_link = page_link | (unsigned long) page;
53} 52}
54 53
54/**
55 * sg_set_page - Set sg entry to point at given page
56 * @sg: SG entry
57 * @page: The page
58 * @len: Length of data
59 * @offset: Offset into page
60 *
61 * Description:
62 * Use this function to set an sg entry pointing at a page, never assign
63 * the page directly. We encode sg table information in the lower bits
64 * of the page pointer. See sg_page() for looking up the page belonging
65 * to an sg entry.
66 *
67 **/
68static inline void sg_set_page(struct scatterlist *sg, struct page *page,
69 unsigned int len, unsigned int offset)
70{
71 sg_assign_page(sg, page);
72 sg->offset = offset;
73 sg->length = len;
74}
75
55#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) 76#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3))
56 77
57/** 78/**
@@ -64,9 +85,7 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
64static inline void sg_set_buf(struct scatterlist *sg, const void *buf, 85static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
65 unsigned int buflen) 86 unsigned int buflen)
66{ 87{
67 sg_set_page(sg, virt_to_page(buf)); 88 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
68 sg->offset = offset_in_page(buf);
69 sg->length = buflen;
70} 89}
71 90
72/* 91/*
@@ -237,7 +256,7 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
237 * on the sg page. 256 * on the sg page.
238 * 257 *
239 **/ 258 **/
240static inline unsigned long sg_phys(struct scatterlist *sg) 259static inline dma_addr_t sg_phys(struct scatterlist *sg)
241{ 260{
242 return page_to_phys(sg_page(sg)) + sg->offset; 261 return page_to_phys(sg_page(sg)) + sg->offset;
243} 262}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4e2c84fcf276..7b7c6c44c2da 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2045,9 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2045 if (copy > 0) { 2045 if (copy > 0) {
2046 if (copy > len) 2046 if (copy > len)
2047 copy = len; 2047 copy = len;
2048 sg_set_page(&sg[elt], virt_to_page(skb->data + offset)); 2048 sg_set_buf(sg, skb->data + offset, copy);
2049 sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
2050 sg[elt].length = copy;
2051 elt++; 2049 elt++;
2052 if ((len -= copy) == 0) 2050 if ((len -= copy) == 0)
2053 return elt; 2051 return elt;
@@ -2065,9 +2063,8 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2065 2063
2066 if (copy > len) 2064 if (copy > len)
2067 copy = len; 2065 copy = len;
2068 sg_set_page(&sg[elt], frag->page); 2066 sg_set_page(&sg[elt], frag->page, copy,
2069 sg[elt].offset = frag->page_offset+offset-start; 2067 frag->page_offset+offset-start);
2070 sg[elt].length = copy;
2071 elt++; 2068 elt++;
2072 if (!(len -= copy)) 2069 if (!(len -= copy))
2073 return elt; 2070 return elt;
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 811777682e2b..4cce3534e408 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -25,7 +25,7 @@
25#include <net/ieee80211.h> 25#include <net/ieee80211.h>
26 26
27#include <linux/crypto.h> 27#include <linux/crypto.h>
28#include <asm/scatterlist.h> 28#include <linux/scatterlist.h>
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30 30
31MODULE_AUTHOR("Jouni Malinen"); 31MODULE_AUTHOR("Jouni Malinen");
@@ -537,13 +537,8 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
537 return -1; 537 return -1;
538 } 538 }
539 sg_init_table(sg, 2); 539 sg_init_table(sg, 2);
540 sg_set_page(&sg[0], virt_to_page(hdr)); 540 sg_set_buf(&sg[0], hdr, 16);
541 sg[0].offset = offset_in_page(hdr); 541 sg_set_buf(&sg[1], data, data_len);
542 sg[0].length = 16;
543
544 sg_set_page(&sg[1], virt_to_page(data));
545 sg[1].offset = offset_in_page(data);
546 sg[1].length = data_len;
547 542
548 if (crypto_hash_setkey(tfm_michael, key, 8)) 543 if (crypto_hash_setkey(tfm_michael, key, 8))
549 return -1; 544 return -1;
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index 9693429489ed..866fc04c44f9 100644
--- a/net/ieee80211/ieee80211_crypt_wep.c
+++ b/net/ieee80211/ieee80211_crypt_wep.c
@@ -22,7 +22,7 @@
22#include <net/ieee80211.h> 22#include <net/ieee80211.h>
23 23
24#include <linux/crypto.h> 24#include <linux/crypto.h>
25#include <asm/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <linux/crc32.h> 26#include <linux/crc32.h>
27 27
28MODULE_AUTHOR("Jouni Malinen"); 28MODULE_AUTHOR("Jouni Malinen");
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index cbd64b216cce..621113a109b2 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -727,9 +727,7 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
727 /* set up scatter list */ 727 /* set up scatter list */
728 end = skb_tail_pointer(skb); 728 end = skb_tail_pointer(skb);
729 sg_init_table(&sg, 1); 729 sg_init_table(&sg, 1);
730 sg_set_page(&sg, virt_to_page(auth)); 730 sg_set_buf(&sg, auth, end - (unsigned char *)auth);
731 sg.offset = (unsigned long)(auth) % PAGE_SIZE;
732 sg.length = end - (unsigned char *)auth;
733 731
734 desc.tfm = asoc->ep->auth_hmacs[hmac_id]; 732 desc.tfm = asoc->ep->auth_hmacs[hmac_id];
735 desc.flags = 0; 733 desc.flags = 0;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 658476c4d587..c055212875f6 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1514,9 +1514,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
1514 1514
1515 /* Sign the message. */ 1515 /* Sign the message. */
1516 sg_init_table(&sg, 1); 1516 sg_init_table(&sg, 1);
1517 sg_set_page(&sg, virt_to_page(&cookie->c)); 1517 sg_set_buf(&sg, &cookie->c, bodysize);
1518 sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
1519 sg.length = bodysize;
1520 keylen = SCTP_SECRET_SIZE; 1518 keylen = SCTP_SECRET_SIZE;
1521 key = (char *)ep->secret_key[ep->current_key]; 1519 key = (char *)ep->secret_key[ep->current_key];
1522 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1520 desc.tfm = sctp_sk(ep->base.sk)->hmac;
@@ -1587,9 +1585,7 @@ struct sctp_association *sctp_unpack_cookie(
1587 /* Check the signature. */ 1585 /* Check the signature. */
1588 keylen = SCTP_SECRET_SIZE; 1586 keylen = SCTP_SECRET_SIZE;
1589 sg_init_table(&sg, 1); 1587 sg_init_table(&sg, 1);
1590 sg_set_page(&sg, virt_to_page(bear_cookie)); 1588 sg_set_buf(&sg, bear_cookie, bodysize);
1591 sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE;
1592 sg.length = bodysize;
1593 key = (char *)ep->secret_key[ep->current_key]; 1589 key = (char *)ep->secret_key[ep->current_key];
1594 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1590 desc.tfm = sctp_sk(ep->base.sk)->hmac;
1595 desc.flags = 0; 1591 desc.flags = 0;
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 32be431affcf..24711be4b2dc 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -199,7 +199,7 @@ encryptor(struct scatterlist *sg, void *data)
199 } else { 199 } else {
200 in_page = sg_page(sg); 200 in_page = sg_page(sg);
201 } 201 }
202 sg_set_page(&desc->infrags[desc->fragno], in_page); 202 sg_assign_page(&desc->infrags[desc->fragno], in_page);
203 desc->fragno++; 203 desc->fragno++;
204 desc->fraglen += sg->length; 204 desc->fraglen += sg->length;
205 desc->pos += sg->length; 205 desc->pos += sg->length;
@@ -215,11 +215,10 @@ encryptor(struct scatterlist *sg, void *data)
215 if (ret) 215 if (ret)
216 return ret; 216 return ret;
217 if (fraglen) { 217 if (fraglen) {
218 sg_set_page(&desc->outfrags[0], sg_page(sg)); 218 sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen,
219 desc->outfrags[0].offset = sg->offset + sg->length - fraglen; 219 sg->offset + sg->length - fraglen);
220 desc->outfrags[0].length = fraglen;
221 desc->infrags[0] = desc->outfrags[0]; 220 desc->infrags[0] = desc->outfrags[0];
222 sg_set_page(&desc->infrags[0], in_page); 221 sg_assign_page(&desc->infrags[0], in_page);
223 desc->fragno = 1; 222 desc->fragno = 1;
224 desc->fraglen = fraglen; 223 desc->fraglen = fraglen;
225 } else { 224 } else {
@@ -287,9 +286,8 @@ decryptor(struct scatterlist *sg, void *data)
287 if (ret) 286 if (ret)
288 return ret; 287 return ret;
289 if (fraglen) { 288 if (fraglen) {
290 sg_set_page(&desc->frags[0], sg_page(sg)); 289 sg_set_page(&desc->frags[0], sg_page(sg), fraglen,
291 desc->frags[0].offset = sg->offset + sg->length - fraglen; 290 sg->offset + sg->length - fraglen);
292 desc->frags[0].length = fraglen;
293 desc->fragno = 1; 291 desc->fragno = 1;
294 desc->fraglen = fraglen; 292 desc->fraglen = fraglen;
295 } else { 293 } else {
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 3d1f7cdf9dd0..f38dac30481b 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1059,9 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
1059 do { 1059 do {
1060 if (thislen > page_len) 1060 if (thislen > page_len)
1061 thislen = page_len; 1061 thislen = page_len;
1062 sg_set_page(sg, buf->pages[i]); 1062 sg_set_page(sg, buf->pages[i], thislen, page_offset);
1063 sg->offset = page_offset;
1064 sg->length = thislen;
1065 ret = actor(sg, data); 1063 ret = actor(sg, data);
1066 if (ret) 1064 if (ret)
1067 goto out; 1065 goto out;
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 313d4bed3aa9..fa45989a716a 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -553,9 +553,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
553 if (copy > len) 553 if (copy > len)
554 copy = len; 554 copy = len;
555 555
556 sg_set_page(&sg, virt_to_page(skb->data + offset)); 556 sg_set_buf(&sg, skb->data + offset, copy);
557 sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
558 sg.length = copy;
559 557
560 err = icv_update(desc, &sg, copy); 558 err = icv_update(desc, &sg, copy);
561 if (unlikely(err)) 559 if (unlikely(err))
@@ -578,9 +576,8 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
578 if (copy > len) 576 if (copy > len)
579 copy = len; 577 copy = len;
580 578
581 sg_set_page(&sg, frag->page); 579 sg_set_page(&sg, frag->page, copy,
582 sg.offset = frag->page_offset + offset-start; 580 frag->page_offset + offset-start);
583 sg.length = copy;
584 581
585 err = icv_update(desc, &sg, copy); 582 err = icv_update(desc, &sg, copy);
586 if (unlikely(err)) 583 if (unlikely(err))