diff options
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 85 |
1 files changed, 64 insertions, 21 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index f4284bf89758..6cc497a2b6da 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,12 +255,19 @@ 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), /* need to resume link */ | ||
| 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 | ||
| @@ -486,6 +500,7 @@ struct ata_port { | |||
| 486 | const struct ata_port_operations *ops; | 500 | const struct ata_port_operations *ops; |
| 487 | spinlock_t *lock; | 501 | spinlock_t *lock; |
| 488 | unsigned long flags; /* ATA_FLAG_xxx */ | 502 | unsigned long flags; /* ATA_FLAG_xxx */ |
| 503 | unsigned int pflags; /* ATA_PFLAG_xxx */ | ||
| 489 | unsigned int id; /* unique id req'd by scsi midlyr */ | 504 | unsigned int id; /* unique id req'd by scsi midlyr */ |
| 490 | unsigned int port_no; /* unique port #; from zero */ | 505 | unsigned int port_no; /* unique port #; from zero */ |
| 491 | unsigned int hard_port_no; /* hardware port #; from zero */ | 506 | unsigned int hard_port_no; /* hardware port #; from zero */ |
| @@ -535,6 +550,9 @@ struct ata_port { | |||
| 535 | struct list_head eh_done_q; | 550 | struct list_head eh_done_q; |
| 536 | wait_queue_head_t eh_wait_q; | 551 | wait_queue_head_t eh_wait_q; |
| 537 | 552 | ||
| 553 | pm_message_t pm_mesg; | ||
| 554 | int *pm_result; | ||
| 555 | |||
| 538 | void *private_data; | 556 | void *private_data; |
| 539 | 557 | ||
| 540 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | 558 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ |
| @@ -589,6 +607,9 @@ struct ata_port_operations { | |||
| 589 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 607 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
| 590 | u32 val); | 608 | u32 val); |
| 591 | 609 | ||
| 610 | int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); | ||
| 611 | int (*port_resume) (struct ata_port *ap); | ||
| 612 | |||
| 592 | int (*port_start) (struct ata_port *ap); | 613 | int (*port_start) (struct ata_port *ap); |
| 593 | void (*port_stop) (struct ata_port *ap); | 614 | void (*port_stop) (struct ata_port *ap); |
| 594 | 615 | ||
| @@ -622,9 +643,18 @@ struct ata_timing { | |||
| 622 | 643 | ||
| 623 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | 644 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) |
| 624 | 645 | ||
| 625 | extern const unsigned long sata_deb_timing_boot[]; | 646 | extern const unsigned long sata_deb_timing_normal[]; |
| 626 | extern const unsigned long sata_deb_timing_eh[]; | 647 | extern const unsigned long sata_deb_timing_hotplug[]; |
| 627 | extern const unsigned long sata_deb_timing_before_fsrst[]; | 648 | extern const unsigned long sata_deb_timing_long[]; |
| 649 | |||
| 650 | static inline const unsigned long * | ||
| 651 | sata_ehc_deb_timing(struct ata_eh_context *ehc) | ||
| 652 | { | ||
| 653 | if (ehc->i.flags & ATA_EHI_HOTPLUGGED) | ||
| 654 | return sata_deb_timing_hotplug; | ||
| 655 | else | ||
| 656 | return sata_deb_timing_normal; | ||
| 657 | } | ||
| 628 | 658 | ||
| 629 | extern void ata_port_probe(struct ata_port *); | 659 | extern void ata_port_probe(struct ata_port *); |
| 630 | extern void __sata_phy_reset(struct ata_port *ap); | 660 | extern void __sata_phy_reset(struct ata_port *ap); |
| @@ -644,6 +674,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, | 674 | extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, |
| 645 | unsigned int n_ports); | 675 | unsigned int n_ports); |
| 646 | extern void ata_pci_remove_one (struct pci_dev *pdev); | 676 | extern void ata_pci_remove_one (struct pci_dev *pdev); |
| 677 | extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t state); | ||
| 678 | 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); | 679 | 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); | 680 | extern int ata_pci_device_resume(struct pci_dev *pdev); |
| 649 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | 681 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); |
| @@ -664,8 +696,9 @@ extern int ata_port_online(struct ata_port *ap); | |||
| 664 | extern int ata_port_offline(struct ata_port *ap); | 696 | extern int ata_port_offline(struct ata_port *ap); |
| 665 | extern int ata_scsi_device_resume(struct scsi_device *); | 697 | extern int ata_scsi_device_resume(struct scsi_device *); |
| 666 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 698 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
| 667 | extern int ata_device_resume(struct ata_device *); | 699 | 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); | 700 | pm_message_t mesg); |
| 701 | extern void ata_host_set_resume(struct ata_host_set *host_set); | ||
| 669 | extern int ata_ratelimit(void); | 702 | extern int ata_ratelimit(void); |
| 670 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 703 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
| 671 | unsigned long timeout_pat, | 704 | unsigned long timeout_pat, |
| @@ -825,19 +858,24 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
| 825 | (ehi)->desc_len = 0; \ | 858 | (ehi)->desc_len = 0; \ |
| 826 | } while (0) | 859 | } while (0) |
| 827 | 860 | ||
| 828 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | 861 | static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi) |
| 829 | { | 862 | { |
| 830 | if (ehi->flags & ATA_EHI_HOTPLUGGED) | 863 | if (ehi->flags & ATA_EHI_HOTPLUGGED) |
| 831 | return; | 864 | return; |
| 832 | 865 | ||
| 833 | ehi->flags |= ATA_EHI_HOTPLUGGED; | 866 | ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK; |
| 834 | ehi->hotplug_timestamp = jiffies; | 867 | ehi->hotplug_timestamp = jiffies; |
| 835 | 868 | ||
| 836 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
| 837 | ehi->action |= ATA_EH_SOFTRESET; | 869 | ehi->action |= ATA_EH_SOFTRESET; |
| 838 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; | 870 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; |
| 839 | } | 871 | } |
| 840 | 872 | ||
| 873 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | ||
| 874 | { | ||
| 875 | __ata_ehi_hotplugged(ehi); | ||
| 876 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
| 877 | } | ||
| 878 | |||
| 841 | /* | 879 | /* |
| 842 | * qc helpers | 880 | * qc helpers |
| 843 | */ | 881 | */ |
| @@ -921,6 +959,11 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) | |||
| 921 | return ata_class_absent(dev->class); | 959 | return ata_class_absent(dev->class); |
| 922 | } | 960 | } |
| 923 | 961 | ||
| 962 | static inline unsigned int ata_dev_ready(const struct ata_device *dev) | ||
| 963 | { | ||
| 964 | return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED); | ||
| 965 | } | ||
| 966 | |||
| 924 | /* | 967 | /* |
| 925 | * port helpers | 968 | * port helpers |
| 926 | */ | 969 | */ |
