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.h93
1 files changed, 62 insertions, 31 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d1dfe872ee3..5b247b8a6b3 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -27,6 +27,7 @@
27#define __LINUX_LIBATA_H__ 27#define __LINUX_LIBATA_H__
28 28
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/jiffies.h>
30#include <linux/interrupt.h> 31#include <linux/interrupt.h>
31#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
32#include <linux/scatterlist.h> 33#include <linux/scatterlist.h>
@@ -111,14 +112,11 @@ enum {
111 /* various global constants */ 112 /* various global constants */
112 LIBATA_MAX_PRD = ATA_MAX_PRD / 2, 113 LIBATA_MAX_PRD = ATA_MAX_PRD / 2,
113 LIBATA_DUMB_MAX_PRD = ATA_MAX_PRD / 4, /* Worst case */ 114 LIBATA_DUMB_MAX_PRD = ATA_MAX_PRD / 4, /* Worst case */
114 ATA_MAX_PORTS = 8,
115 ATA_DEF_QUEUE = 1, 115 ATA_DEF_QUEUE = 1,
116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ 116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
117 ATA_MAX_QUEUE = 32, 117 ATA_MAX_QUEUE = 32,
118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, 118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
119 ATA_MAX_BUS = 2, 119 ATA_SHORT_PAUSE = 16,
120 ATA_DEF_BUSY_WAIT = 10000,
121 ATA_SHORT_PAUSE = (HZ >> 6) + 1,
122 120
123 ATAPI_MAX_DRAIN = 16 << 10, 121 ATAPI_MAX_DRAIN = 16 << 10,
124 122
@@ -171,6 +169,7 @@ enum {
171 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB, 169 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
172 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ 170 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */
173 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ 171 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */
172 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
174 173
175 /* struct ata_port flags */ 174 /* struct ata_port flags */
176 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 175 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
@@ -193,6 +192,10 @@ enum {
193 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 192 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
194 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 193 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
195 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ 194 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
195 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
196 * management */
197 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
198 * led */
196 199
197 /* The following flag belongs to ap->pflags but is kept in 200 /* The following flag belongs to ap->pflags but is kept in
198 * ap->flags because it's referenced in many LLDs and will be 201 * ap->flags because it's referenced in many LLDs and will be
@@ -237,17 +240,16 @@ enum {
237 /* bits 24:31 of host->flags are reserved for LLD specific flags */ 240 /* bits 24:31 of host->flags are reserved for LLD specific flags */
238 241
239 /* various lengths of time */ 242 /* various lengths of time */
240 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 243 ATA_TMOUT_BOOT = 30000, /* heuristic */
241 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ 244 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
242 ATA_TMOUT_INTERNAL = 30 * HZ, 245 ATA_TMOUT_INTERNAL_QUICK = 5000,
243 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,
244 246
245 /* FIXME: GoVault needs 2s but we can't afford that without 247 /* FIXME: GoVault needs 2s but we can't afford that without
246 * parallel probing. 800ms is enough for iVDR disk 248 * parallel probing. 800ms is enough for iVDR disk
247 * HHD424020F7SV00. Increase to 2secs when parallel probing 249 * HHD424020F7SV00. Increase to 2secs when parallel probing
248 * is in place. 250 * is in place.
249 */ 251 */
250 ATA_TMOUT_FF_WAIT = 4 * HZ / 5, 252 ATA_TMOUT_FF_WAIT = 800,
251 253
252 /* Spec mandates to wait for ">= 2ms" before checking status 254 /* Spec mandates to wait for ">= 2ms" before checking status
253 * after reset. We wait 150ms, because that was the magic 255 * after reset. We wait 150ms, because that was the magic
@@ -259,14 +261,14 @@ enum {
259 * 261 *
260 * Old drivers/ide uses the 2mS rule and then waits for ready. 262 * Old drivers/ide uses the 2mS rule and then waits for ready.
261 */ 263 */
262 ATA_WAIT_AFTER_RESET_MSECS = 150, 264 ATA_WAIT_AFTER_RESET = 150,
263 265
264 /* If PMP is supported, we have to do follow-up SRST. As some 266 /* If PMP is supported, we have to do follow-up SRST. As some
265 * PMPs don't send D2H Reg FIS after hardreset, LLDs are 267 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
266 * advised to wait only for the following duration before 268 * advised to wait only for the following duration before
267 * doing SRST. 269 * doing SRST.
268 */ 270 */
269 ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ, 271 ATA_TMOUT_PMP_SRST_WAIT = 1000,
270 272
271 /* ATA bus states */ 273 /* ATA bus states */
272 BUS_UNKNOWN = 0, 274 BUS_UNKNOWN = 0,
@@ -341,7 +343,12 @@ enum {
341 ATA_EH_PMP_TRIES = 5, 343 ATA_EH_PMP_TRIES = 5,
342 ATA_EH_PMP_LINK_TRIES = 3, 344 ATA_EH_PMP_LINK_TRIES = 3,
343 345
344 SATA_PMP_SCR_TIMEOUT = 250, 346 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */
347
348 /* This should match the actual table size of
349 * ata_eh_cmd_timeout_table in libata-eh.c.
350 */
351 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 5,
345 352
346 /* Horkage types. May be set by libata or controller on drives 353 /* Horkage types. May be set by libata or controller on drives
347 (some horkage may be drive/controller pair dependant */ 354 (some horkage may be drive/controller pair dependant */
@@ -351,7 +358,7 @@ enum {
351 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */ 358 ATA_HORKAGE_NONCQ = (1 << 2), /* Don't use NCQ */
352 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */ 359 ATA_HORKAGE_MAX_SEC_128 = (1 << 3), /* Limit max sects to 128 */
353 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ 360 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */
354 ATA_HORKAGE_SKIP_PM = (1 << 5), /* Skip PM operations */ 361 ATA_HORKAGE_DISABLE = (1 << 5), /* Disable it */
355 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ 362 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */
356 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */ 363 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */
357 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ 364 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */
@@ -444,6 +451,15 @@ enum link_pm {
444 MEDIUM_POWER, 451 MEDIUM_POWER,
445}; 452};
446extern struct device_attribute dev_attr_link_power_management_policy; 453extern struct device_attribute dev_attr_link_power_management_policy;
454extern struct device_attribute dev_attr_em_message_type;
455extern struct device_attribute dev_attr_em_message;
456extern struct device_attribute dev_attr_sw_activity;
457
458enum sw_activity {
459 OFF,
460 BLINK_ON,
461 BLINK_OFF,
462};
447 463
448#ifdef CONFIG_ATA_SFF 464#ifdef CONFIG_ATA_SFF
449struct ata_ioports { 465struct ata_ioports {
@@ -600,10 +616,14 @@ struct ata_eh_info {
600struct ata_eh_context { 616struct ata_eh_context {
601 struct ata_eh_info i; 617 struct ata_eh_info i;
602 int tries[ATA_MAX_DEVICES]; 618 int tries[ATA_MAX_DEVICES];
619 int cmd_timeout_idx[ATA_MAX_DEVICES]
620 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
603 unsigned int classes[ATA_MAX_DEVICES]; 621 unsigned int classes[ATA_MAX_DEVICES];
604 unsigned int did_probe_mask; 622 unsigned int did_probe_mask;
605 unsigned int saved_ncq_enabled; 623 unsigned int saved_ncq_enabled;
606 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 624 u8 saved_xfer_mode[ATA_MAX_DEVICES];
625 /* timestamp for the last reset attempt or success */
626 unsigned long last_reset;
607}; 627};
608 628
609struct ata_acpi_drive 629struct ata_acpi_drive
@@ -695,6 +715,7 @@ struct ata_port {
695 struct timer_list fastdrain_timer; 715 struct timer_list fastdrain_timer;
696 unsigned long fastdrain_cnt; 716 unsigned long fastdrain_cnt;
697 717
718 int em_message_type;
698 void *private_data; 719 void *private_data;
699 720
700#ifdef CONFIG_ATA_ACPI 721#ifdef CONFIG_ATA_ACPI
@@ -786,6 +807,12 @@ struct ata_port_operations {
786 u8 (*bmdma_status)(struct ata_port *ap); 807 u8 (*bmdma_status)(struct ata_port *ap);
787#endif /* CONFIG_ATA_SFF */ 808#endif /* CONFIG_ATA_SFF */
788 809
810 ssize_t (*em_show)(struct ata_port *ap, char *buf);
811 ssize_t (*em_store)(struct ata_port *ap, const char *message,
812 size_t size);
813 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
814 ssize_t (*sw_activity_store)(struct ata_device *dev,
815 enum sw_activity val);
789 /* 816 /*
790 * Obsolete 817 * Obsolete
791 */ 818 */
@@ -821,8 +848,6 @@ struct ata_timing {
821 unsigned short udma; /* t2CYCTYP/2 */ 848 unsigned short udma; /* t2CYCTYP/2 */
822}; 849};
823 850
824#define FIT(v, vmin, vmax) max_t(short, min_t(short, v, vmax), vmin)
825
826/* 851/*
827 * Core layer - drivers/ata/libata-core.c 852 * Core layer - drivers/ata/libata-core.c
828 */ 853 */
@@ -900,8 +925,7 @@ extern void ata_host_resume(struct ata_host *host);
900#endif 925#endif
901extern int ata_ratelimit(void); 926extern int ata_ratelimit(void);
902extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 927extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
903 unsigned long interval_msec, 928 unsigned long interval, unsigned long timeout);
904 unsigned long timeout_msec);
905extern int atapi_cmd_type(u8 opcode); 929extern int atapi_cmd_type(u8 opcode);
906extern void ata_tf_to_fis(const struct ata_taskfile *tf, 930extern void ata_tf_to_fis(const struct ata_taskfile *tf,
907 u8 pmp, int is_cmd, u8 *fis); 931 u8 pmp, int is_cmd, u8 *fis);
@@ -1039,6 +1063,7 @@ extern void ata_eh_thaw_port(struct ata_port *ap);
1039 1063
1040extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); 1064extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
1041extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); 1065extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
1066extern void ata_eh_analyze_ncq_error(struct ata_link *link);
1042 1067
1043extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 1068extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1044 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1069 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
@@ -1381,6 +1406,24 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1381 return *(struct ata_port **)&host->hostdata[0]; 1406 return *(struct ata_port **)&host->hostdata[0];
1382} 1407}
1383 1408
1409static inline int ata_check_ready(u8 status)
1410{
1411 if (!(status & ATA_BUSY))
1412 return 1;
1413
1414 /* 0xff indicates either no device or device not ready */
1415 if (status == 0xff)
1416 return -ENODEV;
1417
1418 return 0;
1419}
1420
1421static inline unsigned long ata_deadline(unsigned long from_jiffies,
1422 unsigned long timeout_msecs)
1423{
1424 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1425}
1426
1384 1427
1385/************************************************************************** 1428/**************************************************************************
1386 * PMP - drivers/ata/libata-pmp.c 1429 * PMP - drivers/ata/libata-pmp.c
@@ -1424,7 +1467,8 @@ extern void ata_sff_qc_prep(struct ata_queued_cmd *qc);
1424extern void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc); 1467extern void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc);
1425extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device); 1468extern void ata_sff_dev_select(struct ata_port *ap, unsigned int device);
1426extern u8 ata_sff_check_status(struct ata_port *ap); 1469extern u8 ata_sff_check_status(struct ata_port *ap);
1427extern u8 ata_sff_altstatus(struct ata_port *ap); 1470extern void ata_sff_pause(struct ata_port *ap);
1471extern void ata_sff_dma_pause(struct ata_port *ap);
1428extern int ata_sff_busy_sleep(struct ata_port *ap, 1472extern int ata_sff_busy_sleep(struct ata_port *ap,
1429 unsigned long timeout_pat, unsigned long timeout); 1473 unsigned long timeout_pat, unsigned long timeout);
1430extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline); 1474extern int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline);
@@ -1485,19 +1529,6 @@ extern int ata_pci_sff_init_one(struct pci_dev *pdev,
1485#endif /* CONFIG_PCI */ 1529#endif /* CONFIG_PCI */
1486 1530
1487/** 1531/**
1488 * ata_sff_pause - Flush writes and pause 400 nanoseconds.
1489 * @ap: Port to wait for.
1490 *
1491 * LOCKING:
1492 * Inherited from caller.
1493 */
1494static inline void ata_sff_pause(struct ata_port *ap)
1495{
1496 ata_sff_altstatus(ap);
1497 ndelay(400);
1498}
1499
1500/**
1501 * ata_sff_busy_wait - Wait for a port status register 1532 * ata_sff_busy_wait - Wait for a port status register
1502 * @ap: Port to wait for. 1533 * @ap: Port to wait for.
1503 * @bits: bits that must be clear 1534 * @bits: bits that must be clear