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

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