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.h103
1 files changed, 64 insertions, 39 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 5b247b8a6b3b..507f53ef8038 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -60,9 +60,9 @@
60 60
61/* note: prints function name for you */ 61/* note: prints function name for you */
62#ifdef ATA_DEBUG 62#ifdef ATA_DEBUG
63#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 63#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
64#ifdef ATA_VERBOSE_DEBUG 64#ifdef ATA_VERBOSE_DEBUG
65#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 65#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
66#else 66#else
67#define VPRINTK(fmt, args...) 67#define VPRINTK(fmt, args...)
68#endif /* ATA_VERBOSE_DEBUG */ 68#endif /* ATA_VERBOSE_DEBUG */
@@ -71,7 +71,7 @@
71#define VPRINTK(fmt, args...) 71#define VPRINTK(fmt, args...)
72#endif /* ATA_DEBUG */ 72#endif /* ATA_DEBUG */
73 73
74#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 74#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args)
75 75
76/* NEW: debug levels */ 76/* NEW: debug levels */
77#define HAVE_LIBATA_MSG 1 77#define HAVE_LIBATA_MSG 1
@@ -146,6 +146,7 @@ enum {
146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
149 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
149 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
150 151
151 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
@@ -163,6 +164,7 @@ enum {
163 ATA_DEV_NONE = 9, /* no device */ 164 ATA_DEV_NONE = 9, /* no device */
164 165
165 /* struct ata_link flags */ 166 /* struct ata_link flags */
167 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */
166 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ 168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */
167 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ 169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */
168 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ 170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */
@@ -243,6 +245,7 @@ enum {
243 ATA_TMOUT_BOOT = 30000, /* heuristic */ 245 ATA_TMOUT_BOOT = 30000, /* heuristic */
244 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */ 246 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
245 ATA_TMOUT_INTERNAL_QUICK = 5000, 247 ATA_TMOUT_INTERNAL_QUICK = 5000,
248 ATA_TMOUT_MAX_PARK = 30000,
246 249
247 /* FIXME: GoVault needs 2s but we can't afford that without 250 /* FIXME: GoVault needs 2s but we can't afford that without
248 * parallel probing. 800ms is enough for iVDR disk 251 * parallel probing. 800ms is enough for iVDR disk
@@ -318,8 +321,11 @@ enum {
318 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
319 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
320 ATA_EH_LPM = (1 << 4), /* link power management action */ 323 ATA_EH_LPM = (1 << 4), /* link power management action */
324 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
321 325
322 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, 326 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
327 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
328 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
323 329
324 /* ata_eh_info->flags */ 330 /* ata_eh_info->flags */
325 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 331 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -334,6 +340,9 @@ enum {
334 340
335 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, 341 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
336 342
343 /* mask of flags to transfer *to* the slave link */
344 ATA_EHI_TO_SLAVE_MASK = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET,
345
337 /* max tries if error condition is still set after ->error_handler */ 346 /* max tries if error condition is still set after ->error_handler */
338 ATA_EH_MAX_TRIES = 5, 347 ATA_EH_MAX_TRIES = 5,
339 348
@@ -451,6 +460,7 @@ enum link_pm {
451 MEDIUM_POWER, 460 MEDIUM_POWER,
452}; 461};
453extern struct device_attribute dev_attr_link_power_management_policy; 462extern struct device_attribute dev_attr_link_power_management_policy;
463extern struct device_attribute dev_attr_unload_heads;
454extern struct device_attribute dev_attr_em_message_type; 464extern struct device_attribute dev_attr_em_message_type;
455extern struct device_attribute dev_attr_em_message; 465extern struct device_attribute dev_attr_em_message;
456extern struct device_attribute dev_attr_sw_activity; 466extern struct device_attribute dev_attr_sw_activity;
@@ -553,8 +563,8 @@ struct ata_ering {
553struct ata_device { 563struct ata_device {
554 struct ata_link *link; 564 struct ata_link *link;
555 unsigned int devno; /* 0 or 1 */ 565 unsigned int devno; /* 0 or 1 */
556 unsigned long flags; /* ATA_DFLAG_xxx */
557 unsigned int horkage; /* List of broken features */ 566 unsigned int horkage; /* List of broken features */
567 unsigned long flags; /* ATA_DFLAG_xxx */
558 struct scsi_device *sdev; /* attached SCSI device */ 568 struct scsi_device *sdev; /* attached SCSI device */
559#ifdef CONFIG_ATA_ACPI 569#ifdef CONFIG_ATA_ACPI
560 acpi_handle acpi_handle; 570 acpi_handle acpi_handle;
@@ -563,6 +573,7 @@ struct ata_device {
563 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 573 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
564 u64 n_sectors; /* size of device, if ATA */ 574 u64 n_sectors; /* size of device, if ATA */
565 unsigned int class; /* ATA_DEV_xxx */ 575 unsigned int class; /* ATA_DEV_xxx */
576 unsigned long unpark_deadline;
566 577
567 u8 pio_mode; 578 u8 pio_mode;
568 u8 dma_mode; 579 u8 dma_mode;
@@ -620,6 +631,7 @@ struct ata_eh_context {
620 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 631 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
621 unsigned int classes[ATA_MAX_DEVICES]; 632 unsigned int classes[ATA_MAX_DEVICES];
622 unsigned int did_probe_mask; 633 unsigned int did_probe_mask;
634 unsigned int unloaded_mask;
623 unsigned int saved_ncq_enabled; 635 unsigned int saved_ncq_enabled;
624 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 636 u8 saved_xfer_mode[ATA_MAX_DEVICES];
625 /* timestamp for the last reset attempt or success */ 637 /* timestamp for the last reset attempt or success */
@@ -646,6 +658,7 @@ struct ata_link {
646 658
647 unsigned int flags; /* ATA_LFLAG_xxx */ 659 unsigned int flags; /* ATA_LFLAG_xxx */
648 660
661 u32 saved_scontrol; /* SControl on probe */
649 unsigned int hw_sata_spd_limit; 662 unsigned int hw_sata_spd_limit;
650 unsigned int sata_spd_limit; 663 unsigned int sata_spd_limit;
651 unsigned int sata_spd; /* current SATA PHY speed */ 664 unsigned int sata_spd; /* current SATA PHY speed */
@@ -682,11 +695,11 @@ struct ata_port {
682 unsigned int cbl; /* cable type; ATA_CBL_xxx */ 695 unsigned int cbl; /* cable type; ATA_CBL_xxx */
683 696
684 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; 697 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
685 unsigned long qc_allocated;
686 unsigned int qc_active; 698 unsigned int qc_active;
687 int nr_active_links; /* #links with active qcs */ 699 int nr_active_links; /* #links with active qcs */
688 700
689 struct ata_link link; /* host default link */ 701 struct ata_link link; /* host default link */
702 struct ata_link *slave_link; /* see ata_slave_link_init() */
690 703
691 int nr_pmp_links; /* nr of available PMP links */ 704 int nr_pmp_links; /* nr of available PMP links */
692 struct ata_link *pmp_link; /* array of PMP links */ 705 struct ata_link *pmp_link; /* array of PMP links */
@@ -707,6 +720,7 @@ struct ata_port {
707 struct list_head eh_done_q; 720 struct list_head eh_done_q;
708 wait_queue_head_t eh_wait_q; 721 wait_queue_head_t eh_wait_q;
709 int eh_tries; 722 int eh_tries;
723 struct completion park_req_pending;
710 724
711 pm_message_t pm_mesg; 725 pm_message_t pm_mesg;
712 int *pm_result; 726 int *pm_result;
@@ -750,6 +764,7 @@ struct ata_port_operations {
750 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); 764 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
751 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); 765 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
752 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev); 766 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
767 unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id);
753 768
754 void (*dev_config)(struct ata_device *dev); 769 void (*dev_config)(struct ata_device *dev);
755 770
@@ -769,8 +784,8 @@ struct ata_port_operations {
769 /* 784 /*
770 * Optional features 785 * Optional features
771 */ 786 */
772 int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val); 787 int (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
773 int (*scr_write)(struct ata_port *ap, unsigned int sc_reg, u32 val); 788 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
774 void (*pmp_attach)(struct ata_port *ap); 789 void (*pmp_attach)(struct ata_port *ap);
775 void (*pmp_detach)(struct ata_port *ap); 790 void (*pmp_detach)(struct ata_port *ap);
776 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 791 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -892,6 +907,7 @@ extern void ata_port_disable(struct ata_port *);
892extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 907extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
893extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 908extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
894 const struct ata_port_info * const * ppi, int n_ports); 909 const struct ata_port_info * const * ppi, int n_ports);
910extern int ata_slave_link_init(struct ata_port *ap);
895extern int ata_host_start(struct ata_host *host); 911extern int ata_host_start(struct ata_host *host);
896extern int ata_host_register(struct ata_host *host, 912extern int ata_host_register(struct ata_host *host,
897 struct scsi_host_template *sht); 913 struct scsi_host_template *sht);
@@ -917,8 +933,8 @@ extern int sata_scr_valid(struct ata_link *link);
917extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 933extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
918extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 934extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
919extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val); 935extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
920extern int ata_link_online(struct ata_link *link); 936extern bool ata_link_online(struct ata_link *link);
921extern int ata_link_offline(struct ata_link *link); 937extern bool ata_link_offline(struct ata_link *link);
922#ifdef CONFIG_PM 938#ifdef CONFIG_PM
923extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 939extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
924extern void ata_host_resume(struct ata_host *host); 940extern void ata_host_resume(struct ata_host *host);
@@ -951,6 +967,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
951 unsigned int ofs, unsigned int len); 967 unsigned int ofs, unsigned int len);
952extern void ata_id_c_string(const u16 *id, unsigned char *s, 968extern void ata_id_c_string(const u16 *id, unsigned char *s,
953 unsigned int ofs, unsigned int len); 969 unsigned int ofs, unsigned int len);
970extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
971 struct ata_taskfile *tf, u16 *id);
954extern void ata_qc_complete(struct ata_queued_cmd *qc); 972extern void ata_qc_complete(struct ata_queued_cmd *qc);
955extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); 973extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
956extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 974extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
@@ -1093,6 +1111,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1093 */ 1111 */
1094extern const struct ata_port_operations ata_base_port_ops; 1112extern const struct ata_port_operations ata_base_port_ops;
1095extern const struct ata_port_operations sata_port_ops; 1113extern const struct ata_port_operations sata_port_ops;
1114extern struct device_attribute *ata_common_sdev_attrs[];
1096 1115
1097#define ATA_BASE_SHT(drv_name) \ 1116#define ATA_BASE_SHT(drv_name) \
1098 .module = THIS_MODULE, \ 1117 .module = THIS_MODULE, \
@@ -1107,7 +1126,8 @@ extern const struct ata_port_operations sata_port_ops;
1107 .proc_name = drv_name, \ 1126 .proc_name = drv_name, \
1108 .slave_configure = ata_scsi_slave_config, \ 1127 .slave_configure = ata_scsi_slave_config, \
1109 .slave_destroy = ata_scsi_slave_destroy, \ 1128 .slave_destroy = ata_scsi_slave_destroy, \
1110 .bios_param = ata_std_bios_param 1129 .bios_param = ata_std_bios_param, \
1130 .sdev_attrs = ata_common_sdev_attrs
1111 1131
1112#define ATA_NCQ_SHT(drv_name) \ 1132#define ATA_NCQ_SHT(drv_name) \
1113 ATA_BASE_SHT(drv_name), \ 1133 ATA_BASE_SHT(drv_name), \
@@ -1129,7 +1149,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1129 1149
1130static inline int ata_is_host_link(const struct ata_link *link) 1150static inline int ata_is_host_link(const struct ata_link *link)
1131{ 1151{
1132 return link == &link->ap->link; 1152 return link == &link->ap->link || link == link->ap->slave_link;
1133} 1153}
1134#else /* CONFIG_SATA_PMP */ 1154#else /* CONFIG_SATA_PMP */
1135static inline bool sata_pmp_supported(struct ata_port *ap) 1155static inline bool sata_pmp_supported(struct ata_port *ap)
@@ -1162,7 +1182,7 @@ static inline int sata_srst_pmp(struct ata_link *link)
1162 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1182 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1163 1183
1164#define ata_link_printk(link, lv, fmt, args...) do { \ 1184#define ata_link_printk(link, lv, fmt, args...) do { \
1165 if (sata_pmp_attached((link)->ap)) \ 1185 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1166 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1186 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1167 (link)->pmp , ##args); \ 1187 (link)->pmp , ##args); \
1168 else \ 1188 else \
@@ -1260,34 +1280,17 @@ static inline int ata_link_active(struct ata_link *link)
1260 return ata_tag_valid(link->active_tag) || link->sactive; 1280 return ata_tag_valid(link->active_tag) || link->sactive;
1261} 1281}
1262 1282
1263static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1283extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1264{ 1284 struct ata_link *link,
1265 if (sata_pmp_attached(ap)) 1285 bool dev_only);
1266 return ap->pmp_link;
1267 return &ap->link;
1268}
1269
1270static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1271{
1272 struct ata_port *ap = link->ap;
1273
1274 if (ata_is_host_link(link)) {
1275 if (!sata_pmp_attached(ap))
1276 return NULL;
1277 return ap->pmp_link;
1278 }
1279
1280 if (++link < ap->nr_pmp_links + ap->pmp_link)
1281 return link;
1282 return NULL;
1283}
1284 1286
1285#define __ata_port_for_each_link(lk, ap) \ 1287#define __ata_port_for_each_link(link, ap) \
1286 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) 1288 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1289 (link) = __ata_port_next_link((ap), (link), false))
1287 1290
1288#define ata_port_for_each_link(link, ap) \ 1291#define ata_port_for_each_link(link, ap) \
1289 for ((link) = ata_port_first_link(ap); (link); \ 1292 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1290 (link) = ata_port_next_link(link)) 1293 (link) = __ata_port_next_link((ap), (link), true))
1291 1294
1292#define ata_link_for_each_dev(dev, link) \ 1295#define ata_link_for_each_dev(dev, link) \
1293 for ((dev) = (link)->device; \ 1296 for ((dev) = (link)->device; \
@@ -1424,6 +1427,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
1424 return from_jiffies + msecs_to_jiffies(timeout_msecs); 1427 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1425} 1428}
1426 1429
1430/* Don't open code these in drivers as there are traps. Firstly the range may
1431 change in future hardware and specs, secondly 0xFF means 'no DMA' but is
1432 > UDMA_0. Dyma ddreigiau */
1433
1434static inline int ata_using_mwdma(struct ata_device *adev)
1435{
1436 if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
1437 return 1;
1438 return 0;
1439}
1440
1441static inline int ata_using_udma(struct ata_device *adev)
1442{
1443 if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
1444 return 1;
1445 return 0;
1446}
1447
1448static inline int ata_dma_enabled(struct ata_device *adev)
1449{
1450 return (adev->dma_mode == 0xFF ? 0 : 1);
1451}
1427 1452
1428/************************************************************************** 1453/**************************************************************************
1429 * PMP - drivers/ata/libata-pmp.c 1454 * PMP - drivers/ata/libata-pmp.c