[SCSI] mesh: convert to use the data buffer accessors
- remove the unnecessary map_single path. - convert to use the new accessors for the sg lists and the parameters. Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
This commit is contained in:
committed by
James Bottomley
parent
d8196ed218
commit
f0002c4e1f
@@ -421,7 +421,7 @@ static void mesh_start_cmd(struct mesh_state *ms, struct scsi_cmnd *cmd)
|
|||||||
for (i = 0; i < cmd->cmd_len; ++i)
|
for (i = 0; i < cmd->cmd_len; ++i)
|
||||||
printk(" %x", cmd->cmnd[i]);
|
printk(" %x", cmd->cmnd[i]);
|
||||||
printk(" use_sg=%d buffer=%p bufflen=%u\n",
|
printk(" use_sg=%d buffer=%p bufflen=%u\n",
|
||||||
cmd->use_sg, cmd->request_buffer, cmd->request_bufflen);
|
scsi_sg_count(cmd), scsi_sglist(cmd), scsi_bufflen(cmd));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ms->dma_started)
|
if (ms->dma_started)
|
||||||
@@ -602,13 +602,16 @@ static void mesh_done(struct mesh_state *ms, int start_next)
|
|||||||
cmd->result += (cmd->SCp.Message << 8);
|
cmd->result += (cmd->SCp.Message << 8);
|
||||||
if (DEBUG_TARGET(cmd)) {
|
if (DEBUG_TARGET(cmd)) {
|
||||||
printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n",
|
printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n",
|
||||||
cmd->result, ms->data_ptr, cmd->request_bufflen);
|
cmd->result, ms->data_ptr, scsi_bufflen(cmd));
|
||||||
|
#if 0
|
||||||
|
/* needs to use sg? */
|
||||||
if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 3)
|
if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 3)
|
||||||
&& cmd->request_buffer != 0) {
|
&& cmd->request_buffer != 0) {
|
||||||
unsigned char *b = cmd->request_buffer;
|
unsigned char *b = cmd->request_buffer;
|
||||||
printk(KERN_DEBUG "buffer = %x %x %x %x %x %x %x %x\n",
|
printk(KERN_DEBUG "buffer = %x %x %x %x %x %x %x %x\n",
|
||||||
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]);
|
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
cmd->SCp.this_residual -= ms->data_ptr;
|
cmd->SCp.this_residual -= ms->data_ptr;
|
||||||
mesh_completed(ms, cmd);
|
mesh_completed(ms, cmd);
|
||||||
@@ -1265,15 +1268,18 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd)
|
|||||||
dcmds = ms->dma_cmds;
|
dcmds = ms->dma_cmds;
|
||||||
dtot = 0;
|
dtot = 0;
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
cmd->SCp.this_residual = cmd->request_bufflen;
|
int nseg;
|
||||||
if (cmd->use_sg > 0) {
|
|
||||||
int nseg;
|
cmd->SCp.this_residual = scsi_bufflen(cmd);
|
||||||
|
|
||||||
|
nseg = scsi_dma_map(cmd);
|
||||||
|
BUG_ON(nseg < 0);
|
||||||
|
|
||||||
|
if (nseg) {
|
||||||
total = 0;
|
total = 0;
|
||||||
scl = (struct scatterlist *) cmd->request_buffer;
|
|
||||||
off = ms->data_ptr;
|
off = ms->data_ptr;
|
||||||
nseg = pci_map_sg(ms->pdev, scl, cmd->use_sg,
|
|
||||||
cmd->sc_data_direction);
|
scsi_for_each_sg(cmd, scl, nseg, i) {
|
||||||
for (i = 0; i <nseg; ++i, ++scl) {
|
|
||||||
u32 dma_addr = sg_dma_address(scl);
|
u32 dma_addr = sg_dma_address(scl);
|
||||||
u32 dma_len = sg_dma_len(scl);
|
u32 dma_len = sg_dma_len(scl);
|
||||||
|
|
||||||
@@ -1292,16 +1298,6 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd)
|
|||||||
dtot += dma_len - off;
|
dtot += dma_len - off;
|
||||||
off = 0;
|
off = 0;
|
||||||
}
|
}
|
||||||
} else if (ms->data_ptr < cmd->request_bufflen) {
|
|
||||||
dtot = cmd->request_bufflen - ms->data_ptr;
|
|
||||||
if (dtot > 0xffff)
|
|
||||||
panic("mesh: transfer size >= 64k");
|
|
||||||
st_le16(&dcmds->req_count, dtot);
|
|
||||||
/* XXX Use pci DMA API here ... */
|
|
||||||
st_le32(&dcmds->phy_addr,
|
|
||||||
virt_to_phys(cmd->request_buffer) + ms->data_ptr);
|
|
||||||
dcmds->xfer_status = 0;
|
|
||||||
++dcmds;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dtot == 0) {
|
if (dtot == 0) {
|
||||||
@@ -1356,18 +1352,14 @@ static void halt_dma(struct mesh_state *ms)
|
|||||||
dumplog(ms, ms->conn_tgt);
|
dumplog(ms, ms->conn_tgt);
|
||||||
dumpslog(ms);
|
dumpslog(ms);
|
||||||
#endif /* MESH_DBG */
|
#endif /* MESH_DBG */
|
||||||
} else if (cmd && cmd->request_bufflen != 0 &&
|
} else if (cmd && scsi_bufflen(cmd) &&
|
||||||
ms->data_ptr > cmd->request_bufflen) {
|
ms->data_ptr > scsi_bufflen(cmd)) {
|
||||||
printk(KERN_DEBUG "mesh: target %d overrun, "
|
printk(KERN_DEBUG "mesh: target %d overrun, "
|
||||||
"data_ptr=%x total=%x goes_out=%d\n",
|
"data_ptr=%x total=%x goes_out=%d\n",
|
||||||
ms->conn_tgt, ms->data_ptr, cmd->request_bufflen,
|
ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd),
|
||||||
ms->tgts[ms->conn_tgt].data_goes_out);
|
ms->tgts[ms->conn_tgt].data_goes_out);
|
||||||
}
|
}
|
||||||
if (cmd->use_sg != 0) {
|
scsi_dma_unmap(cmd);
|
||||||
struct scatterlist *sg;
|
|
||||||
sg = (struct scatterlist *)cmd->request_buffer;
|
|
||||||
pci_unmap_sg(ms->pdev, sg, cmd->use_sg, cmd->sc_data_direction);
|
|
||||||
}
|
|
||||||
ms->dma_started = 0;
|
ms->dma_started = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user