libata fixes
Subsystems (4)
PATCH 1/1 libata fixes
And a new, oft-reposted, finally ready cfl driver.
The ioctl fix is notable, an ugly bug.
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/Kconfig | 9 + drivers/ata/Makefile | 1 + drivers/ata/libata-core.c | 73 ++-- drivers/ata/libata-scsi.c | 17 +- drivers/ata/pata_ali.c | 28 +- drivers/ata/pata_atiixp.c | 32 +- drivers/ata/pata_octeon_cf.c | 965 +++++++++++++++++++++++++++++++++++ drivers/ata/sata_fsl.c | 2 +- drivers/ata/sata_via.c | 2 + drivers/scsi/ipr.c | 2 +- drivers/scsi/libsas/sas_scsi_host.c | 2 +- include/linux/libata.h | 11 +- 12 files changed, 1065 insertions(+), 79 deletions(-) create mode 100644 drivers/ata/pata_octeon_cf.c
Andrew Morton (1):
drivers/ata/pata_ali.c: s/isa_bridge/ali_isa_bridge/ to fix alpha build
David Daney (2):
libata: Add another column to the ata_timing table.
libata: New driver for OCTEON SOC Compact Flash interface (v7).
Jeff Garzik (1):
[libata] get-identity ioctl: Fix use of invalid memory pointer
[email protected] (1):
sata_via: Add VT8261 support
Michal Sojka (1):
sata_fsl: Return non-zero on error in probe()
Tejun Heo (1):
pata_atiixp: update port enabledness test handling
drivers/ata/Kconfig +9 -0
@@ -698,6 +698,15 @@ config PATA_IXP4XX_CF If unsure, say N. +config PATA_OCTEON_CF + tristate "OCTEON Boot Bus Compact Flash support" + depends on CPU_CAVIUM_OCTEON + help + This option enables a polled compact flash driver for use with + compact flash cards attached to the OCTEON boot bus. + + If unsure, say N. + config PATA_SCC tristate "Toshiba's Cell Reference Set IDE support" depends on PCI && PPC_CELLEB
drivers/ata/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o obj-$(CONFIG_PATA_SCC) += pata_scc.o obj-$(CONFIG_PATA_SCH) += pata_sch.o obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o +obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o
drivers/ata/libata-core.c +37 -36
97 lines not on this page · raw message
drivers/ata/libata-scsi.c +13 -4
@@ -423,9 +423,9 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,* RETURNS: * Zero on success, negative errno on error. */ -static int ata_get_identity (struct scsi_device *sdev,void __user *arg) +static int ata_get_identity (struct ata_port *ap,struct scsi_device *sdev, +void __user *arg) { -struct ata_port *ap =ata_shost_to_port (sdev->host);struct ata_device *dev =ata_scsi_find_dev (ap, sdev);u16 __user *dst = arg;char buf[40 ];
@@ -645,7 +645,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)return rc; } -int ata_scsi_ioctl (struct scsi_device *scsidev,int cmd,void __user *arg) +int ata_sas_scsi_ioctl (struct ata_port *ap,struct scsi_device *scsidev, +int cmd,void __user *arg) {int val = -EINVAL , rc = -EINVAL ;
@@ -663,7 +664,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)return 0 ;case HDIO_GET_IDENTITY : -return ata_get_identity (scsidev, arg); +return ata_get_identity (ap, scsidev, arg);case HDIO_DRIVE_CMD :if (!capable (CAP_SYS_ADMIN ) || !capable (CAP_SYS_RAWIO ))
@@ -682,6 +683,14 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)return rc; } +EXPORT_SYMBOL_GPL (ata_sas_scsi_ioctl); + +int ata_scsi_ioctl (struct scsi_device *scsidev,int cmd,void __user *arg) +{ +return ata_sas_scsi_ioctl (ata_shost_to_port (scsidev->host), + scsidev, cmd, arg); +} +EXPORT_SYMBOL_GPL (ata_scsi_ioctl);/** * ata_scsi_qc_new - acquire new ata_queued_cmd reference
drivers/ata/pata_ali.c +14 -14
@@ -41,7 +41,7 @@ static int ali_atapi_dma = 0;module_param_named (atapi_dma, ali_atapi_dma, int,0644 );MODULE_PARM_DESC (atapi_dma,"Enable ATAPI DMA (0=disable, 1=enable)" ); -static struct pci_dev *isa_bridge; +static struct pci_dev *ali_isa_bridge;/* * Cable special cases
@@ -346,13 +346,13 @@ static void ali_c2_c3_postreset(struct ata_link *link, unsigned int *classes)int port_bit =4 << link->ap->port_no;/* If our bridge is an ALI 1533 then do the extra work */ -if (isa_bridge) { +if (ali_isa_bridge) {/* Tristate and re-enable the bus signals */ -pci_read_config_byte (isa_bridge,0x58 , &r); +pci_read_config_byte (ali_isa_bridge,0x58 , &r); r &= ~port_bit; -pci_write_config_byte (isa_bridge,0x58 , r); +pci_write_config_byte (ali_isa_bridge,0x58 , r); r |= port_bit; -pci_write_config_byte (isa_bridge,0x58 , r); +pci_write_config_byte (ali_isa_bridge,0x58 , r); }ata_sff_postreset (link, classes); }
@@ -467,14 +467,14 @@ static void ali_init_chipset(struct pci_dev *pdev)pci_write_config_byte (pdev,0x53 , tmp); } north =pci_get_bus_and_slot (0 ,PCI_DEVFN (0 ,0 )); -if (north && north->vendor ==PCI_VENDOR_ID_AL && isa_bridge) { +if (north && north->vendor ==PCI_VENDOR_ID_AL && ali_isa_bridge) {/* Configure the ALi bridge logic. For non ALi rely on BIOS. Set the south bridge enable bit */ -pci_read_config_byte (isa_bridge,0x79 , &tmp); +pci_read_config_byte (ali_isa_bridge,0x79 , &tmp);if (pdev->revision ==0xC2 ) -pci_write_config_byte (isa_bridge,0x79 , tmp |0x04 ); +pci_write_config_byte (ali_isa_bridge,0x79 , tmp |0x04 );else if (pdev->revision >0xC2 && pdev->revision <0xC5 ) -pci_write_config_byte (isa_bridge,0x79 , tmp |0x02 ); +pci_write_config_byte (ali_isa_bridge,0x79 , tmp |0x02 ); }pci_dev_put (north);ata_pci_bmdma_clear_simplex (pdev);
@@ -571,9 +571,9 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)ali_init_chipset (pdev); -if (isa_bridge && pdev->revision >=0x20 && pdev->revision <0xC2 ) { +if (ali_isa_bridge && pdev->revision >=0x20 && pdev->revision <0xC2 ) {/* Are we paired with a UDMA capable chip */ -pci_read_config_byte (isa_bridge,0x5E , &tmp); +pci_read_config_byte (ali_isa_bridge,0x5E , &tmp);if ((tmp &0x1E ) ==0x12 ) ppi[0 ] = &info_20_udma; }
@@ -617,11 +617,11 @@ static struct pci_driver ali_pci_driver = {static int __init ali_init (void ) {int ret; - isa_bridge =pci_get_device (PCI_VENDOR_ID_AL ,PCI_DEVICE_ID_AL_M1533 ,NULL ); + ali_isa_bridge =pci_get_device (PCI_VENDOR_ID_AL ,PCI_DEVICE_ID_AL_M1533 ,NULL ); ret =pci_register_driver (&ali_pci_driver);if (ret <0 ) -pci_dev_put (isa_bridge); +pci_dev_put (ali_isa_bridge);return ret; }
@@ -629,7 +629,7 @@ static int __init ali_init(void) static void __exit ali_exit(void) {pci_unregister_driver (&ali_pci_driver); -pci_dev_put (isa_bridge); +pci_dev_put (ali_isa_bridge); }
drivers/ata/pata_atiixp.c +13 -19
@@ -32,21 +32,6 @@ enum { ATIIXP_IDE_UDMA_MODE = 0x56 }; -static int atiixp_pre_reset (struct ata_link *link,unsigned long deadline) -{ -struct ata_port *ap = link->ap; -static const struct pci_bits atiixp_enable_bits[] = { - {0x48 ,1 ,0x01 ,0x00 }, - {0x48 ,1 ,0x08 ,0x00 } - }; -struct pci_dev *pdev =to_pci_dev (ap->host->dev); - -if (!pci_test_config_bits (pdev, &atiixp_enable_bits[ap->port_no])) -return -ENOENT ; - -return ata_sff_prereset (link, deadline); -} -static int atiixp_cable_detect (struct ata_port *ap) {struct pci_dev *pdev =to_pci_dev (ap->host->dev);
@@ -229,10 +214,9 @@ static struct ata_port_operations atiixp_port_ops = { .cable_detect = atiixp_cable_detect, .set_piomode = atiixp_set_piomode, .set_dmamode = atiixp_set_dmamode, - .prereset = atiixp_pre_reset, }; -static int atiixp_init_one (struct pci_dev *dev,const struct pci_device_id *id) +static int atiixp_init_one (struct pci_dev *pdev,const struct pci_device_id *id) {static const struct ata_port_info info = { .flags =ATA_FLAG_SLAVE_POSS ,
@@ -241,8 +225,18 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x3F, .port_ops = &atiixp_port_ops }; -const struct ata_port_info *ppi[] = { &info,NULL }; -return ata_pci_sff_init_one (dev, ppi, &atiixp_sht,NULL ); +static const struct pci_bits atiixp_enable_bits[] = { + {0x48 ,1 ,0x01 ,0x00 }, + {0x48 ,1 ,0x08 ,0x00 } + }; +const struct ata_port_info *ppi[] = { &info, &info }; +int i; + +for (i =0 ; i <2 ; i++) +if (!pci_test_config_bits (pdev, &atiixp_enable_bits[i])) + ppi[i] = &ata_dummy_port_info; + +return ata_pci_sff_init_one (pdev, ppi, &atiixp_sht,NULL ); }static const struct pci_device_id atiixp[] = {
drivers/ata/pata_octeon_cf.c new file +965 -0
965 lines not on this page · raw message
drivers/ata/sata_fsl.c +1 -1
@@ -1288,7 +1288,7 @@ static const struct ata_port_info sata_fsl_port_info[] = {static int sata_fsl_probe (struct of_device *ofdev,const struct of_device_id *match) { -int retval =0 ; +int retval = -ENXIO ;void __iomem *hcr_base =NULL ;void __iomem *ssr_base =NULL ;void __iomem *csr_base =NULL ;
drivers/ata/sata_via.c +2 -0
@@ -92,6 +92,8 @@ static const struct pci_device_id svia_pci_tbl[] = { { PCI_VDEVICE(VIA, 0x5372), vt6420 }, { PCI_VDEVICE(VIA, 0x7372), vt6420 }, { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */ + { PCI_VDEVICE(VIA, 0x9000), vt8251 }, + { PCI_VDEVICE(VIA, 0x9040), vt8251 }, { } /* terminate list */ };
drivers/scsi/ipr.c +1 -1
@@ -4912,7 +4912,7 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)if (res &&ipr_is_gata (res)) {if (cmd ==HDIO_GET_IDENTITY )return -ENOTTY ; -return ata_scsi_ioctl (sdev, cmd, arg); +return ata_sas_scsi_ioctl (res->sata_port->ap, sdev, cmd, arg); }return -EINVAL ;
drivers/scsi/libsas/sas_scsi_host.c +1 -1
@@ -717,7 +717,7 @@ int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)struct domain_device *dev =sdev_to_domain_dev (sdev);if (dev_is_sata (dev)) -return ata_scsi_ioctl (sdev, cmd, arg); +return ata_sas_scsi_ioctl (dev->sata_dev.ap, sdev, cmd, arg);return -EINVAL ; }
include/linux/libata.h +8 -3
@@ -401,12 +401,14 @@ enum {ATA_TIMING_CYC8B ,ATA_TIMING_ACTIVE = (1 <<4 ),ATA_TIMING_RECOVER = (1 <<5 ), -ATA_TIMING_CYCLE = (1 <<6 ), -ATA_TIMING_UDMA = (1 <<7 ), +ATA_TIMING_DMACK_HOLD = (1 <<6 ), +ATA_TIMING_CYCLE = (1 <<7 ), +ATA_TIMING_UDMA = (1 <<8 ),ATA_TIMING_ALL =ATA_TIMING_SETUP |ATA_TIMING_ACT8B |ATA_TIMING_REC8B |ATA_TIMING_CYC8B |ATA_TIMING_ACTIVE |ATA_TIMING_RECOVER | - ATA_TIMING_CYCLE | ATA_TIMING_UDMA, +ATA_TIMING_DMACK_HOLD |ATA_TIMING_CYCLE | + ATA_TIMING_UDMA, }; enum ata_xfer_mask {
@@ -866,6 +868,7 @@ struct ata_timing {unsigned short cyc8b;/* t0 for 8-bit I/O */ unsigned short active;/* t2 or tD */ unsigned short recover;/* t2i or tK */ +unsigned short dmack_hold;/* tj */ unsigned short cycle;/* t0 */ unsigned short udma;/* t2CYCTYP/2 */ };
@@ -927,6 +930,8 @@ extern void ata_host_init(struct ata_host *, struct device *,extern int ata_scsi_detect (struct scsi_host_template *sht);extern int ata_scsi_ioctl (struct scsi_device *dev,int cmd,void __user *arg);extern int ata_scsi_queuecmd (struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *)); +extern int ata_sas_scsi_ioctl (struct ata_port *ap,struct scsi_device *dev, +int cmd,void __user *arg);extern void ata_sas_port_destroy (struct ata_port *);extern struct ata_port *ata_sas_port_alloc (struct ata_host *,struct ata_port_info *,struct Scsi_Host *);
Quoted 8 lines · On Fri, 16 Jan 2009 10:27:21 -0500 Jeff Garzik <[email protected]> wrote:
And a new, oft-reposted, finally ready cfl driver.
The ioctl fix is notable, an ugly bug.
Please pull from 'upstream-linus' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git upstream-linus
Quoted 6 lines
to receive the following updates:
...
Andrew Morton (1):
drivers/ata/pata_ali.c: s/isa_bridge/ali_isa_bridge/ to fix alpha build
hi, mom.
Quoted 12 lines
...
drivers/ata/pata_atiixp.c +1
-1-static int atiixp_init_one (struct pci_dev *dev,const struct pci_device_id *id) +static int atiixp_init_one (struct pci_dev *pdev,const struct pci_device_id *id) {static const struct ata_port_info info = { .flags =ATA_FLAG_SLAVE_POSS ,@@ -241,8 +225,18 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x3F, .port_ops = &atiixp_port_ops };
drivers/ata/pata_atiixp.c static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) · line 235
Quoted 10 lines
drivers/ata/pata_atiixp.c +8
-2-const struct ata_port_info *ppi[] = { &info,NULL }; -return ata_pci_sff_init_one (dev, ppi, &atiixp_sht,NULL ); +static const struct pci_bits atiixp_enable_bits[] = { + {0x48 ,1 ,0x01 ,0x00 }, + {0x48 ,1 ,0x08 ,0x00 } + }; +const struct ata_port_info *ppi[] = { &info, &info }; +int i; + +for (i =0 ; i <2 ; i++)
s/2/ARRAY_SIZE/
Quoted 55 lines
drivers/ata/pata_atiixp.c +4
-0+if (!pci_test_config_bits (pdev, &atiixp_enable_bits[i])) + ppi[i] = &ata_dummy_port_info; + +return ata_pci_sff_init_one (pdev, ppi, &atiixp_sht,NULL ); }drivers/ata/pata_octeon_cf.c new file +43
-0@@ -0,0 +1,965 @@ +/* +* Driver for the Octeon bootbus compact flash. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +* +* Copyright (C) 2005 - 2009 Cavium Networks +* Copyright (C) 2008 Wind River Systems +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/libata.h> +#include <linux/irq.h> +#include <linux/platform_device.h> +#include <linux/workqueue.h> +#include <scsi/scsi_host.h> + +#include <asm/octeon/octeon.h> + +/* +* The Octeon bootbus compact flash interface is connected in at least +* 3 different configurations on various evaluation boards: +* +* -- 8 bits no irq, no DMA +* -- 16 bits no irq, no DMA +* -- 16 bits True IDE mode with DMA, but no irq. +* +* In the last case the DMA engine can generate an interrupt when the +* transfer is complete. For the first two cases only PIO is supported. +* +*/ + +#define DRV_NAME "pata_octeon_cf" +#define DRV_VERSION "2.1" + + +struct octeon_cf_port { +struct workqueue_struct *wq; +struct delayed_work delayed_finish; +struct ata_port *ap; +int dma_finished;
drivers/ata/pata_octeon_cf.c line 53
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +10
-0+}; + +static struct scsi_host_template octeon_cf_sht = { +ATA_PIO_SHT (DRV_NAME ), +}; + +/** +* Convert nanosecond based time to setting used in the +* boot bus timing register, based on timing multiple +*/
There are comments in this file which use the kerneldoc token, but which aren't in kerneldoc format.
Quoted 4 lines
drivers/ata/pata_octeon_cf.c new file +3
-0+static unsigned int ns_to_tim_reg (unsigned int tim_mult,unsigned int nsecs) +{ +unsigned int val;
drivers/ata/pata_octeon_cf.c line 66
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +10
-0+ +/* +* Compute # of eclock periods to get desired duration in +* nanoseconds. +*/ + val =DIV_ROUND_UP (nsecs * (octeon_get_clock_rate () /1000000 ), +1000 * tim_mult); + +return val; +}
There's great potential for overflows here, but I couldn't be bothered picking through it. Are we sure that it's watertight?
There's a 64-bit divide in there. Will it link on 32-bit platforms?
Or is this all 64-bit-only code?
wtf is an octeon anyway? (greps). Some MIPS thing. I guess it's 64-bit-only.
Quoted 14 lines
drivers/ata/pata_octeon_cf.c new file +14
-0+static void octeon_cf_set_boot_reg_cfg (int cs) +{ +union cvmx_mio_boot_reg_cfgx reg_cfg; + reg_cfg.u64 =cvmx_read_csr (CVMX_MIO_BOOT_REG_CFGX (cs)); + reg_cfg.s.dmack =0 ;/* Don't assert DMACK on access */ + reg_cfg.s.tim_mult =2 ;/* Timing mutiplier 2x */ + reg_cfg.s.rd_dly =0 ;/* Sample on falling edge of BOOT_OE */ + reg_cfg.s.sam =0 ;/* Don't combine write and output enable */ + reg_cfg.s.we_ext =0 ;/* No write enable extension */ + reg_cfg.s.oe_ext =0 ;/* No read enable extension */ + reg_cfg.s.en =1 ;/* Enable this region */ + reg_cfg.s.orbit =0 ;/* Don't combine with previous region */ + reg_cfg.s.ale =0 ;/* Don't do address multiplexing */ +cvmx_write_csr (CVMX_MIO_BOOT_REG_CFGX (cs), reg_cfg.u64);
drivers/ata/pata_octeon_cf.c line 91
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +10
-0+} + +/** +* Called after libata determines the needed PIO mode. This +* function programs the Octeon bootbus regions to support the +* timing requirements of the PIO mode. +* +* @ap: ATA port information +* @dev: ATA device +*/
That's getting more kerneldoccy, but isn't there yet.
Quoted 7 lines
drivers/ata/pata_octeon_cf.c new file +7
-0+static void octeon_cf_set_piomode (struct ata_port *ap,struct ata_device *dev) +{ +struct octeon_cf_data *ocd = ap->dev->platform_data; +union cvmx_mio_boot_reg_timx reg_tim; +int cs = ocd->base_region; +int T ; +struct ata_timing timing;
drivers/ata/pata_octeon_cf.c line 108
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +10
-0+ +int use_iordy; +int trh; +int pause; +/* These names are timing parameters from the ATA spec */ +int t1; +int t2; +int t2i; + +T = (int )(2000000000000LL /octeon_get_clock_rate ());
64/64 divide.
Quoted 64 lines
drivers/ata/pata_octeon_cf.c new file +64
-0+if (ata_timing_compute (dev, dev->pio_mode, &timing,T ,T )) +BUG (); + + t1 = timing.setup; +if (t1) + t1--; + t2 = timing.active; +if (t2) + t2--; + t2i = timing.act8b; +if (t2i) + t2i--; + + trh =ns_to_tim_reg (2 ,20 ); +if (trh) + trh--; + + pause = timing.cycle - timing.active - timing.setup - trh; +if (pause) + pause--; + +octeon_cf_set_boot_reg_cfg (cs); +if (ocd->dma_engine >=0 ) +/* True IDE mode, program both chip selects. */ +octeon_cf_set_boot_reg_cfg (cs +1 ); + + + use_iordy =ata_pio_need_iordy (dev); + + reg_tim.u64 =cvmx_read_csr (CVMX_MIO_BOOT_REG_TIMX (cs)); +/* Disable page mode */ + reg_tim.s.pagem =0 ; +/* Enable dynamic timing */ + reg_tim.s.waitm = use_iordy; +/* Pages are disabled */ + reg_tim.s.pages =0 ; +/* We don't use multiplexed address mode */ + reg_tim.s.ale =0 ; +/* Not used */ + reg_tim.s.page =0 ; +/* Time after IORDY to coninue to assert the data */ + reg_tim.s.wait =0 ; +/* Time to wait to complete the cycle. */ + reg_tim.s.pause = pause; +/* How long to hold after a write to de-assert CE. */ + reg_tim.s.wr_hld = trh; +/* How long to wait after a read to de-assert CE. */ + reg_tim.s.rd_hld = trh; +/* How long write enable is asserted */ + reg_tim.s.we = t2; +/* How long read enable is asserted */ + reg_tim.s.oe = t2; +/* Time after CE that read/write starts */ + reg_tim.s.ce =ns_to_tim_reg (2 ,5 ); +/* Time before CE that address is valid */ + reg_tim.s.adr =0 ; + +/* Program the bootbus region timing for the data port chip select. */ +cvmx_write_csr (CVMX_MIO_BOOT_REG_TIMX (cs), reg_tim.u64); +if (ocd->dma_engine >=0 ) +/* True IDE mode, program both chip selects. */ +cvmx_write_csr (CVMX_MIO_BOOT_REG_TIMX (cs +1 ), reg_tim.u64); +} +
drivers/ata/pata_octeon_cf.c
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +7
-0+static void octeon_cf_tf_read16 (struct ata_port *ap,struct ata_taskfile *tf) +{ +u16 blob; +/* The base of the registers is at ioaddr.data_addr. */ +void __iomem *base = ap->ioaddr.data_addr; + + blob =__raw_readw (base +0xc );
why __raw?
Quoted 36 lines
drivers/ata/pata_octeon_cf.c new file +36
-0+ tf->feature = blob >>8 ; + + blob =__raw_readw (base +2 ); + tf->nsect = blob &0xff ; + tf->lbal = blob >>8 ; + + blob =__raw_readw (base +4 ); + tf->lbam = blob &0xff ; + tf->lbah = blob >>8 ; + + blob =__raw_readw (base +6 ); + tf->device = blob &0xff ; + tf->command = blob >>8 ; + +if (tf->flags &ATA_TFLAG_LBA48 ) { +if (likely (ap->ioaddr.ctl_addr)) { +iowrite8 (tf->ctl |ATA_HOB , ap->ioaddr.ctl_addr); + + blob =__raw_readw (base +0xc ); + tf->hob_feature = blob >>8 ; + + blob =__raw_readw (base +2 ); + tf->hob_nsect = blob &0xff ; + tf->hob_lbal = blob >>8 ; + + blob =__raw_readw (base +4 ); + tf->hob_lbam = blob &0xff ; + tf->hob_lbah = blob >>8 ; + +iowrite8 (tf->ctl, ap->ioaddr.ctl_addr); + ap->last_ctl = tf->ctl; + }else { +WARN_ON (1 ); + } + } +}
drivers/ata/pata_octeon_cf.c
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +7
-0+ +static void octeon_cf_dma_setup (struct ata_queued_cmd *qc) +{ +struct ata_port *ap = qc->ap; +struct octeon_cf_port *cf_port; + + cf_port = (struct octeon_cf_port *)ap->private_data;
Unneeded, undesirable cast of void* (multiple instances).
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +8
-0+DPRINTK ("ENTER\n" ); +/* issue r/w command */ + qc->cursg = qc->sg; + cf_port->dma_finished =0 ; + ap->ops->sff_exec_command (ap, &qc->tf); +DPRINTK ("EXIT\n" ); +} +
drivers/ata/pata_octeon_cf.c
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +9
-0+static irqreturn_t octeon_cf_interrupt (int irq,void *dev_instance) +{ +struct ata_host *host = dev_instance; +struct octeon_cf_port *cf_port; +int i; +unsigned int handled =0 ; +unsigned long flags; + +spin_lock_irqsave (&host->lock, flags);
Would spin_lock() suffice here?
Quoted 68 lines
drivers/ata/pata_octeon_cf.c new file +65
-0+DPRINTK ("ENTER\n" ); +for (i =0 ; i < host->n_ports; i++) { +u8 status; +struct ata_port *ap; +struct ata_queued_cmd *qc; +union cvmx_mio_boot_dma_intx dma_int; +union cvmx_mio_boot_dma_cfgx dma_cfg; +struct octeon_cf_data *ocd; + + ap = host->ports[i]; + ocd = ap->dev->platform_data; +if (!ap || (ap->flags &ATA_FLAG_DISABLED )) +continue ; + + ocd = ap->dev->platform_data; + cf_port = (struct octeon_cf_port *)ap->private_data; + dma_int.u64 = +cvmx_read_csr (CVMX_MIO_BOOT_DMA_INTX (ocd->dma_engine)); + dma_cfg.u64 = +cvmx_read_csr (CVMX_MIO_BOOT_DMA_CFGX (ocd->dma_engine)); + + qc =ata_qc_from_tag (ap, ap->link.active_tag); + +if (qc && (!(qc->tf.flags &ATA_TFLAG_POLLING )) && + (qc->flags &ATA_QCFLAG_ACTIVE )) { +if (dma_int.s.done && !dma_cfg.s.en) { +if (!sg_is_last (qc->cursg)) { + qc->cursg =sg_next (qc->cursg); + handled =1 ; +octeon_cf_dma_start (qc); +continue ; + }else { + cf_port->dma_finished =1 ; + } + } +if (!cf_port->dma_finished) +continue ; + status =ioread8 (ap->ioaddr.altstatus_addr); +if (status & (ATA_BUSY |ATA_DRQ )) { +/* +* We are busy, try to handle it +* later. This is the DMA finished +* interrupt, and it could take a +* little while for the card to be +* ready for more commands. +*/ +/* Clear DMA irq. */ + dma_int.u64 =0 ; + dma_int.s.done =1 ; +cvmx_write_csr (CVMX_MIO_BOOT_DMA_INTX (ocd->dma_engine), + dma_int.u64); + +queue_delayed_work (cf_port->wq, + &cf_port->delayed_finish,1 ); + handled =1 ; + }else { + handled |=octeon_cf_dma_finished (ap, qc); + } + } + } +spin_unlock_irqrestore (&host->lock, flags); +DPRINTK ("EXIT\n" ); +return IRQ_RETVAL (handled); +} +
Quoted 3 lines
drivers/ata/pata_atiixp.c static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) · line 235
Quoted 1 line
drivers/ata/pata_atiixp.c +1
-0+for (i =0 ; i <2 ; i++)s/2/ARRAY_SIZE/
It's 2. It's always 2 for a SFF controller. ARRAY_SIZE is just confusing in this case as the array won't change size.
Quoted 5 lines
There's a 64-bit divide in there. Will it link on 32-bit platforms? Or is this all 64-bit-only code?
wtf is an octeon anyway? (greps). Some MIPS thing. I guess it's 64-bit-only.
Board specific driver anyway
Hello.
Quoted 17 lines · Andrew Morton
drivers/ata/pata_octeon_cf.c line 66
Quoted 13 lines
drivers/ata/pata_octeon_cf.c new file +13
-0+static unsigned int ns_to_tim_reg (unsigned int tim_mult,unsigned int nsecs) +{ +unsigned int val; + +/* +* Compute # of eclock periods to get desired duration in +* nanoseconds. +*/ + val =DIV_ROUND_UP (nsecs * (octeon_get_clock_rate () /1000000 ), +1000 * tim_mult); + +return val; +}There's great potential for overflows here, but I couldn't be bothered picking through it. Are we sure that it's watertight?
Quoted 6 lines
There's a 64-bit divide in there. Will it link on 32-bit platforms?
Or is this all 64-bit-only code?
wtf is an octeon anyway? (greps). Some MIPS thing. I guess it's 64-bit-only.
Yes, it's multicore MIPS64. AFAIK, it should be able to run 32-bit kernel
(don't think that it's really worth it).
WBR, Sergei
On Fri, Jan 16, 2009 at 9:31 AM, Andrew Morton
<[email protected]> wrote:
...
Quoted 9 lines
drivers/ata/pata_octeon_cf.c line 343
Quoted 7 lines
drivers/ata/pata_octeon_cf.c new file +7
-0+static void octeon_cf_tf_read16 (struct ata_port *ap,struct ata_taskfile *tf) +{ +u16 blob; +/* The base of the registers is at ioaddr.data_addr. */ +void __iomem *base = ap->ioaddr.data_addr; + + blob =__raw_readw (base +0xc );why
__raw?
Avoid byte swapping. If it's "native" HW on Big Endian platform, byte swapping isn't needed. If it's working, it's correct.
hth,
grant
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Fri, 16 Jan 2009 10:27:21 -0500 Jeff Garzik <[email protected]> wrote:
+/**
+ * Convert nanosecond based time to setting used in the
+ * boot bus timing register, based on timing multiple
+ */There are comments in this file which use the kerneldoc token, but which aren't in kerneldoc format.
I will endeavor to improve it.
Quoted 9 lines
Quoted 9 lines
drivers/ata/pata_octeon_cf.c new file +9
-0+static unsigned int ns_to_tim_reg (unsigned int tim_mult,unsigned int nsecs) +{ +unsigned int val; + +/* +* Compute # of eclock periods to get desired duration in +* nanoseconds. +*/ + val = DIV_ROUND_UP(nsecs * (octeon_get_clock_rate() / 1000000),
Quoted 9 lines
drivers/ata/pata_octeon_cf.c line 66
Quoted 5 lines
drivers/ata/pata_octeon_cf.c new file +4
-0+ 1000 * tim_mult); + +return val; +}There's great potential for overflows here, but I couldn't be bothered picking through it. Are we sure that it's watertight?
We are calculating timing register values, there will not be overflow given that the delays are all under 1000nS and the clock rate will never be greater than 10GHz.
Quoted 1 line
There's a 64-bit divide in there. Will it link on 32-bit platforms?
It might not...
Quoted 3 lines
Or is this all 64-bit-only code?
... but we are currently only supporting 64 bit kernels.
Quoted 1 line
wtf is an octeon anyway? (greps). Some MIPS thing.
Multicore MIPS64 SOC.
Quoted 1 line
I guess it's 64-bit-only.
Current, yes. See above.
[...]
Quoted 10 lines
Quoted 8 lines
+/**
+ * Called after libata determines the needed PIO mode. This
+ * function programs the Octeon bootbus regions to support the
+ * timing requirements of the PIO mode.
+ *
+ * @ap: ATA port information
+ * @dev: ATA device
+ */That's getting more kerneldoccy, but isn't there yet.
As with the others, I will try to improve it.
[...]
Quoted 4 lines
drivers/ata/pata_octeon_cf.c line 108
Quoted 1 line
drivers/ata/pata_octeon_cf.c new file +1
-0+T = (int )(2000000000000LL /octeon_get_clock_rate ());64/64 divide.
As with the case above, it works as only 64 bit kernel supported.
[...]
Quoted 10 lines
drivers/ata/pata_octeon_cf.c line 343
Quoted 7 lines
drivers/ata/pata_octeon_cf.c new file +7
-0+static void octeon_cf_tf_read16 (struct ata_port *ap,struct ata_taskfile *tf) +{ +u16 blob; +/* The base of the registers is at ioaddr.data_addr. */ +void __iomem *base = ap->ioaddr.data_addr; + + blob =__raw_readw (base +0xc );why
__raw?
readw() does byte swapping, we don't want that, hence the __raw.
[...]
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + cf_port = (struct octeon_cf_port *)ap->private_data;Unneeded, undesirable cast of void* (multiple instances).
I will fix it.
[...]
Quoted 12 lines
drivers/ata/pata_octeon_cf.c line 643
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +9
-0+static irqreturn_t octeon_cf_interrupt (int irq,void *dev_instance) +{ +struct ata_host *host = dev_instance; +struct octeon_cf_port *cf_port; +int i; +unsigned int handled =0 ; +unsigned long flags; + +spin_lock_irqsave (&host->lock, flags);Would
spin_lock()suffice here?
I have to think about that one.
Thanks for looking at it,
David daney
Quoted 17 lines · David Daney
Quoted 1 line · Andrew Morton
On Fri, 16 Jan 2009 10:27:21 -0500 Jeff Garzik <[email protected]> wrote:
[...]
Quoted 12 lines
drivers/ata/pata_octeon_cf.c line 643
Quoted 10 lines
drivers/ata/pata_octeon_cf.c new file +9
-0+static irqreturn_t octeon_cf_interrupt (int irq,void *dev_instance) +{ +struct ata_host *host = dev_instance; +struct octeon_cf_port *cf_port; +int i; +unsigned int handled =0 ; +unsigned long flags; + +spin_lock_irqsave (&host->lock, flags);Would
spin_lock()suffice here?
Quoted 2 lines
I have to think about that one.
The answer is an empirically determined No.
After switching to a spin_lock() as you suggested, I get:
BUG: spinlock recursion on CPU#0, pata_octeon_cf/700 lock: a80000041e8bd218, .magic: dead4ead, .owner: pata_octeon_cf/700, .owner_cpu: 0 Call Trace: [<ffffffffc000c3ec>] dump_stack+0x8/0x34 [<ffffffffc01b9a14>] _raw_spin_lock+0xdc/0x1b0 [<ffffffffc0211680>] ata_scsi_queuecmd+0x40/0x2d8 [<ffffffffc01f4358>] scsi_dispatch_cmd+0x108/0x280 [<ffffffffc01fa778>] scsi_request_fn+0x3a0/0x4a0 [<ffffffffc019a2ec>] blk_invoke_request_fn+0xd4/0x1c0 [<ffffffffc019a9f8>] blk_run_queue+0x28/0x48 [<ffffffffc01f9b74>] scsi_run_queue+0xf4/0x398 [<ffffffffc01faafc>] scsi_next_command+0x3c/0x58 [<ffffffffc01fb7e4>] scsi_io_completion+0x344/0x520 [<ffffffffc019f8a8>] blk_done_softirq+0x98/0xb8 [<ffffffffc004dc18>] __do_softirq+0xd8/0x1f8 [<ffffffffc004ddc0>] do_softirq+0x88/0xa0 [<ffffffffc004e084>] irq_exit+0xac/0xd0 [<ffffffffc0011090>] plat_irq_dispatch+0x100/0x200 [<ffffffffc0000980>] ret_from_irq+0x0/0x4 [<ffffffffc019fa84>] __blk_complete_request+0x114/0x140 [<ffffffffc020f1a8>] ata_scsi_qc_complete+0x1b8/0x400 [<ffffffffc0219dec>] ata_sff_hsm_move+0x10c/0x860 [<ffffffffc021cb20>] octeon_cf_dma_finished+0x188/0x228 [<ffffffffc021ccd8>] octeon_cf_delayed_finish+0x118/0x138 [<ffffffffc005cf94>] run_workqueue+0xcc/0x1a8 [<ffffffffc005d448>] worker_thread+0x60/0xd0 [<ffffffffc0062058>] kthread+0x58/0xa8 [<ffffffffc001a020>] kernel_thread_helper+0x10/0x18
Apparently scsi_io_completion() is called from a softirq, so calls to ata_sff_hsm_move() must be done with interrupts disabled so that a softirq on the same CPU doesn't deadlock with itself.
I am sure you all will correct me if my interpretation of the trace is incorrect.
David Daney