diff options
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r-- | include/linux/libata.h | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 45fb2967b66d..15b77b8dc7e1 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <scsi/scsi_host.h> | 37 | #include <scsi/scsi_host.h> |
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/cdrom.h> | 39 | #include <linux/cdrom.h> |
40 | #include <linux/sched.h> | ||
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Define if arch has non-standard setup. This is a _PCI_ standard | 43 | * Define if arch has non-standard setup. This is a _PCI_ standard |
@@ -172,6 +173,7 @@ enum { | |||
172 | ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ | 173 | ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ |
173 | ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ | 174 | ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ |
174 | ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ | 175 | ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ |
176 | ATA_LFLAG_NO_LPM = (1 << 8), /* disable LPM on this link */ | ||
175 | 177 | ||
176 | /* struct ata_port flags */ | 178 | /* struct ata_port flags */ |
177 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ | 179 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ |
@@ -196,7 +198,7 @@ enum { | |||
196 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ | 198 | ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ |
197 | ATA_FLAG_AN = (1 << 18), /* controller supports AN */ | 199 | ATA_FLAG_AN = (1 << 18), /* controller supports AN */ |
198 | ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ | 200 | ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ |
199 | ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ | 201 | ATA_FLAG_LPM = (1 << 20), /* driver can handle LPM */ |
200 | ATA_FLAG_EM = (1 << 21), /* driver supports enclosure | 202 | ATA_FLAG_EM = (1 << 21), /* driver supports enclosure |
201 | * management */ | 203 | * management */ |
202 | ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity | 204 | ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity |
@@ -324,12 +326,11 @@ enum { | |||
324 | ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */ | 326 | ATA_EH_HARDRESET = (1 << 2), /* meaningful only in ->prereset */ |
325 | ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | 327 | ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, |
326 | ATA_EH_ENABLE_LINK = (1 << 3), | 328 | ATA_EH_ENABLE_LINK = (1 << 3), |
327 | ATA_EH_LPM = (1 << 4), /* link power management action */ | ||
328 | ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */ | 329 | ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */ |
329 | 330 | ||
330 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK, | 331 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK, |
331 | ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET | | 332 | ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET | |
332 | ATA_EH_ENABLE_LINK | ATA_EH_LPM, | 333 | ATA_EH_ENABLE_LINK, |
333 | 334 | ||
334 | /* ata_eh_info->flags */ | 335 | /* ata_eh_info->flags */ |
335 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ | 336 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ |
@@ -341,7 +342,7 @@ enum { | |||
341 | ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ | 342 | ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ |
342 | ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */ | 343 | ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */ |
343 | ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */ | 344 | ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */ |
344 | ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ | 345 | ATA_EHI_POST_SETMODE = (1 << 20), /* revalidating after setmode */ |
345 | 346 | ||
346 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, | 347 | ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, |
347 | 348 | ||
@@ -377,7 +378,6 @@ enum { | |||
377 | ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ | 378 | ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ |
378 | ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ | 379 | ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ |
379 | ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ | 380 | ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ |
380 | ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */ | ||
381 | ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ | 381 | ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ |
382 | ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ | 382 | ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ |
383 | ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ | 383 | ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ |
@@ -464,6 +464,22 @@ enum ata_completion_errors { | |||
464 | AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */ | 464 | AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */ |
465 | }; | 465 | }; |
466 | 466 | ||
467 | /* | ||
468 | * Link power management policy: If you alter this, you also need to | ||
469 | * alter libata-scsi.c (for the ascii descriptions) | ||
470 | */ | ||
471 | enum ata_lpm_policy { | ||
472 | ATA_LPM_UNKNOWN, | ||
473 | ATA_LPM_MAX_POWER, | ||
474 | ATA_LPM_MED_POWER, | ||
475 | ATA_LPM_MIN_POWER, | ||
476 | }; | ||
477 | |||
478 | enum ata_lpm_hints { | ||
479 | ATA_LPM_EMPTY = (1 << 0), /* port empty/probing */ | ||
480 | ATA_LPM_HIPM = (1 << 1), /* may use HIPM */ | ||
481 | }; | ||
482 | |||
467 | /* forward declarations */ | 483 | /* forward declarations */ |
468 | struct scsi_device; | 484 | struct scsi_device; |
469 | struct ata_port_operations; | 485 | struct ata_port_operations; |
@@ -478,16 +494,6 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes, | |||
478 | unsigned long deadline); | 494 | unsigned long deadline); |
479 | typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); | 495 | typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); |
480 | 496 | ||
481 | /* | ||
482 | * host pm policy: If you alter this, you also need to alter libata-scsi.c | ||
483 | * (for the ascii descriptions) | ||
484 | */ | ||
485 | enum link_pm { | ||
486 | NOT_AVAILABLE, | ||
487 | MIN_POWER, | ||
488 | MAX_PERFORMANCE, | ||
489 | MEDIUM_POWER, | ||
490 | }; | ||
491 | extern struct device_attribute dev_attr_link_power_management_policy; | 497 | extern struct device_attribute dev_attr_link_power_management_policy; |
492 | extern struct device_attribute dev_attr_unload_heads; | 498 | extern struct device_attribute dev_attr_unload_heads; |
493 | extern struct device_attribute dev_attr_em_message_type; | 499 | extern struct device_attribute dev_attr_em_message_type; |
@@ -530,6 +536,10 @@ struct ata_host { | |||
530 | void *private_data; | 536 | void *private_data; |
531 | struct ata_port_operations *ops; | 537 | struct ata_port_operations *ops; |
532 | unsigned long flags; | 538 | unsigned long flags; |
539 | |||
540 | struct mutex eh_mutex; | ||
541 | struct task_struct *eh_owner; | ||
542 | |||
533 | #ifdef CONFIG_ATA_ACPI | 543 | #ifdef CONFIG_ATA_ACPI |
534 | acpi_handle acpi_handle; | 544 | acpi_handle acpi_handle; |
535 | #endif | 545 | #endif |
@@ -560,13 +570,13 @@ struct ata_queued_cmd { | |||
560 | unsigned int extrabytes; | 570 | unsigned int extrabytes; |
561 | unsigned int curbytes; | 571 | unsigned int curbytes; |
562 | 572 | ||
563 | struct scatterlist *cursg; | ||
564 | unsigned int cursg_ofs; | ||
565 | |||
566 | struct scatterlist sgent; | 573 | struct scatterlist sgent; |
567 | 574 | ||
568 | struct scatterlist *sg; | 575 | struct scatterlist *sg; |
569 | 576 | ||
577 | struct scatterlist *cursg; | ||
578 | unsigned int cursg_ofs; | ||
579 | |||
570 | unsigned int err_mask; | 580 | unsigned int err_mask; |
571 | struct ata_taskfile result_tf; | 581 | struct ata_taskfile result_tf; |
572 | ata_qc_cb_t complete_fn; | 582 | ata_qc_cb_t complete_fn; |
@@ -604,6 +614,7 @@ struct ata_device { | |||
604 | union acpi_object *gtf_cache; | 614 | union acpi_object *gtf_cache; |
605 | unsigned int gtf_filter; | 615 | unsigned int gtf_filter; |
606 | #endif | 616 | #endif |
617 | struct device tdev; | ||
607 | /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */ | 618 | /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */ |
608 | u64 n_sectors; /* size of device, if ATA */ | 619 | u64 n_sectors; /* size of device, if ATA */ |
609 | u64 n_native_sectors; /* native size, if ATA */ | 620 | u64 n_native_sectors; /* native size, if ATA */ |
@@ -690,6 +701,7 @@ struct ata_link { | |||
690 | struct ata_port *ap; | 701 | struct ata_port *ap; |
691 | int pmp; /* port multiplier port # */ | 702 | int pmp; /* port multiplier port # */ |
692 | 703 | ||
704 | struct device tdev; | ||
693 | unsigned int active_tag; /* active tag on this link */ | 705 | unsigned int active_tag; /* active tag on this link */ |
694 | u32 sactive; /* active NCQ commands */ | 706 | u32 sactive; /* active NCQ commands */ |
695 | 707 | ||
@@ -699,6 +711,7 @@ struct ata_link { | |||
699 | unsigned int hw_sata_spd_limit; | 711 | unsigned int hw_sata_spd_limit; |
700 | unsigned int sata_spd_limit; | 712 | unsigned int sata_spd_limit; |
701 | unsigned int sata_spd; /* current SATA PHY speed */ | 713 | unsigned int sata_spd; /* current SATA PHY speed */ |
714 | enum ata_lpm_policy lpm_policy; | ||
702 | 715 | ||
703 | /* record runtime error info, protected by host_set lock */ | 716 | /* record runtime error info, protected by host_set lock */ |
704 | struct ata_eh_info eh_info; | 717 | struct ata_eh_info eh_info; |
@@ -707,6 +720,8 @@ struct ata_link { | |||
707 | 720 | ||
708 | struct ata_device device[ATA_MAX_DEVICES]; | 721 | struct ata_device device[ATA_MAX_DEVICES]; |
709 | }; | 722 | }; |
723 | #define ATA_LINK_CLEAR_BEGIN offsetof(struct ata_link, active_tag) | ||
724 | #define ATA_LINK_CLEAR_END offsetof(struct ata_link, device[0]) | ||
710 | 725 | ||
711 | struct ata_port { | 726 | struct ata_port { |
712 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ | 727 | struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ |
@@ -752,6 +767,7 @@ struct ata_port { | |||
752 | struct ata_port_stats stats; | 767 | struct ata_port_stats stats; |
753 | struct ata_host *host; | 768 | struct ata_host *host; |
754 | struct device *dev; | 769 | struct device *dev; |
770 | struct device tdev; | ||
755 | 771 | ||
756 | struct mutex scsi_scan_mutex; | 772 | struct mutex scsi_scan_mutex; |
757 | struct delayed_work hotplug_task; | 773 | struct delayed_work hotplug_task; |
@@ -767,7 +783,7 @@ struct ata_port { | |||
767 | 783 | ||
768 | pm_message_t pm_mesg; | 784 | pm_message_t pm_mesg; |
769 | int *pm_result; | 785 | int *pm_result; |
770 | enum link_pm pm_policy; | 786 | enum ata_lpm_policy target_lpm_policy; |
771 | 787 | ||
772 | struct timer_list fastdrain_timer; | 788 | struct timer_list fastdrain_timer; |
773 | unsigned long fastdrain_cnt; | 789 | unsigned long fastdrain_cnt; |
@@ -833,8 +849,8 @@ struct ata_port_operations { | |||
833 | int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val); | 849 | int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val); |
834 | void (*pmp_attach)(struct ata_port *ap); | 850 | void (*pmp_attach)(struct ata_port *ap); |
835 | void (*pmp_detach)(struct ata_port *ap); | 851 | void (*pmp_detach)(struct ata_port *ap); |
836 | int (*enable_pm)(struct ata_port *ap, enum link_pm policy); | 852 | int (*set_lpm)(struct ata_link *link, enum ata_lpm_policy policy, |
837 | void (*disable_pm)(struct ata_port *ap); | 853 | unsigned hints); |
838 | 854 | ||
839 | /* | 855 | /* |
840 | * Start, stop, suspend and resume | 856 | * Start, stop, suspend and resume |
@@ -946,6 +962,8 @@ extern int sata_link_debounce(struct ata_link *link, | |||
946 | const unsigned long *params, unsigned long deadline); | 962 | const unsigned long *params, unsigned long deadline); |
947 | extern int sata_link_resume(struct ata_link *link, const unsigned long *params, | 963 | extern int sata_link_resume(struct ata_link *link, const unsigned long *params, |
948 | unsigned long deadline); | 964 | unsigned long deadline); |
965 | extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy, | ||
966 | bool spm_wakeup); | ||
949 | extern int sata_link_hardreset(struct ata_link *link, | 967 | extern int sata_link_hardreset(struct ata_link *link, |
950 | const unsigned long *timing, unsigned long deadline, | 968 | const unsigned long *timing, unsigned long deadline, |
951 | bool *online, int (*check_ready)(struct ata_link *)); | 969 | bool *online, int (*check_ready)(struct ata_link *)); |
@@ -991,8 +1009,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); | |||
991 | extern void ata_host_resume(struct ata_host *host); | 1009 | extern void ata_host_resume(struct ata_host *host); |
992 | #endif | 1010 | #endif |
993 | extern int ata_ratelimit(void); | 1011 | extern int ata_ratelimit(void); |
994 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | 1012 | extern void ata_msleep(struct ata_port *ap, unsigned int msecs); |
995 | unsigned long interval, unsigned long timeout); | 1013 | extern u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask, |
1014 | u32 val, unsigned long interval, unsigned long timeout); | ||
996 | extern int atapi_cmd_type(u8 opcode); | 1015 | extern int atapi_cmd_type(u8 opcode); |
997 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, | 1016 | extern void ata_tf_to_fis(const struct ata_taskfile *tf, |
998 | u8 pmp, int is_cmd, u8 *fis); | 1017 | u8 pmp, int is_cmd, u8 *fis); |