aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/ahci.c3
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c2
-rw-r--r--drivers/scsi/ata_piix.c18
-rw-r--r--drivers/scsi/libata-core.c489
-rw-r--r--drivers/scsi/libata-scsi.c2
-rw-r--r--drivers/scsi/libata.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c24
-rw-r--r--drivers/scsi/sata_nv.c2
-rw-r--r--drivers/scsi/sata_promise.c1
-rw-r--r--drivers/scsi/sata_qstor.c2
-rw-r--r--drivers/scsi/sata_sil.c9
-rw-r--r--drivers/scsi/sata_sis.c1
-rw-r--r--drivers/scsi/sata_svw.c1
-rw-r--r--drivers/scsi/sata_sx4.c2
-rw-r--r--drivers/scsi/sata_uli.c1
-rw-r--r--drivers/scsi/sata_via.c1
-rw-r--r--drivers/scsi/sata_vsc.c2
-rw-r--r--drivers/scsi/scsi_scan.c1
19 files changed, 483 insertions, 82 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 88e34095ca4e..96df148ed969 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1748,7 +1748,7 @@ config SCSI_NCR53C7xx_FAST
1748 1748
1749config SUN3_SCSI 1749config SUN3_SCSI
1750 tristate "Sun3 NCR5380 SCSI" 1750 tristate "Sun3 NCR5380 SCSI"
1751 depends on SUN3 && SCSI 1751 depends on SUN3 && SCSI && BROKEN
1752 help 1752 help
1753 This option will enable support for the OBIO (onboard io) NCR5380 1753 This option will enable support for the OBIO (onboard io) NCR5380
1754 SCSI controller found in the Sun 3/50 and 3/60, as well as for 1754 SCSI controller found in the Sun 3/50 and 3/60, as well as for
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index da5bd33d982d..fc5263c6b102 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/dma-mapping.h>
35#include "scsi.h" 36#include "scsi.h"
36#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
37#include <linux/libata.h> 38#include <linux/libata.h>
@@ -289,6 +290,8 @@ static void ahci_host_stop(struct ata_host_set *host_set)
289{ 290{
290 struct ahci_host_priv *hpriv = host_set->private_data; 291 struct ahci_host_priv *hpriv = host_set->private_data;
291 kfree(hpriv); 292 kfree(hpriv);
293
294 ata_host_stop(host_set);
292} 295}
293 296
294static int ahci_port_start(struct ata_port *ap) 297static int ahci_port_start(struct ata_port *ap)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 53b7b2c15f86..c4eaaad2c69b 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -2488,7 +2488,7 @@ ahd_linux_dv_thread(void *data)
2488 sprintf(current->comm, "ahd_dv_%d", ahd->unit); 2488 sprintf(current->comm, "ahd_dv_%d", ahd->unit);
2489#else 2489#else
2490 daemonize("ahd_dv_%d", ahd->unit); 2490 daemonize("ahd_dv_%d", ahd->unit);
2491 current->flags |= PF_FREEZE; 2491 current->flags |= PF_NOFREEZE;
2492#endif 2492#endif
2493 unlock_kernel(); 2493 unlock_kernel();
2494 2494
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 3867f91ef8c7..3be546439252 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -153,6 +153,7 @@ static struct ata_port_operations piix_pata_ops = {
153 153
154 .port_start = ata_port_start, 154 .port_start = ata_port_start,
155 .port_stop = ata_port_stop, 155 .port_stop = ata_port_stop,
156 .host_stop = ata_host_stop,
156}; 157};
157 158
158static struct ata_port_operations piix_sata_ops = { 159static struct ata_port_operations piix_sata_ops = {
@@ -180,6 +181,7 @@ static struct ata_port_operations piix_sata_ops = {
180 181
181 .port_start = ata_port_start, 182 .port_start = ata_port_start,
182 .port_stop = ata_port_stop, 183 .port_stop = ata_port_stop,
184 .host_stop = ata_host_stop,
183}; 185};
184 186
185static struct ata_port_info piix_port_info[] = { 187static struct ata_port_info piix_port_info[] = {
@@ -663,15 +665,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
663 return ata_pci_init_one(pdev, port_info, n_ports); 665 return ata_pci_init_one(pdev, port_info, n_ports);
664} 666}
665 667
666/**
667 * piix_init -
668 *
669 * LOCKING:
670 *
671 * RETURNS:
672 *
673 */
674
675static int __init piix_init(void) 668static int __init piix_init(void)
676{ 669{
677 int rc; 670 int rc;
@@ -687,13 +680,6 @@ static int __init piix_init(void)
687 return 0; 680 return 0;
688} 681}
689 682
690/**
691 * piix_exit -
692 *
693 * LOCKING:
694 *
695 */
696
697static void __exit piix_exit(void) 683static void __exit piix_exit(void)
698{ 684{
699 pci_unregister_driver(&piix_pci_driver); 685 pci_unregister_driver(&piix_pci_driver);
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 63d3f70d06e1..9e58f134f68b 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -186,6 +186,28 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
186 ata_wait_idle(ap); 186 ata_wait_idle(ap);
187} 187}
188 188
189
190/**
191 * ata_tf_load - send taskfile registers to host controller
192 * @ap: Port to which output is sent
193 * @tf: ATA taskfile register set
194 *
195 * Outputs ATA taskfile to standard ATA host controller using MMIO
196 * or PIO as indicated by the ATA_FLAG_MMIO flag.
197 * Writes the control, feature, nsect, lbal, lbam, and lbah registers.
198 * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,
199 * hob_lbal, hob_lbam, and hob_lbah.
200 *
201 * This function waits for idle (!BUSY and !DRQ) after writing
202 * registers. If the control register has a new value, this
203 * function also waits for idle after writing control and before
204 * writing the remaining registers.
205 *
206 * May be used as the tf_load() entry in ata_port_operations.
207 *
208 * LOCKING:
209 * Inherited from caller.
210 */
189void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 211void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
190{ 212{
191 if (ap->flags & ATA_FLAG_MMIO) 213 if (ap->flags & ATA_FLAG_MMIO)
@@ -195,11 +217,11 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
195} 217}
196 218
197/** 219/**
198 * ata_exec_command - issue ATA command to host controller 220 * ata_exec_command_pio - issue ATA command to host controller
199 * @ap: port to which command is being issued 221 * @ap: port to which command is being issued
200 * @tf: ATA taskfile register set 222 * @tf: ATA taskfile register set
201 * 223 *
202 * Issues PIO/MMIO write to ATA command register, with proper 224 * Issues PIO write to ATA command register, with proper
203 * synchronization with interrupt handler / other threads. 225 * synchronization with interrupt handler / other threads.
204 * 226 *
205 * LOCKING: 227 * LOCKING:
@@ -235,6 +257,18 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
235 ata_pause(ap); 257 ata_pause(ap);
236} 258}
237 259
260
261/**
262 * ata_exec_command - issue ATA command to host controller
263 * @ap: port to which command is being issued
264 * @tf: ATA taskfile register set
265 *
266 * Issues PIO/MMIO write to ATA command register, with proper
267 * synchronization with interrupt handler / other threads.
268 *
269 * LOCKING:
270 * spin_lock_irqsave(host_set lock)
271 */
238void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 272void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)
239{ 273{
240 if (ap->flags & ATA_FLAG_MMIO) 274 if (ap->flags & ATA_FLAG_MMIO)
@@ -305,7 +339,7 @@ void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf)
305} 339}
306 340
307/** 341/**
308 * ata_tf_read - input device's ATA taskfile shadow registers 342 * ata_tf_read_pio - input device's ATA taskfile shadow registers
309 * @ap: Port from which input is read 343 * @ap: Port from which input is read
310 * @tf: ATA taskfile register set for storing input 344 * @tf: ATA taskfile register set for storing input
311 * 345 *
@@ -368,6 +402,23 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf)
368 } 402 }
369} 403}
370 404
405
406/**
407 * ata_tf_read - input device's ATA taskfile shadow registers
408 * @ap: Port from which input is read
409 * @tf: ATA taskfile register set for storing input
410 *
411 * Reads ATA taskfile registers for currently-selected device
412 * into @tf.
413 *
414 * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48
415 * is set, also reads the hob registers.
416 *
417 * May be used as the tf_read() entry in ata_port_operations.
418 *
419 * LOCKING:
420 * Inherited from caller.
421 */
371void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) 422void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
372{ 423{
373 if (ap->flags & ATA_FLAG_MMIO) 424 if (ap->flags & ATA_FLAG_MMIO)
@@ -381,7 +432,7 @@ void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
381 * @ap: port where the device is 432 * @ap: port where the device is
382 * 433 *
383 * Reads ATA taskfile status register for currently-selected device 434 * Reads ATA taskfile status register for currently-selected device
384 * and return it's value. This also clears pending interrupts 435 * and return its value. This also clears pending interrupts
385 * from this device 436 * from this device
386 * 437 *
387 * LOCKING: 438 * LOCKING:
@@ -397,7 +448,7 @@ static u8 ata_check_status_pio(struct ata_port *ap)
397 * @ap: port where the device is 448 * @ap: port where the device is
398 * 449 *
399 * Reads ATA taskfile status register for currently-selected device 450 * Reads ATA taskfile status register for currently-selected device
400 * via MMIO and return it's value. This also clears pending interrupts 451 * via MMIO and return its value. This also clears pending interrupts
401 * from this device 452 * from this device
402 * 453 *
403 * LOCKING: 454 * LOCKING:
@@ -408,6 +459,20 @@ static u8 ata_check_status_mmio(struct ata_port *ap)
408 return readb((void __iomem *) ap->ioaddr.status_addr); 459 return readb((void __iomem *) ap->ioaddr.status_addr);
409} 460}
410 461
462
463/**
464 * ata_check_status - Read device status reg & clear interrupt
465 * @ap: port where the device is
466 *
467 * Reads ATA taskfile status register for currently-selected device
468 * and return its value. This also clears pending interrupts
469 * from this device
470 *
471 * May be used as the check_status() entry in ata_port_operations.
472 *
473 * LOCKING:
474 * Inherited from caller.
475 */
411u8 ata_check_status(struct ata_port *ap) 476u8 ata_check_status(struct ata_port *ap)
412{ 477{
413 if (ap->flags & ATA_FLAG_MMIO) 478 if (ap->flags & ATA_FLAG_MMIO)
@@ -415,6 +480,20 @@ u8 ata_check_status(struct ata_port *ap)
415 return ata_check_status_pio(ap); 480 return ata_check_status_pio(ap);
416} 481}
417 482
483
484/**
485 * ata_altstatus - Read device alternate status reg
486 * @ap: port where the device is
487 *
488 * Reads ATA taskfile alternate status register for
489 * currently-selected device and return its value.
490 *
491 * Note: may NOT be used as the check_altstatus() entry in
492 * ata_port_operations.
493 *
494 * LOCKING:
495 * Inherited from caller.
496 */
418u8 ata_altstatus(struct ata_port *ap) 497u8 ata_altstatus(struct ata_port *ap)
419{ 498{
420 if (ap->ops->check_altstatus) 499 if (ap->ops->check_altstatus)
@@ -425,6 +504,20 @@ u8 ata_altstatus(struct ata_port *ap)
425 return inb(ap->ioaddr.altstatus_addr); 504 return inb(ap->ioaddr.altstatus_addr);
426} 505}
427 506
507
508/**
509 * ata_chk_err - Read device error reg
510 * @ap: port where the device is
511 *
512 * Reads ATA taskfile error register for
513 * currently-selected device and return its value.
514 *
515 * Note: may NOT be used as the check_err() entry in
516 * ata_port_operations.
517 *
518 * LOCKING:
519 * Inherited from caller.
520 */
428u8 ata_chk_err(struct ata_port *ap) 521u8 ata_chk_err(struct ata_port *ap)
429{ 522{
430 if (ap->ops->check_err) 523 if (ap->ops->check_err)
@@ -873,10 +966,24 @@ void ata_dev_id_string(u16 *id, unsigned char *s,
873 } 966 }
874} 967}
875 968
969
970/**
971 * ata_noop_dev_select - Select device 0/1 on ATA bus
972 * @ap: ATA channel to manipulate
973 * @device: ATA device (numbered from zero) to select
974 *
975 * This function performs no actual function.
976 *
977 * May be used as the dev_select() entry in ata_port_operations.
978 *
979 * LOCKING:
980 * caller.
981 */
876void ata_noop_dev_select (struct ata_port *ap, unsigned int device) 982void ata_noop_dev_select (struct ata_port *ap, unsigned int device)
877{ 983{
878} 984}
879 985
986
880/** 987/**
881 * ata_std_dev_select - Select device 0/1 on ATA bus 988 * ata_std_dev_select - Select device 0/1 on ATA bus
882 * @ap: ATA channel to manipulate 989 * @ap: ATA channel to manipulate
@@ -884,7 +991,9 @@ void ata_noop_dev_select (struct ata_port *ap, unsigned int device)
884 * 991 *
885 * Use the method defined in the ATA specification to 992 * Use the method defined in the ATA specification to
886 * make either device 0, or device 1, active on the 993 * make either device 0, or device 1, active on the
887 * ATA channel. 994 * ATA channel. Works with both PIO and MMIO.
995 *
996 * May be used as the dev_select() entry in ata_port_operations.
888 * 997 *
889 * LOCKING: 998 * LOCKING:
890 * caller. 999 * caller.
@@ -1190,7 +1299,12 @@ err_out:
1190 * ata_bus_probe - Reset and probe ATA bus 1299 * ata_bus_probe - Reset and probe ATA bus
1191 * @ap: Bus to probe 1300 * @ap: Bus to probe
1192 * 1301 *
1302 * Master ATA bus probing function. Initiates a hardware-dependent
1303 * bus reset, then attempts to identify any devices found on
1304 * the bus.
1305 *
1193 * LOCKING: 1306 * LOCKING:
1307 * PCI/etc. bus probe sem.
1194 * 1308 *
1195 * RETURNS: 1309 * RETURNS:
1196 * Zero on success, non-zero on error. 1310 * Zero on success, non-zero on error.
@@ -1229,10 +1343,14 @@ err_out:
1229} 1343}
1230 1344
1231/** 1345/**
1232 * ata_port_probe - 1346 * ata_port_probe - Mark port as enabled
1233 * @ap: 1347 * @ap: Port for which we indicate enablement
1234 * 1348 *
1235 * LOCKING: 1349 * Modify @ap data structure such that the system
1350 * thinks that the entire port is enabled.
1351 *
1352 * LOCKING: host_set lock, or some other form of
1353 * serialization.
1236 */ 1354 */
1237 1355
1238void ata_port_probe(struct ata_port *ap) 1356void ata_port_probe(struct ata_port *ap)
@@ -1241,10 +1359,15 @@ void ata_port_probe(struct ata_port *ap)
1241} 1359}
1242 1360
1243/** 1361/**
1244 * __sata_phy_reset - 1362 * __sata_phy_reset - Wake/reset a low-level SATA PHY
1245 * @ap: 1363 * @ap: SATA port associated with target SATA PHY.
1364 *
1365 * This function issues commands to standard SATA Sxxx
1366 * PHY registers, to wake up the phy (and device), and
1367 * clear any reset condition.
1246 * 1368 *
1247 * LOCKING: 1369 * LOCKING:
1370 * PCI/etc. bus probe sem.
1248 * 1371 *
1249 */ 1372 */
1250void __sata_phy_reset(struct ata_port *ap) 1373void __sata_phy_reset(struct ata_port *ap)
@@ -1289,10 +1412,14 @@ void __sata_phy_reset(struct ata_port *ap)
1289} 1412}
1290 1413
1291/** 1414/**
1292 * __sata_phy_reset - 1415 * sata_phy_reset - Reset SATA bus.
1293 * @ap: 1416 * @ap: SATA port associated with target SATA PHY.
1417 *
1418 * This function resets the SATA bus, and then probes
1419 * the bus for devices.
1294 * 1420 *
1295 * LOCKING: 1421 * LOCKING:
1422 * PCI/etc. bus probe sem.
1296 * 1423 *
1297 */ 1424 */
1298void sata_phy_reset(struct ata_port *ap) 1425void sata_phy_reset(struct ata_port *ap)
@@ -1304,10 +1431,16 @@ void sata_phy_reset(struct ata_port *ap)
1304} 1431}
1305 1432
1306/** 1433/**
1307 * ata_port_disable - 1434 * ata_port_disable - Disable port.
1308 * @ap: 1435 * @ap: Port to be disabled.
1309 * 1436 *
1310 * LOCKING: 1437 * Modify @ap data structure such that the system
1438 * thinks that the entire port is disabled, and should
1439 * never attempt to probe or communicate with devices
1440 * on this port.
1441 *
1442 * LOCKING: host_set lock, or some other form of
1443 * serialization.
1311 */ 1444 */
1312 1445
1313void ata_port_disable(struct ata_port *ap) 1446void ata_port_disable(struct ata_port *ap)
@@ -1416,7 +1549,10 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode,
1416 * ata_set_mode - Program timings and issue SET FEATURES - XFER 1549 * ata_set_mode - Program timings and issue SET FEATURES - XFER
1417 * @ap: port on which timings will be programmed 1550 * @ap: port on which timings will be programmed
1418 * 1551 *
1552 * Set ATA device disk transfer mode (PIO3, UDMA6, etc.).
1553 *
1419 * LOCKING: 1554 * LOCKING:
1555 * PCI/etc. bus probe sem.
1420 * 1556 *
1421 */ 1557 */
1422static void ata_set_mode(struct ata_port *ap) 1558static void ata_set_mode(struct ata_port *ap)
@@ -1467,7 +1603,10 @@ err_out:
1467 * @tmout_pat: impatience timeout 1603 * @tmout_pat: impatience timeout
1468 * @tmout: overall timeout 1604 * @tmout: overall timeout
1469 * 1605 *
1470 * LOCKING: 1606 * Sleep until ATA Status register bit BSY clears,
1607 * or a timeout occurs.
1608 *
1609 * LOCKING: None.
1471 * 1610 *
1472 */ 1611 */
1473 1612
@@ -1553,10 +1692,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1553} 1692}
1554 1693
1555/** 1694/**
1556 * ata_bus_edd - 1695 * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command.
1557 * @ap: 1696 * @ap: Port to reset and probe
1697 *
1698 * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and
1699 * probe the bus. Not often used these days.
1558 * 1700 *
1559 * LOCKING: 1701 * LOCKING:
1702 * PCI/etc. bus probe sem.
1560 * 1703 *
1561 */ 1704 */
1562 1705
@@ -1633,8 +1776,8 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
1633 * the device is ATA or ATAPI. 1776 * the device is ATA or ATAPI.
1634 * 1777 *
1635 * LOCKING: 1778 * LOCKING:
1636 * Inherited from caller. Some functions called by this function 1779 * PCI/etc. bus probe sem.
1637 * obtain the host_set lock. 1780 * Obtains host_set lock.
1638 * 1781 *
1639 * SIDE EFFECTS: 1782 * SIDE EFFECTS:
1640 * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. 1783 * Sets ATA_FLAG_PORT_DISABLED if bus reset fails.
@@ -1876,7 +2019,11 @@ static int fgb(u32 bitmap)
1876 * @xfer_mode_out: (output) SET FEATURES - XFER MODE code 2019 * @xfer_mode_out: (output) SET FEATURES - XFER MODE code
1877 * @xfer_shift_out: (output) bit shift that selects this mode 2020 * @xfer_shift_out: (output) bit shift that selects this mode
1878 * 2021 *
2022 * Based on host and device capabilities, determine the
2023 * maximum transfer mode that is amenable to all.
2024 *
1879 * LOCKING: 2025 * LOCKING:
2026 * PCI/etc. bus probe sem.
1880 * 2027 *
1881 * RETURNS: 2028 * RETURNS:
1882 * Zero on success, negative on error. 2029 * Zero on success, negative on error.
@@ -1909,7 +2056,11 @@ static int ata_choose_xfer_mode(struct ata_port *ap,
1909 * @ap: Port associated with device @dev 2056 * @ap: Port associated with device @dev
1910 * @dev: Device to which command will be sent 2057 * @dev: Device to which command will be sent
1911 * 2058 *
2059 * Issue SET FEATURES - XFER MODE command to device @dev
2060 * on port @ap.
2061 *
1912 * LOCKING: 2062 * LOCKING:
2063 * PCI/etc. bus probe sem.
1913 */ 2064 */
1914 2065
1915static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) 2066static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
@@ -1947,10 +2098,13 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
1947} 2098}
1948 2099
1949/** 2100/**
1950 * ata_sg_clean - 2101 * ata_sg_clean - Unmap DMA memory associated with command
1951 * @qc: 2102 * @qc: Command containing DMA memory to be released
2103 *
2104 * Unmap all mapped DMA memory associated with this command.
1952 * 2105 *
1953 * LOCKING: 2106 * LOCKING:
2107 * spin_lock_irqsave(host_set lock)
1954 */ 2108 */
1955 2109
1956static void ata_sg_clean(struct ata_queued_cmd *qc) 2110static void ata_sg_clean(struct ata_queued_cmd *qc)
@@ -1981,7 +2135,11 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
1981 * ata_fill_sg - Fill PCI IDE PRD table 2135 * ata_fill_sg - Fill PCI IDE PRD table
1982 * @qc: Metadata associated with taskfile to be transferred 2136 * @qc: Metadata associated with taskfile to be transferred
1983 * 2137 *
2138 * Fill PCI IDE PRD (scatter-gather) table with segments
2139 * associated with the current disk command.
2140 *
1984 * LOCKING: 2141 * LOCKING:
2142 * spin_lock_irqsave(host_set lock)
1985 * 2143 *
1986 */ 2144 */
1987static void ata_fill_sg(struct ata_queued_cmd *qc) 2145static void ata_fill_sg(struct ata_queued_cmd *qc)
@@ -2028,7 +2186,13 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
2028 * ata_check_atapi_dma - Check whether ATAPI DMA can be supported 2186 * ata_check_atapi_dma - Check whether ATAPI DMA can be supported
2029 * @qc: Metadata associated with taskfile to check 2187 * @qc: Metadata associated with taskfile to check
2030 * 2188 *
2189 * Allow low-level driver to filter ATA PACKET commands, returning
2190 * a status indicating whether or not it is OK to use DMA for the
2191 * supplied PACKET command.
2192 *
2031 * LOCKING: 2193 * LOCKING:
2194 * spin_lock_irqsave(host_set lock)
2195 *
2032 * RETURNS: 0 when ATAPI DMA can be used 2196 * RETURNS: 0 when ATAPI DMA can be used
2033 * nonzero otherwise 2197 * nonzero otherwise
2034 */ 2198 */
@@ -2046,6 +2210,8 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
2046 * ata_qc_prep - Prepare taskfile for submission 2210 * ata_qc_prep - Prepare taskfile for submission
2047 * @qc: Metadata associated with taskfile to be prepared 2211 * @qc: Metadata associated with taskfile to be prepared
2048 * 2212 *
2213 * Prepare ATA taskfile for submission.
2214 *
2049 * LOCKING: 2215 * LOCKING:
2050 * spin_lock_irqsave(host_set lock) 2216 * spin_lock_irqsave(host_set lock)
2051 */ 2217 */
@@ -2057,6 +2223,32 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2057 ata_fill_sg(qc); 2223 ata_fill_sg(qc);
2058} 2224}
2059 2225
2226/**
2227 * ata_sg_init_one - Associate command with memory buffer
2228 * @qc: Command to be associated
2229 * @buf: Memory buffer
2230 * @buflen: Length of memory buffer, in bytes.
2231 *
2232 * Initialize the data-related elements of queued_cmd @qc
2233 * to point to a single memory buffer, @buf of byte length @buflen.
2234 *
2235 * LOCKING:
2236 * spin_lock_irqsave(host_set lock)
2237 */
2238
2239
2240
2241/**
2242 * ata_sg_init_one - Prepare a one-entry scatter-gather list.
2243 * @qc: Queued command
2244 * @buf: transfer buffer
2245 * @buflen: length of buf
2246 *
2247 * Builds a single-entry scatter-gather list to initiate a
2248 * transfer utilizing the specified buffer.
2249 *
2250 * LOCKING:
2251 */
2060void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) 2252void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2061{ 2253{
2062 struct scatterlist *sg; 2254 struct scatterlist *sg;
@@ -2074,6 +2266,32 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
2074 sg->length = buflen; 2266 sg->length = buflen;
2075} 2267}
2076 2268
2269/**
2270 * ata_sg_init - Associate command with scatter-gather table.
2271 * @qc: Command to be associated
2272 * @sg: Scatter-gather table.
2273 * @n_elem: Number of elements in s/g table.
2274 *
2275 * Initialize the data-related elements of queued_cmd @qc
2276 * to point to a scatter-gather table @sg, containing @n_elem
2277 * elements.
2278 *
2279 * LOCKING:
2280 * spin_lock_irqsave(host_set lock)
2281 */
2282
2283
2284/**
2285 * ata_sg_init - Assign a scatter gather list to a queued command
2286 * @qc: Queued command
2287 * @sg: Scatter-gather list
2288 * @n_elem: length of sg list
2289 *
2290 * Attaches a scatter-gather list to a queued command.
2291 *
2292 * LOCKING:
2293 */
2294
2077void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 2295void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
2078 unsigned int n_elem) 2296 unsigned int n_elem)
2079{ 2297{
@@ -2083,14 +2301,16 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
2083} 2301}
2084 2302
2085/** 2303/**
2086 * ata_sg_setup_one - 2304 * ata_sg_setup_one - DMA-map the memory buffer associated with a command.
2087 * @qc: 2305 * @qc: Command with memory buffer to be mapped.
2306 *
2307 * DMA-map the memory buffer associated with queued_cmd @qc.
2088 * 2308 *
2089 * LOCKING: 2309 * LOCKING:
2090 * spin_lock_irqsave(host_set lock) 2310 * spin_lock_irqsave(host_set lock)
2091 * 2311 *
2092 * RETURNS: 2312 * RETURNS:
2093 * 2313 * Zero on success, negative on error.
2094 */ 2314 */
2095 2315
2096static int ata_sg_setup_one(struct ata_queued_cmd *qc) 2316static int ata_sg_setup_one(struct ata_queued_cmd *qc)
@@ -2115,13 +2335,16 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2115} 2335}
2116 2336
2117/** 2337/**
2118 * ata_sg_setup - 2338 * ata_sg_setup - DMA-map the scatter-gather table associated with a command.
2119 * @qc: 2339 * @qc: Command with scatter-gather table to be mapped.
2340 *
2341 * DMA-map the scatter-gather table associated with queued_cmd @qc.
2120 * 2342 *
2121 * LOCKING: 2343 * LOCKING:
2122 * spin_lock_irqsave(host_set lock) 2344 * spin_lock_irqsave(host_set lock)
2123 * 2345 *
2124 * RETURNS: 2346 * RETURNS:
2347 * Zero on success, negative on error.
2125 * 2348 *
2126 */ 2349 */
2127 2350
@@ -2151,6 +2374,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2151 * @ap: 2374 * @ap:
2152 * 2375 *
2153 * LOCKING: 2376 * LOCKING:
2377 * None. (executing in kernel thread context)
2154 * 2378 *
2155 * RETURNS: 2379 * RETURNS:
2156 * 2380 *
@@ -2198,6 +2422,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2198 * @ap: 2422 * @ap:
2199 * 2423 *
2200 * LOCKING: 2424 * LOCKING:
2425 * None. (executing in kernel thread context)
2201 */ 2426 */
2202 2427
2203static void ata_pio_complete (struct ata_port *ap) 2428static void ata_pio_complete (struct ata_port *ap)
@@ -2240,6 +2465,18 @@ static void ata_pio_complete (struct ata_port *ap)
2240 ata_qc_complete(qc, drv_stat); 2465 ata_qc_complete(qc, drv_stat);
2241} 2466}
2242 2467
2468
2469/**
2470 * swap_buf_le16 -
2471 * @buf: Buffer to swap
2472 * @buf_words: Number of 16-bit words in buffer.
2473 *
2474 * Swap halves of 16-bit words if needed to convert from
2475 * little-endian byte order to native cpu byte order, or
2476 * vice-versa.
2477 *
2478 * LOCKING:
2479 */
2243void swap_buf_le16(u16 *buf, unsigned int buf_words) 2480void swap_buf_le16(u16 *buf, unsigned int buf_words)
2244{ 2481{
2245#ifdef __BIG_ENDIAN 2482#ifdef __BIG_ENDIAN
@@ -2340,7 +2577,6 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
2340next_sg: 2577next_sg:
2341 sg = &qc->sg[qc->cursg]; 2578 sg = &qc->sg[qc->cursg];
2342 2579
2343next_page:
2344 page = sg->page; 2580 page = sg->page;
2345 offset = sg->offset + qc->cursg_ofs; 2581 offset = sg->offset + qc->cursg_ofs;
2346 2582
@@ -2348,6 +2584,7 @@ next_page:
2348 page = nth_page(page, (offset >> PAGE_SHIFT)); 2584 page = nth_page(page, (offset >> PAGE_SHIFT));
2349 offset %= PAGE_SIZE; 2585 offset %= PAGE_SIZE;
2350 2586
2587 /* don't overrun current sg */
2351 count = min(sg->length - qc->cursg_ofs, bytes); 2588 count = min(sg->length - qc->cursg_ofs, bytes);
2352 2589
2353 /* don't cross page boundaries */ 2590 /* don't cross page boundaries */
@@ -2372,8 +2609,6 @@ next_page:
2372 kunmap(page); 2609 kunmap(page);
2373 2610
2374 if (bytes) { 2611 if (bytes) {
2375 if (qc->cursg_ofs < sg->length)
2376 goto next_page;
2377 goto next_sg; 2612 goto next_sg;
2378 } 2613 }
2379} 2614}
@@ -2415,6 +2650,7 @@ err_out:
2415 * @ap: 2650 * @ap:
2416 * 2651 *
2417 * LOCKING: 2652 * LOCKING:
2653 * None. (executing in kernel thread context)
2418 */ 2654 */
2419 2655
2420static void ata_pio_block(struct ata_port *ap) 2656static void ata_pio_block(struct ata_port *ap)
@@ -2583,6 +2819,7 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
2583 * transaction completed successfully. 2819 * transaction completed successfully.
2584 * 2820 *
2585 * LOCKING: 2821 * LOCKING:
2822 * Inherited from SCSI layer (none, can sleep)
2586 */ 2823 */
2587 2824
2588static void ata_qc_timeout(struct ata_queued_cmd *qc) 2825static void ata_qc_timeout(struct ata_queued_cmd *qc)
@@ -2692,6 +2929,7 @@ out:
2692 * @dev: Device from whom we request an available command structure 2929 * @dev: Device from whom we request an available command structure
2693 * 2930 *
2694 * LOCKING: 2931 * LOCKING:
2932 * None.
2695 */ 2933 */
2696 2934
2697static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) 2935static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
@@ -2717,6 +2955,7 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
2717 * @dev: Device from whom we request an available command structure 2955 * @dev: Device from whom we request an available command structure
2718 * 2956 *
2719 * LOCKING: 2957 * LOCKING:
2958 * None.
2720 */ 2959 */
2721 2960
2722struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 2961struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
@@ -2781,6 +3020,7 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
2781 * in case something prevents using it. 3020 * in case something prevents using it.
2782 * 3021 *
2783 * LOCKING: 3022 * LOCKING:
3023 * spin_lock_irqsave(host_set lock)
2784 * 3024 *
2785 */ 3025 */
2786void ata_qc_free(struct ata_queued_cmd *qc) 3026void ata_qc_free(struct ata_queued_cmd *qc)
@@ -2794,9 +3034,13 @@ void ata_qc_free(struct ata_queued_cmd *qc)
2794/** 3034/**
2795 * ata_qc_complete - Complete an active ATA command 3035 * ata_qc_complete - Complete an active ATA command
2796 * @qc: Command to complete 3036 * @qc: Command to complete
2797 * @drv_stat: ATA status register contents 3037 * @drv_stat: ATA Status register contents
3038 *
3039 * Indicate to the mid and upper layers that an ATA
3040 * command has completed, with either an ok or not-ok status.
2798 * 3041 *
2799 * LOCKING: 3042 * LOCKING:
3043 * spin_lock_irqsave(host_set lock)
2800 * 3044 *
2801 */ 3045 */
2802 3046
@@ -2892,6 +3136,7 @@ err_out:
2892 return -1; 3136 return -1;
2893} 3137}
2894 3138
3139
2895/** 3140/**
2896 * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner 3141 * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner
2897 * @qc: command to issue to device 3142 * @qc: command to issue to device
@@ -2901,6 +3146,8 @@ err_out:
2901 * classes called "protocols", and issuing each type of protocol 3146 * classes called "protocols", and issuing each type of protocol
2902 * is slightly different. 3147 * is slightly different.
2903 * 3148 *
3149 * May be used as the qc_issue() entry in ata_port_operations.
3150 *
2904 * LOCKING: 3151 * LOCKING:
2905 * spin_lock_irqsave(host_set lock) 3152 * spin_lock_irqsave(host_set lock)
2906 * 3153 *
@@ -2958,7 +3205,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
2958} 3205}
2959 3206
2960/** 3207/**
2961 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction 3208 * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
2962 * @qc: Info associated with this ATA transaction. 3209 * @qc: Info associated with this ATA transaction.
2963 * 3210 *
2964 * LOCKING: 3211 * LOCKING:
@@ -3065,6 +3312,18 @@ static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
3065 ap->ioaddr.bmdma_addr + ATA_DMA_CMD); 3312 ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
3066} 3313}
3067 3314
3315
3316/**
3317 * ata_bmdma_start - Start a PCI IDE BMDMA transaction
3318 * @qc: Info associated with this ATA transaction.
3319 *
3320 * Writes the ATA_DMA_START flag to the DMA command register.
3321 *
3322 * May be used as the bmdma_start() entry in ata_port_operations.
3323 *
3324 * LOCKING:
3325 * spin_lock_irqsave(host_set lock)
3326 */
3068void ata_bmdma_start(struct ata_queued_cmd *qc) 3327void ata_bmdma_start(struct ata_queued_cmd *qc)
3069{ 3328{
3070 if (qc->ap->flags & ATA_FLAG_MMIO) 3329 if (qc->ap->flags & ATA_FLAG_MMIO)
@@ -3073,6 +3332,20 @@ void ata_bmdma_start(struct ata_queued_cmd *qc)
3073 ata_bmdma_start_pio(qc); 3332 ata_bmdma_start_pio(qc);
3074} 3333}
3075 3334
3335
3336/**
3337 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
3338 * @qc: Info associated with this ATA transaction.
3339 *
3340 * Writes address of PRD table to device's PRD Table Address
3341 * register, sets the DMA control register, and calls
3342 * ops->exec_command() to start the transfer.
3343 *
3344 * May be used as the bmdma_setup() entry in ata_port_operations.
3345 *
3346 * LOCKING:
3347 * spin_lock_irqsave(host_set lock)
3348 */
3076void ata_bmdma_setup(struct ata_queued_cmd *qc) 3349void ata_bmdma_setup(struct ata_queued_cmd *qc)
3077{ 3350{
3078 if (qc->ap->flags & ATA_FLAG_MMIO) 3351 if (qc->ap->flags & ATA_FLAG_MMIO)
@@ -3081,6 +3354,19 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
3081 ata_bmdma_setup_pio(qc); 3354 ata_bmdma_setup_pio(qc);
3082} 3355}
3083 3356
3357
3358/**
3359 * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
3360 * @ap: Port associated with this ATA transaction.
3361 *
3362 * Clear interrupt and error flags in DMA status register.
3363 *
3364 * May be used as the irq_clear() entry in ata_port_operations.
3365 *
3366 * LOCKING:
3367 * spin_lock_irqsave(host_set lock)
3368 */
3369
3084void ata_bmdma_irq_clear(struct ata_port *ap) 3370void ata_bmdma_irq_clear(struct ata_port *ap)
3085{ 3371{
3086 if (ap->flags & ATA_FLAG_MMIO) { 3372 if (ap->flags & ATA_FLAG_MMIO) {
@@ -3093,6 +3379,19 @@ void ata_bmdma_irq_clear(struct ata_port *ap)
3093 3379
3094} 3380}
3095 3381
3382
3383/**
3384 * ata_bmdma_status - Read PCI IDE BMDMA status
3385 * @ap: Port associated with this ATA transaction.
3386 *
3387 * Read and return BMDMA status register.
3388 *
3389 * May be used as the bmdma_status() entry in ata_port_operations.
3390 *
3391 * LOCKING:
3392 * spin_lock_irqsave(host_set lock)
3393 */
3394
3096u8 ata_bmdma_status(struct ata_port *ap) 3395u8 ata_bmdma_status(struct ata_port *ap)
3097{ 3396{
3098 u8 host_stat; 3397 u8 host_stat;
@@ -3104,6 +3403,19 @@ u8 ata_bmdma_status(struct ata_port *ap)
3104 return host_stat; 3403 return host_stat;
3105} 3404}
3106 3405
3406
3407/**
3408 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
3409 * @ap: Port associated with this ATA transaction.
3410 *
3411 * Clears the ATA_DMA_START flag in the dma control register
3412 *
3413 * May be used as the bmdma_stop() entry in ata_port_operations.
3414 *
3415 * LOCKING:
3416 * spin_lock_irqsave(host_set lock)
3417 */
3418
3107void ata_bmdma_stop(struct ata_port *ap) 3419void ata_bmdma_stop(struct ata_port *ap)
3108{ 3420{
3109 if (ap->flags & ATA_FLAG_MMIO) { 3421 if (ap->flags & ATA_FLAG_MMIO) {
@@ -3203,13 +3515,18 @@ idle_irq:
3203 3515
3204/** 3516/**
3205 * ata_interrupt - Default ATA host interrupt handler 3517 * ata_interrupt - Default ATA host interrupt handler
3206 * @irq: irq line 3518 * @irq: irq line (unused)
3207 * @dev_instance: pointer to our host information structure 3519 * @dev_instance: pointer to our ata_host_set information structure
3208 * @regs: unused 3520 * @regs: unused
3209 * 3521 *
3522 * Default interrupt handler for PCI IDE devices. Calls
3523 * ata_host_intr() for each port that is not disabled.
3524 *
3210 * LOCKING: 3525 * LOCKING:
3526 * Obtains host_set lock during operation.
3211 * 3527 *
3212 * RETURNS: 3528 * RETURNS:
3529 * IRQ_NONE or IRQ_HANDLED.
3213 * 3530 *
3214 */ 3531 */
3215 3532
@@ -3302,6 +3619,19 @@ err_out:
3302 ata_qc_complete(qc, ATA_ERR); 3619 ata_qc_complete(qc, ATA_ERR);
3303} 3620}
3304 3621
3622
3623/**
3624 * ata_port_start - Set port up for dma.
3625 * @ap: Port to initialize
3626 *
3627 * Called just after data structures for each port are
3628 * initialized. Allocates space for PRD table.
3629 *
3630 * May be used as the port_start() entry in ata_port_operations.
3631 *
3632 * LOCKING:
3633 */
3634
3305int ata_port_start (struct ata_port *ap) 3635int ata_port_start (struct ata_port *ap)
3306{ 3636{
3307 struct device *dev = ap->host_set->dev; 3637 struct device *dev = ap->host_set->dev;
@@ -3315,6 +3645,18 @@ int ata_port_start (struct ata_port *ap)
3315 return 0; 3645 return 0;
3316} 3646}
3317 3647
3648
3649/**
3650 * ata_port_stop - Undo ata_port_start()
3651 * @ap: Port to shut down
3652 *
3653 * Frees the PRD table.
3654 *
3655 * May be used as the port_stop() entry in ata_port_operations.
3656 *
3657 * LOCKING:
3658 */
3659
3318void ata_port_stop (struct ata_port *ap) 3660void ata_port_stop (struct ata_port *ap)
3319{ 3661{
3320 struct device *dev = ap->host_set->dev; 3662 struct device *dev = ap->host_set->dev;
@@ -3322,6 +3664,13 @@ void ata_port_stop (struct ata_port *ap)
3322 dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma); 3664 dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
3323} 3665}
3324 3666
3667void ata_host_stop (struct ata_host_set *host_set)
3668{
3669 if (host_set->mmio_base)
3670 iounmap(host_set->mmio_base);
3671}
3672
3673
3325/** 3674/**
3326 * ata_host_remove - Unregister SCSI host structure with upper layers 3675 * ata_host_remove - Unregister SCSI host structure with upper layers
3327 * @ap: Port to unregister 3676 * @ap: Port to unregister
@@ -3350,7 +3699,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
3350 * @ent: Probe information provided by low-level driver 3699 * @ent: Probe information provided by low-level driver
3351 * @port_no: Port number associated with this ata_port 3700 * @port_no: Port number associated with this ata_port
3352 * 3701 *
3702 * Initialize a new ata_port structure, and its associated
3703 * scsi_host.
3704 *
3353 * LOCKING: 3705 * LOCKING:
3706 * Inherited from caller.
3354 * 3707 *
3355 */ 3708 */
3356 3709
@@ -3405,9 +3758,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
3405 * @host_set: Collections of ports to which we add 3758 * @host_set: Collections of ports to which we add
3406 * @port_no: Port number associated with this host 3759 * @port_no: Port number associated with this host
3407 * 3760 *
3761 * Attach low-level ATA driver to system.
3762 *
3408 * LOCKING: 3763 * LOCKING:
3764 * PCI/etc. bus probe sem.
3409 * 3765 *
3410 * RETURNS: 3766 * RETURNS:
3767 * New ata_port on success, for NULL on error.
3411 * 3768 *
3412 */ 3769 */
3413 3770
@@ -3440,12 +3797,22 @@ err_out:
3440} 3797}
3441 3798
3442/** 3799/**
3443 * ata_device_add - 3800 * ata_device_add - Register hardware device with ATA and SCSI layers
3444 * @ent: 3801 * @ent: Probe information describing hardware device to be registered
3802 *
3803 * This function processes the information provided in the probe
3804 * information struct @ent, allocates the necessary ATA and SCSI
3805 * host information structures, initializes them, and registers
3806 * everything with requisite kernel subsystems.
3807 *
3808 * This function requests irqs, probes the ATA bus, and probes
3809 * the SCSI bus.
3445 * 3810 *
3446 * LOCKING: 3811 * LOCKING:
3812 * PCI/etc. bus probe sem.
3447 * 3813 *
3448 * RETURNS: 3814 * RETURNS:
3815 * Number of ports registered. Zero on error (no ports registered).
3449 * 3816 *
3450 */ 3817 */
3451 3818
@@ -3597,7 +3964,15 @@ int ata_scsi_release(struct Scsi_Host *host)
3597/** 3964/**
3598 * ata_std_ports - initialize ioaddr with standard port offsets. 3965 * ata_std_ports - initialize ioaddr with standard port offsets.
3599 * @ioaddr: IO address structure to be initialized 3966 * @ioaddr: IO address structure to be initialized
3967 *
3968 * Utility function which initializes data_addr, error_addr,
3969 * feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr,
3970 * device_addr, status_addr, and command_addr to standard offsets
3971 * relative to cmd_addr.
3972 *
3973 * Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr.
3600 */ 3974 */
3975
3601void ata_std_ports(struct ata_ioports *ioaddr) 3976void ata_std_ports(struct ata_ioports *ioaddr)
3602{ 3977{
3603 ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; 3978 ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA;
@@ -3639,6 +4014,20 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port)
3639 return probe_ent; 4014 return probe_ent;
3640} 4015}
3641 4016
4017
4018
4019/**
4020 * ata_pci_init_native_mode - Initialize native-mode driver
4021 * @pdev: pci device to be initialized
4022 * @port: array[2] of pointers to port info structures.
4023 *
4024 * Utility function which allocates and initializes an
4025 * ata_probe_ent structure for a standard dual-port
4026 * PIO-based IDE controller. The returned ata_probe_ent
4027 * structure can be passed to ata_device_add(). The returned
4028 * ata_probe_ent structure should then be freed with kfree().
4029 */
4030
3642#ifdef CONFIG_PCI 4031#ifdef CONFIG_PCI
3643struct ata_probe_ent * 4032struct ata_probe_ent *
3644ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) 4033ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port)
@@ -3720,10 +4109,19 @@ ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port,
3720 * @port_info: Information from low-level host driver 4109 * @port_info: Information from low-level host driver
3721 * @n_ports: Number of ports attached to host controller 4110 * @n_ports: Number of ports attached to host controller
3722 * 4111 *
4112 * This is a helper function which can be called from a driver's
4113 * xxx_init_one() probe function if the hardware uses traditional
4114 * IDE taskfile registers.
4115 *
4116 * This function calls pci_enable_device(), reserves its register
4117 * regions, sets the dma mask, enables bus master mode, and calls
4118 * ata_device_add()
4119 *
3723 * LOCKING: 4120 * LOCKING:
3724 * Inherited from PCI layer (may sleep). 4121 * Inherited from PCI layer (may sleep).
3725 * 4122 *
3726 * RETURNS: 4123 * RETURNS:
4124 * Zero on success, negative on errno-based value on error.
3727 * 4125 *
3728 */ 4126 */
3729 4127
@@ -3878,10 +4276,6 @@ void ata_pci_remove_one (struct pci_dev *pdev)
3878 } 4276 }
3879 4277
3880 free_irq(host_set->irq, host_set); 4278 free_irq(host_set->irq, host_set);
3881 if (host_set->ops->host_stop)
3882 host_set->ops->host_stop(host_set);
3883 if (host_set->mmio_base)
3884 iounmap(host_set->mmio_base);
3885 4279
3886 for (i = 0; i < host_set->n_ports; i++) { 4280 for (i = 0; i < host_set->n_ports; i++) {
3887 ap = host_set->ports[i]; 4281 ap = host_set->ports[i];
@@ -3900,6 +4294,9 @@ void ata_pci_remove_one (struct pci_dev *pdev)
3900 scsi_host_put(ap->host); 4294 scsi_host_put(ap->host);
3901 } 4295 }
3902 4296
4297 if (host_set->ops->host_stop)
4298 host_set->ops->host_stop(host_set);
4299
3903 kfree(host_set); 4300 kfree(host_set);
3904 4301
3905 pci_release_regions(pdev); 4302 pci_release_regions(pdev);
@@ -3943,15 +4340,6 @@ int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits)
3943#endif /* CONFIG_PCI */ 4340#endif /* CONFIG_PCI */
3944 4341
3945 4342
3946/**
3947 * ata_init -
3948 *
3949 * LOCKING:
3950 *
3951 * RETURNS:
3952 *
3953 */
3954
3955static int __init ata_init(void) 4343static int __init ata_init(void)
3956{ 4344{
3957 ata_wq = create_workqueue("ata"); 4345 ata_wq = create_workqueue("ata");
@@ -3997,6 +4385,7 @@ EXPORT_SYMBOL_GPL(ata_chk_err);
3997EXPORT_SYMBOL_GPL(ata_exec_command); 4385EXPORT_SYMBOL_GPL(ata_exec_command);
3998EXPORT_SYMBOL_GPL(ata_port_start); 4386EXPORT_SYMBOL_GPL(ata_port_start);
3999EXPORT_SYMBOL_GPL(ata_port_stop); 4387EXPORT_SYMBOL_GPL(ata_port_stop);
4388EXPORT_SYMBOL_GPL(ata_host_stop);
4000EXPORT_SYMBOL_GPL(ata_interrupt); 4389EXPORT_SYMBOL_GPL(ata_interrupt);
4001EXPORT_SYMBOL_GPL(ata_qc_prep); 4390EXPORT_SYMBOL_GPL(ata_qc_prep);
4002EXPORT_SYMBOL_GPL(ata_bmdma_setup); 4391EXPORT_SYMBOL_GPL(ata_bmdma_setup);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 416ba67ba9ee..7a4adc4c8f09 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -947,7 +947,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
947} 947}
948 948
949/** 949/**
950 * ata_scsiop_noop - 950 * ata_scsiop_noop - Command handler that simply returns success.
951 * @args: device IDENTIFY data / SCSI command of interest. 951 * @args: device IDENTIFY data / SCSI command of interest.
952 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 952 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
953 * @buflen: Response buffer length. 953 * @buflen: Response buffer length.
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 6518226b8f87..d90430bbb0de 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -26,7 +26,7 @@
26#define __LIBATA_H__ 26#define __LIBATA_H__
27 27
28#define DRV_NAME "libata" 28#define DRV_NAME "libata"
29#define DRV_VERSION "1.10" /* must be exactly four chars */ 29#define DRV_VERSION "1.11" /* must be exactly four chars */
30 30
31struct ata_scsi_args { 31struct ata_scsi_args {
32 u16 *id; 32 u16 *id;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index f12a2b6fa7a0..e6831264f67c 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -465,6 +465,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
465 int ret, i; 465 int ret, i;
466 unsigned int id, lun; 466 unsigned int id, lun;
467 unsigned long serial; 467 unsigned long serial;
468 unsigned long flags;
468 469
469 if (!CMD_SP(cmd)) 470 if (!CMD_SP(cmd))
470 return FAILED; 471 return FAILED;
@@ -476,7 +477,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
476 serial = cmd->serial_number; 477 serial = cmd->serial_number;
477 478
478 /* Check active list for command command. */ 479 /* Check active list for command command. */
479 spin_lock(&ha->hardware_lock); 480 spin_lock_irqsave(&ha->hardware_lock, flags);
480 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { 481 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
481 sp = ha->outstanding_cmds[i]; 482 sp = ha->outstanding_cmds[i];
482 483
@@ -491,7 +492,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
491 sp->state)); 492 sp->state));
492 DEBUG3(qla2x00_print_scsi_cmd(cmd);) 493 DEBUG3(qla2x00_print_scsi_cmd(cmd);)
493 494
494 spin_unlock(&ha->hardware_lock); 495 spin_unlock_irqrestore(&ha->hardware_lock, flags);
495 if (qla2x00_abort_command(ha, sp)) { 496 if (qla2x00_abort_command(ha, sp)) {
496 DEBUG2(printk("%s(%ld): abort_command " 497 DEBUG2(printk("%s(%ld): abort_command "
497 "mbx failed.\n", __func__, ha->host_no)); 498 "mbx failed.\n", __func__, ha->host_no));
@@ -500,20 +501,19 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
500 "mbx success.\n", __func__, ha->host_no)); 501 "mbx success.\n", __func__, ha->host_no));
501 ret = SUCCESS; 502 ret = SUCCESS;
502 } 503 }
503 spin_lock(&ha->hardware_lock); 504 spin_lock_irqsave(&ha->hardware_lock, flags);
504 505
505 break; 506 break;
506 } 507 }
508 spin_unlock_irqrestore(&ha->hardware_lock, flags);
507 509
508 /* Wait for the command to be returned. */ 510 /* Wait for the command to be returned. */
509 if (ret == SUCCESS) { 511 if (ret == SUCCESS) {
510 spin_unlock(&ha->hardware_lock);
511 if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { 512 if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) {
512 qla_printk(KERN_ERR, ha, 513 qla_printk(KERN_ERR, ha,
513 "scsi(%ld:%d:%d): Abort handler timed out -- %lx " 514 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
514 "%x.\n", ha->host_no, id, lun, serial, ret); 515 "%x.\n", ha->host_no, id, lun, serial, ret);
515 } 516 }
516 spin_lock(&ha->hardware_lock);
517 } 517 }
518 518
519 qla_printk(KERN_INFO, ha, 519 qla_printk(KERN_INFO, ha,
@@ -544,6 +544,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
544 int status; 544 int status;
545 srb_t *sp; 545 srb_t *sp;
546 struct scsi_cmnd *cmd; 546 struct scsi_cmnd *cmd;
547 unsigned long flags;
547 548
548 status = 0; 549 status = 0;
549 550
@@ -552,11 +553,11 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
552 * array 553 * array
553 */ 554 */
554 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 555 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
555 spin_lock(&ha->hardware_lock); 556 spin_lock_irqsave(&ha->hardware_lock, flags);
556 sp = ha->outstanding_cmds[cnt]; 557 sp = ha->outstanding_cmds[cnt];
557 if (sp) { 558 if (sp) {
558 cmd = sp->cmd; 559 cmd = sp->cmd;
559 spin_unlock(&ha->hardware_lock); 560 spin_unlock_irqrestore(&ha->hardware_lock, flags);
560 if (cmd->device->id == t) { 561 if (cmd->device->id == t) {
561 if (!qla2x00_eh_wait_on_command(ha, cmd)) { 562 if (!qla2x00_eh_wait_on_command(ha, cmd)) {
562 status = 1; 563 status = 1;
@@ -564,7 +565,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
564 } 565 }
565 } 566 }
566 } else { 567 } else {
567 spin_unlock(&ha->hardware_lock); 568 spin_unlock_irqrestore(&ha->hardware_lock, flags);
568 } 569 }
569 } 570 }
570 return (status); 571 return (status);
@@ -690,6 +691,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
690 int status; 691 int status;
691 srb_t *sp; 692 srb_t *sp;
692 struct scsi_cmnd *cmd; 693 struct scsi_cmnd *cmd;
694 unsigned long flags;
693 695
694 status = 1; 696 status = 1;
695 697
@@ -698,17 +700,17 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
698 * array 700 * array
699 */ 701 */
700 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 702 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
701 spin_lock(&ha->hardware_lock); 703 spin_lock_irqsave(&ha->hardware_lock, flags);
702 sp = ha->outstanding_cmds[cnt]; 704 sp = ha->outstanding_cmds[cnt];
703 if (sp) { 705 if (sp) {
704 cmd = sp->cmd; 706 cmd = sp->cmd;
705 spin_unlock(&ha->hardware_lock); 707 spin_unlock_irqrestore(&ha->hardware_lock, flags);
706 status = qla2x00_eh_wait_on_command(ha, cmd); 708 status = qla2x00_eh_wait_on_command(ha, cmd);
707 if (status == 0) 709 if (status == 0)
708 break; 710 break;
709 } 711 }
710 else { 712 else {
711 spin_unlock(&ha->hardware_lock); 713 spin_unlock_irqrestore(&ha->hardware_lock, flags);
712 } 714 }
713 } 715 }
714 return (status); 716 return (status);
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 69009f853a49..b0403ccd8a25 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -329,6 +329,8 @@ static void nv_host_stop (struct ata_host_set *host_set)
329 host->host_desc->disable_hotplug(host_set); 329 host->host_desc->disable_hotplug(host_set);
330 330
331 kfree(host); 331 kfree(host);
332
333 ata_host_stop(host_set);
332} 334}
333 335
334static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 336static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index c4e9e0298122..b18c90582e67 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -122,6 +122,7 @@ static struct ata_port_operations pdc_ata_ops = {
122 .scr_write = pdc_sata_scr_write, 122 .scr_write = pdc_sata_scr_write,
123 .port_start = pdc_port_start, 123 .port_start = pdc_port_start,
124 .port_stop = pdc_port_stop, 124 .port_stop = pdc_port_stop,
125 .host_stop = ata_host_stop,
125}; 126};
126 127
127static struct ata_port_info pdc_port_info[] = { 128static struct ata_port_info pdc_port_info[] = {
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index dfd362104717..1383e8a28d72 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -536,6 +536,8 @@ static void qs_host_stop(struct ata_host_set *host_set)
536 536
537 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ 537 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
538 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ 538 writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
539
540 ata_host_stop(host_set);
539} 541}
540 542
541static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) 543static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 2b2ff48be396..49ed557a4b66 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -161,6 +161,7 @@ static struct ata_port_operations sil_ops = {
161 .scr_write = sil_scr_write, 161 .scr_write = sil_scr_write,
162 .port_start = ata_port_start, 162 .port_start = ata_port_start,
163 .port_stop = ata_port_stop, 163 .port_stop = ata_port_stop,
164 .host_stop = ata_host_stop,
164}; 165};
165 166
166static struct ata_port_info sil_port_info[] = { 167static struct ata_port_info sil_port_info[] = {
@@ -431,7 +432,13 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
431 writeb(cls, mmio_base + SIL_FIFO_R0); 432 writeb(cls, mmio_base + SIL_FIFO_R0);
432 writeb(cls, mmio_base + SIL_FIFO_W0); 433 writeb(cls, mmio_base + SIL_FIFO_W0);
433 writeb(cls, mmio_base + SIL_FIFO_R1); 434 writeb(cls, mmio_base + SIL_FIFO_R1);
434 writeb(cls, mmio_base + SIL_FIFO_W2); 435 writeb(cls, mmio_base + SIL_FIFO_W1);
436 if (ent->driver_data == sil_3114) {
437 writeb(cls, mmio_base + SIL_FIFO_R2);
438 writeb(cls, mmio_base + SIL_FIFO_W2);
439 writeb(cls, mmio_base + SIL_FIFO_R3);
440 writeb(cls, mmio_base + SIL_FIFO_W3);
441 }
435 } else 442 } else
436 printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n", 443 printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n",
437 pci_name(pdev)); 444 pci_name(pdev));
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 5105ddd08447..e418b89c6b9d 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -114,6 +114,7 @@ static struct ata_port_operations sis_ops = {
114 .scr_write = sis_scr_write, 114 .scr_write = sis_scr_write,
115 .port_start = ata_port_start, 115 .port_start = ata_port_start,
116 .port_stop = ata_port_stop, 116 .port_stop = ata_port_stop,
117 .host_stop = ata_host_stop,
117}; 118};
118 119
119static struct ata_port_info sis_port_info = { 120static struct ata_port_info sis_port_info = {
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 05075bd3a893..edef1fa969fc 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -313,6 +313,7 @@ static struct ata_port_operations k2_sata_ops = {
313 .scr_write = k2_sata_scr_write, 313 .scr_write = k2_sata_scr_write,
314 .port_start = ata_port_start, 314 .port_start = ata_port_start,
315 .port_stop = ata_port_stop, 315 .port_stop = ata_port_stop,
316 .host_stop = ata_host_stop,
316}; 317};
317 318
318static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) 319static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base)
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index 70118650c461..140cea05de3f 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -245,6 +245,8 @@ static void pdc20621_host_stop(struct ata_host_set *host_set)
245 245
246 iounmap(dimm_mmio); 246 iounmap(dimm_mmio);
247 kfree(hpriv); 247 kfree(hpriv);
248
249 ata_host_stop(host_set);
248} 250}
249 251
250static int pdc_port_start(struct ata_port *ap) 252static int pdc_port_start(struct ata_port *ap)
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 0bff4f475f26..a71fb54eebd3 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -113,6 +113,7 @@ static struct ata_port_operations uli_ops = {
113 113
114 .port_start = ata_port_start, 114 .port_start = ata_port_start,
115 .port_stop = ata_port_stop, 115 .port_stop = ata_port_stop,
116 .host_stop = ata_host_stop,
116}; 117};
117 118
118static struct ata_port_info uli_port_info = { 119static struct ata_port_info uli_port_info = {
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 3a7830667277..f43183c19a12 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -134,6 +134,7 @@ static struct ata_port_operations svia_sata_ops = {
134 134
135 .port_start = ata_port_start, 135 .port_start = ata_port_start,
136 .port_stop = ata_port_stop, 136 .port_stop = ata_port_stop,
137 .host_stop = ata_host_stop,
137}; 138};
138 139
139static struct ata_port_info svia_port_info = { 140static struct ata_port_info svia_port_info = {
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 2c28f0ad73c2..c5e09dc6f3de 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -21,6 +21,7 @@
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/dma-mapping.h>
24#include "scsi.h" 25#include "scsi.h"
25#include <scsi/scsi_host.h> 26#include <scsi/scsi_host.h>
26#include <linux/libata.h> 27#include <linux/libata.h>
@@ -230,6 +231,7 @@ static struct ata_port_operations vsc_sata_ops = {
230 .scr_write = vsc_sata_scr_write, 231 .scr_write = vsc_sata_scr_write,
231 .port_start = ata_port_start, 232 .port_start = ata_port_start,
232 .port_stop = ata_port_stop, 233 .port_stop = ata_port_stop,
234 .host_stop = ata_host_stop,
233}; 235};
234 236
235static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base) 237static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 4d273ceb1d09..9fa209097e3b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1216,6 +1216,7 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1216 if (!starget) 1216 if (!starget)
1217 return ERR_PTR(-ENOMEM); 1217 return ERR_PTR(-ENOMEM);
1218 1218
1219 get_device(&starget->dev);
1219 down(&shost->scan_mutex); 1220 down(&shost->scan_mutex);
1220 res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); 1221 res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
1221 if (res != SCSI_SCAN_LUN_PRESENT) 1222 if (res != SCSI_SCAN_LUN_PRESENT)