diff options
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 87 |
1 files changed, 66 insertions, 21 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index f4284bf89758..66c3100c2b94 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -131,6 +131,7 @@ enum { | |||
131 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, | 131 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, |
132 | 132 | ||
133 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ | 133 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ |
134 | ATA_DFLAG_SUSPENDED = (1 << 9), /* device suspended */ | ||
134 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, | 135 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, |
135 | 136 | ||
136 | ATA_DFLAG_DETACH = (1 << 16), | 137 | ATA_DFLAG_DETACH = (1 << 16), |
@@ -160,22 +161,28 @@ enum { | |||
160 | ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */ | 161 | ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */ |
161 | ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H | 162 | ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H |
162 | * Register FIS clearing BSY */ | 163 | * Register FIS clearing BSY */ |
163 | |||
164 | ATA_FLAG_DEBUGMSG = (1 << 13), | 164 | ATA_FLAG_DEBUGMSG = (1 << 13), |
165 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 14), /* flush port task */ | ||
166 | 165 | ||
167 | ATA_FLAG_EH_PENDING = (1 << 15), /* EH pending */ | 166 | /* The following flag belongs to ap->pflags but is kept in |
168 | ATA_FLAG_EH_IN_PROGRESS = (1 << 16), /* EH in progress */ | 167 | * ap->flags because it's referenced in many LLDs and will be |
169 | ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */ | 168 | * removed in not-too-distant future. |
170 | ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */ | 169 | */ |
171 | ATA_FLAG_LOADING = (1 << 19), /* boot/loading probe */ | 170 | ATA_FLAG_DISABLED = (1 << 23), /* port is disabled, ignore it */ |
172 | ATA_FLAG_UNLOADING = (1 << 20), /* module is unloading */ | 171 | |
173 | ATA_FLAG_SCSI_HOTPLUG = (1 << 21), /* SCSI hotplug scheduled */ | 172 | /* bits 24:31 of ap->flags are reserved for LLD specific flags */ |
174 | 173 | ||
175 | ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */ | 174 | /* struct ata_port pflags */ |
176 | ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */ | 175 | ATA_PFLAG_EH_PENDING = (1 << 0), /* EH pending */ |
176 | ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */ | ||
177 | ATA_PFLAG_FROZEN = (1 << 2), /* port is frozen */ | ||
178 | ATA_PFLAG_RECOVERED = (1 << 3), /* recovery action performed */ | ||
179 | ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ | ||
180 | ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ | ||
181 | ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ | ||
177 | 182 | ||
178 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ | 183 | ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ |
184 | ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ | ||
185 | ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ | ||
179 | 186 | ||
180 | /* struct ata_queued_cmd flags */ | 187 | /* struct ata_queued_cmd flags */ |
181 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ | 188 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |
@@ -248,15 +255,24 @@ enum { | |||
248 | ATA_EH_REVALIDATE = (1 << 0), | 255 | ATA_EH_REVALIDATE = (1 << 0), |
249 | ATA_EH_SOFTRESET = (1 << 1), | 256 | ATA_EH_SOFTRESET = (1 << 1), |
250 | ATA_EH_HARDRESET = (1 << 2), | 257 | ATA_EH_HARDRESET = (1 << 2), |
258 | ATA_EH_SUSPEND = (1 << 3), | ||
259 | ATA_EH_RESUME = (1 << 4), | ||
260 | ATA_EH_PM_FREEZE = (1 << 5), | ||
251 | 261 | ||
252 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | 262 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, |
253 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, | 263 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_SUSPEND | |
264 | ATA_EH_RESUME | ATA_EH_PM_FREEZE, | ||
254 | 265 | ||
255 | /* ata_eh_info->flags */ | 266 | /* ata_eh_info->flags */ |
256 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ | 267 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ |
268 | ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */ | ||
269 | ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ | ||
270 | ATA_EHI_QUIET = (1 << 3), /* be quiet */ | ||
257 | 271 | ||
258 | ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */ | 272 | ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */ |
259 | 273 | ||
274 | ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK, | ||
275 | |||
260 | /* max repeat if error condition is still set after ->error_handler */ | 276 | /* max repeat if error condition is still set after ->error_handler */ |
261 | ATA_EH_MAX_REPEAT = 5, | 277 | ATA_EH_MAX_REPEAT = 5, |
262 | 278 | ||
@@ -486,6 +502,7 @@ struct ata_port { | |||
486 | const struct ata_port_operations *ops; | 502 | const struct ata_port_operations *ops; |
487 | spinlock_t *lock; | 503 | spinlock_t *lock; |
488 | unsigned long flags; /* ATA_FLAG_xxx */ | 504 | unsigned long flags; /* ATA_FLAG_xxx */ |
505 | unsigned int pflags; /* ATA_PFLAG_xxx */ | ||
489 | unsigned int id; /* unique id req'd by scsi midlyr */ | 506 | unsigned int id; /* unique id req'd by scsi midlyr */ |
490 | unsigned int port_no; /* unique port #; from zero */ | 507 | unsigned int port_no; /* unique port #; from zero */ |
491 | unsigned int hard_port_no; /* hardware port #; from zero */ | 508 | unsigned int hard_port_no; /* hardware port #; from zero */ |
@@ -535,6 +552,9 @@ struct ata_port { | |||
535 | struct list_head eh_done_q; | 552 | struct list_head eh_done_q; |
536 | wait_queue_head_t eh_wait_q; | 553 | wait_queue_head_t eh_wait_q; |
537 | 554 | ||
555 | pm_message_t pm_mesg; | ||
556 | int *pm_result; | ||
557 | |||
538 | void *private_data; | 558 | void *private_data; |
539 | 559 | ||
540 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | 560 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ |
@@ -589,6 +609,9 @@ struct ata_port_operations { | |||
589 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 609 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
590 | u32 val); | 610 | u32 val); |
591 | 611 | ||
612 | int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); | ||
613 | int (*port_resume) (struct ata_port *ap); | ||
614 | |||
592 | int (*port_start) (struct ata_port *ap); | 615 | int (*port_start) (struct ata_port *ap); |
593 | void (*port_stop) (struct ata_port *ap); | 616 | void (*port_stop) (struct ata_port *ap); |
594 | 617 | ||
@@ -622,9 +645,18 @@ struct ata_timing { | |||
622 | 645 | ||
623 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | 646 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) |
624 | 647 | ||
625 | extern const unsigned long sata_deb_timing_boot[]; | 648 | extern const unsigned long sata_deb_timing_normal[]; |
626 | extern const unsigned long sata_deb_timing_eh[]; | 649 | extern const unsigned long sata_deb_timing_hotplug[]; |
627 | extern const unsigned long sata_deb_timing_before_fsrst[]; | 650 | extern const unsigned long sata_deb_timing_long[]; |
651 | |||
652 | static inline const unsigned long * | ||
653 | sata_ehc_deb_timing(struct ata_eh_context *ehc) | ||
654 | { | ||
655 | if (ehc->i.flags & ATA_EHI_HOTPLUGGED) | ||
656 | return sata_deb_timing_hotplug; | ||
657 | else | ||
658 | return sata_deb_timing_normal; | ||
659 | } | ||
628 | 660 | ||
629 | extern void ata_port_probe(struct ata_port *); | 661 | extern void ata_port_probe(struct ata_port *); |
630 | extern void __sata_phy_reset(struct ata_port *ap); | 662 | extern void __sata_phy_reset(struct ata_port *ap); |
@@ -644,6 +676,8 @@ extern void ata_std_ports(struct ata_ioports *ioaddr); | |||
644 | extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | 676 | extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, |
645 | unsigned int n_ports); | 677 | unsigned int n_ports); |
646 | extern void ata_pci_remove_one (struct pci_dev *pdev); | 678 | extern void ata_pci_remove_one (struct pci_dev *pdev); |
679 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t state); | ||
680 | extern void ata_pci_device_do_resume(struct pci_dev *pdev); | ||
647 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); | 681 | extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); |
648 | extern int ata_pci_device_resume(struct pci_dev *pdev); | 682 | extern int ata_pci_device_resume(struct pci_dev *pdev); |
649 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | 683 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); |
@@ -664,8 +698,9 @@ extern int ata_port_online(struct ata_port *ap); | |||
664 | extern int ata_port_offline(struct ata_port *ap); | 698 | extern int ata_port_offline(struct ata_port *ap); |
665 | extern int ata_scsi_device_resume(struct scsi_device *); | 699 | extern int ata_scsi_device_resume(struct scsi_device *); |
666 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 700 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
667 | extern int ata_device_resume(struct ata_device *); | 701 | extern int ata_host_set_suspend(struct ata_host_set *host_set, |
668 | extern int ata_device_suspend(struct ata_device *, pm_message_t state); | 702 | pm_message_t mesg); |
703 | extern void ata_host_set_resume(struct ata_host_set *host_set); | ||
669 | extern int ata_ratelimit(void); | 704 | extern int ata_ratelimit(void); |
670 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 705 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
671 | unsigned long timeout_pat, | 706 | unsigned long timeout_pat, |
@@ -825,19 +860,24 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
825 | (ehi)->desc_len = 0; \ | 860 | (ehi)->desc_len = 0; \ |
826 | } while (0) | 861 | } while (0) |
827 | 862 | ||
828 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | 863 | static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi) |
829 | { | 864 | { |
830 | if (ehi->flags & ATA_EHI_HOTPLUGGED) | 865 | if (ehi->flags & ATA_EHI_HOTPLUGGED) |
831 | return; | 866 | return; |
832 | 867 | ||
833 | ehi->flags |= ATA_EHI_HOTPLUGGED; | 868 | ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK; |
834 | ehi->hotplug_timestamp = jiffies; | 869 | ehi->hotplug_timestamp = jiffies; |
835 | 870 | ||
836 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
837 | ehi->action |= ATA_EH_SOFTRESET; | 871 | ehi->action |= ATA_EH_SOFTRESET; |
838 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; | 872 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; |
839 | } | 873 | } |
840 | 874 | ||
875 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | ||
876 | { | ||
877 | __ata_ehi_hotplugged(ehi); | ||
878 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
879 | } | ||
880 | |||
841 | /* | 881 | /* |
842 | * qc helpers | 882 | * qc helpers |
843 | */ | 883 | */ |
@@ -921,6 +961,11 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) | |||
921 | return ata_class_absent(dev->class); | 961 | return ata_class_absent(dev->class); |
922 | } | 962 | } |
923 | 963 | ||
964 | static inline unsigned int ata_dev_ready(const struct ata_device *dev) | ||
965 | { | ||
966 | return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED); | ||
967 | } | ||
968 | |||
924 | /* | 969 | /* |
925 | * port helpers | 970 | * port helpers |
926 | */ | 971 | */ |