sched: use show_regs() to improve __schedule_bug() output
[safe/jmp/linux-2.6] / include / linux / libata.h
index 84dfc23..6fd24e0 100644 (file)
@@ -28,9 +28,8 @@
 
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <linux/pci.h>
 #include <linux/dma-mapping.h>
-#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
 #include <linux/io.h>
 #include <linux/ata.h>
 #include <linux/workqueue.h>
@@ -107,12 +106,6 @@ static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
 /* defines only for the constants which don't work well as enums */
 #define ATA_TAG_POISON         0xfafbfcfdU
 
-/* move to PCI layer? */
-static inline struct device *pci_dev_to_dev(struct pci_dev *pdev)
-{
-       return &pdev->dev;
-}
-
 enum {
        /* various global constants */
        LIBATA_MAX_PRD          = ATA_MAX_PRD / 2,
@@ -210,6 +203,7 @@ enum {
        ATA_PFLAG_UNLOADING     = (1 << 5), /* module is unloading */
        ATA_PFLAG_SCSI_HOTPLUG  = (1 << 6), /* SCSI hotplug scheduled */
        ATA_PFLAG_INITIALIZING  = (1 << 7), /* being initialized, don't touch */
+       ATA_PFLAG_RESETTING     = (1 << 8), /* reset in progress */
 
        ATA_PFLAG_SUSPENDED     = (1 << 17), /* port is suspended (power) */
        ATA_PFLAG_PM_PENDING    = (1 << 18), /* PM operation pending */
@@ -332,7 +326,7 @@ enum {
        ATA_HORKAGE_SKIP_PM     = (1 << 5),     /* Skip PM operations */
        ATA_HORKAGE_HPA_SIZE    = (1 << 6),     /* native size off by one */
 
-        /* DMA mask for user DMA control: User visible values; DO NOT 
+        /* DMA mask for user DMA control: User visible values; DO NOT
            renumber */
        ATA_DMA_MASK_ATA        = (1 << 0),     /* DMA on ATA Disk */
        ATA_DMA_MASK_ATAPI      = (1 << 1),     /* DMA on ATAPI */
@@ -422,6 +416,7 @@ struct ata_queued_cmd {
        unsigned long           flags;          /* ATA_QCFLAG_xxx */
        unsigned int            tag;
        unsigned int            n_elem;
+       unsigned int            n_iter;
        unsigned int            orig_n_elem;
 
        int                     dma_dir;
@@ -432,7 +427,7 @@ struct ata_queued_cmd {
        unsigned int            nbytes;
        unsigned int            curbytes;
 
-       unsigned int            cursg;
+       struct scatterlist      *cursg;
        unsigned int            cursg_ofs;
 
        struct scatterlist      sgent;
@@ -668,8 +663,6 @@ struct ata_port_operations {
        /* port multiplier */
        void (*pmp_attach) (struct ata_port *ap);
        void (*pmp_detach) (struct ata_port *ap);
-       int (*pmp_read) (struct ata_device *dev, int pmp, int reg, u32 *r_val);
-       int (*pmp_write) (struct ata_device *dev, int pmp, int reg, u32 val);
 
        /* Error handlers.  ->error_handler overrides ->eng_timeout and
         * indicates that new-style EH is in place.
@@ -724,7 +717,7 @@ struct ata_timing {
        unsigned short udma;            /* t2CYCTYP/2 */
 };
 
-#define FIT(v,vmin,vmax)       max_t(short,min_t(short,v,vmax),vmin)
+#define FIT(v, vmin, vmax)     max_t(short, min_t(short, v, vmax), vmin)
 
 extern const unsigned long sata_deb_timing_normal[];
 extern const unsigned long sata_deb_timing_hotplug[];
@@ -767,18 +760,7 @@ extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
 extern void ata_port_disable(struct ata_port *);
 extern void ata_std_ports(struct ata_ioports *ioaddr);
-#ifdef CONFIG_PCI
-extern int ata_pci_init_one (struct pci_dev *pdev,
-                            const struct ata_port_info * const * ppi);
-extern void ata_pci_remove_one (struct pci_dev *pdev);
-#ifdef CONFIG_PM
-extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
-extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
-extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
-extern int ata_pci_device_resume(struct pci_dev *pdev);
-#endif
-extern int ata_pci_clear_simplex(struct pci_dev *pdev);
-#endif /* CONFIG_PCI */
+
 extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
 extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
                        const struct ata_port_info * const * ppi, int n_ports);
@@ -834,14 +816,14 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
 extern void ata_tf_to_fis(const struct ata_taskfile *tf,
                          u8 pmp, int is_cmd, u8 *fis);
 extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
-extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
-extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
+extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
+extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
 extern u8 ata_check_status(struct ata_port *ap);
 extern u8 ata_altstatus(struct ata_port *ap);
 extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
-extern int ata_port_start (struct ata_port *ap);
-extern int ata_sff_port_start (struct ata_port *ap);
-extern irqreturn_t ata_interrupt (int irq, void *dev_instance);
+extern int ata_port_start(struct ata_port *ap);
+extern int ata_sff_port_start(struct ata_port *ap);
+extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
 extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf,
                          unsigned int buflen, int write_data);
 extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
@@ -862,8 +844,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
 extern void ata_id_c_string(const u16 *id, unsigned char *s,
                            unsigned int ofs, unsigned int len);
 extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown);
-extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
-extern void ata_bmdma_start (struct ata_queued_cmd *qc);
+extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
+extern void ata_bmdma_start(struct ata_queued_cmd *qc);
 extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
 extern u8   ata_bmdma_status(struct ata_port *ap);
 extern void ata_bmdma_irq_clear(struct ata_port *ap);
@@ -929,11 +911,26 @@ enum {
 /* libata-acpi.c */
 #ifdef CONFIG_ATA_ACPI
 extern int ata_acpi_cbl_80wire(struct ata_port *ap);
+int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm);
+int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *stm);
 #else
 static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; }
 #endif
 
 #ifdef CONFIG_PCI
+struct pci_dev;
+
+extern int ata_pci_init_one(struct pci_dev *pdev,
+                            const struct ata_port_info * const * ppi);
+extern void ata_pci_remove_one(struct pci_dev *pdev);
+#ifdef CONFIG_PM
+extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
+extern int __must_check ata_pci_device_do_resume(struct pci_dev *pdev);
+extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
+extern int ata_pci_device_resume(struct pci_dev *pdev);
+#endif
+extern int ata_pci_clear_simplex(struct pci_dev *pdev);
+
 struct pci_bits {
        unsigned int            reg;    /* PCI config register to read */
        unsigned int            width;  /* 1 (8 bit), 2 (16 bit), 4 (32 bit) */
@@ -954,12 +951,6 @@ extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
  * PMP
  */
 extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
-extern void sata_pmp_read_init_tf(struct ata_taskfile *tf,
-                                 struct ata_device *dev, int pmp, int reg);
-extern u32 sata_pmp_read_val(const struct ata_taskfile *tf);
-extern void sata_pmp_write_init_tf(struct ata_taskfile *tf,
-                                  struct ata_device *dev,
-                                  int pmp, int reg, u32 val);
 extern int sata_pmp_std_prereset(struct ata_link *link, unsigned long deadline);
 extern int sata_pmp_std_hardreset(struct ata_link *link, unsigned int *class,
                                  unsigned long deadline);
@@ -1046,21 +1037,10 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
 /*
  * qc helpers
  */
-static inline int
-ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc)
-{
-       if (sg == &qc->pad_sgent)
-               return 1;
-       if (qc->pad_len)
-               return 0;
-       if (((sg - qc->__sg) + 1) == qc->n_elem)
-               return 1;
-       return 0;
-}
-
 static inline struct scatterlist *
 ata_qc_first_sg(struct ata_queued_cmd *qc)
 {
+       qc->n_iter = 0;
        if (qc->n_elem)
                return qc->__sg;
        if (qc->pad_len)
@@ -1073,8 +1053,8 @@ ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
 {
        if (sg == &qc->pad_sgent)
                return NULL;
-       if (++sg - qc->__sg < qc->n_elem)
-               return sg;
+       if (++qc->n_iter < qc->n_elem)
+               return sg_next(sg);
        if (qc->pad_len)
                return &qc->pad_sgent;
        return NULL;
@@ -1319,9 +1299,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
        qc->dma_dir = DMA_NONE;
        qc->__sg = NULL;
        qc->flags = 0;
-       qc->cursg = qc->cursg_ofs = 0;
+       qc->cursg = NULL;
+       qc->cursg_ofs = 0;
        qc->nbytes = qc->curbytes = 0;
        qc->n_elem = 0;
+       qc->n_iter = 0;
        qc->err_mask = 0;
        qc->pad_len = 0;
        qc->sect_size = ATA_SECT_SIZE;