libata patches for 2.6.30
Subsystems (3)
cover libata patches for 2.6.30
Just a small set but the libata stuff is fairly important
---
Alan Cox (4):
libata: Improve timeout handling
libata: Drain data on errors
pata_sc1200: Activate secondary channel
pata_artop: Serializing support
block/blk-settings.c | 2 - drivers/ata/libata-eh.c | 19 ++++++++- drivers/ata/libata-sff.c | 91 +++++++++++++++++++++++++++++++++++++++++++- drivers/ata/pata_artop.c | 33 +++++++++++++--- drivers/ata/pata_isapnp.c | 12 +++++- drivers/ata/pata_pcmcia.c | 34 ++++++++++++++++ drivers/ata/pata_sc1200.c | 29 +++++++++++++- drivers/ata/pdc_adma.c | 2 + drivers/ata/sata_mv.c | 2 + drivers/ata/sata_nv.c | 1 drivers/ata/sata_promise.c | 2 + drivers/ata/sata_qstor.c | 1 drivers/ata/sata_vsc.c | 3 + include/linux/libata.h | 5 ++ 14 files changed, 219 insertions(+), 17 deletions(-)
Signature · 2 lines
If this writing is visible please refill and remember to order a new box of signature files from your supplier
PATCH 1/4 pata_artop: Serializing support
From: Alan Cox <[email protected]>
Enable both ports on the 6210 and serialize them
---
block/blk-settings.c | 2 +- drivers/ata/pata_artop.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-)
block/blk-settings.c +1 -1
@@ -431,7 +431,7 @@ EXPORT_SYMBOL(blk_queue_segment_boundary);* * description: * set required memory and length alignment for direct dma transactions. -* this is used when buiding direct io requests for the queue. +* this is used when building direct io requests for the queue. * **/ void blk_queue_dma_alignment (struct request_queue *q,int mask)
drivers/ata/pata_artop.c +27 -6
@@ -12,7 +12,6 @@* performance Alessandro Zummo <[email protected]> * * TODO -* 850 serialization once the core supports it * Investigate no_dsc on 850R * Clock detect */
@@ -29,7 +28,7 @@#include <linux/ata.h> #define DRV_NAME "pata_artop" -#define DRV_VERSION "0.4.4" +#define DRV_VERSION "0.4.5"/* * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
@@ -283,6 +282,31 @@ static void artop6260_set_dmamode (struct ata_port *ap, struct ata_device *adev)pci_write_config_byte (pdev,0x44 + ap->port_no, ultra); } +/** +* artop_6210_qc_defer - implement serialization +* @qc: command +* +* Issue commands per host on this chip. +*/ + +static int artop6210_qc_defer (struct ata_queued_cmd *qc) +{ +struct ata_host *host = qc->ap->host; +struct ata_port *alt = host->ports[1 ^ qc->ap->port_no]; +int rc; + +/* First apply the usual rules */ + rc =ata_std_qc_defer (qc); +if (rc !=0 ) +return rc; + +/* Now apply serialization rules. Only allow a command if the +other channel state machine is idle */ +if (alt && alt->qc_active) +return ATA_DEFER_PORT ; +return 0 ; +} +static struct scsi_host_template artop_sht = {ATA_BMDMA_SHT (DRV_NAME ), };
@@ -293,6 +317,7 @@ static struct ata_port_operations artop6210_ops = { .set_piomode = artop6210_set_piomode, .set_dmamode = artop6210_set_dmamode, .prereset = artop6210_pre_reset, + .qc_defer = artop6210_qc_defer, };static struct ata_port_operations artop6260_ops = {
@@ -362,12 +387,8 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)if (id->driver_data ==0 ) {/* 6210 variant */ ppi[0 ] = &info_6210; - ppi[1 ] = &ata_dummy_port_info;/* BIOS may have left us in UDMA, clear it before libata probe */ pci_write_config_byte (pdev,0x54 ,0 ); -/* For the moment (also lacks dsc) */ -printk (KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n" ); -printk (KERN_WARNING "Secondary ATA ports will not be activated.\n" ); }else if (id->driver_data ==1 )/* 6260 */ ppi[0 ] = &info_626x;
Re: [PATCH 1/4] pata_artop: Serializing support
Quoted 8 lines · Alan Cox
From: Alan Cox <[email protected]>
Enable both ports on the 6210 and serialize them
Signed-off-by Alan Cox <[email protected]>---
block/blk-settings.c | 2 +-
applied 1-2, after removing the block/* comment changes (not my area)
PATCH 2/4 pata_sc1200: Activate secondary channel
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Implement serialize and turn on slave channel
---
drivers/ata/pata_sc1200.c | 29 +++++++++++++++++++++++++++-- 1 files changed, 27 insertions(+), 2 deletions(-)
drivers/ata/pata_sc1200.c +27 -2
@@ -2,7 +2,6 @@* New ATA layer SC1200 driver Alan Cox <[email protected]> * * TODO: Mode selection filtering -* TODO: Can't enable second channel until ATA core has serialize * TODO: Needs custom DMA cleanup code * * Based very heavily on
@@ -178,6 +177,31 @@ static unsigned int sc1200_qc_issue(struct ata_queued_cmd *qc)return ata_sff_qc_issue (qc); } +/** +* sc1200_qc_defer - implement serialization +* @qc: command +* +* Serialize command issue on this controller. +*/ + +static int sc1200_qc_defer (struct ata_queued_cmd *qc) +{ +struct ata_host *host = qc->ap->host; +struct ata_port *alt = host->ports[1 ^ qc->ap->port_no]; +int rc; + +/* First apply the usual rules */ + rc =ata_std_qc_defer (qc); +if (rc !=0 ) +return rc; + +/* Now apply serialization rules. Only allow a command if the +other channel state machine is idle */ +if (alt && alt->qc_active) +return ATA_DEFER_PORT ; +return 0 ; +} +static struct scsi_host_template sc1200_sht = {ATA_BMDMA_SHT (DRV_NAME ), .sg_tablesize =LIBATA_DUMB_MAX_PRD ,
@@ -187,6 +211,7 @@ static struct ata_port_operations sc1200_port_ops = { .inherits = &ata_bmdma_port_ops, .qc_prep = ata_sff_dumb_qc_prep, .qc_issue = sc1200_qc_issue, + .qc_defer = sc1200_qc_defer, .cable_detect = ata_cable_40wire, .set_piomode = sc1200_set_piomode, .set_dmamode = sc1200_set_dmamode,
@@ -211,7 +236,7 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &sc1200_port_ops };/* Can't enable port 2 yet, see top comments */ -const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; +const struct ata_port_info *ppi[] = { &info, };return ata_pci_sff_init_one (dev, ppi, &sc1200_sht,NULL ); }
PATCH 3/4 libata: Drain data on errors
In reply to Alan CoxFrom: Alan Cox <[email protected]>
If the device is signalling that there is data to drain after an error we should read the bytes out and throw them away. Without this some devices and controllers get wedged and don't recover.
Based on earlier work by Mark Lord
---
drivers/ata/libata-sff.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- drivers/ata/pata_pcmcia.c | 34 +++++++++++++++++++++++++++++++++- include/linux/libata.h | 3 +++ 3 files changed, 79 insertions(+), 3 deletions(-)
drivers/ata/libata-sff.c +43 -2
@@ -52,6 +52,7 @@ const struct ata_port_operations ata_sff_port_ops = { .softreset = ata_sff_softreset, .hardreset = sata_sff_hardreset, .postreset = ata_sff_postreset, + .drain_fifo = ata_sff_drain_fifo, .error_handler = ata_sff_error_handler, .post_internal_cmd = ata_sff_post_internal_cmd,
@@ -2199,6 +2200,39 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes)EXPORT_SYMBOL_GPL (ata_sff_postreset);/** +* ata_sff_drain_fifo - Stock FIFO drain logic for SFF controllers +* @qc: command +* +* Drain the FIFO and device of any stuck data following a command +* failing to complete. In some cases this is neccessary before a +* reset will recover the device. +* +*/ + +void ata_sff_drain_fifo (struct ata_queued_cmd *qc) +{ +int count; +struct ata_port *ap; + +/* We only need to flush incoming data when a command was running */ +if (qc ==NULL || qc->dma_dir ==DMA_TO_DEVICE ) +return ; + + ap = qc->ap; +/* Drain up to 64K of data before we give up this recovery method */ +for (count =0 ; (ap->ops->sff_check_status (ap) &ATA_DRQ ) + && count <32768 ; count++) +ioread16 (ap->ioaddr.data_addr); + +/* Can become DEBUG later */ +if (count) +ata_port_printk (ap,KERN_DEBUG , +"drained %d bytes to clear DRQ.\n" , count); + +} +EXPORT_SYMBOL_GPL (ata_sff_drain_fifo); + +/** * ata_sff_error_handler - Stock error handler for BMDMA controller * @ap: port to handle error for *
@@ -2239,7 +2273,8 @@ void ata_sff_error_handler(struct ata_port *ap)* really a timeout event, adjust error mask and * cancel frozen state. */ -if (qc->err_mask ==AC_ERR_TIMEOUT && (host_stat &ATA_DMA_ERR )) { +if (qc->err_mask ==AC_ERR_TIMEOUT + && (host_stat &ATA_DMA_ERR )) { qc->err_mask =AC_ERR_HOST_BUS ; thaw =1 ; }
@@ -2250,6 +2285,13 @@ void ata_sff_error_handler(struct ata_port *ap)ata_sff_sync (ap);/* FIXME: We don't need this */ ap->ops->sff_check_status (ap); ap->ops->sff_irq_clear (ap); +/* We *MUST* do FIFO draining before we issue a reset as several +* devices helpfully clear their internal state and will lock solid +* if we touch the data port post reset. Pass qc in case anyone wants +* to do different PIO/DMA recovery or has per command fixups +*/ +if (ap->ops->drain_fifo) + ap->ops->drain_fifo (qc);spin_unlock_irqrestore (ap->lock, flags);
@@ -2959,4 +3001,3 @@ out:EXPORT_SYMBOL_GPL (ata_pci_sff_init_one);#endif /* CONFIG_PCI */ -
drivers/ata/pata_pcmcia.c +33 -1
@@ -42,7 +42,7 @@#define DRV_NAME "pata_pcmcia" -#define DRV_VERSION "0.3.3" +#define DRV_VERSION "0.3.5"/* * Private data structure to glue stuff together
@@ -126,6 +126,37 @@ static unsigned int ata_data_xfer_8bit(struct ata_device *dev,return buflen; } +/** +* pcmcia_8bit_drain_fifo - Stock FIFO drain logic for SFF controllers +* @qc: command +* +* Drain the FIFO and device of any stuck data following a command +* failing to complete. In some cases this is neccessary before a +* reset will recover the device. +* +*/ + +void pcmcia_8bit_drain_fifo (struct ata_queued_cmd *qc) +{ +int count; +struct ata_port *ap; + +/* We only need to flush incoming data when a command was running */ +if (qc ==NULL || qc->dma_dir ==DMA_TO_DEVICE ) +return ; + + ap = qc->ap; + +/* Drain up to 64K of data before we give up this recovery method */ +for (count =0 ; (ap->ops->sff_check_status (ap) &ATA_DRQ ) + && count++ <65536 ;) +ioread8 (ap->ioaddr.data_addr); + +if (count) +ata_port_printk (ap,KERN_WARNING ,"drained %d bytes to clear DRQ.\n" , + count); + +}static struct scsi_host_template pcmcia_sht = {ATA_PIO_SHT (DRV_NAME ),
@@ -143,6 +174,7 @@ static struct ata_port_operations pcmcia_8bit_port_ops = { .sff_data_xfer = ata_data_xfer_8bit, .cable_detect = ata_cable_40wire, .set_mode = pcmcia_set_mode_8bit, + .drain_fifo = pcmcia_8bit_drain_fifo, };#define CS_CHECK (fn, ret) \
include/linux/libata.h +3 -0
@@ -836,6 +836,8 @@ struct ata_port_operations {void (*bmdma_start)(struct ata_queued_cmd *qc);void (*bmdma_stop)(struct ata_queued_cmd *qc);u8 (*bmdma_status)(struct ata_port *ap); + +void (*drain_fifo)(struct ata_queued_cmd *qc);#endif /* CONFIG_ATA_SFF */ ssize_t (*em_show)(struct ata_port *ap,char *buf);
@@ -1584,6 +1586,7 @@ extern int ata_sff_softreset(struct ata_link *link, unsigned int *classes,extern int sata_sff_hardreset (struct ata_link *link,unsigned int *class,unsigned long deadline);extern void ata_sff_postreset (struct ata_link *link,unsigned int *classes); +extern void ata_sff_drain_fifo (struct ata_queued_cmd *qc);extern void ata_sff_error_handler (struct ata_port *ap);extern void ata_sff_post_internal_cmd (struct ata_queued_cmd *qc);extern int ata_sff_port_start (struct ata_port *ap);
Jeff Garzik
AppliedRe: [PATCH 3/4] libata: Drain data on errors
Quoted 8 lines · Alan Cox
From: Alan Cox <[email protected]>
If the device is signalling that there is data to drain after an error we should read the bytes out and throw them away. Without this some devices and controllers get wedged and don't recover.
Based on earlier work by Mark Lord
Quoted 7 lines
Signed-off-by Alan Cox <[email protected]>---
drivers/ata/libata-sff.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- drivers/ata/pata_pcmcia.c | 34 +++++++++++++++++++++++++++++++++- include/linux/libata.h | 3 +++ 3 files changed, 79 insertions(+), 3 deletions(-)
applied
PATCH 4/4 libata: Improve timeout handling
In reply to Alan CoxFrom: Alan Cox <[email protected]>
On a timeout call a device specific handler early in the recovery so that we can complete and process successful commands which timed out due to IRQ loss or the like rather more elegantly.
[Revised to exclude the timeout handling on a few devices that inherit from
SFF but are not SFF enough to use the default timeout handler]
---
drivers/ata/libata-eh.c | 19 ++++++++++++++++-- drivers/ata/libata-sff.c | 46 +++++++++++++++++++++++++++++++++++++++++++- drivers/ata/pata_isapnp.c | 12 ++++++++++- drivers/ata/pdc_adma.c | 2 ++ drivers/ata/sata_mv.c | 2 ++ drivers/ata/sata_nv.c | 1 + drivers/ata/sata_promise.c | 2 ++ drivers/ata/sata_qstor.c | 1 + drivers/ata/sata_vsc.c | 3 +++ include/linux/libata.h | 2 ++ 10 files changed, 85 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +17 -2
@@ -547,7 +547,7 @@ void ata_scsi_error(struct Scsi_Host *host)/* For new EH, all qcs are finished in one of three ways - * normal completion, error completion, and SCSI timeout. -* Both cmpletions can race against SCSI timeout. When normal +* Both completions can race against SCSI timeout. When normal * completion wins, the qc never reaches EH. When error * completion wins, the qc has ATA_QCFLAG_FAILED set. *
@@ -562,7 +562,19 @@ void ata_scsi_error(struct Scsi_Host *host)int nr_timedout =0 ;spin_lock_irqsave (ap->lock, flags); - + +/* This must occur under the ap->lock as we don't want +a polled recovery to race the real interrupt handler ++ The lost_interrupt handler checks for any completed but +non-notified command and completes much like an IRQ handler. ++ We then fall into the error recovery code which will treat +this as if normal completion won the race */ + +if (ap->ops->lost_interrupt) + ap->ops->lost_interrupt (ap); +list_for_each_entry_safe (scmd, tmp, &host->eh_cmd_q, eh_entry) {struct ata_queued_cmd *qc;
@@ -606,6 +618,9 @@ void ata_scsi_error(struct Scsi_Host *host) ap->eh_tries =ATA_EH_MAX_TRIES ; }else spin_unlock_wait (ap->lock); + +/* If we timed raced normal completion and there is nothing to +recover nr_timedout == 0 why exactly are we doing error recovery ? */ repeat:/* invoke error handler */
drivers/ata/libata-sff.c +45 -1
64 lines not on this page · raw message
drivers/ata/pata_isapnp.c +10 -2
@@ -17,7 +17,7 @@#include <linux/libata.h> #define DRV_NAME "pata_isapnp" -#define DRV_VERSION "0.2.2" +#define DRV_VERSION "0.2.5"static struct scsi_host_template isapnp_sht = {ATA_PIO_SHT (DRV_NAME ),
@@ -28,6 +28,13 @@ static struct ata_port_operations isapnp_port_ops = { .cable_detect = ata_cable_40wire, }; +static struct ata_port_operations isapnp_noalt_port_ops = { + .inherits = &ata_sff_port_ops, + .cable_detect = ata_cable_40wire, +/* No altstatus so we don't want to use the lost interrupt poll */ + .lost_interrupt =ATA_OP_NULL , +}; +/** * isapnp_init_one - attach an isapnp interface * @idev: PnP device
@@ -65,7 +72,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev ap = host->ports[0 ]; - ap->ops = &isapnp_port_ops; + ap->ops = &isapnp_noalt_port_ops; ap->pio_mask =1 ; ap->flags |=ATA_FLAG_SLAVE_POSS ;
@@ -76,6 +83,7 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev pnp_port_start(idev, 1), 1); ap->ioaddr.altstatus_addr = ctl_addr; ap->ioaddr.ctl_addr = ctl_addr; + ap->ops = &isapnp_port_ops; }ata_sff_std_ports (&ap->ioaddr);
drivers/ata/pdc_adma.c +2 -0
@@ -148,6 +148,8 @@ static struct scsi_host_template adma_ata_sht = {static struct ata_port_operations adma_ata_ops = { .inherits = &ata_sff_port_ops, + .lost_interrupt =ATA_OP_NULL , + .check_atapi_dma = adma_check_atapi_dma, .qc_prep = adma_qc_prep, .qc_issue = adma_qc_issue,
drivers/ata/sata_mv.c +2 -0
@@ -566,6 +566,8 @@ static struct scsi_host_template mv6_sht = {static struct ata_port_operations mv5_ops = { .inherits = &ata_sff_port_ops, + .lost_interrupt =ATA_OP_NULL , + .qc_defer = mv_qc_defer, .qc_prep = mv_qc_prep, .qc_issue = mv_qc_issue,
drivers/ata/sata_nv.c +1 -0
@@ -408,6 +408,7 @@ static struct scsi_host_template nv_swncq_sht = {static struct ata_port_operations nv_common_ops = { .inherits = &ata_bmdma_port_ops, + .lost_interrupt =ATA_OP_NULL , .scr_read = nv_scr_read, .scr_write = nv_scr_write, };
drivers/ata/sata_promise.c +2 -0
@@ -176,7 +176,9 @@ static const struct ata_port_operations pdc_common_ops = { .check_atapi_dma = pdc_check_atapi_dma, .qc_prep = pdc_qc_prep, .qc_issue = pdc_qc_issue, + .sff_irq_clear = pdc_irq_clear, + .lost_interrupt = ATA_OP_NULL, .post_internal_cmd = pdc_post_internal_cmd, .error_handler = pdc_error_handler,
drivers/ata/sata_qstor.c +1 -0
@@ -147,6 +147,7 @@ static struct ata_port_operations qs_ata_ops = { .softreset = ATA_OP_NULL, .error_handler = qs_error_handler, .post_internal_cmd = ATA_OP_NULL, + .lost_interrupt = ATA_OP_NULL, .scr_read = qs_scr_read, .scr_write = qs_scr_write,
drivers/ata/sata_vsc.c +3 -0
@@ -308,6 +308,9 @@ static struct scsi_host_template vsc_sata_sht = {static struct ata_port_operations vsc_sata_ops = { .inherits = &ata_bmdma_port_ops, +/* The IRQ handling is not quite standard SFF behaviour so we +cannot use the default lost interrupt handler */ + .lost_interrupt =ATA_OP_NULL , .sff_tf_load = vsc_sata_tf_load, .sff_tf_read = vsc_sata_tf_read, .freeze = vsc_freeze,
include/linux/libata.h +2 -0
@@ -795,6 +795,7 @@ struct ata_port_operations {ata_reset_fn_t pmp_hardreset;ata_postreset_fn_t pmp_postreset;void (*error_handler)(struct ata_port *ap); +void (*lost_interrupt)(struct ata_port *ap);void (*post_internal_cmd)(struct ata_queued_cmd *qc);/*
@@ -1574,6 +1575,7 @@ extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);extern unsigned int ata_sff_host_intr (struct ata_port *ap,struct ata_queued_cmd *qc);extern irqreturn_t ata_sff_interrupt (int irq,void *dev_instance); +extern void ata_sff_lost_interrupt (struct ata_port *ap);extern void ata_sff_freeze (struct ata_port *ap);extern void ata_sff_thaw (struct ata_port *ap);extern int ata_sff_prereset (struct ata_link *link,unsigned long deadline);
Jeff Garzik
AppliedRe: [PATCH 4/4] libata: Improve timeout handling
Quoted 10 lines · Alan Cox
From: Alan Cox <[email protected]>
On a timeout call a device specific handler early in the recovery so that we can complete and process successful commands which timed out due to IRQ loss or the like rather more elegantly.
[Revised to exclude the timeout handling on a few devices that inherit from
SFF but are not SFF enough to use the default timeout handler]Signed-off-by Alan Cox <[email protected]>
applied
let's see what explodes! :)