]> err.no Git - linux-2.6/blobdiff - include/linux/libata.h
[PATCH] libata-eh: implement new EH
[linux-2.6] / include / linux / libata.h
index 6023f324e68e694cdd6f8efa281c7735349dd630..9fe46073cf8c1155b08c6ef0baec0714d9c8898a 100644 (file)
@@ -155,6 +155,7 @@ enum {
 
        ATA_FLAG_EH_PENDING     = (1 << 16), /* EH pending */
        ATA_FLAG_FROZEN         = (1 << 17), /* port is frozen */
+       ATA_FLAG_RECOVERED      = (1 << 18), /* recovery action performed */
 
        ATA_FLAG_DISABLED       = (1 << 22), /* port is disabled, ignore it */
        ATA_FLAG_SUSPENDED      = (1 << 23), /* port is suspended (power) */
@@ -225,8 +226,29 @@ enum {
        ATA_PORT_PRIMARY        = (1 << 0),
        ATA_PORT_SECONDARY      = (1 << 1),
 
+       /* ering size */
+       ATA_ERING_SIZE          = 32,
+
+       /* desc_len for ata_eh_info and context */
+       ATA_EH_DESC_LEN         = 80,
+
+       /* reset / recovery action types */
+       ATA_EH_REVALIDATE       = (1 << 0),
+       ATA_EH_SOFTRESET        = (1 << 1),
+       ATA_EH_HARDRESET        = (1 << 2),
+
+       ATA_EH_RESET_MASK       = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
+
+       /* ata_eh_info->flags */
+       ATA_EHI_DID_RESET       = (1 << 0), /* already reset this port */
+
+       /* max repeat if error condition is still set after ->error_handler */
+       ATA_EH_MAX_REPEAT       = 5,
+
        /* how hard are we gonna try to probe/recover devices */
        ATA_PROBE_MAX_TRIES     = 3,
+       ATA_EH_RESET_TRIES      = 3,
+       ATA_EH_DEV_TRIES        = 3,
 };
 
 enum hsm_task_states {
@@ -364,6 +386,17 @@ struct ata_host_stats {
        unsigned long           rw_reqbuf;
 };
 
+struct ata_ering_entry {
+       int                     is_io;
+       unsigned int            err_mask;
+       u64                     timestamp;
+};
+
+struct ata_ering {
+       int                     cursor;
+       struct ata_ering_entry  ring[ATA_ERING_SIZE];
+};
+
 struct ata_device {
        struct ata_port         *ap;
        u64                     n_sectors;      /* size of device, if ATA */
@@ -390,6 +423,24 @@ struct ata_device {
        u16                     cylinders;      /* Number of cylinders */
        u16                     heads;          /* Number of heads */
        u16                     sectors;        /* Number of sectors per track */
+
+       /* error history */
+       struct ata_ering        ering;
+};
+
+struct ata_eh_info {
+       struct ata_device       *dev;           /* offending device */
+       u32                     serror;         /* SError from LLDD */
+       unsigned int            err_mask;       /* port-wide err_mask */
+       unsigned int            action;         /* ATA_EH_* action mask */
+       unsigned int            flags;          /* ATA_EHI_* flags */
+       char                    desc[ATA_EH_DESC_LEN];
+       int                     desc_len;
+};
+
+struct ata_eh_context {
+       struct ata_eh_info      i;
+       int                     tries[ATA_MAX_DEVICES];
 };
 
 struct ata_port {
@@ -416,6 +467,11 @@ struct ata_port {
        unsigned int            cbl;    /* cable type; ATA_CBL_xxx */
        unsigned int            sata_spd_limit; /* SATA PHY speed limit */
 
+       /* record runtime error info, protected by host_set lock */
+       struct ata_eh_info      eh_info;
+       /* EH context owned by EH */
+       struct ata_eh_context   eh_context;
+
        struct ata_device       device[ATA_MAX_DEVICES];
 
        struct ata_queued_cmd   qcmd[ATA_MAX_QUEUE];
@@ -662,9 +718,20 @@ extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_
  * EH
  */
 extern void ata_eng_timeout(struct ata_port *ap);
+
+extern void ata_port_schedule_eh(struct ata_port *ap);
+extern int ata_port_abort(struct ata_port *ap);
+extern int ata_port_freeze(struct ata_port *ap);
+
+extern void ata_eh_freeze_port(struct ata_port *ap);
+extern void ata_eh_thaw_port(struct ata_port *ap);
+
 extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
 extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
 
+extern void ata_do_eh(struct ata_port *ap, ata_reset_fn_t softreset,
+                     ata_reset_fn_t hardreset, ata_postreset_fn_t postreset);
+
 /*
  * printk helpers
  */
@@ -674,6 +741,20 @@ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
 #define ata_dev_printk(dev, lv, fmt, args...) \
        printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args)
 
+/*
+ * ata_eh_info helpers
+ */
+#define ata_ehi_push_desc(ehi, fmt, args...) do { \
+       (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \
+                                    ATA_EH_DESC_LEN - (ehi)->desc_len, \
+                                    fmt , ##args); \
+} while (0)
+
+#define ata_ehi_clear_desc(ehi) do { \
+       (ehi)->desc[0] = '\0'; \
+       (ehi)->desc_len = 0; \
+} while (0)
+
 /*
  * qc helpers
  */