aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h69
1 files changed, 45 insertions, 24 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index f010f18a0f86..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,23 +326,23 @@ 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 */
336 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ 337 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
337 ATA_EHI_QUIET = (1 << 3), /* be quiet */ 338 ATA_EHI_QUIET = (1 << 3), /* be quiet */
339 ATA_EHI_NO_RECOVERY = (1 << 4), /* no recovery */
338 340
339 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */ 341 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */
340 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ 342 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
341 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */ 343 ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */
342 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */ 344 ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */
343 ATA_EHI_POST_SETMODE = (1 << 20), /* revaildating after setmode */ 345 ATA_EHI_POST_SETMODE = (1 << 20), /* revalidating after setmode */
344 346
345 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,
346 348
@@ -376,7 +378,6 @@ enum {
376 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ 378 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */
377 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */ 379 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */
378 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ 380 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */
379 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */
380 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ 381 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */
381 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ 382 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */
382 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ 383 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */
@@ -463,6 +464,22 @@ enum ata_completion_errors {
463 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */ 464 AC_ERR_NCQ = (1 << 10), /* marker for offending NCQ qc */
464}; 465};
465 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 */
471enum ata_lpm_policy {
472 ATA_LPM_UNKNOWN,
473 ATA_LPM_MAX_POWER,
474 ATA_LPM_MED_POWER,
475 ATA_LPM_MIN_POWER,
476};
477
478enum ata_lpm_hints {
479 ATA_LPM_EMPTY = (1 << 0), /* port empty/probing */
480 ATA_LPM_HIPM = (1 << 1), /* may use HIPM */
481};
482
466/* forward declarations */ 483/* forward declarations */
467struct scsi_device; 484struct scsi_device;
468struct ata_port_operations; 485struct ata_port_operations;
@@ -477,16 +494,6 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
477 unsigned long deadline); 494 unsigned long deadline);
478typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); 495typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
479 496
480/*
481 * host pm policy: If you alter this, you also need to alter libata-scsi.c
482 * (for the ascii descriptions)
483 */
484enum link_pm {
485 NOT_AVAILABLE,
486 MIN_POWER,
487 MAX_PERFORMANCE,
488 MEDIUM_POWER,
489};
490extern struct device_attribute dev_attr_link_power_management_policy; 497extern struct device_attribute dev_attr_link_power_management_policy;
491extern struct device_attribute dev_attr_unload_heads; 498extern struct device_attribute dev_attr_unload_heads;
492extern struct device_attribute dev_attr_em_message_type; 499extern struct device_attribute dev_attr_em_message_type;
@@ -529,6 +536,10 @@ struct ata_host {
529 void *private_data; 536 void *private_data;
530 struct ata_port_operations *ops; 537 struct ata_port_operations *ops;
531 unsigned long flags; 538 unsigned long flags;
539
540 struct mutex eh_mutex;
541 struct task_struct *eh_owner;
542
532#ifdef CONFIG_ATA_ACPI 543#ifdef CONFIG_ATA_ACPI
533 acpi_handle acpi_handle; 544 acpi_handle acpi_handle;
534#endif 545#endif
@@ -559,13 +570,13 @@ struct ata_queued_cmd {
559 unsigned int extrabytes; 570 unsigned int extrabytes;
560 unsigned int curbytes; 571 unsigned int curbytes;
561 572
562 struct scatterlist *cursg;
563 unsigned int cursg_ofs;
564
565 struct scatterlist sgent; 573 struct scatterlist sgent;
566 574
567 struct scatterlist *sg; 575 struct scatterlist *sg;
568 576
577 struct scatterlist *cursg;
578 unsigned int cursg_ofs;
579
569 unsigned int err_mask; 580 unsigned int err_mask;
570 struct ata_taskfile result_tf; 581 struct ata_taskfile result_tf;
571 ata_qc_cb_t complete_fn; 582 ata_qc_cb_t complete_fn;
@@ -603,6 +614,7 @@ struct ata_device {
603 union acpi_object *gtf_cache; 614 union acpi_object *gtf_cache;
604 unsigned int gtf_filter; 615 unsigned int gtf_filter;
605#endif 616#endif
617 struct device tdev;
606 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */ 618 /* n_sector is CLEAR_BEGIN, read comment above CLEAR_BEGIN */
607 u64 n_sectors; /* size of device, if ATA */ 619 u64 n_sectors; /* size of device, if ATA */
608 u64 n_native_sectors; /* native size, if ATA */ 620 u64 n_native_sectors; /* native size, if ATA */
@@ -689,6 +701,7 @@ struct ata_link {
689 struct ata_port *ap; 701 struct ata_port *ap;
690 int pmp; /* port multiplier port # */ 702 int pmp; /* port multiplier port # */
691 703
704 struct device tdev;
692 unsigned int active_tag; /* active tag on this link */ 705 unsigned int active_tag; /* active tag on this link */
693 u32 sactive; /* active NCQ commands */ 706 u32 sactive; /* active NCQ commands */
694 707
@@ -698,6 +711,7 @@ struct ata_link {
698 unsigned int hw_sata_spd_limit; 711 unsigned int hw_sata_spd_limit;
699 unsigned int sata_spd_limit; 712 unsigned int sata_spd_limit;
700 unsigned int sata_spd; /* current SATA PHY speed */ 713 unsigned int sata_spd; /* current SATA PHY speed */
714 enum ata_lpm_policy lpm_policy;
701 715
702 /* record runtime error info, protected by host_set lock */ 716 /* record runtime error info, protected by host_set lock */
703 struct ata_eh_info eh_info; 717 struct ata_eh_info eh_info;
@@ -706,6 +720,8 @@ struct ata_link {
706 720
707 struct ata_device device[ATA_MAX_DEVICES]; 721 struct ata_device device[ATA_MAX_DEVICES];
708}; 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])
709 725
710struct ata_port { 726struct ata_port {
711 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */ 727 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
@@ -723,6 +739,7 @@ struct ata_port {
723 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */ 739 struct ata_ioports ioaddr; /* ATA cmd/ctl/dma register blocks */
724 u8 ctl; /* cache of ATA control register */ 740 u8 ctl; /* cache of ATA control register */
725 u8 last_ctl; /* Cache last written value */ 741 u8 last_ctl; /* Cache last written value */
742 struct ata_link* sff_pio_task_link; /* link currently used */
726 struct delayed_work sff_pio_task; 743 struct delayed_work sff_pio_task;
727#ifdef CONFIG_ATA_BMDMA 744#ifdef CONFIG_ATA_BMDMA
728 struct ata_bmdma_prd *bmdma_prd; /* BMDMA SG list */ 745 struct ata_bmdma_prd *bmdma_prd; /* BMDMA SG list */
@@ -750,6 +767,7 @@ struct ata_port {
750 struct ata_port_stats stats; 767 struct ata_port_stats stats;
751 struct ata_host *host; 768 struct ata_host *host;
752 struct device *dev; 769 struct device *dev;
770 struct device tdev;
753 771
754 struct mutex scsi_scan_mutex; 772 struct mutex scsi_scan_mutex;
755 struct delayed_work hotplug_task; 773 struct delayed_work hotplug_task;
@@ -765,7 +783,7 @@ struct ata_port {
765 783
766 pm_message_t pm_mesg; 784 pm_message_t pm_mesg;
767 int *pm_result; 785 int *pm_result;
768 enum link_pm pm_policy; 786 enum ata_lpm_policy target_lpm_policy;
769 787
770 struct timer_list fastdrain_timer; 788 struct timer_list fastdrain_timer;
771 unsigned long fastdrain_cnt; 789 unsigned long fastdrain_cnt;
@@ -831,8 +849,8 @@ struct ata_port_operations {
831 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);
832 void (*pmp_attach)(struct ata_port *ap); 850 void (*pmp_attach)(struct ata_port *ap);
833 void (*pmp_detach)(struct ata_port *ap); 851 void (*pmp_detach)(struct ata_port *ap);
834 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 852 int (*set_lpm)(struct ata_link *link, enum ata_lpm_policy policy,
835 void (*disable_pm)(struct ata_port *ap); 853 unsigned hints);
836 854
837 /* 855 /*
838 * Start, stop, suspend and resume 856 * Start, stop, suspend and resume
@@ -944,6 +962,8 @@ extern int sata_link_debounce(struct ata_link *link,
944 const unsigned long *params, unsigned long deadline); 962 const unsigned long *params, unsigned long deadline);
945extern int sata_link_resume(struct ata_link *link, const unsigned long *params, 963extern int sata_link_resume(struct ata_link *link, const unsigned long *params,
946 unsigned long deadline); 964 unsigned long deadline);
965extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
966 bool spm_wakeup);
947extern int sata_link_hardreset(struct ata_link *link, 967extern int sata_link_hardreset(struct ata_link *link,
948 const unsigned long *timing, unsigned long deadline, 968 const unsigned long *timing, unsigned long deadline,
949 bool *online, int (*check_ready)(struct ata_link *)); 969 bool *online, int (*check_ready)(struct ata_link *));
@@ -989,8 +1009,9 @@ extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
989extern void ata_host_resume(struct ata_host *host); 1009extern void ata_host_resume(struct ata_host *host);
990#endif 1010#endif
991extern int ata_ratelimit(void); 1011extern int ata_ratelimit(void);
992extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 1012extern void ata_msleep(struct ata_port *ap, unsigned int msecs);
993 unsigned long interval, unsigned long timeout); 1013extern u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask,
1014 u32 val, unsigned long interval, unsigned long timeout);
994extern int atapi_cmd_type(u8 opcode); 1015extern int atapi_cmd_type(u8 opcode);
995extern void ata_tf_to_fis(const struct ata_taskfile *tf, 1016extern void ata_tf_to_fis(const struct ata_taskfile *tf,
996 u8 pmp, int is_cmd, u8 *fis); 1017 u8 pmp, int is_cmd, u8 *fis);
@@ -1594,7 +1615,7 @@ extern void ata_sff_irq_on(struct ata_port *ap);
1594extern void ata_sff_irq_clear(struct ata_port *ap); 1615extern void ata_sff_irq_clear(struct ata_port *ap);
1595extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, 1616extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1596 u8 status, int in_wq); 1617 u8 status, int in_wq);
1597extern void ata_sff_queue_pio_task(struct ata_port *ap, unsigned long delay); 1618extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay);
1598extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc); 1619extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
1599extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc); 1620extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
1600extern unsigned int ata_sff_port_intr(struct ata_port *ap, 1621extern unsigned int ata_sff_port_intr(struct ata_port *ap,