Several recent libata commits
PATCH 1/1 Several recent libata commits
Linus pulled the latest stuff (incl. Alan and Tejun's stuff) already.
The 'upstream' branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
contains the following updates:
drivers/scsi/libata-bmdma.c | 234 ++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/libata-core.c | 234 -------------------------------------------- drivers/scsi/sata_nv.c | 181 +++++++++++----------------------- drivers/scsi/sata_sil24.c | 23 +--- drivers/scsi/sata_uli.c | 37 +++++- 5 files changed, 333 insertions(+), 376 deletions(-)
Jeff Garzik:
[libata sata_sil24] cleanups: use pci_iomap(), kzalloc() [libata sata_nv] cleanups: convert #defines to enums; remove in-file history [libata sata_nv] eliminate duplicate codepaths with iomap [libata sata_uli] kill scr_addr abuse
[libata] Move some bmdma-specific code to libata-bmdma.c
drivers/scsi/libata-bmdma.c +234 -0
@@ -418,6 +418,240 @@ u8 ata_altstatus(struct ata_port *ap)return inb (ap->ioaddr.altstatus_addr); } +/** +* ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction +* @qc: Info associated with this ATA transaction. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +unsigned int rw = (qc->tf.flags &ATA_TFLAG_WRITE ); +u8 dmactl; +void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; + +/* load PRD table addr. */ +mb ();/* make sure PRD table writes are visible to controller */ +writel (ap->prd_dma, mmio +ATA_DMA_TABLE_OFS ); + +/* specify data direction, triple-check start bit is clear */ + dmactl =readb (mmio +ATA_DMA_CMD ); + dmactl &= ~(ATA_DMA_WR |ATA_DMA_START ); +if (!rw) + dmactl |=ATA_DMA_WR ; +writeb (dmactl, mmio +ATA_DMA_CMD ); + +/* issue r/w command */ + ap->ops->exec_command (ap, &qc->tf); +} + +/** +* ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction +* @qc: Info associated with this ATA transaction. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; +u8 dmactl; + +/* start host DMA transaction */ + dmactl =readb (mmio +ATA_DMA_CMD ); +writeb (dmactl |ATA_DMA_START , mmio +ATA_DMA_CMD ); + +/* Strictly, one may wish to issue a readb() here, to +* flush the mmio write. However, control also passes +* to the hardware at this point, and it will interrupt +* us when we are to resume control. So, in effect, +* we don't care when the mmio write flushes. +* Further, a read of the DMA status register _immediately_ +* following the write may not be what certain flaky hardware +* is expected, so I think it is best to not add a readb() +* without first all the MMIO ATA cards/mobos. +* Or maybe I'm just being paranoid. +*/ +} + +/** +* ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO) +* @qc: Info associated with this ATA transaction. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +unsigned int rw = (qc->tf.flags &ATA_TFLAG_WRITE ); +u8 dmactl; + +/* load PRD table addr. */ +outl (ap->prd_dma, ap->ioaddr.bmdma_addr +ATA_DMA_TABLE_OFS ); + +/* specify data direction, triple-check start bit is clear */ + dmactl =inb (ap->ioaddr.bmdma_addr +ATA_DMA_CMD ); + dmactl &= ~(ATA_DMA_WR |ATA_DMA_START ); +if (!rw) + dmactl |=ATA_DMA_WR ; +outb (dmactl, ap->ioaddr.bmdma_addr +ATA_DMA_CMD ); + +/* issue r/w command */ + ap->ops->exec_command (ap, &qc->tf); +} + +/** +* ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO) +* @qc: Info associated with this ATA transaction. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +static void ata_bmdma_start_pio (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +u8 dmactl; + +/* start host DMA transaction */ + dmactl =inb (ap->ioaddr.bmdma_addr +ATA_DMA_CMD ); +outb (dmactl |ATA_DMA_START , + ap->ioaddr.bmdma_addr +ATA_DMA_CMD ); +} + + +/** +* ata_bmdma_start - Start a PCI IDE BMDMA transaction +* @qc: Info associated with this ATA transaction. +* +* Writes the ATA_DMA_START flag to the DMA command register. +* +* May be used as the bmdma_start() entry in ata_port_operations. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ +void ata_bmdma_start (struct ata_queued_cmd *qc) +{ +if (qc->ap->flags &ATA_FLAG_MMIO ) +ata_bmdma_start_mmio (qc); +else +ata_bmdma_start_pio (qc); +} + + +/** +* ata_bmdma_setup - Set up PCI IDE BMDMA transaction +* @qc: Info associated with this ATA transaction. +* +* Writes address of PRD table to device's PRD Table Address +* register, sets the DMA control register, and calls +* ops->exec_command() to start the transfer. +* +* May be used as the bmdma_setup() entry in ata_port_operations. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ +void ata_bmdma_setup (struct ata_queued_cmd *qc) +{ +if (qc->ap->flags &ATA_FLAG_MMIO ) +ata_bmdma_setup_mmio (qc); +else +ata_bmdma_setup_pio (qc); +} + + +/** +* ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt. +* @ap: Port associated with this ATA transaction. +* +* Clear interrupt and error flags in DMA status register. +* +* May be used as the irq_clear() entry in ata_port_operations. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +void ata_bmdma_irq_clear (struct ata_port *ap) +{ +if (!ap->ioaddr.bmdma_addr) +return ; + +if (ap->flags &ATA_FLAG_MMIO ) { +void __iomem *mmio = + ((void __iomem *) ap->ioaddr.bmdma_addr) +ATA_DMA_STATUS ; +writeb (readb (mmio), mmio); + }else { +unsigned long addr = ap->ioaddr.bmdma_addr +ATA_DMA_STATUS ; +outb (inb (addr), addr); + } +} + + +/** +* ata_bmdma_status - Read PCI IDE BMDMA status +* @ap: Port associated with this ATA transaction. +* +* Read and return BMDMA status register. +* +* May be used as the bmdma_status() entry in ata_port_operations. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +u8 ata_bmdma_status (struct ata_port *ap) +{ +u8 host_stat; +if (ap->flags &ATA_FLAG_MMIO ) { +void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; + host_stat =readb (mmio +ATA_DMA_STATUS ); + }else + host_stat =inb (ap->ioaddr.bmdma_addr +ATA_DMA_STATUS ); +return host_stat; +} + + +/** +* ata_bmdma_stop - Stop PCI IDE BMDMA transfer +* @qc: Command we are ending DMA for +* +* Clears the ATA_DMA_START flag in the dma control register +* +* May be used as the bmdma_stop() entry in ata_port_operations. +* +* LOCKING: +* spin_lock_irqsave(host_set lock) +*/ + +void ata_bmdma_stop (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +if (ap->flags &ATA_FLAG_MMIO ) { +void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; + +/* clear start/stop bit */ +writeb (readb (mmio +ATA_DMA_CMD ) & ~ATA_DMA_START , + mmio +ATA_DMA_CMD ); + }else { +/* clear start/stop bit */ +outb (inb (ap->ioaddr.bmdma_addr +ATA_DMA_CMD ) & ~ATA_DMA_START , + ap->ioaddr.bmdma_addr +ATA_DMA_CMD ); + } + +/* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ +ata_altstatus (ap);/* dummy read */ +} +#ifdef CONFIG_PCI static struct ata_probe_ent *ata_probe_ent_alloc (struct device *dev,const struct ata_port_info *port)
drivers/scsi/libata-core.c +0 -234
240 lines not on this page · raw message
drivers/scsi/sata_nv.c +62 -119
246 lines not on this page · raw message
drivers/scsi/sata_sil24.c +10 -13
@@ -842,9 +842,10 @@ static void sil24_port_stop(struct ata_pstatic void sil24_host_stop (struct ata_host_set *host_set) {struct sil24_host_priv *hpriv = host_set->private_data; +struct pci_dev *pdev =to_pci_dev (host_set->dev); -iounmap (hpriv->host_base); -iounmap (hpriv->port_base); +pci_iounmap (pdev, hpriv->host_base); +pci_iounmap (pdev, hpriv->port_base);kfree (hpriv); }
@@ -871,26 +872,23 @@ static int sil24_init_one(struct pci_dev goto out_disable; rc = -ENOMEM ; -/* ioremap mmio registers */ - host_base =ioremap (pci_resource_start (pdev,0 ), -pci_resource_len (pdev,0 )); +/* map mmio registers */ + host_base =pci_iomap (pdev,0 ,0 );if (!host_base) goto out_free; - port_base =ioremap (pci_resource_start (pdev,2 ), -pci_resource_len (pdev,2 )); + port_base =pci_iomap (pdev,2 ,0 );if (!port_base) goto out_free;/* allocate & init probe_ent and hpriv */ - probe_ent =kmalloc (sizeof (*probe_ent),GFP_KERNEL ); + probe_ent =kzalloc (sizeof (*probe_ent),GFP_KERNEL );if (!probe_ent) goto out_free; - hpriv =kmalloc (sizeof (*hpriv),GFP_KERNEL ); + hpriv =kzalloc (sizeof (*hpriv),GFP_KERNEL );if (!hpriv) goto out_free; -memset (probe_ent,0 ,sizeof (*probe_ent)); probe_ent->dev =pci_dev_to_dev (pdev);INIT_LIST_HEAD (&probe_ent->node);
@@ -907,7 +905,6 @@ static int sil24_init_one(struct pci_dev probe_ent->mmio_base = port_base; probe_ent->private_data = hpriv; -memset (hpriv,0 ,sizeof (*hpriv)); hpriv->host_base = host_base; hpriv->port_base = port_base;
@@ -1011,9 +1008,9 @@ static int sil24_init_one(struct pci_dev out_free:if (host_base) -iounmap (host_base); +pci_iounmap (pdev, host_base);if (port_base) -iounmap (port_base); +pci_iounmap (pdev, port_base);kfree (probe_ent);kfree (hpriv);pci_release_regions (pdev);
drivers/scsi/sata_uli.c +27 -10
@@ -44,6 +44,8 @@ enum { uli_5287 =1 , uli_5281 =2 , + uli_max_ports =4 , +/* PCI configuration registers */ ULI5287_BASE =0x90 ,/* sata0 phy SCR registers */ ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */
@@ -51,6 +53,10 @@ enum { ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */ }; +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 u32 uli_scr_read (struct ata_port *ap,unsigned int sc_reg);static void uli_scr_write (struct ata_port *ap,unsigned int sc_reg,u32 val);
@@ -137,7 +143,8 @@ MODULE_VERSION(DRV_VERSION);static unsigned int get_scr_cfg_addr (struct ata_port *ap,unsigned int sc_reg) { -return ap->ioaddr.scr_addr + (4 * sc_reg); +struct uli_priv *hpriv = ap->host_set->private_data; +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)
@@ -182,6 +189,7 @@ static int uli_init_one (struct pci_devint rc;unsigned int board_idx = (unsigned int ) ent->driver_data;int pci_dev_busy =0 ; +struct uli_priv *hpriv;if (!printed_version++)dev_printk (KERN_INFO , &pdev->dev,"version " DRV_VERSION "\n" );
@@ -210,10 +218,18 @@ static int uli_init_one (struct pci_dev goto err_out_regions; } + hpriv =kzalloc (sizeof (*hpriv),GFP_KERNEL ); +if (!hpriv) { + rc = -ENOMEM ; + goto err_out_probe_ent; + } + + probe_ent->private_data = hpriv; +switch (board_idx) {case uli_5287: - probe_ent->port[0 ].scr_addr =ULI5287_BASE ; - probe_ent->port[1 ].scr_addr =ULI5287_BASE +ULI5287_OFFS ; + hpriv->scr_cfg_addr[0 ] =ULI5287_BASE ; + hpriv->scr_cfg_addr[1 ] =ULI5287_BASE +ULI5287_OFFS ; probe_ent->n_ports =4 ; probe_ent->port[2 ].cmd_addr =pci_resource_start (pdev,0 ) +8 ;
@@ -221,27 +237,27 @@ static int uli_init_one (struct pci_dev probe_ent->port[2 ].ctl_addr = (pci_resource_start (pdev,1 ) |ATA_PCI_CTL_OFS ) +4 ; probe_ent->port[2 ].bmdma_addr =pci_resource_start (pdev,4 ) +16 ; - probe_ent->port[2 ].scr_addr =ULI5287_BASE +ULI5287_OFFS *4 ; + hpriv->scr_cfg_addr[2 ] =ULI5287_BASE +ULI5287_OFFS *4 ; probe_ent->port[3 ].cmd_addr =pci_resource_start (pdev,2 ) +8 ; probe_ent->port[3 ].altstatus_addr = probe_ent->port[3 ].ctl_addr = (pci_resource_start (pdev,3 ) |ATA_PCI_CTL_OFS ) +4 ; probe_ent->port[3 ].bmdma_addr =pci_resource_start (pdev,4 ) +24 ; - probe_ent->port[3 ].scr_addr =ULI5287_BASE +ULI5287_OFFS *5 ; + hpriv->scr_cfg_addr[3 ] =ULI5287_BASE +ULI5287_OFFS *5 ;ata_std_ports (&probe_ent->port[2 ]);ata_std_ports (&probe_ent->port[3 ]);break ;case uli_5289: - probe_ent->port[0 ].scr_addr =ULI5287_BASE ; - probe_ent->port[1 ].scr_addr =ULI5287_BASE +ULI5287_OFFS ; + hpriv->scr_cfg_addr[0 ] =ULI5287_BASE ; + hpriv->scr_cfg_addr[1 ] =ULI5287_BASE +ULI5287_OFFS ;break ;case uli_5281: - probe_ent->port[0 ].scr_addr =ULI5281_BASE ; - probe_ent->port[1 ].scr_addr =ULI5281_BASE +ULI5281_OFFS ; + hpriv->scr_cfg_addr[0 ] =ULI5281_BASE ; + hpriv->scr_cfg_addr[1 ] =ULI5281_BASE +ULI5281_OFFS ;break ;default :
@@ -258,9 +274,10 @@ static int uli_init_one (struct pci_devreturn 0 ; +err_out_probe_ent: +kfree (probe_ent); err_out_regions:pci_release_regions (pdev); - err_out:if (!pci_dev_busy)pci_disable_device (pdev);