aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/ahci.c9
-rw-r--r--drivers/ata/libata-core.c96
-rw-r--r--drivers/ata/libata-eh.c87
-rw-r--r--drivers/ata/libata-pmp.c2
-rw-r--r--drivers/ata/libata-scsi.c1
-rw-r--r--drivers/ata/libata-sff.c28
-rw-r--r--drivers/ata/libata.h4
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/pata_via.c4
-rw-r--r--drivers/ata/sata_mv.c4
-rw-r--r--drivers/ata/sata_nv.c21
-rw-r--r--drivers/ata/sata_sil.c2
12 files changed, 205 insertions, 55 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 77bba4c083cb..a603bbf9b1b7 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -61,9 +61,14 @@
61#define EM_MSG_LED_VALUE_ON 0x00010000 61#define EM_MSG_LED_VALUE_ON 0x00010000
62 62
63static int ahci_skip_host_reset; 63static int ahci_skip_host_reset;
64static int ahci_ignore_sss;
65
64module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); 66module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
65MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); 67MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
66 68
69module_param_named(ignore_sss, ahci_ignore_sss, int, 0444);
70MODULE_PARM_DESC(ignore_sss, "Ignore staggered spinup flag (0=don't ignore, 1=ignore)");
71
67static int ahci_enable_alpm(struct ata_port *ap, 72static int ahci_enable_alpm(struct ata_port *ap,
68 enum link_pm policy); 73 enum link_pm policy);
69static void ahci_disable_alpm(struct ata_port *ap); 74static void ahci_disable_alpm(struct ata_port *ap);
@@ -2692,8 +2697,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2692 host->iomap = pcim_iomap_table(pdev); 2697 host->iomap = pcim_iomap_table(pdev);
2693 host->private_data = hpriv; 2698 host->private_data = hpriv;
2694 2699
2695 if (!(hpriv->cap & HOST_CAP_SSS)) 2700 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
2696 host->flags |= ATA_HOST_PARALLEL_SCAN; 2701 host->flags |= ATA_HOST_PARALLEL_SCAN;
2702 else
2703 printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n");
2697 2704
2698 if (pi.flags & ATA_FLAG_EM) 2705 if (pi.flags & ATA_FLAG_EM)
2699 ahci_reset_em(host); 2706 ahci_reset_em(host);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 88c242856dae..9fbf0595f3d4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -164,6 +164,11 @@ MODULE_LICENSE("GPL");
164MODULE_VERSION(DRV_VERSION); 164MODULE_VERSION(DRV_VERSION);
165 165
166 166
167static bool ata_sstatus_online(u32 sstatus)
168{
169 return (sstatus & 0xf) == 0x3;
170}
171
167/** 172/**
168 * ata_link_next - link iteration helper 173 * ata_link_next - link iteration helper
169 * @link: the previous link, NULL to start 174 * @link: the previous link, NULL to start
@@ -1015,18 +1020,6 @@ static const char *sata_spd_string(unsigned int spd)
1015 return spd_str[spd - 1]; 1020 return spd_str[spd - 1];
1016} 1021}
1017 1022
1018void ata_dev_disable(struct ata_device *dev)
1019{
1020 if (ata_dev_enabled(dev)) {
1021 if (ata_msg_drv(dev->link->ap))
1022 ata_dev_printk(dev, KERN_WARNING, "disabled\n");
1023 ata_acpi_on_disable(dev);
1024 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 |
1025 ATA_DNXFER_QUIET);
1026 dev->class++;
1027 }
1028}
1029
1030static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy) 1023static int ata_dev_set_dipm(struct ata_device *dev, enum link_pm policy)
1031{ 1024{
1032 struct ata_link *link = dev->link; 1025 struct ata_link *link = dev->link;
@@ -2239,6 +2232,40 @@ retry:
2239 return rc; 2232 return rc;
2240} 2233}
2241 2234
2235static int ata_do_link_spd_horkage(struct ata_device *dev)
2236{
2237 struct ata_link *plink = ata_dev_phys_link(dev);
2238 u32 target, target_limit;
2239
2240 if (!sata_scr_valid(plink))
2241 return 0;
2242
2243 if (dev->horkage & ATA_HORKAGE_1_5_GBPS)
2244 target = 1;
2245 else
2246 return 0;
2247
2248 target_limit = (1 << target) - 1;
2249
2250 /* if already on stricter limit, no need to push further */
2251 if (plink->sata_spd_limit <= target_limit)
2252 return 0;
2253
2254 plink->sata_spd_limit = target_limit;
2255
2256 /* Request another EH round by returning -EAGAIN if link is
2257 * going faster than the target speed. Forward progress is
2258 * guaranteed by setting sata_spd_limit to target_limit above.
2259 */
2260 if (plink->sata_spd > target) {
2261 ata_dev_printk(dev, KERN_INFO,
2262 "applying link speed limit horkage to %s\n",
2263 sata_spd_string(target));
2264 return -EAGAIN;
2265 }
2266 return 0;
2267}
2268
2242static inline u8 ata_dev_knobble(struct ata_device *dev) 2269static inline u8 ata_dev_knobble(struct ata_device *dev)
2243{ 2270{
2244 struct ata_port *ap = dev->link->ap; 2271 struct ata_port *ap = dev->link->ap;
@@ -2329,6 +2356,10 @@ int ata_dev_configure(struct ata_device *dev)
2329 return 0; 2356 return 0;
2330 } 2357 }
2331 2358
2359 rc = ata_do_link_spd_horkage(dev);
2360 if (rc)
2361 return rc;
2362
2332 /* let ACPI work its magic */ 2363 /* let ACPI work its magic */
2333 rc = ata_acpi_on_devcfg(dev); 2364 rc = ata_acpi_on_devcfg(dev);
2334 if (rc) 2365 if (rc)
@@ -2784,7 +2815,7 @@ int ata_bus_probe(struct ata_port *ap)
2784 /* This is the last chance, better to slow 2815 /* This is the last chance, better to slow
2785 * down than lose it. 2816 * down than lose it.
2786 */ 2817 */
2787 sata_down_spd_limit(&ap->link); 2818 sata_down_spd_limit(&ap->link, 0);
2788 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 2819 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2789 } 2820 }
2790 } 2821 }
@@ -2880,21 +2911,27 @@ void ata_port_disable(struct ata_port *ap)
2880/** 2911/**
2881 * sata_down_spd_limit - adjust SATA spd limit downward 2912 * sata_down_spd_limit - adjust SATA spd limit downward
2882 * @link: Link to adjust SATA spd limit for 2913 * @link: Link to adjust SATA spd limit for
2914 * @spd_limit: Additional limit
2883 * 2915 *
2884 * Adjust SATA spd limit of @link downward. Note that this 2916 * Adjust SATA spd limit of @link downward. Note that this
2885 * function only adjusts the limit. The change must be applied 2917 * function only adjusts the limit. The change must be applied
2886 * using sata_set_spd(). 2918 * using sata_set_spd().
2887 * 2919 *
2920 * If @spd_limit is non-zero, the speed is limited to equal to or
2921 * lower than @spd_limit if such speed is supported. If
2922 * @spd_limit is slower than any supported speed, only the lowest
2923 * supported speed is allowed.
2924 *
2888 * LOCKING: 2925 * LOCKING:
2889 * Inherited from caller. 2926 * Inherited from caller.
2890 * 2927 *
2891 * RETURNS: 2928 * RETURNS:
2892 * 0 on success, negative errno on failure 2929 * 0 on success, negative errno on failure
2893 */ 2930 */
2894int sata_down_spd_limit(struct ata_link *link) 2931int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
2895{ 2932{
2896 u32 sstatus, spd, mask; 2933 u32 sstatus, spd, mask;
2897 int rc, highbit; 2934 int rc, bit;
2898 2935
2899 if (!sata_scr_valid(link)) 2936 if (!sata_scr_valid(link))
2900 return -EOPNOTSUPP; 2937 return -EOPNOTSUPP;
@@ -2903,7 +2940,7 @@ int sata_down_spd_limit(struct ata_link *link)
2903 * If not, use cached value in link->sata_spd. 2940 * If not, use cached value in link->sata_spd.
2904 */ 2941 */
2905 rc = sata_scr_read(link, SCR_STATUS, &sstatus); 2942 rc = sata_scr_read(link, SCR_STATUS, &sstatus);
2906 if (rc == 0) 2943 if (rc == 0 && ata_sstatus_online(sstatus))
2907 spd = (sstatus >> 4) & 0xf; 2944 spd = (sstatus >> 4) & 0xf;
2908 else 2945 else
2909 spd = link->sata_spd; 2946 spd = link->sata_spd;
@@ -2913,8 +2950,8 @@ int sata_down_spd_limit(struct ata_link *link)
2913 return -EINVAL; 2950 return -EINVAL;
2914 2951
2915 /* unconditionally mask off the highest bit */ 2952 /* unconditionally mask off the highest bit */
2916 highbit = fls(mask) - 1; 2953 bit = fls(mask) - 1;
2917 mask &= ~(1 << highbit); 2954 mask &= ~(1 << bit);
2918 2955
2919 /* Mask off all speeds higher than or equal to the current 2956 /* Mask off all speeds higher than or equal to the current
2920 * one. Force 1.5Gbps if current SPD is not available. 2957 * one. Force 1.5Gbps if current SPD is not available.
@@ -2928,6 +2965,15 @@ int sata_down_spd_limit(struct ata_link *link)
2928 if (!mask) 2965 if (!mask)
2929 return -EINVAL; 2966 return -EINVAL;
2930 2967
2968 if (spd_limit) {
2969 if (mask & ((1 << spd_limit) - 1))
2970 mask &= (1 << spd_limit) - 1;
2971 else {
2972 bit = ffs(mask) - 1;
2973 mask = 1 << bit;
2974 }
2975 }
2976
2931 link->sata_spd_limit = mask; 2977 link->sata_spd_limit = mask;
2932 2978
2933 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n", 2979 ata_link_printk(link, KERN_WARNING, "limiting SATA link speed to %s\n",
@@ -4215,6 +4261,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4215 /* Devices that do not need bridging limits applied */ 4261 /* Devices that do not need bridging limits applied */
4216 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, }, 4262 { "MTRON MSP-SATA*", NULL, ATA_HORKAGE_BRIDGE_OK, },
4217 4263
4264 /* Devices which aren't very happy with higher link speeds */
4265 { "WD My Book", NULL, ATA_HORKAGE_1_5_GBPS, },
4266
4218 /* End Marker */ 4267 /* End Marker */
4219 { } 4268 { }
4220}; 4269};
@@ -4709,8 +4758,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
4709 4758
4710/** 4759/**
4711 * ata_qc_new - Request an available ATA command, for queueing 4760 * ata_qc_new - Request an available ATA command, for queueing
4712 * @ap: Port associated with device @dev 4761 * @ap: target port
4713 * @dev: Device from whom we request an available command structure
4714 * 4762 *
4715 * LOCKING: 4763 * LOCKING:
4716 * None. 4764 * None.
@@ -5175,7 +5223,7 @@ bool ata_phys_link_online(struct ata_link *link)
5175 u32 sstatus; 5223 u32 sstatus;
5176 5224
5177 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5225 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5178 (sstatus & 0xf) == 0x3) 5226 ata_sstatus_online(sstatus))
5179 return true; 5227 return true;
5180 return false; 5228 return false;
5181} 5229}
@@ -5199,7 +5247,7 @@ bool ata_phys_link_offline(struct ata_link *link)
5199 u32 sstatus; 5247 u32 sstatus;
5200 5248
5201 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && 5249 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
5202 (sstatus & 0xf) != 0x3) 5250 !ata_sstatus_online(sstatus))
5203 return true; 5251 return true;
5204 return false; 5252 return false;
5205} 5253}
@@ -5412,8 +5460,8 @@ void ata_dev_init(struct ata_device *dev)
5412 dev->horkage = 0; 5460 dev->horkage = 0;
5413 spin_unlock_irqrestore(ap->lock, flags); 5461 spin_unlock_irqrestore(ap->lock, flags);
5414 5462
5415 memset((void *)dev + ATA_DEVICE_CLEAR_OFFSET, 0, 5463 memset((void *)dev + ATA_DEVICE_CLEAR_BEGIN, 0,
5416 sizeof(*dev) - ATA_DEVICE_CLEAR_OFFSET); 5464 ATA_DEVICE_CLEAR_END - ATA_DEVICE_CLEAR_BEGIN);
5417 dev->pio_mask = UINT_MAX; 5465 dev->pio_mask = UINT_MAX;
5418 dev->mwdma_mask = UINT_MAX; 5466 dev->mwdma_mask = UINT_MAX;
5419 dev->udma_mask = UINT_MAX; 5467 dev->udma_mask = UINT_MAX;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8147a8386370..ce2ef0475339 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -82,6 +82,10 @@ enum {
82 ATA_EH_FASTDRAIN_INTERVAL = 3000, 82 ATA_EH_FASTDRAIN_INTERVAL = 3000,
83 83
84 ATA_EH_UA_TRIES = 5, 84 ATA_EH_UA_TRIES = 5,
85
86 /* probe speed down parameters, see ata_eh_schedule_probe() */
87 ATA_EH_PROBE_TRIAL_INTERVAL = 60000, /* 1 min */
88 ATA_EH_PROBE_TRIALS = 2,
85}; 89};
86 90
87/* The following table determines how we sequence resets. Each entry 91/* The following table determines how we sequence resets. Each entry
@@ -1176,6 +1180,32 @@ void ata_eh_qc_retry(struct ata_queued_cmd *qc)
1176} 1180}
1177 1181
1178/** 1182/**
1183 * ata_dev_disable - disable ATA device
1184 * @dev: ATA device to disable
1185 *
1186 * Disable @dev.
1187 *
1188 * Locking:
1189 * EH context.
1190 */
1191void ata_dev_disable(struct ata_device *dev)
1192{
1193 if (!ata_dev_enabled(dev))
1194 return;
1195
1196 if (ata_msg_drv(dev->link->ap))
1197 ata_dev_printk(dev, KERN_WARNING, "disabled\n");
1198 ata_acpi_on_disable(dev);
1199 ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | ATA_DNXFER_QUIET);
1200 dev->class++;
1201
1202 /* From now till the next successful probe, ering is used to
1203 * track probe failures. Clear accumulated device error info.
1204 */
1205 ata_ering_clear(&dev->ering);
1206}
1207
1208/**
1179 * ata_eh_detach_dev - detach ATA device 1209 * ata_eh_detach_dev - detach ATA device
1180 * @dev: ATA device to detach 1210 * @dev: ATA device to detach
1181 * 1211 *
@@ -1849,7 +1879,7 @@ static unsigned int ata_eh_speed_down(struct ata_device *dev,
1849 /* speed down? */ 1879 /* speed down? */
1850 if (verdict & ATA_EH_SPDN_SPEED_DOWN) { 1880 if (verdict & ATA_EH_SPDN_SPEED_DOWN) {
1851 /* speed down SATA link speed if possible */ 1881 /* speed down SATA link speed if possible */
1852 if (sata_down_spd_limit(link) == 0) { 1882 if (sata_down_spd_limit(link, 0) == 0) {
1853 action |= ATA_EH_RESET; 1883 action |= ATA_EH_RESET;
1854 goto done; 1884 goto done;
1855 } 1885 }
@@ -2601,11 +2631,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
2601 } 2631 }
2602 2632
2603 if (try == max_tries - 1) { 2633 if (try == max_tries - 1) {
2604 sata_down_spd_limit(link); 2634 sata_down_spd_limit(link, 0);
2605 if (slave) 2635 if (slave)
2606 sata_down_spd_limit(slave); 2636 sata_down_spd_limit(slave, 0);
2607 } else if (rc == -EPIPE) 2637 } else if (rc == -EPIPE)
2608 sata_down_spd_limit(failed_link); 2638 sata_down_spd_limit(failed_link, 0);
2609 2639
2610 if (hardreset) 2640 if (hardreset)
2611 reset = hardreset; 2641 reset = hardreset;
@@ -2744,6 +2774,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2744 readid_flags, dev->id); 2774 readid_flags, dev->id);
2745 switch (rc) { 2775 switch (rc) {
2746 case 0: 2776 case 0:
2777 /* clear error info accumulated during probe */
2778 ata_ering_clear(&dev->ering);
2747 new_mask |= 1 << dev->devno; 2779 new_mask |= 1 << dev->devno;
2748 break; 2780 break;
2749 case -ENOENT: 2781 case -ENOENT:
@@ -2947,9 +2979,24 @@ static int ata_eh_skip_recovery(struct ata_link *link)
2947 return 1; 2979 return 1;
2948} 2980}
2949 2981
2982static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg)
2983{
2984 u64 interval = msecs_to_jiffies(ATA_EH_PROBE_TRIAL_INTERVAL);
2985 u64 now = get_jiffies_64();
2986 int *trials = void_arg;
2987
2988 if (ent->timestamp < now - min(now, interval))
2989 return -1;
2990
2991 (*trials)++;
2992 return 0;
2993}
2994
2950static int ata_eh_schedule_probe(struct ata_device *dev) 2995static int ata_eh_schedule_probe(struct ata_device *dev)
2951{ 2996{
2952 struct ata_eh_context *ehc = &dev->link->eh_context; 2997 struct ata_eh_context *ehc = &dev->link->eh_context;
2998 struct ata_link *link = ata_dev_phys_link(dev);
2999 int trials = 0;
2953 3000
2954 if (!(ehc->i.probe_mask & (1 << dev->devno)) || 3001 if (!(ehc->i.probe_mask & (1 << dev->devno)) ||
2955 (ehc->did_probe_mask & (1 << dev->devno))) 3002 (ehc->did_probe_mask & (1 << dev->devno)))
@@ -2962,6 +3009,25 @@ static int ata_eh_schedule_probe(struct ata_device *dev)
2962 ehc->saved_xfer_mode[dev->devno] = 0; 3009 ehc->saved_xfer_mode[dev->devno] = 0;
2963 ehc->saved_ncq_enabled &= ~(1 << dev->devno); 3010 ehc->saved_ncq_enabled &= ~(1 << dev->devno);
2964 3011
3012 /* Record and count probe trials on the ering. The specific
3013 * error mask used is irrelevant. Because a successful device
3014 * detection clears the ering, this count accumulates only if
3015 * there are consecutive failed probes.
3016 *
3017 * If the count is equal to or higher than ATA_EH_PROBE_TRIALS
3018 * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is
3019 * forced to 1.5Gbps.
3020 *
3021 * This is to work around cases where failed link speed
3022 * negotiation results in device misdetection leading to
3023 * infinite DEVXCHG or PHRDY CHG events.
3024 */
3025 ata_ering_record(&dev->ering, 0, AC_ERR_OTHER);
3026 ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials);
3027
3028 if (trials > ATA_EH_PROBE_TRIALS)
3029 sata_down_spd_limit(link, 1);
3030
2965 return 1; 3031 return 1;
2966} 3032}
2967 3033
@@ -2969,7 +3035,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2969{ 3035{
2970 struct ata_eh_context *ehc = &dev->link->eh_context; 3036 struct ata_eh_context *ehc = &dev->link->eh_context;
2971 3037
2972 ehc->tries[dev->devno]--; 3038 /* -EAGAIN from EH routine indicates retry without prejudice.
3039 * The requester is responsible for ensuring forward progress.
3040 */
3041 if (err != -EAGAIN)
3042 ehc->tries[dev->devno]--;
2973 3043
2974 switch (err) { 3044 switch (err) {
2975 case -ENODEV: 3045 case -ENODEV:
@@ -2979,12 +3049,13 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2979 /* give it just one more chance */ 3049 /* give it just one more chance */
2980 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); 3050 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
2981 case -EIO: 3051 case -EIO:
2982 if (ehc->tries[dev->devno] == 1 && dev->pio_mode > XFER_PIO_0) { 3052 if (ehc->tries[dev->devno] == 1) {
2983 /* This is the last chance, better to slow 3053 /* This is the last chance, better to slow
2984 * down than lose it. 3054 * down than lose it.
2985 */ 3055 */
2986 sata_down_spd_limit(ata_dev_phys_link(dev)); 3056 sata_down_spd_limit(ata_dev_phys_link(dev), 0);
2987 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); 3057 if (dev->pio_mode > XFER_PIO_0)
3058 ata_down_xfermask_limit(dev, ATA_DNXFER_PIO);
2988 } 3059 }
2989 } 3060 }
2990 3061
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 98ca07a2db87..619f2c33950e 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -729,7 +729,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
729 if (tries) { 729 if (tries) {
730 /* consecutive revalidation failures? speed down */ 730 /* consecutive revalidation failures? speed down */
731 if (reval_failed) 731 if (reval_failed)
732 sata_down_spd_limit(link); 732 sata_down_spd_limit(link, 0);
733 else 733 else
734 reval_failed = 1; 734 reval_failed = 1;
735 735
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 3c4c5ae277ba..b9747fa59e54 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -415,6 +415,7 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
415 415
416/** 416/**
417 * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl 417 * ata_get_identity - Handler for HDIO_GET_IDENTITY ioctl
418 * @ap: target port
418 * @sdev: SCSI device to get identify data for 419 * @sdev: SCSI device to get identify data for
419 * @arg: User buffer area for identify data 420 * @arg: User buffer area for identify data
420 * 421 *
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 0b299b0f8172..714cb046b594 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -773,18 +773,32 @@ unsigned int ata_sff_data_xfer32(struct ata_device *dev, unsigned char *buf,
773 else 773 else
774 iowrite32_rep(data_addr, buf, words); 774 iowrite32_rep(data_addr, buf, words);
775 775
776 /* Transfer trailing bytes, if any */
776 if (unlikely(slop)) { 777 if (unlikely(slop)) {
777 __le32 pad; 778 unsigned char pad[4];
779
780 /* Point buf to the tail of buffer */
781 buf += buflen - slop;
782
783 /*
784 * Use io*_rep() accessors here as well to avoid pointlessly
785 * swapping bytes to and fro on the big endian machines...
786 */
778 if (rw == READ) { 787 if (rw == READ) {
779 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); 788 if (slop < 3)
780 memcpy(buf + buflen - slop, &pad, slop); 789 ioread16_rep(data_addr, pad, 1);
790 else
791 ioread32_rep(data_addr, pad, 1);
792 memcpy(buf, pad, slop);
781 } else { 793 } else {
782 memcpy(&pad, buf + buflen - slop, slop); 794 memcpy(pad, buf, slop);
783 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); 795 if (slop < 3)
796 iowrite16_rep(data_addr, pad, 1);
797 else
798 iowrite32_rep(data_addr, pad, 1);
784 } 799 }
785 words++;
786 } 800 }
787 return words << 2; 801 return (buflen + 1) & ~1;
788} 802}
789EXPORT_SYMBOL_GPL(ata_sff_data_xfer32); 803EXPORT_SYMBOL_GPL(ata_sff_data_xfer32);
790 804
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index fe2839e58774..cea8014cd87e 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -79,7 +79,6 @@ extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
79 u64 block, u32 n_block, unsigned int tf_flags, 79 u64 block, u32 n_block, unsigned int tf_flags,
80 unsigned int tag); 80 unsigned int tag);
81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev); 81extern u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev);
82extern void ata_dev_disable(struct ata_device *dev);
83extern void ata_pio_queue_task(struct ata_port *ap, void *data, 82extern void ata_pio_queue_task(struct ata_port *ap, void *data,
84 unsigned long delay); 83 unsigned long delay);
85extern void ata_port_flush_task(struct ata_port *ap); 84extern void ata_port_flush_task(struct ata_port *ap);
@@ -100,7 +99,7 @@ extern int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags);
100extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class, 99extern int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
101 unsigned int readid_flags); 100 unsigned int readid_flags);
102extern int ata_dev_configure(struct ata_device *dev); 101extern int ata_dev_configure(struct ata_device *dev);
103extern int sata_down_spd_limit(struct ata_link *link); 102extern int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
104extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); 103extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
105extern void ata_sg_clean(struct ata_queued_cmd *qc); 104extern void ata_sg_clean(struct ata_queued_cmd *qc);
106extern void ata_qc_free(struct ata_queued_cmd *qc); 105extern void ata_qc_free(struct ata_queued_cmd *qc);
@@ -160,6 +159,7 @@ extern void ata_scsi_error(struct Scsi_Host *host);
160extern void ata_port_wait_eh(struct ata_port *ap); 159extern void ata_port_wait_eh(struct ata_port *ap);
161extern void ata_eh_fastdrain_timerfn(unsigned long arg); 160extern void ata_eh_fastdrain_timerfn(unsigned long arg);
162extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); 161extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc);
162extern void ata_dev_disable(struct ata_device *dev);
163extern void ata_eh_detach_dev(struct ata_device *dev); 163extern void ata_eh_detach_dev(struct ata_device *dev);
164extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, 164extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
165 unsigned int action); 165 unsigned int action);
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 3080f371222c..f1b26f7c8e4d 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -12,7 +12,7 @@
12 * 12 *
13 * Probe code based on drivers/ide/legacy/qd65xx.c 13 * Probe code based on drivers/ide/legacy/qd65xx.c
14 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by 14 * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
15 * Samuel Thibault <samuel.thibault@fnac.net> 15 * Samuel Thibault <samuel.thibault@ens-lyon.org>
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 79a6c9a0b721..ba556d3e6963 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -110,7 +110,8 @@ static const struct via_isa_bridge {
110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 110 { "vt8237s", PCI_DEVICE_ID_VIA_8237S, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 111 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA }, 112 { "cx700", PCI_DEVICE_ID_VIA_CX700, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
113 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES}, 113 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES },
114 { "vt6415", PCI_DEVICE_ID_VIA_6415, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES },
114 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 115 { "vt8237a", PCI_DEVICE_ID_VIA_8237A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
115 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 116 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
116 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 117 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -593,6 +594,7 @@ static int via_reinit_one(struct pci_dev *pdev)
593#endif 594#endif
594 595
595static const struct pci_device_id via[] = { 596static const struct pci_device_id via[] = {
597 { PCI_VDEVICE(VIA, 0x0415), },
596 { PCI_VDEVICE(VIA, 0x0571), }, 598 { PCI_VDEVICE(VIA, 0x0571), },
597 { PCI_VDEVICE(VIA, 0x0581), }, 599 { PCI_VDEVICE(VIA, 0x0581), },
598 { PCI_VDEVICE(VIA, 0x1571), }, 600 { PCI_VDEVICE(VIA, 0x1571), },
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index f2d8a020ea53..4ae1a4138b47 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -663,8 +663,8 @@ static const struct pci_device_id mv_pci_tbl[] = {
663 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, 663 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x },
664 /* RocketRAID 1720/174x have different identifiers */ 664 /* RocketRAID 1720/174x have different identifiers */
665 { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, 665 { PCI_VDEVICE(TTI, 0x1720), chip_6042 },
666 { PCI_VDEVICE(TTI, 0x1740), chip_508x }, 666 { PCI_VDEVICE(TTI, 0x1740), chip_6042 },
667 { PCI_VDEVICE(TTI, 0x1742), chip_508x }, 667 { PCI_VDEVICE(TTI, 0x1742), chip_6042 },
668 668
669 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, 669 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x },
670 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, 670 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x },
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index c49ad0e61b6f..55a8eed3f3a3 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -421,26 +421,33 @@ static struct ata_port_operations nv_generic_ops = {
421 .hardreset = ATA_OP_NULL, 421 .hardreset = ATA_OP_NULL,
422}; 422};
423 423
424/* OSDL bz3352 reports that nf2/3 controllers can't determine device 424/* nf2 is ripe with hardreset related problems.
425 * signature reliably. Also, the following thread reports detection 425 *
426 * failure on cold boot with the standard debouncing timing. 426 * kernel bz#3352 reports nf2/3 controllers can't determine device
427 * signature reliably. The following thread reports detection failure
428 * on cold boot with the standard debouncing timing.
427 * 429 *
428 * http://thread.gmane.org/gmane.linux.ide/34098 430 * http://thread.gmane.org/gmane.linux.ide/34098
429 * 431 *
430 * Debounce with hotplug timing and request follow-up SRST. 432 * And bz#12176 reports that hardreset simply doesn't work on nf2.
433 * Give up on it and just don't do hardreset.
431 */ 434 */
432static struct ata_port_operations nv_nf2_ops = { 435static struct ata_port_operations nv_nf2_ops = {
433 .inherits = &nv_common_ops, 436 .inherits = &nv_generic_ops,
434 .freeze = nv_nf2_freeze, 437 .freeze = nv_nf2_freeze,
435 .thaw = nv_nf2_thaw, 438 .thaw = nv_nf2_thaw,
436 .hardreset = nv_noclassify_hardreset,
437}; 439};
438 440
439/* CK804 finally gets hardreset right */ 441/* For initial probing after boot and hot plugging, hardreset mostly
442 * works fine on CK804 but curiously, reprobing on the initial port by
443 * rescanning or rmmod/insmod fails to acquire the initial D2H Reg FIS
444 * in somewhat undeterministic way. Use noclassify hardreset.
445 */
440static struct ata_port_operations nv_ck804_ops = { 446static struct ata_port_operations nv_ck804_ops = {
441 .inherits = &nv_common_ops, 447 .inherits = &nv_common_ops,
442 .freeze = nv_ck804_freeze, 448 .freeze = nv_ck804_freeze,
443 .thaw = nv_ck804_thaw, 449 .thaw = nv_ck804_thaw,
450 .hardreset = nv_noclassify_hardreset,
444 .host_stop = nv_ck804_host_stop, 451 .host_stop = nv_ck804_host_stop,
445}; 452};
446 453
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 9f029595f454..d0091609e210 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -324,7 +324,7 @@ static void sil_fill_sg(struct ata_queued_cmd *qc)
324 324
325 prd->addr = cpu_to_le32(addr); 325 prd->addr = cpu_to_le32(addr);
326 prd->flags_len = cpu_to_le32(sg_len); 326 prd->flags_len = cpu_to_le32(sg_len);
327 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, sg_len); 327 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", si, addr, sg_len);
328 328
329 last_prd = prd; 329 last_prd = prd;
330 prd++; 330 prd++;