lockd: convert nsm_mutex to a spinlock
[safe/jmp/linux-2.6] / include / linux / libata.h
index 4bbf252..07ed56f 100644 (file)
@@ -261,6 +261,13 @@ enum {
         */
        ATA_WAIT_AFTER_RESET_MSECS = 150,
 
+       /* If PMP is supported, we have to do follow-up SRST.  As some
+        * PMPs don't send D2H Reg FIS after hardreset, LLDs are
+        * advised to wait only for the following duration before
+        * doing SRST.
+        */
+       ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ,
+
        /* ATA bus states */
        BUS_UNKNOWN             = 0,
        BUS_DMA                 = 1,
@@ -436,8 +443,9 @@ enum link_pm {
        MAX_PERFORMANCE,
        MEDIUM_POWER,
 };
-extern struct class_device_attribute class_device_attr_link_power_management_policy;
+extern struct device_attribute dev_attr_link_power_management_policy;
 
+#ifdef CONFIG_ATA_SFF
 struct ata_ioports {
        void __iomem            *cmd_addr;
        void __iomem            *data_addr;
@@ -455,6 +463,7 @@ struct ata_ioports {
        void __iomem            *bmdma_addr;
        void __iomem            *scr_addr;
 };
+#endif /* CONFIG_ATA_SFF */
 
 struct ata_host {
        spinlock_t              lock;
@@ -641,7 +650,9 @@ struct ata_port {
        struct ata_prd          *prd;    /* our SG list */
        dma_addr_t              prd_dma; /* and its DMA mapping */
 
+#ifdef CONFIG_ATA_SFF
        struct ata_ioports      ioaddr; /* ATA cmd/ctl/dma register blocks */
+#endif /* CONFIG_ATA_SFF */
 
        u8                      ctl;    /* cache of ATA control register */
        u8                      last_ctl;       /* Cache last written value */
@@ -708,6 +719,7 @@ struct ata_port_operations {
        int  (*check_atapi_dma)(struct ata_queued_cmd *qc);
        void (*qc_prep)(struct ata_queued_cmd *qc);
        unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
+       bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
 
        /*
         * Configuration and exception handling
@@ -752,6 +764,7 @@ struct ata_port_operations {
        void (*port_stop)(struct ata_port *ap);
        void (*host_stop)(struct ata_host *host);
 
+#ifdef CONFIG_ATA_SFF
        /*
         * SFF / taskfile oriented ops
         */
@@ -771,6 +784,7 @@ struct ata_port_operations {
        void (*bmdma_start)(struct ata_queued_cmd *qc);
        void (*bmdma_stop)(struct ata_queued_cmd *qc);
        u8   (*bmdma_status)(struct ata_port *ap);
+#endif /* CONFIG_ATA_SFF */
 
        /*
         * Obsolete
@@ -844,7 +858,10 @@ extern int sata_link_debounce(struct ata_link *link,
 extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
                            unsigned long deadline);
 extern int sata_link_hardreset(struct ata_link *link,
-                       const unsigned long *timing, unsigned long deadline);
+                       const unsigned long *timing, unsigned long deadline,
+                       bool *online, int (*check_ready)(struct ata_link *));
+extern int sata_std_hardreset(struct ata_link *link, unsigned int *class,
+                             unsigned long deadline);
 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes);
 extern void ata_port_disable(struct ata_port *);
 
@@ -900,7 +917,6 @@ extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
 extern int ata_xfer_mode2shift(unsigned long xfer_mode);
 extern const char *ata_mode_string(unsigned long xfer_mask);
 extern unsigned long ata_id_xfermask(const u16 *id);
-extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
 extern int ata_port_start(struct ata_port *ap);
 extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
 extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
@@ -913,8 +929,7 @@ 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_qc_complete(struct ata_queued_cmd *qc);
-extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
-                                   void (*finish_qc)(struct ata_queued_cmd *));
+extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
 extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
                              void (*done)(struct scsi_cmnd *));
 extern int ata_std_bios_param(struct scsi_device *sdev,
@@ -1012,16 +1027,6 @@ static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
 #endif
 
 /*
- * PMP - drivers/ata/libata-pmp.c
- */
-extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
-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);
-extern void sata_pmp_std_postreset(struct ata_link *link, unsigned int *class);
-extern void sata_pmp_error_handler(struct ata_port *ap);
-
-/*
  * EH - drivers/ata/libata-eh.c
  */
 extern void ata_port_schedule_eh(struct ata_port *ap);
@@ -1064,7 +1069,6 @@ extern void ata_std_error_handler(struct ata_port *ap);
  */
 extern const struct ata_port_operations ata_base_port_ops;
 extern const struct ata_port_operations sata_port_ops;
-extern const struct ata_port_operations sata_pmp_port_ops;
 
 #define ATA_BASE_SHT(drv_name)                                 \
        .module                 = THIS_MODULE,                  \
@@ -1086,13 +1090,55 @@ extern const struct ata_port_operations sata_pmp_port_ops;
        .change_queue_depth     = ata_scsi_change_queue_depth
 
 /*
+ * PMP helpers
+ */
+#ifdef CONFIG_SATA_PMP
+static inline bool sata_pmp_supported(struct ata_port *ap)
+{
+       return ap->flags & ATA_FLAG_PMP;
+}
+
+static inline bool sata_pmp_attached(struct ata_port *ap)
+{
+       return ap->nr_pmp_links != 0;
+}
+
+static inline int ata_is_host_link(const struct ata_link *link)
+{
+       return link == &link->ap->link;
+}
+#else /* CONFIG_SATA_PMP */
+static inline bool sata_pmp_supported(struct ata_port *ap)
+{
+       return false;
+}
+
+static inline bool sata_pmp_attached(struct ata_port *ap)
+{
+       return false;
+}
+
+static inline int ata_is_host_link(const struct ata_link *link)
+{
+       return 1;
+}
+#endif /* CONFIG_SATA_PMP */
+
+static inline int sata_srst_pmp(struct ata_link *link)
+{
+       if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
+               return SATA_PMP_CTRL_PORT;
+       return link->pmp;
+}
+
+/*
  * printk helpers
  */
 #define ata_port_printk(ap, lv, fmt, args...) \
        printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
 
 #define ata_link_printk(link, lv, fmt, args...) do { \
-       if ((link)->ap->nr_pmp_links) \
+       if (sata_pmp_attached((link)->ap)) \
                printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id,   \
                       (link)->pmp , ##args); \
        else \
@@ -1178,11 +1224,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
 /*
  * link helpers
  */
-static inline int ata_is_host_link(const struct ata_link *link)
-{
-       return link == &link->ap->link;
-}
-
 static inline int ata_link_max_devices(const struct ata_link *link)
 {
        if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
@@ -1197,7 +1238,7 @@ static inline int ata_link_active(struct ata_link *link)
 
 static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
 {
-       if (ap->nr_pmp_links)
+       if (sata_pmp_attached(ap))
                return ap->pmp_link;
        return &ap->link;
 }
@@ -1206,8 +1247,8 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
 {
        struct ata_port *ap = link->ap;
 
-       if (link == &ap->link) {
-               if (!ap->nr_pmp_links)
+       if (ata_is_host_link(link)) {
+               if (!sata_pmp_attached(ap))
                        return NULL;
                return ap->pmp_link;
        }
@@ -1341,9 +1382,31 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
        return *(struct ata_port **)&host->hostdata[0];
 }
 
+
+/**************************************************************************
+ * PMP - drivers/ata/libata-pmp.c
+ */
+#ifdef CONFIG_SATA_PMP
+
+extern const struct ata_port_operations sata_pmp_port_ops;
+
+extern int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc);
+extern void sata_pmp_error_handler(struct ata_port *ap);
+
+#else /* CONFIG_SATA_PMP */
+
+#define sata_pmp_port_ops              sata_port_ops
+#define sata_pmp_qc_defer_cmd_switch   ata_std_qc_defer
+#define sata_pmp_error_handler         ata_std_error_handler
+
+#endif /* CONFIG_SATA_PMP */
+
+
 /**************************************************************************
  * SFF - drivers/ata/libata-sff.c
  */
+#ifdef CONFIG_ATA_SFF
+
 extern const struct ata_port_operations ata_sff_port_ops;
 extern const struct ata_port_operations ata_bmdma_port_ops;
 
@@ -1379,6 +1442,7 @@ extern void ata_sff_irq_clear(struct ata_port *ap);
 extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
                            u8 status, int in_wq);
 extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
+extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
 extern unsigned int ata_sff_host_intr(struct ata_port *ap,
                                      struct ata_queued_cmd *qc);
 extern irqreturn_t ata_sff_interrupt(int irq, void *dev_instance);
@@ -1483,5 +1547,6 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
 
        return status;
 }
+#endif /* CONFIG_ATA_SFF */
 
 #endif /* __LINUX_LIBATA_H__ */