aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-21 22:03:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-21 22:03:38 -0400
commite10117d36ef758da0690c95ecffc09d5dd7da479 (patch)
treef2bb867cfc33f24d9c6bbb36dd189869e62ecce2 /include/linux
parentf3270b16e00f0614fa418dcc50883da5949375b4 (diff)
parent89692c03226a066a017048cf7fbacbaa645f0e79 (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (26 commits) include/linux/libata.h: fix typo pata_bf54x: fix return type of bfin_set_devctl Drivers: ata: Makefile: replace the use of <module>-objs with <module>-y libahci: fix result_tf handling after an ATA PIO data-in command pata_sl82c105: implement sff_irq_check() method pata_sil680: implement sff_irq_check() method pata_pdc202xx_old: implement sff_irq_check() method pata_cmd640: implement sff_irq_check() method ata_piix: Add device ID for ICH4-L pata_sil680: make sil680_sff_exec_command() 'static' ata: Intel IDE-R support libata: reorder ata_queued_cmd to remove alignment padding on 64 bit builds libata: Signal that our SATL supports WRITE SAME(16) with UNMAP ata_piix: remove SIDPR locking libata: implement cross-port EH exclusion libata: add @ap to ata_wait_register() and introduce ata_msleep() ata_piix: implement LPM support libata: implement LPM support for port multipliers libata: reimplement link power management libata: implement sata_link_scr_lpm() and make ata_dev_set_feature() global ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ata.h46
-rw-r--r--include/linux/libata.h65
2 files changed, 82 insertions, 29 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fe6e681a9d74..0c4929fa34d3 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -89,6 +89,7 @@ enum {
89 ATA_ID_SPG = 98, 89 ATA_ID_SPG = 98,
90 ATA_ID_LBA_CAPACITY_2 = 100, 90 ATA_ID_LBA_CAPACITY_2 = 100,
91 ATA_ID_SECTOR_SIZE = 106, 91 ATA_ID_SECTOR_SIZE = 106,
92 ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */
92 ATA_ID_LAST_LUN = 126, 93 ATA_ID_LAST_LUN = 126,
93 ATA_ID_DLF = 128, 94 ATA_ID_DLF = 128,
94 ATA_ID_CSFO = 129, 95 ATA_ID_CSFO = 129,
@@ -640,16 +641,49 @@ static inline int ata_id_flush_ext_enabled(const u16 *id)
640 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; 641 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400;
641} 642}
642 643
643static inline int ata_id_has_large_logical_sectors(const u16 *id) 644static inline u32 ata_id_logical_sector_size(const u16 *id)
644{ 645{
645 if ((id[ATA_ID_SECTOR_SIZE] & 0xc000) != 0x4000) 646 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
646 return 0; 647 * IDENTIFY DEVICE data, word 117-118.
647 return id[ATA_ID_SECTOR_SIZE] & (1 << 13); 648 * 0xd000 ignores bit 13 (logical:physical > 1)
649 */
650 if ((id[ATA_ID_SECTOR_SIZE] & 0xd000) == 0x5000)
651 return (((id[ATA_ID_LOGICAL_SECTOR_SIZE+1] << 16)
652 + id[ATA_ID_LOGICAL_SECTOR_SIZE]) * sizeof(u16)) ;
653 return ATA_SECT_SIZE;
654}
655
656static inline u8 ata_id_log2_per_physical_sector(const u16 *id)
657{
658 /* T13/1699-D Revision 6a, Sep 6, 2008. Page 128.
659 * IDENTIFY DEVICE data, word 106.
660 * 0xe000 ignores bit 12 (logical sector > 512 bytes)
661 */
662 if ((id[ATA_ID_SECTOR_SIZE] & 0xe000) == 0x6000)
663 return (id[ATA_ID_SECTOR_SIZE] & 0xf);
664 return 0;
648} 665}
649 666
650static inline u16 ata_id_logical_per_physical_sectors(const u16 *id) 667/* Offset of logical sectors relative to physical sectors.
668 *
669 * If device has more than one logical sector per physical sector
670 * (aka 512 byte emulation), vendors might offset the "sector 0" address
671 * so sector 63 is "naturally aligned" - e.g. FAT partition table.
672 * This avoids Read/Mod/Write penalties when using FAT partition table
673 * and updating "well aligned" (FS perspective) physical sectors on every
674 * transaction.
675 */
676static inline u16 ata_id_logical_sector_offset(const u16 *id,
677 u8 log2_per_phys)
651{ 678{
652 return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf); 679 u16 word_209 = id[209];
680
681 if ((log2_per_phys > 1) && (word_209 & 0xc000) == 0x4000) {
682 u16 first = word_209 & 0x3fff;
683 if (first > 0)
684 return (1 << log2_per_phys) - first;
685 }
686 return 0;
653} 687}
654 688
655static inline int ata_id_has_lba48(const u16 *id) 689static inline int ata_id_has_lba48(const u16 *id)
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 */
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
467/* forward declarations */ 483/* forward declarations */
468struct scsi_device; 484struct scsi_device;
469struct ata_port_operations; 485struct 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);
479typedef 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);
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 */
485enum link_pm {
486 NOT_AVAILABLE,
487 MIN_POWER,
488 MAX_PERFORMANCE,
489 MEDIUM_POWER,
490};
491extern struct device_attribute dev_attr_link_power_management_policy; 497extern struct device_attribute dev_attr_link_power_management_policy;
492extern struct device_attribute dev_attr_unload_heads; 498extern struct device_attribute dev_attr_unload_heads;
493extern struct device_attribute dev_attr_em_message_type; 499extern 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
711struct ata_port { 726struct 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);
947extern 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,
948 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);
949extern int sata_link_hardreset(struct ata_link *link, 967extern 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);
991extern void ata_host_resume(struct ata_host *host); 1009extern void ata_host_resume(struct ata_host *host);
992#endif 1010#endif
993extern int ata_ratelimit(void); 1011extern int ata_ratelimit(void);
994extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 1012extern void ata_msleep(struct ata_port *ap, unsigned int msecs);
995 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);
996extern int atapi_cmd_type(u8 opcode); 1015extern int atapi_cmd_type(u8 opcode);
997extern void ata_tf_to_fis(const struct ata_taskfile *tf, 1016extern 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);