diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 18:58:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 18:58:44 -0400 |
commit | 6edad161cd4dfe1df772e7a74ab63cab53b5e8c1 (patch) | |
tree | 389d6daa728b2ba1bd8c2180cab705706449f62a /include/linux | |
parent | 236ee8c33277ab48671995f26dc68a4639936418 (diff) | |
parent | 0dd4b21f517e138ea113db255645fbae1bf5eef3 (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev: (258 commits)
[libata] conversion to new debug scheme, part 1 of $N
[PATCH] libata: Add ata_scsi_dev_disabled
[libata] Add host lock to struct ata_port
[PATCH] libata: implement per-dev EH action mask eh_info->dev_action[]
[PATCH] libata-dev: move the CDB-intr DMA blacklisting
[PATCH] ahci: disable NCQ support on vt8251
[libata] ahci: add JMicron PCI IDs
[libata] sata_nv: add PCI IDs
[libata] ahci: Add NVIDIA PCI IDs.
[PATCH] libata: convert several bmdma-style controllers to new EH, take #3
[PATCH] sata_via: convert to new EH, take #3
[libata] sata_nv: s/spin_lock_irqsave/spin_lock/ in irq handler
[PATCH] sata_nv: add hotplug support
[PATCH] sata_nv: convert to new EH
[PATCH] sata_nv: better irq handlers
[PATCH] sata_nv: simplify constants
[PATCH] sata_nv: kill struct nv_host_desc and nv_host
[PATCH] sata_nv: kill not-working hotplug code
[libata] Update docs to reflect current driver API
[PATCH] libata: add host_set->next for legacy two host_sets case, take #3
...
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/ata.h | 37 | ||||
-rw-r--r-- | include/linux/libata.h | 473 | ||||
-rw-r--r-- | include/linux/pci_ids.h | 9 |
3 files changed, 391 insertions, 128 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 312a2c0c64e6..3671af869696 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -97,6 +97,9 @@ enum { | |||
97 | ATA_DRQ = (1 << 3), /* data request i/o */ | 97 | ATA_DRQ = (1 << 3), /* data request i/o */ |
98 | ATA_ERR = (1 << 0), /* have an error */ | 98 | ATA_ERR = (1 << 0), /* have an error */ |
99 | ATA_SRST = (1 << 2), /* software reset */ | 99 | ATA_SRST = (1 << 2), /* software reset */ |
100 | ATA_ICRC = (1 << 7), /* interface CRC error */ | ||
101 | ATA_UNC = (1 << 6), /* uncorrectable media error */ | ||
102 | ATA_IDNF = (1 << 4), /* ID not found */ | ||
100 | ATA_ABORTED = (1 << 2), /* command aborted */ | 103 | ATA_ABORTED = (1 << 2), /* command aborted */ |
101 | 104 | ||
102 | /* ATA command block registers */ | 105 | /* ATA command block registers */ |
@@ -130,6 +133,8 @@ enum { | |||
130 | ATA_CMD_WRITE = 0xCA, | 133 | ATA_CMD_WRITE = 0xCA, |
131 | ATA_CMD_WRITE_EXT = 0x35, | 134 | ATA_CMD_WRITE_EXT = 0x35, |
132 | ATA_CMD_WRITE_FUA_EXT = 0x3D, | 135 | ATA_CMD_WRITE_FUA_EXT = 0x3D, |
136 | ATA_CMD_FPDMA_READ = 0x60, | ||
137 | ATA_CMD_FPDMA_WRITE = 0x61, | ||
133 | ATA_CMD_PIO_READ = 0x20, | 138 | ATA_CMD_PIO_READ = 0x20, |
134 | ATA_CMD_PIO_READ_EXT = 0x24, | 139 | ATA_CMD_PIO_READ_EXT = 0x24, |
135 | ATA_CMD_PIO_WRITE = 0x30, | 140 | ATA_CMD_PIO_WRITE = 0x30, |
@@ -148,6 +153,10 @@ enum { | |||
148 | ATA_CMD_INIT_DEV_PARAMS = 0x91, | 153 | ATA_CMD_INIT_DEV_PARAMS = 0x91, |
149 | ATA_CMD_READ_NATIVE_MAX = 0xF8, | 154 | ATA_CMD_READ_NATIVE_MAX = 0xF8, |
150 | ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, | 155 | ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, |
156 | ATA_CMD_READ_LOG_EXT = 0x2f, | ||
157 | |||
158 | /* READ_LOG_EXT pages */ | ||
159 | ATA_LOG_SATA_NCQ = 0x10, | ||
151 | 160 | ||
152 | /* SETFEATURES stuff */ | 161 | /* SETFEATURES stuff */ |
153 | SETFEATURES_XFER = 0x03, | 162 | SETFEATURES_XFER = 0x03, |
@@ -172,6 +181,9 @@ enum { | |||
172 | XFER_PIO_0 = 0x08, | 181 | XFER_PIO_0 = 0x08, |
173 | XFER_PIO_SLOW = 0x00, | 182 | XFER_PIO_SLOW = 0x00, |
174 | 183 | ||
184 | SETFEATURES_WC_ON = 0x02, /* Enable write cache */ | ||
185 | SETFEATURES_WC_OFF = 0x82, /* Disable write cache */ | ||
186 | |||
175 | /* ATAPI stuff */ | 187 | /* ATAPI stuff */ |
176 | ATAPI_PKT_DMA = (1 << 0), | 188 | ATAPI_PKT_DMA = (1 << 0), |
177 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: | 189 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: |
@@ -192,6 +204,16 @@ enum { | |||
192 | SCR_ACTIVE = 3, | 204 | SCR_ACTIVE = 3, |
193 | SCR_NOTIFICATION = 4, | 205 | SCR_NOTIFICATION = 4, |
194 | 206 | ||
207 | /* SError bits */ | ||
208 | SERR_DATA_RECOVERED = (1 << 0), /* recovered data error */ | ||
209 | SERR_COMM_RECOVERED = (1 << 1), /* recovered comm failure */ | ||
210 | SERR_DATA = (1 << 8), /* unrecovered data error */ | ||
211 | SERR_PERSISTENT = (1 << 9), /* persistent data/comm error */ | ||
212 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ | ||
213 | SERR_INTERNAL = (1 << 11), /* host internal error */ | ||
214 | SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */ | ||
215 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ | ||
216 | |||
195 | /* struct ata_taskfile flags */ | 217 | /* struct ata_taskfile flags */ |
196 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ | 218 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ |
197 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ | 219 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ |
@@ -199,6 +221,7 @@ enum { | |||
199 | ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ | 221 | ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ |
200 | ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ | 222 | ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ |
201 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ | 223 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ |
224 | ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ | ||
202 | }; | 225 | }; |
203 | 226 | ||
204 | enum ata_tf_protocols { | 227 | enum ata_tf_protocols { |
@@ -207,6 +230,7 @@ enum ata_tf_protocols { | |||
207 | ATA_PROT_NODATA, /* no data */ | 230 | ATA_PROT_NODATA, /* no data */ |
208 | ATA_PROT_PIO, /* PIO single sector */ | 231 | ATA_PROT_PIO, /* PIO single sector */ |
209 | ATA_PROT_DMA, /* DMA */ | 232 | ATA_PROT_DMA, /* DMA */ |
233 | ATA_PROT_NCQ, /* NCQ */ | ||
210 | ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ | 234 | ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ |
211 | ATA_PROT_ATAPI_NODATA, /* packet command, no data */ | 235 | ATA_PROT_ATAPI_NODATA, /* packet command, no data */ |
212 | ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */ | 236 | ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */ |
@@ -262,6 +286,8 @@ struct ata_taskfile { | |||
262 | #define ata_id_has_pm(id) ((id)[82] & (1 << 3)) | 286 | #define ata_id_has_pm(id) ((id)[82] & (1 << 3)) |
263 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) | 287 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) |
264 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) | 288 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) |
289 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) | ||
290 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) | ||
265 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) | 291 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) |
266 | #define ata_id_has_dword_io(id) ((id)[50] & (1 << 0)) | 292 | #define ata_id_has_dword_io(id) ((id)[50] & (1 << 0)) |
267 | #define ata_id_u32(id,n) \ | 293 | #define ata_id_u32(id,n) \ |
@@ -272,6 +298,8 @@ struct ata_taskfile { | |||
272 | ((u64) (id)[(n) + 1] << 16) | \ | 298 | ((u64) (id)[(n) + 1] << 16) | \ |
273 | ((u64) (id)[(n) + 0]) ) | 299 | ((u64) (id)[(n) + 0]) ) |
274 | 300 | ||
301 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) | ||
302 | |||
275 | static inline unsigned int ata_id_major_version(const u16 *id) | 303 | static inline unsigned int ata_id_major_version(const u16 *id) |
276 | { | 304 | { |
277 | unsigned int mver; | 305 | unsigned int mver; |
@@ -311,6 +339,15 @@ static inline int is_atapi_taskfile(const struct ata_taskfile *tf) | |||
311 | (tf->protocol == ATA_PROT_ATAPI_DMA); | 339 | (tf->protocol == ATA_PROT_ATAPI_DMA); |
312 | } | 340 | } |
313 | 341 | ||
342 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | ||
343 | { | ||
344 | return (tf->command == ATA_CMD_READ_MULTI) || | ||
345 | (tf->command == ATA_CMD_WRITE_MULTI) || | ||
346 | (tf->command == ATA_CMD_READ_MULTI_EXT) || | ||
347 | (tf->command == ATA_CMD_WRITE_MULTI_EXT) || | ||
348 | (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); | ||
349 | } | ||
350 | |||
314 | static inline int ata_ok(u8 status) | 351 | static inline int ata_ok(u8 status) |
315 | { | 352 | { |
316 | return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) | 353 | return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) |
diff --git a/include/linux/libata.h b/include/linux/libata.h index b80d2e7fa6d2..20b1cf527c60 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <linux/ata.h> | 34 | #include <linux/ata.h> |
35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
36 | #include <scsi/scsi_host.h> | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * compile-time options: to be removed as soon as all the drivers are | 39 | * compile-time options: to be removed as soon as all the drivers are |
@@ -44,7 +45,6 @@ | |||
44 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ | 45 | #undef ATA_NDEBUG /* define to disable quick runtime checks */ |
45 | #undef ATA_ENABLE_PATA /* define to enable PATA support in some | 46 | #undef ATA_ENABLE_PATA /* define to enable PATA support in some |
46 | * low-level drivers */ | 47 | * low-level drivers */ |
47 | #undef ATAPI_ENABLE_DMADIR /* enables ATAPI DMADIR bridge support */ | ||
48 | 48 | ||
49 | 49 | ||
50 | /* note: prints function name for you */ | 50 | /* note: prints function name for you */ |
@@ -108,8 +108,11 @@ enum { | |||
108 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, | 108 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, |
109 | ATA_MAX_PORTS = 8, | 109 | ATA_MAX_PORTS = 8, |
110 | ATA_DEF_QUEUE = 1, | 110 | ATA_DEF_QUEUE = 1, |
111 | ATA_MAX_QUEUE = 1, | 111 | /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ |
112 | ATA_MAX_QUEUE = 32, | ||
113 | ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, | ||
112 | ATA_MAX_SECTORS = 200, /* FIXME */ | 114 | ATA_MAX_SECTORS = 200, /* FIXME */ |
115 | ATA_MAX_SECTORS_LBA48 = 65535, | ||
113 | ATA_MAX_BUS = 2, | 116 | ATA_MAX_BUS = 2, |
114 | ATA_DEF_BUSY_WAIT = 10000, | 117 | ATA_DEF_BUSY_WAIT = 10000, |
115 | ATA_SHORT_PAUSE = (HZ >> 6) + 1, | 118 | ATA_SHORT_PAUSE = (HZ >> 6) + 1, |
@@ -120,9 +123,17 @@ enum { | |||
120 | ATA_SHT_USE_CLUSTERING = 1, | 123 | ATA_SHT_USE_CLUSTERING = 1, |
121 | 124 | ||
122 | /* struct ata_device stuff */ | 125 | /* struct ata_device stuff */ |
123 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ | 126 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ |
124 | ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ | 127 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ |
125 | ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */ | 128 | ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */ |
129 | ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */ | ||
130 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, | ||
131 | |||
132 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ | ||
133 | ATA_DFLAG_INIT_MASK = (1 << 16) - 1, | ||
134 | |||
135 | ATA_DFLAG_DETACH = (1 << 16), | ||
136 | ATA_DFLAG_DETACHED = (1 << 17), | ||
126 | 137 | ||
127 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 138 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
128 | ATA_DEV_ATA = 1, /* ATA device */ | 139 | ATA_DEV_ATA = 1, /* ATA device */ |
@@ -132,43 +143,57 @@ enum { | |||
132 | ATA_DEV_NONE = 5, /* no device */ | 143 | ATA_DEV_NONE = 5, /* no device */ |
133 | 144 | ||
134 | /* struct ata_port flags */ | 145 | /* struct ata_port flags */ |
135 | ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */ | 146 | ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ |
136 | /* (doesn't imply presence) */ | 147 | /* (doesn't imply presence) */ |
137 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 148 | ATA_FLAG_SATA = (1 << 1), |
138 | ATA_FLAG_SATA = (1 << 3), | 149 | ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */ |
139 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 150 | ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */ |
140 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ | 151 | ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */ |
141 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 152 | ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */ |
142 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ | 153 | ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ |
143 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 154 | ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ |
144 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 155 | ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ |
145 | * proper HSM is in place. */ | 156 | ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD |
146 | ATA_FLAG_DEBUGMSG = (1 << 10), | 157 | * doesn't handle PIO interrupts */ |
147 | ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */ | 158 | ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */ |
148 | 159 | ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */ | |
149 | ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */ | 160 | ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H |
150 | 161 | * Register FIS clearing BSY */ | |
151 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 162 | |
152 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 163 | ATA_FLAG_DEBUGMSG = (1 << 13), |
153 | 164 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 14), /* flush port task */ | |
154 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */ | 165 | |
155 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | 166 | ATA_FLAG_EH_PENDING = (1 << 15), /* EH pending */ |
156 | 167 | ATA_FLAG_EH_IN_PROGRESS = (1 << 16), /* EH in progress */ | |
157 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 168 | ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */ |
158 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 169 | ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */ |
159 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 170 | ATA_FLAG_LOADING = (1 << 19), /* boot/loading probe */ |
171 | ATA_FLAG_UNLOADING = (1 << 20), /* module is unloading */ | ||
172 | ATA_FLAG_SCSI_HOTPLUG = (1 << 21), /* SCSI hotplug scheduled */ | ||
173 | |||
174 | ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */ | ||
175 | ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */ | ||
176 | |||
177 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ | ||
178 | |||
179 | /* struct ata_queued_cmd flags */ | ||
180 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ | ||
181 | ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ | ||
182 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | ||
160 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 183 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
161 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | 184 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
185 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ | ||
186 | |||
187 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ | ||
188 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ | ||
189 | ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */ | ||
162 | 190 | ||
163 | /* host set flags */ | 191 | /* host set flags */ |
164 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ | 192 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ |
165 | 193 | ||
166 | /* various lengths of time */ | 194 | /* various lengths of time */ |
167 | ATA_TMOUT_PIO = 30 * HZ, | ||
168 | ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ | 195 | ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ |
169 | ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ | 196 | ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ |
170 | ATA_TMOUT_CDB = 30 * HZ, | ||
171 | ATA_TMOUT_CDB_QUICK = 5 * HZ, | ||
172 | ATA_TMOUT_INTERNAL = 30 * HZ, | 197 | ATA_TMOUT_INTERNAL = 30 * HZ, |
173 | ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, | 198 | ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, |
174 | 199 | ||
@@ -207,21 +232,56 @@ enum { | |||
207 | /* size of buffer to pad xfers ending on unaligned boundaries */ | 232 | /* size of buffer to pad xfers ending on unaligned boundaries */ |
208 | ATA_DMA_PAD_SZ = 4, | 233 | ATA_DMA_PAD_SZ = 4, |
209 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, | 234 | ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, |
210 | 235 | ||
211 | /* Masks for port functions */ | 236 | /* masks for port functions */ |
212 | ATA_PORT_PRIMARY = (1 << 0), | 237 | ATA_PORT_PRIMARY = (1 << 0), |
213 | ATA_PORT_SECONDARY = (1 << 1), | 238 | ATA_PORT_SECONDARY = (1 << 1), |
239 | |||
240 | /* ering size */ | ||
241 | ATA_ERING_SIZE = 32, | ||
242 | |||
243 | /* desc_len for ata_eh_info and context */ | ||
244 | ATA_EH_DESC_LEN = 80, | ||
245 | |||
246 | /* reset / recovery action types */ | ||
247 | ATA_EH_REVALIDATE = (1 << 0), | ||
248 | ATA_EH_SOFTRESET = (1 << 1), | ||
249 | ATA_EH_HARDRESET = (1 << 2), | ||
250 | |||
251 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | ||
252 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, | ||
253 | |||
254 | /* ata_eh_info->flags */ | ||
255 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ | ||
256 | |||
257 | ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */ | ||
258 | |||
259 | /* max repeat if error condition is still set after ->error_handler */ | ||
260 | ATA_EH_MAX_REPEAT = 5, | ||
261 | |||
262 | /* how hard are we gonna try to probe/recover devices */ | ||
263 | ATA_PROBE_MAX_TRIES = 3, | ||
264 | ATA_EH_RESET_TRIES = 3, | ||
265 | ATA_EH_DEV_TRIES = 3, | ||
266 | |||
267 | /* Drive spinup time (time from power-on to the first D2H FIS) | ||
268 | * in msecs - 8s currently. Failing to get ready in this time | ||
269 | * isn't critical. It will result in reset failure for | ||
270 | * controllers which can't wait for the first D2H FIS. libata | ||
271 | * will retry, so it just has to be long enough to spin up | ||
272 | * most devices. | ||
273 | */ | ||
274 | ATA_SPINUP_WAIT = 8000, | ||
214 | }; | 275 | }; |
215 | 276 | ||
216 | enum hsm_task_states { | 277 | enum hsm_task_states { |
217 | HSM_ST_UNKNOWN, | 278 | HSM_ST_UNKNOWN, /* state unknown */ |
218 | HSM_ST_IDLE, | 279 | HSM_ST_IDLE, /* no command on going */ |
219 | HSM_ST_POLL, | 280 | HSM_ST, /* (waiting the device to) transfer data */ |
220 | HSM_ST_TMOUT, | 281 | HSM_ST_LAST, /* (waiting the device to) complete command */ |
221 | HSM_ST, | 282 | HSM_ST_ERR, /* error */ |
222 | HSM_ST_LAST, | 283 | HSM_ST_FIRST, /* (waiting the device to) |
223 | HSM_ST_LAST_POLL, | 284 | write CDB or first data block */ |
224 | HSM_ST_ERR, | ||
225 | }; | 285 | }; |
226 | 286 | ||
227 | enum ata_completion_errors { | 287 | enum ata_completion_errors { |
@@ -244,9 +304,9 @@ struct ata_queued_cmd; | |||
244 | 304 | ||
245 | /* typedefs */ | 305 | /* typedefs */ |
246 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 306 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
247 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | 307 | typedef int (*ata_prereset_fn_t)(struct ata_port *ap); |
248 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | 308 | typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes); |
249 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | 309 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); |
250 | 310 | ||
251 | struct ata_ioports { | 311 | struct ata_ioports { |
252 | unsigned long cmd_addr; | 312 | unsigned long cmd_addr; |
@@ -297,7 +357,8 @@ struct ata_host_set { | |||
297 | unsigned long flags; | 357 | unsigned long flags; |
298 | int simplex_claimed; /* Keep seperate in case we | 358 | int simplex_claimed; /* Keep seperate in case we |
299 | ever need to do this locked */ | 359 | ever need to do this locked */ |
300 | struct ata_port * ports[0]; | 360 | struct ata_host_set *next; /* for legacy mode */ |
361 | struct ata_port *ports[0]; | ||
301 | }; | 362 | }; |
302 | 363 | ||
303 | struct ata_queued_cmd { | 364 | struct ata_queued_cmd { |
@@ -336,7 +397,7 @@ struct ata_queued_cmd { | |||
336 | struct scatterlist *__sg; | 397 | struct scatterlist *__sg; |
337 | 398 | ||
338 | unsigned int err_mask; | 399 | unsigned int err_mask; |
339 | 400 | struct ata_taskfile result_tf; | |
340 | ata_qc_cb_t complete_fn; | 401 | ata_qc_cb_t complete_fn; |
341 | 402 | ||
342 | void *private_data; | 403 | void *private_data; |
@@ -348,12 +409,26 @@ struct ata_host_stats { | |||
348 | unsigned long rw_reqbuf; | 409 | unsigned long rw_reqbuf; |
349 | }; | 410 | }; |
350 | 411 | ||
412 | struct ata_ering_entry { | ||
413 | int is_io; | ||
414 | unsigned int err_mask; | ||
415 | u64 timestamp; | ||
416 | }; | ||
417 | |||
418 | struct ata_ering { | ||
419 | int cursor; | ||
420 | struct ata_ering_entry ring[ATA_ERING_SIZE]; | ||
421 | }; | ||
422 | |||
351 | struct ata_device { | 423 | struct ata_device { |
352 | u64 n_sectors; /* size of device, if ATA */ | 424 | struct ata_port *ap; |
425 | unsigned int devno; /* 0 or 1 */ | ||
353 | unsigned long flags; /* ATA_DFLAG_xxx */ | 426 | unsigned long flags; /* ATA_DFLAG_xxx */ |
427 | struct scsi_device *sdev; /* attached SCSI device */ | ||
428 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ | ||
429 | u64 n_sectors; /* size of device, if ATA */ | ||
354 | unsigned int class; /* ATA_DEV_xxx */ | 430 | unsigned int class; /* ATA_DEV_xxx */ |
355 | unsigned int devno; /* 0 or 1 */ | 431 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ |
356 | u16 *id; /* IDENTIFY xxx DEVICE data */ | ||
357 | u8 pio_mode; | 432 | u8 pio_mode; |
358 | u8 dma_mode; | 433 | u8 dma_mode; |
359 | u8 xfer_mode; | 434 | u8 xfer_mode; |
@@ -373,11 +448,42 @@ struct ata_device { | |||
373 | u16 cylinders; /* Number of cylinders */ | 448 | u16 cylinders; /* Number of cylinders */ |
374 | u16 heads; /* Number of heads */ | 449 | u16 heads; /* Number of heads */ |
375 | u16 sectors; /* Number of sectors per track */ | 450 | u16 sectors; /* Number of sectors per track */ |
451 | |||
452 | /* error history */ | ||
453 | struct ata_ering ering; | ||
454 | }; | ||
455 | |||
456 | /* Offset into struct ata_device. Fields above it are maintained | ||
457 | * acress device init. Fields below are zeroed. | ||
458 | */ | ||
459 | #define ATA_DEVICE_CLEAR_OFFSET offsetof(struct ata_device, n_sectors) | ||
460 | |||
461 | struct ata_eh_info { | ||
462 | struct ata_device *dev; /* offending device */ | ||
463 | u32 serror; /* SError from LLDD */ | ||
464 | unsigned int err_mask; /* port-wide err_mask */ | ||
465 | unsigned int action; /* ATA_EH_* action mask */ | ||
466 | unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */ | ||
467 | unsigned int flags; /* ATA_EHI_* flags */ | ||
468 | |||
469 | unsigned long hotplug_timestamp; | ||
470 | unsigned int probe_mask; | ||
471 | |||
472 | char desc[ATA_EH_DESC_LEN]; | ||
473 | int desc_len; | ||
474 | }; | ||
475 | |||
476 | struct ata_eh_context { | ||
477 | struct ata_eh_info i; | ||
478 | int tries[ATA_MAX_DEVICES]; | ||
479 | unsigned int classes[ATA_MAX_DEVICES]; | ||
480 | unsigned int did_probe_mask; | ||
376 | }; | 481 | }; |
377 | 482 | ||
378 | struct ata_port { | 483 | struct ata_port { |
379 | struct Scsi_Host *host; /* our co-allocated scsi host */ | 484 | struct Scsi_Host *host; /* our co-allocated scsi host */ |
380 | const struct ata_port_operations *ops; | 485 | const struct ata_port_operations *ops; |
486 | spinlock_t *lock; | ||
381 | unsigned long flags; /* ATA_FLAG_xxx */ | 487 | unsigned long flags; /* ATA_FLAG_xxx */ |
382 | unsigned int id; /* unique id req'd by scsi midlyr */ | 488 | unsigned int id; /* unique id req'd by scsi midlyr */ |
383 | unsigned int port_no; /* unique port #; from zero */ | 489 | unsigned int port_no; /* unique port #; from zero */ |
@@ -397,26 +503,40 @@ struct ata_port { | |||
397 | unsigned int mwdma_mask; | 503 | unsigned int mwdma_mask; |
398 | unsigned int udma_mask; | 504 | unsigned int udma_mask; |
399 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 505 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
506 | unsigned int hw_sata_spd_limit; | ||
507 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | ||
508 | |||
509 | /* record runtime error info, protected by host_set lock */ | ||
510 | struct ata_eh_info eh_info; | ||
511 | /* EH context owned by EH */ | ||
512 | struct ata_eh_context eh_context; | ||
400 | 513 | ||
401 | struct ata_device device[ATA_MAX_DEVICES]; | 514 | struct ata_device device[ATA_MAX_DEVICES]; |
402 | 515 | ||
403 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; | 516 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; |
404 | unsigned long qactive; | 517 | unsigned long qc_allocated; |
518 | unsigned int qc_active; | ||
519 | |||
405 | unsigned int active_tag; | 520 | unsigned int active_tag; |
521 | u32 sactive; | ||
406 | 522 | ||
407 | struct ata_host_stats stats; | 523 | struct ata_host_stats stats; |
408 | struct ata_host_set *host_set; | 524 | struct ata_host_set *host_set; |
409 | struct device *dev; | 525 | struct device *dev; |
410 | 526 | ||
411 | struct work_struct port_task; | 527 | struct work_struct port_task; |
528 | struct work_struct hotplug_task; | ||
529 | struct work_struct scsi_rescan_task; | ||
412 | 530 | ||
413 | unsigned int hsm_task_state; | 531 | unsigned int hsm_task_state; |
414 | unsigned long pio_task_timeout; | ||
415 | 532 | ||
416 | u32 msg_enable; | 533 | u32 msg_enable; |
417 | struct list_head eh_done_q; | 534 | struct list_head eh_done_q; |
535 | wait_queue_head_t eh_wait_q; | ||
418 | 536 | ||
419 | void *private_data; | 537 | void *private_data; |
538 | |||
539 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | ||
420 | }; | 540 | }; |
421 | 541 | ||
422 | struct ata_port_operations { | 542 | struct ata_port_operations { |
@@ -438,7 +558,6 @@ struct ata_port_operations { | |||
438 | 558 | ||
439 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ | 559 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
440 | void (*set_mode) (struct ata_port *ap); | 560 | void (*set_mode) (struct ata_port *ap); |
441 | int (*probe_reset) (struct ata_port *ap, unsigned int *classes); | ||
442 | 561 | ||
443 | void (*post_set_mode) (struct ata_port *ap); | 562 | void (*post_set_mode) (struct ata_port *ap); |
444 | 563 | ||
@@ -447,10 +566,20 @@ struct ata_port_operations { | |||
447 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 566 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
448 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 567 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
449 | 568 | ||
569 | void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); | ||
570 | |||
450 | void (*qc_prep) (struct ata_queued_cmd *qc); | 571 | void (*qc_prep) (struct ata_queued_cmd *qc); |
451 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | 572 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
452 | 573 | ||
453 | void (*eng_timeout) (struct ata_port *ap); | 574 | /* Error handlers. ->error_handler overrides ->eng_timeout and |
575 | * indicates that new-style EH is in place. | ||
576 | */ | ||
577 | void (*eng_timeout) (struct ata_port *ap); /* obsolete */ | ||
578 | |||
579 | void (*freeze) (struct ata_port *ap); | ||
580 | void (*thaw) (struct ata_port *ap); | ||
581 | void (*error_handler) (struct ata_port *ap); | ||
582 | void (*post_internal_cmd) (struct ata_queued_cmd *qc); | ||
454 | 583 | ||
455 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 584 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
456 | void (*irq_clear) (struct ata_port *); | 585 | void (*irq_clear) (struct ata_port *); |
@@ -492,22 +621,22 @@ struct ata_timing { | |||
492 | 621 | ||
493 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | 622 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) |
494 | 623 | ||
624 | extern const unsigned long sata_deb_timing_boot[]; | ||
625 | extern const unsigned long sata_deb_timing_eh[]; | ||
626 | extern const unsigned long sata_deb_timing_before_fsrst[]; | ||
627 | |||
495 | extern void ata_port_probe(struct ata_port *); | 628 | extern void ata_port_probe(struct ata_port *); |
496 | extern void __sata_phy_reset(struct ata_port *ap); | 629 | extern void __sata_phy_reset(struct ata_port *ap); |
497 | extern void sata_phy_reset(struct ata_port *ap); | 630 | extern void sata_phy_reset(struct ata_port *ap); |
498 | extern void ata_bus_reset(struct ata_port *ap); | 631 | extern void ata_bus_reset(struct ata_port *ap); |
499 | extern int ata_drive_probe_reset(struct ata_port *ap, | 632 | extern int sata_set_spd(struct ata_port *ap); |
500 | ata_probeinit_fn_t probeinit, | 633 | extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param); |
501 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 634 | extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param); |
502 | ata_postreset_fn_t postreset, unsigned int *classes); | 635 | extern int ata_std_prereset(struct ata_port *ap); |
503 | extern void ata_std_probeinit(struct ata_port *ap); | 636 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
504 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | 637 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
505 | unsigned int *classes); | ||
506 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
507 | unsigned int *class); | ||
508 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 638 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
509 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 639 | extern int ata_dev_revalidate(struct ata_device *dev, int post_reset); |
510 | int post_reset); | ||
511 | extern void ata_port_disable(struct ata_port *); | 640 | extern void ata_port_disable(struct ata_port *); |
512 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 641 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
513 | #ifdef CONFIG_PCI | 642 | #ifdef CONFIG_PCI |
@@ -519,24 +648,32 @@ extern int ata_pci_device_resume(struct pci_dev *pdev); | |||
519 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | 648 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); |
520 | #endif /* CONFIG_PCI */ | 649 | #endif /* CONFIG_PCI */ |
521 | extern int ata_device_add(const struct ata_probe_ent *ent); | 650 | extern int ata_device_add(const struct ata_probe_ent *ent); |
651 | extern void ata_port_detach(struct ata_port *ap); | ||
522 | extern void ata_host_set_remove(struct ata_host_set *host_set); | 652 | extern void ata_host_set_remove(struct ata_host_set *host_set); |
523 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 653 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
524 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 654 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
525 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 655 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
526 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
527 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
528 | extern int ata_scsi_release(struct Scsi_Host *host); | 656 | extern int ata_scsi_release(struct Scsi_Host *host); |
529 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 657 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
658 | extern int sata_scr_valid(struct ata_port *ap); | ||
659 | extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); | ||
660 | extern int sata_scr_write(struct ata_port *ap, int reg, u32 val); | ||
661 | extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); | ||
662 | extern int ata_port_online(struct ata_port *ap); | ||
663 | extern int ata_port_offline(struct ata_port *ap); | ||
530 | extern int ata_scsi_device_resume(struct scsi_device *); | 664 | extern int ata_scsi_device_resume(struct scsi_device *); |
531 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 665 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
532 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 666 | extern int ata_device_resume(struct ata_device *); |
533 | extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state); | 667 | extern int ata_device_suspend(struct ata_device *, pm_message_t state); |
534 | extern int ata_ratelimit(void); | 668 | extern int ata_ratelimit(void); |
535 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 669 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
536 | unsigned long timeout_pat, | 670 | unsigned long timeout_pat, |
537 | unsigned long timeout); | 671 | unsigned long timeout); |
538 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), | 672 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), |
539 | void *data, unsigned long delay); | 673 | void *data, unsigned long delay); |
674 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | ||
675 | unsigned long interval_msec, | ||
676 | unsigned long timeout_msec); | ||
540 | 677 | ||
541 | /* | 678 | /* |
542 | * Default driver ops implementations | 679 | * Default driver ops implementations |
@@ -550,11 +687,16 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | |||
550 | extern u8 ata_check_status(struct ata_port *ap); | 687 | extern u8 ata_check_status(struct ata_port *ap); |
551 | extern u8 ata_altstatus(struct ata_port *ap); | 688 | extern u8 ata_altstatus(struct ata_port *ap); |
552 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 689 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
553 | extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes); | ||
554 | extern int ata_port_start (struct ata_port *ap); | 690 | extern int ata_port_start (struct ata_port *ap); |
555 | extern void ata_port_stop (struct ata_port *ap); | 691 | extern void ata_port_stop (struct ata_port *ap); |
556 | extern void ata_host_stop (struct ata_host_set *host_set); | 692 | extern void ata_host_stop (struct ata_host_set *host_set); |
557 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); | 693 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); |
694 | extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, | ||
695 | unsigned int buflen, int write_data); | ||
696 | extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, | ||
697 | unsigned int buflen, int write_data); | ||
698 | extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | ||
699 | unsigned int buflen, int write_data); | ||
558 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 700 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
559 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 701 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
560 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 702 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
@@ -572,17 +714,29 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); | |||
572 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 714 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
573 | extern u8 ata_bmdma_status(struct ata_port *ap); | 715 | extern u8 ata_bmdma_status(struct ata_port *ap); |
574 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 716 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
575 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 717 | extern void ata_bmdma_freeze(struct ata_port *ap); |
576 | extern void ata_eng_timeout(struct ata_port *ap); | 718 | extern void ata_bmdma_thaw(struct ata_port *ap); |
577 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 719 | extern void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset, |
578 | struct scsi_cmnd *cmd, | 720 | ata_reset_fn_t softreset, |
721 | ata_reset_fn_t hardreset, | ||
722 | ata_postreset_fn_t postreset); | ||
723 | extern void ata_bmdma_error_handler(struct ata_port *ap); | ||
724 | extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); | ||
725 | extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
726 | u8 status, int in_wq); | ||
727 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | ||
728 | extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, | ||
729 | void (*finish_qc)(struct ata_queued_cmd *)); | ||
730 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | ||
579 | void (*done)(struct scsi_cmnd *)); | 731 | void (*done)(struct scsi_cmnd *)); |
580 | extern int ata_std_bios_param(struct scsi_device *sdev, | 732 | extern int ata_std_bios_param(struct scsi_device *sdev, |
581 | struct block_device *bdev, | 733 | struct block_device *bdev, |
582 | sector_t capacity, int geom[]); | 734 | sector_t capacity, int geom[]); |
583 | extern int ata_scsi_slave_config(struct scsi_device *sdev); | 735 | extern int ata_scsi_slave_config(struct scsi_device *sdev); |
584 | extern struct ata_device *ata_dev_pair(struct ata_port *ap, | 736 | extern void ata_scsi_slave_destroy(struct scsi_device *sdev); |
585 | struct ata_device *adev); | 737 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, |
738 | int queue_depth); | ||
739 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | ||
586 | 740 | ||
587 | /* | 741 | /* |
588 | * Timing helpers | 742 | * Timing helpers |
@@ -628,7 +782,64 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
628 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); | 782 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); |
629 | #endif /* CONFIG_PCI */ | 783 | #endif /* CONFIG_PCI */ |
630 | 784 | ||
785 | /* | ||
786 | * EH | ||
787 | */ | ||
788 | extern void ata_eng_timeout(struct ata_port *ap); | ||
789 | |||
790 | extern void ata_port_schedule_eh(struct ata_port *ap); | ||
791 | extern int ata_port_abort(struct ata_port *ap); | ||
792 | extern int ata_port_freeze(struct ata_port *ap); | ||
793 | |||
794 | extern void ata_eh_freeze_port(struct ata_port *ap); | ||
795 | extern void ata_eh_thaw_port(struct ata_port *ap); | ||
796 | |||
797 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
798 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
799 | |||
800 | extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | ||
801 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
802 | ata_postreset_fn_t postreset); | ||
803 | |||
804 | /* | ||
805 | * printk helpers | ||
806 | */ | ||
807 | #define ata_port_printk(ap, lv, fmt, args...) \ | ||
808 | printk(lv"ata%u: "fmt, (ap)->id , ##args) | ||
809 | |||
810 | #define ata_dev_printk(dev, lv, fmt, args...) \ | ||
811 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) | ||
812 | |||
813 | /* | ||
814 | * ata_eh_info helpers | ||
815 | */ | ||
816 | #define ata_ehi_push_desc(ehi, fmt, args...) do { \ | ||
817 | (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \ | ||
818 | ATA_EH_DESC_LEN - (ehi)->desc_len, \ | ||
819 | fmt , ##args); \ | ||
820 | } while (0) | ||
821 | |||
822 | #define ata_ehi_clear_desc(ehi) do { \ | ||
823 | (ehi)->desc[0] = '\0'; \ | ||
824 | (ehi)->desc_len = 0; \ | ||
825 | } while (0) | ||
826 | |||
827 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | ||
828 | { | ||
829 | if (ehi->flags & ATA_EHI_HOTPLUGGED) | ||
830 | return; | ||
831 | |||
832 | ehi->flags |= ATA_EHI_HOTPLUGGED; | ||
833 | ehi->hotplug_timestamp = jiffies; | ||
631 | 834 | ||
835 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
836 | ehi->action |= ATA_EH_SOFTRESET; | ||
837 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; | ||
838 | } | ||
839 | |||
840 | /* | ||
841 | * qc helpers | ||
842 | */ | ||
632 | static inline int | 843 | static inline int |
633 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 844 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
634 | { | 845 | { |
@@ -671,14 +882,39 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
671 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 882 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
672 | } | 883 | } |
673 | 884 | ||
674 | static inline unsigned int ata_class_present(unsigned int class) | 885 | static inline unsigned int ata_tag_internal(unsigned int tag) |
886 | { | ||
887 | return tag == ATA_MAX_QUEUE - 1; | ||
888 | } | ||
889 | |||
890 | static inline unsigned int ata_class_enabled(unsigned int class) | ||
675 | { | 891 | { |
676 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 892 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
677 | } | 893 | } |
678 | 894 | ||
679 | static inline unsigned int ata_dev_present(const struct ata_device *dev) | 895 | static inline unsigned int ata_class_disabled(unsigned int class) |
680 | { | 896 | { |
681 | return ata_class_present(dev->class); | 897 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP; |
898 | } | ||
899 | |||
900 | static inline unsigned int ata_class_absent(unsigned int class) | ||
901 | { | ||
902 | return !ata_class_enabled(class) && !ata_class_disabled(class); | ||
903 | } | ||
904 | |||
905 | static inline unsigned int ata_dev_enabled(const struct ata_device *dev) | ||
906 | { | ||
907 | return ata_class_enabled(dev->class); | ||
908 | } | ||
909 | |||
910 | static inline unsigned int ata_dev_disabled(const struct ata_device *dev) | ||
911 | { | ||
912 | return ata_class_disabled(dev->class); | ||
913 | } | ||
914 | |||
915 | static inline unsigned int ata_dev_absent(const struct ata_device *dev) | ||
916 | { | ||
917 | return ata_class_absent(dev->class); | ||
682 | } | 918 | } |
683 | 919 | ||
684 | static inline u8 ata_chk_status(struct ata_port *ap) | 920 | static inline u8 ata_chk_status(struct ata_port *ap) |
@@ -759,20 +995,35 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | |||
759 | qc->tf.ctl |= ATA_NIEN; | 995 | qc->tf.ctl |= ATA_NIEN; |
760 | } | 996 | } |
761 | 997 | ||
762 | static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, | 998 | static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, |
763 | unsigned int tag) | 999 | unsigned int tag) |
764 | { | 1000 | { |
765 | if (likely(ata_tag_valid(tag))) | 1001 | if (likely(ata_tag_valid(tag))) |
766 | return &ap->qcmd[tag]; | 1002 | return &ap->qcmd[tag]; |
767 | return NULL; | 1003 | return NULL; |
768 | } | 1004 | } |
769 | 1005 | ||
770 | static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device) | 1006 | static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap, |
1007 | unsigned int tag) | ||
1008 | { | ||
1009 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
1010 | |||
1011 | if (unlikely(!qc) || !ap->ops->error_handler) | ||
1012 | return qc; | ||
1013 | |||
1014 | if ((qc->flags & (ATA_QCFLAG_ACTIVE | | ||
1015 | ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE) | ||
1016 | return qc; | ||
1017 | |||
1018 | return NULL; | ||
1019 | } | ||
1020 | |||
1021 | static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | ||
771 | { | 1022 | { |
772 | memset(tf, 0, sizeof(*tf)); | 1023 | memset(tf, 0, sizeof(*tf)); |
773 | 1024 | ||
774 | tf->ctl = ap->ctl; | 1025 | tf->ctl = dev->ap->ctl; |
775 | if (device == 0) | 1026 | if (dev->devno == 0) |
776 | tf->device = ATA_DEVICE_OBS; | 1027 | tf->device = ATA_DEVICE_OBS; |
777 | else | 1028 | else |
778 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 1029 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
@@ -787,26 +1038,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
787 | qc->nbytes = qc->curbytes = 0; | 1038 | qc->nbytes = qc->curbytes = 0; |
788 | qc->err_mask = 0; | 1039 | qc->err_mask = 0; |
789 | 1040 | ||
790 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | 1041 | ata_tf_init(qc->dev, &qc->tf); |
791 | } | ||
792 | |||
793 | /** | ||
794 | * ata_qc_complete - Complete an active ATA command | ||
795 | * @qc: Command to complete | ||
796 | * @err_mask: ATA Status register contents | ||
797 | * | ||
798 | * Indicate to the mid and upper layers that an ATA | ||
799 | * command has completed, with either an ok or not-ok status. | ||
800 | * | ||
801 | * LOCKING: | ||
802 | * spin_lock_irqsave(host_set lock) | ||
803 | */ | ||
804 | static inline void ata_qc_complete(struct ata_queued_cmd *qc) | ||
805 | { | ||
806 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
807 | return; | ||
808 | 1042 | ||
809 | __ata_qc_complete(qc); | 1043 | /* init result_tf such that it indicates normal completion */ |
1044 | qc->result_tf.command = ATA_DRDY; | ||
1045 | qc->result_tf.feature = 0; | ||
810 | } | 1046 | } |
811 | 1047 | ||
812 | /** | 1048 | /** |
@@ -885,28 +1121,6 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
885 | return status; | 1121 | return status; |
886 | } | 1122 | } |
887 | 1123 | ||
888 | static inline u32 scr_read(struct ata_port *ap, unsigned int reg) | ||
889 | { | ||
890 | return ap->ops->scr_read(ap, reg); | ||
891 | } | ||
892 | |||
893 | static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val) | ||
894 | { | ||
895 | ap->ops->scr_write(ap, reg, val); | ||
896 | } | ||
897 | |||
898 | static inline void scr_write_flush(struct ata_port *ap, unsigned int reg, | ||
899 | u32 val) | ||
900 | { | ||
901 | ap->ops->scr_write(ap, reg, val); | ||
902 | (void) ap->ops->scr_read(ap, reg); | ||
903 | } | ||
904 | |||
905 | static inline unsigned int sata_dev_present(struct ata_port *ap) | ||
906 | { | ||
907 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; | ||
908 | } | ||
909 | |||
910 | static inline int ata_try_flush_cache(const struct ata_device *dev) | 1124 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
911 | { | 1125 | { |
912 | return ata_id_wcache_enabled(dev->id) || | 1126 | return ata_id_wcache_enabled(dev->id) || |
@@ -916,7 +1130,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
916 | 1130 | ||
917 | static inline unsigned int ac_err_mask(u8 status) | 1131 | static inline unsigned int ac_err_mask(u8 status) |
918 | { | 1132 | { |
919 | if (status & ATA_BUSY) | 1133 | if (status & (ATA_BUSY | ATA_DRQ)) |
920 | return AC_ERR_HSM; | 1134 | return AC_ERR_HSM; |
921 | if (status & (ATA_ERR | ATA_DF)) | 1135 | if (status & (ATA_ERR | ATA_DF)) |
922 | return AC_ERR_DEV; | 1136 | return AC_ERR_DEV; |
@@ -944,4 +1158,9 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | |||
944 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); | 1158 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); |
945 | } | 1159 | } |
946 | 1160 | ||
1161 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | ||
1162 | { | ||
1163 | return (struct ata_port *) &host->hostdata[0]; | ||
1164 | } | ||
1165 | |||
947 | #endif /* __LINUX_LIBATA_H__ */ | 1166 | #endif /* __LINUX_LIBATA_H__ */ |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index cde701c13c77..c2fd2d19938b 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1196,8 +1196,12 @@ | |||
1196 | #define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 | 1196 | #define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 |
1197 | #define PCI_DEVICE_ID_NVIDIA_NVENET_16 0x03E5 | 1197 | #define PCI_DEVICE_ID_NVIDIA_NVENET_16 0x03E5 |
1198 | #define PCI_DEVICE_ID_NVIDIA_NVENET_17 0x03E6 | 1198 | #define PCI_DEVICE_ID_NVIDIA_NVENET_17 0x03E6 |
1199 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7 | ||
1200 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE 0x03EC | ||
1199 | #define PCI_DEVICE_ID_NVIDIA_NVENET_18 0x03EE | 1201 | #define PCI_DEVICE_ID_NVIDIA_NVENET_18 0x03EE |
1200 | #define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF | 1202 | #define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF |
1203 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6 | ||
1204 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7 | ||
1201 | #define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450 | 1205 | #define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450 |
1202 | #define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 | 1206 | #define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 |
1203 | #define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452 | 1207 | #define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452 |
@@ -1255,6 +1259,7 @@ | |||
1255 | #define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 | 1259 | #define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 |
1256 | #define PCI_DEVICE_ID_VIA_3269_0 0x0269 | 1260 | #define PCI_DEVICE_ID_VIA_3269_0 0x0269 |
1257 | #define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 | 1261 | #define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 |
1262 | #define PCI_DEVICE_ID_VIA_3296_0 0x0296 | ||
1258 | #define PCI_DEVICE_ID_VIA_8363_0 0x0305 | 1263 | #define PCI_DEVICE_ID_VIA_8363_0 0x0305 |
1259 | #define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 | 1264 | #define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 |
1260 | #define PCI_DEVICE_ID_VIA_8371_0 0x0391 | 1265 | #define PCI_DEVICE_ID_VIA_8371_0 0x0391 |
@@ -1262,6 +1267,7 @@ | |||
1262 | #define PCI_DEVICE_ID_VIA_82C561 0x0561 | 1267 | #define PCI_DEVICE_ID_VIA_82C561 0x0561 |
1263 | #define PCI_DEVICE_ID_VIA_82C586_1 0x0571 | 1268 | #define PCI_DEVICE_ID_VIA_82C586_1 0x0571 |
1264 | #define PCI_DEVICE_ID_VIA_82C576 0x0576 | 1269 | #define PCI_DEVICE_ID_VIA_82C576 0x0576 |
1270 | #define PCI_DEVICE_ID_VIA_SATA_EIDE 0x0581 | ||
1265 | #define PCI_DEVICE_ID_VIA_82C586_0 0x0586 | 1271 | #define PCI_DEVICE_ID_VIA_82C586_0 0x0586 |
1266 | #define PCI_DEVICE_ID_VIA_82C596 0x0596 | 1272 | #define PCI_DEVICE_ID_VIA_82C596 0x0596 |
1267 | #define PCI_DEVICE_ID_VIA_82C597_0 0x0597 | 1273 | #define PCI_DEVICE_ID_VIA_82C597_0 0x0597 |
@@ -1302,10 +1308,11 @@ | |||
1302 | #define PCI_DEVICE_ID_VIA_8783_0 0x3208 | 1308 | #define PCI_DEVICE_ID_VIA_8783_0 0x3208 |
1303 | #define PCI_DEVICE_ID_VIA_8237 0x3227 | 1309 | #define PCI_DEVICE_ID_VIA_8237 0x3227 |
1304 | #define PCI_DEVICE_ID_VIA_8251 0x3287 | 1310 | #define PCI_DEVICE_ID_VIA_8251 0x3287 |
1305 | #define PCI_DEVICE_ID_VIA_3296_0 0x0296 | 1311 | #define PCI_DEVICE_ID_VIA_8237A 0x3337 |
1306 | #define PCI_DEVICE_ID_VIA_8231 0x8231 | 1312 | #define PCI_DEVICE_ID_VIA_8231 0x8231 |
1307 | #define PCI_DEVICE_ID_VIA_8231_4 0x8235 | 1313 | #define PCI_DEVICE_ID_VIA_8231_4 0x8235 |
1308 | #define PCI_DEVICE_ID_VIA_8365_1 0x8305 | 1314 | #define PCI_DEVICE_ID_VIA_8365_1 0x8305 |
1315 | #define PCI_DEVICE_ID_VIA_CX700 0x8324 | ||
1309 | #define PCI_DEVICE_ID_VIA_8371_1 0x8391 | 1316 | #define PCI_DEVICE_ID_VIA_8371_1 0x8391 |
1310 | #define PCI_DEVICE_ID_VIA_82C598_1 0x8598 | 1317 | #define PCI_DEVICE_ID_VIA_82C598_1 0x8598 |
1311 | #define PCI_DEVICE_ID_VIA_838X_1 0xB188 | 1318 | #define PCI_DEVICE_ID_VIA_838X_1 0xB188 |