aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c3
-rw-r--r--drivers/ata/libata-acpi.c10
-rw-r--r--drivers/ata/libata-core.c80
-rw-r--r--drivers/ata/libata-scsi.c44
-rw-r--r--drivers/ata/libata.h3
-rw-r--r--drivers/ata/pata_scc.c4
-rw-r--r--drivers/ata/sata_sil24.c3
7 files changed, 98 insertions, 49 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1ae443d7ab92..e00e1b913d28 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -173,7 +173,8 @@ enum {
173 173
174 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 174 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
175 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 175 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
176 ATA_FLAG_SKIP_D2H_BSY, 176 ATA_FLAG_SKIP_D2H_BSY |
177 ATA_FLAG_ACPI_SATA,
177}; 178};
178 179
179struct ahci_cmd_hdr { 180struct ahci_cmd_hdr {
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ed4138e24b0c..02236739b40f 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -321,7 +321,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
321 321
322 /* Don't continue if device has no _ADR method. 322 /* Don't continue if device has no _ADR method.
323 * _GTF is intended for known motherboard devices. */ 323 * _GTF is intended for known motherboard devices. */
324 if (!(ap->cbl == ATA_CBL_SATA)) { 324 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); 325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
326 if (err < 0) { 326 if (err < 0) {
327 if (ata_msg_probe(ap)) 327 if (ata_msg_probe(ap))
@@ -343,7 +343,7 @@ static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
343 343
344 /* Get this drive's _ADR info. if not already known. */ 344 /* Get this drive's _ADR info. if not already known. */
345 if (!dev->obj_handle) { 345 if (!dev->obj_handle) {
346 if (!(ap->cbl == ATA_CBL_SATA)) { 346 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
347 /* get child objects of dev_handle == channel objects, 347 /* get child objects of dev_handle == channel objects,
348 * + _their_ children == drive objects */ 348 * + _their_ children == drive objects */
349 /* channel is ap->port_no */ 349 /* channel is ap->port_no */
@@ -528,7 +528,7 @@ static int do_drive_set_taskfiles(struct ata_device *dev,
528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
529 __FUNCTION__, ap->port_no); 529 __FUNCTION__, ap->port_no);
530 530
531 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) 531 if (libata_noacpi || !(ap->flags & ATA_FLAG_ACPI_SATA))
532 return 0; 532 return 0;
533 533
534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) 534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
@@ -578,7 +578,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
578 * we should not run GTF on PATA devices since some 578 * we should not run GTF on PATA devices since some
579 * PATA require execution of GTM/STM before GTF. 579 * PATA require execution of GTM/STM before GTF.
580 */ 580 */
581 if (!(ap->cbl == ATA_CBL_SATA)) 581 if (!(ap->flags & ATA_FLAG_ACPI_SATA))
582 return 0; 582 return 0;
583 583
584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { 584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
@@ -641,7 +641,7 @@ int ata_acpi_push_id(struct ata_device *dev)
641 __FUNCTION__, dev->devno, ap->port_no); 641 __FUNCTION__, dev->devno, ap->port_no);
642 642
643 /* Don't continue if not a SATA device. */ 643 /* Don't continue if not a SATA device. */
644 if (!(ap->cbl == ATA_CBL_SATA)) { 644 if (!(ap->flags & ATA_FLAG_ACPI_SATA)) {
645 if (ata_msg_probe(ap)) 645 if (ata_msg_probe(ap))
646 ata_dev_printk(dev, KERN_DEBUG, 646 ata_dev_printk(dev, KERN_DEBUG,
647 "%s: Not a SATA device\n", __FUNCTION__); 647 "%s: Not a SATA device\n", __FUNCTION__);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4166407eb47c..d5939e659cbb 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1919,7 +1919,6 @@ int ata_dev_configure(struct ata_device *dev)
1919 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); 1919 snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id));
1920 1920
1921 dev->n_sectors = ata_id_n_sectors(id); 1921 dev->n_sectors = ata_id_n_sectors(id);
1922 dev->n_sectors_boot = dev->n_sectors;
1923 1922
1924 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ 1923 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1925 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, 1924 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
@@ -3632,7 +3631,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3632 const u16 *old_id = dev->id; 3631 const u16 *old_id = dev->id;
3633 unsigned char model[2][ATA_ID_PROD_LEN + 1]; 3632 unsigned char model[2][ATA_ID_PROD_LEN + 1];
3634 unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; 3633 unsigned char serial[2][ATA_ID_SERNO_LEN + 1];
3635 u64 new_n_sectors;
3636 3634
3637 if (dev->class != new_class) { 3635 if (dev->class != new_class) {
3638 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", 3636 ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n",
@@ -3644,7 +3642,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3644 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1])); 3642 ata_id_c_string(new_id, model[1], ATA_ID_PROD, sizeof(model[1]));
3645 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0])); 3643 ata_id_c_string(old_id, serial[0], ATA_ID_SERNO, sizeof(serial[0]));
3646 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1])); 3644 ata_id_c_string(new_id, serial[1], ATA_ID_SERNO, sizeof(serial[1]));
3647 new_n_sectors = ata_id_n_sectors(new_id);
3648 3645
3649 if (strcmp(model[0], model[1])) { 3646 if (strcmp(model[0], model[1])) {
3650 ata_dev_printk(dev, KERN_INFO, "model number mismatch " 3647 ata_dev_printk(dev, KERN_INFO, "model number mismatch "
@@ -3658,25 +3655,12 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3658 return 0; 3655 return 0;
3659 } 3656 }
3660 3657
3661 if (dev->class == ATA_DEV_ATA && dev->n_sectors != new_n_sectors) {
3662 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
3663 "%llu != %llu\n",
3664 (unsigned long long)dev->n_sectors,
3665 (unsigned long long)new_n_sectors);
3666 /* Are we the boot time size - if so we appear to be the
3667 same disk at this point and our HPA got reapplied */
3668 if (ata_ignore_hpa && dev->n_sectors_boot == new_n_sectors
3669 && ata_id_hpa_enabled(new_id))
3670 return 1;
3671 return 0;
3672 }
3673
3674 return 1; 3658 return 1;
3675} 3659}
3676 3660
3677/** 3661/**
3678 * ata_dev_revalidate - Revalidate ATA device 3662 * ata_dev_reread_id - Re-read IDENTIFY data
3679 * @dev: device to revalidate 3663 * @adev: target ATA device
3680 * @readid_flags: read ID flags 3664 * @readid_flags: read ID flags
3681 * 3665 *
3682 * Re-read IDENTIFY page and make sure @dev is still attached to 3666 * Re-read IDENTIFY page and make sure @dev is still attached to
@@ -3688,34 +3672,68 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
3688 * RETURNS: 3672 * RETURNS:
3689 * 0 on success, negative errno otherwise 3673 * 0 on success, negative errno otherwise
3690 */ 3674 */
3691int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) 3675int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags)
3692{ 3676{
3693 unsigned int class = dev->class; 3677 unsigned int class = dev->class;
3694 u16 *id = (void *)dev->ap->sector_buf; 3678 u16 *id = (void *)dev->ap->sector_buf;
3695 int rc; 3679 int rc;
3696 3680
3697 if (!ata_dev_enabled(dev)) {
3698 rc = -ENODEV;
3699 goto fail;
3700 }
3701
3702 /* read ID data */ 3681 /* read ID data */
3703 rc = ata_dev_read_id(dev, &class, readid_flags, id); 3682 rc = ata_dev_read_id(dev, &class, readid_flags, id);
3704 if (rc) 3683 if (rc)
3705 goto fail; 3684 return rc;
3706 3685
3707 /* is the device still there? */ 3686 /* is the device still there? */
3708 if (!ata_dev_same_device(dev, class, id)) { 3687 if (!ata_dev_same_device(dev, class, id))
3709 rc = -ENODEV; 3688 return -ENODEV;
3710 goto fail;
3711 }
3712 3689
3713 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); 3690 memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS);
3691 return 0;
3692}
3693
3694/**
3695 * ata_dev_revalidate - Revalidate ATA device
3696 * @dev: device to revalidate
3697 * @readid_flags: read ID flags
3698 *
3699 * Re-read IDENTIFY page, make sure @dev is still attached to the
3700 * port and reconfigure it according to the new IDENTIFY page.
3701 *
3702 * LOCKING:
3703 * Kernel thread context (may sleep)
3704 *
3705 * RETURNS:
3706 * 0 on success, negative errno otherwise
3707 */
3708int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
3709{
3710 u64 n_sectors = dev->n_sectors;
3711 int rc;
3712
3713 if (!ata_dev_enabled(dev))
3714 return -ENODEV;
3715
3716 /* re-read ID */
3717 rc = ata_dev_reread_id(dev, readid_flags);
3718 if (rc)
3719 goto fail;
3714 3720
3715 /* configure device according to the new ID */ 3721 /* configure device according to the new ID */
3716 rc = ata_dev_configure(dev); 3722 rc = ata_dev_configure(dev);
3717 if (rc == 0) 3723 if (rc)
3718 return 0; 3724 goto fail;
3725
3726 /* verify n_sectors hasn't changed */
3727 if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) {
3728 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
3729 "%llu != %llu\n",
3730 (unsigned long long)n_sectors,
3731 (unsigned long long)dev->n_sectors);
3732 rc = -ENODEV;
3733 goto fail;
3734 }
3735
3736 return 0;
3719 3737
3720 fail: 3738 fail:
3721 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); 3739 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index dd81fa78cdcf..b6a1de8fad5b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -893,6 +893,23 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
893 return queue_depth; 893 return queue_depth;
894} 894}
895 895
896/* XXX: for ata_spindown_compat */
897static void ata_delayed_done_timerfn(unsigned long arg)
898{
899 struct scsi_cmnd *scmd = (void *)arg;
900
901 scmd->scsi_done(scmd);
902}
903
904/* XXX: for ata_spindown_compat */
905static void ata_delayed_done(struct scsi_cmnd *scmd)
906{
907 static struct timer_list timer;
908
909 setup_timer(&timer, ata_delayed_done_timerfn, (unsigned long)scmd);
910 mod_timer(&timer, jiffies + 5 * HZ);
911}
912
896/** 913/**
897 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command 914 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
898 * @qc: Storage for translated ATA taskfile 915 * @qc: Storage for translated ATA taskfile
@@ -950,21 +967,24 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
950 * for more info. 967 * for more info.
951 */ 968 */
952 if (ata_spindown_compat && 969 if (ata_spindown_compat &&
970 (qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
953 (system_state == SYSTEM_HALT || 971 (system_state == SYSTEM_HALT ||
954 system_state == SYSTEM_POWER_OFF)) { 972 system_state == SYSTEM_POWER_OFF)) {
955 static int warned = 0; 973 static unsigned long warned = 0;
956 974
957 if (!warned) { 975 if (!test_and_set_bit(0, &warned)) {
958 spin_unlock_irq(qc->ap->lock);
959 ata_dev_printk(qc->dev, KERN_WARNING, 976 ata_dev_printk(qc->dev, KERN_WARNING,
960 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " 977 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
961 "UPDATE SHUTDOWN UTILITY\n"); 978 "UPDATE SHUTDOWN UTILITY\n");
962 ata_dev_printk(qc->dev, KERN_WARNING, 979 ata_dev_printk(qc->dev, KERN_WARNING,
963 "For more info, visit " 980 "For more info, visit "
964 "http://linux-ata.org/shutdown.html\n"); 981 "http://linux-ata.org/shutdown.html\n");
965 warned = 1; 982
966 ssleep(5); 983 /* ->scsi_done is not used, use it for
967 spin_lock_irq(qc->ap->lock); 984 * delayed completion.
985 */
986 scmd->scsi_done = qc->scsidone;
987 qc->scsidone = ata_delayed_done;
968 } 988 }
969 scmd->result = SAM_STAT_GOOD; 989 scmd->result = SAM_STAT_GOOD;
970 return 1; 990 return 1;
@@ -1375,6 +1395,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1375 } 1395 }
1376 } 1396 }
1377 1397
1398 /* XXX: track spindown state for spindown_compat */
1399 if (unlikely(qc->tf.command == ATA_CMD_STANDBY ||
1400 qc->tf.command == ATA_CMD_STANDBYNOW1))
1401 qc->dev->flags |= ATA_DFLAG_SPUNDOWN;
1402 else if (likely(system_state != SYSTEM_HALT &&
1403 system_state != SYSTEM_POWER_OFF))
1404 qc->dev->flags &= ~ATA_DFLAG_SPUNDOWN;
1405
1378 if (need_sense && !ap->ops->error_handler) 1406 if (need_sense && !ap->ops->error_handler)
1379 ata_dump_status(ap->print_id, &qc->result_tf); 1407 ata_dump_status(ap->print_id, &qc->result_tf);
1380 1408
@@ -1488,14 +1516,14 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
1488 1516
1489early_finish: 1517early_finish:
1490 ata_qc_free(qc); 1518 ata_qc_free(qc);
1491 done(cmd); 1519 qc->scsidone(cmd);
1492 DPRINTK("EXIT - early finish (good or error)\n"); 1520 DPRINTK("EXIT - early finish (good or error)\n");
1493 return 0; 1521 return 0;
1494 1522
1495err_did: 1523err_did:
1496 ata_qc_free(qc); 1524 ata_qc_free(qc);
1497 cmd->result = (DID_ERROR << 16); 1525 cmd->result = (DID_ERROR << 16);
1498 done(cmd); 1526 qc->scsidone(cmd);
1499err_mem: 1527err_mem:
1500 DPRINTK("EXIT - internal\n"); 1528 DPRINTK("EXIT - internal\n");
1501 return 0; 1529 return 0;
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 8b71b73a199c..13cb0c9af68d 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -76,7 +76,8 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev,
76extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 76extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
77extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 77extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
78 unsigned int flags, u16 *id); 78 unsigned int flags, u16 *id);
79extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags); 79extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
80extern int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags);
80extern int ata_dev_configure(struct ata_device *dev); 81extern int ata_dev_configure(struct ata_device *dev);
81extern int sata_down_spd_limit(struct ata_port *ap); 82extern int sata_down_spd_limit(struct ata_port *ap);
82extern int sata_set_spd_needed(struct ata_port *ap); 83extern int sata_set_spd_needed(struct ata_port *ap);
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index cca3aa225efe..844e53b280c7 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -864,10 +864,10 @@ static void scc_bmdma_freeze (struct ata_port *ap)
864 * @ap: ATA port to be reset 864 * @ap: ATA port to be reset
865 */ 865 */
866 866
867static int scc_pata_prereset (struct ata_port *ap) 867static int scc_pata_prereset (struct ata_port *ap, unsigned long deadline)
868{ 868{
869 ap->cbl = ATA_CBL_PATA80; 869 ap->cbl = ATA_CBL_PATA80;
870 return ata_std_prereset(ap); 870 return ata_std_prereset(ap, deadline);
871} 871}
872 872
873/** 873/**
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index a69d78cd8e9b..0cb6618935b1 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -237,7 +237,8 @@ enum {
237 /* host flags */ 237 /* host flags */
238 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 238 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
239 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 239 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
240 ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY, 240 ATA_FLAG_NCQ | ATA_FLAG_SKIP_D2H_BSY |
241 ATA_FLAG_ACPI_SATA,
241 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */ 242 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */
242 243
243 IRQ_STAT_4PORTS = 0xf, 244 IRQ_STAT_4PORTS = 0xf,