aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-06-26 13:48:43 -0400
committerJeff Garzik <jeff@garzik.org>2007-06-27 02:50:08 -0400
commitb9a4197e266a40d5d1d16c9fb2a852cf10743afe (patch)
tree6ec97e0122aae58944deee21c6619e23d86be64a
parente00f1ff3c8977eff07d0214d2f3478ac947bda0f (diff)
libata: use PIO for non-16 byte aligned ATAPI commands
The IDE driver used DMA for ATAPI commands if READ/WRITE command is multiple of sector size or sg command is multiple of 16 bytes. For libata, READ/WRITE sector alignment is guaranteed by the high level driver (sr), so we only have to worry about the 16 byte alignment. This patch makes ata_check_atapi_dma() always request PIO for all data transfer commands which are not multiple of 16 bytes. The following reports are related to this problem. http://bugzilla.kernel.org/show_bug.cgi?id=8605 (confirmed) http://thread.gmane.org/gmane.linux.kernel/476620 (confirmed) https://bugzilla.novell.com/show_bug.cgi?id=229260 (probably) Albert first pointed out the difference between IDE and libata. Kudos to him. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Albert Lee <albertcc@tw.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/ata/libata-core.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 642097a7d60d..094b51891dbf 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4109,6 +4109,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
4109 if (idx) 4109 if (idx)
4110 ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); 4110 ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
4111} 4111}
4112
4112/** 4113/**
4113 * ata_check_atapi_dma - Check whether ATAPI DMA can be supported 4114 * ata_check_atapi_dma - Check whether ATAPI DMA can be supported
4114 * @qc: Metadata associated with taskfile to check 4115 * @qc: Metadata associated with taskfile to check
@@ -4126,33 +4127,19 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
4126int ata_check_atapi_dma(struct ata_queued_cmd *qc) 4127int ata_check_atapi_dma(struct ata_queued_cmd *qc)
4127{ 4128{
4128 struct ata_port *ap = qc->ap; 4129 struct ata_port *ap = qc->ap;
4129 int rc = 0; /* Assume ATAPI DMA is OK by default */ 4130
4130 4131 /* Don't allow DMA if it isn't multiple of 16 bytes. Quite a
4131 /* some drives can only do ATAPI DMA on read/write */ 4132 * few ATAPI devices choke on such DMA requests.
4132 if (unlikely(qc->dev->horkage & ATA_HORKAGE_DMA_RW_ONLY)) { 4133 */
4133 struct scsi_cmnd *cmd = qc->scsicmd; 4134 if (unlikely(qc->nbytes & 15))
4134 u8 *scsicmd = cmd->cmnd; 4135 return 1;
4135
4136 switch (scsicmd[0]) {
4137 case READ_10:
4138 case WRITE_10:
4139 case READ_12:
4140 case WRITE_12:
4141 case READ_6:
4142 case WRITE_6:
4143 /* atapi dma maybe ok */
4144 break;
4145 default:
4146 /* turn off atapi dma */
4147 return 1;
4148 }
4149 }
4150 4136
4151 if (ap->ops->check_atapi_dma) 4137 if (ap->ops->check_atapi_dma)
4152 rc = ap->ops->check_atapi_dma(qc); 4138 return ap->ops->check_atapi_dma(qc);
4153 4139
4154 return rc; 4140 return 0;
4155} 4141}
4142
4156/** 4143/**
4157 * ata_qc_prep - Prepare taskfile for submission 4144 * ata_qc_prep - Prepare taskfile for submission
4158 * @qc: Metadata associated with taskfile to be prepared 4145 * @qc: Metadata associated with taskfile to be prepared