2.4.x libata fixes, and new ULi ctlr support
PATCH 1/1 2.4.x libata fixes, and new ULi ctlr support
patch and changelog attached.
Please do a
bk pull bk://gkernel.bkbits.net/libata-upstream-2.4
This will update the following files:
drivers/scsi/libata-core.c | 46 ++++++++++++++++++++++++---------------- drivers/scsi/libata-scsi.c | 5 ++++ drivers/scsi/libata.h | 1 drivers/scsi/sata_nv.c | 10 +++++++- drivers/scsi/sata_uli.c | 51 ++++++++++++++++++++------------------------- include/linux/libata.h | 2 + 6 files changed, 68 insertions(+), 47 deletions(-)
through these ChangeSets:
<[email protected]> (04/12/27 1.1559)
[libata] add #include (fixes 2.4 alpha build)
<[email protected]> (04/12/27 1.1558)
[libata] verify ATAPI DMA for a given request is OK
After some testing, it seems that some PATA host adapter (ex. pdc20275) cannot work reliably with specific request buffer sizes under ATAPI DMA mode.
Detailed test result:
4096, 2048, 1024, 512, 256: OK
384, 257, 255, 128, 96, 64, 32: failed (irq lost)
It seems multiple of 256 bytes are the safe ATAPI DMA buffer sizes to use.
Attached please find the patch to fix the pdc2027x ATAPI DMA problem.
Changes:
1. Add a callback function "check_atapi_dma()" to ata_port_operations such that libata core can ask the driver: "Can this command be processed in ATAPI DMA mode safely? " when the the command is received.
2. ATAPI DMA is off by default if the callback function is not provided by the driver
If the callback function is not provided by the driver, the ATAPI DMA should be as is. The ATAPI DMA is already controlled by dev->flags.
BTW, the patch isolates the ATAPI DMA workaround to the pdc20275 driver itself, not impacting libata core .
<[email protected]> (04/12/27 1.1557)
[libata] PIO error handling improvement
Tested burning CD-RW with libata-dev-2.6 and cdrecord:
1. ATAPI DMA mode - tested OK
2. ATAPI PIO mode - test failed when cdrecord finishes burning and issues MODE_SELECT to the device.
After checking the log, it showed that MODE_SELECT caused ata_pio_complete()
to return error.
However, the error is not handled by ata_pio_task().
Attached please find the patch for ata_pio_task() error handling for your review.
Changes in the patch:
1. End the PIO task when PIO_ST_IDLE state is entered
2. End the PIO task after PIO_ST_TMOUT and PIO_ST_ERR state handled by ata_pio_error()
3. Remove the first "if" statement to handle the error condition returned from
ata_pio_block(), ata_pio_complete() and ata_pio_poll().
Change #2 is not so necessary since ata_pio_error() will put the cmd to PIO_ST_IDLE state after the error condition is handled. The change just saves a function call to queue_work().
Tested OK on on my machine with pdc20275 and ASUS CD-RW drive.
<[email protected]> (04/12/27 1.1556)
[libata] use PIO mode for request sense
<[email protected]> (04/12/27 1.1555)
[libata sata_uli] add 5281 support, fix SATA phy setup for others
Contributed by Peer Chen @ ULi and tested by a user.
<[email protected]> (04/12/27 1.1554)
[libata sata_nv] fix dev detect by removing sata-reset flag
Remove ATA_FLAG_SATA_RESET. See comment in code and
http://bugme.osdl.org/show_bug.cgi?id=3352 for more details.
This problem needs more investigation. Removing the flag appears to fix the problems in the field, so it's the best temporary solution.
drivers/scsi/libata-core.c +28 -18
@@ -28,6 +28,7 @@#include <linux/pci.h> #include <linux/init.h> #include <linux/list.h> +#include <linux/mm.h> #include <linux/highmem.h> #include <linux/spinlock.h> #include <linux/blkdev.h>
@@ -1918,7 +1919,24 @@if (idx) ap->prd[idx -1 ].flags_len |=cpu_to_le32 (ATA_PRD_EOT ); } +/** +* ata_check_atapi_dma - Check whether ATAPI DMA can be supported +* @qc: Metadata associated with taskfile to check +* +* LOCKING: +* RETURNS: 0 when ATAPI DMA can be used +* nonzero otherwise +*/ +int ata_check_atapi_dma (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +int rc =0 ;/* Assume ATAPI DMA is OK by default */ + +if (ap->ops->check_atapi_dma) + rc = ap->ops->check_atapi_dma (qc); +return rc; +}/** * ata_qc_prep - Prepare taskfile for submission * @qc: Metadata associated with taskfile to be prepared
@@ -2368,6 +2386,9 @@unsigned long timeout =0 ;switch (ap->pio_task_state) { +case PIO_ST_IDLE : +return ; +case PIO_ST :ata_pio_block (ap);break ;
@@ -2384,7 +2405,7 @@case PIO_ST_TMOUT :case PIO_ST_ERR :ata_pio_error (ap); -break ; +return ; }if (timeout) {
@@ -2392,11 +2413,7 @@schedule_timeout (timeout); } -if ((ap->pio_task_state !=PIO_ST_IDLE ) && - (ap->pio_task_state !=PIO_ST_TMOUT ) && - (ap->pio_task_state !=PIO_ST_ERR )) { -schedule_task (&ap->pio_task); - } +schedule_task (&ap->pio_task); } static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
@@ -2405,7 +2422,6 @@DECLARE_COMPLETION (wait);struct ata_queued_cmd *qc;unsigned long flags; -int using_pio = dev->flags &ATA_DFLAG_PIO ;int rc;DPRINTK ("ATAPI request sense\n" );
@@ -2426,16 +2442,10 @@ qc->tf.flags |=ATA_TFLAG_ISADDR |ATA_TFLAG_DEVICE ; qc->tf.command =ATA_CMD_PACKET ; -if (using_pio) { - qc->tf.protocol =ATA_PROT_ATAPI ; - qc->tf.lbam = (8 *1024 ) &0xff ; - qc->tf.lbah = (8 *1024 ) >>8 ; - - qc->nbytes =SCSI_SENSE_BUFFERSIZE ; - }else { - qc->tf.protocol =ATA_PROT_ATAPI_DMA ; - qc->tf.feature |=ATAPI_PKT_DMA ; - } + qc->tf.protocol =ATA_PROT_ATAPI ; + qc->tf.lbam = (8 *1024 ) &0xff ; + qc->tf.lbah = (8 *1024 ) >>8 ; + qc->nbytes =SCSI_SENSE_BUFFERSIZE ; qc->waiting = &wait; qc->complete_fn = ata_qc_complete_noop;
@@ -2707,7 +2717,7 @@return 1 ;/* fall through */ - +default :return 0 ; }
drivers/scsi/libata-scsi.c +5 -0
@@ -1256,6 +1256,11 @@int using_pio = (dev->flags &ATA_DFLAG_PIO );int nodata = (cmd->sc_data_direction ==SCSI_DATA_NONE ); +if (!using_pio) +/* Check whether ATAPI DMA is safe */ +if (ata_check_atapi_dma (qc)) + using_pio =1 ; +memcpy (&qc->cdb, scsicmd, qc->ap->cdb_len); qc->complete_fn = atapi_qc_complete;
drivers/scsi/libata.h +1 -0
@@ -38,6 +38,7 @@extern struct ata_queued_cmd *ata_qc_new_init (struct ata_port *ap,struct ata_device *dev);extern int ata_qc_issue (struct ata_queued_cmd *qc); +extern int ata_check_atapi_dma (struct ata_queued_cmd *qc);extern void ata_dev_select (struct ata_port *ap,unsigned int device,unsigned int wait,unsigned int can_sleep);extern void ata_tf_to_host_nolock (struct ata_port *ap,struct ata_taskfile *tf);
drivers/scsi/sata_nv.c +9 -1
@@ -219,10 +219,18 @@ .host_stop = nv_host_stop, }; +/* FIXME: The hardware provides the necessary SATA PHY controls +* to support ATA_FLAG_SATA_RESET. However, it is currently +* necessary to disable that flag, to solve misdetection problems. +* See http://bugme.osdl.org/show_bug.cgi?id=3352 for more info. +* +* This problem really needs to be investigated further. But in the +* meantime, we avoid ATA_FLAG_SATA_RESET to get people working. +*/ static struct ata_port_info nv_port_info = { .sht = &nv_sht, .host_flags =ATA_FLAG_SATA | -ATA_FLAG_SATA_RESET | +/* ATA_FLAG_SATA_RESET | */ ATA_FLAG_SRST |ATA_FLAG_NO_LEGACY , .pio_mask =NV_PIO_MASK ,
drivers/scsi/sata_uli.c +23 -28
113 lines not on this page · raw message
include/linux/libata.h +2 -0
@@ -340,6 +340,8 @@void (*phy_reset) (struct ata_port *ap);void (*post_set_mode) (struct ata_port *ap); +int (*check_atapi_dma) (struct ata_queued_cmd *qc); +void (*bmdma_setup) (struct ata_queued_cmd *qc);void (*bmdma_start) (struct ata_queued_cmd *qc);