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.h99
1 files changed, 61 insertions, 38 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 5b247b8a6b3b..947cf84e555d 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 */
@@ -451,6 +457,7 @@ enum link_pm {
451 MEDIUM_POWER, 457 MEDIUM_POWER,
452}; 458};
453extern struct device_attribute dev_attr_link_power_management_policy; 459extern struct device_attribute dev_attr_link_power_management_policy;
460extern struct device_attribute dev_attr_unload_heads;
454extern struct device_attribute dev_attr_em_message_type; 461extern struct device_attribute dev_attr_em_message_type;
455extern struct device_attribute dev_attr_em_message; 462extern struct device_attribute dev_attr_em_message;
456extern struct device_attribute dev_attr_sw_activity; 463extern struct device_attribute dev_attr_sw_activity;
@@ -553,8 +560,8 @@ struct ata_ering {
553struct ata_device { 560struct ata_device {
554 struct ata_link *link; 561 struct ata_link *link;
555 unsigned int devno; /* 0 or 1 */ 562 unsigned int devno; /* 0 or 1 */
556 unsigned long flags; /* ATA_DFLAG_xxx */
557 unsigned int horkage; /* List of broken features */ 563 unsigned int horkage; /* List of broken features */
564 unsigned long flags; /* ATA_DFLAG_xxx */
558 struct scsi_device *sdev; /* attached SCSI device */ 565 struct scsi_device *sdev; /* attached SCSI device */
559#ifdef CONFIG_ATA_ACPI 566#ifdef CONFIG_ATA_ACPI
560 acpi_handle acpi_handle; 567 acpi_handle acpi_handle;
@@ -563,6 +570,7 @@ struct ata_device {
563 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 570 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
564 u64 n_sectors; /* size of device, if ATA */ 571 u64 n_sectors; /* size of device, if ATA */
565 unsigned int class; /* ATA_DEV_xxx */ 572 unsigned int class; /* ATA_DEV_xxx */
573 unsigned long unpark_deadline;
566 574
567 u8 pio_mode; 575 u8 pio_mode;
568 u8 dma_mode; 576 u8 dma_mode;
@@ -620,6 +628,7 @@ struct ata_eh_context {
620 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 628 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
621 unsigned int classes[ATA_MAX_DEVICES]; 629 unsigned int classes[ATA_MAX_DEVICES];
622 unsigned int did_probe_mask; 630 unsigned int did_probe_mask;
631 unsigned int unloaded_mask;
623 unsigned int saved_ncq_enabled; 632 unsigned int saved_ncq_enabled;
624 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 633 u8 saved_xfer_mode[ATA_MAX_DEVICES];
625 /* timestamp for the last reset attempt or success */ 634 /* timestamp for the last reset attempt or success */
@@ -646,6 +655,7 @@ struct ata_link {
646 655
647 unsigned int flags; /* ATA_LFLAG_xxx */ 656 unsigned int flags; /* ATA_LFLAG_xxx */
648 657
658 u32 saved_scontrol; /* SControl on probe */
649 unsigned int hw_sata_spd_limit; 659 unsigned int hw_sata_spd_limit;
650 unsigned int sata_spd_limit; 660 unsigned int sata_spd_limit;
651 unsigned int sata_spd; /* current SATA PHY speed */ 661 unsigned int sata_spd; /* current SATA PHY speed */
@@ -686,7 +696,8 @@ struct ata_port {
686 unsigned int qc_active; 696 unsigned int qc_active;
687 int nr_active_links; /* #links with active qcs */ 697 int nr_active_links; /* #links with active qcs */
688 698
689 struct ata_link link; /* host default link */ 699 struct ata_link link; /* host default link */
700 struct ata_link *slave_link; /* see ata_slave_link_init() */
690 701
691 int nr_pmp_links; /* nr of available PMP links */ 702 int nr_pmp_links; /* nr of available PMP links */
692 struct ata_link *pmp_link; /* array of PMP links */ 703 struct ata_link *pmp_link; /* array of PMP links */
@@ -707,6 +718,7 @@ struct ata_port {
707 struct list_head eh_done_q; 718 struct list_head eh_done_q;
708 wait_queue_head_t eh_wait_q; 719 wait_queue_head_t eh_wait_q;
709 int eh_tries; 720 int eh_tries;
721 struct completion park_req_pending;
710 722
711 pm_message_t pm_mesg; 723 pm_message_t pm_mesg;
712 int *pm_result; 724 int *pm_result;
@@ -750,6 +762,7 @@ struct ata_port_operations {
750 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); 762 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
751 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); 763 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); 764 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
765 unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id);
753 766
754 void (*dev_config)(struct ata_device *dev); 767 void (*dev_config)(struct ata_device *dev);
755 768
@@ -769,8 +782,8 @@ struct ata_port_operations {
769 /* 782 /*
770 * Optional features 783 * Optional features
771 */ 784 */
772 int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val); 785 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); 786 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
774 void (*pmp_attach)(struct ata_port *ap); 787 void (*pmp_attach)(struct ata_port *ap);
775 void (*pmp_detach)(struct ata_port *ap); 788 void (*pmp_detach)(struct ata_port *ap);
776 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 789 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -892,6 +905,7 @@ extern void ata_port_disable(struct ata_port *);
892extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 905extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
893extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 906extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
894 const struct ata_port_info * const * ppi, int n_ports); 907 const struct ata_port_info * const * ppi, int n_ports);
908extern int ata_slave_link_init(struct ata_port *ap);
895extern int ata_host_start(struct ata_host *host); 909extern int ata_host_start(struct ata_host *host);
896extern int ata_host_register(struct ata_host *host, 910extern int ata_host_register(struct ata_host *host,
897 struct scsi_host_template *sht); 911 struct scsi_host_template *sht);
@@ -917,8 +931,8 @@ extern int sata_scr_valid(struct ata_link *link);
917extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 931extern 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); 932extern 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); 933extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
920extern int ata_link_online(struct ata_link *link); 934extern bool ata_link_online(struct ata_link *link);
921extern int ata_link_offline(struct ata_link *link); 935extern bool ata_link_offline(struct ata_link *link);
922#ifdef CONFIG_PM 936#ifdef CONFIG_PM
923extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 937extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
924extern void ata_host_resume(struct ata_host *host); 938extern void ata_host_resume(struct ata_host *host);
@@ -951,6 +965,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
951 unsigned int ofs, unsigned int len); 965 unsigned int ofs, unsigned int len);
952extern void ata_id_c_string(const u16 *id, unsigned char *s, 966extern void ata_id_c_string(const u16 *id, unsigned char *s,
953 unsigned int ofs, unsigned int len); 967 unsigned int ofs, unsigned int len);
968extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
969 struct ata_taskfile *tf, u16 *id);
954extern void ata_qc_complete(struct ata_queued_cmd *qc); 970extern void ata_qc_complete(struct ata_queued_cmd *qc);
955extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); 971extern 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, 972extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
@@ -1093,6 +1109,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1093 */ 1109 */
1094extern const struct ata_port_operations ata_base_port_ops; 1110extern const struct ata_port_operations ata_base_port_ops;
1095extern const struct ata_port_operations sata_port_ops; 1111extern const struct ata_port_operations sata_port_ops;
1112extern struct device_attribute *ata_common_sdev_attrs[];
1096 1113
1097#define ATA_BASE_SHT(drv_name) \ 1114#define ATA_BASE_SHT(drv_name) \
1098 .module = THIS_MODULE, \ 1115 .module = THIS_MODULE, \
@@ -1107,7 +1124,8 @@ extern const struct ata_port_operations sata_port_ops;
1107 .proc_name = drv_name, \ 1124 .proc_name = drv_name, \
1108 .slave_configure = ata_scsi_slave_config, \ 1125 .slave_configure = ata_scsi_slave_config, \
1109 .slave_destroy = ata_scsi_slave_destroy, \ 1126 .slave_destroy = ata_scsi_slave_destroy, \
1110 .bios_param = ata_std_bios_param 1127 .bios_param = ata_std_bios_param, \
1128 .sdev_attrs = ata_common_sdev_attrs
1111 1129
1112#define ATA_NCQ_SHT(drv_name) \ 1130#define ATA_NCQ_SHT(drv_name) \
1113 ATA_BASE_SHT(drv_name), \ 1131 ATA_BASE_SHT(drv_name), \
@@ -1129,7 +1147,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1129 1147
1130static inline int ata_is_host_link(const struct ata_link *link) 1148static inline int ata_is_host_link(const struct ata_link *link)
1131{ 1149{
1132 return link == &link->ap->link; 1150 return link == &link->ap->link || link == link->ap->slave_link;
1133} 1151}
1134#else /* CONFIG_SATA_PMP */ 1152#else /* CONFIG_SATA_PMP */
1135static inline bool sata_pmp_supported(struct ata_port *ap) 1153static inline bool sata_pmp_supported(struct ata_port *ap)
@@ -1162,7 +1180,7 @@ static inline int sata_srst_pmp(struct ata_link *link)
1162 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1180 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1163 1181
1164#define ata_link_printk(link, lv, fmt, args...) do { \ 1182#define ata_link_printk(link, lv, fmt, args...) do { \
1165 if (sata_pmp_attached((link)->ap)) \ 1183 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1166 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1184 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1167 (link)->pmp , ##args); \ 1185 (link)->pmp , ##args); \
1168 else \ 1186 else \
@@ -1260,34 +1278,17 @@ static inline int ata_link_active(struct ata_link *link)
1260 return ata_tag_valid(link->active_tag) || link->sactive; 1278 return ata_tag_valid(link->active_tag) || link->sactive;
1261} 1279}
1262 1280
1263static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1281extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1264{ 1282 struct ata_link *link,
1265 if (sata_pmp_attached(ap)) 1283 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 1284
1285#define __ata_port_for_each_link(lk, ap) \ 1285#define __ata_port_for_each_link(link, ap) \
1286 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) 1286 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1287 (link) = __ata_port_next_link((ap), (link), false))
1287 1288
1288#define ata_port_for_each_link(link, ap) \ 1289#define ata_port_for_each_link(link, ap) \
1289 for ((link) = ata_port_first_link(ap); (link); \ 1290 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1290 (link) = ata_port_next_link(link)) 1291 (link) = __ata_port_next_link((ap), (link), true))
1291 1292
1292#define ata_link_for_each_dev(dev, link) \ 1293#define ata_link_for_each_dev(dev, link) \
1293 for ((dev) = (link)->device; \ 1294 for ((dev) = (link)->device; \
@@ -1424,6 +1425,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
1424 return from_jiffies + msecs_to_jiffies(timeout_msecs); 1425 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1425} 1426}
1426 1427
1428/* Don't open code these in drivers as there are traps. Firstly the range may
1429 change in future hardware and specs, secondly 0xFF means 'no DMA' but is
1430 > UDMA_0. Dyma ddreigiau */
1431
1432static inline int ata_using_mwdma(struct ata_device *adev)
1433{
1434 if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
1435 return 1;
1436 return 0;
1437}
1438
1439static inline int ata_using_udma(struct ata_device *adev)
1440{
1441 if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
1442 return 1;
1443 return 0;
1444}
1445
1446static inline int ata_dma_enabled(struct ata_device *adev)
1447{
1448 return (adev->dma_mode == 0xFF ? 0 : 1);
1449}
1427 1450
1428/************************************************************************** 1451/**************************************************************************
1429 * PMP - drivers/ata/libata-pmp.c 1452 * PMP - drivers/ata/libata-pmp.c