aboutsummaryrefslogtreecommitdiff
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2008-02-19 11:36:57 +0100
committerJens Axboe <jens.axboe@oracle.com>2008-02-19 11:36:57 +0100
commitfa2fc7f4813bfec1ae3232d49e3befbd601e8a6f (patch)
treef5598bd35f38812318da493cc027238a2256e036 /drivers/ata/libata-core.c
parentdde2020754aeb14e17052d61784dcb37f252aac2 (diff)
libata: implement drain buffers
This just updates the libata slave configure routine to take advantage of the block layer drain buffers. It also adjusts the size lengths in the atapi code to add the drain buffer to the DMA length so the driver knows it can rely on it. I suspect I should also be checking for AHCI as well as ATA_DEV_ATAPI, but I couldn't see how to do that easily. tj: * atapi_drain_needed() added such that draining is applied to only misc ATAPI commands. * q->bounce_gfp used when allocating drain buffer. * Now duplicate ATAPI PIO drain logic dropped. * ata_dev_printk() used instead of sdev_printk(). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c56
1 files changed, 4 insertions, 52 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3587ac3fe3f..def3682f416 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4642,28 +4642,6 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
}
/**
- * atapi_qc_may_overflow - Check whether data transfer may overflow
- * @qc: ATA command in question
- *
- * ATAPI commands which transfer variable length data to host
- * might overflow due to application error or hardare bug. This
- * function checks whether overflow should be drained and ignored
- * for @qc.
- *
- * LOCKING:
- * None.
- *
- * RETURNS:
- * 1 if @qc may overflow; otherwise, 0.
- */
-static int atapi_qc_may_overflow(struct ata_queued_cmd *qc)
-{
- return ata_is_atapi(qc->tf.protocol) && ata_is_data(qc->tf.protocol) &&
- atapi_cmd_type(qc->cdb[0]) == ATAPI_MISC &&
- !(qc->tf.flags & ATA_TFLAG_WRITE);
-}
-
-/**
* ata_std_qc_defer - Check whether a qc needs to be deferred
* @qc: ATA command in question
*
@@ -5026,36 +5004,10 @@ static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
next_sg:
sg = qc->cursg;
if (unlikely(!sg)) {
- /*
- * The end of qc->sg is reached and the device expects
- * more data to transfer. In order not to overrun qc->sg
- * and fulfill length specified in the byte count register,
- * - for read case, discard trailing data from the device
- * - for write case, padding zero data to the device
- */
- u16 pad_buf[1] = { 0 };
-
- if (qc->curbytes + bytes > qc->nbytes + ATAPI_MAX_DRAIN) {
- ata_ehi_push_desc(ehi, "too much trailing data "
- "buf=%u cur=%u bytes=%u",
- qc->nbytes, qc->curbytes, bytes);
- return -1;
- }
-
- /* allow overflow only for misc ATAPI commands */
- if (!atapi_qc_may_overflow(qc)) {
- ata_ehi_push_desc(ehi, "unexpected trailing data "
- "%u bytes", bytes);
- return -1;
- }
-
- consumed = 0;
- while (consumed < bytes)
- consumed += ap->ops->data_xfer(dev,
- (unsigned char *)pad_buf, 2, rw);
-
- qc->curbytes += bytes;
- return 0;
+ ata_ehi_push_desc(ehi, "unexpected or too much trailing data "
+ "buf=%u cur=%u bytes=%u",
+ qc->nbytes, qc->curbytes, bytes);
+ return -1;
}
page = sg_page(sg);