diff options
author | David Howells <dhowells@redhat.com> | 2006-12-05 12:01:28 -0500 |
---|---|---|
committer | David Howells <dhowells@warthog.cambridge.redhat.com> | 2006-12-05 12:01:28 -0500 |
commit | 9db73724453a9350e1c22dbe732d427e2939a5c9 (patch) | |
tree | 15e3ead6413ae97398a54292acc199bee0864d42 /drivers/ata/libata-core.c | |
parent | 4c1ac1b49122b805adfa4efc620592f68dccf5db (diff) | |
parent | e62438630ca37539c8cc1553710bbfaa3cf960a7 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
drivers/ata/libata-scsi.c
include/linux/libata.h
Futher merge of Linus's head and compilation fixups.
Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 536 |
1 files changed, 426 insertions, 110 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index b5f2da6ac80e..8816e30fb7a4 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -199,7 +199,8 @@ static const u8 ata_rw_cmds[] = { | |||
199 | 199 | ||
200 | /** | 200 | /** |
201 | * ata_rwcmd_protocol - set taskfile r/w commands and protocol | 201 | * ata_rwcmd_protocol - set taskfile r/w commands and protocol |
202 | * @qc: command to examine and configure | 202 | * @tf: command to examine and configure |
203 | * @dev: device tf belongs to | ||
203 | * | 204 | * |
204 | * Examine the device configuration and tf->flags to calculate | 205 | * Examine the device configuration and tf->flags to calculate |
205 | * the proper read/write commands and protocol to use. | 206 | * the proper read/write commands and protocol to use. |
@@ -207,10 +208,8 @@ static const u8 ata_rw_cmds[] = { | |||
207 | * LOCKING: | 208 | * LOCKING: |
208 | * caller. | 209 | * caller. |
209 | */ | 210 | */ |
210 | int ata_rwcmd_protocol(struct ata_queued_cmd *qc) | 211 | static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) |
211 | { | 212 | { |
212 | struct ata_taskfile *tf = &qc->tf; | ||
213 | struct ata_device *dev = qc->dev; | ||
214 | u8 cmd; | 213 | u8 cmd; |
215 | 214 | ||
216 | int index, fua, lba48, write; | 215 | int index, fua, lba48, write; |
@@ -222,7 +221,7 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc) | |||
222 | if (dev->flags & ATA_DFLAG_PIO) { | 221 | if (dev->flags & ATA_DFLAG_PIO) { |
223 | tf->protocol = ATA_PROT_PIO; | 222 | tf->protocol = ATA_PROT_PIO; |
224 | index = dev->multi_count ? 0 : 8; | 223 | index = dev->multi_count ? 0 : 8; |
225 | } else if (lba48 && (qc->ap->flags & ATA_FLAG_PIO_LBA48)) { | 224 | } else if (lba48 && (dev->ap->flags & ATA_FLAG_PIO_LBA48)) { |
226 | /* Unable to use DMA due to host limitation */ | 225 | /* Unable to use DMA due to host limitation */ |
227 | tf->protocol = ATA_PROT_PIO; | 226 | tf->protocol = ATA_PROT_PIO; |
228 | index = dev->multi_count ? 0 : 8; | 227 | index = dev->multi_count ? 0 : 8; |
@@ -240,6 +239,174 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc) | |||
240 | } | 239 | } |
241 | 240 | ||
242 | /** | 241 | /** |
242 | * ata_tf_read_block - Read block address from ATA taskfile | ||
243 | * @tf: ATA taskfile of interest | ||
244 | * @dev: ATA device @tf belongs to | ||
245 | * | ||
246 | * LOCKING: | ||
247 | * None. | ||
248 | * | ||
249 | * Read block address from @tf. This function can handle all | ||
250 | * three address formats - LBA, LBA48 and CHS. tf->protocol and | ||
251 | * flags select the address format to use. | ||
252 | * | ||
253 | * RETURNS: | ||
254 | * Block address read from @tf. | ||
255 | */ | ||
256 | u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev) | ||
257 | { | ||
258 | u64 block = 0; | ||
259 | |||
260 | if (tf->flags & ATA_TFLAG_LBA) { | ||
261 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
262 | block |= (u64)tf->hob_lbah << 40; | ||
263 | block |= (u64)tf->hob_lbam << 32; | ||
264 | block |= tf->hob_lbal << 24; | ||
265 | } else | ||
266 | block |= (tf->device & 0xf) << 24; | ||
267 | |||
268 | block |= tf->lbah << 16; | ||
269 | block |= tf->lbam << 8; | ||
270 | block |= tf->lbal; | ||
271 | } else { | ||
272 | u32 cyl, head, sect; | ||
273 | |||
274 | cyl = tf->lbam | (tf->lbah << 8); | ||
275 | head = tf->device & 0xf; | ||
276 | sect = tf->lbal; | ||
277 | |||
278 | block = (cyl * dev->heads + head) * dev->sectors + sect; | ||
279 | } | ||
280 | |||
281 | return block; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * ata_build_rw_tf - Build ATA taskfile for given read/write request | ||
286 | * @tf: Target ATA taskfile | ||
287 | * @dev: ATA device @tf belongs to | ||
288 | * @block: Block address | ||
289 | * @n_block: Number of blocks | ||
290 | * @tf_flags: RW/FUA etc... | ||
291 | * @tag: tag | ||
292 | * | ||
293 | * LOCKING: | ||
294 | * None. | ||
295 | * | ||
296 | * Build ATA taskfile @tf for read/write request described by | ||
297 | * @block, @n_block, @tf_flags and @tag on @dev. | ||
298 | * | ||
299 | * RETURNS: | ||
300 | * | ||
301 | * 0 on success, -ERANGE if the request is too large for @dev, | ||
302 | * -EINVAL if the request is invalid. | ||
303 | */ | ||
304 | int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | ||
305 | u64 block, u32 n_block, unsigned int tf_flags, | ||
306 | unsigned int tag) | ||
307 | { | ||
308 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
309 | tf->flags |= tf_flags; | ||
310 | |||
311 | if ((dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | | ||
312 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ && | ||
313 | likely(tag != ATA_TAG_INTERNAL)) { | ||
314 | /* yay, NCQ */ | ||
315 | if (!lba_48_ok(block, n_block)) | ||
316 | return -ERANGE; | ||
317 | |||
318 | tf->protocol = ATA_PROT_NCQ; | ||
319 | tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; | ||
320 | |||
321 | if (tf->flags & ATA_TFLAG_WRITE) | ||
322 | tf->command = ATA_CMD_FPDMA_WRITE; | ||
323 | else | ||
324 | tf->command = ATA_CMD_FPDMA_READ; | ||
325 | |||
326 | tf->nsect = tag << 3; | ||
327 | tf->hob_feature = (n_block >> 8) & 0xff; | ||
328 | tf->feature = n_block & 0xff; | ||
329 | |||
330 | tf->hob_lbah = (block >> 40) & 0xff; | ||
331 | tf->hob_lbam = (block >> 32) & 0xff; | ||
332 | tf->hob_lbal = (block >> 24) & 0xff; | ||
333 | tf->lbah = (block >> 16) & 0xff; | ||
334 | tf->lbam = (block >> 8) & 0xff; | ||
335 | tf->lbal = block & 0xff; | ||
336 | |||
337 | tf->device = 1 << 6; | ||
338 | if (tf->flags & ATA_TFLAG_FUA) | ||
339 | tf->device |= 1 << 7; | ||
340 | } else if (dev->flags & ATA_DFLAG_LBA) { | ||
341 | tf->flags |= ATA_TFLAG_LBA; | ||
342 | |||
343 | if (lba_28_ok(block, n_block)) { | ||
344 | /* use LBA28 */ | ||
345 | tf->device |= (block >> 24) & 0xf; | ||
346 | } else if (lba_48_ok(block, n_block)) { | ||
347 | if (!(dev->flags & ATA_DFLAG_LBA48)) | ||
348 | return -ERANGE; | ||
349 | |||
350 | /* use LBA48 */ | ||
351 | tf->flags |= ATA_TFLAG_LBA48; | ||
352 | |||
353 | tf->hob_nsect = (n_block >> 8) & 0xff; | ||
354 | |||
355 | tf->hob_lbah = (block >> 40) & 0xff; | ||
356 | tf->hob_lbam = (block >> 32) & 0xff; | ||
357 | tf->hob_lbal = (block >> 24) & 0xff; | ||
358 | } else | ||
359 | /* request too large even for LBA48 */ | ||
360 | return -ERANGE; | ||
361 | |||
362 | if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) | ||
363 | return -EINVAL; | ||
364 | |||
365 | tf->nsect = n_block & 0xff; | ||
366 | |||
367 | tf->lbah = (block >> 16) & 0xff; | ||
368 | tf->lbam = (block >> 8) & 0xff; | ||
369 | tf->lbal = block & 0xff; | ||
370 | |||
371 | tf->device |= ATA_LBA; | ||
372 | } else { | ||
373 | /* CHS */ | ||
374 | u32 sect, head, cyl, track; | ||
375 | |||
376 | /* The request -may- be too large for CHS addressing. */ | ||
377 | if (!lba_28_ok(block, n_block)) | ||
378 | return -ERANGE; | ||
379 | |||
380 | if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) | ||
381 | return -EINVAL; | ||
382 | |||
383 | /* Convert LBA to CHS */ | ||
384 | track = (u32)block / dev->sectors; | ||
385 | cyl = track / dev->heads; | ||
386 | head = track % dev->heads; | ||
387 | sect = (u32)block % dev->sectors + 1; | ||
388 | |||
389 | DPRINTK("block %u track %u cyl %u head %u sect %u\n", | ||
390 | (u32)block, track, cyl, head, sect); | ||
391 | |||
392 | /* Check whether the converted CHS can fit. | ||
393 | Cylinder: 0-65535 | ||
394 | Head: 0-15 | ||
395 | Sector: 1-255*/ | ||
396 | if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect)) | ||
397 | return -ERANGE; | ||
398 | |||
399 | tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ | ||
400 | tf->lbal = sect; | ||
401 | tf->lbam = cyl; | ||
402 | tf->lbah = cyl >> 8; | ||
403 | tf->device |= head; | ||
404 | } | ||
405 | |||
406 | return 0; | ||
407 | } | ||
408 | |||
409 | /** | ||
243 | * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask | 410 | * ata_pack_xfermask - Pack pio, mwdma and udma masks into xfer_mask |
244 | * @pio_mask: pio_mask | 411 | * @pio_mask: pio_mask |
245 | * @mwdma_mask: mwdma_mask | 412 | * @mwdma_mask: mwdma_mask |
@@ -997,13 +1164,13 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
997 | } | 1164 | } |
998 | 1165 | ||
999 | /** | 1166 | /** |
1000 | * ata_exec_internal - execute libata internal command | 1167 | * ata_exec_internal_sg - execute libata internal command |
1001 | * @dev: Device to which the command is sent | 1168 | * @dev: Device to which the command is sent |
1002 | * @tf: Taskfile registers for the command and the result | 1169 | * @tf: Taskfile registers for the command and the result |
1003 | * @cdb: CDB for packet command | 1170 | * @cdb: CDB for packet command |
1004 | * @dma_dir: Data tranfer direction of the command | 1171 | * @dma_dir: Data tranfer direction of the command |
1005 | * @buf: Data buffer of the command | 1172 | * @sg: sg list for the data buffer of the command |
1006 | * @buflen: Length of data buffer | 1173 | * @n_elem: Number of sg entries |
1007 | * | 1174 | * |
1008 | * Executes libata internal command with timeout. @tf contains | 1175 | * Executes libata internal command with timeout. @tf contains |
1009 | * command on entry and result on return. Timeout and error | 1176 | * command on entry and result on return. Timeout and error |
@@ -1017,9 +1184,10 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
1017 | * RETURNS: | 1184 | * RETURNS: |
1018 | * Zero on success, AC_ERR_* mask on failure | 1185 | * Zero on success, AC_ERR_* mask on failure |
1019 | */ | 1186 | */ |
1020 | unsigned ata_exec_internal(struct ata_device *dev, | 1187 | unsigned ata_exec_internal_sg(struct ata_device *dev, |
1021 | struct ata_taskfile *tf, const u8 *cdb, | 1188 | struct ata_taskfile *tf, const u8 *cdb, |
1022 | int dma_dir, void *buf, unsigned int buflen) | 1189 | int dma_dir, struct scatterlist *sg, |
1190 | unsigned int n_elem) | ||
1023 | { | 1191 | { |
1024 | struct ata_port *ap = dev->ap; | 1192 | struct ata_port *ap = dev->ap; |
1025 | u8 command = tf->command; | 1193 | u8 command = tf->command; |
@@ -1075,7 +1243,12 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1075 | qc->flags |= ATA_QCFLAG_RESULT_TF; | 1243 | qc->flags |= ATA_QCFLAG_RESULT_TF; |
1076 | qc->dma_dir = dma_dir; | 1244 | qc->dma_dir = dma_dir; |
1077 | if (dma_dir != DMA_NONE) { | 1245 | if (dma_dir != DMA_NONE) { |
1078 | ata_sg_init_one(qc, buf, buflen); | 1246 | unsigned int i, buflen = 0; |
1247 | |||
1248 | for (i = 0; i < n_elem; i++) | ||
1249 | buflen += sg[i].length; | ||
1250 | |||
1251 | ata_sg_init(qc, sg, n_elem); | ||
1079 | qc->nsect = buflen / ATA_SECT_SIZE; | 1252 | qc->nsect = buflen / ATA_SECT_SIZE; |
1080 | } | 1253 | } |
1081 | 1254 | ||
@@ -1159,6 +1332,35 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1159 | } | 1332 | } |
1160 | 1333 | ||
1161 | /** | 1334 | /** |
1335 | * ata_exec_internal_sg - execute libata internal command | ||
1336 | * @dev: Device to which the command is sent | ||
1337 | * @tf: Taskfile registers for the command and the result | ||
1338 | * @cdb: CDB for packet command | ||
1339 | * @dma_dir: Data tranfer direction of the command | ||
1340 | * @buf: Data buffer of the command | ||
1341 | * @buflen: Length of data buffer | ||
1342 | * | ||
1343 | * Wrapper around ata_exec_internal_sg() which takes simple | ||
1344 | * buffer instead of sg list. | ||
1345 | * | ||
1346 | * LOCKING: | ||
1347 | * None. Should be called with kernel context, might sleep. | ||
1348 | * | ||
1349 | * RETURNS: | ||
1350 | * Zero on success, AC_ERR_* mask on failure | ||
1351 | */ | ||
1352 | unsigned ata_exec_internal(struct ata_device *dev, | ||
1353 | struct ata_taskfile *tf, const u8 *cdb, | ||
1354 | int dma_dir, void *buf, unsigned int buflen) | ||
1355 | { | ||
1356 | struct scatterlist sg; | ||
1357 | |||
1358 | sg_init_one(&sg, buf, buflen); | ||
1359 | |||
1360 | return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1); | ||
1361 | } | ||
1362 | |||
1363 | /** | ||
1162 | * ata_do_simple_cmd - execute simple internal command | 1364 | * ata_do_simple_cmd - execute simple internal command |
1163 | * @dev: Device to which the command is sent | 1365 | * @dev: Device to which the command is sent |
1164 | * @cmd: Opcode to execute | 1366 | * @cmd: Opcode to execute |
@@ -1222,7 +1424,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1222 | * ata_dev_read_id - Read ID data from the specified device | 1424 | * ata_dev_read_id - Read ID data from the specified device |
1223 | * @dev: target device | 1425 | * @dev: target device |
1224 | * @p_class: pointer to class of the target device (may be changed) | 1426 | * @p_class: pointer to class of the target device (may be changed) |
1225 | * @post_reset: is this read ID post-reset? | 1427 | * @flags: ATA_READID_* flags |
1226 | * @id: buffer to read IDENTIFY data into | 1428 | * @id: buffer to read IDENTIFY data into |
1227 | * | 1429 | * |
1228 | * Read ID data from the specified device. ATA_CMD_ID_ATA is | 1430 | * Read ID data from the specified device. ATA_CMD_ID_ATA is |
@@ -1237,7 +1439,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1237 | * 0 on success, -errno otherwise. | 1439 | * 0 on success, -errno otherwise. |
1238 | */ | 1440 | */ |
1239 | int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | 1441 | int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, |
1240 | int post_reset, u16 *id) | 1442 | unsigned int flags, u16 *id) |
1241 | { | 1443 | { |
1242 | struct ata_port *ap = dev->ap; | 1444 | struct ata_port *ap = dev->ap; |
1243 | unsigned int class = *p_class; | 1445 | unsigned int class = *p_class; |
@@ -1269,10 +1471,17 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1269 | } | 1471 | } |
1270 | 1472 | ||
1271 | tf.protocol = ATA_PROT_PIO; | 1473 | tf.protocol = ATA_PROT_PIO; |
1474 | tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */ | ||
1272 | 1475 | ||
1273 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, | 1476 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1274 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1477 | id, sizeof(id[0]) * ATA_ID_WORDS); |
1275 | if (err_mask) { | 1478 | if (err_mask) { |
1479 | if (err_mask & AC_ERR_NODEV_HINT) { | ||
1480 | DPRINTK("ata%u.%d: NODEV after polling detection\n", | ||
1481 | ap->id, dev->devno); | ||
1482 | return -ENOENT; | ||
1483 | } | ||
1484 | |||
1276 | rc = -EIO; | 1485 | rc = -EIO; |
1277 | reason = "I/O error"; | 1486 | reason = "I/O error"; |
1278 | goto err_out; | 1487 | goto err_out; |
@@ -1292,7 +1501,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1292 | goto err_out; | 1501 | goto err_out; |
1293 | } | 1502 | } |
1294 | 1503 | ||
1295 | if (post_reset && class == ATA_DEV_ATA) { | 1504 | if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) { |
1296 | /* | 1505 | /* |
1297 | * The exact sequence expected by certain pre-ATA4 drives is: | 1506 | * The exact sequence expected by certain pre-ATA4 drives is: |
1298 | * SRST RESET | 1507 | * SRST RESET |
@@ -1312,7 +1521,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1312 | /* current CHS translation info (id[53-58]) might be | 1521 | /* current CHS translation info (id[53-58]) might be |
1313 | * changed. reread the identify device info. | 1522 | * changed. reread the identify device info. |
1314 | */ | 1523 | */ |
1315 | post_reset = 0; | 1524 | flags &= ~ATA_READID_POSTRESET; |
1316 | goto retry; | 1525 | goto retry; |
1317 | } | 1526 | } |
1318 | } | 1527 | } |
@@ -1343,7 +1552,10 @@ static void ata_dev_config_ncq(struct ata_device *dev, | |||
1343 | desc[0] = '\0'; | 1552 | desc[0] = '\0'; |
1344 | return; | 1553 | return; |
1345 | } | 1554 | } |
1346 | 1555 | if (ata_device_blacklisted(dev) & ATA_HORKAGE_NONCQ) { | |
1556 | snprintf(desc, desc_sz, "NCQ (not used)"); | ||
1557 | return; | ||
1558 | } | ||
1347 | if (ap->flags & ATA_FLAG_NCQ) { | 1559 | if (ap->flags & ATA_FLAG_NCQ) { |
1348 | hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1); | 1560 | hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1); |
1349 | dev->flags |= ATA_DFLAG_NCQ; | 1561 | dev->flags |= ATA_DFLAG_NCQ; |
@@ -1372,7 +1584,6 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap) | |||
1372 | /** | 1584 | /** |
1373 | * ata_dev_configure - Configure the specified ATA/ATAPI device | 1585 | * ata_dev_configure - Configure the specified ATA/ATAPI device |
1374 | * @dev: Target device to configure | 1586 | * @dev: Target device to configure |
1375 | * @print_info: Enable device info printout | ||
1376 | * | 1587 | * |
1377 | * Configure @dev according to @dev->id. Generic and low-level | 1588 | * Configure @dev according to @dev->id. Generic and low-level |
1378 | * driver specific fixups are also applied. | 1589 | * driver specific fixups are also applied. |
@@ -1383,9 +1594,10 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap) | |||
1383 | * RETURNS: | 1594 | * RETURNS: |
1384 | * 0 on success, -errno otherwise | 1595 | * 0 on success, -errno otherwise |
1385 | */ | 1596 | */ |
1386 | int ata_dev_configure(struct ata_device *dev, int print_info) | 1597 | int ata_dev_configure(struct ata_device *dev) |
1387 | { | 1598 | { |
1388 | struct ata_port *ap = dev->ap; | 1599 | struct ata_port *ap = dev->ap; |
1600 | int print_info = ap->eh_context.i.flags & ATA_EHI_PRINTINFO; | ||
1389 | const u16 *id = dev->id; | 1601 | const u16 *id = dev->id; |
1390 | unsigned int xfer_mask; | 1602 | unsigned int xfer_mask; |
1391 | char revbuf[7]; /* XYZ-99\0 */ | 1603 | char revbuf[7]; /* XYZ-99\0 */ |
@@ -1452,6 +1664,10 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1452 | if (ata_id_has_lba48(id)) { | 1664 | if (ata_id_has_lba48(id)) { |
1453 | dev->flags |= ATA_DFLAG_LBA48; | 1665 | dev->flags |= ATA_DFLAG_LBA48; |
1454 | lba_desc = "LBA48"; | 1666 | lba_desc = "LBA48"; |
1667 | |||
1668 | if (dev->n_sectors >= (1UL << 28) && | ||
1669 | ata_id_has_flush_ext(id)) | ||
1670 | dev->flags |= ATA_DFLAG_FLUSH_EXT; | ||
1455 | } | 1671 | } |
1456 | 1672 | ||
1457 | /* config NCQ */ | 1673 | /* config NCQ */ |
@@ -1528,6 +1744,11 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1528 | cdb_intr_string); | 1744 | cdb_intr_string); |
1529 | } | 1745 | } |
1530 | 1746 | ||
1747 | /* determine max_sectors */ | ||
1748 | dev->max_sectors = ATA_MAX_SECTORS; | ||
1749 | if (dev->flags & ATA_DFLAG_LBA48) | ||
1750 | dev->max_sectors = ATA_MAX_SECTORS_LBA48; | ||
1751 | |||
1531 | if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { | 1752 | if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) { |
1532 | /* Let the user know. We don't want to disallow opens for | 1753 | /* Let the user know. We don't want to disallow opens for |
1533 | rescue purposes, or in case the vendor is just a blithering | 1754 | rescue purposes, or in case the vendor is just a blithering |
@@ -1629,11 +1850,14 @@ int ata_bus_probe(struct ata_port *ap) | |||
1629 | if (!ata_dev_enabled(dev)) | 1850 | if (!ata_dev_enabled(dev)) |
1630 | continue; | 1851 | continue; |
1631 | 1852 | ||
1632 | rc = ata_dev_read_id(dev, &dev->class, 1, dev->id); | 1853 | rc = ata_dev_read_id(dev, &dev->class, ATA_READID_POSTRESET, |
1854 | dev->id); | ||
1633 | if (rc) | 1855 | if (rc) |
1634 | goto fail; | 1856 | goto fail; |
1635 | 1857 | ||
1636 | rc = ata_dev_configure(dev, 1); | 1858 | ap->eh_context.i.flags |= ATA_EHI_PRINTINFO; |
1859 | rc = ata_dev_configure(dev); | ||
1860 | ap->eh_context.i.flags &= ~ATA_EHI_PRINTINFO; | ||
1637 | if (rc) | 1861 | if (rc) |
1638 | goto fail; | 1862 | goto fail; |
1639 | } | 1863 | } |
@@ -2151,6 +2375,7 @@ int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0) | |||
2151 | 2375 | ||
2152 | static int ata_dev_set_mode(struct ata_device *dev) | 2376 | static int ata_dev_set_mode(struct ata_device *dev) |
2153 | { | 2377 | { |
2378 | struct ata_eh_context *ehc = &dev->ap->eh_context; | ||
2154 | unsigned int err_mask; | 2379 | unsigned int err_mask; |
2155 | int rc; | 2380 | int rc; |
2156 | 2381 | ||
@@ -2165,7 +2390,9 @@ static int ata_dev_set_mode(struct ata_device *dev) | |||
2165 | return -EIO; | 2390 | return -EIO; |
2166 | } | 2391 | } |
2167 | 2392 | ||
2393 | ehc->i.flags |= ATA_EHI_POST_SETMODE; | ||
2168 | rc = ata_dev_revalidate(dev, 0); | 2394 | rc = ata_dev_revalidate(dev, 0); |
2395 | ehc->i.flags &= ~ATA_EHI_POST_SETMODE; | ||
2169 | if (rc) | 2396 | if (rc) |
2170 | return rc; | 2397 | return rc; |
2171 | 2398 | ||
@@ -2323,11 +2550,14 @@ static inline void ata_tf_to_host(struct ata_port *ap, | |||
2323 | * Sleep until ATA Status register bit BSY clears, | 2550 | * Sleep until ATA Status register bit BSY clears, |
2324 | * or a timeout occurs. | 2551 | * or a timeout occurs. |
2325 | * | 2552 | * |
2326 | * LOCKING: None. | 2553 | * LOCKING: |
2554 | * Kernel thread context (may sleep). | ||
2555 | * | ||
2556 | * RETURNS: | ||
2557 | * 0 on success, -errno otherwise. | ||
2327 | */ | 2558 | */ |
2328 | 2559 | int ata_busy_sleep(struct ata_port *ap, | |
2329 | unsigned int ata_busy_sleep (struct ata_port *ap, | 2560 | unsigned long tmout_pat, unsigned long tmout) |
2330 | unsigned long tmout_pat, unsigned long tmout) | ||
2331 | { | 2561 | { |
2332 | unsigned long timer_start, timeout; | 2562 | unsigned long timer_start, timeout; |
2333 | u8 status; | 2563 | u8 status; |
@@ -2335,27 +2565,32 @@ unsigned int ata_busy_sleep (struct ata_port *ap, | |||
2335 | status = ata_busy_wait(ap, ATA_BUSY, 300); | 2565 | status = ata_busy_wait(ap, ATA_BUSY, 300); |
2336 | timer_start = jiffies; | 2566 | timer_start = jiffies; |
2337 | timeout = timer_start + tmout_pat; | 2567 | timeout = timer_start + tmout_pat; |
2338 | while ((status & ATA_BUSY) && (time_before(jiffies, timeout))) { | 2568 | while (status != 0xff && (status & ATA_BUSY) && |
2569 | time_before(jiffies, timeout)) { | ||
2339 | msleep(50); | 2570 | msleep(50); |
2340 | status = ata_busy_wait(ap, ATA_BUSY, 3); | 2571 | status = ata_busy_wait(ap, ATA_BUSY, 3); |
2341 | } | 2572 | } |
2342 | 2573 | ||
2343 | if (status & ATA_BUSY) | 2574 | if (status != 0xff && (status & ATA_BUSY)) |
2344 | ata_port_printk(ap, KERN_WARNING, | 2575 | ata_port_printk(ap, KERN_WARNING, |
2345 | "port is slow to respond, please be patient " | 2576 | "port is slow to respond, please be patient " |
2346 | "(Status 0x%x)\n", status); | 2577 | "(Status 0x%x)\n", status); |
2347 | 2578 | ||
2348 | timeout = timer_start + tmout; | 2579 | timeout = timer_start + tmout; |
2349 | while ((status & ATA_BUSY) && (time_before(jiffies, timeout))) { | 2580 | while (status != 0xff && (status & ATA_BUSY) && |
2581 | time_before(jiffies, timeout)) { | ||
2350 | msleep(50); | 2582 | msleep(50); |
2351 | status = ata_chk_status(ap); | 2583 | status = ata_chk_status(ap); |
2352 | } | 2584 | } |
2353 | 2585 | ||
2586 | if (status == 0xff) | ||
2587 | return -ENODEV; | ||
2588 | |||
2354 | if (status & ATA_BUSY) { | 2589 | if (status & ATA_BUSY) { |
2355 | ata_port_printk(ap, KERN_ERR, "port failed to respond " | 2590 | ata_port_printk(ap, KERN_ERR, "port failed to respond " |
2356 | "(%lu secs, Status 0x%x)\n", | 2591 | "(%lu secs, Status 0x%x)\n", |
2357 | tmout / HZ, status); | 2592 | tmout / HZ, status); |
2358 | return 1; | 2593 | return -EBUSY; |
2359 | } | 2594 | } |
2360 | 2595 | ||
2361 | return 0; | 2596 | return 0; |
@@ -2446,10 +2681,8 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2446 | * the bus shows 0xFF because the odd clown forgets the D7 | 2681 | * the bus shows 0xFF because the odd clown forgets the D7 |
2447 | * pulldown resistor. | 2682 | * pulldown resistor. |
2448 | */ | 2683 | */ |
2449 | if (ata_check_status(ap) == 0xFF) { | 2684 | if (ata_check_status(ap) == 0xFF) |
2450 | ata_port_printk(ap, KERN_ERR, "SRST failed (status 0xFF)\n"); | 2685 | return 0; |
2451 | return AC_ERR_OTHER; | ||
2452 | } | ||
2453 | 2686 | ||
2454 | ata_bus_post_reset(ap, devmask); | 2687 | ata_bus_post_reset(ap, devmask); |
2455 | 2688 | ||
@@ -2775,9 +3008,9 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes) | |||
2775 | } | 3008 | } |
2776 | 3009 | ||
2777 | /** | 3010 | /** |
2778 | * sata_std_hardreset - reset host port via SATA phy reset | 3011 | * sata_port_hardreset - reset port via SATA phy reset |
2779 | * @ap: port to reset | 3012 | * @ap: port to reset |
2780 | * @class: resulting class of attached device | 3013 | * @timing: timing parameters { interval, duratinon, timeout } in msec |
2781 | * | 3014 | * |
2782 | * SATA phy-reset host port using DET bits of SControl register. | 3015 | * SATA phy-reset host port using DET bits of SControl register. |
2783 | * | 3016 | * |
@@ -2787,10 +3020,8 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes) | |||
2787 | * RETURNS: | 3020 | * RETURNS: |
2788 | * 0 on success, -errno otherwise. | 3021 | * 0 on success, -errno otherwise. |
2789 | */ | 3022 | */ |
2790 | int sata_std_hardreset(struct ata_port *ap, unsigned int *class) | 3023 | int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing) |
2791 | { | 3024 | { |
2792 | struct ata_eh_context *ehc = &ap->eh_context; | ||
2793 | const unsigned long *timing = sata_ehc_deb_timing(ehc); | ||
2794 | u32 scontrol; | 3025 | u32 scontrol; |
2795 | int rc; | 3026 | int rc; |
2796 | 3027 | ||
@@ -2803,24 +3034,24 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class) | |||
2803 | * and Sil3124. | 3034 | * and Sil3124. |
2804 | */ | 3035 | */ |
2805 | if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) | 3036 | if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) |
2806 | return rc; | 3037 | goto out; |
2807 | 3038 | ||
2808 | scontrol = (scontrol & 0x0f0) | 0x304; | 3039 | scontrol = (scontrol & 0x0f0) | 0x304; |
2809 | 3040 | ||
2810 | if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol))) | 3041 | if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol))) |
2811 | return rc; | 3042 | goto out; |
2812 | 3043 | ||
2813 | sata_set_spd(ap); | 3044 | sata_set_spd(ap); |
2814 | } | 3045 | } |
2815 | 3046 | ||
2816 | /* issue phy wake/reset */ | 3047 | /* issue phy wake/reset */ |
2817 | if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) | 3048 | if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) |
2818 | return rc; | 3049 | goto out; |
2819 | 3050 | ||
2820 | scontrol = (scontrol & 0x0f0) | 0x301; | 3051 | scontrol = (scontrol & 0x0f0) | 0x301; |
2821 | 3052 | ||
2822 | if ((rc = sata_scr_write_flush(ap, SCR_CONTROL, scontrol))) | 3053 | if ((rc = sata_scr_write_flush(ap, SCR_CONTROL, scontrol))) |
2823 | return rc; | 3054 | goto out; |
2824 | 3055 | ||
2825 | /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 | 3056 | /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 |
2826 | * 10.4.2 says at least 1 ms. | 3057 | * 10.4.2 says at least 1 ms. |
@@ -2828,7 +3059,40 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class) | |||
2828 | msleep(1); | 3059 | msleep(1); |
2829 | 3060 | ||
2830 | /* bring phy back */ | 3061 | /* bring phy back */ |
2831 | sata_phy_resume(ap, timing); | 3062 | rc = sata_phy_resume(ap, timing); |
3063 | out: | ||
3064 | DPRINTK("EXIT, rc=%d\n", rc); | ||
3065 | return rc; | ||
3066 | } | ||
3067 | |||
3068 | /** | ||
3069 | * sata_std_hardreset - reset host port via SATA phy reset | ||
3070 | * @ap: port to reset | ||
3071 | * @class: resulting class of attached device | ||
3072 | * | ||
3073 | * SATA phy-reset host port using DET bits of SControl register, | ||
3074 | * wait for !BSY and classify the attached device. | ||
3075 | * | ||
3076 | * LOCKING: | ||
3077 | * Kernel thread context (may sleep) | ||
3078 | * | ||
3079 | * RETURNS: | ||
3080 | * 0 on success, -errno otherwise. | ||
3081 | */ | ||
3082 | int sata_std_hardreset(struct ata_port *ap, unsigned int *class) | ||
3083 | { | ||
3084 | const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context); | ||
3085 | int rc; | ||
3086 | |||
3087 | DPRINTK("ENTER\n"); | ||
3088 | |||
3089 | /* do hardreset */ | ||
3090 | rc = sata_port_hardreset(ap, timing); | ||
3091 | if (rc) { | ||
3092 | ata_port_printk(ap, KERN_ERR, | ||
3093 | "COMRESET failed (errno=%d)\n", rc); | ||
3094 | return rc; | ||
3095 | } | ||
2832 | 3096 | ||
2833 | /* TODO: phy layer with polling, timeouts, etc. */ | 3097 | /* TODO: phy layer with polling, timeouts, etc. */ |
2834 | if (ata_port_offline(ap)) { | 3098 | if (ata_port_offline(ap)) { |
@@ -2967,7 +3231,7 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
2967 | /** | 3231 | /** |
2968 | * ata_dev_revalidate - Revalidate ATA device | 3232 | * ata_dev_revalidate - Revalidate ATA device |
2969 | * @dev: device to revalidate | 3233 | * @dev: device to revalidate |
2970 | * @post_reset: is this revalidation after reset? | 3234 | * @readid_flags: read ID flags |
2971 | * | 3235 | * |
2972 | * Re-read IDENTIFY page and make sure @dev is still attached to | 3236 | * Re-read IDENTIFY page and make sure @dev is still attached to |
2973 | * the port. | 3237 | * the port. |
@@ -2978,7 +3242,7 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
2978 | * RETURNS: | 3242 | * RETURNS: |
2979 | * 0 on success, negative errno otherwise | 3243 | * 0 on success, negative errno otherwise |
2980 | */ | 3244 | */ |
2981 | int ata_dev_revalidate(struct ata_device *dev, int post_reset) | 3245 | int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) |
2982 | { | 3246 | { |
2983 | unsigned int class = dev->class; | 3247 | unsigned int class = dev->class; |
2984 | u16 *id = (void *)dev->ap->sector_buf; | 3248 | u16 *id = (void *)dev->ap->sector_buf; |
@@ -2990,7 +3254,7 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset) | |||
2990 | } | 3254 | } |
2991 | 3255 | ||
2992 | /* read ID data */ | 3256 | /* read ID data */ |
2993 | rc = ata_dev_read_id(dev, &class, post_reset, id); | 3257 | rc = ata_dev_read_id(dev, &class, readid_flags, id); |
2994 | if (rc) | 3258 | if (rc) |
2995 | goto fail; | 3259 | goto fail; |
2996 | 3260 | ||
@@ -3003,7 +3267,7 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset) | |||
3003 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); | 3267 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); |
3004 | 3268 | ||
3005 | /* configure device according to the new ID */ | 3269 | /* configure device according to the new ID */ |
3006 | rc = ata_dev_configure(dev, 0); | 3270 | rc = ata_dev_configure(dev); |
3007 | if (rc == 0) | 3271 | if (rc == 0) |
3008 | return 0; | 3272 | return 0; |
3009 | 3273 | ||
@@ -3012,37 +3276,55 @@ int ata_dev_revalidate(struct ata_device *dev, int post_reset) | |||
3012 | return rc; | 3276 | return rc; |
3013 | } | 3277 | } |
3014 | 3278 | ||
3015 | static const char * const ata_dma_blacklist [] = { | 3279 | struct ata_blacklist_entry { |
3016 | "WDC AC11000H", NULL, | 3280 | const char *model_num; |
3017 | "WDC AC22100H", NULL, | 3281 | const char *model_rev; |
3018 | "WDC AC32500H", NULL, | 3282 | unsigned long horkage; |
3019 | "WDC AC33100H", NULL, | 3283 | }; |
3020 | "WDC AC31600H", NULL, | 3284 | |
3021 | "WDC AC32100H", "24.09P07", | 3285 | static const struct ata_blacklist_entry ata_device_blacklist [] = { |
3022 | "WDC AC23200L", "21.10N21", | 3286 | /* Devices with DMA related problems under Linux */ |
3023 | "Compaq CRD-8241B", NULL, | 3287 | { "WDC AC11000H", NULL, ATA_HORKAGE_NODMA }, |
3024 | "CRD-8400B", NULL, | 3288 | { "WDC AC22100H", NULL, ATA_HORKAGE_NODMA }, |
3025 | "CRD-8480B", NULL, | 3289 | { "WDC AC32500H", NULL, ATA_HORKAGE_NODMA }, |
3026 | "CRD-8482B", NULL, | 3290 | { "WDC AC33100H", NULL, ATA_HORKAGE_NODMA }, |
3027 | "CRD-84", NULL, | 3291 | { "WDC AC31600H", NULL, ATA_HORKAGE_NODMA }, |
3028 | "SanDisk SDP3B", NULL, | 3292 | { "WDC AC32100H", "24.09P07", ATA_HORKAGE_NODMA }, |
3029 | "SanDisk SDP3B-64", NULL, | 3293 | { "WDC AC23200L", "21.10N21", ATA_HORKAGE_NODMA }, |
3030 | "SANYO CD-ROM CRD", NULL, | 3294 | { "Compaq CRD-8241B", NULL, ATA_HORKAGE_NODMA }, |
3031 | "HITACHI CDR-8", NULL, | 3295 | { "CRD-8400B", NULL, ATA_HORKAGE_NODMA }, |
3032 | "HITACHI CDR-8335", NULL, | 3296 | { "CRD-8480B", NULL, ATA_HORKAGE_NODMA }, |
3033 | "HITACHI CDR-8435", NULL, | 3297 | { "CRD-8482B", NULL, ATA_HORKAGE_NODMA }, |
3034 | "Toshiba CD-ROM XM-6202B", NULL, | 3298 | { "CRD-84", NULL, ATA_HORKAGE_NODMA }, |
3035 | "TOSHIBA CD-ROM XM-1702BC", NULL, | 3299 | { "SanDisk SDP3B", NULL, ATA_HORKAGE_NODMA }, |
3036 | "CD-532E-A", NULL, | 3300 | { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA }, |
3037 | "E-IDE CD-ROM CR-840", NULL, | 3301 | { "SANYO CD-ROM CRD", NULL, ATA_HORKAGE_NODMA }, |
3038 | "CD-ROM Drive/F5A", NULL, | 3302 | { "HITACHI CDR-8", NULL, ATA_HORKAGE_NODMA }, |
3039 | "WPI CDD-820", NULL, | 3303 | { "HITACHI CDR-8335", NULL, ATA_HORKAGE_NODMA }, |
3040 | "SAMSUNG CD-ROM SC-148C", NULL, | 3304 | { "HITACHI CDR-8435", NULL, ATA_HORKAGE_NODMA }, |
3041 | "SAMSUNG CD-ROM SC", NULL, | 3305 | { "Toshiba CD-ROM XM-6202B", NULL, ATA_HORKAGE_NODMA }, |
3042 | "SanDisk SDP3B-64", NULL, | 3306 | { "TOSHIBA CD-ROM XM-1702BC", NULL, ATA_HORKAGE_NODMA }, |
3043 | "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL, | 3307 | { "CD-532E-A", NULL, ATA_HORKAGE_NODMA }, |
3044 | "_NEC DV5800A", NULL, | 3308 | { "E-IDE CD-ROM CR-840",NULL, ATA_HORKAGE_NODMA }, |
3045 | "SAMSUNG CD-ROM SN-124", "N001" | 3309 | { "CD-ROM Drive/F5A", NULL, ATA_HORKAGE_NODMA }, |
3310 | { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA }, | ||
3311 | { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA }, | ||
3312 | { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA }, | ||
3313 | { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA }, | ||
3314 | { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, | ||
3315 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, | ||
3316 | { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, | ||
3317 | |||
3318 | /* Devices we expect to fail diagnostics */ | ||
3319 | |||
3320 | /* Devices where NCQ should be avoided */ | ||
3321 | /* NCQ is slow */ | ||
3322 | { "WDC WD740ADFD-00", NULL, ATA_HORKAGE_NONCQ }, | ||
3323 | |||
3324 | /* Devices with NCQ limits */ | ||
3325 | |||
3326 | /* End Marker */ | ||
3327 | { } | ||
3046 | }; | 3328 | }; |
3047 | 3329 | ||
3048 | static int ata_strim(char *s, size_t len) | 3330 | static int ata_strim(char *s, size_t len) |
@@ -3057,20 +3339,12 @@ static int ata_strim(char *s, size_t len) | |||
3057 | return len; | 3339 | return len; |
3058 | } | 3340 | } |
3059 | 3341 | ||
3060 | static int ata_dma_blacklisted(const struct ata_device *dev) | 3342 | unsigned long ata_device_blacklisted(const struct ata_device *dev) |
3061 | { | 3343 | { |
3062 | unsigned char model_num[40]; | 3344 | unsigned char model_num[40]; |
3063 | unsigned char model_rev[16]; | 3345 | unsigned char model_rev[16]; |
3064 | unsigned int nlen, rlen; | 3346 | unsigned int nlen, rlen; |
3065 | int i; | 3347 | const struct ata_blacklist_entry *ad = ata_device_blacklist; |
3066 | |||
3067 | /* We don't support polling DMA. | ||
3068 | * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) | ||
3069 | * if the LLDD handles only interrupts in the HSM_ST_LAST state. | ||
3070 | */ | ||
3071 | if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) && | ||
3072 | (dev->flags & ATA_DFLAG_CDB_INTR)) | ||
3073 | return 1; | ||
3074 | 3348 | ||
3075 | ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS, | 3349 | ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS, |
3076 | sizeof(model_num)); | 3350 | sizeof(model_num)); |
@@ -3079,17 +3353,30 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
3079 | nlen = ata_strim(model_num, sizeof(model_num)); | 3353 | nlen = ata_strim(model_num, sizeof(model_num)); |
3080 | rlen = ata_strim(model_rev, sizeof(model_rev)); | 3354 | rlen = ata_strim(model_rev, sizeof(model_rev)); |
3081 | 3355 | ||
3082 | for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i += 2) { | 3356 | while (ad->model_num) { |
3083 | if (!strncmp(ata_dma_blacklist[i], model_num, nlen)) { | 3357 | if (!strncmp(ad->model_num, model_num, nlen)) { |
3084 | if (ata_dma_blacklist[i+1] == NULL) | 3358 | if (ad->model_rev == NULL) |
3085 | return 1; | 3359 | return ad->horkage; |
3086 | if (!strncmp(ata_dma_blacklist[i], model_rev, rlen)) | 3360 | if (!strncmp(ad->model_rev, model_rev, rlen)) |
3087 | return 1; | 3361 | return ad->horkage; |
3088 | } | 3362 | } |
3363 | ad++; | ||
3089 | } | 3364 | } |
3090 | return 0; | 3365 | return 0; |
3091 | } | 3366 | } |
3092 | 3367 | ||
3368 | static int ata_dma_blacklisted(const struct ata_device *dev) | ||
3369 | { | ||
3370 | /* We don't support polling DMA. | ||
3371 | * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) | ||
3372 | * if the LLDD handles only interrupts in the HSM_ST_LAST state. | ||
3373 | */ | ||
3374 | if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) && | ||
3375 | (dev->flags & ATA_DFLAG_CDB_INTR)) | ||
3376 | return 1; | ||
3377 | return (ata_device_blacklisted(dev) & ATA_HORKAGE_NODMA) ? 1 : 0; | ||
3378 | } | ||
3379 | |||
3093 | /** | 3380 | /** |
3094 | * ata_dev_xfermask - Compute supported xfermask of the given device | 3381 | * ata_dev_xfermask - Compute supported xfermask of the given device |
3095 | * @dev: Device to compute xfermask for | 3382 | * @dev: Device to compute xfermask for |
@@ -3117,6 +3404,13 @@ static void ata_dev_xfermask(struct ata_device *dev) | |||
3117 | */ | 3404 | */ |
3118 | if (ap->cbl == ATA_CBL_PATA40) | 3405 | if (ap->cbl == ATA_CBL_PATA40) |
3119 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); | 3406 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); |
3407 | /* Apply drive side cable rule. Unknown or 80 pin cables reported | ||
3408 | * host side are checked drive side as well. Cases where we know a | ||
3409 | * 40wire cable is used safely for 80 are not checked here. | ||
3410 | */ | ||
3411 | if (ata_drive_40wire(dev->id) && (ap->cbl == ATA_CBL_PATA_UNK || ap->cbl == ATA_CBL_PATA80)) | ||
3412 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); | ||
3413 | |||
3120 | 3414 | ||
3121 | xfer_mask &= ata_pack_xfermask(dev->pio_mask, | 3415 | xfer_mask &= ata_pack_xfermask(dev->pio_mask, |
3122 | dev->mwdma_mask, dev->udma_mask); | 3416 | dev->mwdma_mask, dev->udma_mask); |
@@ -3234,8 +3528,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, | |||
3234 | * LOCKING: | 3528 | * LOCKING: |
3235 | * spin_lock_irqsave(host lock) | 3529 | * spin_lock_irqsave(host lock) |
3236 | */ | 3530 | */ |
3237 | 3531 | void ata_sg_clean(struct ata_queued_cmd *qc) | |
3238 | static void ata_sg_clean(struct ata_queued_cmd *qc) | ||
3239 | { | 3532 | { |
3240 | struct ata_port *ap = qc->ap; | 3533 | struct ata_port *ap = qc->ap; |
3241 | struct scatterlist *sg = qc->__sg; | 3534 | struct scatterlist *sg = qc->__sg; |
@@ -3393,19 +3686,15 @@ void ata_noop_qc_prep(struct ata_queued_cmd *qc) { } | |||
3393 | 3686 | ||
3394 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | 3687 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) |
3395 | { | 3688 | { |
3396 | struct scatterlist *sg; | ||
3397 | |||
3398 | qc->flags |= ATA_QCFLAG_SINGLE; | 3689 | qc->flags |= ATA_QCFLAG_SINGLE; |
3399 | 3690 | ||
3400 | memset(&qc->sgent, 0, sizeof(qc->sgent)); | ||
3401 | qc->__sg = &qc->sgent; | 3691 | qc->__sg = &qc->sgent; |
3402 | qc->n_elem = 1; | 3692 | qc->n_elem = 1; |
3403 | qc->orig_n_elem = 1; | 3693 | qc->orig_n_elem = 1; |
3404 | qc->buf_virt = buf; | 3694 | qc->buf_virt = buf; |
3405 | qc->nbytes = buflen; | 3695 | qc->nbytes = buflen; |
3406 | 3696 | ||
3407 | sg = qc->__sg; | 3697 | sg_init_one(&qc->sgent, buf, buflen); |
3408 | sg_init_one(sg, buf, buflen); | ||
3409 | } | 3698 | } |
3410 | 3699 | ||
3411 | /** | 3700 | /** |
@@ -4198,8 +4487,12 @@ fsm_start: | |||
4198 | /* device stops HSM for abort/error */ | 4487 | /* device stops HSM for abort/error */ |
4199 | qc->err_mask |= AC_ERR_DEV; | 4488 | qc->err_mask |= AC_ERR_DEV; |
4200 | else | 4489 | else |
4201 | /* HSM violation. Let EH handle this */ | 4490 | /* HSM violation. Let EH handle this. |
4202 | qc->err_mask |= AC_ERR_HSM; | 4491 | * Phantom devices also trigger this |
4492 | * condition. Mark hint. | ||
4493 | */ | ||
4494 | qc->err_mask |= AC_ERR_HSM | | ||
4495 | AC_ERR_NODEV_HINT; | ||
4203 | 4496 | ||
4204 | ap->hsm_task_state = HSM_ST_ERR; | 4497 | ap->hsm_task_state = HSM_ST_ERR; |
4205 | goto fsm_start; | 4498 | goto fsm_start; |
@@ -4439,6 +4732,14 @@ void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
4439 | qc->complete_fn(qc); | 4732 | qc->complete_fn(qc); |
4440 | } | 4733 | } |
4441 | 4734 | ||
4735 | static void fill_result_tf(struct ata_queued_cmd *qc) | ||
4736 | { | ||
4737 | struct ata_port *ap = qc->ap; | ||
4738 | |||
4739 | ap->ops->tf_read(ap, &qc->result_tf); | ||
4740 | qc->result_tf.flags = qc->tf.flags; | ||
4741 | } | ||
4742 | |||
4442 | /** | 4743 | /** |
4443 | * ata_qc_complete - Complete an active ATA command | 4744 | * ata_qc_complete - Complete an active ATA command |
4444 | * @qc: Command to complete | 4745 | * @qc: Command to complete |
@@ -4476,7 +4777,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
4476 | if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) { | 4777 | if (unlikely(qc->flags & ATA_QCFLAG_FAILED)) { |
4477 | if (!ata_tag_internal(qc->tag)) { | 4778 | if (!ata_tag_internal(qc->tag)) { |
4478 | /* always fill result TF for failed qc */ | 4779 | /* always fill result TF for failed qc */ |
4479 | ap->ops->tf_read(ap, &qc->result_tf); | 4780 | fill_result_tf(qc); |
4480 | ata_qc_schedule_eh(qc); | 4781 | ata_qc_schedule_eh(qc); |
4481 | return; | 4782 | return; |
4482 | } | 4783 | } |
@@ -4484,7 +4785,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
4484 | 4785 | ||
4485 | /* read result TF if requested */ | 4786 | /* read result TF if requested */ |
4486 | if (qc->flags & ATA_QCFLAG_RESULT_TF) | 4787 | if (qc->flags & ATA_QCFLAG_RESULT_TF) |
4487 | ap->ops->tf_read(ap, &qc->result_tf); | 4788 | fill_result_tf(qc); |
4488 | 4789 | ||
4489 | __ata_qc_complete(qc); | 4790 | __ata_qc_complete(qc); |
4490 | } else { | 4791 | } else { |
@@ -4493,7 +4794,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
4493 | 4794 | ||
4494 | /* read result TF if failed or requested */ | 4795 | /* read result TF if failed or requested */ |
4495 | if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF) | 4796 | if (qc->err_mask || qc->flags & ATA_QCFLAG_RESULT_TF) |
4496 | ap->ops->tf_read(ap, &qc->result_tf); | 4797 | fill_result_tf(qc); |
4497 | 4798 | ||
4498 | __ata_qc_complete(qc); | 4799 | __ata_qc_complete(qc); |
4499 | } | 4800 | } |
@@ -4673,6 +4974,14 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4673 | } | 4974 | } |
4674 | } | 4975 | } |
4675 | 4976 | ||
4977 | /* Some controllers show flaky interrupt behavior after | ||
4978 | * setting xfer mode. Use polling instead. | ||
4979 | */ | ||
4980 | if (unlikely(qc->tf.command == ATA_CMD_SET_FEATURES && | ||
4981 | qc->tf.feature == SETFEATURES_XFER) && | ||
4982 | (ap->flags & ATA_FLAG_SETXFER_POLLING)) | ||
4983 | qc->tf.flags |= ATA_TFLAG_POLLING; | ||
4984 | |||
4676 | /* select the device */ | 4985 | /* select the device */ |
4677 | ata_dev_select(ap, qc->dev->devno, 1, 0); | 4986 | ata_dev_select(ap, qc->dev->devno, 1, 0); |
4678 | 4987 | ||
@@ -4781,6 +5090,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4781 | inline unsigned int ata_host_intr (struct ata_port *ap, | 5090 | inline unsigned int ata_host_intr (struct ata_port *ap, |
4782 | struct ata_queued_cmd *qc) | 5091 | struct ata_queued_cmd *qc) |
4783 | { | 5092 | { |
5093 | struct ata_eh_info *ehi = &ap->eh_info; | ||
4784 | u8 status, host_stat = 0; | 5094 | u8 status, host_stat = 0; |
4785 | 5095 | ||
4786 | VPRINTK("ata%u: protocol %d task_state %d\n", | 5096 | VPRINTK("ata%u: protocol %d task_state %d\n", |
@@ -4841,6 +5151,11 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
4841 | ap->ops->irq_clear(ap); | 5151 | ap->ops->irq_clear(ap); |
4842 | 5152 | ||
4843 | ata_hsm_move(ap, qc, status, 0); | 5153 | ata_hsm_move(ap, qc, status, 0); |
5154 | |||
5155 | if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA || | ||
5156 | qc->tf.protocol == ATA_PROT_ATAPI_DMA)) | ||
5157 | ata_ehi_push_desc(ehi, "BMDMA stat 0x%x", host_stat); | ||
5158 | |||
4844 | return 1; /* irq handled */ | 5159 | return 1; /* irq handled */ |
4845 | 5160 | ||
4846 | idle_irq: | 5161 | idle_irq: |
@@ -5047,7 +5362,7 @@ int ata_flush_cache(struct ata_device *dev) | |||
5047 | if (!ata_try_flush_cache(dev)) | 5362 | if (!ata_try_flush_cache(dev)) |
5048 | return 0; | 5363 | return 0; |
5049 | 5364 | ||
5050 | if (ata_id_has_flush_ext(dev->id)) | 5365 | if (dev->flags & ATA_DFLAG_FLUSH_EXT) |
5051 | cmd = ATA_CMD_FLUSH_EXT; | 5366 | cmd = ATA_CMD_FLUSH_EXT; |
5052 | else | 5367 | else |
5053 | cmd = ATA_CMD_FLUSH; | 5368 | cmd = ATA_CMD_FLUSH; |
@@ -5519,9 +5834,8 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5519 | ap->ioaddr.bmdma_addr, | 5834 | ap->ioaddr.bmdma_addr, |
5520 | irq_line); | 5835 | irq_line); |
5521 | 5836 | ||
5522 | ata_chk_status(ap); | 5837 | /* freeze port before requesting IRQ */ |
5523 | host->ops->irq_clear(ap); | 5838 | ata_eh_freeze_port(ap); |
5524 | ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */ | ||
5525 | } | 5839 | } |
5526 | 5840 | ||
5527 | /* obtain irq, that may be shared between channels */ | 5841 | /* obtain irq, that may be shared between channels */ |
@@ -6119,6 +6433,7 @@ EXPORT_SYMBOL_GPL(__sata_phy_reset); | |||
6119 | EXPORT_SYMBOL_GPL(ata_bus_reset); | 6433 | EXPORT_SYMBOL_GPL(ata_bus_reset); |
6120 | EXPORT_SYMBOL_GPL(ata_std_prereset); | 6434 | EXPORT_SYMBOL_GPL(ata_std_prereset); |
6121 | EXPORT_SYMBOL_GPL(ata_std_softreset); | 6435 | EXPORT_SYMBOL_GPL(ata_std_softreset); |
6436 | EXPORT_SYMBOL_GPL(sata_port_hardreset); | ||
6122 | EXPORT_SYMBOL_GPL(sata_std_hardreset); | 6437 | EXPORT_SYMBOL_GPL(sata_std_hardreset); |
6123 | EXPORT_SYMBOL_GPL(ata_std_postreset); | 6438 | EXPORT_SYMBOL_GPL(ata_std_postreset); |
6124 | EXPORT_SYMBOL_GPL(ata_dev_classify); | 6439 | EXPORT_SYMBOL_GPL(ata_dev_classify); |
@@ -6145,6 +6460,7 @@ EXPORT_SYMBOL_GPL(ata_host_suspend); | |||
6145 | EXPORT_SYMBOL_GPL(ata_host_resume); | 6460 | EXPORT_SYMBOL_GPL(ata_host_resume); |
6146 | EXPORT_SYMBOL_GPL(ata_id_string); | 6461 | EXPORT_SYMBOL_GPL(ata_id_string); |
6147 | EXPORT_SYMBOL_GPL(ata_id_c_string); | 6462 | EXPORT_SYMBOL_GPL(ata_id_c_string); |
6463 | EXPORT_SYMBOL_GPL(ata_device_blacklisted); | ||
6148 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 6464 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
6149 | 6465 | ||
6150 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); | 6466 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |