aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-15 07:46:29 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-15 07:46:29 -0400
commitb2aaf8f74cdc84a9182f6cabf198b7763bcb9d40 (patch)
tree53ccb1c2c14751fe69cf93102e76e97021f6df07 /include/linux/libata.h
parent4f962d4d65923d7b722192e729840cfb79af0a5a (diff)
parent278429cff8809958d25415ba0ed32b59866ab1a8 (diff)
Merge branch 'linus' into stackprotector
Conflicts: arch/x86/kernel/Makefile include/asm-x86/pda.h
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h154
1 files changed, 106 insertions, 48 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index e57e5d08312..947cf84e555 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>
@@ -59,9 +60,9 @@
59 60
60/* note: prints function name for you */ 61/* note: prints function name for you */
61#ifdef ATA_DEBUG 62#ifdef ATA_DEBUG
62#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 63#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
63#ifdef ATA_VERBOSE_DEBUG 64#ifdef ATA_VERBOSE_DEBUG
64#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 65#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
65#else 66#else
66#define VPRINTK(fmt, args...) 67#define VPRINTK(fmt, args...)
67#endif /* ATA_VERBOSE_DEBUG */ 68#endif /* ATA_VERBOSE_DEBUG */
@@ -70,7 +71,7 @@
70#define VPRINTK(fmt, args...) 71#define VPRINTK(fmt, args...)
71#endif /* ATA_DEBUG */ 72#endif /* ATA_DEBUG */
72 73
73#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)
74 75
75/* NEW: debug levels */ 76/* NEW: debug levels */
76#define HAVE_LIBATA_MSG 1 77#define HAVE_LIBATA_MSG 1
@@ -115,7 +116,7 @@ enum {
115 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ 116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
116 ATA_MAX_QUEUE = 32, 117 ATA_MAX_QUEUE = 32,
117 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, 118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
118 ATA_SHORT_PAUSE = (HZ >> 6) + 1, 119 ATA_SHORT_PAUSE = 16,
119 120
120 ATAPI_MAX_DRAIN = 16 << 10, 121 ATAPI_MAX_DRAIN = 16 << 10,
121 122
@@ -145,6 +146,7 @@ enum {
145 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
146 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
147 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 */
148 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
149 151
150 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
@@ -162,12 +164,14 @@ enum {
162 ATA_DEV_NONE = 9, /* no device */ 164 ATA_DEV_NONE = 9, /* no device */
163 165
164 /* struct ata_link flags */ 166 /* struct ata_link flags */
167 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */
165 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ 168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */
166 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ 169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */
167 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ 170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */
168 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB, 171 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
169 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ 172 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */
170 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ 173 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */
174 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
171 175
172 /* struct ata_port flags */ 176 /* struct ata_port flags */
173 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 177 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
@@ -190,6 +194,10 @@ enum {
190 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 194 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
191 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 195 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
192 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ 196 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
197 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
198 * management */
199 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
200 * led */
193 201
194 /* The following flag belongs to ap->pflags but is kept in 202 /* The following flag belongs to ap->pflags but is kept in
195 * ap->flags because it's referenced in many LLDs and will be 203 * ap->flags because it's referenced in many LLDs and will be
@@ -234,17 +242,17 @@ enum {
234 /* bits 24:31 of host->flags are reserved for LLD specific flags */ 242 /* bits 24:31 of host->flags are reserved for LLD specific flags */
235 243
236 /* various lengths of time */ 244 /* various lengths of time */
237 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 245 ATA_TMOUT_BOOT = 30000, /* heuristic */
238 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ 246 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
239 ATA_TMOUT_INTERNAL = 30 * HZ, 247 ATA_TMOUT_INTERNAL_QUICK = 5000,
240 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, 248 ATA_TMOUT_MAX_PARK = 30000,
241 249
242 /* FIXME: GoVault needs 2s but we can't afford that without 250 /* FIXME: GoVault needs 2s but we can't afford that without
243 * parallel probing. 800ms is enough for iVDR disk 251 * parallel probing. 800ms is enough for iVDR disk
244 * HHD424020F7SV00. Increase to 2secs when parallel probing 252 * HHD424020F7SV00. Increase to 2secs when parallel probing
245 * is in place. 253 * is in place.
246 */ 254 */
247 ATA_TMOUT_FF_WAIT = 4 * HZ / 5, 255 ATA_TMOUT_FF_WAIT = 800,
248 256
249 /* Spec mandates to wait for ">= 2ms" before checking status 257 /* Spec mandates to wait for ">= 2ms" before checking status
250 * after reset. We wait 150ms, because that was the magic 258 * after reset. We wait 150ms, because that was the magic
@@ -256,14 +264,14 @@ enum {
256 * 264 *
257 * Old drivers/ide uses the 2mS rule and then waits for ready. 265 * Old drivers/ide uses the 2mS rule and then waits for ready.
258 */ 266 */
259 ATA_WAIT_AFTER_RESET_MSECS = 150, 267 ATA_WAIT_AFTER_RESET = 150,
260 268
261 /* If PMP is supported, we have to do follow-up SRST. As some 269 /* If PMP is supported, we have to do follow-up SRST. As some
262 * PMPs don't send D2H Reg FIS after hardreset, LLDs are 270 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
263 * advised to wait only for the following duration before 271 * advised to wait only for the following duration before
264 * doing SRST. 272 * doing SRST.
265 */ 273 */
266 ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ, 274 ATA_TMOUT_PMP_SRST_WAIT = 1000,
267 275
268 /* ATA bus states */ 276 /* ATA bus states */
269 BUS_UNKNOWN = 0, 277 BUS_UNKNOWN = 0,
@@ -313,8 +321,11 @@ enum {
313 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
314 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
315 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 */
316 325
317 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,
318 329
319 /* ata_eh_info->flags */ 330 /* ata_eh_info->flags */
320 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 331 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -340,6 +351,11 @@ enum {
340 351
341 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */ 352 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */
342 353
354 /* This should match the actual table size of
355 * ata_eh_cmd_timeout_table in libata-eh.c.
356 */
357 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 5,
358
343 /* Horkage types. May be set by libata or controller on drives 359 /* Horkage types. May be set by libata or controller on drives
344 (some horkage may be drive/controller pair dependant */ 360 (some horkage may be drive/controller pair dependant */
345 361
@@ -441,6 +457,16 @@ enum link_pm {
441 MEDIUM_POWER, 457 MEDIUM_POWER,
442}; 458};
443extern 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;
461extern struct device_attribute dev_attr_em_message_type;
462extern struct device_attribute dev_attr_em_message;
463extern struct device_attribute dev_attr_sw_activity;
464
465enum sw_activity {
466 OFF,
467 BLINK_ON,
468 BLINK_OFF,
469};
444 470
445#ifdef CONFIG_ATA_SFF 471#ifdef CONFIG_ATA_SFF
446struct ata_ioports { 472struct ata_ioports {
@@ -534,8 +560,8 @@ struct ata_ering {
534struct ata_device { 560struct ata_device {
535 struct ata_link *link; 561 struct ata_link *link;
536 unsigned int devno; /* 0 or 1 */ 562 unsigned int devno; /* 0 or 1 */
537 unsigned long flags; /* ATA_DFLAG_xxx */
538 unsigned int horkage; /* List of broken features */ 563 unsigned int horkage; /* List of broken features */
564 unsigned long flags; /* ATA_DFLAG_xxx */
539 struct scsi_device *sdev; /* attached SCSI device */ 565 struct scsi_device *sdev; /* attached SCSI device */
540#ifdef CONFIG_ATA_ACPI 566#ifdef CONFIG_ATA_ACPI
541 acpi_handle acpi_handle; 567 acpi_handle acpi_handle;
@@ -544,6 +570,7 @@ struct ata_device {
544 /* 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 */
545 u64 n_sectors; /* size of device, if ATA */ 571 u64 n_sectors; /* size of device, if ATA */
546 unsigned int class; /* ATA_DEV_xxx */ 572 unsigned int class; /* ATA_DEV_xxx */
573 unsigned long unpark_deadline;
547 574
548 u8 pio_mode; 575 u8 pio_mode;
549 u8 dma_mode; 576 u8 dma_mode;
@@ -597,10 +624,15 @@ struct ata_eh_info {
597struct ata_eh_context { 624struct ata_eh_context {
598 struct ata_eh_info i; 625 struct ata_eh_info i;
599 int tries[ATA_MAX_DEVICES]; 626 int tries[ATA_MAX_DEVICES];
627 int cmd_timeout_idx[ATA_MAX_DEVICES]
628 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
600 unsigned int classes[ATA_MAX_DEVICES]; 629 unsigned int classes[ATA_MAX_DEVICES];
601 unsigned int did_probe_mask; 630 unsigned int did_probe_mask;
631 unsigned int unloaded_mask;
602 unsigned int saved_ncq_enabled; 632 unsigned int saved_ncq_enabled;
603 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 633 u8 saved_xfer_mode[ATA_MAX_DEVICES];
634 /* timestamp for the last reset attempt or success */
635 unsigned long last_reset;
604}; 636};
605 637
606struct ata_acpi_drive 638struct ata_acpi_drive
@@ -623,6 +655,7 @@ struct ata_link {
623 655
624 unsigned int flags; /* ATA_LFLAG_xxx */ 656 unsigned int flags; /* ATA_LFLAG_xxx */
625 657
658 u32 saved_scontrol; /* SControl on probe */
626 unsigned int hw_sata_spd_limit; 659 unsigned int hw_sata_spd_limit;
627 unsigned int sata_spd_limit; 660 unsigned int sata_spd_limit;
628 unsigned int sata_spd; /* current SATA PHY speed */ 661 unsigned int sata_spd; /* current SATA PHY speed */
@@ -663,7 +696,8 @@ struct ata_port {
663 unsigned int qc_active; 696 unsigned int qc_active;
664 int nr_active_links; /* #links with active qcs */ 697 int nr_active_links; /* #links with active qcs */
665 698
666 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() */
667 701
668 int nr_pmp_links; /* nr of available PMP links */ 702 int nr_pmp_links; /* nr of available PMP links */
669 struct ata_link *pmp_link; /* array of PMP links */ 703 struct ata_link *pmp_link; /* array of PMP links */
@@ -684,6 +718,7 @@ struct ata_port {
684 struct list_head eh_done_q; 718 struct list_head eh_done_q;
685 wait_queue_head_t eh_wait_q; 719 wait_queue_head_t eh_wait_q;
686 int eh_tries; 720 int eh_tries;
721 struct completion park_req_pending;
687 722
688 pm_message_t pm_mesg; 723 pm_message_t pm_mesg;
689 int *pm_result; 724 int *pm_result;
@@ -692,6 +727,7 @@ struct ata_port {
692 struct timer_list fastdrain_timer; 727 struct timer_list fastdrain_timer;
693 unsigned long fastdrain_cnt; 728 unsigned long fastdrain_cnt;
694 729
730 int em_message_type;
695 void *private_data; 731 void *private_data;
696 732
697#ifdef CONFIG_ATA_ACPI 733#ifdef CONFIG_ATA_ACPI
@@ -726,6 +762,7 @@ struct ata_port_operations {
726 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); 762 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
727 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); 763 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
728 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);
729 766
730 void (*dev_config)(struct ata_device *dev); 767 void (*dev_config)(struct ata_device *dev);
731 768
@@ -745,8 +782,8 @@ struct ata_port_operations {
745 /* 782 /*
746 * Optional features 783 * Optional features
747 */ 784 */
748 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);
749 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);
750 void (*pmp_attach)(struct ata_port *ap); 787 void (*pmp_attach)(struct ata_port *ap);
751 void (*pmp_detach)(struct ata_port *ap); 788 void (*pmp_detach)(struct ata_port *ap);
752 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 789 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -783,6 +820,12 @@ struct ata_port_operations {
783 u8 (*bmdma_status)(struct ata_port *ap); 820 u8 (*bmdma_status)(struct ata_port *ap);
784#endif /* CONFIG_ATA_SFF */ 821#endif /* CONFIG_ATA_SFF */
785 822
823 ssize_t (*em_show)(struct ata_port *ap, char *buf);
824 ssize_t (*em_store)(struct ata_port *ap, const char *message,
825 size_t size);
826 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
827 ssize_t (*sw_activity_store)(struct ata_device *dev,
828 enum sw_activity val);
786 /* 829 /*
787 * Obsolete 830 * Obsolete
788 */ 831 */
@@ -862,6 +905,7 @@ extern void ata_port_disable(struct ata_port *);
862extern 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);
863extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 906extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
864 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);
865extern int ata_host_start(struct ata_host *host); 909extern int ata_host_start(struct ata_host *host);
866extern int ata_host_register(struct ata_host *host, 910extern int ata_host_register(struct ata_host *host,
867 struct scsi_host_template *sht); 911 struct scsi_host_template *sht);
@@ -887,16 +931,15 @@ extern int sata_scr_valid(struct ata_link *link);
887extern 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);
888extern 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);
889extern 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);
890extern int ata_link_online(struct ata_link *link); 934extern bool ata_link_online(struct ata_link *link);
891extern int ata_link_offline(struct ata_link *link); 935extern bool ata_link_offline(struct ata_link *link);
892#ifdef CONFIG_PM 936#ifdef CONFIG_PM
893extern 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);
894extern void ata_host_resume(struct ata_host *host); 938extern void ata_host_resume(struct ata_host *host);
895#endif 939#endif
896extern int ata_ratelimit(void); 940extern int ata_ratelimit(void);
897extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 941extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
898 unsigned long interval_msec, 942 unsigned long interval, unsigned long timeout);
899 unsigned long timeout_msec);
900extern int atapi_cmd_type(u8 opcode); 943extern int atapi_cmd_type(u8 opcode);
901extern void ata_tf_to_fis(const struct ata_taskfile *tf, 944extern void ata_tf_to_fis(const struct ata_taskfile *tf,
902 u8 pmp, int is_cmd, u8 *fis); 945 u8 pmp, int is_cmd, u8 *fis);
@@ -922,6 +965,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
922 unsigned int ofs, unsigned int len); 965 unsigned int ofs, unsigned int len);
923extern void ata_id_c_string(const u16 *id, unsigned char *s, 966extern void ata_id_c_string(const u16 *id, unsigned char *s,
924 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);
925extern void ata_qc_complete(struct ata_queued_cmd *qc); 970extern void ata_qc_complete(struct ata_queued_cmd *qc);
926extern 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);
927extern 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,
@@ -1064,6 +1109,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1064 */ 1109 */
1065extern const struct ata_port_operations ata_base_port_ops; 1110extern const struct ata_port_operations ata_base_port_ops;
1066extern 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[];
1067 1113
1068#define ATA_BASE_SHT(drv_name) \ 1114#define ATA_BASE_SHT(drv_name) \
1069 .module = THIS_MODULE, \ 1115 .module = THIS_MODULE, \
@@ -1078,7 +1124,8 @@ extern const struct ata_port_operations sata_port_ops;
1078 .proc_name = drv_name, \ 1124 .proc_name = drv_name, \
1079 .slave_configure = ata_scsi_slave_config, \ 1125 .slave_configure = ata_scsi_slave_config, \
1080 .slave_destroy = ata_scsi_slave_destroy, \ 1126 .slave_destroy = ata_scsi_slave_destroy, \
1081 .bios_param = ata_std_bios_param 1127 .bios_param = ata_std_bios_param, \
1128 .sdev_attrs = ata_common_sdev_attrs
1082 1129
1083#define ATA_NCQ_SHT(drv_name) \ 1130#define ATA_NCQ_SHT(drv_name) \
1084 ATA_BASE_SHT(drv_name), \ 1131 ATA_BASE_SHT(drv_name), \
@@ -1100,7 +1147,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1100 1147
1101static inline int ata_is_host_link(const struct ata_link *link) 1148static inline int ata_is_host_link(const struct ata_link *link)
1102{ 1149{
1103 return link == &link->ap->link; 1150 return link == &link->ap->link || link == link->ap->slave_link;
1104} 1151}
1105#else /* CONFIG_SATA_PMP */ 1152#else /* CONFIG_SATA_PMP */
1106static inline bool sata_pmp_supported(struct ata_port *ap) 1153static inline bool sata_pmp_supported(struct ata_port *ap)
@@ -1133,7 +1180,7 @@ static inline int sata_srst_pmp(struct ata_link *link)
1133 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1180 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1134 1181
1135#define ata_link_printk(link, lv, fmt, args...) do { \ 1182#define ata_link_printk(link, lv, fmt, args...) do { \
1136 if (sata_pmp_attached((link)->ap)) \ 1183 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1137 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1184 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1138 (link)->pmp , ##args); \ 1185 (link)->pmp , ##args); \
1139 else \ 1186 else \
@@ -1231,34 +1278,17 @@ static inline int ata_link_active(struct ata_link *link)
1231 return ata_tag_valid(link->active_tag) || link->sactive; 1278 return ata_tag_valid(link->active_tag) || link->sactive;
1232} 1279}
1233 1280
1234static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1281extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1235{ 1282 struct ata_link *link,
1236 if (sata_pmp_attached(ap)) 1283 bool dev_only);
1237 return ap->pmp_link;
1238 return &ap->link;
1239}
1240 1284
1241static inline struct ata_link *ata_port_next_link(struct ata_link *link) 1285#define __ata_port_for_each_link(link, ap) \
1242{ 1286 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1243 struct ata_port *ap = link->ap; 1287 (link) = __ata_port_next_link((ap), (link), false))
1244
1245 if (ata_is_host_link(link)) {
1246 if (!sata_pmp_attached(ap))
1247 return NULL;
1248 return ap->pmp_link;
1249 }
1250
1251 if (++link < ap->nr_pmp_links + ap->pmp_link)
1252 return link;
1253 return NULL;
1254}
1255
1256#define __ata_port_for_each_link(lk, ap) \
1257 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk))
1258 1288
1259#define ata_port_for_each_link(link, ap) \ 1289#define ata_port_for_each_link(link, ap) \
1260 for ((link) = ata_port_first_link(ap); (link); \ 1290 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1261 (link) = ata_port_next_link(link)) 1291 (link) = __ata_port_next_link((ap), (link), true))
1262 1292
1263#define ata_link_for_each_dev(dev, link) \ 1293#define ata_link_for_each_dev(dev, link) \
1264 for ((dev) = (link)->device; \ 1294 for ((dev) = (link)->device; \
@@ -1389,6 +1419,34 @@ static inline int ata_check_ready(u8 status)
1389 return 0; 1419 return 0;
1390} 1420}
1391 1421
1422static inline unsigned long ata_deadline(unsigned long from_jiffies,
1423 unsigned long timeout_msecs)
1424{
1425 return from_jiffies + msecs_to_jiffies(timeout_msecs);
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}
1392 1450
1393/************************************************************************** 1451/**************************************************************************
1394 * PMP - drivers/ata/libata-pmp.c 1452 * PMP - drivers/ata/libata-pmp.c