diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-15 19:51:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-15 19:51:54 -0400 |
commit | bc06cffdec85d487c77109dffcd2f285bdc502d3 (patch) | |
tree | adc6e6398243da87e66c56102840597a329183a0 /drivers/scsi/mesh.c | |
parent | d3502d7f25b22cfc9762bf1781faa9db1bb3be2e (diff) | |
parent | 9413d7b8aa777dd1fc7db9563ce5e80d769fe7b5 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (166 commits)
[SCSI] ibmvscsi: convert to use the data buffer accessors
[SCSI] dc395x: convert to use the data buffer accessors
[SCSI] ncr53c8xx: convert to use the data buffer accessors
[SCSI] sym53c8xx: convert to use the data buffer accessors
[SCSI] ppa: coding police and printk levels
[SCSI] aic7xxx_old: remove redundant GFP_ATOMIC from kmalloc
[SCSI] i2o: remove redundant GFP_ATOMIC from kmalloc from device.c
[SCSI] remove the dead CYBERSTORMIII_SCSI option
[SCSI] don't build scsi_dma_{map,unmap} for !HAS_DMA
[SCSI] Clean up scsi_add_lun a bit
[SCSI] 53c700: Remove printk, which triggers because of low scsi clock on SNI RMs
[SCSI] sni_53c710: Cleanup
[SCSI] qla4xxx: Fix underrun/overrun conditions
[SCSI] megaraid_mbox: use mutex instead of semaphore
[SCSI] aacraid: add 51245, 51645 and 52245 adapters to documentation.
[SCSI] qla2xxx: update version to 8.02.00-k1.
[SCSI] qla2xxx: add support for NPIV
[SCSI] stex: use resid for xfer len information
[SCSI] Add Brownie 1200U3P to blacklist
[SCSI] scsi.c: convert to use the data buffer accessors
...
Diffstat (limited to 'drivers/scsi/mesh.c')
-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 | ||