diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-17 22:29:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-17 22:29:32 -0500 |
commit | ededa4d396b15c282aa60d6aacddfc07f0142dbf (patch) | |
tree | dc8af166ac6f7332e5a885675dec222a0494de41 | |
parent | 64396accc2831fcbdc7d793edc25481a5ebc75b2 (diff) | |
parent | 140b5e59119a172a91b5fa13d54ca4f79bbefee1 (diff) |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
libata: fix ATAPI draining
libata: update atapi_eh_request_sense() such that lbam/lbah contains buffer size
libata-acpi: implement _GTF command filtering
libata-acpi: improve _GTF execution error handling and reporting
libata-acpi: improve ACPI disabling
libata-acpi: implement dev->gtf_cache and evaluate _GTF right after _STM during resume
libata-acpi: implement and use ata_acpi_init_gtm()
libata-acpi: add new hooks ata_acpi_dissociate() and ata_acpi_on_disable()
libata: ata_dev_disable() should be called from EH context
libata: add more opcodes to ata.h
libata: update ata_*_printk() macros such that level can be a variable
libata-acpi: adjust constness in ata_acpi_gtm/stm() parameters
sata_mv: improve warnings about Highpoint RocketRAID 23xx cards
libata: add ST3160023AS / 3.42 to NCQ blacklist
libata: clear link->eh_info.serror from ata_std_postreset()
sata_sil: fix spurious IRQ handling
-rw-r--r-- | drivers/ata/libata-acpi.c | 387 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 101 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 4 | ||||
-rw-r--r-- | drivers/ata/libata.h | 8 | ||||
-rw-r--r-- | drivers/ata/sata_mv.c | 30 | ||||
-rw-r--r-- | drivers/ata/sata_sil.c | 18 | ||||
-rw-r--r-- | include/linux/ata.h | 15 | ||||
-rw-r--r-- | include/linux/libata.h | 29 |
8 files changed, 419 insertions, 173 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 545ea865ceb5..7bf4befd96bc 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * Copyright (C) 2006 Randy Dunlap | 6 | * Copyright (C) 2006 Randy Dunlap |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/module.h> | ||
9 | #include <linux/ata.h> | 10 | #include <linux/ata.h> |
10 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
11 | #include <linux/device.h> | 12 | #include <linux/device.h> |
@@ -25,6 +26,18 @@ | |||
25 | #include <acpi/acmacros.h> | 26 | #include <acpi/acmacros.h> |
26 | #include <acpi/actypes.h> | 27 | #include <acpi/actypes.h> |
27 | 28 | ||
29 | enum { | ||
30 | ATA_ACPI_FILTER_SETXFER = 1 << 0, | ||
31 | ATA_ACPI_FILTER_LOCK = 1 << 1, | ||
32 | |||
33 | ATA_ACPI_FILTER_DEFAULT = ATA_ACPI_FILTER_SETXFER | | ||
34 | ATA_ACPI_FILTER_LOCK, | ||
35 | }; | ||
36 | |||
37 | static unsigned int ata_acpi_gtf_filter = ATA_ACPI_FILTER_DEFAULT; | ||
38 | module_param_named(acpi_gtf_filter, ata_acpi_gtf_filter, int, 0644); | ||
39 | MODULE_PARM_DESC(acpi_gtf_filter, "filter mask for ACPI _GTF commands, set to filter out (0x1=set xfermode, 0x2=lock/freeze lock)"); | ||
40 | |||
28 | #define NO_PORT_MULT 0xffff | 41 | #define NO_PORT_MULT 0xffff |
29 | #define SATA_ADR(root, pmp) (((root) << 16) | (pmp)) | 42 | #define SATA_ADR(root, pmp) (((root) << 16) | (pmp)) |
30 | 43 | ||
@@ -41,6 +54,12 @@ static int is_pci_dev(struct device *dev) | |||
41 | return (dev->bus == &pci_bus_type); | 54 | return (dev->bus == &pci_bus_type); |
42 | } | 55 | } |
43 | 56 | ||
57 | static void ata_acpi_clear_gtf(struct ata_device *dev) | ||
58 | { | ||
59 | kfree(dev->gtf_cache); | ||
60 | dev->gtf_cache = NULL; | ||
61 | } | ||
62 | |||
44 | /** | 63 | /** |
45 | * ata_acpi_associate_sata_port - associate SATA port with ACPI objects | 64 | * ata_acpi_associate_sata_port - associate SATA port with ACPI objects |
46 | * @ap: target SATA port | 65 | * @ap: target SATA port |
@@ -94,6 +113,9 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap) | |||
94 | 113 | ||
95 | dev->acpi_handle = acpi_get_child(ap->acpi_handle, i); | 114 | dev->acpi_handle = acpi_get_child(ap->acpi_handle, i); |
96 | } | 115 | } |
116 | |||
117 | if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0) | ||
118 | ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; | ||
97 | } | 119 | } |
98 | 120 | ||
99 | static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, | 121 | static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, |
@@ -188,6 +210,32 @@ void ata_acpi_associate(struct ata_host *host) | |||
188 | } | 210 | } |
189 | 211 | ||
190 | /** | 212 | /** |
213 | * ata_acpi_dissociate - dissociate ATA host from ACPI objects | ||
214 | * @host: target ATA host | ||
215 | * | ||
216 | * This function is called during driver detach after the whole host | ||
217 | * is shut down. | ||
218 | * | ||
219 | * LOCKING: | ||
220 | * EH context. | ||
221 | */ | ||
222 | void ata_acpi_dissociate(struct ata_host *host) | ||
223 | { | ||
224 | int i; | ||
225 | |||
226 | /* Restore initial _GTM values so that driver which attaches | ||
227 | * afterward can use them too. | ||
228 | */ | ||
229 | for (i = 0; i < host->n_ports; i++) { | ||
230 | struct ata_port *ap = host->ports[i]; | ||
231 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); | ||
232 | |||
233 | if (ap->acpi_handle && gtm) | ||
234 | ata_acpi_stm(ap, gtm); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | /** | ||
191 | * ata_acpi_gtm - execute _GTM | 239 | * ata_acpi_gtm - execute _GTM |
192 | * @ap: target ATA port | 240 | * @ap: target ATA port |
193 | * @gtm: out parameter for _GTM result | 241 | * @gtm: out parameter for _GTM result |
@@ -200,7 +248,7 @@ void ata_acpi_associate(struct ata_host *host) | |||
200 | * RETURNS: | 248 | * RETURNS: |
201 | * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. | 249 | * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure. |
202 | */ | 250 | */ |
203 | int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *gtm) | 251 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm) |
204 | { | 252 | { |
205 | struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; | 253 | struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER }; |
206 | union acpi_object *out_obj; | 254 | union acpi_object *out_obj; |
@@ -259,15 +307,16 @@ EXPORT_SYMBOL_GPL(ata_acpi_gtm); | |||
259 | * RETURNS: | 307 | * RETURNS: |
260 | * 0 on success, -ENOENT if _STM doesn't exist, -errno on failure. | 308 | * 0 on success, -ENOENT if _STM doesn't exist, -errno on failure. |
261 | */ | 309 | */ |
262 | int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm) | 310 | int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm) |
263 | { | 311 | { |
264 | acpi_status status; | 312 | acpi_status status; |
313 | struct ata_acpi_gtm stm_buf = *stm; | ||
265 | struct acpi_object_list input; | 314 | struct acpi_object_list input; |
266 | union acpi_object in_params[3]; | 315 | union acpi_object in_params[3]; |
267 | 316 | ||
268 | in_params[0].type = ACPI_TYPE_BUFFER; | 317 | in_params[0].type = ACPI_TYPE_BUFFER; |
269 | in_params[0].buffer.length = sizeof(struct ata_acpi_gtm); | 318 | in_params[0].buffer.length = sizeof(struct ata_acpi_gtm); |
270 | in_params[0].buffer.pointer = (u8 *)stm; | 319 | in_params[0].buffer.pointer = (u8 *)&stm_buf; |
271 | /* Buffers for id may need byteswapping ? */ | 320 | /* Buffers for id may need byteswapping ? */ |
272 | in_params[1].type = ACPI_TYPE_BUFFER; | 321 | in_params[1].type = ACPI_TYPE_BUFFER; |
273 | in_params[1].buffer.length = 512; | 322 | in_params[1].buffer.length = 512; |
@@ -297,7 +346,6 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm); | |||
297 | * ata_dev_get_GTF - get the drive bootup default taskfile settings | 346 | * ata_dev_get_GTF - get the drive bootup default taskfile settings |
298 | * @dev: target ATA device | 347 | * @dev: target ATA device |
299 | * @gtf: output parameter for buffer containing _GTF taskfile arrays | 348 | * @gtf: output parameter for buffer containing _GTF taskfile arrays |
300 | * @ptr_to_free: pointer which should be freed | ||
301 | * | 349 | * |
302 | * This applies to both PATA and SATA drives. | 350 | * This applies to both PATA and SATA drives. |
303 | * | 351 | * |
@@ -311,11 +359,10 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm); | |||
311 | * EH context. | 359 | * EH context. |
312 | * | 360 | * |
313 | * RETURNS: | 361 | * RETURNS: |
314 | * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't | 362 | * Number of taskfiles on success, 0 if _GTF doesn't exist. -EINVAL |
315 | * contain valid data. | 363 | * if _GTF is invalid. |
316 | */ | 364 | */ |
317 | static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | 365 | static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf) |
318 | void **ptr_to_free) | ||
319 | { | 366 | { |
320 | struct ata_port *ap = dev->link->ap; | 367 | struct ata_port *ap = dev->link->ap; |
321 | acpi_status status; | 368 | acpi_status status; |
@@ -323,6 +370,12 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | |||
323 | union acpi_object *out_obj; | 370 | union acpi_object *out_obj; |
324 | int rc = 0; | 371 | int rc = 0; |
325 | 372 | ||
373 | /* if _GTF is cached, use the cached value */ | ||
374 | if (dev->gtf_cache) { | ||
375 | out_obj = dev->gtf_cache; | ||
376 | goto done; | ||
377 | } | ||
378 | |||
326 | /* set up output buffer */ | 379 | /* set up output buffer */ |
327 | output.length = ACPI_ALLOCATE_BUFFER; | 380 | output.length = ACPI_ALLOCATE_BUFFER; |
328 | output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ | 381 | output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ |
@@ -333,12 +386,14 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | |||
333 | 386 | ||
334 | /* _GTF has no input parameters */ | 387 | /* _GTF has no input parameters */ |
335 | status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); | 388 | status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); |
389 | out_obj = dev->gtf_cache = output.pointer; | ||
336 | 390 | ||
337 | if (ACPI_FAILURE(status)) { | 391 | if (ACPI_FAILURE(status)) { |
338 | if (status != AE_NOT_FOUND) { | 392 | if (status != AE_NOT_FOUND) { |
339 | ata_dev_printk(dev, KERN_WARNING, | 393 | ata_dev_printk(dev, KERN_WARNING, |
340 | "_GTF evaluation failed (AE 0x%x)\n", | 394 | "_GTF evaluation failed (AE 0x%x)\n", |
341 | status); | 395 | status); |
396 | rc = -EINVAL; | ||
342 | } | 397 | } |
343 | goto out_free; | 398 | goto out_free; |
344 | } | 399 | } |
@@ -350,14 +405,15 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | |||
350 | __FUNCTION__, | 405 | __FUNCTION__, |
351 | (unsigned long long)output.length, | 406 | (unsigned long long)output.length, |
352 | output.pointer); | 407 | output.pointer); |
408 | rc = -EINVAL; | ||
353 | goto out_free; | 409 | goto out_free; |
354 | } | 410 | } |
355 | 411 | ||
356 | out_obj = output.pointer; | ||
357 | if (out_obj->type != ACPI_TYPE_BUFFER) { | 412 | if (out_obj->type != ACPI_TYPE_BUFFER) { |
358 | ata_dev_printk(dev, KERN_WARNING, | 413 | ata_dev_printk(dev, KERN_WARNING, |
359 | "_GTF unexpected object type 0x%x\n", | 414 | "_GTF unexpected object type 0x%x\n", |
360 | out_obj->type); | 415 | out_obj->type); |
416 | rc = -EINVAL; | ||
361 | goto out_free; | 417 | goto out_free; |
362 | } | 418 | } |
363 | 419 | ||
@@ -365,21 +421,23 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | |||
365 | ata_dev_printk(dev, KERN_WARNING, | 421 | ata_dev_printk(dev, KERN_WARNING, |
366 | "unexpected _GTF length (%d)\n", | 422 | "unexpected _GTF length (%d)\n", |
367 | out_obj->buffer.length); | 423 | out_obj->buffer.length); |
424 | rc = -EINVAL; | ||
368 | goto out_free; | 425 | goto out_free; |
369 | } | 426 | } |
370 | 427 | ||
371 | *ptr_to_free = out_obj; | 428 | done: |
372 | *gtf = (void *)out_obj->buffer.pointer; | ||
373 | rc = out_obj->buffer.length / REGS_PER_GTF; | 429 | rc = out_obj->buffer.length / REGS_PER_GTF; |
374 | 430 | if (gtf) { | |
375 | if (ata_msg_probe(ap)) | 431 | *gtf = (void *)out_obj->buffer.pointer; |
376 | ata_dev_printk(dev, KERN_DEBUG, "%s: returning " | 432 | if (ata_msg_probe(ap)) |
377 | "gtf=%p, gtf_count=%d, ptr_to_free=%p\n", | 433 | ata_dev_printk(dev, KERN_DEBUG, |
378 | __FUNCTION__, *gtf, rc, *ptr_to_free); | 434 | "%s: returning gtf=%p, gtf_count=%d\n", |
435 | __FUNCTION__, *gtf, rc); | ||
436 | } | ||
379 | return rc; | 437 | return rc; |
380 | 438 | ||
381 | out_free: | 439 | out_free: |
382 | kfree(output.pointer); | 440 | ata_acpi_clear_gtf(dev); |
383 | return rc; | 441 | return rc; |
384 | } | 442 | } |
385 | 443 | ||
@@ -393,22 +451,21 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, | |||
393 | 451 | ||
394 | int ata_acpi_cbl_80wire(struct ata_port *ap) | 452 | int ata_acpi_cbl_80wire(struct ata_port *ap) |
395 | { | 453 | { |
396 | struct ata_acpi_gtm gtm; | 454 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); |
397 | int valid = 0; | 455 | int valid = 0; |
398 | 456 | ||
399 | /* No _GTM data, no information */ | 457 | if (!gtm) |
400 | if (ata_acpi_gtm(ap, >m) < 0) | ||
401 | return 0; | 458 | return 0; |
402 | 459 | ||
403 | /* Split timing, DMA enabled */ | 460 | /* Split timing, DMA enabled */ |
404 | if ((gtm.flags & 0x11) == 0x11 && gtm.drive[0].dma < 55) | 461 | if ((gtm->flags & 0x11) == 0x11 && gtm->drive[0].dma < 55) |
405 | valid |= 1; | 462 | valid |= 1; |
406 | if ((gtm.flags & 0x14) == 0x14 && gtm.drive[1].dma < 55) | 463 | if ((gtm->flags & 0x14) == 0x14 && gtm->drive[1].dma < 55) |
407 | valid |= 2; | 464 | valid |= 2; |
408 | /* Shared timing, DMA enabled */ | 465 | /* Shared timing, DMA enabled */ |
409 | if ((gtm.flags & 0x11) == 0x01 && gtm.drive[0].dma < 55) | 466 | if ((gtm->flags & 0x11) == 0x01 && gtm->drive[0].dma < 55) |
410 | valid |= 1; | 467 | valid |= 1; |
411 | if ((gtm.flags & 0x14) == 0x04 && gtm.drive[0].dma < 55) | 468 | if ((gtm->flags & 0x14) == 0x04 && gtm->drive[0].dma < 55) |
412 | valid |= 2; | 469 | valid |= 2; |
413 | 470 | ||
414 | /* Drive check */ | 471 | /* Drive check */ |
@@ -421,8 +478,62 @@ int ata_acpi_cbl_80wire(struct ata_port *ap) | |||
421 | 478 | ||
422 | EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); | 479 | EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); |
423 | 480 | ||
481 | static void ata_acpi_gtf_to_tf(struct ata_device *dev, | ||
482 | const struct ata_acpi_gtf *gtf, | ||
483 | struct ata_taskfile *tf) | ||
484 | { | ||
485 | ata_tf_init(dev, tf); | ||
486 | |||
487 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
488 | tf->protocol = ATA_PROT_NODATA; | ||
489 | tf->feature = gtf->tf[0]; /* 0x1f1 */ | ||
490 | tf->nsect = gtf->tf[1]; /* 0x1f2 */ | ||
491 | tf->lbal = gtf->tf[2]; /* 0x1f3 */ | ||
492 | tf->lbam = gtf->tf[3]; /* 0x1f4 */ | ||
493 | tf->lbah = gtf->tf[4]; /* 0x1f5 */ | ||
494 | tf->device = gtf->tf[5]; /* 0x1f6 */ | ||
495 | tf->command = gtf->tf[6]; /* 0x1f7 */ | ||
496 | } | ||
497 | |||
498 | static int ata_acpi_filter_tf(const struct ata_taskfile *tf, | ||
499 | const struct ata_taskfile *ptf) | ||
500 | { | ||
501 | if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_SETXFER) { | ||
502 | /* libata doesn't use ACPI to configure transfer mode. | ||
503 | * It will only confuse device configuration. Skip. | ||
504 | */ | ||
505 | if (tf->command == ATA_CMD_SET_FEATURES && | ||
506 | tf->feature == SETFEATURES_XFER) | ||
507 | return 1; | ||
508 | } | ||
509 | |||
510 | if (ata_acpi_gtf_filter & ATA_ACPI_FILTER_LOCK) { | ||
511 | /* BIOS writers, sorry but we don't wanna lock | ||
512 | * features unless the user explicitly said so. | ||
513 | */ | ||
514 | |||
515 | /* DEVICE CONFIGURATION FREEZE LOCK */ | ||
516 | if (tf->command == ATA_CMD_CONF_OVERLAY && | ||
517 | tf->feature == ATA_DCO_FREEZE_LOCK) | ||
518 | return 1; | ||
519 | |||
520 | /* SECURITY FREEZE LOCK */ | ||
521 | if (tf->command == ATA_CMD_SEC_FREEZE_LOCK) | ||
522 | return 1; | ||
523 | |||
524 | /* SET MAX LOCK and SET MAX FREEZE LOCK */ | ||
525 | if ((!ptf || ptf->command != ATA_CMD_READ_NATIVE_MAX) && | ||
526 | tf->command == ATA_CMD_SET_MAX && | ||
527 | (tf->feature == ATA_SET_MAX_LOCK || | ||
528 | tf->feature == ATA_SET_MAX_FREEZE_LOCK)) | ||
529 | return 1; | ||
530 | } | ||
531 | |||
532 | return 0; | ||
533 | } | ||
534 | |||
424 | /** | 535 | /** |
425 | * taskfile_load_raw - send taskfile registers to host controller | 536 | * ata_acpi_run_tf - send taskfile registers to host controller |
426 | * @dev: target ATA device | 537 | * @dev: target ATA device |
427 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) | 538 | * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) |
428 | * | 539 | * |
@@ -441,56 +552,77 @@ EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); | |||
441 | * EH context. | 552 | * EH context. |
442 | * | 553 | * |
443 | * RETURNS: | 554 | * RETURNS: |
444 | * 0 on success, -errno on failure. | 555 | * 1 if command is executed successfully. 0 if ignored, rejected or |
556 | * filtered out, -errno on other errors. | ||
445 | */ | 557 | */ |
446 | static int taskfile_load_raw(struct ata_device *dev, | 558 | static int ata_acpi_run_tf(struct ata_device *dev, |
447 | const struct ata_acpi_gtf *gtf) | 559 | const struct ata_acpi_gtf *gtf, |
560 | const struct ata_acpi_gtf *prev_gtf) | ||
448 | { | 561 | { |
449 | struct ata_port *ap = dev->link->ap; | 562 | struct ata_taskfile *pptf = NULL; |
450 | struct ata_taskfile tf, rtf; | 563 | struct ata_taskfile tf, ptf, rtf; |
451 | unsigned int err_mask; | 564 | unsigned int err_mask; |
565 | const char *level; | ||
566 | char msg[60]; | ||
567 | int rc; | ||
452 | 568 | ||
453 | if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0) | 569 | if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0) |
454 | && (gtf->tf[3] == 0) && (gtf->tf[4] == 0) && (gtf->tf[5] == 0) | 570 | && (gtf->tf[3] == 0) && (gtf->tf[4] == 0) && (gtf->tf[5] == 0) |
455 | && (gtf->tf[6] == 0)) | 571 | && (gtf->tf[6] == 0)) |
456 | return 0; | 572 | return 0; |
457 | 573 | ||
458 | ata_tf_init(dev, &tf); | 574 | ata_acpi_gtf_to_tf(dev, gtf, &tf); |
575 | if (prev_gtf) { | ||
576 | ata_acpi_gtf_to_tf(dev, prev_gtf, &ptf); | ||
577 | pptf = &ptf; | ||
578 | } | ||
459 | 579 | ||
460 | /* convert gtf to tf */ | 580 | if (!ata_acpi_filter_tf(&tf, pptf)) { |
461 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ | 581 | rtf = tf; |
462 | tf.protocol = ATA_PROT_NODATA; | 582 | err_mask = ata_exec_internal(dev, &rtf, NULL, |
463 | tf.feature = gtf->tf[0]; /* 0x1f1 */ | 583 | DMA_NONE, NULL, 0, 0); |
464 | tf.nsect = gtf->tf[1]; /* 0x1f2 */ | ||
465 | tf.lbal = gtf->tf[2]; /* 0x1f3 */ | ||
466 | tf.lbam = gtf->tf[3]; /* 0x1f4 */ | ||
467 | tf.lbah = gtf->tf[4]; /* 0x1f5 */ | ||
468 | tf.device = gtf->tf[5]; /* 0x1f6 */ | ||
469 | tf.command = gtf->tf[6]; /* 0x1f7 */ | ||
470 | 584 | ||
471 | if (ata_msg_probe(ap)) | 585 | switch (err_mask) { |
472 | ata_dev_printk(dev, KERN_DEBUG, "executing ACPI cmd " | 586 | case 0: |
473 | "%02x/%02x:%02x:%02x:%02x:%02x:%02x\n", | 587 | level = KERN_DEBUG; |
474 | tf.command, tf.feature, tf.nsect, | 588 | snprintf(msg, sizeof(msg), "succeeded"); |
475 | tf.lbal, tf.lbam, tf.lbah, tf.device); | 589 | rc = 1; |
476 | 590 | break; | |
477 | rtf = tf; | 591 | |
478 | err_mask = ata_exec_internal(dev, &rtf, NULL, DMA_NONE, NULL, 0, 0); | 592 | case AC_ERR_DEV: |
479 | if (err_mask) { | 593 | level = KERN_INFO; |
480 | ata_dev_printk(dev, KERN_ERR, | 594 | snprintf(msg, sizeof(msg), |
481 | "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x failed " | 595 | "rejected by device (Stat=0x%02x Err=0x%02x)", |
482 | "(Emask=0x%x Stat=0x%02x Err=0x%02x)\n", | 596 | rtf.command, rtf.feature); |
483 | tf.command, tf.feature, tf.nsect, tf.lbal, tf.lbam, | 597 | rc = 0; |
484 | tf.lbah, tf.device, err_mask, rtf.command, rtf.feature); | 598 | break; |
485 | return -EIO; | 599 | |
600 | default: | ||
601 | level = KERN_ERR; | ||
602 | snprintf(msg, sizeof(msg), | ||
603 | "failed (Emask=0x%x Stat=0x%02x Err=0x%02x)", | ||
604 | err_mask, rtf.command, rtf.feature); | ||
605 | rc = -EIO; | ||
606 | break; | ||
607 | } | ||
608 | } else { | ||
609 | level = KERN_INFO; | ||
610 | snprintf(msg, sizeof(msg), "filtered out"); | ||
611 | rc = 0; | ||
486 | } | 612 | } |
487 | 613 | ||
488 | return 0; | 614 | ata_dev_printk(dev, level, |
615 | "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x %s\n", | ||
616 | tf.command, tf.feature, tf.nsect, tf.lbal, | ||
617 | tf.lbam, tf.lbah, tf.device, msg); | ||
618 | |||
619 | return rc; | ||
489 | } | 620 | } |
490 | 621 | ||
491 | /** | 622 | /** |
492 | * ata_acpi_exec_tfs - get then write drive taskfile settings | 623 | * ata_acpi_exec_tfs - get then write drive taskfile settings |
493 | * @dev: target ATA device | 624 | * @dev: target ATA device |
625 | * @nr_executed: out paramter for the number of executed commands | ||
494 | * | 626 | * |
495 | * Evaluate _GTF and excute returned taskfiles. | 627 | * Evaluate _GTF and excute returned taskfiles. |
496 | * | 628 | * |
@@ -498,35 +630,36 @@ static int taskfile_load_raw(struct ata_device *dev, | |||
498 | * EH context. | 630 | * EH context. |
499 | * | 631 | * |
500 | * RETURNS: | 632 | * RETURNS: |
501 | * Number of executed taskfiles on success, 0 if _GTF doesn't exist or | 633 | * Number of executed taskfiles on success, 0 if _GTF doesn't exist. |
502 | * doesn't contain valid data. -errno on other errors. | 634 | * -errno on other errors. |
503 | */ | 635 | */ |
504 | static int ata_acpi_exec_tfs(struct ata_device *dev) | 636 | static int ata_acpi_exec_tfs(struct ata_device *dev, int *nr_executed) |
505 | { | 637 | { |
506 | struct ata_acpi_gtf *gtf = NULL; | 638 | struct ata_acpi_gtf *gtf = NULL, *pgtf = NULL; |
507 | void *ptr_to_free = NULL; | ||
508 | int gtf_count, i, rc; | 639 | int gtf_count, i, rc; |
509 | 640 | ||
510 | /* get taskfiles */ | 641 | /* get taskfiles */ |
511 | gtf_count = ata_dev_get_GTF(dev, >f, &ptr_to_free); | 642 | rc = ata_dev_get_GTF(dev, >f); |
643 | if (rc < 0) | ||
644 | return rc; | ||
645 | gtf_count = rc; | ||
512 | 646 | ||
513 | /* execute them */ | 647 | /* execute them */ |
514 | for (i = 0, rc = 0; i < gtf_count; i++) { | 648 | for (i = 0; i < gtf_count; i++, gtf++) { |
515 | int tmp; | 649 | rc = ata_acpi_run_tf(dev, gtf, pgtf); |
516 | 650 | if (rc < 0) | |
517 | /* ACPI errors are eventually ignored. Run till the | 651 | break; |
518 | * end even after errors. | 652 | if (rc) { |
519 | */ | 653 | (*nr_executed)++; |
520 | tmp = taskfile_load_raw(dev, gtf++); | 654 | pgtf = gtf; |
521 | if (!rc) | 655 | } |
522 | rc = tmp; | ||
523 | } | 656 | } |
524 | 657 | ||
525 | kfree(ptr_to_free); | 658 | ata_acpi_clear_gtf(dev); |
526 | 659 | ||
527 | if (rc == 0) | 660 | if (rc < 0) |
528 | return gtf_count; | 661 | return rc; |
529 | return rc; | 662 | return 0; |
530 | } | 663 | } |
531 | 664 | ||
532 | /** | 665 | /** |
@@ -596,27 +729,8 @@ static int ata_acpi_push_id(struct ata_device *dev) | |||
596 | */ | 729 | */ |
597 | int ata_acpi_on_suspend(struct ata_port *ap) | 730 | int ata_acpi_on_suspend(struct ata_port *ap) |
598 | { | 731 | { |
599 | unsigned long flags; | 732 | /* nada */ |
600 | int rc; | 733 | return 0; |
601 | |||
602 | /* proceed iff per-port acpi_handle is valid */ | ||
603 | if (!ap->acpi_handle) | ||
604 | return 0; | ||
605 | BUG_ON(ap->flags & ATA_FLAG_ACPI_SATA); | ||
606 | |||
607 | /* store timing parameters */ | ||
608 | rc = ata_acpi_gtm(ap, &ap->acpi_gtm); | ||
609 | |||
610 | spin_lock_irqsave(ap->lock, flags); | ||
611 | if (rc == 0) | ||
612 | ap->pflags |= ATA_PFLAG_GTM_VALID; | ||
613 | else | ||
614 | ap->pflags &= ~ATA_PFLAG_GTM_VALID; | ||
615 | spin_unlock_irqrestore(ap->lock, flags); | ||
616 | |||
617 | if (rc == -ENOENT) | ||
618 | rc = 0; | ||
619 | return rc; | ||
620 | } | 734 | } |
621 | 735 | ||
622 | /** | 736 | /** |
@@ -631,18 +745,34 @@ int ata_acpi_on_suspend(struct ata_port *ap) | |||
631 | */ | 745 | */ |
632 | void ata_acpi_on_resume(struct ata_port *ap) | 746 | void ata_acpi_on_resume(struct ata_port *ap) |
633 | { | 747 | { |
748 | const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); | ||
634 | struct ata_device *dev; | 749 | struct ata_device *dev; |
635 | 750 | ||
636 | if (ap->acpi_handle && (ap->pflags & ATA_PFLAG_GTM_VALID)) { | 751 | if (ap->acpi_handle && gtm) { |
637 | BUG_ON(ap->flags & ATA_FLAG_ACPI_SATA); | 752 | /* _GTM valid */ |
638 | 753 | ||
639 | /* restore timing parameters */ | 754 | /* restore timing parameters */ |
640 | ata_acpi_stm(ap, &ap->acpi_gtm); | 755 | ata_acpi_stm(ap, gtm); |
641 | } | ||
642 | 756 | ||
643 | /* schedule _GTF */ | 757 | /* _GTF should immediately follow _STM so that it can |
644 | ata_link_for_each_dev(dev, &ap->link) | 758 | * use values set by _STM. Cache _GTF result and |
645 | dev->flags |= ATA_DFLAG_ACPI_PENDING; | 759 | * schedule _GTF. |
760 | */ | ||
761 | ata_link_for_each_dev(dev, &ap->link) { | ||
762 | ata_acpi_clear_gtf(dev); | ||
763 | if (ata_dev_get_GTF(dev, NULL) >= 0) | ||
764 | dev->flags |= ATA_DFLAG_ACPI_PENDING; | ||
765 | } | ||
766 | } else { | ||
767 | /* SATA _GTF needs to be evaulated after _SDD and | ||
768 | * there's no reason to evaluate IDE _GTF early | ||
769 | * without _STM. Clear cache and schedule _GTF. | ||
770 | */ | ||
771 | ata_link_for_each_dev(dev, &ap->link) { | ||
772 | ata_acpi_clear_gtf(dev); | ||
773 | dev->flags |= ATA_DFLAG_ACPI_PENDING; | ||
774 | } | ||
775 | } | ||
646 | } | 776 | } |
647 | 777 | ||
648 | /** | 778 | /** |
@@ -664,6 +794,7 @@ int ata_acpi_on_devcfg(struct ata_device *dev) | |||
664 | struct ata_port *ap = dev->link->ap; | 794 | struct ata_port *ap = dev->link->ap; |
665 | struct ata_eh_context *ehc = &ap->link.eh_context; | 795 | struct ata_eh_context *ehc = &ap->link.eh_context; |
666 | int acpi_sata = ap->flags & ATA_FLAG_ACPI_SATA; | 796 | int acpi_sata = ap->flags & ATA_FLAG_ACPI_SATA; |
797 | int nr_executed = 0; | ||
667 | int rc; | 798 | int rc; |
668 | 799 | ||
669 | if (!dev->acpi_handle) | 800 | if (!dev->acpi_handle) |
@@ -682,14 +813,14 @@ int ata_acpi_on_devcfg(struct ata_device *dev) | |||
682 | } | 813 | } |
683 | 814 | ||
684 | /* do _GTF */ | 815 | /* do _GTF */ |
685 | rc = ata_acpi_exec_tfs(dev); | 816 | rc = ata_acpi_exec_tfs(dev, &nr_executed); |
686 | if (rc < 0) | 817 | if (rc) |
687 | goto acpi_err; | 818 | goto acpi_err; |
688 | 819 | ||
689 | dev->flags &= ~ATA_DFLAG_ACPI_PENDING; | 820 | dev->flags &= ~ATA_DFLAG_ACPI_PENDING; |
690 | 821 | ||
691 | /* refresh IDENTIFY page if any _GTF command has been executed */ | 822 | /* refresh IDENTIFY page if any _GTF command has been executed */ |
692 | if (rc > 0) { | 823 | if (nr_executed) { |
693 | rc = ata_dev_reread_id(dev, 0); | 824 | rc = ata_dev_reread_id(dev, 0); |
694 | if (rc < 0) { | 825 | if (rc < 0) { |
695 | ata_dev_printk(dev, KERN_ERR, "failed to IDENTIFY " | 826 | ata_dev_printk(dev, KERN_ERR, "failed to IDENTIFY " |
@@ -701,17 +832,39 @@ int ata_acpi_on_devcfg(struct ata_device *dev) | |||
701 | return 0; | 832 | return 0; |
702 | 833 | ||
703 | acpi_err: | 834 | acpi_err: |
704 | /* let EH retry on the first failure, disable ACPI on the second */ | 835 | /* ignore evaluation failure if we can continue safely */ |
705 | if (dev->flags & ATA_DFLAG_ACPI_FAILED) { | 836 | if (rc == -EINVAL && !nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) |
706 | ata_dev_printk(dev, KERN_WARNING, "ACPI on devcfg failed the " | 837 | return 0; |
707 | "second time, disabling (errno=%d)\n", rc); | ||
708 | |||
709 | dev->acpi_handle = NULL; | ||
710 | 838 | ||
711 | /* if port is working, request IDENTIFY reload and continue */ | 839 | /* fail and let EH retry once more for unknown IO errors */ |
712 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) | 840 | if (!(dev->flags & ATA_DFLAG_ACPI_FAILED)) { |
713 | rc = 1; | 841 | dev->flags |= ATA_DFLAG_ACPI_FAILED; |
842 | return rc; | ||
714 | } | 843 | } |
715 | dev->flags |= ATA_DFLAG_ACPI_FAILED; | 844 | |
845 | ata_dev_printk(dev, KERN_WARNING, | ||
846 | "ACPI: failed the second time, disabled\n"); | ||
847 | dev->acpi_handle = NULL; | ||
848 | |||
849 | /* We can safely continue if no _GTF command has been executed | ||
850 | * and port is not frozen. | ||
851 | */ | ||
852 | if (!nr_executed && !(ap->pflags & ATA_PFLAG_FROZEN)) | ||
853 | return 0; | ||
854 | |||
716 | return rc; | 855 | return rc; |
717 | } | 856 | } |
857 | |||
858 | /** | ||
859 | * ata_acpi_on_disable - ATA ACPI hook called when a device is disabled | ||
860 | * @dev: target ATA device | ||
861 | * | ||
862 | * This function is called when @dev is about to be disabled. | ||
863 | * | ||
864 | * LOCKING: | ||
865 | * EH context. | ||
866 | */ | ||
867 | void ata_acpi_on_disable(struct ata_device *dev) | ||
868 | { | ||
869 | ata_acpi_clear_gtf(dev); | ||
870 | } | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index e4dea8623a71..4753a1831dbc 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include <linux/libata.h> | 64 | #include <linux/libata.h> |
65 | #include <asm/semaphore.h> | 65 | #include <asm/semaphore.h> |
66 | #include <asm/byteorder.h> | 66 | #include <asm/byteorder.h> |
67 | #include <linux/cdrom.h> | ||
67 | 68 | ||
68 | #include "libata.h" | 69 | #include "libata.h" |
69 | 70 | ||
@@ -622,6 +623,7 @@ void ata_dev_disable(struct ata_device *dev) | |||
622 | if (ata_dev_enabled(dev)) { | 623 | if (ata_dev_enabled(dev)) { |
623 | if (ata_msg_drv(dev->link->ap)) | 624 | if (ata_msg_drv(dev->link->ap)) |
624 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); | 625 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); |
626 | ata_acpi_on_disable(dev); | ||
625 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | | 627 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | |
626 | ATA_DNXFER_QUIET); | 628 | ATA_DNXFER_QUIET); |
627 | dev->class++; | 629 | dev->class++; |
@@ -3923,6 +3925,7 @@ void ata_std_postreset(struct ata_link *link, unsigned int *classes) | |||
3923 | /* clear SError */ | 3925 | /* clear SError */ |
3924 | if (sata_scr_read(link, SCR_ERROR, &serror) == 0) | 3926 | if (sata_scr_read(link, SCR_ERROR, &serror) == 0) |
3925 | sata_scr_write(link, SCR_ERROR, serror); | 3927 | sata_scr_write(link, SCR_ERROR, serror); |
3928 | link->eh_info.serror = 0; | ||
3926 | 3929 | ||
3927 | /* is double-select really necessary? */ | 3930 | /* is double-select really necessary? */ |
3928 | if (classes[0] != ATA_DEV_NONE) | 3931 | if (classes[0] != ATA_DEV_NONE) |
@@ -4149,6 +4152,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4149 | { "HITACHI HDS7250SASUN500G*", NULL, ATA_HORKAGE_NONCQ }, | 4152 | { "HITACHI HDS7250SASUN500G*", NULL, ATA_HORKAGE_NONCQ }, |
4150 | { "HITACHI HDS7225SBSUN250G*", NULL, ATA_HORKAGE_NONCQ }, | 4153 | { "HITACHI HDS7225SBSUN250G*", NULL, ATA_HORKAGE_NONCQ }, |
4151 | { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ }, | 4154 | { "ST380817AS", "3.42", ATA_HORKAGE_NONCQ }, |
4155 | { "ST3160023AS", "3.42", ATA_HORKAGE_NONCQ }, | ||
4152 | 4156 | ||
4153 | /* Blacklist entries taken from Silicon Image 3124/3132 | 4157 | /* Blacklist entries taken from Silicon Image 3124/3132 |
4154 | Windows driver .inf file - also several Linux problem reports */ | 4158 | Windows driver .inf file - also several Linux problem reports */ |
@@ -4649,6 +4653,43 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
4649 | } | 4653 | } |
4650 | 4654 | ||
4651 | /** | 4655 | /** |
4656 | * atapi_qc_may_overflow - Check whether data transfer may overflow | ||
4657 | * @qc: ATA command in question | ||
4658 | * | ||
4659 | * ATAPI commands which transfer variable length data to host | ||
4660 | * might overflow due to application error or hardare bug. This | ||
4661 | * function checks whether overflow should be drained and ignored | ||
4662 | * for @qc. | ||
4663 | * | ||
4664 | * LOCKING: | ||
4665 | * None. | ||
4666 | * | ||
4667 | * RETURNS: | ||
4668 | * 1 if @qc may overflow; otherwise, 0. | ||
4669 | */ | ||
4670 | static int atapi_qc_may_overflow(struct ata_queued_cmd *qc) | ||
4671 | { | ||
4672 | if (qc->tf.protocol != ATA_PROT_ATAPI && | ||
4673 | qc->tf.protocol != ATA_PROT_ATAPI_DMA) | ||
4674 | return 0; | ||
4675 | |||
4676 | if (qc->tf.flags & ATA_TFLAG_WRITE) | ||
4677 | return 0; | ||
4678 | |||
4679 | switch (qc->cdb[0]) { | ||
4680 | case READ_10: | ||
4681 | case READ_12: | ||
4682 | case WRITE_10: | ||
4683 | case WRITE_12: | ||
4684 | case GPCMD_READ_CD: | ||
4685 | case GPCMD_READ_CD_MSF: | ||
4686 | return 0; | ||
4687 | } | ||
4688 | |||
4689 | return 1; | ||
4690 | } | ||
4691 | |||
4692 | /** | ||
4652 | * ata_std_qc_defer - Check whether a qc needs to be deferred | 4693 | * ata_std_qc_defer - Check whether a qc needs to be deferred |
4653 | * @qc: ATA command in question | 4694 | * @qc: ATA command in question |
4654 | * | 4695 | * |
@@ -5136,23 +5177,19 @@ static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
5136 | * Inherited from caller. | 5177 | * Inherited from caller. |
5137 | * | 5178 | * |
5138 | */ | 5179 | */ |
5139 | 5180 | static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) | |
5140 | static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) | ||
5141 | { | 5181 | { |
5142 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | 5182 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); |
5143 | struct scatterlist *sg = qc->__sg; | ||
5144 | struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem); | ||
5145 | struct ata_port *ap = qc->ap; | 5183 | struct ata_port *ap = qc->ap; |
5184 | struct ata_eh_info *ehi = &qc->dev->link->eh_info; | ||
5185 | struct scatterlist *sg; | ||
5146 | struct page *page; | 5186 | struct page *page; |
5147 | unsigned char *buf; | 5187 | unsigned char *buf; |
5148 | unsigned int offset, count; | 5188 | unsigned int offset, count; |
5149 | int no_more_sg = 0; | ||
5150 | |||
5151 | if (qc->curbytes + bytes >= qc->nbytes) | ||
5152 | ap->hsm_task_state = HSM_ST_LAST; | ||
5153 | 5189 | ||
5154 | next_sg: | 5190 | next_sg: |
5155 | if (unlikely(no_more_sg)) { | 5191 | sg = qc->cursg; |
5192 | if (unlikely(!sg)) { | ||
5156 | /* | 5193 | /* |
5157 | * The end of qc->sg is reached and the device expects | 5194 | * The end of qc->sg is reached and the device expects |
5158 | * more data to transfer. In order not to overrun qc->sg | 5195 | * more data to transfer. In order not to overrun qc->sg |
@@ -5161,21 +5198,28 @@ next_sg: | |||
5161 | * - for write case, padding zero data to the device | 5198 | * - for write case, padding zero data to the device |
5162 | */ | 5199 | */ |
5163 | u16 pad_buf[1] = { 0 }; | 5200 | u16 pad_buf[1] = { 0 }; |
5164 | unsigned int words = bytes >> 1; | ||
5165 | unsigned int i; | 5201 | unsigned int i; |
5166 | 5202 | ||
5167 | if (words) /* warning if bytes > 1 */ | 5203 | if (bytes > qc->curbytes - qc->nbytes + ATAPI_MAX_DRAIN) { |
5168 | ata_dev_printk(qc->dev, KERN_WARNING, | 5204 | ata_ehi_push_desc(ehi, "too much trailing data " |
5169 | "%u bytes trailing data\n", bytes); | 5205 | "buf=%u cur=%u bytes=%u", |
5206 | qc->nbytes, qc->curbytes, bytes); | ||
5207 | return -1; | ||
5208 | } | ||
5170 | 5209 | ||
5171 | for (i = 0; i < words; i++) | 5210 | /* overflow is exptected for misc ATAPI commands */ |
5211 | if (bytes && !atapi_qc_may_overflow(qc)) | ||
5212 | ata_dev_printk(qc->dev, KERN_WARNING, "ATAPI %u bytes " | ||
5213 | "trailing data (cdb=%02x nbytes=%u)\n", | ||
5214 | bytes, qc->cdb[0], qc->nbytes); | ||
5215 | |||
5216 | for (i = 0; i < (bytes + 1) / 2; i++) | ||
5172 | ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 2, do_write); | 5217 | ap->ops->data_xfer(qc->dev, (unsigned char *)pad_buf, 2, do_write); |
5173 | 5218 | ||
5174 | ap->hsm_task_state = HSM_ST_LAST; | 5219 | qc->curbytes += bytes; |
5175 | return; | ||
5176 | } | ||
5177 | 5220 | ||
5178 | sg = qc->cursg; | 5221 | return 0; |
5222 | } | ||
5179 | 5223 | ||
5180 | page = sg_page(sg); | 5224 | page = sg_page(sg); |
5181 | offset = sg->offset + qc->cursg_ofs; | 5225 | offset = sg->offset + qc->cursg_ofs; |
@@ -5210,19 +5254,20 @@ next_sg: | |||
5210 | } | 5254 | } |
5211 | 5255 | ||
5212 | bytes -= count; | 5256 | bytes -= count; |
5257 | if ((count & 1) && bytes) | ||
5258 | bytes--; | ||
5213 | qc->curbytes += count; | 5259 | qc->curbytes += count; |
5214 | qc->cursg_ofs += count; | 5260 | qc->cursg_ofs += count; |
5215 | 5261 | ||
5216 | if (qc->cursg_ofs == sg->length) { | 5262 | if (qc->cursg_ofs == sg->length) { |
5217 | if (qc->cursg == lsg) | ||
5218 | no_more_sg = 1; | ||
5219 | |||
5220 | qc->cursg = sg_next(qc->cursg); | 5263 | qc->cursg = sg_next(qc->cursg); |
5221 | qc->cursg_ofs = 0; | 5264 | qc->cursg_ofs = 0; |
5222 | } | 5265 | } |
5223 | 5266 | ||
5224 | if (bytes) | 5267 | if (bytes) |
5225 | goto next_sg; | 5268 | goto next_sg; |
5269 | |||
5270 | return 0; | ||
5226 | } | 5271 | } |
5227 | 5272 | ||
5228 | /** | 5273 | /** |
@@ -5265,7 +5310,8 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
5265 | 5310 | ||
5266 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); | 5311 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); |
5267 | 5312 | ||
5268 | __atapi_pio_bytes(qc, bytes); | 5313 | if (__atapi_pio_bytes(qc, bytes)) |
5314 | goto err_out; | ||
5269 | ata_altstatus(ap); /* flush */ | 5315 | ata_altstatus(ap); /* flush */ |
5270 | 5316 | ||
5271 | return; | 5317 | return; |
@@ -7208,18 +7254,14 @@ static void ata_port_detach(struct ata_port *ap) | |||
7208 | 7254 | ||
7209 | ata_port_wait_eh(ap); | 7255 | ata_port_wait_eh(ap); |
7210 | 7256 | ||
7211 | /* EH is now guaranteed to see UNLOADING, so no new device | 7257 | /* EH is now guaranteed to see UNLOADING - EH context belongs |
7212 | * will be attached. Disable all existing devices. | 7258 | * to us. Disable all existing devices. |
7213 | */ | 7259 | */ |
7214 | spin_lock_irqsave(ap->lock, flags); | ||
7215 | |||
7216 | ata_port_for_each_link(link, ap) { | 7260 | ata_port_for_each_link(link, ap) { |
7217 | ata_link_for_each_dev(dev, link) | 7261 | ata_link_for_each_dev(dev, link) |
7218 | ata_dev_disable(dev); | 7262 | ata_dev_disable(dev); |
7219 | } | 7263 | } |
7220 | 7264 | ||
7221 | spin_unlock_irqrestore(ap->lock, flags); | ||
7222 | |||
7223 | /* Final freeze & EH. All in-flight commands are aborted. EH | 7265 | /* Final freeze & EH. All in-flight commands are aborted. EH |
7224 | * will be skipped and retrials will be terminated with bad | 7266 | * will be skipped and retrials will be terminated with bad |
7225 | * target. | 7267 | * target. |
@@ -7251,6 +7293,9 @@ void ata_host_detach(struct ata_host *host) | |||
7251 | 7293 | ||
7252 | for (i = 0; i < host->n_ports; i++) | 7294 | for (i = 0; i < host->n_ports; i++) |
7253 | ata_port_detach(host->ports[i]); | 7295 | ata_port_detach(host->ports[i]); |
7296 | |||
7297 | /* the host is dead now, dissociate ACPI */ | ||
7298 | ata_acpi_dissociate(host); | ||
7254 | } | 7299 | } |
7255 | 7300 | ||
7256 | /** | 7301 | /** |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e6605f038647..f0124a8d3134 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1264,8 +1264,8 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) | |||
1264 | tf.feature |= ATAPI_PKT_DMA; | 1264 | tf.feature |= ATAPI_PKT_DMA; |
1265 | } else { | 1265 | } else { |
1266 | tf.protocol = ATA_PROT_ATAPI; | 1266 | tf.protocol = ATA_PROT_ATAPI; |
1267 | tf.lbam = (8 * 1024) & 0xff; | 1267 | tf.lbam = SCSI_SENSE_BUFFERSIZE; |
1268 | tf.lbah = (8 * 1024) >> 8; | 1268 | tf.lbah = 0; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, | 1271 | return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 0e6cf3a484dc..bbe59c2fd1e2 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -108,15 +108,19 @@ extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm); | |||
108 | #ifdef CONFIG_ATA_ACPI | 108 | #ifdef CONFIG_ATA_ACPI |
109 | extern void ata_acpi_associate_sata_port(struct ata_port *ap); | 109 | extern void ata_acpi_associate_sata_port(struct ata_port *ap); |
110 | extern void ata_acpi_associate(struct ata_host *host); | 110 | extern void ata_acpi_associate(struct ata_host *host); |
111 | extern void ata_acpi_dissociate(struct ata_host *host); | ||
111 | extern int ata_acpi_on_suspend(struct ata_port *ap); | 112 | extern int ata_acpi_on_suspend(struct ata_port *ap); |
112 | extern void ata_acpi_on_resume(struct ata_port *ap); | 113 | extern void ata_acpi_on_resume(struct ata_port *ap); |
113 | extern int ata_acpi_on_devcfg(struct ata_device *adev); | 114 | extern int ata_acpi_on_devcfg(struct ata_device *dev); |
115 | extern void ata_acpi_on_disable(struct ata_device *dev); | ||
114 | #else | 116 | #else |
115 | static inline void ata_acpi_associate_sata_port(struct ata_port *ap) { } | 117 | static inline void ata_acpi_associate_sata_port(struct ata_port *ap) { } |
116 | static inline void ata_acpi_associate(struct ata_host *host) { } | 118 | static inline void ata_acpi_associate(struct ata_host *host) { } |
119 | static inline void ata_acpi_dissociate(struct ata_host *host) { } | ||
117 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } | 120 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } |
118 | static inline void ata_acpi_on_resume(struct ata_port *ap) { } | 121 | static inline void ata_acpi_on_resume(struct ata_port *ap) { } |
119 | static inline int ata_acpi_on_devcfg(struct ata_device *adev) { return 0; } | 122 | static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; } |
123 | static inline void ata_acpi_on_disable(struct ata_device *dev) { } | ||
120 | #endif | 124 | #endif |
121 | 125 | ||
122 | /* libata-scsi.c */ | 126 | /* libata-scsi.c */ |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index fe0105d35bae..37b850ae0845 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -2506,11 +2506,31 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx) | |||
2506 | if (pdev->vendor == PCI_VENDOR_ID_TTI && | 2506 | if (pdev->vendor == PCI_VENDOR_ID_TTI && |
2507 | (pdev->device == 0x2300 || pdev->device == 0x2310)) | 2507 | (pdev->device == 0x2300 || pdev->device == 0x2310)) |
2508 | { | 2508 | { |
2509 | printk(KERN_WARNING "sata_mv: Highpoint RocketRAID BIOS" | 2509 | /* |
2510 | " will CORRUPT DATA on attached drives when" | 2510 | * Highpoint RocketRAID PCIe 23xx series cards: |
2511 | " configured as \"Legacy\". BEWARE!\n"); | 2511 | * |
2512 | printk(KERN_WARNING "sata_mv: Use BIOS \"JBOD\" volumes" | 2512 | * Unconfigured drives are treated as "Legacy" |
2513 | " instead for safety.\n"); | 2513 | * by the BIOS, and it overwrites sector 8 with |
2514 | * a "Lgcy" metadata block prior to Linux boot. | ||
2515 | * | ||
2516 | * Configured drives (RAID or JBOD) leave sector 8 | ||
2517 | * alone, but instead overwrite a high numbered | ||
2518 | * sector for the RAID metadata. This sector can | ||
2519 | * be determined exactly, by truncating the physical | ||
2520 | * drive capacity to a nice even GB value. | ||
2521 | * | ||
2522 | * RAID metadata is at: (dev->n_sectors & ~0xfffff) | ||
2523 | * | ||
2524 | * Warn the user, lest they think we're just buggy. | ||
2525 | */ | ||
2526 | printk(KERN_WARNING DRV_NAME ": Highpoint RocketRAID" | ||
2527 | " BIOS CORRUPTS DATA on all attached drives," | ||
2528 | " regardless of if/how they are configured." | ||
2529 | " BEWARE!\n"); | ||
2530 | printk(KERN_WARNING DRV_NAME ": For data safety, do not" | ||
2531 | " use sectors 8-9 on \"Legacy\" drives," | ||
2532 | " and avoid the final two gigabytes on" | ||
2533 | " all RocketRAID BIOS initialized drives.\n"); | ||
2514 | } | 2534 | } |
2515 | case chip_6042: | 2535 | case chip_6042: |
2516 | hpriv->ops = &mv6xxx_ops; | 2536 | hpriv->ops = &mv6xxx_ops; |
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 4e6e381279cc..f5119bf40c24 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -390,23 +390,19 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) | |||
390 | sil_scr_read(ap, SCR_ERROR, &serror); | 390 | sil_scr_read(ap, SCR_ERROR, &serror); |
391 | sil_scr_write(ap, SCR_ERROR, serror); | 391 | sil_scr_write(ap, SCR_ERROR, serror); |
392 | 392 | ||
393 | /* Trigger hotplug and accumulate SError only if the | 393 | /* Sometimes spurious interrupts occur, double check |
394 | * port isn't already frozen. Otherwise, PHY events | 394 | * it's PHYRDY CHG. |
395 | * during hardreset makes controllers with broken SIEN | ||
396 | * repeat probing needlessly. | ||
397 | */ | 395 | */ |
398 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) { | 396 | if (serror & SERR_PHYRDY_CHG) { |
399 | ata_ehi_hotplugged(&ap->link.eh_info); | ||
400 | ap->link.eh_info.serror |= serror; | 397 | ap->link.eh_info.serror |= serror; |
398 | goto freeze; | ||
401 | } | 399 | } |
402 | 400 | ||
403 | goto freeze; | 401 | if (!(bmdma2 & SIL_DMA_COMPLETE)) |
402 | return; | ||
404 | } | 403 | } |
405 | 404 | ||
406 | if (unlikely(!qc)) | 405 | if (unlikely(!qc || (qc->tf.flags & ATA_TFLAG_POLLING))) { |
407 | goto freeze; | ||
408 | |||
409 | if (unlikely(qc->tf.flags & ATA_TFLAG_POLLING)) { | ||
410 | /* this sometimes happens, just clear IRQ */ | 406 | /* this sometimes happens, just clear IRQ */ |
411 | ata_chk_status(ap); | 407 | ata_chk_status(ap); |
412 | return; | 408 | return; |
diff --git a/include/linux/ata.h b/include/linux/ata.h index 5c4e54a2a8d6..72ab80801ef6 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -190,6 +190,8 @@ enum { | |||
190 | ATA_CMD_READ_LOG_EXT = 0x2f, | 190 | ATA_CMD_READ_LOG_EXT = 0x2f, |
191 | ATA_CMD_PMP_READ = 0xE4, | 191 | ATA_CMD_PMP_READ = 0xE4, |
192 | ATA_CMD_PMP_WRITE = 0xE8, | 192 | ATA_CMD_PMP_WRITE = 0xE8, |
193 | ATA_CMD_CONF_OVERLAY = 0xB1, | ||
194 | ATA_CMD_SEC_FREEZE_LOCK = 0xF5, | ||
193 | 195 | ||
194 | /* READ_LOG_EXT pages */ | 196 | /* READ_LOG_EXT pages */ |
195 | ATA_LOG_SATA_NCQ = 0x10, | 197 | ATA_LOG_SATA_NCQ = 0x10, |
@@ -239,6 +241,19 @@ enum { | |||
239 | SATA_AN = 0x05, /* Asynchronous Notification */ | 241 | SATA_AN = 0x05, /* Asynchronous Notification */ |
240 | SATA_DIPM = 0x03, /* Device Initiated Power Management */ | 242 | SATA_DIPM = 0x03, /* Device Initiated Power Management */ |
241 | 243 | ||
244 | /* feature values for SET_MAX */ | ||
245 | ATA_SET_MAX_ADDR = 0x00, | ||
246 | ATA_SET_MAX_PASSWD = 0x01, | ||
247 | ATA_SET_MAX_LOCK = 0x02, | ||
248 | ATA_SET_MAX_UNLOCK = 0x03, | ||
249 | ATA_SET_MAX_FREEZE_LOCK = 0x04, | ||
250 | |||
251 | /* feature values for DEVICE CONFIGURATION OVERLAY */ | ||
252 | ATA_DCO_RESTORE = 0xC0, | ||
253 | ATA_DCO_FREEZE_LOCK = 0xC1, | ||
254 | ATA_DCO_IDENTIFY = 0xC2, | ||
255 | ATA_DCO_SET = 0xC3, | ||
256 | |||
242 | /* ATAPI stuff */ | 257 | /* ATAPI stuff */ |
243 | ATAPI_PKT_DMA = (1 << 0), | 258 | ATAPI_PKT_DMA = (1 << 0), |
244 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: | 259 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: |
diff --git a/include/linux/libata.h b/include/linux/libata.h index ef52a07c43d8..124033cb5e9b 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -119,6 +119,8 @@ enum { | |||
119 | ATA_DEF_BUSY_WAIT = 10000, | 119 | ATA_DEF_BUSY_WAIT = 10000, |
120 | ATA_SHORT_PAUSE = (HZ >> 6) + 1, | 120 | ATA_SHORT_PAUSE = (HZ >> 6) + 1, |
121 | 121 | ||
122 | ATAPI_MAX_DRAIN = 16 << 10, | ||
123 | |||
122 | ATA_SHT_EMULATED = 1, | 124 | ATA_SHT_EMULATED = 1, |
123 | ATA_SHT_CMD_PER_LUN = 1, | 125 | ATA_SHT_CMD_PER_LUN = 1, |
124 | ATA_SHT_THIS_ID = -1, | 126 | ATA_SHT_THIS_ID = -1, |
@@ -211,7 +213,7 @@ enum { | |||
211 | 213 | ||
212 | ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ | 214 | ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ |
213 | ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ | 215 | ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ |
214 | ATA_PFLAG_GTM_VALID = (1 << 19), /* acpi_gtm data valid */ | 216 | ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */ |
215 | 217 | ||
216 | /* struct ata_queued_cmd flags */ | 218 | /* struct ata_queued_cmd flags */ |
217 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ | 219 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |
@@ -498,6 +500,7 @@ struct ata_device { | |||
498 | struct scsi_device *sdev; /* attached SCSI device */ | 500 | struct scsi_device *sdev; /* attached SCSI device */ |
499 | #ifdef CONFIG_ATA_ACPI | 501 | #ifdef CONFIG_ATA_ACPI |
500 | acpi_handle acpi_handle; | 502 | acpi_handle acpi_handle; |
503 | union acpi_object *gtf_cache; | ||
501 | #endif | 504 | #endif |
502 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ | 505 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ |
503 | u64 n_sectors; /* size of device, if ATA */ | 506 | u64 n_sectors; /* size of device, if ATA */ |
@@ -653,7 +656,7 @@ struct ata_port { | |||
653 | 656 | ||
654 | #ifdef CONFIG_ATA_ACPI | 657 | #ifdef CONFIG_ATA_ACPI |
655 | acpi_handle acpi_handle; | 658 | acpi_handle acpi_handle; |
656 | struct ata_acpi_gtm acpi_gtm; | 659 | struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */ |
657 | #endif | 660 | #endif |
658 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | 661 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ |
659 | }; | 662 | }; |
@@ -939,10 +942,20 @@ enum { | |||
939 | 942 | ||
940 | /* libata-acpi.c */ | 943 | /* libata-acpi.c */ |
941 | #ifdef CONFIG_ATA_ACPI | 944 | #ifdef CONFIG_ATA_ACPI |
945 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | ||
946 | { | ||
947 | if (ap->pflags & ATA_PFLAG_INIT_GTM_VALID) | ||
948 | return &ap->__acpi_init_gtm; | ||
949 | return NULL; | ||
950 | } | ||
942 | extern int ata_acpi_cbl_80wire(struct ata_port *ap); | 951 | extern int ata_acpi_cbl_80wire(struct ata_port *ap); |
943 | int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm); | 952 | int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); |
944 | int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *stm); | 953 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); |
945 | #else | 954 | #else |
955 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) | ||
956 | { | ||
957 | return NULL; | ||
958 | } | ||
946 | static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } | 959 | static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } |
947 | #endif | 960 | #endif |
948 | 961 | ||
@@ -1013,18 +1026,18 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
1013 | * printk helpers | 1026 | * printk helpers |
1014 | */ | 1027 | */ |
1015 | #define ata_port_printk(ap, lv, fmt, args...) \ | 1028 | #define ata_port_printk(ap, lv, fmt, args...) \ |
1016 | printk(lv"ata%u: "fmt, (ap)->print_id , ##args) | 1029 | printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) |
1017 | 1030 | ||
1018 | #define ata_link_printk(link, lv, fmt, args...) do { \ | 1031 | #define ata_link_printk(link, lv, fmt, args...) do { \ |
1019 | if ((link)->ap->nr_pmp_links) \ | 1032 | if ((link)->ap->nr_pmp_links) \ |
1020 | printk(lv"ata%u.%02u: "fmt, (link)->ap->print_id, \ | 1033 | printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ |
1021 | (link)->pmp , ##args); \ | 1034 | (link)->pmp , ##args); \ |
1022 | else \ | 1035 | else \ |
1023 | printk(lv"ata%u: "fmt, (link)->ap->print_id , ##args); \ | 1036 | printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \ |
1024 | } while(0) | 1037 | } while(0) |
1025 | 1038 | ||
1026 | #define ata_dev_printk(dev, lv, fmt, args...) \ | 1039 | #define ata_dev_printk(dev, lv, fmt, args...) \ |
1027 | printk(lv"ata%u.%02u: "fmt, (dev)->link->ap->print_id, \ | 1040 | printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id, \ |
1028 | (dev)->link->pmp + (dev)->devno , ##args) | 1041 | (dev)->link->pmp + (dev)->devno , ##args) |
1029 | 1042 | ||
1030 | /* | 1043 | /* |