Skip to content

Commit 45711f1

Browse files
author
Jens Axboe
committed
[SG] Update drivers to use sg helpers
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 78c2f0b commit 45711f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+278
-275
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ static void do_ubd_request(struct request_queue *q)
11151115
}
11161116
prepare_request(req, io_req,
11171117
(unsigned long long) req->sector << 9,
1118-
sg->offset, sg->length, sg->page);
1118+
sg->offset, sg->length, sg_page(sg));
11191119

11201120
last_sectors = sg->length >> 9;
11211121
n = os_write_file(thread_fd, &io_req,

drivers/ata/libata-core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,7 +4296,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc)
42964296
sg_last(sg, qc->orig_n_elem)->length += qc->pad_len;
42974297
if (pad_buf) {
42984298
struct scatterlist *psg = &qc->pad_sgent;
4299-
void *addr = kmap_atomic(psg->page, KM_IRQ0);
4299+
void *addr = kmap_atomic(sg_page(psg), KM_IRQ0);
43004300
memcpy(addr + psg->offset, pad_buf, qc->pad_len);
43014301
kunmap_atomic(addr, KM_IRQ0);
43024302
}
@@ -4686,11 +4686,11 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
46864686
* data in this function or read data in ata_sg_clean.
46874687
*/
46884688
offset = lsg->offset + lsg->length - qc->pad_len;
4689-
psg->page = nth_page(lsg->page, offset >> PAGE_SHIFT);
4689+
sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT));
46904690
psg->offset = offset_in_page(offset);
46914691

46924692
if (qc->tf.flags & ATA_TFLAG_WRITE) {
4693-
void *addr = kmap_atomic(psg->page, KM_IRQ0);
4693+
void *addr = kmap_atomic(sg_page(psg), KM_IRQ0);
46944694
memcpy(pad_buf, addr + psg->offset, qc->pad_len);
46954695
kunmap_atomic(addr, KM_IRQ0);
46964696
}
@@ -4836,7 +4836,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
48364836
if (qc->curbytes == qc->nbytes - qc->sect_size)
48374837
ap->hsm_task_state = HSM_ST_LAST;
48384838

4839-
page = qc->cursg->page;
4839+
page = sg_page(qc->cursg);
48404840
offset = qc->cursg->offset + qc->cursg_ofs;
48414841

48424842
/* get the current page and offset */
@@ -4988,7 +4988,7 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
49884988

49894989
sg = qc->cursg;
49904990

4991-
page = sg->page;
4991+
page = sg_page(sg);
49924992
offset = sg->offset + qc->cursg_ofs;
49934993

49944994
/* get the current page and offset */

drivers/ata/libata-scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out)
15441544
struct scatterlist *sg = scsi_sglist(cmd);
15451545

15461546
if (sg) {
1547-
buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
1547+
buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
15481548
buflen = sg->length;
15491549
} else {
15501550
buf = NULL;

drivers/block/DAC960.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
345345
Command->V1.ScatterGatherList =
346346
(DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU;
347347
Command->V1.ScatterGatherListDMA = ScatterGatherDMA;
348+
sg_init_table(Command->cmd_sglist, DAC960_V1_ScatterGatherLimit);
348349
} else {
349350
Command->cmd_sglist = Command->V2.ScatterList;
350351
Command->V2.ScatterGatherList =
@@ -353,6 +354,7 @@ static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
353354
Command->V2.RequestSense =
354355
(DAC960_SCSI_RequestSense_T *)RequestSenseCPU;
355356
Command->V2.RequestSenseDMA = RequestSenseDMA;
357+
sg_init_table(Command->cmd_sglist, DAC960_V2_ScatterGatherLimit);
356358
}
357359
}
358360
return true;

drivers/block/cciss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ static void do_cciss_request(struct request_queue *q)
26102610
(int)creq->nr_sectors);
26112611
#endif /* CCISS_DEBUG */
26122612

2613-
memset(tmp_sg, 0, sizeof(tmp_sg));
2613+
sg_init_table(tmp_sg, MAXSGENTRIES);
26142614
seg = blk_rq_map_sg(q, creq, tmp_sg);
26152615

26162616
/* get the DMA records for the setup */
@@ -2621,7 +2621,7 @@ static void do_cciss_request(struct request_queue *q)
26212621

26222622
for (i = 0; i < seg; i++) {
26232623
c->SG[i].Len = tmp_sg[i].length;
2624-
temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page,
2624+
temp64.val = (__u64) pci_map_page(h->pdev, sg_page(&tmp_sg[i]),
26252625
tmp_sg[i].offset,
26262626
tmp_sg[i].length, dir);
26272627
c->SG[i].Addr.lower = temp64.val32.lower;

drivers/block/cpqarray.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@ static void do_ida_request(struct request_queue *q)
918918
DBGPX(
919919
printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors);
920920
);
921+
sg_init_table(tmp_sg, SG_MAX);
921922
seg = blk_rq_map_sg(q, creq, tmp_sg);
922923

923924
/* Now do all the DMA Mappings */
@@ -929,7 +930,7 @@ DBGPX(
929930
{
930931
c->req.sg[i].size = tmp_sg[i].length;
931932
c->req.sg[i].addr = (__u32) pci_map_page(h->pci_dev,
932-
tmp_sg[i].page,
933+
sg_page(&tmp_sg[i]),
933934
tmp_sg[i].offset,
934935
tmp_sg[i].length, dir);
935936
}

drivers/block/cryptoloop.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/crypto.h>
2727
#include <linux/blkdev.h>
2828
#include <linux/loop.h>
29+
#include <linux/scatterlist.h>
2930
#include <asm/semaphore.h>
3031
#include <asm/uaccess.h>
3132

@@ -119,14 +120,17 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
119120
.tfm = tfm,
120121
.flags = CRYPTO_TFM_REQ_MAY_SLEEP,
121122
};
122-
struct scatterlist sg_out = { NULL, };
123-
struct scatterlist sg_in = { NULL, };
123+
struct scatterlist sg_out;
124+
struct scatterlist sg_in;
124125

125126
encdec_cbc_t encdecfunc;
126127
struct page *in_page, *out_page;
127128
unsigned in_offs, out_offs;
128129
int err;
129130

131+
sg_init_table(&sg_out, 1);
132+
sg_init_table(&sg_in, 1);
133+
130134
if (cmd == READ) {
131135
in_page = raw_page;
132136
in_offs = raw_off;
@@ -146,11 +150,11 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
146150
u32 iv[4] = { 0, };
147151
iv[0] = cpu_to_le32(IV & 0xffffffff);
148152

149-
sg_in.page = in_page;
153+
sg_set_page(&sg_in, in_page);
150154
sg_in.offset = in_offs;
151155
sg_in.length = sz;
152156

153-
sg_out.page = out_page;
157+
sg_set_page(&sg_out, out_page);
154158
sg_out.offset = out_offs;
155159
sg_out.length = sz;
156160

drivers/block/sunvdc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ static int __send_request(struct request *req)
388388
op = VD_OP_BWRITE;
389389
}
390390

391+
sg_init_table(sg, port->ring_cookies);
391392
nsg = blk_rq_map_sg(req->q, req, sg);
392393

393394
len = 0;

drivers/block/sx8.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ static struct carm_request *carm_get_request(struct carm_host *host)
522522
host->n_msgs++;
523523

524524
assert(host->n_msgs <= CARM_MAX_REQ);
525+
sg_init_table(crq->sg, CARM_MAX_REQ_SG);
525526
return crq;
526527
}
527528

drivers/block/ub.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/usb_usual.h>
2626
#include <linux/blkdev.h>
2727
#include <linux/timer.h>
28+
#include <linux/scatterlist.h>
2829
#include <scsi/scsi.h>
2930

3031
#define DRV_NAME "ub"
@@ -656,6 +657,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
656657
if ((cmd = ub_get_cmd(lun)) == NULL)
657658
return -1;
658659
memset(cmd, 0, sizeof(struct ub_scsi_cmd));
660+
sg_init_table(cmd->sgv, UB_MAX_REQ_SG);
659661

660662
blkdev_dequeue_request(rq);
661663

@@ -1309,9 +1311,8 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
13091311
else
13101312
pipe = sc->send_bulk_pipe;
13111313
sc->last_pipe = pipe;
1312-
usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe,
1313-
page_address(sg->page) + sg->offset, sg->length,
1314-
ub_urb_complete, sc);
1314+
usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, sg_virt(sg),
1315+
sg->length, ub_urb_complete, sc);
13151316
sc->work_urb.actual_length = 0;
13161317
sc->work_urb.error_count = 0;
13171318
sc->work_urb.status = 0;
@@ -1427,7 +1428,7 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
14271428
scmd->state = UB_CMDST_INIT;
14281429
scmd->nsg = 1;
14291430
sg = &scmd->sgv[0];
1430-
sg->page = virt_to_page(sc->top_sense);
1431+
sg_set_page(sg, virt_to_page(sc->top_sense));
14311432
sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1);
14321433
sg->length = UB_SENSE_SIZE;
14331434
scmd->len = UB_SENSE_SIZE;
@@ -1863,7 +1864,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
18631864
cmd->state = UB_CMDST_INIT;
18641865
cmd->nsg = 1;
18651866
sg = &cmd->sgv[0];
1866-
sg->page = virt_to_page(p);
1867+
sg_set_page(sg, virt_to_page(p));
18671868
sg->offset = (unsigned long)p & (PAGE_SIZE-1);
18681869
sg->length = 8;
18691870
cmd->len = 8;

0 commit comments

Comments
 (0)