aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/esp_scsi.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-11-24 09:37:26 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-24 10:13:15 -0500
commit6df388f2d549d3a2a7ad58b632d2ecd25fc0ff3f (patch)
tree7b663c4ebd1da38079723da2989e7f44388a52f2 /drivers/scsi/esp_scsi.c
parent3a7e7be2a9a2105742c3c88d466ea2158a03a837 (diff)
am53c974: BLAST residual handling
The am53c974 has an design issue where a single byte might be left in the SCSI FIFO after a DMA transfer. As the handling code is currently untested add a WARN_ON() statement here. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/esp_scsi.c')
-rw-r--r--drivers/scsi/esp_scsi.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 25cc6fa0535c..4366011cd400 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -1334,6 +1334,35 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent,
1334 bytes_sent = esp->data_dma_len; 1334 bytes_sent = esp->data_dma_len;
1335 bytes_sent -= ecount; 1335 bytes_sent -= ecount;
1336 1336
1337 /*
1338 * The am53c974 has a DMA 'pecularity'. The doc states:
1339 * In some odd byte conditions, one residual byte will
1340 * be left in the SCSI FIFO, and the FIFO Flags will
1341 * never count to '0 '. When this happens, the residual
1342 * byte should be retrieved via PIO following completion
1343 * of the BLAST operation.
1344 */
1345 if (fifo_cnt == 1 && ent->flags & ESP_CMD_FLAG_RESIDUAL) {
1346 size_t count = 1;
1347 size_t offset = bytes_sent;
1348 u8 bval = esp_read8(ESP_FDATA);
1349
1350 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE)
1351 ent->sense_ptr[bytes_sent] = bval;
1352 else {
1353 struct esp_cmd_priv *p = ESP_CMD_PRIV(cmd);
1354 u8 *ptr;
1355
1356 ptr = scsi_kmap_atomic_sg(p->cur_sg, p->u.num_sg,
1357 &offset, &count);
1358 if (likely(ptr)) {
1359 *(ptr + offset) = bval;
1360 scsi_kunmap_atomic_sg(ptr);
1361 }
1362 }
1363 bytes_sent += fifo_cnt;
1364 ent->flags &= ~ESP_CMD_FLAG_RESIDUAL;
1365 }
1337 if (!(ent->flags & ESP_CMD_FLAG_WRITE)) 1366 if (!(ent->flags & ESP_CMD_FLAG_WRITE))
1338 bytes_sent -= fifo_cnt; 1367 bytes_sent -= fifo_cnt;
1339 1368