* [PATCH] libata: Set transfer sizes properly for ATAPI
@ 2007-09-20 14:01 Alan Cox
2007-09-20 20:47 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2007-09-20 14:01 UTC (permalink / raw)
To: linux-ide, jeff
In theory this isn't needed. In practice it seems to matter now and then
and was also done by the old IDE DMA layer.
Signed-off-by: Alan Cox <alan@redhat.com>
diff -u --exclude-from /usr/src/exclude --new-file --recursive linux.vanilla-2.6.23rc6-mm1/drivers/ata/libata-scsi.c linux-2.6.23rc6-mm1/drivers/ata/libata-scsi.c
--- linux.vanilla-2.6.23rc6-mm1/drivers/ata/libata-scsi.c 2007-09-18 15:32:51.000000000 +0100
+++ linux-2.6.23rc6-mm1/drivers/ata/libata-scsi.c 2007-09-19 21:30:51.368961456 +0100
@@ -2276,8 +2276,8 @@
qc->tf.feature |= ATAPI_PKT_DMA;
} else {
qc->tf.protocol = ATA_PROT_ATAPI;
- qc->tf.lbam = (8 * 1024) & 0xff;
- qc->tf.lbah = (8 * 1024) >> 8;
+ qc->tf.lbam = SCSI_SENSE_BUFFERSIZE;
+ qc->tf.lbah = 0;
}
qc->nbytes = SCSI_SENSE_BUFFERSIZE;
@@ -2386,6 +2386,7 @@
struct ata_device *dev = qc->dev;
int using_pio = (dev->flags & ATA_DFLAG_PIO);
int nodata = (scmd->sc_data_direction == DMA_NONE);
+ unsigned int nbytes;
memset(qc->cdb, 0, dev->cdb_len);
memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len);
@@ -2400,19 +2401,25 @@
qc->tf.command = ATA_CMD_PACKET;
qc->nbytes = scmd->request_bufflen;
-
+
/* check whether ATAPI DMA is safe */
if (!using_pio && ata_check_atapi_dma(qc))
using_pio = 1;
+ /* Some controller variants snoop this value for Packet transfers
+ to do state machine and FIFO management. Thus we want to set it
+ properly, and for DMA where it is effectively meaningless */
+ nbytes = min(qc->nbytes, (unsigned int)63 * 1024);
+
+ qc->tf.lbam = (nbytes & 0xFF);
+ qc->tf.lbah = (nbytes >> 8);
+
if (using_pio || nodata) {
/* no data, or PIO data xfer */
if (nodata)
qc->tf.protocol = ATA_PROT_ATAPI_NODATA;
else
qc->tf.protocol = ATA_PROT_ATAPI;
- qc->tf.lbam = (8 * 1024) & 0xff;
- qc->tf.lbah = (8 * 1024) >> 8;
} else {
/* DMA data xfer */
qc->tf.protocol = ATA_PROT_ATAPI_DMA;
@@ -2423,6 +2430,9 @@
qc->tf.feature |= ATAPI_DMADIR;
}
+
+ /* FIXME: We need to translate 0x05 READ_BLOCK_LIMITS to a MODE_SENSE
+ as ATAPI tape drives don't get this right otherwise */
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] libata: Set transfer sizes properly for ATAPI
2007-09-20 14:01 [PATCH] libata: Set transfer sizes properly for ATAPI Alan Cox
@ 2007-09-20 20:47 ` Jeff Garzik
2007-09-20 21:44 ` Alan Cox
2007-09-21 22:14 ` Alan Cox
0 siblings, 2 replies; 5+ messages in thread
From: Jeff Garzik @ 2007-09-20 20:47 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-ide
[-- Attachment #1: Type: text/plain, Size: 224 bytes --]
Alan Cox wrote:
> In theory this isn't needed. In practice it seems to matter now and then
> and was also done by the old IDE DMA layer.
>
> Signed-off-by: Alan Cox <alan@redhat.com>
applied a modified version (attached)
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2272 bytes --]
commit 8dcab000d7a3b114a3434129d1d6437263835c87
Author: Jeff Garzik <jeff@garzik.org>
Date: Thu Sep 20 16:46:42 2007 -0400
[libata] Always set ATAPI TF lbam/lbah, regardless of PIO or DMA
A slightly modified version of Alan Cox's change:
libata: Set transfer sizes properly for ATAPI
In theory this isn't needed. In practice it seems to matter now and then
and was also done by the old IDE DMA layer.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/ata/libata-scsi.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
8dcab000d7a3b114a3434129d1d6437263835c87
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index f0f586b..8eac137 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2273,10 +2273,10 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
qc->tf.feature |= ATAPI_PKT_DMA;
} else {
qc->tf.protocol = ATA_PROT_ATAPI;
- qc->tf.lbam = (8 * 1024) & 0xff;
- qc->tf.lbah = (8 * 1024) >> 8;
}
qc->nbytes = SCSI_SENSE_BUFFERSIZE;
+ qc->tf.lbam = SCSI_SENSE_BUFFERSIZE;
+ qc->tf.lbah = 0;
qc->complete_fn = atapi_sense_complete;
@@ -2383,6 +2383,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
struct ata_device *dev = qc->dev;
int using_pio = (dev->flags & ATA_DFLAG_PIO);
int nodata = (scmd->sc_data_direction == DMA_NONE);
+ unsigned int nbytes;
memset(qc->cdb, 0, dev->cdb_len);
memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len);
@@ -2402,14 +2403,20 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
if (!using_pio && ata_check_atapi_dma(qc))
using_pio = 1;
+ /* Some controller variants snoop this value for Packet transfers
+ to do state machine and FIFO management. Thus we want to set it
+ properly, even for DMA where it is effectively meaningless */
+
+ nbytes = qc->nbytes & 0xffff;
+ qc->tf.lbam = (nbytes & 0xff);
+ qc->tf.lbah = (nbytes >> 8);
+
if (using_pio || nodata) {
/* no data, or PIO data xfer */
if (nodata)
qc->tf.protocol = ATA_PROT_ATAPI_NODATA;
else
qc->tf.protocol = ATA_PROT_ATAPI;
- qc->tf.lbam = (8 * 1024) & 0xff;
- qc->tf.lbah = (8 * 1024) >> 8;
} else {
/* DMA data xfer */
qc->tf.protocol = ATA_PROT_ATAPI_DMA;
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] libata: Set transfer sizes properly for ATAPI
2007-09-20 20:47 ` Jeff Garzik
@ 2007-09-20 21:44 ` Alan Cox
2007-09-21 22:14 ` Alan Cox
1 sibling, 0 replies; 5+ messages in thread
From: Alan Cox @ 2007-09-20 21:44 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-ide
On Thu, 20 Sep 2007 16:47:16 -0400
Jeff Garzik <jeff@garzik.org> wrote:
> Alan Cox wrote:
> > In theory this isn't needed. In practice it seems to matter now and then
> > and was also done by the old IDE DMA layer.
> >
> > Signed-off-by: Alan Cox <alan@redhat.com>
>
> applied a modified version (attached)
Can you guarantee our transfer size never exceeds 63Kbytes (see the spec
for what occurs after that - its not intuitive)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata: Set transfer sizes properly for ATAPI
2007-09-20 20:47 ` Jeff Garzik
2007-09-20 21:44 ` Alan Cox
@ 2007-09-21 22:14 ` Alan Cox
2007-09-21 22:34 ` Jeff Garzik
1 sibling, 1 reply; 5+ messages in thread
From: Alan Cox @ 2007-09-21 22:14 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-ide
On Thu, 20 Sep 2007 16:47:16 -0400
Jeff Garzik <jeff@garzik.org> wrote:
> Alan Cox wrote:
> > In theory this isn't needed. In practice it seems to matter now and then
> > and was also done by the old IDE DMA layer.
> >
> > Signed-off-by: Alan Cox <alan@redhat.com>
>
> applied a modified version (attached)
NAK your version on testing. Mine works, yours doesn't.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata: Set transfer sizes properly for ATAPI
2007-09-21 22:14 ` Alan Cox
@ 2007-09-21 22:34 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2007-09-21 22:34 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-ide
Alan Cox wrote:
> On Thu, 20 Sep 2007 16:47:16 -0400
> Jeff Garzik <jeff@garzik.org> wrote:
>
>> Alan Cox wrote:
>>> In theory this isn't needed. In practice it seems to matter now and then
>>> and was also done by the old IDE DMA layer.
>>>
>>> Signed-off-by: Alan Cox <alan@redhat.com>
>> applied a modified version (attached)
>
> NAK your version on testing. Mine works, yours doesn't.
Yeah I already reverted it from #upstream
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-21 22:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-20 14:01 [PATCH] libata: Set transfer sizes properly for ATAPI Alan Cox
2007-09-20 20:47 ` Jeff Garzik
2007-09-20 21:44 ` Alan Cox
2007-09-21 22:14 ` Alan Cox
2007-09-21 22:34 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).