aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-20 22:56:23 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-20 22:56:23 -0500
commit7be5cb14611945044306ecb7444678c43df21135 (patch)
treeaa381f5a5ecdb7f0f144bb2afa919b44782de0b8
parent1803f3389b7ac9ed33ea561b3b94e22e2864a95d (diff)
parent73fd8b6d310196ae878767200786503fcff57bd5 (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: libata: fix kernel-doc parameter warning sata_mv: remove iounmap in mv_platform_remove and use devm_iomap ata: fix sparse warning in libata.h libata: implement libata.force module parameter sata_mv: use hpriv->base instead of the host->iomap sata_mv: Define module alias for platform device ata: fix sparse warnings in pata_legacy.c
-rw-r--r--Documentation/kernel-parameters.txt35
-rw-r--r--drivers/ata/libata-core.c380
-rw-r--r--drivers/ata/libata-eh.c8
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_legacy.c44
-rw-r--r--drivers/ata/sata_mv.c9
-rw-r--r--include/linux/libata.h2
8 files changed, 448 insertions, 33 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 7278295f94d2..9a5b6658c65e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -950,6 +950,41 @@ and is between 256 and 4096 characters. It is defined in the file
950 when set. 950 when set.
951 Format: <int> 951 Format: <int>
952 952
953 libata.force= [LIBATA] Force configurations. The format is comma
954 separated list of "[ID:]VAL" where ID is
955 PORT[:DEVICE]. PORT and DEVICE are decimal numbers
956 matching port, link or device. Basically, it matches
957 the ATA ID string printed on console by libata. If
958 the whole ID part is omitted, the last PORT and DEVICE
959 values are used. If ID hasn't been specified yet, the
960 configuration applies to all ports, links and devices.
961
962 If only DEVICE is omitted, the parameter applies to
963 the port and all links and devices behind it. DEVICE
964 number of 0 either selects the first device or the
965 first fan-out link behind PMP device. It does not
966 select the host link. DEVICE number of 15 selects the
967 host link and device attached to it.
968
969 The VAL specifies the configuration to force. As long
970 as there's no ambiguity shortcut notation is allowed.
971 For example, both 1.5 and 1.5G would work for 1.5Gbps.
972 The following configurations can be forced.
973
974 * Cable type: 40c, 80c, short40c, unk, ign or sata.
975 Any ID with matching PORT is used.
976
977 * SATA link speed limit: 1.5Gbps or 3.0Gbps.
978
979 * Transfer mode: pio[0-7], mwdma[0-4] and udma[0-7].
980 udma[/][16,25,33,44,66,100,133] notation is also
981 allowed.
982
983 * [no]ncq: Turn on or off NCQ.
984
985 If there are multiple matching configurations changing
986 the same attribute, the last one is used.
987
953 load_ramdisk= [RAM] List of ramdisks to load from floppy 988 load_ramdisk= [RAM] List of ramdisks to load from floppy
954 See Documentation/ramdisk.txt. 989 See Documentation/ramdisk.txt.
955 990
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index def3682f416a..60d1bb556973 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -87,6 +87,28 @@ static struct workqueue_struct *ata_wq;
87 87
88struct workqueue_struct *ata_aux_wq; 88struct workqueue_struct *ata_aux_wq;
89 89
90struct ata_force_param {
91 const char *name;
92 unsigned int cbl;
93 int spd_limit;
94 unsigned long xfer_mask;
95 unsigned int horkage_on;
96 unsigned int horkage_off;
97};
98
99struct ata_force_ent {
100 int port;
101 int device;
102 struct ata_force_param param;
103};
104
105static struct ata_force_ent *ata_force_tbl;
106static int ata_force_tbl_size;
107
108static char ata_force_param_buf[PAGE_SIZE] __initdata;
109module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0444);
110MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
111
90int atapi_enabled = 1; 112int atapi_enabled = 1;
91module_param(atapi_enabled, int, 0444); 113module_param(atapi_enabled, int, 0444);
92MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); 114MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
@@ -130,6 +152,179 @@ MODULE_VERSION(DRV_VERSION);
130 152
131 153
132/** 154/**
155 * ata_force_cbl - force cable type according to libata.force
156 * @link: ATA link of interest
157 *
158 * Force cable type according to libata.force and whine about it.
159 * The last entry which has matching port number is used, so it
160 * can be specified as part of device force parameters. For
161 * example, both "a:40c,1.00:udma4" and "1.00:40c,udma4" have the
162 * same effect.
163 *
164 * LOCKING:
165 * EH context.
166 */
167void ata_force_cbl(struct ata_port *ap)
168{
169 int i;
170
171 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
172 const struct ata_force_ent *fe = &ata_force_tbl[i];
173
174 if (fe->port != -1 && fe->port != ap->print_id)
175 continue;
176
177 if (fe->param.cbl == ATA_CBL_NONE)
178 continue;
179
180 ap->cbl = fe->param.cbl;
181 ata_port_printk(ap, KERN_NOTICE,
182 "FORCE: cable set to %s\n", fe->param.name);
183 return;
184 }
185}
186
187/**
188 * ata_force_spd_limit - force SATA spd limit according to libata.force
189 * @link: ATA link of interest
190 *
191 * Force SATA spd limit according to libata.force and whine about
192 * it. When only the port part is specified (e.g. 1:), the limit
193 * applies to all links connected to both the host link and all
194 * fan-out ports connected via PMP. If the device part is
195 * specified as 0 (e.g. 1.00:), it specifies the first fan-out
196 * link not the host link. Device number 15 always points to the
197 * host link whether PMP is attached or not.
198 *
199 * LOCKING:
200 * EH context.
201 */
202static void ata_force_spd_limit(struct ata_link *link)
203{
204 int linkno, i;
205
206 if (ata_is_host_link(link))
207 linkno = 15;
208 else
209 linkno = link->pmp;
210
211 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
212 const struct ata_force_ent *fe = &ata_force_tbl[i];
213
214 if (fe->port != -1 && fe->port != link->ap->print_id)
215 continue;
216
217 if (fe->device != -1 && fe->device != linkno)
218 continue;
219
220 if (!fe->param.spd_limit)
221 continue;
222
223 link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1;
224 ata_link_printk(link, KERN_NOTICE,
225 "FORCE: PHY spd limit set to %s\n", fe->param.name);
226 return;
227 }
228}
229
230/**
231 * ata_force_xfermask - force xfermask according to libata.force
232 * @dev: ATA device of interest
233 *
234 * Force xfer_mask according to libata.force and whine about it.
235 * For consistency with link selection, device number 15 selects
236 * the first device connected to the host link.
237 *
238 * LOCKING:
239 * EH context.
240 */
241static void ata_force_xfermask(struct ata_device *dev)
242{
243 int devno = dev->link->pmp + dev->devno;
244 int alt_devno = devno;
245 int i;
246
247 /* allow n.15 for the first device attached to host port */
248 if (ata_is_host_link(dev->link) && devno == 0)
249 alt_devno = 15;
250
251 for (i = ata_force_tbl_size - 1; i >= 0; i--) {
252 const struct ata_force_ent *fe = &ata_force_tbl[i];
253 unsigned long pio_mask, mwdma_mask, udma_mask;
254
255 if (fe->port != -1 && fe->port != dev->link->ap->print_id)
256 continue;
257
258 if (fe->device != -1 && fe->device != devno &&
259 fe->device != alt_devno)
260 continue;
261
262 if (!fe->param.xfer_mask)
263 continue;
264
265 ata_unpack_xfermask(fe->param.xfer_mask,
266 &pio_mask, &mwdma_mask, &udma_mask);
267 if (udma_mask)
268 dev->udma_mask = udma_mask;
269 else if (mwdma_mask) {
270 dev->udma_mask = 0;
271 dev->mwdma_mask = mwdma_mask;
272 } else {
273 dev->udma_mask = 0;
274 dev->mwdma_mask = 0;
275 dev->pio_mask = pio_mask;
276 }
277
278 ata_dev_printk(dev, KERN_NOTICE,
279 "FORCE: xfer_mask set to %s\n", fe->param.name);
280 return;
281 }
282}
283
284/**
285 * ata_force_horkage - force horkage according to libata.force
286 * @dev: ATA device of interest
287 *
288 * Force horkage according to libata.force and whine about it.
289 * For consistency with link selection, device number 15 selects
290 * the first device connected to the host link.
291 *
292 * LOCKING:
293 * EH context.
294 */
295static void ata_force_horkage(struct ata_device *dev)
296{
297 int devno = dev->link->pmp + dev->devno;
298 int alt_devno = devno;
299 int i;
300
301 /* allow n.15 for the first device attached to host port */
302 if (ata_is_host_link(dev->link) && devno == 0)
303 alt_devno = 15;
304
305 for (i = 0; i < ata_force_tbl_size; i++) {
306 const struct ata_force_ent *fe = &ata_force_tbl[i];
307
308 if (fe->port != -1 && fe->port != dev->link->ap->print_id)
309 continue;
310
311 if (fe->device != -1 && fe->device != devno &&
312 fe->device != alt_devno)
313 continue;
314
315 if (!(~dev->horkage & fe->param.horkage_on) &&
316 !(dev->horkage & fe->param.horkage_off))
317 continue;
318
319 dev->horkage |= fe->param.horkage_on;
320 dev->horkage &= ~fe->param.horkage_off;
321
322 ata_dev_printk(dev, KERN_NOTICE,
323 "FORCE: horkage modified (%s)\n", fe->param.name);
324 }
325}
326
327/**
133 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure 328 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
134 * @tf: Taskfile to convert 329 * @tf: Taskfile to convert
135 * @pmp: Port multiplier port 330 * @pmp: Port multiplier port
@@ -2067,6 +2262,7 @@ int ata_dev_configure(struct ata_device *dev)
2067 2262
2068 /* set horkage */ 2263 /* set horkage */
2069 dev->horkage |= ata_dev_blacklisted(dev); 2264 dev->horkage |= ata_dev_blacklisted(dev);
2265 ata_force_horkage(dev);
2070 2266
2071 /* let ACPI work its magic */ 2267 /* let ACPI work its magic */
2072 rc = ata_acpi_on_devcfg(dev); 2268 rc = ata_acpi_on_devcfg(dev);
@@ -3150,6 +3346,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
3150 mode_mask = ATA_DMA_MASK_CFA; 3346 mode_mask = ATA_DMA_MASK_CFA;
3151 3347
3152 ata_dev_xfermask(dev); 3348 ata_dev_xfermask(dev);
3349 ata_force_xfermask(dev);
3153 3350
3154 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); 3351 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
3155 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 3352 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
@@ -6497,7 +6694,8 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
6497 */ 6694 */
6498int sata_link_init_spd(struct ata_link *link) 6695int sata_link_init_spd(struct ata_link *link)
6499{ 6696{
6500 u32 scontrol, spd; 6697 u32 scontrol;
6698 u8 spd;
6501 int rc; 6699 int rc;
6502 6700
6503 rc = sata_scr_read(link, SCR_CONTROL, &scontrol); 6701 rc = sata_scr_read(link, SCR_CONTROL, &scontrol);
@@ -6508,6 +6706,8 @@ int sata_link_init_spd(struct ata_link *link)
6508 if (spd) 6706 if (spd)
6509 link->hw_sata_spd_limit &= (1 << spd) - 1; 6707 link->hw_sata_spd_limit &= (1 << spd) - 1;
6510 6708
6709 ata_force_spd_limit(link);
6710
6511 link->sata_spd_limit = link->hw_sata_spd_limit; 6711 link->sata_spd_limit = link->hw_sata_spd_limit;
6512 6712
6513 return 0; 6713 return 0;
@@ -7218,10 +7418,187 @@ int ata_pci_device_resume(struct pci_dev *pdev)
7218 7418
7219#endif /* CONFIG_PCI */ 7419#endif /* CONFIG_PCI */
7220 7420
7421static int __init ata_parse_force_one(char **cur,
7422 struct ata_force_ent *force_ent,
7423 const char **reason)
7424{
7425 /* FIXME: Currently, there's no way to tag init const data and
7426 * using __initdata causes build failure on some versions of
7427 * gcc. Once __initdataconst is implemented, add const to the
7428 * following structure.
7429 */
7430 static struct ata_force_param force_tbl[] __initdata = {
7431 { "40c", .cbl = ATA_CBL_PATA40 },
7432 { "80c", .cbl = ATA_CBL_PATA80 },
7433 { "short40c", .cbl = ATA_CBL_PATA40_SHORT },
7434 { "unk", .cbl = ATA_CBL_PATA_UNK },
7435 { "ign", .cbl = ATA_CBL_PATA_IGN },
7436 { "sata", .cbl = ATA_CBL_SATA },
7437 { "1.5Gbps", .spd_limit = 1 },
7438 { "3.0Gbps", .spd_limit = 2 },
7439 { "noncq", .horkage_on = ATA_HORKAGE_NONCQ },
7440 { "ncq", .horkage_off = ATA_HORKAGE_NONCQ },
7441 { "pio0", .xfer_mask = 1 << (ATA_SHIFT_PIO + 0) },
7442 { "pio1", .xfer_mask = 1 << (ATA_SHIFT_PIO + 1) },
7443 { "pio2", .xfer_mask = 1 << (ATA_SHIFT_PIO + 2) },
7444 { "pio3", .xfer_mask = 1 << (ATA_SHIFT_PIO + 3) },
7445 { "pio4", .xfer_mask = 1 << (ATA_SHIFT_PIO + 4) },
7446 { "pio5", .xfer_mask = 1 << (ATA_SHIFT_PIO + 5) },
7447 { "pio6", .xfer_mask = 1 << (ATA_SHIFT_PIO + 6) },
7448 { "mwdma0", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 0) },
7449 { "mwdma1", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 1) },
7450 { "mwdma2", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 2) },
7451 { "mwdma3", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 3) },
7452 { "mwdma4", .xfer_mask = 1 << (ATA_SHIFT_MWDMA + 4) },
7453 { "udma0", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
7454 { "udma16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
7455 { "udma/16", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 0) },
7456 { "udma1", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
7457 { "udma25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
7458 { "udma/25", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 1) },
7459 { "udma2", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
7460 { "udma33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
7461 { "udma/33", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 2) },
7462 { "udma3", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
7463 { "udma44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
7464 { "udma/44", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 3) },
7465 { "udma4", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
7466 { "udma66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
7467 { "udma/66", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 4) },
7468 { "udma5", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
7469 { "udma100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
7470 { "udma/100", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 5) },
7471 { "udma6", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
7472 { "udma133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
7473 { "udma/133", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 6) },
7474 { "udma7", .xfer_mask = 1 << (ATA_SHIFT_UDMA + 7) },
7475 };
7476 char *start = *cur, *p = *cur;
7477 char *id, *val, *endp;
7478 const struct ata_force_param *match_fp = NULL;
7479 int nr_matches = 0, i;
7480
7481 /* find where this param ends and update *cur */
7482 while (*p != '\0' && *p != ',')
7483 p++;
7484
7485 if (*p == '\0')
7486 *cur = p;
7487 else
7488 *cur = p + 1;
7489
7490 *p = '\0';
7491
7492 /* parse */
7493 p = strchr(start, ':');
7494 if (!p) {
7495 val = strstrip(start);
7496 goto parse_val;
7497 }
7498 *p = '\0';
7499
7500 id = strstrip(start);
7501 val = strstrip(p + 1);
7502
7503 /* parse id */
7504 p = strchr(id, '.');
7505 if (p) {
7506 *p++ = '\0';
7507 force_ent->device = simple_strtoul(p, &endp, 10);
7508 if (p == endp || *endp != '\0') {
7509 *reason = "invalid device";
7510 return -EINVAL;
7511 }
7512 }
7513
7514 force_ent->port = simple_strtoul(id, &endp, 10);
7515 if (p == endp || *endp != '\0') {
7516 *reason = "invalid port/link";
7517 return -EINVAL;
7518 }
7519
7520 parse_val:
7521 /* parse val, allow shortcuts so that both 1.5 and 1.5Gbps work */
7522 for (i = 0; i < ARRAY_SIZE(force_tbl); i++) {
7523 const struct ata_force_param *fp = &force_tbl[i];
7524
7525 if (strncasecmp(val, fp->name, strlen(val)))
7526 continue;
7527
7528 nr_matches++;
7529 match_fp = fp;
7530
7531 if (strcasecmp(val, fp->name) == 0) {
7532 nr_matches = 1;
7533 break;
7534 }
7535 }
7536
7537 if (!nr_matches) {
7538 *reason = "unknown value";
7539 return -EINVAL;
7540 }
7541 if (nr_matches > 1) {
7542 *reason = "ambigious value";
7543 return -EINVAL;
7544 }
7545
7546 force_ent->param = *match_fp;
7547
7548 return 0;
7549}
7550
7551static void __init ata_parse_force_param(void)
7552{
7553 int idx = 0, size = 1;
7554 int last_port = -1, last_device = -1;
7555 char *p, *cur, *next;
7556
7557 /* calculate maximum number of params and allocate force_tbl */
7558 for (p = ata_force_param_buf; *p; p++)
7559 if (*p == ',')
7560 size++;
7561
7562 ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL);
7563 if (!ata_force_tbl) {
7564 printk(KERN_WARNING "ata: failed to extend force table, "
7565 "libata.force ignored\n");
7566 return;
7567 }
7568
7569 /* parse and populate the table */
7570 for (cur = ata_force_param_buf; *cur != '\0'; cur = next) {
7571 const char *reason = "";
7572 struct ata_force_ent te = { .port = -1, .device = -1 };
7573
7574 next = cur;
7575 if (ata_parse_force_one(&next, &te, &reason)) {
7576 printk(KERN_WARNING "ata: failed to parse force "
7577 "parameter \"%s\" (%s)\n",
7578 cur, reason);
7579 continue;
7580 }
7581
7582 if (te.port == -1) {
7583 te.port = last_port;
7584 te.device = last_device;
7585 }
7586
7587 ata_force_tbl[idx++] = te;
7588
7589 last_port = te.port;
7590 last_device = te.device;
7591 }
7592
7593 ata_force_tbl_size = idx;
7594}
7221 7595
7222static int __init ata_init(void) 7596static int __init ata_init(void)
7223{ 7597{
7224 ata_probe_timeout *= HZ; 7598 ata_probe_timeout *= HZ;
7599
7600 ata_parse_force_param();
7601
7225 ata_wq = create_workqueue("ata"); 7602 ata_wq = create_workqueue("ata");
7226 if (!ata_wq) 7603 if (!ata_wq)
7227 return -ENOMEM; 7604 return -ENOMEM;
@@ -7238,6 +7615,7 @@ static int __init ata_init(void)
7238 7615
7239static void __exit ata_exit(void) 7616static void __exit ata_exit(void)
7240{ 7617{
7618 kfree(ata_force_tbl);
7241 destroy_workqueue(ata_wq); 7619 destroy_workqueue(ata_wq);
7242 destroy_workqueue(ata_aux_wq); 7620 destroy_workqueue(ata_aux_wq);
7243} 7621}
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 4e31071acc02..698ce2cea52c 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2393,9 +2393,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2393 } 2393 }
2394 2394
2395 /* PDIAG- should have been released, ask cable type if post-reset */ 2395 /* PDIAG- should have been released, ask cable type if post-reset */
2396 if (ata_is_host_link(link) && ap->ops->cable_detect && 2396 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) {
2397 (ehc->i.flags & ATA_EHI_DID_RESET)) 2397 if (ap->ops->cable_detect)
2398 ap->cbl = ap->ops->cable_detect(ap); 2398 ap->cbl = ap->ops->cable_detect(ap);
2399 ata_force_cbl(ap);
2400 }
2399 2401
2400 /* Configure new devices forward such that user doesn't see 2402 /* Configure new devices forward such that user doesn't see
2401 * device detection messages backwards. 2403 * device detection messages backwards.
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index dd41b1a1b304..f888babc8283 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -828,7 +828,7 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
828 828
829/** 829/**
830 * atapi_drain_needed - Check whether data transfer may overflow 830 * atapi_drain_needed - Check whether data transfer may overflow
831 * @request: request to be checked 831 * @rq: request to be checked
832 * 832 *
833 * ATAPI commands which transfer variable length data to host 833 * ATAPI commands which transfer variable length data to host
834 * might overflow due to application error or hardare bug. This 834 * might overflow due to application error or hardare bug. This
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 409ffb9af163..6036dedfe377 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -61,6 +61,7 @@ extern int atapi_passthru16;
61extern int libata_fua; 61extern int libata_fua;
62extern int libata_noacpi; 62extern int libata_noacpi;
63extern int libata_allow_tpm; 63extern int libata_allow_tpm;
64extern void ata_force_cbl(struct ata_port *ap);
64extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 65extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
65extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 66extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
66 u64 block, u32 n_block, unsigned int tf_flags, 67 u64 block, u32 n_block, unsigned int tf_flags,
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index d2177f75078a..50fe08ebe23c 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -774,14 +774,14 @@ static struct ata_port_operations opti82c46x_port_ops = {
774static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev) 774static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
775{ 775{
776 struct ata_timing t; 776 struct ata_timing t;
777 struct legacy_data *qdi = ap->host->private_data; 777 struct legacy_data *ld_qdi = ap->host->private_data;
778 int active, recovery; 778 int active, recovery;
779 u8 timing; 779 u8 timing;
780 780
781 /* Get the timing data in cycles */ 781 /* Get the timing data in cycles */
782 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); 782 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
783 783
784 if (qdi->fast) { 784 if (ld_qdi->fast) {
785 active = 8 - FIT(t.active, 1, 8); 785 active = 8 - FIT(t.active, 1, 8);
786 recovery = 18 - FIT(t.recover, 3, 18); 786 recovery = 18 - FIT(t.recover, 3, 18);
787 } else { 787 } else {
@@ -790,9 +790,9 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
790 } 790 }
791 timing = (recovery << 4) | active | 0x08; 791 timing = (recovery << 4) | active | 0x08;
792 792
793 qdi->clock[adev->devno] = timing; 793 ld_qdi->clock[adev->devno] = timing;
794 794
795 outb(timing, qdi->timing); 795 outb(timing, ld_qdi->timing);
796} 796}
797 797
798/** 798/**
@@ -808,14 +808,14 @@ static void qdi6500_set_piomode(struct ata_port *ap, struct ata_device *adev)
808static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev) 808static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev)
809{ 809{
810 struct ata_timing t; 810 struct ata_timing t;
811 struct legacy_data *qdi = ap->host->private_data; 811 struct legacy_data *ld_qdi = ap->host->private_data;
812 int active, recovery; 812 int active, recovery;
813 u8 timing; 813 u8 timing;
814 814
815 /* Get the timing data in cycles */ 815 /* Get the timing data in cycles */
816 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); 816 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
817 817
818 if (qdi->fast) { 818 if (ld_qdi->fast) {
819 active = 8 - FIT(t.active, 1, 8); 819 active = 8 - FIT(t.active, 1, 8);
820 recovery = 18 - FIT(t.recover, 3, 18); 820 recovery = 18 - FIT(t.recover, 3, 18);
821 } else { 821 } else {
@@ -824,12 +824,12 @@ static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev)
824 } 824 }
825 timing = (recovery << 4) | active | 0x08; 825 timing = (recovery << 4) | active | 0x08;
826 826
827 qdi->clock[adev->devno] = timing; 827 ld_qdi->clock[adev->devno] = timing;
828 828
829 outb(timing, qdi->timing + 2 * ap->port_no); 829 outb(timing, ld_qdi->timing + 2 * ap->port_no);
830 /* Clear the FIFO */ 830 /* Clear the FIFO */
831 if (adev->class != ATA_DEV_ATA) 831 if (adev->class != ATA_DEV_ATA)
832 outb(0x5F, qdi->timing + 3); 832 outb(0x5F, ld_qdi->timing + 3);
833} 833}
834 834
835/** 835/**
@@ -845,14 +845,14 @@ static void qdi6580dp_set_piomode(struct ata_port *ap, struct ata_device *adev)
845static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev) 845static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
846{ 846{
847 struct ata_timing t; 847 struct ata_timing t;
848 struct legacy_data *qdi = ap->host->private_data; 848 struct legacy_data *ld_qdi = ap->host->private_data;
849 int active, recovery; 849 int active, recovery;
850 u8 timing; 850 u8 timing;
851 851
852 /* Get the timing data in cycles */ 852 /* Get the timing data in cycles */
853 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000); 853 ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
854 854
855 if (qdi->fast) { 855 if (ld_qdi->fast) {
856 active = 8 - FIT(t.active, 1, 8); 856 active = 8 - FIT(t.active, 1, 8);
857 recovery = 18 - FIT(t.recover, 3, 18); 857 recovery = 18 - FIT(t.recover, 3, 18);
858 } else { 858 } else {
@@ -860,11 +860,11 @@ static void qdi6580_set_piomode(struct ata_port *ap, struct ata_device *adev)
860 recovery = 15 - FIT(t.recover, 0, 15); 860 recovery = 15 - FIT(t.recover, 0, 15);
861 } 861 }
862 timing = (recovery << 4) | active | 0x08; 862 timing = (recovery << 4) | active | 0x08;
863 qdi->clock[adev->devno] = timing; 863 ld_qdi->clock[adev->devno] = timing;
864 outb(timing, qdi->timing + 2 * adev->devno); 864 outb(timing, ld_qdi->timing + 2 * adev->devno);
865 /* Clear the FIFO */ 865 /* Clear the FIFO */
866 if (adev->class != ATA_DEV_ATA) 866 if (adev->class != ATA_DEV_ATA)
867 outb(0x5F, qdi->timing + 3); 867 outb(0x5F, ld_qdi->timing + 3);
868} 868}
869 869
870/** 870/**
@@ -879,12 +879,12 @@ static unsigned int qdi_qc_issue_prot(struct ata_queued_cmd *qc)
879{ 879{
880 struct ata_port *ap = qc->ap; 880 struct ata_port *ap = qc->ap;
881 struct ata_device *adev = qc->dev; 881 struct ata_device *adev = qc->dev;
882 struct legacy_data *qdi = ap->host->private_data; 882 struct legacy_data *ld_qdi = ap->host->private_data;
883 883
884 if (qdi->clock[adev->devno] != qdi->last) { 884 if (ld_qdi->clock[adev->devno] != ld_qdi->last) {
885 if (adev->pio_mode) { 885 if (adev->pio_mode) {
886 qdi->last = qdi->clock[adev->devno]; 886 ld_qdi->last = ld_qdi->clock[adev->devno];
887 outb(qdi->clock[adev->devno], qdi->timing + 887 outb(ld_qdi->clock[adev->devno], ld_qdi->timing +
888 2 * ap->port_no); 888 2 * ap->port_no);
889 } 889 }
890 } 890 }
@@ -1037,12 +1037,12 @@ static u8 winbond_readcfg(unsigned long port, u8 reg)
1037static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) 1037static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
1038{ 1038{
1039 struct ata_timing t; 1039 struct ata_timing t;
1040 struct legacy_data *winbond = ap->host->private_data; 1040 struct legacy_data *ld_winbond = ap->host->private_data;
1041 int active, recovery; 1041 int active, recovery;
1042 u8 reg; 1042 u8 reg;
1043 int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2); 1043 int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2);
1044 1044
1045 reg = winbond_readcfg(winbond->timing, 0x81); 1045 reg = winbond_readcfg(ld_winbond->timing, 0x81);
1046 1046
1047 /* Get the timing data in cycles */ 1047 /* Get the timing data in cycles */
1048 if (reg & 0x40) /* Fast VLB bus, assume 50MHz */ 1048 if (reg & 0x40) /* Fast VLB bus, assume 50MHz */
@@ -1053,7 +1053,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
1053 active = (FIT(t.active, 3, 17) - 1) & 0x0F; 1053 active = (FIT(t.active, 3, 17) - 1) & 0x0F;
1054 recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F; 1054 recovery = (FIT(t.recover, 1, 15) + 1) & 0x0F;
1055 timing = (active << 4) | recovery; 1055 timing = (active << 4) | recovery;
1056 winbond_writecfg(winbond->timing, timing, reg); 1056 winbond_writecfg(ld_winbond->timing, timing, reg);
1057 1057
1058 /* Load the setup timing */ 1058 /* Load the setup timing */
1059 1059
@@ -1063,7 +1063,7 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
1063 if (!ata_pio_need_iordy(adev)) 1063 if (!ata_pio_need_iordy(adev))
1064 reg |= 0x02; /* IORDY off */ 1064 reg |= 0x02; /* IORDY off */
1065 reg |= (FIT(t.setup, 0, 3) << 6); 1065 reg |= (FIT(t.setup, 0, 3) << 6);
1066 winbond_writecfg(winbond->timing, timing + 1, reg); 1066 winbond_writecfg(ld_winbond->timing, timing + 1, reg);
1067} 1067}
1068 1068
1069static int winbond_port(struct platform_device *dev, 1069static int winbond_port(struct platform_device *dev,
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 1c1fbf375d9a..6ebebde8454a 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -870,7 +870,7 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,
870 struct mv_host_priv *hpriv = ap->host->private_data; 870 struct mv_host_priv *hpriv = ap->host->private_data;
871 int hard_port = mv_hardport_from_port(ap->port_no); 871 int hard_port = mv_hardport_from_port(ap->port_no);
872 void __iomem *hc_mmio = mv_hc_base_from_port( 872 void __iomem *hc_mmio = mv_hc_base_from_port(
873 ap->host->iomap[MV_PRIMARY_BAR], hard_port); 873 mv_host_base(ap->host), hard_port);
874 u32 hc_irq_cause, ipending; 874 u32 hc_irq_cause, ipending;
875 875
876 /* clear EDMA event indicators, if any */ 876 /* clear EDMA event indicators, if any */
@@ -2947,7 +2947,8 @@ static int mv_platform_probe(struct platform_device *pdev)
2947 hpriv->n_ports = n_ports; 2947 hpriv->n_ports = n_ports;
2948 2948
2949 host->iomap = NULL; 2949 host->iomap = NULL;
2950 hpriv->base = ioremap(res->start, res->end - res->start + 1); 2950 hpriv->base = devm_ioremap(&pdev->dev, res->start,
2951 res->end - res->start + 1);
2951 hpriv->base -= MV_SATAHC0_REG_BASE; 2952 hpriv->base -= MV_SATAHC0_REG_BASE;
2952 2953
2953 rc = mv_create_dma_pools(hpriv, &pdev->dev); 2954 rc = mv_create_dma_pools(hpriv, &pdev->dev);
@@ -2979,11 +2980,8 @@ static int __devexit mv_platform_remove(struct platform_device *pdev)
2979{ 2980{
2980 struct device *dev = &pdev->dev; 2981 struct device *dev = &pdev->dev;
2981 struct ata_host *host = dev_get_drvdata(dev); 2982 struct ata_host *host = dev_get_drvdata(dev);
2982 struct mv_host_priv *hpriv = host->private_data;
2983 void __iomem *base = hpriv->base;
2984 2983
2985 ata_host_detach(host); 2984 ata_host_detach(host);
2986 iounmap(base);
2987 return 0; 2985 return 0;
2988} 2986}
2989 2987
@@ -3194,6 +3192,7 @@ MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers");
3194MODULE_LICENSE("GPL"); 3192MODULE_LICENSE("GPL");
3195MODULE_DEVICE_TABLE(pci, mv_pci_tbl); 3193MODULE_DEVICE_TABLE(pci, mv_pci_tbl);
3196MODULE_VERSION(DRV_VERSION); 3194MODULE_VERSION(DRV_VERSION);
3195MODULE_ALIAS("platform:sata_mv");
3197 3196
3198#ifdef CONFIG_PCI 3197#ifdef CONFIG_PCI
3199module_param(msi, int, 0444); 3198module_param(msi, int, 0444);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 2e098f940cec..ce7603a73156 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1197,7 +1197,7 @@ static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1197 return ap->pmp_link; 1197 return ap->pmp_link;
1198 } 1198 }
1199 1199
1200 if (++link - ap->pmp_link < ap->nr_pmp_links) 1200 if (++link < ap->nr_pmp_links + ap->pmp_link)
1201 return link; 1201 return link;
1202 return NULL; 1202 return NULL;
1203} 1203}