diff options
-rw-r--r-- | drivers/scsi/mesh.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index e64d1a19d8d7..651d09b08f2a 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c | |||
@@ -421,7 +421,7 @@ static void mesh_start_cmd(struct mesh_state *ms, struct scsi_cmnd *cmd) | |||
421 | for (i = 0; i < cmd->cmd_len; ++i) | 421 | for (i = 0; i < cmd->cmd_len; ++i) |
422 | printk(" %x", cmd->cmnd[i]); | 422 | printk(" %x", cmd->cmnd[i]); |
423 | printk(" use_sg=%d buffer=%p bufflen=%u\n", | 423 | printk(" use_sg=%d buffer=%p bufflen=%u\n", |
424 | cmd->use_sg, cmd->request_buffer, cmd->request_bufflen); | 424 | scsi_sg_count(cmd), scsi_sglist(cmd), scsi_bufflen(cmd)); |
425 | } | 425 | } |
426 | #endif | 426 | #endif |
427 | if (ms->dma_started) | 427 | if (ms->dma_started) |
@@ -602,13 +602,16 @@ static void mesh_done(struct mesh_state *ms, int start_next) | |||
602 | cmd->result += (cmd->SCp.Message << 8); | 602 | cmd->result += (cmd->SCp.Message << 8); |
603 | if (DEBUG_TARGET(cmd)) { | 603 | if (DEBUG_TARGET(cmd)) { |
604 | printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", | 604 | printk(KERN_DEBUG "mesh_done: result = %x, data_ptr=%d, buflen=%d\n", |
605 | cmd->result, ms->data_ptr, cmd->request_bufflen); | 605 | cmd->result, ms->data_ptr, scsi_bufflen(cmd)); |
606 | #if 0 | ||
607 | /* needs to use sg? */ | ||
606 | if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 3) | 608 | if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 3) |
607 | && cmd->request_buffer != 0) { | 609 | && cmd->request_buffer != 0) { |
608 | unsigned char *b = cmd->request_buffer; | 610 | unsigned char *b = cmd->request_buffer; |
609 | printk(KERN_DEBUG "buffer = %x %x %x %x %x %x %x %x\n", | 611 | printk(KERN_DEBUG "buffer = %x %x %x %x %x %x %x %x\n", |
610 | b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]); | 612 | b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]); |
611 | } | 613 | } |
614 | #endif | ||
612 | } | 615 | } |
613 | cmd->SCp.this_residual -= ms->data_ptr; | 616 | cmd->SCp.this_residual -= ms->data_ptr; |
614 | mesh_completed(ms, cmd); | 617 | mesh_completed(ms, cmd); |
@@ -1265,15 +1268,18 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd) | |||
1265 | dcmds = ms->dma_cmds; | 1268 | dcmds = ms->dma_cmds; |
1266 | dtot = 0; | 1269 | dtot = 0; |
1267 | if (cmd) { | 1270 | if (cmd) { |
1268 | cmd->SCp.this_residual = cmd->request_bufflen; | 1271 | int nseg; |
1269 | if (cmd->use_sg > 0) { | 1272 | |
1270 | int nseg; | 1273 | cmd->SCp.this_residual = scsi_bufflen(cmd); |
1274 | |||
1275 | nseg = scsi_dma_map(cmd); | ||
1276 | BUG_ON(nseg < 0); | ||
1277 | |||
1278 | if (nseg) { | ||
1271 | total = 0; | 1279 | total = 0; |
1272 | scl = (struct scatterlist *) cmd->request_buffer; | ||
1273 | off = ms->data_ptr; | 1280 | off = ms->data_ptr; |
1274 | nseg = pci_map_sg(ms->pdev, scl, cmd->use_sg, | 1281 | |
1275 | cmd->sc_data_direction); | 1282 | scsi_for_each_sg(cmd, scl, nseg, i) { |
1276 | for (i = 0; i <nseg; ++i, ++scl) { | ||
1277 | u32 dma_addr = sg_dma_address(scl); | 1283 | u32 dma_addr = sg_dma_address(scl); |
1278 | u32 dma_len = sg_dma_len(scl); | 1284 | u32 dma_len = sg_dma_len(scl); |
1279 | 1285 | ||
@@ -1292,16 +1298,6 @@ static void set_dma_cmds(struct mesh_state *ms, struct scsi_cmnd *cmd) | |||
1292 | dtot += dma_len - off; | 1298 | dtot += dma_len - off; |
1293 | off = 0; | 1299 | off = 0; |
1294 | } | 1300 | } |
1295 | } else if (ms->data_ptr < cmd->request_bufflen) { | ||
1296 | dtot = cmd->request_bufflen - ms->data_ptr; | ||
1297 | if (dtot > 0xffff) | ||
1298 | panic("mesh: transfer size >= 64k"); | ||
1299 | st_le16(&dcmds->req_count, dtot); | ||
1300 | /* XXX Use pci DMA API here ... */ | ||
1301 | st_le32(&dcmds->phy_addr, | ||
1302 | virt_to_phys(cmd->request_buffer) + ms->data_ptr); | ||
1303 | dcmds->xfer_status = 0; | ||
1304 | ++dcmds; | ||
1305 | } | 1301 | } |
1306 | } | 1302 | } |
1307 | if (dtot == 0) { | 1303 | if (dtot == 0) { |
@@ -1356,18 +1352,14 @@ static void halt_dma(struct mesh_state *ms) | |||
1356 | dumplog(ms, ms->conn_tgt); | 1352 | dumplog(ms, ms->conn_tgt); |
1357 | dumpslog(ms); | 1353 | dumpslog(ms); |
1358 | #endif /* MESH_DBG */ | 1354 | #endif /* MESH_DBG */ |
1359 | } else if (cmd && cmd->request_bufflen != 0 && | 1355 | } else if (cmd && scsi_bufflen(cmd) && |
1360 | ms->data_ptr > cmd->request_bufflen) { | 1356 | ms->data_ptr > scsi_bufflen(cmd)) { |
1361 | printk(KERN_DEBUG "mesh: target %d overrun, " | 1357 | printk(KERN_DEBUG "mesh: target %d overrun, " |
1362 | "data_ptr=%x total=%x goes_out=%d\n", | 1358 | "data_ptr=%x total=%x goes_out=%d\n", |
1363 | ms->conn_tgt, ms->data_ptr, cmd->request_bufflen, | 1359 | ms->conn_tgt, ms->data_ptr, scsi_bufflen(cmd), |
1364 | ms->tgts[ms->conn_tgt].data_goes_out); | 1360 | ms->tgts[ms->conn_tgt].data_goes_out); |
1365 | } | 1361 | } |
1366 | if (cmd->use_sg != 0) { | 1362 | scsi_dma_unmap(cmd); |
1367 | struct scatterlist *sg; | ||
1368 | sg = (struct scatterlist *)cmd->request_buffer; | ||
1369 | pci_unmap_sg(ms->pdev, sg, cmd->use_sg, cmd->sc_data_direction); | ||
1370 | } | ||
1371 | ms->dma_started = 0; | 1363 | ms->dma_started = 0; |
1372 | } | 1364 | } |
1373 | 1365 | ||