libata fixes
Subsystems (3)
PATCH 1/2 libata fixes
"real" fixes, and checkpatch fixes.
Please pull from 'upstream-linus' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream-linus
to receive the following updates:
drivers/ata/ahci.c | 17 ++--- drivers/ata/libata-core.c | 146 +++++++++++++++++++++++--------- drivers/ata/libata-eh.c | 25 +++++- drivers/ata/libata-scsi.c | 23 ----- drivers/ata/pata_acpi.c | 4 +- drivers/ata/pata_ns87415.c | 2 + drivers/ata/pata_optidma.c | 2 +- drivers/ata/pata_pcmcia.c | 12 ++-- drivers/ata/pata_pdc2027x.c | 2 +- drivers/ata/pata_pdc202xx_old.c | 4 +- drivers/ata/pata_scc.c | 13 +--- drivers/ata/pata_via.c | 2 +- drivers/ata/pata_winbond.c | 2 +- drivers/ata/pdc_adma.c | 12 ++-- drivers/ata/sata_inic162x.c | 4 +- drivers/ata/sata_mv.c | 7 +- drivers/ata/sata_nv.c | 120 ++++++++++++++------------ drivers/ata/sata_promise.c | 38 +++++---- drivers/ata/sata_qstor.c | 3 +- drivers/ata/sata_sil.c | 11 ++- drivers/ata/sata_sil24.c | 9 +- drivers/ata/sata_sis.c | 64 ++++++++------- drivers/ata/sata_svw.c | 10 +- drivers/ata/sata_sx4.c | 177 ++++++++++++++++++++------------------- drivers/ata/sata_uli.c | 18 ++-- drivers/ata/sata_via.c | 20 ++-- drivers/ata/sata_vsc.c | 15 ++-- include/linux/ata.h | 1 + include/linux/libata.h | 9 ++ 29 files changed, 432 insertions(+), 340 deletions(-)
Frank Lichtenheld (1):
pata_ns87415: define SUPERIO_IDE_MAX_RETRIES
Jeff Garzik (4):
[libata] fix 'if(' and similar areas that lack whitespace [libata] Address some checkpatch-spotted issues [libata] sata_nv: fix SWNCQ enabling
[libata] AHCI: fix newly introduced host-reset bug
Tejun Heo (6):
libata: relocate and fix post-command processing
libata: track SLEEP state and issue SRST to wake it up
libata: implement ata_wait_after_reset()
libata: relocate forcing PIO0 on reset
libata: no need to speed down if already at PIO0
libata: add MAXTOR 7V300F0/VA111900 to NCQ blacklist
drivers/ata/ahci.c +6 -11
@@ -898,8 +898,10 @@ static int ahci_reset_controller(struct ata_host *host)* AHCI-specific, such as HOST_RESET. */ tmp =readl (mmio +HOST_CTL ); -if (!(tmp &HOST_AHCI_EN )) -writel (tmp |HOST_AHCI_EN , mmio +HOST_CTL ); +if (!(tmp &HOST_AHCI_EN )) { + tmp |=HOST_AHCI_EN ; +writel (tmp, mmio +HOST_CTL ); + }/* global controller reset */ if ((tmp &HOST_RESET ) ==0 ) {
@@ -1153,15 +1155,8 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class, tf.ctl &= ~ATA_SRST ;ahci_exec_polled_cmd (ap, pmp, &tf,0 ,0 ,0 ); -/* spec mandates ">= 2ms" before checking status. -* We wait 150ms, because that was the magic delay used for -* ATAPI devices in Hale Landis's ATADRVR, for the period of time -* between when the ATA command register is written, and then -* status is checked. Because waiting for "a while" before -* checking status is fine, post SRST, we perform this magic -* delay here as well. -*/ -msleep (150 ); +/* wait a while before checking status */ +ata_wait_after_reset (ap, deadline); rc =ata_wait_ready (ap, deadline);/* link occupied, -ENODEV too is an error */
drivers/ata/libata-core.c +106 -40
212 lines not on this page · raw message
drivers/ata/libata-eh.c +23 -2
@@ -2083,6 +2083,25 @@ int ata_eh_reset(struct ata_link *link, int classify,ata_eh_about_to_do (link,NULL , ehc->i.action &ATA_EH_RESET_MASK ); +ata_link_for_each_dev (dev, link) { +/* If we issue an SRST then an ATA drive (not ATAPI) +* may change configuration and be in PIO0 timing. If +* we do a hard reset (or are coming from power on) +* this is true for ATA or ATAPI. Until we've set a +* suitable controller mode we should not touch the +* bus as we may be talking too fast. +*/ + dev->pio_mode =XFER_PIO_0 ; + +/* If the controller has a pio mode setup function +* then use it to set the chipset to rights. Don't +* touch the DMA setup as that will be dealt with when +* configuring devices. +*/ +if (ap->ops->set_piomode) + ap->ops->set_piomode (ap, dev); + } +/* Determine which reset to use and record in ehc->i.action. * prereset() may examine and modify it. */
@@ -2208,9 +2227,11 @@ int ata_eh_reset(struct ata_link *link, int classify,ata_link_for_each_dev (dev, link) {/* After the reset, the device state is PIO 0 * and the controller state is undefined. -* Record the mode. +* Reset also wakes up drives from sleeping +* mode. */ dev->pio_mode =XFER_PIO_0 ; + dev->flags &= ~ATA_DFLAG_SLEEPING ;if (ata_link_offline (link))continue ;
@@ -2416,7 +2437,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)/* give it just one more chance */ ehc->tries[dev->devno] =min (ehc->tries[dev->devno],1 );case -EIO : -if (ehc->tries[dev->devno] ==1 ) { +if (ehc->tries[dev->devno] ==1 && dev->pio_mode >XFER_PIO_0 ) {/* This is the last chance, better to slow * down than lose it. */
drivers/ata/libata-scsi.c +0 -23
@@ -1361,33 +1361,10 @@ nothing_to_do:static void ata_scsi_qc_complete (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap; -struct ata_eh_info *ehi = &qc->dev->link->eh_info;struct scsi_cmnd *cmd = qc->scsicmd;u8 *cdb = cmd->cmnd;int need_sense = (qc->err_mask !=0 ); -/* We snoop the SET_FEATURES - Write Cache ON/OFF command, and -* schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE -* cache -*/ -if (ap->ops->error_handler && !need_sense) { -switch (qc->tf.command) { -case ATA_CMD_SET_FEATURES : -if ((qc->tf.feature ==SETFEATURES_WC_ON ) || - (qc->tf.feature ==SETFEATURES_WC_OFF )) { - ehi->action |=ATA_EH_REVALIDATE ; -ata_port_schedule_eh (ap); - } -break ; - -case ATA_CMD_INIT_DEV_PARAMS :/* CHS translation changed */ -case ATA_CMD_SET_MULTI :/* multi_count changed */ - ehi->action |=ATA_EH_REVALIDATE ; -ata_port_schedule_eh (ap); -break ; - } - } -/* For ATA pass thru (SAT) commands, generate a sense block if * user mandated it or if there's an error. Note that if we * generate because the user forced us to, a check condition
drivers/ata/pata_acpi.c +2 -2
@@ -181,7 +181,7 @@ static void pacpi_set_piomode(struct ata_port *ap, struct ata_device *adev)int unit = adev->devno;struct pata_acpi *acpi = ap->private_data; -if (!(acpi->gtm.flags &0x10 )) +if (!(acpi->gtm.flags &0x10 )) unit =0 ;/* Now stuff the nS values into the structure */
@@ -202,7 +202,7 @@ static void pacpi_set_dmamode(struct ata_port *ap, struct ata_device *adev)int unit = adev->devno;struct pata_acpi *acpi = ap->private_data; -if (!(acpi->gtm.flags &0x10 )) +if (!(acpi->gtm.flags &0x10 )) unit =0 ;/* Now stuff the nS values into the structure */
drivers/ata/pata_ns87415.c +2 -0
@@ -215,6 +215,8 @@ static int ns87415_check_atapi_dma(struct ata_queued_cmd *qc)#include <asm/superio.h> +#define SUPERIO_IDE_MAX_RETRIES 25 +/** * ns87560_read_buggy - workaround buggy Super I/O chip * @port: Port to read
drivers/ata/pata_optidma.c +1 -1
@@ -449,7 +449,7 @@ static int optiplus_with_udma(struct pci_dev *pdev)/* Find function 1 */ dev1 =pci_get_device (0x1045 ,0xC701 ,NULL ); -if (dev1 ==NULL ) +if (dev1 ==NULL )return 0 ;/* Rev must be >= 0x10 */
drivers/ata/pata_pcmcia.c +6 -6
@@ -74,8 +74,7 @@ static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_dreturn ata_do_set_mode (link, r_failed_dev);if (memcmp (master->id +ATA_ID_FW_REV , slave->id +ATA_ID_FW_REV , -ATA_ID_FW_REV_LEN +ATA_ID_PROD_LEN ) ==0 ) - { +ATA_ID_FW_REV_LEN +ATA_ID_PROD_LEN ) ==0 ) {/* Suspicious match, but could be two cards from the same vendor - check serial */ if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO,
@@ -248,7 +247,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) goto next_entry; io_base = pdev->io.BasePort1; ctl_base = pdev->io.BasePort1 +0x0e ; - }else goto next_entry; + }else + goto next_entry;/* If we've got this far, we're done */ break ; }
@@ -285,8 +285,8 @@ next_entry: printk(KERN_WARNING DRV_NAME ": second channel not yet supported.\n");/* -* Having done the PCMCIA plumbing the ATA side is relatively -* sane. +* Having done the PCMCIA plumbing the ATA side is relatively +* sane. */ ret = -ENOMEM ; host =ata_host_alloc (&pdev->dev,1 );
@@ -363,7 +363,7 @@ static struct pcmcia_device_id pcmcia_devices[] = {PCMCIA_DEVICE_MANF_CARD (0x0098 ,0x0000 ),/* Toshiba */ PCMCIA_DEVICE_MANF_CARD (0x00a4 ,0x002d ),PCMCIA_DEVICE_MANF_CARD (0x00ce ,0x0000 ),/* Samsung */ -PCMCIA_DEVICE_MANF_CARD (0x0319 ,0x0000 ),/* Hitachi */ +PCMCIA_DEVICE_MANF_CARD (0x0319 ,0x0000 ),/* Hitachi */ PCMCIA_DEVICE_MANF_CARD (0x2080 ,0x0001 ),PCMCIA_DEVICE_MANF_CARD (0x4e01 ,0x0100 ),/* Viking CFA */ PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */
drivers/ata/pata_pdc2027x.c +1 -1
@@ -348,7 +348,7 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned longata_id_c_string (pair->id, model_num,ATA_ID_PROD ,ATA_ID_PROD_LEN +1 );/* If the master is a maxtor in UDMA6 then the slave should not use UDMA 6 */ -if (strstr (model_num,"Maxtor" ) ==0 && pair->dma_mode ==XFER_UDMA_6 ) +if (strstr (model_num,"Maxtor" ) ==0 && pair->dma_mode ==XFER_UDMA_6 ) mask &= ~ (1 << (6 +ATA_SHIFT_UDMA ));return ata_pci_default_filter (adev, mask);
drivers/ata/pata_pdc202xx_old.c +2 -2
@@ -351,9 +351,9 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *idstruct pci_dev *bridge = dev->bus->self;/* Don't grab anything behind a Promise I2O RAID */ if (bridge && bridge->vendor ==PCI_VENDOR_ID_INTEL ) { -if ( bridge->device ==PCI_DEVICE_ID_INTEL_I960 ) +if (bridge->device ==PCI_DEVICE_ID_INTEL_I960 )return -ENODEV ; -if ( bridge->device ==PCI_DEVICE_ID_INTEL_I960RM ) +if (bridge->device ==PCI_DEVICE_ID_INTEL_I960RM )return -ENODEV ; } }
drivers/ata/pata_scc.c +2 -11
@@ -570,17 +570,8 @@ static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,udelay (20 );out_be32 (ioaddr->ctl_addr, ap->ctl); -/* spec mandates ">= 2ms" before checking status. -* We wait 150ms, because that was the magic delay used for -* ATAPI devices in Hale Landis's ATADRVR, for the period of time -* between when the ATA command register is written, and then -* status is checked. Because waiting for "a while" before -* checking status is fine, post SRST, we perform this magic -* delay here as well. -* -* Old drivers/ide uses the 2mS rule and then waits for ready -*/ -msleep (150 ); +/* wait a while before checking status */ +ata_wait_after_reset (ap, deadline);/* Before we perform post reset processing we want to see if * the bus shows 0xFF because the odd clown forgets the D7
drivers/ata/pata_via.c +1 -1
@@ -176,7 +176,7 @@ static int via_cable_detect(struct ata_port *ap) {if ((config->flags &VIA_UDMA ) <VIA_UDMA_66 )return ATA_CBL_PATA40 ;/* UDMA 66 chips have only drive side logic */ -else if ((config->flags &VIA_UDMA ) <VIA_UDMA_100 ) +else if ((config->flags &VIA_UDMA ) <VIA_UDMA_100 )return ATA_CBL_PATA_UNK ;/* UDMA 100 or later */ pci_read_config_dword (pdev,0x50 , &ata66);
drivers/ata/pata_winbond.c +1 -1
@@ -279,7 +279,7 @@ static __init int winbond_init(void)if (request_region (port,2 ,"pata_winbond" )) { ret =winbond_init_one (port); -if (ret <=0 ) +if (ret <=0 )release_region (port,2 );else ct+= ret; }
drivers/ata/pdc_adma.c +6 -6
@@ -47,10 +47,10 @@#define DRV_VERSION "1.0"/* macro to calculate base address for ATA regs */ -#define ADMA_ATA_REGS (base,port_no) ((base) + ((port_no) * 0x40)) +#define ADMA_ATA_REGS (base, port_no) ((base) + ((port_no) * 0x40))/* macro to calculate base address for ADMA regs */ -#define ADMA_REGS (base,port_no) ((base) + 0x80 + ((port_no) * 0x20)) +#define ADMA_REGS (base, port_no) ((base) + 0x80 + ((port_no) * 0x20))/* macro to obtain addresses from ata_port */ #define ADMA_PORT_REGS (ap) \
@@ -128,7 +128,7 @@ struct adma_port_priv {adma_state_t state; }; -static int adma_ata_init_one (struct pci_dev *pdev, +static int adma_ata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent);static int adma_port_start (struct ata_port *ap);static void adma_host_stop (struct ata_host *host);
@@ -340,8 +340,8 @@ static int adma_fill_sg(struct ata_queued_cmd *qc) buf[i++] =0 ;/* pPKLW */ buf[i++] =0 ;/* reserved */ - *(__le32 *)(buf + i) - = (pFLAGS & pEND) ?0 :cpu_to_le32 (pp->pkt_dma + i +4 ); + *(__le32 *)(buf + i) = + (pFLAGS & pEND) ?0 :cpu_to_le32 (pp->pkt_dma + i +4 ); i +=4 ; VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
@@ -617,7 +617,7 @@ static int adma_port_start(struct ata_port *ap)return -ENOMEM ;/* paranoia? */ if ((pp->pkt_dma &7 ) !=0 ) { -printk ("bad alignment for pp->pkt_dma: %08x\n" , +printk (KERN_ERR "bad alignment for pp->pkt_dma: %08x\n" , (u32 )pp->pkt_dma);return -ENOMEM ; }
drivers/ata/sata_inic162x.c +2 -2
@@ -143,7 +143,7 @@ static const int scr_map[] = { [SCR_CONTROL] = 2, }; -static void __iomem *inic_port_base (struct ata_port *ap) +static void __iomem *inic_port_base (struct ata_port *ap) {return ap->host->iomap[MMIO_BAR ] + ap->port_no *PORT_SIZE ; }
@@ -448,7 +448,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,struct ata_taskfile tf;/* wait a while before checking status */ -msleep (150 ); +ata_wait_after_reset (ap, deadline); rc =ata_wait_ready (ap, deadline);/* link occupied, -ENODEV too is an error */
drivers/ata/sata_mv.c +4 -3
@@ -1156,7 +1156,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc) last_sg->flags_size |=cpu_to_le32 (EPRD_FLAG_END_OF_TBL ); } -static inline void mv_crqb_pack_cmd (__le16 *cmdw,u8 data,u8 addr,unsigned last) +static void mv_crqb_pack_cmd (__le16 *cmdw,u8 data,u8 addr,unsigned last) {u16 tmp = data | (addr <<CRQB_CMD_ADDR_SHIFT ) |CRQB_CMD_CS | (last ?CRQB_CMD_LAST :0 );
@@ -2429,7 +2429,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)struct mv_host_priv *hpriv = host->private_data;u32 hp_flags = hpriv->hp_flags; -switch (board_idx) { +switch (board_idx) {case chip_5080: hpriv->ops = &mv5xxx_ops; hp_flags |=MV_HP_GEN_I ;
@@ -2510,7 +2510,8 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)break ;default : - printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); +dev_printk (KERN_ERR , &pdev->dev, +"BUG: invalid board index %u\n" , board_idx);return 1 ; }
drivers/ata/sata_nv.c +65 -55
330 lines not on this page · raw message
drivers/ata/sata_promise.c +23 -15
@@ -83,10 +83,12 @@ enum {PDC_PCI_SYS_ERR = (1 <<22 ),/* PCI system error */ PDC1_PCI_PARITY_ERR = (1 <<23 ),/* PCI parity error (from SATA150 driver) */ PDC1_ERR_MASK =PDC1_PCI_PARITY_ERR , -PDC2_ERR_MASK =PDC2_HTO_ERR |PDC2_ATA_HBA_ERR |PDC2_ATA_DMA_CNT_ERR , -PDC_ERR_MASK = (PDC_PH_ERR |PDC_SH_ERR |PDC_DH_ERR |PDC_OVERRUN_ERR - |PDC_UNDERRUN_ERR |PDC_DRIVE_ERR |PDC_PCI_SYS_ERR - |PDC1_ERR_MASK |PDC2_ERR_MASK ), +PDC2_ERR_MASK =PDC2_HTO_ERR |PDC2_ATA_HBA_ERR | +PDC2_ATA_DMA_CNT_ERR , +PDC_ERR_MASK =PDC_PH_ERR |PDC_SH_ERR |PDC_DH_ERR | +PDC_OVERRUN_ERR |PDC_UNDERRUN_ERR | +PDC_DRIVE_ERR |PDC_PCI_SYS_ERR | +PDC1_ERR_MASK |PDC2_ERR_MASK , board_2037x =0 ,/* FastTrak S150 TX2plus */ board_2037x_pata = 1, /* FastTrak S150 TX2plus PATA port */
@@ -695,19 +697,20 @@ static void pdc_irq_clear(struct ata_port *ap)readl (mmio +PDC_INT_SEQMASK ); } -static inline int pdc_is_sataii_tx4 (unsigned long flags) +static int pdc_is_sataii_tx4 (unsigned long flags) {const unsigned long mask =PDC_FLAG_GEN_II |PDC_FLAG_4_PORTS ;return (flags & mask) == mask; } -static inline unsigned int pdc_port_no_to_ata_no (unsigned int port_no,int is_sataii_tx4) +static unsigned int pdc_port_no_to_ata_no (unsigned int port_no, +int is_sataii_tx4) {static const unsigned char sataii_tx4_port_remap[4 ] = {3 ,1 ,0 ,2 };return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no; } -static irqreturn_t pdc_interrupt (int irq,void *dev_instance) +static irqreturn_t pdc_interrupt (int irq,void *dev_instance) {struct ata_host *host = dev_instance;struct ata_port *ap;
@@ -839,15 +842,16 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)static void pdc_tf_load_mmio (struct ata_port *ap,const struct ata_taskfile *tf) { -WARN_ON (tf->protocol ==ATA_PROT_DMA || - tf->protocol ==ATA_PROT_ATAPI_DMA ); +WARN_ON (tf->protocol ==ATA_PROT_DMA || + tf->protocol ==ATA_PROT_ATAPI_DMA );ata_tf_load (ap, tf); } -static void pdc_exec_command_mmio (struct ata_port *ap,const struct ata_taskfile *tf) +static void pdc_exec_command_mmio (struct ata_port *ap, +const struct ata_taskfile *tf) { -WARN_ON (tf->protocol ==ATA_PROT_DMA || - tf->protocol ==ATA_PROT_ATAPI_DMA ); +WARN_ON (tf->protocol ==ATA_PROT_DMA || + tf->protocol ==ATA_PROT_ATAPI_DMA );ata_exec_command (ap, tf); }
@@ -870,8 +874,11 @@ static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) }/* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */ if (scsicmd[0 ] ==WRITE_10 ) { -unsigned int lba; - lba = (scsicmd[2 ] <<24 ) | (scsicmd[3 ] <<16 ) | (scsicmd[4 ] <<8 ) | scsicmd[5 ]; +unsigned int lba = + (scsicmd[2 ] <<24 ) | + (scsicmd[3 ] <<16 ) | + (scsicmd[4 ] <<8 ) | + scsicmd[5 ];if (lba >=0xFFFF4FA2 ) pio =1 ; }
@@ -956,7 +963,8 @@ static void pdc_host_init(struct ata_host *host)writel (tmp, mmio +PDC_SLEW_CTL ); } -static int pdc_ata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) +static int pdc_ata_init_one (struct pci_dev *pdev, +const struct pci_device_id *ent) {static int printed_version;const struct ata_port_info *pi = &pdc_port_info[ent->driver_data];
drivers/ata/sata_qstor.c +1 -2
@@ -113,7 +113,7 @@ struct qs_port_priv {static int qs_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val);static int qs_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val); -static int qs_ata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent); +static int qs_ata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent);static int qs_port_start (struct ata_port *ap);static void qs_host_stop (struct ata_host *host);static void qs_phy_reset (struct ata_port *ap);
@@ -135,7 +135,6 @@ static struct scsi_host_template qs_ata_sht = { .sg_tablesize = QS_MAX_PRD, .cmd_per_lun = ATA_SHT_CMD_PER_LUN, .emulated = ATA_SHT_EMULATED, -//FIXME .use_clustering = ATA_SHT_USE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING, .proc_name = DRV_NAME, .dma_boundary = QS_DMA_BOUNDARY,
drivers/ata/sata_sil.c +6 -5
@@ -111,7 +111,7 @@ enum { SIL_QUIRK_UDMA5MAX = (1 << 1), }; -static int sil_init_one (struct pci_dev *pdev,const struct pci_device_id *ent); +static int sil_init_one (struct pci_dev *pdev,const struct pci_device_id *ent);#ifdef CONFIG_PM static int sil_pci_device_resume (struct pci_dev *pdev);#endif
@@ -138,7 +138,7 @@ static const struct pci_device_id sil_pci_tbl[] = {/* TODO firmware versions should be added - eric */ static const struct sil_drivelist { -const char * product; +const char *product;unsigned int quirk; } sil_blacklist [] = { {"ST320012AS" ,SIL_QUIRK_MOD15WRITE },
@@ -279,7 +279,7 @@ MODULE_LICENSE("GPL");MODULE_DEVICE_TABLE (pci, sil_pci_tbl);MODULE_VERSION (DRV_VERSION ); -static int slow_down =0 ; +static int slow_down;module_param (slow_down, int,0444 );MODULE_PARM_DESC (slow_down,"Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)" );
@@ -332,7 +332,8 @@ static int sil_set_mode(struct ata_link *link, struct ata_device **r_failed)return 0 ; } -static inline void __iomem *sil_scr_addr (struct ata_port *ap,unsigned int sc_reg) +static inline void __iomem *sil_scr_addr (struct ata_port *ap, +unsigned int sc_reg) {void __iomem *offset = ap->ioaddr.scr_addr;
@@ -643,7 +644,7 @@ static void sil_init_controller(struct ata_host *host) } } -static int sil_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) +static int sil_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {static int printed_version;int board_id = ent->driver_data;
drivers/ata/sata_sil24.c +5 -4
@@ -674,7 +674,7 @@ static int sil24_do_softreset(struct ata_link *link, unsigned int *class,/* put the port into known state */ if (sil24_init_port (ap)) { - reason ="port not ready" ; + reason ="port not ready" ; goto err; }
@@ -756,7 +756,8 @@ static int sil24_hardreset(struct ata_link *link, unsigned int *class,writel (PORT_CS_DEV_RST , port +PORT_CTRL_STAT ); tmp =ata_wait_register (port +PORT_CTRL_STAT , -PORT_CS_DEV_RST ,PORT_CS_DEV_RST ,10 , tout_msec); +PORT_CS_DEV_RST ,PORT_CS_DEV_RST ,10 , + tout_msec);/* SStatus oscillates between zero and valid status after * DEV_RST, debounce it.
@@ -1270,7 +1271,7 @@ static void sil24_init_controller(struct ata_host *host) PORT_CS_PORT_RST, 10, 100);if (tmp &PORT_CS_PORT_RST )dev_printk (KERN_ERR , host->dev, -"failed to clear port RST\n" ); +"failed to clear port RST\n" ); }/* configure port */
@@ -1283,7 +1284,7 @@ static void sil24_init_controller(struct ata_host *host)static int sil24_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) { -static int printed_version =0 ; +static int printed_version;struct ata_port_info pi = sil24_port_info[ent->driver_data];const struct ata_port_info *ppi[] = { &pi,NULL };void __iomem *const *iomap;
drivers/ata/sata_sis.c +34 -30
118 lines not on this page · raw message
drivers/ata/sata_svw.c +5 -5
@@ -182,7 +182,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ; tf->hob_lbah = lbah >>8 ; - } + } }/**
@@ -193,7 +193,7 @@ static void k2_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)* spin_lock_irqsave(host lock) */ -static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) +static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap;unsigned int rw = (qc->tf.flags &ATA_TFLAG_WRITE );
@@ -224,7 +224,7 @@ static void k2_bmdma_setup_mmio (struct ata_queued_cmd *qc)* spin_lock_irqsave(host lock) */ -static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) +static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc) {struct ata_port *ap = qc->ap;void __iomem *mmio = ap->ioaddr.bmdma_addr;
@@ -255,7 +255,7 @@ static void k2_bmdma_start_mmio (struct ata_queued_cmd *qc)static u8 k2_stat_check_status (struct ata_port *ap) { -return readl (ap->ioaddr.status_addr); +return readl (ap->ioaddr.status_addr); }#ifdef CONFIG_PPC_OF
@@ -395,7 +395,7 @@ static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) } -static int k2_sata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) +static int k2_sata_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {static int printed_version; const struct ata_port_info *ppi[] =
drivers/ata/sata_sx4.c +90 -87
377 lines not on this page · raw message
drivers/ata/sata_uli.c +9 -9
@@ -56,9 +56,9 @@ struct uli_priv {unsigned int scr_cfg_addr[uli_max_ports]; }; -static int uli_init_one (struct pci_dev *pdev,const struct pci_device_id *ent); -static int uli_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val); -static int uli_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val); +static int uli_init_one (struct pci_dev *pdev,const struct pci_device_id *ent); +static int uli_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val); +static int uli_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val);static const struct pci_device_id uli_pci_tbl[] = { {PCI_VDEVICE (AL ,0x5289 ), uli_5289 },
@@ -143,7 +143,7 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg); } -static u32 uli_scr_cfg_read (struct ata_port *ap,unsigned int sc_reg) +static u32 uli_scr_cfg_read (struct ata_port *ap,unsigned int sc_reg) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);unsigned int cfg_addr =get_scr_cfg_addr (ap, sc_reg);
@@ -153,7 +153,7 @@ static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)return val; } -static void uli_scr_cfg_write (struct ata_port *ap,unsigned int scr,u32 val) +static void uli_scr_cfg_write (struct ata_port *ap,unsigned int scr,u32 val) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);unsigned int cfg_addr =get_scr_cfg_addr (ap, scr);
@@ -161,7 +161,7 @@ static void uli_scr_cfg_write (struct ata_port *ap, unsigned int scr, u32 val)pci_write_config_dword (pdev, cfg_addr, val); } -static int uli_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val) +static int uli_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val) {if (sc_reg >SCR_CONTROL )return -EINVAL ;
@@ -170,16 +170,16 @@ static int uli_scr_read (struct ata_port *ap, unsigned int sc_reg, u32 *val)return 0 ; } -static int uli_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val) +static int uli_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val) { -if (sc_reg >SCR_CONTROL )//SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 +if (sc_reg >SCR_CONTROL )//SCR_CONTROL=2, SCR_ERROR=1, SCR_STATUS=0 return -EINVAL ;uli_scr_cfg_write (ap, sc_reg, val);return 0 ; } -static int uli_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) +static int uli_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {static int printed_version;const struct ata_port_info *ppi[] = { &uli_port_info,NULL };
drivers/ata/sata_via.c +10 -10
@@ -3,7 +3,7 @@* * Maintained by: Jeff Garzik <[email protected]> * Please ALWAYS copy [email protected] -on emails. +* on emails. * * Copyright 2003-2004 Red Hat, Inc. All rights reserved. * Copyright 2003-2004 Jeff Garzik
@@ -69,7 +69,7 @@ enum { SATA_EXT_PHY = (1 << 6), /* 0==use PATA, 1==ext phy */ }; -static int svia_init_one (struct pci_dev *pdev,const struct pci_device_id *ent); +static int svia_init_one (struct pci_dev *pdev,const struct pci_device_id *ent);static int svia_scr_read (struct ata_port *ap,unsigned int sc_reg,u32 *val);static int svia_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val);static void svia_noop_freeze (struct ata_port *ap);
@@ -372,12 +372,12 @@ static const unsigned int vt6421_bar_sizes[] = { 16, 16, 16, 16, 32, 128 }; -static void __iomem *svia_scr_addr (void __iomem *addr,unsigned int port) +static void __iomem *svia_scr_addr (void __iomem *addr,unsigned int port) {return addr + (port *128 ); } -static void __iomem *vt6421_scr_addr (void __iomem *addr,unsigned int port) +static void __iomem *vt6421_scr_addr (void __iomem *addr,unsigned int port) {return addr + (port *64 ); }
@@ -472,7 +472,7 @@ static void svia_configure(struct pci_dev *pdev)if ((tmp8 &ALL_PORTS ) !=ALL_PORTS ) {dev_printk (KERN_DEBUG , &pdev->dev,"enabling SATA channels (0x%x)\n" , - (int ) tmp8); + (int ) tmp8); tmp8 |=ALL_PORTS ;pci_write_config_byte (pdev,SATA_CHAN_ENAB , tmp8); }
@@ -482,7 +482,7 @@ static void svia_configure(struct pci_dev *pdev)if ((tmp8 &ALL_PORTS ) !=ALL_PORTS ) {dev_printk (KERN_DEBUG , &pdev->dev,"enabling SATA channel interrupts (0x%x)\n" , - (int ) tmp8); + (int ) tmp8); tmp8 |=ALL_PORTS ;pci_write_config_byte (pdev,SATA_INT_GATE , tmp8); }
@@ -492,13 +492,13 @@ static void svia_configure(struct pci_dev *pdev)if ((tmp8 &NATIVE_MODE_ALL ) !=NATIVE_MODE_ALL ) {dev_printk (KERN_DEBUG , &pdev->dev,"enabling SATA channel native mode (0x%x)\n" , - (int ) tmp8); + (int ) tmp8); tmp8 |=NATIVE_MODE_ALL ;pci_write_config_byte (pdev,SATA_NATIVE_MODE , tmp8); } } -static int svia_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) +static int svia_init_one (struct pci_dev *pdev,const struct pci_device_id *ent) {static int printed_version;unsigned int i;
@@ -525,8 +525,8 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)dev_printk (KERN_ERR , &pdev->dev,"invalid PCI BAR %u (sz 0x%llx, val 0x%llx)\n" , i, - (unsigned long long )pci_resource_start (pdev, i), - (unsigned long long )pci_resource_len (pdev, i)); + (unsigned long long )pci_resource_start (pdev, i), + (unsigned long long )pci_resource_len (pdev, i));return -ENODEV ; }
drivers/ata/sata_vsc.c +9 -6
@@ -162,7 +162,8 @@ static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)/* * The only thing the ctl register is used for is SRST. * That is not enabled or disabled via tf_load. -* However, if ATA_NIEN is changed, then we need to change the interrupt register. +* However, if ATA_NIEN is changed, then we need to change +* the interrupt register. */ if ((tf->ctl &ATA_NIEN ) != (ap->last_ctl &ATA_NIEN )) { ap->last_ctl = tf->ctl;
@@ -219,7 +220,7 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) tf->hob_lbal = lbal >>8 ; tf->hob_lbam = lbam >>8 ; tf->hob_lbah = lbah >>8 ; - } + } }static inline void vsc_error_intr (u8 port_status,struct ata_port *ap)
@@ -256,9 +257,10 @@ static void vsc_port_intr(u8 port_status, struct ata_port *ap)/* * vsc_sata_interrupt * -* Read the interrupt register and process for the devices that have them pending. +* Read the interrupt register and process for the devices that have +* them pending. */ -static irqreturn_t vsc_sata_interrupt (int irq,void *dev_instance) +static irqreturn_t vsc_sata_interrupt (int irq,void *dev_instance) {struct ata_host *host = dev_instance;unsigned int i;
@@ -287,7 +289,7 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance) handled++; }else dev_printk (KERN_ERR , host->dev, -": interrupt from disabled port %d\n" , i); +"interrupt from disabled port %d\n" , i); } }
@@ -363,7 +365,8 @@ static void __devinit vsc_sata_setup_port(struct ata_ioports *port, } -static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) +static int __devinit vsc_sata_init_one(struct pci_dev *pdev, + const struct pci_device_id *ent) { static const struct ata_port_info pi = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
include/linux/ata.h +1 -0
@@ -180,6 +180,7 @@ enum {ATA_CMD_VERIFY_EXT =0x42 ,ATA_CMD_STANDBYNOW1 =0xE0 ,ATA_CMD_IDLEIMMEDIATE =0xE1 , +ATA_CMD_SLEEP =0xE6 ,ATA_CMD_INIT_DEV_PARAMS =0x91 ,ATA_CMD_READ_NATIVE_MAX =0xF8 , ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
include/linux/libata.h +9 -0
@@ -138,6 +138,7 @@ enum {ATA_DFLAG_PIO = (1 <<12 ),/* device limited to PIO mode */ ATA_DFLAG_NCQ_OFF = (1 <<13 ),/* device limited to non-NCQ mode */ ATA_DFLAG_SPUNDOWN = (1 <<14 ),/* XXX: for spindown_compat */ +ATA_DFLAG_SLEEPING = (1 <<15 ),/* device is sleeping */ ATA_DFLAG_INIT_MASK = (1 <<16 ) -1 , ATA_DFLAG_DETACH = (1 << 16),
@@ -234,6 +235,13 @@ enum {ATA_TMOUT_INTERNAL =30 *HZ ,ATA_TMOUT_INTERNAL_QUICK =5 *HZ , +/* FIXME: GoVault needs 2s but we can't afford that without +* parallel probing. 800ms is enough for iVDR disk +* HHD424020F7SV00. Increase to 2secs when parallel probing +* is in place. +*/ +ATA_TMOUT_FF_WAIT =4 *HZ /5 , +/* ATA bus states */ BUS_UNKNOWN =0 , BUS_DMA = 1,
@@ -799,6 +807,7 @@ extern void ata_host_resume(struct ata_host *host);extern int ata_ratelimit (void );extern int ata_busy_sleep (struct ata_port *ap,unsigned long timeout_pat,unsigned long timeout); +extern void ata_wait_after_reset (struct ata_port *ap,unsigned long deadline);extern int ata_wait_ready (struct ata_port *ap,unsigned long deadline);extern void ata_port_queue_task (struct ata_port *ap,work_func_t fn,void *data,unsigned long delay);
PATCH 2/2 libata: add ALPM
NOTE: This is on top of the 'upstream-linus' branch, in a linear history. If you pull this, you get BOTH this and upstream-linus. If you already pulled upstream-linus, you will get only what you see below.
This has been in -mm for a while, but didn't make the initial push due to my own fault.
Hardware SATA link power management (ALPM) has a __significant__ positive impact on power saving. At the min_power setting (maximize power savings), there have been claimed of battery life being extended by 30-60 minutes or more (on a 4-6 hour battery).
Please pull from 'alpm' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git alpm
to receive the following updates:
.../scsi/link_power_management_policy.txt | 19 ++ drivers/ata/ahci.c | 157 ++++++++++++++++- drivers/ata/libata-core.c | 196 +++++++++++++++++++- drivers/ata/libata-eh.c | 4 + drivers/ata/libata-scsi.c | 68 +++++++ drivers/ata/libata.h | 2 + include/linux/ata.h | 21 ++ include/linux/libata.h | 21 ++- 8 files changed, 484 insertions(+), 4 deletions(-) create mode 100644 Documentation/scsi/link_power_management_policy.txt
Kristen Carlson Accardi (2):
[libata] Link power management infrastructure [libata] AHCI: add hw link power management support
Documentation/scsi/link_power_management_policy.txt new file +19 -0
@@ -0,0 +1,19 @@ +This parameter allows the user to set the link (interface) power management. +There are 3 possible options: + +Value Effect +---------------------------------------------------------------------------- +min_power Tell the controller to try to make the link use the + least possible power when possible. This may + sacrifice some performance due to increased latency + when coming out of lower power states. + +max_performance Generally, this means no power management. Tell + the controller to have performance be a priority + over power management. + +medium_power Tell the controller to enter a lower power state + when possible, but do not enter the lowest power + state, thus improving latency over min_power setting. + +
drivers/ata/ahci.c +155 -2
222 lines not on this page · raw message
drivers/ata/libata-core.c +195 -1
238 lines not on this page · raw message
drivers/ata/libata-eh.c +4 -0
@@ -2628,6 +2628,10 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ehc->i.flags &= ~ATA_EHI_SETMODE ; } +if (ehc->i.action &ATA_EHI_LPM ) +ata_link_for_each_dev (dev, link) +ata_dev_enable_pm (dev, ap->pm_policy); +/* this link is okay now */ ehc->i.flags =0 ;continue ;
drivers/ata/libata-scsi.c +68 -0
74 lines not on this page · raw message
drivers/ata/libata.h +2 -0
@@ -101,6 +101,8 @@ extern int sata_link_init_spd(struct ata_link *link);extern int ata_task_ioctl (struct scsi_device *scsidev,void __user *arg);extern int ata_cmd_ioctl (struct scsi_device *scsidev,void __user *arg);extern struct ata_port *ata_port_alloc (struct ata_host *host); +extern void ata_dev_enable_pm (struct ata_device *dev,enum link_pm policy); +extern void ata_lpm_schedule (struct ata_port *ap,enum link_pm );/* libata-acpi.c */ #ifdef CONFIG_ATA_ACPI
include/linux/ata.h +21 -0
@@ -236,6 +236,7 @@ enum {/* SETFEATURE Sector counts for SATA features */ SATA_AN =0x05 ,/* Asynchronous Notification */ +SATA_DIPM =0x03 ,/* Device Initiated Power Management */ /* ATAPI stuff */ ATAPI_PKT_DMA = (1 << 0),
@@ -378,6 +379,26 @@ struct ata_taskfile {#define ata_id_cdb_intr (id) (((id)[0] & 0x60) == 0x20) +static inline bool ata_id_has_hipm (const u16 *id) +{ +u16 val = id[76 ]; + +if (val ==0 || val ==0xffff ) +return false; + +return val & (1 <<9 ); +} + +static inline bool ata_id_has_dipm (const u16 *id) +{ +u16 val = id[78 ]; + +if (val ==0 || val ==0xffff ) +return false; + +return val & (1 <<3 ); +} +static inline int ata_id_has_fua (const u16 *id) {if ((id[84 ] &0xC000 ) !=0x4000 )
include/linux/libata.h +20 -1
@@ -133,6 +133,8 @@ enum {ATA_DFLAG_ACPI_PENDING = (1 <<5 ),/* ACPI resume action pending */ ATA_DFLAG_ACPI_FAILED = (1 <<6 ),/* ACPI on devcfg has failed */ ATA_DFLAG_AN = (1 <<7 ),/* AN configured */ +ATA_DFLAG_HIPM = (1 <<8 ),/* device supports HIPM */ +ATA_DFLAG_DIPM = (1 <<9 ),/* device supports DIPM */ ATA_DFLAG_CFG_MASK = (1 <<12 ) -1 , ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */
@@ -186,6 +188,7 @@ enum {ATA_FLAG_ACPI_SATA = (1 <<17 ),/* need native SATA ACPI layout */ ATA_FLAG_AN = (1 <<18 ),/* controller supports AN */ ATA_FLAG_PMP = (1 <<19 ),/* controller supports PMP */ +ATA_FLAG_IPM = (1 <<20 ),/* driver can handle IPM */ /* The following flag belongs to ap->pflags but is kept in * ap->flags because it's referenced in many LLDs and will be
@@ -302,6 +305,7 @@ enum {ATA_EHI_RESUME_LINK = (1 <<1 ),/* resume link (reset modifier) */ ATA_EHI_NO_AUTOPSY = (1 <<2 ),/* no autopsy */ ATA_EHI_QUIET = (1 <<3 ),/* be quiet */ +ATA_EHI_LPM = (1 <<4 ),/* link power management action */ ATA_EHI_DID_SOFTRESET = (1 <<16 ),/* already soft-reset this port */ ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
@@ -333,6 +337,7 @@ enum {ATA_HORKAGE_BROKEN_HPA = (1 <<4 ),/* Broken HPA */ ATA_HORKAGE_SKIP_PM = (1 <<5 ),/* Skip PM operations */ ATA_HORKAGE_HPA_SIZE = (1 <<6 ),/* native size off by one */ + ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems *//* DMA mask for user DMA control: User visible values; DO NOT renumber */
@@ -378,6 +383,18 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes, unsigned long deadline);typedef void (*ata_postreset_fn_t )(struct ata_link *link,unsigned int *classes); +/* +* host pm policy: If you alter this, you also need to alter libata-scsi.c +* (for the ascii descriptions) +*/ +enum link_pm { +NOT_AVAILABLE , +MIN_POWER , +MAX_PERFORMANCE , +MEDIUM_POWER , +}; +extern struct class_device_attribute class_device_attr_link_power_management_policy; +struct ata_ioports {void __iomem *cmd_addr;void __iomem *data_addr;
@@ -624,6 +641,7 @@ struct ata_port {pm_message_t pm_mesg;int *pm_result; +enum link_pm pm_policy;struct timer_list fastdrain_timer;unsigned long fastdrain_cnt;
@@ -691,7 +709,8 @@ struct ata_port_operations {int (*port_suspend) (struct ata_port *ap,pm_message_t mesg);int (*port_resume) (struct ata_port *ap); - +int (*enable_pm) (struct ata_port *ap,enum link_pm policy); +void (*disable_pm) (struct ata_port *ap);int (*port_start) (struct ata_port *ap);void (*port_stop) (struct ata_port *ap);