aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-28 12:29:23 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-10-28 12:29:23 -0400
commit7a9f8f93d2dad38f30fbc79d8a1e6517373aa4b6 (patch)
tree9116e5bde860d00685c5b6eee7be5ba9899aabb9 /drivers/scsi/libata-core.c
parent972c26bdd6b58e7534473c4f7928584578cf43f4 (diff)
parent5fadd053d9bb4345ec6f405d24db4e7eb49cf81e (diff)
Merge branch 'master'
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c282
1 files changed, 223 insertions, 59 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index c5e663fefdf..64f30bf5931 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -67,9 +67,9 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev);
67static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev); 67static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev);
68static void ata_set_mode(struct ata_port *ap); 68static void ata_set_mode(struct ata_port *ap);
69static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 69static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
70static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift); 70static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift);
71static int fgb(u32 bitmap); 71static int fgb(u32 bitmap);
72static int ata_choose_xfer_mode(struct ata_port *ap, 72static int ata_choose_xfer_mode(const struct ata_port *ap,
73 u8 *xfer_mode_out, 73 u8 *xfer_mode_out,
74 unsigned int *xfer_shift_out); 74 unsigned int *xfer_shift_out);
75static void __ata_qc_complete(struct ata_queued_cmd *qc); 75static void __ata_qc_complete(struct ata_queued_cmd *qc);
@@ -87,7 +87,7 @@ MODULE_LICENSE("GPL");
87MODULE_VERSION(DRV_VERSION); 87MODULE_VERSION(DRV_VERSION);
88 88
89/** 89/**
90 * ata_tf_load - send taskfile registers to host controller 90 * ata_tf_load_pio - send taskfile registers to host controller
91 * @ap: Port to which output is sent 91 * @ap: Port to which output is sent
92 * @tf: ATA taskfile register set 92 * @tf: ATA taskfile register set
93 * 93 *
@@ -97,7 +97,7 @@ MODULE_VERSION(DRV_VERSION);
97 * Inherited from caller. 97 * Inherited from caller.
98 */ 98 */
99 99
100static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf) 100static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf)
101{ 101{
102 struct ata_ioports *ioaddr = &ap->ioaddr; 102 struct ata_ioports *ioaddr = &ap->ioaddr;
103 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 103 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -155,7 +155,7 @@ static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf)
155 * Inherited from caller. 155 * Inherited from caller.
156 */ 156 */
157 157
158static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 158static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
159{ 159{
160 struct ata_ioports *ioaddr = &ap->ioaddr; 160 struct ata_ioports *ioaddr = &ap->ioaddr;
161 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 161 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -224,7 +224,7 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
224 * LOCKING: 224 * LOCKING:
225 * Inherited from caller. 225 * Inherited from caller.
226 */ 226 */
227void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 227void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
228{ 228{
229 if (ap->flags & ATA_FLAG_MMIO) 229 if (ap->flags & ATA_FLAG_MMIO)
230 ata_tf_load_mmio(ap, tf); 230 ata_tf_load_mmio(ap, tf);
@@ -244,7 +244,7 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
244 * spin_lock_irqsave(host_set lock) 244 * spin_lock_irqsave(host_set lock)
245 */ 245 */
246 246
247static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf) 247static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
248{ 248{
249 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 249 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
250 250
@@ -265,7 +265,7 @@ static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf)
265 * spin_lock_irqsave(host_set lock) 265 * spin_lock_irqsave(host_set lock)
266 */ 266 */
267 267
268static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 268static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
269{ 269{
270 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 270 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
271 271
@@ -285,7 +285,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
285 * LOCKING: 285 * LOCKING:
286 * spin_lock_irqsave(host_set lock) 286 * spin_lock_irqsave(host_set lock)
287 */ 287 */
288void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 288void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
289{ 289{
290 if (ap->flags & ATA_FLAG_MMIO) 290 if (ap->flags & ATA_FLAG_MMIO)
291 ata_exec_command_mmio(ap, tf); 291 ata_exec_command_mmio(ap, tf);
@@ -305,7 +305,7 @@ void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)
305 * Obtains host_set lock. 305 * Obtains host_set lock.
306 */ 306 */
307 307
308static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf) 308static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
309{ 309{
310 unsigned long flags; 310 unsigned long flags;
311 311
@@ -328,7 +328,7 @@ static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf)
328 * Obtains host_set lock. 328 * Obtains host_set lock.
329 */ 329 */
330 330
331static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf) 331static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
332{ 332{
333 ap->ops->tf_load(ap, tf); 333 ap->ops->tf_load(ap, tf);
334 334
@@ -348,7 +348,7 @@ static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
348 * spin_lock_irqsave(host_set lock) 348 * spin_lock_irqsave(host_set lock)
349 */ 349 */
350 350
351void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) 351void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf)
352{ 352{
353 ap->ops->tf_load(ap, tf); 353 ap->ops->tf_load(ap, tf);
354 ap->ops->exec_command(ap, tf); 354 ap->ops->exec_command(ap, tf);
@@ -558,7 +558,7 @@ u8 ata_chk_err(struct ata_port *ap)
558 * Inherited from caller. 558 * Inherited from caller.
559 */ 559 */
560 560
561void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp) 561void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
562{ 562{
563 fis[0] = 0x27; /* Register - Host to Device FIS */ 563 fis[0] = 0x27; /* Register - Host to Device FIS */
564 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number, 564 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number,
@@ -599,7 +599,7 @@ void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp)
599 * Inherited from caller. 599 * Inherited from caller.
600 */ 600 */
601 601
602void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf) 602void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
603{ 603{
604 tf->command = fis[2]; /* status */ 604 tf->command = fis[2]; /* status */
605 tf->feature = fis[3]; /* error */ 605 tf->feature = fis[3]; /* error */
@@ -845,7 +845,7 @@ static unsigned int ata_devchk(struct ata_port *ap,
845 * the event of failure. 845 * the event of failure.
846 */ 846 */
847 847
848unsigned int ata_dev_classify(struct ata_taskfile *tf) 848unsigned int ata_dev_classify(const struct ata_taskfile *tf)
849{ 849{
850 /* Apple's open source Darwin code hints that some devices only 850 /* Apple's open source Darwin code hints that some devices only
851 * put a proper signature into the LBA mid/high registers, 851 * put a proper signature into the LBA mid/high registers,
@@ -937,7 +937,7 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
937 * caller. 937 * caller.
938 */ 938 */
939 939
940void ata_dev_id_string(u16 *id, unsigned char *s, 940void ata_dev_id_string(const u16 *id, unsigned char *s,
941 unsigned int ofs, unsigned int len) 941 unsigned int ofs, unsigned int len)
942{ 942{
943 unsigned int c; 943 unsigned int c;
@@ -1054,7 +1054,7 @@ void ata_dev_select(struct ata_port *ap, unsigned int device,
1054 * caller. 1054 * caller.
1055 */ 1055 */
1056 1056
1057static inline void ata_dump_id(struct ata_device *dev) 1057static inline void ata_dump_id(const struct ata_device *dev)
1058{ 1058{
1059 DPRINTK("49==0x%04x " 1059 DPRINTK("49==0x%04x "
1060 "53==0x%04x " 1060 "53==0x%04x "
@@ -1082,6 +1082,31 @@ static inline void ata_dump_id(struct ata_device *dev)
1082 dev->id[93]); 1082 dev->id[93]);
1083} 1083}
1084 1084
1085/*
1086 * Compute the PIO modes available for this device. This is not as
1087 * trivial as it seems if we must consider early devices correctly.
1088 *
1089 * FIXME: pre IDE drive timing (do we care ?).
1090 */
1091
1092static unsigned int ata_pio_modes(const struct ata_device *adev)
1093{
1094 u16 modes;
1095
1096 /* Usual case. Word 53 indicates word 88 is valid */
1097 if (adev->id[ATA_ID_FIELD_VALID] & (1 << 2)) {
1098 modes = adev->id[ATA_ID_PIO_MODES] & 0x03;
1099 modes <<= 3;
1100 modes |= 0x7;
1101 return modes;
1102 }
1103
1104 /* If word 88 isn't valid then Word 51 holds the PIO timing number
1105 for the maximum. Turn it into a mask and return it */
1106 modes = (2 << (adev->id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ;
1107 return modes;
1108}
1109
1085/** 1110/**
1086 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1111 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1087 * @ap: port on which device we wish to probe resides 1112 * @ap: port on which device we wish to probe resides
@@ -1215,10 +1240,8 @@ retry:
1215 xfer_modes = dev->id[ATA_ID_UDMA_MODES]; 1240 xfer_modes = dev->id[ATA_ID_UDMA_MODES];
1216 if (!xfer_modes) 1241 if (!xfer_modes)
1217 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA; 1242 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;
1218 if (!xfer_modes) { 1243 if (!xfer_modes)
1219 xfer_modes = (dev->id[ATA_ID_PIO_MODES]) << (ATA_SHIFT_PIO + 3); 1244 xfer_modes = ata_pio_modes(dev);
1220 xfer_modes |= (0x7 << ATA_SHIFT_PIO);
1221 }
1222 1245
1223 ata_dump_id(dev); 1246 ata_dump_id(dev);
1224 1247
@@ -1329,7 +1352,7 @@ err_out:
1329} 1352}
1330 1353
1331 1354
1332static inline u8 ata_dev_knobble(struct ata_port *ap) 1355static inline u8 ata_dev_knobble(const struct ata_port *ap)
1333{ 1356{
1334 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id))); 1357 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id)));
1335} 1358}
@@ -1515,7 +1538,153 @@ void ata_port_disable(struct ata_port *ap)
1515 ap->flags |= ATA_FLAG_PORT_DISABLED; 1538 ap->flags |= ATA_FLAG_PORT_DISABLED;
1516} 1539}
1517 1540
1518static struct { 1541/*
1542 * This mode timing computation functionality is ported over from
1543 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
1544 */
1545/*
1546 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1547 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1548 * for PIO 5, which is a nonstandard extension and UDMA6, which
1549 * is currently supported only by Maxtor drives.
1550 */
1551
1552static const struct ata_timing ata_timing[] = {
1553
1554 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 },
1555 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 },
1556 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 },
1557 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 },
1558
1559 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 },
1560 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
1561 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
1562
1563/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
1564
1565 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
1566 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
1567 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
1568
1569 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
1570 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1571 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
1572
1573/* { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, */
1574 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 },
1575 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
1576
1577 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 },
1578 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 },
1579 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 },
1580
1581/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */
1582
1583 { 0xFF }
1584};
1585
1586#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
1587#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
1588
1589static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
1590{
1591 q->setup = EZ(t->setup * 1000, T);
1592 q->act8b = EZ(t->act8b * 1000, T);
1593 q->rec8b = EZ(t->rec8b * 1000, T);
1594 q->cyc8b = EZ(t->cyc8b * 1000, T);
1595 q->active = EZ(t->active * 1000, T);
1596 q->recover = EZ(t->recover * 1000, T);
1597 q->cycle = EZ(t->cycle * 1000, T);
1598 q->udma = EZ(t->udma * 1000, UT);
1599}
1600
1601void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
1602 struct ata_timing *m, unsigned int what)
1603{
1604 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
1605 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
1606 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
1607 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
1608 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
1609 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
1610 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
1611 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
1612}
1613
1614static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
1615{
1616 const struct ata_timing *t;
1617
1618 for (t = ata_timing; t->mode != speed; t++)
1619 if (t->mode == 0xFF)
1620 return NULL;
1621 return t;
1622}
1623
1624int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1625 struct ata_timing *t, int T, int UT)
1626{
1627 const struct ata_timing *s;
1628 struct ata_timing p;
1629
1630 /*
1631 * Find the mode.
1632 */
1633
1634 if (!(s = ata_timing_find_mode(speed)))
1635 return -EINVAL;
1636
1637 /*
1638 * If the drive is an EIDE drive, it can tell us it needs extended
1639 * PIO/MW_DMA cycle timing.
1640 */
1641
1642 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
1643 memset(&p, 0, sizeof(p));
1644 if(speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
1645 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO];
1646 else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY];
1647 } else if(speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) {
1648 p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN];
1649 }
1650 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
1651 }
1652
1653 /*
1654 * Convert the timing to bus clock counts.
1655 */
1656
1657 ata_timing_quantize(s, t, T, UT);
1658
1659 /*
1660 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
1661 * and some other commands. We have to ensure that the DMA cycle timing is
1662 * slower/equal than the fastest PIO timing.
1663 */
1664
1665 if (speed > XFER_PIO_4) {
1666 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
1667 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
1668 }
1669
1670 /*
1671 * Lenghten active & recovery time so that cycle time is correct.
1672 */
1673
1674 if (t->act8b + t->rec8b < t->cyc8b) {
1675 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
1676 t->rec8b = t->cyc8b - t->act8b;
1677 }
1678
1679 if (t->active + t->recover < t->cycle) {
1680 t->active += (t->cycle - (t->active + t->recover)) / 2;
1681 t->recover = t->cycle - t->active;
1682 }
1683
1684 return 0;
1685}
1686
1687static const struct {
1519 unsigned int shift; 1688 unsigned int shift;
1520 u8 base; 1689 u8 base;
1521} xfer_mode_classes[] = { 1690} xfer_mode_classes[] = {
@@ -1924,7 +2093,8 @@ err_out:
1924 DPRINTK("EXIT\n"); 2093 DPRINTK("EXIT\n");
1925} 2094}
1926 2095
1927static void ata_pr_blacklisted(struct ata_port *ap, struct ata_device *dev) 2096static void ata_pr_blacklisted(const struct ata_port *ap,
2097 const struct ata_device *dev)
1928{ 2098{
1929 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n", 2099 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n",
1930 ap->id, dev->devno); 2100 ap->id, dev->devno);
@@ -1962,7 +2132,7 @@ static const char * ata_dma_blacklist [] = {
1962 "_NEC DV5800A", 2132 "_NEC DV5800A",
1963}; 2133};
1964 2134
1965static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev) 2135static int ata_dma_blacklisted(const struct ata_device *dev)
1966{ 2136{
1967 unsigned char model_num[40]; 2137 unsigned char model_num[40];
1968 char *s; 2138 char *s;
@@ -1987,9 +2157,9 @@ static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev)
1987 return 0; 2157 return 0;
1988} 2158}
1989 2159
1990static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift) 2160static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
1991{ 2161{
1992 struct ata_device *master, *slave; 2162 const struct ata_device *master, *slave;
1993 unsigned int mask; 2163 unsigned int mask;
1994 2164
1995 master = &ap->device[0]; 2165 master = &ap->device[0];
@@ -2001,14 +2171,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2001 mask = ap->udma_mask; 2171 mask = ap->udma_mask;
2002 if (ata_dev_present(master)) { 2172 if (ata_dev_present(master)) {
2003 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff); 2173 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff);
2004 if (ata_dma_blacklisted(ap, master)) { 2174 if (ata_dma_blacklisted(master)) {
2005 mask = 0; 2175 mask = 0;
2006 ata_pr_blacklisted(ap, master); 2176 ata_pr_blacklisted(ap, master);
2007 } 2177 }
2008 } 2178 }
2009 if (ata_dev_present(slave)) { 2179 if (ata_dev_present(slave)) {
2010 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff); 2180 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff);
2011 if (ata_dma_blacklisted(ap, slave)) { 2181 if (ata_dma_blacklisted(slave)) {
2012 mask = 0; 2182 mask = 0;
2013 ata_pr_blacklisted(ap, slave); 2183 ata_pr_blacklisted(ap, slave);
2014 } 2184 }
@@ -2018,14 +2188,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2018 mask = ap->mwdma_mask; 2188 mask = ap->mwdma_mask;
2019 if (ata_dev_present(master)) { 2189 if (ata_dev_present(master)) {
2020 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07); 2190 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07);
2021 if (ata_dma_blacklisted(ap, master)) { 2191 if (ata_dma_blacklisted(master)) {
2022 mask = 0; 2192 mask = 0;
2023 ata_pr_blacklisted(ap, master); 2193 ata_pr_blacklisted(ap, master);
2024 } 2194 }
2025 } 2195 }
2026 if (ata_dev_present(slave)) { 2196 if (ata_dev_present(slave)) {
2027 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07); 2197 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07);
2028 if (ata_dma_blacklisted(ap, slave)) { 2198 if (ata_dma_blacklisted(slave)) {
2029 mask = 0; 2199 mask = 0;
2030 ata_pr_blacklisted(ap, slave); 2200 ata_pr_blacklisted(ap, slave);
2031 } 2201 }
@@ -2089,7 +2259,7 @@ static int fgb(u32 bitmap)
2089 * Zero on success, negative on error. 2259 * Zero on success, negative on error.
2090 */ 2260 */
2091 2261
2092static int ata_choose_xfer_mode(struct ata_port *ap, 2262static int ata_choose_xfer_mode(const struct ata_port *ap,
2093 u8 *xfer_mode_out, 2263 u8 *xfer_mode_out,
2094 unsigned int *xfer_shift_out) 2264 unsigned int *xfer_shift_out)
2095{ 2265{
@@ -2613,13 +2783,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2613 2783
2614/** 2784/**
2615 * ata_pio_poll - 2785 * ata_pio_poll -
2616 * @ap: 2786 * @ap: the target ata_port
2617 * 2787 *
2618 * LOCKING: 2788 * LOCKING:
2619 * None. (executing in kernel thread context) 2789 * None. (executing in kernel thread context)
2620 * 2790 *
2621 * RETURNS: 2791 * RETURNS:
2622 * 2792 * timeout value to use
2623 */ 2793 */
2624 2794
2625static unsigned long ata_pio_poll(struct ata_port *ap) 2795static unsigned long ata_pio_poll(struct ata_port *ap)
@@ -2660,8 +2830,8 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2660} 2830}
2661 2831
2662/** 2832/**
2663 * ata_pio_complete - 2833 * ata_pio_complete - check if drive is busy or idle
2664 * @ap: 2834 * @ap: the target ata_port
2665 * 2835 *
2666 * LOCKING: 2836 * LOCKING:
2667 * None. (executing in kernel thread context) 2837 * None. (executing in kernel thread context)
@@ -2713,7 +2883,7 @@ static int ata_pio_complete (struct ata_port *ap)
2713 2883
2714 2884
2715/** 2885/**
2716 * swap_buf_le16 - 2886 * swap_buf_le16 - swap halves of 16-words in place
2717 * @buf: Buffer to swap 2887 * @buf: Buffer to swap
2718 * @buf_words: Number of 16-bit words in buffer. 2888 * @buf_words: Number of 16-bit words in buffer.
2719 * 2889 *
@@ -2722,6 +2892,7 @@ static int ata_pio_complete (struct ata_port *ap)
2722 * vice-versa. 2892 * vice-versa.
2723 * 2893 *
2724 * LOCKING: 2894 * LOCKING:
2895 * Inherited from caller.
2725 */ 2896 */
2726void swap_buf_le16(u16 *buf, unsigned int buf_words) 2897void swap_buf_le16(u16 *buf, unsigned int buf_words)
2727{ 2898{
@@ -2744,7 +2915,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
2744 * 2915 *
2745 * LOCKING: 2916 * LOCKING:
2746 * Inherited from caller. 2917 * Inherited from caller.
2747 *
2748 */ 2918 */
2749 2919
2750static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf, 2920static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2790,7 +2960,6 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2790 * 2960 *
2791 * LOCKING: 2961 * LOCKING:
2792 * Inherited from caller. 2962 * Inherited from caller.
2793 *
2794 */ 2963 */
2795 2964
2796static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf, 2965static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2830,7 +2999,6 @@ static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
2830 * 2999 *
2831 * LOCKING: 3000 * LOCKING:
2832 * Inherited from caller. 3001 * Inherited from caller.
2833 *
2834 */ 3002 */
2835 3003
2836static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, 3004static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2983,7 +3151,6 @@ next_sg:
2983 * 3151 *
2984 * LOCKING: 3152 * LOCKING:
2985 * Inherited from caller. 3153 * Inherited from caller.
2986 *
2987 */ 3154 */
2988 3155
2989static void atapi_pio_bytes(struct ata_queued_cmd *qc) 3156static void atapi_pio_bytes(struct ata_queued_cmd *qc)
@@ -3019,8 +3186,8 @@ err_out:
3019} 3186}
3020 3187
3021/** 3188/**
3022 * ata_pio_sector - 3189 * ata_pio_block - start PIO on a block
3023 * @ap: 3190 * @ap: the target ata_port
3024 * 3191 *
3025 * LOCKING: 3192 * LOCKING:
3026 * None. (executing in kernel thread context) 3193 * None. (executing in kernel thread context)
@@ -3032,7 +3199,7 @@ static void ata_pio_block(struct ata_port *ap)
3032 u8 status; 3199 u8 status;
3033 3200
3034 /* 3201 /*
3035 * This is purely hueristic. This is a fast path. 3202 * This is purely heuristic. This is a fast path.
3036 * Sometimes when we enter, BSY will be cleared in 3203 * Sometimes when we enter, BSY will be cleared in
3037 * a chk-status or two. If not, the drive is probably seeking 3204 * a chk-status or two. If not, the drive is probably seeking
3038 * or something. Snooze for a couple msecs, then 3205 * or something. Snooze for a couple msecs, then
@@ -3352,7 +3519,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3352 * 3519 *
3353 * LOCKING: 3520 * LOCKING:
3354 * spin_lock_irqsave(host_set lock) 3521 * spin_lock_irqsave(host_set lock)
3355 *
3356 */ 3522 */
3357void ata_qc_free(struct ata_queued_cmd *qc) 3523void ata_qc_free(struct ata_queued_cmd *qc)
3358{ 3524{
@@ -3372,7 +3538,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3372 * 3538 *
3373 * LOCKING: 3539 * LOCKING:
3374 * spin_lock_irqsave(host_set lock) 3540 * spin_lock_irqsave(host_set lock)
3375 *
3376 */ 3541 */
3377 3542
3378void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3543void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
@@ -3866,7 +4031,6 @@ idle_irq:
3866 * 4031 *
3867 * RETURNS: 4032 * RETURNS:
3868 * IRQ_NONE or IRQ_HANDLED. 4033 * IRQ_NONE or IRQ_HANDLED.
3869 *
3870 */ 4034 */
3871 4035
3872irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 4036irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
@@ -3978,6 +4142,7 @@ err_out:
3978 * May be used as the port_start() entry in ata_port_operations. 4142 * May be used as the port_start() entry in ata_port_operations.
3979 * 4143 *
3980 * LOCKING: 4144 * LOCKING:
4145 * Inherited from caller.
3981 */ 4146 */
3982 4147
3983int ata_port_start (struct ata_port *ap) 4148int ata_port_start (struct ata_port *ap)
@@ -4009,6 +4174,7 @@ int ata_port_start (struct ata_port *ap)
4009 * May be used as the port_stop() entry in ata_port_operations. 4174 * May be used as the port_stop() entry in ata_port_operations.
4010 * 4175 *
4011 * LOCKING: 4176 * LOCKING:
4177 * Inherited from caller.
4012 */ 4178 */
4013 4179
4014void ata_port_stop (struct ata_port *ap) 4180void ata_port_stop (struct ata_port *ap)
@@ -4032,6 +4198,7 @@ void ata_host_stop (struct ata_host_set *host_set)
4032 * @do_unregister: 1 if we fully unregister, 0 to just stop the port 4198 * @do_unregister: 1 if we fully unregister, 0 to just stop the port
4033 * 4199 *
4034 * LOCKING: 4200 * LOCKING:
4201 * Inherited from caller.
4035 */ 4202 */
4036 4203
4037static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) 4204static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
@@ -4059,12 +4226,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
4059 * 4226 *
4060 * LOCKING: 4227 * LOCKING:
4061 * Inherited from caller. 4228 * Inherited from caller.
4062 *
4063 */ 4229 */
4064 4230
4065static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, 4231static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4066 struct ata_host_set *host_set, 4232 struct ata_host_set *host_set,
4067 struct ata_probe_ent *ent, unsigned int port_no) 4233 const struct ata_probe_ent *ent, unsigned int port_no)
4068{ 4234{
4069 unsigned int i; 4235 unsigned int i;
4070 4236
@@ -4120,10 +4286,9 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4120 * 4286 *
4121 * RETURNS: 4287 * RETURNS:
4122 * New ata_port on success, for NULL on error. 4288 * New ata_port on success, for NULL on error.
4123 *
4124 */ 4289 */
4125 4290
4126static struct ata_port * ata_host_add(struct ata_probe_ent *ent, 4291static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
4127 struct ata_host_set *host_set, 4292 struct ata_host_set *host_set,
4128 unsigned int port_no) 4293 unsigned int port_no)
4129{ 4294{
@@ -4168,10 +4333,9 @@ err_out:
4168 * 4333 *
4169 * RETURNS: 4334 * RETURNS:
4170 * Number of ports registered. Zero on error (no ports registered). 4335 * Number of ports registered. Zero on error (no ports registered).
4171 *
4172 */ 4336 */
4173 4337
4174int ata_device_add(struct ata_probe_ent *ent) 4338int ata_device_add(const struct ata_probe_ent *ent)
4175{ 4339{
4176 unsigned int count = 0, i; 4340 unsigned int count = 0, i;
4177 struct device *dev = ent->dev; 4341 struct device *dev = ent->dev;
@@ -4300,7 +4464,6 @@ err_out:
4300 * Inherited from calling layer (may sleep). 4464 * Inherited from calling layer (may sleep).
4301 */ 4465 */
4302 4466
4303
4304void ata_host_set_remove(struct ata_host_set *host_set) 4467void ata_host_set_remove(struct ata_host_set *host_set)
4305{ 4468{
4306 struct ata_port *ap; 4469 struct ata_port *ap;
@@ -4390,7 +4553,7 @@ void ata_std_ports(struct ata_ioports *ioaddr)
4390} 4553}
4391 4554
4392static struct ata_probe_ent * 4555static struct ata_probe_ent *
4393ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) 4556ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
4394{ 4557{
4395 struct ata_probe_ent *probe_ent; 4558 struct ata_probe_ent *probe_ent;
4396 4559
@@ -4490,7 +4653,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4490 if (!probe_ent) 4653 if (!probe_ent)
4491 return NULL; 4654 return NULL;
4492 4655
4493
4494 probe_ent->legacy_mode = 1; 4656 probe_ent->legacy_mode = 1;
4495 probe_ent->n_ports = 1; 4657 probe_ent->n_ports = 1;
4496 probe_ent->hard_port_no = port_num; 4658 probe_ent->hard_port_no = port_num;
@@ -4534,7 +4696,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4534 * 4696 *
4535 * RETURNS: 4697 * RETURNS:
4536 * Zero on success, negative on errno-based value on error. 4698 * Zero on success, negative on errno-based value on error.
4537 *
4538 */ 4699 */
4539 4700
4540int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 4701int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
@@ -4682,7 +4843,7 @@ err_out:
4682 * @pdev: PCI device that was removed 4843 * @pdev: PCI device that was removed
4683 * 4844 *
4684 * PCI layer indicates to libata via this hook that 4845 * PCI layer indicates to libata via this hook that
4685 * hot-unplug or module unload event has occured. 4846 * hot-unplug or module unload event has occurred.
4686 * Handle this by unregistering all objects associated 4847 * Handle this by unregistering all objects associated
4687 * with this PCI device. Free those objects. Then finally 4848 * with this PCI device. Free those objects. Then finally
4688 * release PCI resources and disable device. 4849 * release PCI resources and disable device.
@@ -4703,7 +4864,7 @@ void ata_pci_remove_one (struct pci_dev *pdev)
4703} 4864}
4704 4865
4705/* move to PCI subsystem */ 4866/* move to PCI subsystem */
4706int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) 4867int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
4707{ 4868{
4708 unsigned long tmp = 0; 4869 unsigned long tmp = 0;
4709 4870
@@ -4830,6 +4991,9 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
4830EXPORT_SYMBOL_GPL(ata_dev_config); 4991EXPORT_SYMBOL_GPL(ata_dev_config);
4831EXPORT_SYMBOL_GPL(ata_scsi_simulate); 4992EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4832 4993
4994EXPORT_SYMBOL_GPL(ata_timing_compute);
4995EXPORT_SYMBOL_GPL(ata_timing_merge);
4996
4833#ifdef CONFIG_PCI 4997#ifdef CONFIG_PCI
4834EXPORT_SYMBOL_GPL(pci_test_config_bits); 4998EXPORT_SYMBOL_GPL(pci_test_config_bits);
4835EXPORT_SYMBOL_GPL(ata_pci_host_stop); 4999EXPORT_SYMBOL_GPL(ata_pci_host_stop);