2.6.x libata fixes and updates
PATCH 1/1 2.6.x libata fixes and updates
There are some more core changes coming, but I wanted to push this out since it appears to address a problem a couple lkml users were seeing.
Tested on ich5, silicon image, promise and via.
Please do a
bk pull bk://gkernel.bkbits.net/libata-2.6
This will update the following files:
drivers/scsi/ata_piix.c | 6 + drivers/scsi/libata-core.c | 134 +++++++++++++++++++++++--------------------- drivers/scsi/libata-scsi.c | 29 +++++++++ drivers/scsi/sata_nv.c | 2 drivers/scsi/sata_promise.c | 49 +++++++++++----- drivers/scsi/sata_sil.c | 3 drivers/scsi/sata_sis.c | 2 drivers/scsi/sata_svw.c | 2 drivers/scsi/sata_sx4.c | 15 ++++ drivers/scsi/sata_via.c | 3 drivers/scsi/sata_vsc.c | 2 include/linux/ata.h | 10 ++- include/linux/libata.h | 31 ++++++++-- 13 files changed, 206 insertions(+), 82 deletions(-)
through these ChangeSets:
<[email protected]> (04/07/04 1.1792)
[libata sata_promise] update driver to use new ->qc_issue hook
The ->qc_issue hook was designed to allow drivers to override some or all of the actual delivery of the taskfile to hardware.
In the case of Promise, the hardware has its own packet format when doing read/write DMA commands, but uses traditional ATA taskfile registers for other types of commands.
<[email protected]> (04/07/04 1.1791)
[libata] create, and use aga_sg_init[_one] helpers
Move more SCSI-specific code out of libata core.
<[email protected]> (04/07/04 1.1790)
[libata] split ATA_QCFLAG_SG into ATA_QCFLAG_{SG,SINGLE}
In part of the effort to remove SCSI specifics from the libata internals, remove references to cmd->use_sg. cmd->use_sg becomes ATA_QCFLAG_SG, and !cmd->use_sg becomes ATA_QCFLAG_SINGLE.
Convenience constant ATA_QCFLAG_DMAMAP is created when the programmer wishes to refer collectively to ATA_QCFLAG_{SG,SINGLE}.
<[email protected]> (04/07/03 1.1789)
[ata] add ata_ok() inlined helper, and ATA_{DRDY,DF} bit to linux/ata.h
<[email protected]> (04/07/03 1.1788)
[libata] create, and use, ->irq_clear hook
This is more conservative in general, and so applies to multiple controllers. Specifically it attempts to address irq-related issues on the Intel ICH5/6 hardware. On Intel ICH5/6, the BMDMA 'interrupt' status bit will be set even on non-DMA commands, which software (and I) did not expect.
This change clears pending interrupts once upon initialization, and then each time ata_irq_on() is called.
<[email protected]> (04/07/03 1.1787)
[libata sata_sil] add drive to mod15write quirk list
<[email protected]> (04/07/03 1.1786)
[libata] add ata_queued_cmd completion hook
<[email protected]> (04/07/03 1.1785)
[libata] add ->qc_issue hook
This hook is used when an ATA controller wishes to use hardware-specific methods of taskfile delivery, rather than the standard method of bitbanging the ATA shadow registers.
drivers/scsi/ata_piix.c +6 -0
@@ -138,9 +138,12 @@ .bmdma_setup = ata_bmdma_setup_pio, .bmdma_start = ata_bmdma_start_pio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, + .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .port_start = ata_port_start, .port_stop = ata_port_stop,
@@ -161,9 +164,12 @@ .bmdma_setup = ata_bmdma_setup_pio, .bmdma_start = ata_bmdma_start_pio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, + .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .port_start = ata_port_start, .port_stop = ata_port_stop,
drivers/scsi/libata-core.c +73 -61
288 lines not on this page · raw message
drivers/scsi/libata-scsi.c +28 -1
@@ -335,6 +335,24 @@return 1 ; } +static int ata_scsi_qc_complete (struct ata_queued_cmd *qc,u8 drv_stat) +{ +struct scsi_cmnd *cmd = qc->scsicmd; + +if (unlikely (drv_stat & (ATA_ERR |ATA_BUSY |ATA_DRQ ))) { +if (is_atapi_taskfile (&qc->tf)) + cmd->result =SAM_STAT_CHECK_CONDITION ; +else +ata_to_sense_error (qc); + }else { + cmd->result =SAM_STAT_GOOD ; + } + + qc->scsidone (cmd); + +return 0 ; +} +/** * ata_scsi_translate - Translate then issue SCSI command to ATA device * @ap: ATA port to which the command is addressed
@@ -368,6 +386,7 @@if (!qc)return ; +/* data is present; dma-map it */ if (cmd->sc_data_direction ==SCSI_DATA_READ || cmd->sc_data_direction ==SCSI_DATA_WRITE ) {if (unlikely (cmd->request_bufflen <1 )) {
@@ -376,8 +395,16 @@ goto err_out; } - qc->flags |=ATA_QCFLAG_SG ;/* data is present; dma-map it */ +if (cmd->use_sg) +ata_sg_init (qc, cmd->request_buffer, cmd->use_sg); +else +ata_sg_init_one (qc, cmd->request_buffer, + cmd->request_bufflen); + + qc->pci_dma_dir =scsi_to_pci_dma_dir (cmd->sc_data_direction); } + + qc->complete_fn = ata_scsi_qc_complete;if (xlat_func (qc, scsicmd)) goto err_out;
drivers/scsi/sata_nv.c +2 -0
@@ -139,8 +139,10 @@ .bmdma_setup = ata_bmdma_setup_pio, .bmdma_start = ata_bmdma_start_pio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = ata_eng_timeout, .irq_handler = nv_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = nv_scr_read, .scr_write = nv_scr_write, .port_start = ata_port_start,
drivers/scsi/sata_promise.c +35 -14
95 lines not on this page · raw message
drivers/scsi/sata_sil.c +3 -0
@@ -86,6 +86,7 @@ { "ST360015AS", SIL_QUIRK_MOD15WRITE }, { "ST380023AS", SIL_QUIRK_MOD15WRITE }, { "ST3120023AS", SIL_QUIRK_MOD15WRITE }, + { "ST3160023AS", SIL_QUIRK_MOD15WRITE }, { "ST340014ASL", SIL_QUIRK_MOD15WRITE }, { "ST360014ASL", SIL_QUIRK_MOD15WRITE }, { "ST380011ASL", SIL_QUIRK_MOD15WRITE },
@@ -132,8 +133,10 @@ .bmdma_setup = ata_bmdma_setup_mmio, .bmdma_start = ata_bmdma_start_mmio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = sil_scr_read, .scr_write = sil_scr_write, .port_start = ata_port_start,
drivers/scsi/sata_sis.c +2 -0
@@ -101,8 +101,10 @@ .bmdma_setup = ata_bmdma_setup_pio, .bmdma_start = ata_bmdma_start_pio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = sis_scr_read, .scr_write = sis_scr_write, .port_start = ata_port_start,
drivers/scsi/sata_svw.c +2 -0
@@ -234,8 +234,10 @@ .bmdma_setup = ata_bmdma_setup_mmio, .bmdma_start = ata_bmdma_start_mmio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = k2_sata_scr_read, .scr_write = k2_sata_scr_write, .port_start = ata_port_start,
drivers/scsi/sata_sx4.c +14 -1
@@ -171,6 +171,7 @@#endif static void pdc20621_put_to_dimm (struct ata_probe_ent *pe,void *psource,u32 offset,u32 size); +static void pdc20621_irq_clear (struct ata_port *ap);static Scsi_Host_Template pdc_sata_sht = {
@@ -201,8 +202,10 @@ .bmdma_setup = pdc20621_dma_setup, .bmdma_start = pdc20621_dma_start, .qc_prep = pdc20621_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = pdc_eng_timeout, .irq_handler = pdc20621_interrupt, + .irq_clear = pdc20621_irq_clear, .port_start = pdc_port_start, .port_stop = pdc_port_stop, .host_stop = pdc20621_host_stop,
@@ -446,7 +449,7 @@unsigned int i, last, idx, total_len =0 , sgt_len;u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ ]; -if (!(qc->flags &ATA_QCFLAG_SG )) +if (!(qc->flags &ATA_QCFLAG_DMAMAP ))return ;VPRINTK ("ata%u: ENTER\n" , ap->id);
@@ -700,6 +703,16 @@ }return handled; +} + +static void pdc20621_irq_clear (struct ata_port *ap) +{ +struct ata_host_set *host_set = ap->host_set; +void *mmio = host_set->mmio_base; + + mmio +=PDC_CHIP0_OFS ; + +readl (mmio +PDC_20621_SEQMASK ); }static irqreturn_t pdc20621_interrupt (int irq,void *dev_instance,struct pt_regs *regs)
drivers/scsi/sata_via.c +3 -0
@@ -109,9 +109,12 @@ .bmdma_setup = ata_bmdma_setup_pio, .bmdma_start = ata_bmdma_start_pio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, + .eng_timeout = ata_eng_timeout, .irq_handler = ata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = svia_scr_read, .scr_write = svia_scr_write,
drivers/scsi/sata_vsc.c +2 -0
@@ -216,8 +216,10 @@ .bmdma_setup = ata_bmdma_setup_mmio, .bmdma_start = ata_bmdma_start_mmio, .qc_prep = ata_qc_prep, + .qc_issue = ata_qc_issue_prot, .eng_timeout = ata_eng_timeout, .irq_handler = vsc_sata_interrupt, + .irq_clear = ata_bmdma_irq_clear, .scr_read = vsc_sata_scr_read, .scr_write = vsc_sata_scr_write, .port_start = ata_port_start,
include/linux/ata.h +9 -1
@@ -78,9 +78,11 @@ATA_NIEN = (1 <<1 ),/* disable-irq flag */ ATA_LBA = (1 <<6 ),/* LBA28 selector */ ATA_DEV1 = (1 <<4 ),/* Select Device 1 (slave) */ -ATA_BUSY = (1 <<7 ),/* BSY status bit */ ATA_DEVICE_OBS = (1 <<7 ) | (1 <<5 ),/* obs bits in dev reg */ ATA_DEVCTL_OBS = (1 <<3 ),/* obsolete bit in devctl reg */ +ATA_BUSY = (1 <<7 ),/* BSY status bit */ +ATA_DRDY = (1 <<6 ),/* device ready */ +ATA_DF = (1 <<5 ),/* device fault */ ATA_DRQ = (1 <<3 ),/* data request i/o */ ATA_ERR = (1 <<0 ),/* have an error */ ATA_SRST = (1 << 2), /* software reset */
@@ -222,6 +224,12 @@ {return (tf->protocol ==ATA_PROT_ATAPI ) || (tf->protocol ==ATA_PROT_ATAPI_DMA ); +} + +static inline int ata_ok (u8 status) +{ +return ((status & (ATA_BUSY |ATA_DRDY |ATA_DF |ATA_DRQ |ATA_ERR )) + ==ATA_DRDY ); }#endif /* __LINUX_ATA_H__ */
include/linux/libata.h +27 -4
@@ -112,7 +112,9 @@ATA_QCFLAG_ACTIVE = (1 <<1 ),/* cmd not yet ack'd to scsi lyer */ ATA_QCFLAG_DMA = (1 <<2 ),/* data delivered via DMA */ -ATA_QCFLAG_SG = (1 <<4 ),/* have s/g table? */ +ATA_QCFLAG_SG = (1 <<3 ),/* have s/g table? */ +ATA_QCFLAG_SINGLE = (1 <<4 ),/* no s/g, just a single buffer */ +ATA_QCFLAG_DMAMAP =ATA_QCFLAG_SG |ATA_QCFLAG_SINGLE ,/* various lengths of time */ ATA_TMOUT_EDD = 5 * HZ, /* hueristic */
@@ -158,7 +160,7 @@struct ata_queued_cmd ;/* typedefs */ -typedef void (*ata_qc_cb_t ) (struct ata_queued_cmd *qc,unsigned int flags); +typedef int (*ata_qc_cb_t ) (struct ata_queued_cmd *qc,u8 drv_stat);struct ata_ioports {unsigned long cmd_addr;
@@ -202,6 +204,7 @@void *mmio_base;unsigned int n_ports;void *private_data; +struct ata_port_operations *ops;struct ata_port * ports[0 ]; };
@@ -215,16 +218,21 @@unsigned long flags;/* ATA_QCFLAG_xxx */ unsigned int tag;unsigned int n_elem; + +int pci_dma_dir; +unsigned int nsect;unsigned int cursect;unsigned int cursg;unsigned int cursg_ofs; +struct ata_taskfile tf;struct scatterlist sgent; +void *buf_virt;struct scatterlist *sg; -ata_qc_cb_t callback; +ata_qc_cb_t complete_fn;struct completion *waiting;
@@ -311,10 +319,14 @@void (*bmdma_setup) (struct ata_queued_cmd *qc);void (*bmdma_start) (struct ata_queued_cmd *qc); +void (*qc_prep) (struct ata_queued_cmd *qc); +int (*qc_issue) (struct ata_queued_cmd *qc); +void (*eng_timeout) (struct ata_port *ap);irqreturn_t (*irq_handler)(int ,void *,struct pt_regs *); +void (*irq_clear) (struct ata_port *);u32 (*scr_read) (struct ata_port *ap,unsigned int sc_reg); void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
@@ -372,12 +384,18 @@extern void ata_port_stop (struct ata_port *ap);extern irqreturn_t ata_interrupt (int irq,void *dev_instance,struct pt_regs *regs);extern void ata_qc_prep (struct ata_queued_cmd *qc); +extern int ata_qc_issue_prot (struct ata_queued_cmd *qc); +extern void ata_sg_init_one (struct ata_queued_cmd *qc,void *buf, +unsigned int buflen); +extern void ata_sg_init (struct ata_queued_cmd *qc,struct scatterlist *sg, +unsigned int n_elem);extern void ata_dev_id_string (struct ata_device *dev,unsigned char *s,unsigned int ofs,unsigned int len);extern void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc);extern void ata_bmdma_start_mmio (struct ata_queued_cmd *qc);extern void ata_bmdma_setup_pio (struct ata_queued_cmd *qc);extern void ata_bmdma_start_pio (struct ata_queued_cmd *qc); +extern void ata_bmdma_irq_clear (struct ata_port *ap);extern int pci_test_config_bits (struct pci_dev *pdev,struct pci_bits *bits);extern void ata_qc_complete (struct ata_queued_cmd *qc,u8 drv_stat);extern void ata_eng_timeout (struct ata_port *ap);
@@ -480,6 +498,7 @@static inline u8 ata_irq_on (struct ata_port *ap) {struct ata_ioports *ioaddr = &ap->ioaddr; +u8 tmp; ap->ctl &= ~ATA_NIEN ; ap->last_ctl = ap->ctl;
@@ -488,7 +507,11 @@writeb (ap->ctl, ioaddr->ctl_addr); else outb(ap->ctl, ioaddr->ctl_addr); -return ata_wait_idle (ap); + tmp =ata_wait_idle (ap); + + ap->ops->irq_clear (ap); + +return tmp; }static inline u8 ata_irq_ack (struct ata_port *ap,unsigned int chk_drq)