aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
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 b16955b0c4d1..ab8b7354452c 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);
@@ -88,7 +88,7 @@ MODULE_LICENSE("GPL");
88MODULE_VERSION(DRV_VERSION); 88MODULE_VERSION(DRV_VERSION);
89 89
90/** 90/**
91 * ata_tf_load - send taskfile registers to host controller 91 * ata_tf_load_pio - send taskfile registers to host controller
92 * @ap: Port to which output is sent 92 * @ap: Port to which output is sent
93 * @tf: ATA taskfile register set 93 * @tf: ATA taskfile register set
94 * 94 *
@@ -98,7 +98,7 @@ MODULE_VERSION(DRV_VERSION);
98 * Inherited from caller. 98 * Inherited from caller.
99 */ 99 */
100 100
101static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf) 101static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf)
102{ 102{
103 struct ata_ioports *ioaddr = &ap->ioaddr; 103 struct ata_ioports *ioaddr = &ap->ioaddr;
104 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 104 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -156,7 +156,7 @@ static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf)
156 * Inherited from caller. 156 * Inherited from caller.
157 */ 157 */
158 158
159static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 159static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
160{ 160{
161 struct ata_ioports *ioaddr = &ap->ioaddr; 161 struct ata_ioports *ioaddr = &ap->ioaddr;
162 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 162 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -225,7 +225,7 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
225 * LOCKING: 225 * LOCKING:
226 * Inherited from caller. 226 * Inherited from caller.
227 */ 227 */
228void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 228void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
229{ 229{
230 if (ap->flags & ATA_FLAG_MMIO) 230 if (ap->flags & ATA_FLAG_MMIO)
231 ata_tf_load_mmio(ap, tf); 231 ata_tf_load_mmio(ap, tf);
@@ -245,7 +245,7 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
245 * spin_lock_irqsave(host_set lock) 245 * spin_lock_irqsave(host_set lock)
246 */ 246 */
247 247
248static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf) 248static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
249{ 249{
250 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 250 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
251 251
@@ -266,7 +266,7 @@ static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf)
266 * spin_lock_irqsave(host_set lock) 266 * spin_lock_irqsave(host_set lock)
267 */ 267 */
268 268
269static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 269static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
270{ 270{
271 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 271 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
272 272
@@ -286,7 +286,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
286 * LOCKING: 286 * LOCKING:
287 * spin_lock_irqsave(host_set lock) 287 * spin_lock_irqsave(host_set lock)
288 */ 288 */
289void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 289void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
290{ 290{
291 if (ap->flags & ATA_FLAG_MMIO) 291 if (ap->flags & ATA_FLAG_MMIO)
292 ata_exec_command_mmio(ap, tf); 292 ata_exec_command_mmio(ap, tf);
@@ -306,7 +306,7 @@ void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)
306 * Obtains host_set lock. 306 * Obtains host_set lock.
307 */ 307 */
308 308
309static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf) 309static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
310{ 310{
311 unsigned long flags; 311 unsigned long flags;
312 312
@@ -329,7 +329,7 @@ static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf)
329 * Obtains host_set lock. 329 * Obtains host_set lock.
330 */ 330 */
331 331
332static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf) 332static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
333{ 333{
334 ap->ops->tf_load(ap, tf); 334 ap->ops->tf_load(ap, tf);
335 335
@@ -349,7 +349,7 @@ static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
349 * spin_lock_irqsave(host_set lock) 349 * spin_lock_irqsave(host_set lock)
350 */ 350 */
351 351
352void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) 352void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf)
353{ 353{
354 ap->ops->tf_load(ap, tf); 354 ap->ops->tf_load(ap, tf);
355 ap->ops->exec_command(ap, tf); 355 ap->ops->exec_command(ap, tf);
@@ -559,7 +559,7 @@ u8 ata_chk_err(struct ata_port *ap)
559 * Inherited from caller. 559 * Inherited from caller.
560 */ 560 */
561 561
562void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp) 562void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
563{ 563{
564 fis[0] = 0x27; /* Register - Host to Device FIS */ 564 fis[0] = 0x27; /* Register - Host to Device FIS */
565 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number, 565 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number,
@@ -600,7 +600,7 @@ void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp)
600 * Inherited from caller. 600 * Inherited from caller.
601 */ 601 */
602 602
603void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf) 603void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
604{ 604{
605 tf->command = fis[2]; /* status */ 605 tf->command = fis[2]; /* status */
606 tf->feature = fis[3]; /* error */ 606 tf->feature = fis[3]; /* error */
@@ -846,7 +846,7 @@ static unsigned int ata_devchk(struct ata_port *ap,
846 * the event of failure. 846 * the event of failure.
847 */ 847 */
848 848
849unsigned int ata_dev_classify(struct ata_taskfile *tf) 849unsigned int ata_dev_classify(const struct ata_taskfile *tf)
850{ 850{
851 /* Apple's open source Darwin code hints that some devices only 851 /* Apple's open source Darwin code hints that some devices only
852 * put a proper signature into the LBA mid/high registers, 852 * put a proper signature into the LBA mid/high registers,
@@ -938,7 +938,7 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
938 * caller. 938 * caller.
939 */ 939 */
940 940
941void ata_dev_id_string(u16 *id, unsigned char *s, 941void ata_dev_id_string(const u16 *id, unsigned char *s,
942 unsigned int ofs, unsigned int len) 942 unsigned int ofs, unsigned int len)
943{ 943{
944 unsigned int c; 944 unsigned int c;
@@ -1055,7 +1055,7 @@ void ata_dev_select(struct ata_port *ap, unsigned int device,
1055 * caller. 1055 * caller.
1056 */ 1056 */
1057 1057
1058static inline void ata_dump_id(struct ata_device *dev) 1058static inline void ata_dump_id(const struct ata_device *dev)
1059{ 1059{
1060 DPRINTK("49==0x%04x " 1060 DPRINTK("49==0x%04x "
1061 "53==0x%04x " 1061 "53==0x%04x "
@@ -1083,6 +1083,31 @@ static inline void ata_dump_id(struct ata_device *dev)
1083 dev->id[93]); 1083 dev->id[93]);
1084} 1084}
1085 1085
1086/*
1087 * Compute the PIO modes available for this device. This is not as
1088 * trivial as it seems if we must consider early devices correctly.
1089 *
1090 * FIXME: pre IDE drive timing (do we care ?).
1091 */
1092
1093static unsigned int ata_pio_modes(const struct ata_device *adev)
1094{
1095 u16 modes;
1096
1097 /* Usual case. Word 53 indicates word 88 is valid */
1098 if (adev->id[ATA_ID_FIELD_VALID] & (1 << 2)) {
1099 modes = adev->id[ATA_ID_PIO_MODES] & 0x03;
1100 modes <<= 3;
1101 modes |= 0x7;
1102 return modes;
1103 }
1104
1105 /* If word 88 isn't valid then Word 51 holds the PIO timing number
1106 for the maximum. Turn it into a mask and return it */
1107 modes = (2 << (adev->id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ;
1108 return modes;
1109}
1110
1086/** 1111/**
1087 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1112 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1088 * @ap: port on which device we wish to probe resides 1113 * @ap: port on which device we wish to probe resides
@@ -1216,10 +1241,8 @@ retry:
1216 xfer_modes = dev->id[ATA_ID_UDMA_MODES]; 1241 xfer_modes = dev->id[ATA_ID_UDMA_MODES];
1217 if (!xfer_modes) 1242 if (!xfer_modes)
1218 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA; 1243 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;
1219 if (!xfer_modes) { 1244 if (!xfer_modes)
1220 xfer_modes = (dev->id[ATA_ID_PIO_MODES]) << (ATA_SHIFT_PIO + 3); 1245 xfer_modes = ata_pio_modes(dev);
1221 xfer_modes |= (0x7 << ATA_SHIFT_PIO);
1222 }
1223 1246
1224 ata_dump_id(dev); 1247 ata_dump_id(dev);
1225 1248
@@ -1333,7 +1356,7 @@ err_out:
1333} 1356}
1334 1357
1335 1358
1336static inline u8 ata_dev_knobble(struct ata_port *ap) 1359static inline u8 ata_dev_knobble(const struct ata_port *ap)
1337{ 1360{
1338 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id))); 1361 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id)));
1339} 1362}
@@ -1519,7 +1542,153 @@ void ata_port_disable(struct ata_port *ap)
1519 ap->flags |= ATA_FLAG_PORT_DISABLED; 1542 ap->flags |= ATA_FLAG_PORT_DISABLED;
1520} 1543}
1521 1544
1522static struct { 1545/*
1546 * This mode timing computation functionality is ported over from
1547 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
1548 */
1549/*
1550 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1551 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1552 * for PIO 5, which is a nonstandard extension and UDMA6, which
1553 * is currently supported only by Maxtor drives.
1554 */
1555
1556static const struct ata_timing ata_timing[] = {
1557
1558 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 },
1559 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 },
1560 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 },
1561 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 },
1562
1563 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 },
1564 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
1565 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
1566
1567/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
1568
1569 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
1570 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
1571 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
1572
1573 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
1574 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1575 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
1576
1577/* { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, */
1578 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 },
1579 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
1580
1581 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 },
1582 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 },
1583 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 },
1584
1585/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */
1586
1587 { 0xFF }
1588};
1589
1590#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
1591#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
1592
1593static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
1594{
1595 q->setup = EZ(t->setup * 1000, T);
1596 q->act8b = EZ(t->act8b * 1000, T);
1597 q->rec8b = EZ(t->rec8b * 1000, T);
1598 q->cyc8b = EZ(t->cyc8b * 1000, T);
1599 q->active = EZ(t->active * 1000, T);
1600 q->recover = EZ(t->recover * 1000, T);
1601 q->cycle = EZ(t->cycle * 1000, T);
1602 q->udma = EZ(t->udma * 1000, UT);
1603}
1604
1605void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
1606 struct ata_timing *m, unsigned int what)
1607{
1608 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
1609 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
1610 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
1611 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
1612 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
1613 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
1614 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
1615 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
1616}
1617
1618static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
1619{
1620 const struct ata_timing *t;
1621
1622 for (t = ata_timing; t->mode != speed; t++)
1623 if (t->mode == 0xFF)
1624 return NULL;
1625 return t;
1626}
1627
1628int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1629 struct ata_timing *t, int T, int UT)
1630{
1631 const struct ata_timing *s;
1632 struct ata_timing p;
1633
1634 /*
1635 * Find the mode.
1636 */
1637
1638 if (!(s = ata_timing_find_mode(speed)))
1639 return -EINVAL;
1640
1641 /*
1642 * If the drive is an EIDE drive, it can tell us it needs extended
1643 * PIO/MW_DMA cycle timing.
1644 */
1645
1646 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
1647 memset(&p, 0, sizeof(p));
1648 if(speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
1649 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO];
1650 else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY];
1651 } else if(speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) {
1652 p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN];
1653 }
1654 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
1655 }
1656
1657 /*
1658 * Convert the timing to bus clock counts.
1659 */
1660
1661 ata_timing_quantize(s, t, T, UT);
1662
1663 /*
1664 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
1665 * and some other commands. We have to ensure that the DMA cycle timing is
1666 * slower/equal than the fastest PIO timing.
1667 */
1668
1669 if (speed > XFER_PIO_4) {
1670 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
1671 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
1672 }
1673
1674 /*
1675 * Lenghten active & recovery time so that cycle time is correct.
1676 */
1677
1678 if (t->act8b + t->rec8b < t->cyc8b) {
1679 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
1680 t->rec8b = t->cyc8b - t->act8b;
1681 }
1682
1683 if (t->active + t->recover < t->cycle) {
1684 t->active += (t->cycle - (t->active + t->recover)) / 2;
1685 t->recover = t->cycle - t->active;
1686 }
1687
1688 return 0;
1689}
1690
1691static const struct {
1523 unsigned int shift; 1692 unsigned int shift;
1524 u8 base; 1693 u8 base;
1525} xfer_mode_classes[] = { 1694} xfer_mode_classes[] = {
@@ -1928,7 +2097,8 @@ err_out:
1928 DPRINTK("EXIT\n"); 2097 DPRINTK("EXIT\n");
1929} 2098}
1930 2099
1931static void ata_pr_blacklisted(struct ata_port *ap, struct ata_device *dev) 2100static void ata_pr_blacklisted(const struct ata_port *ap,
2101 const struct ata_device *dev)
1932{ 2102{
1933 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n", 2103 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n",
1934 ap->id, dev->devno); 2104 ap->id, dev->devno);
@@ -1966,7 +2136,7 @@ static const char * ata_dma_blacklist [] = {
1966 "_NEC DV5800A", 2136 "_NEC DV5800A",
1967}; 2137};
1968 2138
1969static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev) 2139static int ata_dma_blacklisted(const struct ata_device *dev)
1970{ 2140{
1971 unsigned char model_num[40]; 2141 unsigned char model_num[40];
1972 char *s; 2142 char *s;
@@ -1991,9 +2161,9 @@ static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev)
1991 return 0; 2161 return 0;
1992} 2162}
1993 2163
1994static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift) 2164static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
1995{ 2165{
1996 struct ata_device *master, *slave; 2166 const struct ata_device *master, *slave;
1997 unsigned int mask; 2167 unsigned int mask;
1998 2168
1999 master = &ap->device[0]; 2169 master = &ap->device[0];
@@ -2005,14 +2175,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2005 mask = ap->udma_mask; 2175 mask = ap->udma_mask;
2006 if (ata_dev_present(master)) { 2176 if (ata_dev_present(master)) {
2007 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff); 2177 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff);
2008 if (ata_dma_blacklisted(ap, master)) { 2178 if (ata_dma_blacklisted(master)) {
2009 mask = 0; 2179 mask = 0;
2010 ata_pr_blacklisted(ap, master); 2180 ata_pr_blacklisted(ap, master);
2011 } 2181 }
2012 } 2182 }
2013 if (ata_dev_present(slave)) { 2183 if (ata_dev_present(slave)) {
2014 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff); 2184 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff);
2015 if (ata_dma_blacklisted(ap, slave)) { 2185 if (ata_dma_blacklisted(slave)) {
2016 mask = 0; 2186 mask = 0;
2017 ata_pr_blacklisted(ap, slave); 2187 ata_pr_blacklisted(ap, slave);
2018 } 2188 }
@@ -2022,14 +2192,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2022 mask = ap->mwdma_mask; 2192 mask = ap->mwdma_mask;
2023 if (ata_dev_present(master)) { 2193 if (ata_dev_present(master)) {
2024 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07); 2194 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07);
2025 if (ata_dma_blacklisted(ap, master)) { 2195 if (ata_dma_blacklisted(master)) {
2026 mask = 0; 2196 mask = 0;
2027 ata_pr_blacklisted(ap, master); 2197 ata_pr_blacklisted(ap, master);
2028 } 2198 }
2029 } 2199 }
2030 if (ata_dev_present(slave)) { 2200 if (ata_dev_present(slave)) {
2031 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07); 2201 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07);
2032 if (ata_dma_blacklisted(ap, slave)) { 2202 if (ata_dma_blacklisted(slave)) {
2033 mask = 0; 2203 mask = 0;
2034 ata_pr_blacklisted(ap, slave); 2204 ata_pr_blacklisted(ap, slave);
2035 } 2205 }
@@ -2093,7 +2263,7 @@ static int fgb(u32 bitmap)
2093 * Zero on success, negative on error. 2263 * Zero on success, negative on error.
2094 */ 2264 */
2095 2265
2096static int ata_choose_xfer_mode(struct ata_port *ap, 2266static int ata_choose_xfer_mode(const struct ata_port *ap,
2097 u8 *xfer_mode_out, 2267 u8 *xfer_mode_out,
2098 unsigned int *xfer_shift_out) 2268 unsigned int *xfer_shift_out)
2099{ 2269{
@@ -2534,13 +2704,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2534 2704
2535/** 2705/**
2536 * ata_pio_poll - 2706 * ata_pio_poll -
2537 * @ap: 2707 * @ap: the target ata_port
2538 * 2708 *
2539 * LOCKING: 2709 * LOCKING:
2540 * None. (executing in kernel thread context) 2710 * None. (executing in kernel thread context)
2541 * 2711 *
2542 * RETURNS: 2712 * RETURNS:
2543 * 2713 * timeout value to use
2544 */ 2714 */
2545 2715
2546static unsigned long ata_pio_poll(struct ata_port *ap) 2716static unsigned long ata_pio_poll(struct ata_port *ap)
@@ -2581,8 +2751,8 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2581} 2751}
2582 2752
2583/** 2753/**
2584 * ata_pio_complete - 2754 * ata_pio_complete - check if drive is busy or idle
2585 * @ap: 2755 * @ap: the target ata_port
2586 * 2756 *
2587 * LOCKING: 2757 * LOCKING:
2588 * None. (executing in kernel thread context) 2758 * None. (executing in kernel thread context)
@@ -2634,7 +2804,7 @@ static int ata_pio_complete (struct ata_port *ap)
2634 2804
2635 2805
2636/** 2806/**
2637 * swap_buf_le16 - 2807 * swap_buf_le16 - swap halves of 16-words in place
2638 * @buf: Buffer to swap 2808 * @buf: Buffer to swap
2639 * @buf_words: Number of 16-bit words in buffer. 2809 * @buf_words: Number of 16-bit words in buffer.
2640 * 2810 *
@@ -2643,6 +2813,7 @@ static int ata_pio_complete (struct ata_port *ap)
2643 * vice-versa. 2813 * vice-versa.
2644 * 2814 *
2645 * LOCKING: 2815 * LOCKING:
2816 * Inherited from caller.
2646 */ 2817 */
2647void swap_buf_le16(u16 *buf, unsigned int buf_words) 2818void swap_buf_le16(u16 *buf, unsigned int buf_words)
2648{ 2819{
@@ -2665,7 +2836,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
2665 * 2836 *
2666 * LOCKING: 2837 * LOCKING:
2667 * Inherited from caller. 2838 * Inherited from caller.
2668 *
2669 */ 2839 */
2670 2840
2671static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf, 2841static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2711,7 +2881,6 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2711 * 2881 *
2712 * LOCKING: 2882 * LOCKING:
2713 * Inherited from caller. 2883 * Inherited from caller.
2714 *
2715 */ 2884 */
2716 2885
2717static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf, 2886static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2751,7 +2920,6 @@ static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
2751 * 2920 *
2752 * LOCKING: 2921 * LOCKING:
2753 * Inherited from caller. 2922 * Inherited from caller.
2754 *
2755 */ 2923 */
2756 2924
2757static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, 2925static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -3029,7 +3197,6 @@ next_sg:
3029 * 3197 *
3030 * LOCKING: 3198 * LOCKING:
3031 * Inherited from caller. 3199 * Inherited from caller.
3032 *
3033 */ 3200 */
3034 3201
3035static void atapi_pio_bytes(struct ata_queued_cmd *qc) 3202static void atapi_pio_bytes(struct ata_queued_cmd *qc)
@@ -3067,8 +3234,8 @@ err_out:
3067} 3234}
3068 3235
3069/** 3236/**
3070 * ata_pio_sector - 3237 * ata_pio_block - start PIO on a block
3071 * @ap: 3238 * @ap: the target ata_port
3072 * 3239 *
3073 * LOCKING: 3240 * LOCKING:
3074 * None. (executing in kernel thread context) 3241 * None. (executing in kernel thread context)
@@ -3080,7 +3247,7 @@ static void ata_pio_block(struct ata_port *ap)
3080 u8 status; 3247 u8 status;
3081 3248
3082 /* 3249 /*
3083 * This is purely hueristic. This is a fast path. 3250 * This is purely heuristic. This is a fast path.
3084 * Sometimes when we enter, BSY will be cleared in 3251 * Sometimes when we enter, BSY will be cleared in
3085 * a chk-status or two. If not, the drive is probably seeking 3252 * a chk-status or two. If not, the drive is probably seeking
3086 * or something. Snooze for a couple msecs, then 3253 * or something. Snooze for a couple msecs, then
@@ -3402,7 +3569,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3402 * 3569 *
3403 * LOCKING: 3570 * LOCKING:
3404 * spin_lock_irqsave(host_set lock) 3571 * spin_lock_irqsave(host_set lock)
3405 *
3406 */ 3572 */
3407void ata_qc_free(struct ata_queued_cmd *qc) 3573void ata_qc_free(struct ata_queued_cmd *qc)
3408{ 3574{
@@ -3422,7 +3588,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3422 * 3588 *
3423 * LOCKING: 3589 * LOCKING:
3424 * spin_lock_irqsave(host_set lock) 3590 * spin_lock_irqsave(host_set lock)
3425 *
3426 */ 3591 */
3427 3592
3428void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3593void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
@@ -4071,7 +4236,6 @@ idle_irq:
4071 * 4236 *
4072 * RETURNS: 4237 * RETURNS:
4073 * IRQ_NONE or IRQ_HANDLED. 4238 * IRQ_NONE or IRQ_HANDLED.
4074 *
4075 */ 4239 */
4076 4240
4077irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 4241irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
@@ -4114,6 +4278,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4114 * May be used as the port_start() entry in ata_port_operations. 4278 * May be used as the port_start() entry in ata_port_operations.
4115 * 4279 *
4116 * LOCKING: 4280 * LOCKING:
4281 * Inherited from caller.
4117 */ 4282 */
4118 4283
4119int ata_port_start (struct ata_port *ap) 4284int ata_port_start (struct ata_port *ap)
@@ -4139,6 +4304,7 @@ int ata_port_start (struct ata_port *ap)
4139 * May be used as the port_stop() entry in ata_port_operations. 4304 * May be used as the port_stop() entry in ata_port_operations.
4140 * 4305 *
4141 * LOCKING: 4306 * LOCKING:
4307 * Inherited from caller.
4142 */ 4308 */
4143 4309
4144void ata_port_stop (struct ata_port *ap) 4310void ata_port_stop (struct ata_port *ap)
@@ -4161,6 +4327,7 @@ void ata_host_stop (struct ata_host_set *host_set)
4161 * @do_unregister: 1 if we fully unregister, 0 to just stop the port 4327 * @do_unregister: 1 if we fully unregister, 0 to just stop the port
4162 * 4328 *
4163 * LOCKING: 4329 * LOCKING:
4330 * Inherited from caller.
4164 */ 4331 */
4165 4332
4166static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) 4333static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
@@ -4188,12 +4355,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
4188 * 4355 *
4189 * LOCKING: 4356 * LOCKING:
4190 * Inherited from caller. 4357 * Inherited from caller.
4191 *
4192 */ 4358 */
4193 4359
4194static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, 4360static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4195 struct ata_host_set *host_set, 4361 struct ata_host_set *host_set,
4196 struct ata_probe_ent *ent, unsigned int port_no) 4362 const struct ata_probe_ent *ent, unsigned int port_no)
4197{ 4363{
4198 unsigned int i; 4364 unsigned int i;
4199 4365
@@ -4249,10 +4415,9 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4249 * 4415 *
4250 * RETURNS: 4416 * RETURNS:
4251 * New ata_port on success, for NULL on error. 4417 * New ata_port on success, for NULL on error.
4252 *
4253 */ 4418 */
4254 4419
4255static struct ata_port * ata_host_add(struct ata_probe_ent *ent, 4420static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
4256 struct ata_host_set *host_set, 4421 struct ata_host_set *host_set,
4257 unsigned int port_no) 4422 unsigned int port_no)
4258{ 4423{
@@ -4297,10 +4462,9 @@ err_out:
4297 * 4462 *
4298 * RETURNS: 4463 * RETURNS:
4299 * Number of ports registered. Zero on error (no ports registered). 4464 * Number of ports registered. Zero on error (no ports registered).
4300 *
4301 */ 4465 */
4302 4466
4303int ata_device_add(struct ata_probe_ent *ent) 4467int ata_device_add(const struct ata_probe_ent *ent)
4304{ 4468{
4305 unsigned int count = 0, i; 4469 unsigned int count = 0, i;
4306 struct device *dev = ent->dev; 4470 struct device *dev = ent->dev;
@@ -4429,7 +4593,6 @@ err_out:
4429 * Inherited from calling layer (may sleep). 4593 * Inherited from calling layer (may sleep).
4430 */ 4594 */
4431 4595
4432
4433void ata_host_set_remove(struct ata_host_set *host_set) 4596void ata_host_set_remove(struct ata_host_set *host_set)
4434{ 4597{
4435 struct ata_port *ap; 4598 struct ata_port *ap;
@@ -4519,7 +4682,7 @@ void ata_std_ports(struct ata_ioports *ioaddr)
4519} 4682}
4520 4683
4521static struct ata_probe_ent * 4684static struct ata_probe_ent *
4522ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) 4685ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
4523{ 4686{
4524 struct ata_probe_ent *probe_ent; 4687 struct ata_probe_ent *probe_ent;
4525 4688
@@ -4619,7 +4782,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4619 if (!probe_ent) 4782 if (!probe_ent)
4620 return NULL; 4783 return NULL;
4621 4784
4622
4623 probe_ent->legacy_mode = 1; 4785 probe_ent->legacy_mode = 1;
4624 probe_ent->n_ports = 1; 4786 probe_ent->n_ports = 1;
4625 probe_ent->hard_port_no = port_num; 4787 probe_ent->hard_port_no = port_num;
@@ -4663,7 +4825,6 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4663 * 4825 *
4664 * RETURNS: 4826 * RETURNS:
4665 * Zero on success, negative on errno-based value on error. 4827 * Zero on success, negative on errno-based value on error.
4666 *
4667 */ 4828 */
4668 4829
4669int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 4830int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
@@ -4811,7 +4972,7 @@ err_out:
4811 * @pdev: PCI device that was removed 4972 * @pdev: PCI device that was removed
4812 * 4973 *
4813 * PCI layer indicates to libata via this hook that 4974 * PCI layer indicates to libata via this hook that
4814 * hot-unplug or module unload event has occured. 4975 * hot-unplug or module unload event has occurred.
4815 * Handle this by unregistering all objects associated 4976 * Handle this by unregistering all objects associated
4816 * with this PCI device. Free those objects. Then finally 4977 * with this PCI device. Free those objects. Then finally
4817 * release PCI resources and disable device. 4978 * release PCI resources and disable device.
@@ -4832,7 +4993,7 @@ void ata_pci_remove_one (struct pci_dev *pdev)
4832} 4993}
4833 4994
4834/* move to PCI subsystem */ 4995/* move to PCI subsystem */
4835int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) 4996int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
4836{ 4997{
4837 unsigned long tmp = 0; 4998 unsigned long tmp = 0;
4838 4999
@@ -4959,6 +5120,9 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
4959EXPORT_SYMBOL_GPL(ata_dev_config); 5120EXPORT_SYMBOL_GPL(ata_dev_config);
4960EXPORT_SYMBOL_GPL(ata_scsi_simulate); 5121EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4961 5122
5123EXPORT_SYMBOL_GPL(ata_timing_compute);
5124EXPORT_SYMBOL_GPL(ata_timing_merge);
5125
4962#ifdef CONFIG_PCI 5126#ifdef CONFIG_PCI
4963EXPORT_SYMBOL_GPL(pci_test_config_bits); 5127EXPORT_SYMBOL_GPL(pci_test_config_bits);
4964EXPORT_SYMBOL_GPL(ata_pci_host_stop); 5128EXPORT_SYMBOL_GPL(ata_pci_host_stop);