diff options
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 104 |
1 files changed, 57 insertions, 47 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4166407eb47c..3ca9c610c110 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -59,7 +59,7 @@ | |||
59 | 59 | ||
60 | #include "libata.h" | 60 | #include "libata.h" |
61 | 61 | ||
62 | #define DRV_VERSION "2.20" /* must be exactly four chars */ | 62 | #define DRV_VERSION "2.21" /* must be exactly four chars */ |
63 | 63 | ||
64 | 64 | ||
65 | /* debounce timing parameters in msecs { interval, duration, timeout } */ | 65 | /* debounce timing parameters in msecs { interval, duration, timeout } */ |
@@ -101,12 +101,6 @@ int libata_noacpi = 1; | |||
101 | module_param_named(noacpi, libata_noacpi, int, 0444); | 101 | module_param_named(noacpi, libata_noacpi, int, 0444); |
102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); | 102 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); |
103 | 103 | ||
104 | int ata_spindown_compat = 1; | ||
105 | module_param_named(spindown_compat, ata_spindown_compat, int, 0644); | ||
106 | MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown " | ||
107 | "behavior. Will be removed. More info can be found in " | ||
108 | "Documentation/feature-removal-schedule.txt\n"); | ||
109 | |||
110 | MODULE_AUTHOR("Jeff Garzik"); | 104 | MODULE_AUTHOR("Jeff Garzik"); |
111 | MODULE_DESCRIPTION("Library module for ATA devices"); | 105 | MODULE_DESCRIPTION("Library module for ATA devices"); |
112 | MODULE_LICENSE("GPL"); | 106 | MODULE_LICENSE("GPL"); |
@@ -983,7 +977,7 @@ static u64 ata_hpa_resize(struct ata_device *dev) | |||
983 | { | 977 | { |
984 | u64 sectors = dev->n_sectors; | 978 | u64 sectors = dev->n_sectors; |
985 | u64 hpa_sectors; | 979 | u64 hpa_sectors; |
986 | 980 | ||
987 | if (ata_id_has_lba48(dev->id)) | 981 | if (ata_id_has_lba48(dev->id)) |
988 | hpa_sectors = ata_read_native_max_address_ext(dev); | 982 | hpa_sectors = ata_read_native_max_address_ext(dev); |
989 | else | 983 | else |
@@ -1594,7 +1588,7 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | |||
1594 | * Check if the current speed of the device requires IORDY. Used | 1588 | * Check if the current speed of the device requires IORDY. Used |
1595 | * by various controllers for chip configuration. | 1589 | * by various controllers for chip configuration. |
1596 | */ | 1590 | */ |
1597 | 1591 | ||
1598 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) | 1592 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) |
1599 | { | 1593 | { |
1600 | /* Controller doesn't support IORDY. Probably a pointless check | 1594 | /* Controller doesn't support IORDY. Probably a pointless check |
@@ -1617,7 +1611,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1617 | * Compute the highest mode possible if we are not using iordy. Return | 1611 | * Compute the highest mode possible if we are not using iordy. Return |
1618 | * -1 if no iordy mode is available. | 1612 | * -1 if no iordy mode is available. |
1619 | */ | 1613 | */ |
1620 | 1614 | ||
1621 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) | 1615 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) |
1622 | { | 1616 | { |
1623 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ | 1617 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ |
@@ -1919,7 +1913,6 @@ int ata_dev_configure(struct ata_device *dev) | |||
1919 | snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); | 1913 | snprintf(revbuf, 7, "ATA-%d", ata_id_major_version(id)); |
1920 | 1914 | ||
1921 | dev->n_sectors = ata_id_n_sectors(id); | 1915 | dev->n_sectors = ata_id_n_sectors(id); |
1922 | dev->n_sectors_boot = dev->n_sectors; | ||
1923 | 1916 | ||
1924 | /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ | 1917 | /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */ |
1925 | ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, | 1918 | ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV, |
@@ -2670,7 +2663,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
2670 | t->active += (t->cycle - (t->active + t->recover)) / 2; | 2663 | t->active += (t->cycle - (t->active + t->recover)) / 2; |
2671 | t->recover = t->cycle - t->active; | 2664 | t->recover = t->cycle - t->active; |
2672 | } | 2665 | } |
2673 | 2666 | ||
2674 | /* In a few cases quantisation may produce enough errors to | 2667 | /* In a few cases quantisation may produce enough errors to |
2675 | leave t->cycle too low for the sum of active and recovery | 2668 | leave t->cycle too low for the sum of active and recovery |
2676 | if so we must correct this */ | 2669 | if so we must correct this */ |
@@ -2900,9 +2893,6 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2900 | if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX)) | 2893 | if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX)) |
2901 | ap->host->simplex_claimed = ap; | 2894 | ap->host->simplex_claimed = ap; |
2902 | 2895 | ||
2903 | /* step5: chip specific finalisation */ | ||
2904 | if (ap->ops->post_set_mode) | ||
2905 | ap->ops->post_set_mode(ap); | ||
2906 | out: | 2896 | out: |
2907 | if (rc) | 2897 | if (rc) |
2908 | *r_failed_dev = dev; | 2898 | *r_failed_dev = dev; |
@@ -3032,7 +3022,7 @@ int ata_wait_ready(struct ata_port *ap, unsigned long deadline) | |||
3032 | 3022 | ||
3033 | if (!(status & ATA_BUSY)) | 3023 | if (!(status & ATA_BUSY)) |
3034 | return 0; | 3024 | return 0; |
3035 | if (status == 0xff) | 3025 | if (!ata_port_online(ap) && status == 0xff) |
3036 | return -ENODEV; | 3026 | return -ENODEV; |
3037 | if (time_after(now, deadline)) | 3027 | if (time_after(now, deadline)) |
3038 | return -EBUSY; | 3028 | return -EBUSY; |
@@ -3378,7 +3368,7 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline) | |||
3378 | */ | 3368 | */ |
3379 | if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) { | 3369 | if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) { |
3380 | rc = ata_wait_ready(ap, deadline); | 3370 | rc = ata_wait_ready(ap, deadline); |
3381 | if (rc) { | 3371 | if (rc && rc != -ENODEV) { |
3382 | ata_port_printk(ap, KERN_WARNING, "device not ready " | 3372 | ata_port_printk(ap, KERN_WARNING, "device not ready " |
3383 | "(errno=%d), forcing hardreset\n", rc); | 3373 | "(errno=%d), forcing hardreset\n", rc); |
3384 | ehc->i.action |= ATA_EH_HARDRESET; | 3374 | ehc->i.action |= ATA_EH_HARDRESET; |
@@ -3632,7 +3622,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
3632 | const u16 *old_id = dev->id; | 3622 | const u16 *old_id = dev->id; |
3633 | unsigned char model[2][ATA_ID_PROD_LEN + 1]; | 3623 | unsigned char model[2][ATA_ID_PROD_LEN + 1]; |
3634 | unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; | 3624 | unsigned char serial[2][ATA_ID_SERNO_LEN + 1]; |
3635 | u64 new_n_sectors; | ||
3636 | 3625 | ||
3637 | if (dev->class != new_class) { | 3626 | if (dev->class != new_class) { |
3638 | ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", | 3627 | ata_dev_printk(dev, KERN_INFO, "class mismatch %d != %d\n", |
@@ -3644,7 +3633,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])); | 3633 | 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])); | 3634 | 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])); | 3635 | 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 | 3636 | ||
3649 | if (strcmp(model[0], model[1])) { | 3637 | if (strcmp(model[0], model[1])) { |
3650 | ata_dev_printk(dev, KERN_INFO, "model number mismatch " | 3638 | ata_dev_printk(dev, KERN_INFO, "model number mismatch " |
@@ -3658,25 +3646,12 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
3658 | return 0; | 3646 | return 0; |
3659 | } | 3647 | } |
3660 | 3648 | ||
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; | 3649 | return 1; |
3675 | } | 3650 | } |
3676 | 3651 | ||
3677 | /** | 3652 | /** |
3678 | * ata_dev_revalidate - Revalidate ATA device | 3653 | * ata_dev_reread_id - Re-read IDENTIFY data |
3679 | * @dev: device to revalidate | 3654 | * @adev: target ATA device |
3680 | * @readid_flags: read ID flags | 3655 | * @readid_flags: read ID flags |
3681 | * | 3656 | * |
3682 | * Re-read IDENTIFY page and make sure @dev is still attached to | 3657 | * Re-read IDENTIFY page and make sure @dev is still attached to |
@@ -3688,34 +3663,68 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
3688 | * RETURNS: | 3663 | * RETURNS: |
3689 | * 0 on success, negative errno otherwise | 3664 | * 0 on success, negative errno otherwise |
3690 | */ | 3665 | */ |
3691 | int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) | 3666 | int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags) |
3692 | { | 3667 | { |
3693 | unsigned int class = dev->class; | 3668 | unsigned int class = dev->class; |
3694 | u16 *id = (void *)dev->ap->sector_buf; | 3669 | u16 *id = (void *)dev->ap->sector_buf; |
3695 | int rc; | 3670 | int rc; |
3696 | 3671 | ||
3697 | if (!ata_dev_enabled(dev)) { | ||
3698 | rc = -ENODEV; | ||
3699 | goto fail; | ||
3700 | } | ||
3701 | |||
3702 | /* read ID data */ | 3672 | /* read ID data */ |
3703 | rc = ata_dev_read_id(dev, &class, readid_flags, id); | 3673 | rc = ata_dev_read_id(dev, &class, readid_flags, id); |
3704 | if (rc) | 3674 | if (rc) |
3705 | goto fail; | 3675 | return rc; |
3706 | 3676 | ||
3707 | /* is the device still there? */ | 3677 | /* is the device still there? */ |
3708 | if (!ata_dev_same_device(dev, class, id)) { | 3678 | if (!ata_dev_same_device(dev, class, id)) |
3709 | rc = -ENODEV; | 3679 | return -ENODEV; |
3710 | goto fail; | ||
3711 | } | ||
3712 | 3680 | ||
3713 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); | 3681 | memcpy(dev->id, id, sizeof(id[0]) * ATA_ID_WORDS); |
3682 | return 0; | ||
3683 | } | ||
3684 | |||
3685 | /** | ||
3686 | * ata_dev_revalidate - Revalidate ATA device | ||
3687 | * @dev: device to revalidate | ||
3688 | * @readid_flags: read ID flags | ||
3689 | * | ||
3690 | * Re-read IDENTIFY page, make sure @dev is still attached to the | ||
3691 | * port and reconfigure it according to the new IDENTIFY page. | ||
3692 | * | ||
3693 | * LOCKING: | ||
3694 | * Kernel thread context (may sleep) | ||
3695 | * | ||
3696 | * RETURNS: | ||
3697 | * 0 on success, negative errno otherwise | ||
3698 | */ | ||
3699 | int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags) | ||
3700 | { | ||
3701 | u64 n_sectors = dev->n_sectors; | ||
3702 | int rc; | ||
3703 | |||
3704 | if (!ata_dev_enabled(dev)) | ||
3705 | return -ENODEV; | ||
3706 | |||
3707 | /* re-read ID */ | ||
3708 | rc = ata_dev_reread_id(dev, readid_flags); | ||
3709 | if (rc) | ||
3710 | goto fail; | ||
3714 | 3711 | ||
3715 | /* configure device according to the new ID */ | 3712 | /* configure device according to the new ID */ |
3716 | rc = ata_dev_configure(dev); | 3713 | rc = ata_dev_configure(dev); |
3717 | if (rc == 0) | 3714 | if (rc) |
3718 | return 0; | 3715 | goto fail; |
3716 | |||
3717 | /* verify n_sectors hasn't changed */ | ||
3718 | if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) { | ||
3719 | ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch " | ||
3720 | "%llu != %llu\n", | ||
3721 | (unsigned long long)n_sectors, | ||
3722 | (unsigned long long)dev->n_sectors); | ||
3723 | rc = -ENODEV; | ||
3724 | goto fail; | ||
3725 | } | ||
3726 | |||
3727 | return 0; | ||
3719 | 3728 | ||
3720 | fail: | 3729 | fail: |
3721 | ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); | 3730 | ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); |
@@ -3759,6 +3768,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3759 | { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, | 3768 | { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, |
3760 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, | 3769 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, |
3761 | { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, | 3770 | { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, |
3771 | { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, | ||
3762 | 3772 | ||
3763 | /* Weird ATAPI devices */ | 3773 | /* Weird ATAPI devices */ |
3764 | { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | | 3774 | { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | |