aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/ahci.c82
-rw-r--r--drivers/scsi/ata_piix.c53
-rw-r--r--drivers/scsi/libata-core.c58
-rw-r--r--drivers/scsi/libata-scsi.c48
-rw-r--r--include/linux/ata.h12
-rw-r--r--include/linux/libata.h52
6 files changed, 212 insertions, 93 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 19bd346951dd..30676b0eb366 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -446,10 +446,61 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
446 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); 446 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
447} 447}
448 448
449static void ahci_phy_reset(struct ata_port *ap) 449static int ahci_stop_engine(struct ata_port *ap)
450{
451 void __iomem *mmio = ap->host_set->mmio_base;
452 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
453 int work;
454 u32 tmp;
455
456 tmp = readl(port_mmio + PORT_CMD);
457 tmp &= ~PORT_CMD_START;
458 writel(tmp, port_mmio + PORT_CMD);
459
460 /* wait for engine to stop. TODO: this could be
461 * as long as 500 msec
462 */
463 work = 1000;
464 while (work-- > 0) {
465 tmp = readl(port_mmio + PORT_CMD);
466 if ((tmp & PORT_CMD_LIST_ON) == 0)
467 return 0;
468 udelay(10);
469 }
470
471 return -EIO;
472}
473
474static void ahci_start_engine(struct ata_port *ap)
475{
476 void __iomem *mmio = ap->host_set->mmio_base;
477 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
478 u32 tmp;
479
480 tmp = readl(port_mmio + PORT_CMD);
481 tmp |= PORT_CMD_START;
482 writel(tmp, port_mmio + PORT_CMD);
483 readl(port_mmio + PORT_CMD); /* flush */
484}
485
486static unsigned int ahci_dev_classify(struct ata_port *ap)
450{ 487{
451 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; 488 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
452 struct ata_taskfile tf; 489 struct ata_taskfile tf;
490 u32 tmp;
491
492 tmp = readl(port_mmio + PORT_SIG);
493 tf.lbah = (tmp >> 24) & 0xff;
494 tf.lbam = (tmp >> 16) & 0xff;
495 tf.lbal = (tmp >> 8) & 0xff;
496 tf.nsect = (tmp) & 0xff;
497
498 return ata_dev_classify(&tf);
499}
500
501static void ahci_phy_reset(struct ata_port *ap)
502{
503 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
453 struct ata_device *dev = &ap->device[0]; 504 struct ata_device *dev = &ap->device[0];
454 u32 new_tmp, tmp; 505 u32 new_tmp, tmp;
455 506
@@ -458,13 +509,7 @@ static void ahci_phy_reset(struct ata_port *ap)
458 if (ap->flags & ATA_FLAG_PORT_DISABLED) 509 if (ap->flags & ATA_FLAG_PORT_DISABLED)
459 return; 510 return;
460 511
461 tmp = readl(port_mmio + PORT_SIG); 512 dev->class = ahci_dev_classify(ap);
462 tf.lbah = (tmp >> 24) & 0xff;
463 tf.lbam = (tmp >> 16) & 0xff;
464 tf.lbal = (tmp >> 8) & 0xff;
465 tf.nsect = (tmp) & 0xff;
466
467 dev->class = ata_dev_classify(&tf);
468 if (!ata_dev_present(dev)) { 513 if (!ata_dev_present(dev)) {
469 ata_port_disable(ap); 514 ata_port_disable(ap);
470 return; 515 return;
@@ -572,7 +617,6 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
572 void __iomem *mmio = ap->host_set->mmio_base; 617 void __iomem *mmio = ap->host_set->mmio_base;
573 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 618 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
574 u32 tmp; 619 u32 tmp;
575 int work;
576 620
577 if ((ap->device[0].class != ATA_DEV_ATAPI) || 621 if ((ap->device[0].class != ATA_DEV_ATAPI) ||
578 ((irq_stat & PORT_IRQ_TF_ERR) == 0)) 622 ((irq_stat & PORT_IRQ_TF_ERR) == 0))
@@ -588,20 +632,7 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
588 readl(port_mmio + PORT_SCR_ERR)); 632 readl(port_mmio + PORT_SCR_ERR));
589 633
590 /* stop DMA */ 634 /* stop DMA */
591 tmp = readl(port_mmio + PORT_CMD); 635 ahci_stop_engine(ap);
592 tmp &= ~PORT_CMD_START;
593 writel(tmp, port_mmio + PORT_CMD);
594
595 /* wait for engine to stop. TODO: this could be
596 * as long as 500 msec
597 */
598 work = 1000;
599 while (work-- > 0) {
600 tmp = readl(port_mmio + PORT_CMD);
601 if ((tmp & PORT_CMD_LIST_ON) == 0)
602 break;
603 udelay(10);
604 }
605 636
606 /* clear SATA phy error, if any */ 637 /* clear SATA phy error, if any */
607 tmp = readl(port_mmio + PORT_SCR_ERR); 638 tmp = readl(port_mmio + PORT_SCR_ERR);
@@ -620,10 +651,7 @@ static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
620 } 651 }
621 652
622 /* re-start DMA */ 653 /* re-start DMA */
623 tmp = readl(port_mmio + PORT_CMD); 654 ahci_start_engine(ap);
624 tmp |= PORT_CMD_START;
625 writel(tmp, port_mmio + PORT_CMD);
626 readl(port_mmio + PORT_CMD); /* flush */
627} 655}
628 656
629static void ahci_eng_timeout(struct ata_port *ap) 657static void ahci_eng_timeout(struct ata_port *ap)
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index fc3ca051ceed..19d8d4ba6a1e 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -101,9 +101,11 @@ enum {
101 ICH5_PCS = 0x92, /* port control and status */ 101 ICH5_PCS = 0x92, /* port control and status */
102 PIIX_SCC = 0x0A, /* sub-class code register */ 102 PIIX_SCC = 0x0A, /* sub-class code register */
103 103
104 PIIX_FLAG_AHCI = (1 << 28), /* AHCI possible */ 104 PIIX_FLAG_AHCI = (1 << 27), /* AHCI possible */
105 PIIX_FLAG_CHECKINTR = (1 << 29), /* make sure PCI INTx enabled */ 105 PIIX_FLAG_CHECKINTR = (1 << 28), /* make sure PCI INTx enabled */
106 PIIX_FLAG_COMBINED = (1 << 30), /* combined mode possible */ 106 PIIX_FLAG_COMBINED = (1 << 29), /* combined mode possible */
107 /* ICH6/7 use different scheme for map value */
108 PIIX_FLAG_COMBINED_ICH6 = PIIX_FLAG_COMBINED | (1 << 30),
107 109
108 /* combined mode. if set, PATA is channel 0. 110 /* combined mode. if set, PATA is channel 0.
109 * if clear, PATA is channel 1. 111 * if clear, PATA is channel 1.
@@ -297,8 +299,8 @@ static struct ata_port_info piix_port_info[] = {
297 { 299 {
298 .sht = &piix_sht, 300 .sht = &piix_sht,
299 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | 301 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST |
300 PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | 302 PIIX_FLAG_COMBINED_ICH6 |
301 ATA_FLAG_SLAVE_POSS, 303 PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS,
302 .pio_mask = 0x1f, /* pio0-4 */ 304 .pio_mask = 0x1f, /* pio0-4 */
303 .mwdma_mask = 0x07, /* mwdma0-2 */ 305 .mwdma_mask = 0x07, /* mwdma0-2 */
304 .udma_mask = 0x7f, /* udma0-6 */ 306 .udma_mask = 0x7f, /* udma0-6 */
@@ -309,8 +311,9 @@ static struct ata_port_info piix_port_info[] = {
309 { 311 {
310 .sht = &piix_sht, 312 .sht = &piix_sht,
311 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | 313 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST |
312 PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | 314 PIIX_FLAG_COMBINED_ICH6 |
313 ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, 315 PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS |
316 PIIX_FLAG_AHCI,
314 .pio_mask = 0x1f, /* pio0-4 */ 317 .pio_mask = 0x1f, /* pio0-4 */
315 .mwdma_mask = 0x07, /* mwdma0-2 */ 318 .mwdma_mask = 0x07, /* mwdma0-2 */
316 .udma_mask = 0x7f, /* udma0-6 */ 319 .udma_mask = 0x7f, /* udma0-6 */
@@ -680,6 +683,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
680 struct ata_port_info *port_info[2]; 683 struct ata_port_info *port_info[2];
681 unsigned int combined = 0; 684 unsigned int combined = 0;
682 unsigned int pata_chan = 0, sata_chan = 0; 685 unsigned int pata_chan = 0, sata_chan = 0;
686 unsigned long host_flags;
683 687
684 if (!printed_version++) 688 if (!printed_version++)
685 dev_printk(KERN_DEBUG, &pdev->dev, 689 dev_printk(KERN_DEBUG, &pdev->dev,
@@ -692,7 +696,9 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
692 port_info[0] = &piix_port_info[ent->driver_data]; 696 port_info[0] = &piix_port_info[ent->driver_data];
693 port_info[1] = &piix_port_info[ent->driver_data]; 697 port_info[1] = &piix_port_info[ent->driver_data];
694 698
695 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { 699 host_flags = port_info[0]->host_flags;
700
701 if (host_flags & PIIX_FLAG_AHCI) {
696 u8 tmp; 702 u8 tmp;
697 pci_read_config_byte(pdev, PIIX_SCC, &tmp); 703 pci_read_config_byte(pdev, PIIX_SCC, &tmp);
698 if (tmp == PIIX_AHCI_DEVICE) { 704 if (tmp == PIIX_AHCI_DEVICE) {
@@ -702,16 +708,35 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
702 } 708 }
703 } 709 }
704 710
705 if (port_info[0]->host_flags & PIIX_FLAG_COMBINED) { 711 if (host_flags & PIIX_FLAG_COMBINED) {
706 u8 tmp; 712 u8 tmp;
707 pci_read_config_byte(pdev, ICH5_PMR, &tmp); 713 pci_read_config_byte(pdev, ICH5_PMR, &tmp);
708 714
709 if (tmp & PIIX_COMB) { 715 if (host_flags & PIIX_FLAG_COMBINED_ICH6) {
710 combined = 1; 716 switch (tmp) {
711 if (tmp & PIIX_COMB_PATA_P0) 717 case 0:
718 break;
719 case 1:
720 combined = 1;
712 sata_chan = 1; 721 sata_chan = 1;
713 else 722 break;
723 case 2:
724 combined = 1;
714 pata_chan = 1; 725 pata_chan = 1;
726 break;
727 case 3:
728 dev_printk(KERN_WARNING, &pdev->dev,
729 "invalid MAP value %u\n", tmp);
730 break;
731 }
732 } else {
733 if (tmp & PIIX_COMB) {
734 combined = 1;
735 if (tmp & PIIX_COMB_PATA_P0)
736 sata_chan = 1;
737 else
738 pata_chan = 1;
739 }
715 } 740 }
716 } 741 }
717 742
@@ -721,7 +746,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
721 * MSI is disabled (and it is disabled, as we don't use 746 * MSI is disabled (and it is disabled, as we don't use
722 * message-signalled interrupts currently). 747 * message-signalled interrupts currently).
723 */ 748 */
724 if (port_info[0]->host_flags & PIIX_FLAG_CHECKINTR) 749 if (host_flags & PIIX_FLAG_CHECKINTR)
725 pci_intx(pdev, 1); 750 pci_intx(pdev, 1);
726 751
727 if (combined) { 752 if (combined) {
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 498f20668fe0..857f535c8190 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1536,6 +1536,41 @@ void ata_port_probe(struct ata_port *ap)
1536} 1536}
1537 1537
1538/** 1538/**
1539 * sata_print_link_status - Print SATA link status
1540 * @ap: SATA port to printk link status about
1541 *
1542 * This function prints link speed and status of a SATA link.
1543 *
1544 * LOCKING:
1545 * None.
1546 */
1547static void sata_print_link_status(struct ata_port *ap)
1548{
1549 u32 sstatus, tmp;
1550 const char *speed;
1551
1552 if (!ap->ops->scr_read)
1553 return;
1554
1555 sstatus = scr_read(ap, SCR_STATUS);
1556
1557 if (sata_dev_present(ap)) {
1558 tmp = (sstatus >> 4) & 0xf;
1559 if (tmp & (1 << 0))
1560 speed = "1.5";
1561 else if (tmp & (1 << 1))
1562 speed = "3.0";
1563 else
1564 speed = "<unknown>";
1565 printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n",
1566 ap->id, speed, sstatus);
1567 } else {
1568 printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n",
1569 ap->id, sstatus);
1570 }
1571}
1572
1573/**
1539 * __sata_phy_reset - Wake/reset a low-level SATA PHY 1574 * __sata_phy_reset - Wake/reset a low-level SATA PHY
1540 * @ap: SATA port associated with target SATA PHY. 1575 * @ap: SATA port associated with target SATA PHY.
1541 * 1576 *
@@ -1569,27 +1604,14 @@ void __sata_phy_reset(struct ata_port *ap)
1569 break; 1604 break;
1570 } while (time_before(jiffies, timeout)); 1605 } while (time_before(jiffies, timeout));
1571 1606
1572 /* TODO: phy layer with polling, timeouts, etc. */ 1607 /* print link status */
1573 sstatus = scr_read(ap, SCR_STATUS); 1608 sata_print_link_status(ap);
1574 if (sata_dev_present(ap)) {
1575 const char *speed;
1576 u32 tmp;
1577 1609
1578 tmp = (sstatus >> 4) & 0xf; 1610 /* TODO: phy layer with polling, timeouts, etc. */
1579 if (tmp & (1 << 0)) 1611 if (sata_dev_present(ap))
1580 speed = "1.5";
1581 else if (tmp & (1 << 1))
1582 speed = "3.0";
1583 else
1584 speed = "<unknown>";
1585 printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n",
1586 ap->id, speed, sstatus);
1587 ata_port_probe(ap); 1612 ata_port_probe(ap);
1588 } else { 1613 else
1589 printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n",
1590 ap->id, sstatus);
1591 ata_port_disable(ap); 1614 ata_port_disable(ap);
1592 }
1593 1615
1594 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1616 if (ap->flags & ATA_FLAG_PORT_DISABLED)
1595 return; 1617 return;
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index cfbceb504718..0e65bfe92e6f 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -985,9 +985,13 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
985 if (dev->flags & ATA_DFLAG_LBA) { 985 if (dev->flags & ATA_DFLAG_LBA) {
986 tf->flags |= ATA_TFLAG_LBA; 986 tf->flags |= ATA_TFLAG_LBA;
987 987
988 if (dev->flags & ATA_DFLAG_LBA48) { 988 if (lba_28_ok(block, n_block)) {
989 if (n_block > (64 * 1024)) 989 /* use LBA28 */
990 goto invalid_fld; 990 tf->command = ATA_CMD_VERIFY;
991 tf->device |= (block >> 24) & 0xf;
992 } else if (lba_48_ok(block, n_block)) {
993 if (!(dev->flags & ATA_DFLAG_LBA48))
994 goto out_of_range;
991 995
992 /* use LBA48 */ 996 /* use LBA48 */
993 tf->flags |= ATA_TFLAG_LBA48; 997 tf->flags |= ATA_TFLAG_LBA48;
@@ -998,15 +1002,9 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
998 tf->hob_lbah = (block >> 40) & 0xff; 1002 tf->hob_lbah = (block >> 40) & 0xff;
999 tf->hob_lbam = (block >> 32) & 0xff; 1003 tf->hob_lbam = (block >> 32) & 0xff;
1000 tf->hob_lbal = (block >> 24) & 0xff; 1004 tf->hob_lbal = (block >> 24) & 0xff;
1001 } else { 1005 } else
1002 if (n_block > 256) 1006 /* request too large even for LBA48 */
1003 goto invalid_fld; 1007 goto out_of_range;
1004
1005 /* use LBA28 */
1006 tf->command = ATA_CMD_VERIFY;
1007
1008 tf->device |= (block >> 24) & 0xf;
1009 }
1010 1008
1011 tf->nsect = n_block & 0xff; 1009 tf->nsect = n_block & 0xff;
1012 1010
@@ -1019,8 +1017,8 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
1019 /* CHS */ 1017 /* CHS */
1020 u32 sect, head, cyl, track; 1018 u32 sect, head, cyl, track;
1021 1019
1022 if (n_block > 256) 1020 if (!lba_28_ok(block, n_block))
1023 goto invalid_fld; 1021 goto out_of_range;
1024 1022
1025 /* Convert LBA to CHS */ 1023 /* Convert LBA to CHS */
1026 track = (u32)block / dev->sectors; 1024 track = (u32)block / dev->sectors;
@@ -1139,9 +1137,11 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1139 if (dev->flags & ATA_DFLAG_LBA) { 1137 if (dev->flags & ATA_DFLAG_LBA) {
1140 tf->flags |= ATA_TFLAG_LBA; 1138 tf->flags |= ATA_TFLAG_LBA;
1141 1139
1142 if (dev->flags & ATA_DFLAG_LBA48) { 1140 if (lba_28_ok(block, n_block)) {
1143 /* The request -may- be too large for LBA48. */ 1141 /* use LBA28 */
1144 if ((block >> 48) || (n_block > 65536)) 1142 tf->device |= (block >> 24) & 0xf;
1143 } else if (lba_48_ok(block, n_block)) {
1144 if (!(dev->flags & ATA_DFLAG_LBA48))
1145 goto out_of_range; 1145 goto out_of_range;
1146 1146
1147 /* use LBA48 */ 1147 /* use LBA48 */
@@ -1152,15 +1152,9 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1152 tf->hob_lbah = (block >> 40) & 0xff; 1152 tf->hob_lbah = (block >> 40) & 0xff;
1153 tf->hob_lbam = (block >> 32) & 0xff; 1153 tf->hob_lbam = (block >> 32) & 0xff;
1154 tf->hob_lbal = (block >> 24) & 0xff; 1154 tf->hob_lbal = (block >> 24) & 0xff;
1155 } else { 1155 } else
1156 /* use LBA28 */ 1156 /* request too large even for LBA48 */
1157 1157 goto out_of_range;
1158 /* The request -may- be too large for LBA28. */
1159 if ((block >> 28) || (n_block > 256))
1160 goto out_of_range;
1161
1162 tf->device |= (block >> 24) & 0xf;
1163 }
1164 1158
1165 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1159 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1166 goto invalid_fld; 1160 goto invalid_fld;
@@ -1178,7 +1172,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1178 u32 sect, head, cyl, track; 1172 u32 sect, head, cyl, track;
1179 1173
1180 /* The request -may- be too large for CHS addressing. */ 1174 /* The request -may- be too large for CHS addressing. */
1181 if ((block >> 28) || (n_block > 256)) 1175 if (!lba_28_ok(block, n_block))
1182 goto out_of_range; 1176 goto out_of_range;
1183 1177
1184 if (unlikely(ata_rwcmd_protocol(qc) < 0)) 1178 if (unlikely(ata_rwcmd_protocol(qc) < 0))
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 29fa99bde2be..8e88efc565be 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -313,4 +313,16 @@ static inline int ata_ok(u8 status)
313 == ATA_DRDY); 313 == ATA_DRDY);
314} 314}
315 315
316static inline int lba_28_ok(u64 block, u32 n_block)
317{
318 /* check the ending block number */
319 return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256);
320}
321
322static inline int lba_48_ok(u64 block, u32 n_block)
323{
324 /* check the ending block number */
325 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
326}
327
316#endif /* __LINUX_ATA_H__ */ 328#endif /* __LINUX_ATA_H__ */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 6282bd553c45..cf59ecfff865 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -35,7 +35,8 @@
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36 36
37/* 37/*
38 * compile-time options 38 * compile-time options: to be removed as soon as all the drivers are
39 * converted to the new debugging mechanism
39 */ 40 */
40#undef ATA_DEBUG /* debugging output */ 41#undef ATA_DEBUG /* debugging output */
41#undef ATA_VERBOSE_DEBUG /* yet more debugging output */ 42#undef ATA_VERBOSE_DEBUG /* yet more debugging output */
@@ -71,6 +72,38 @@
71 } 72 }
72#endif 73#endif
73 74
75/* NEW: debug levels */
76#define HAVE_LIBATA_MSG 1
77
78enum {
79 ATA_MSG_DRV = 0x0001,
80 ATA_MSG_INFO = 0x0002,
81 ATA_MSG_PROBE = 0x0004,
82 ATA_MSG_WARN = 0x0008,
83 ATA_MSG_MALLOC = 0x0010,
84 ATA_MSG_CTL = 0x0020,
85 ATA_MSG_INTR = 0x0040,
86 ATA_MSG_ERR = 0x0080,
87};
88
89#define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV)
90#define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO)
91#define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE)
92#define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN)
93#define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC)
94#define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL)
95#define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR)
96#define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR)
97
98static inline u32 ata_msg_init(int dval, int default_msg_enable_bits)
99{
100 if (dval < 0 || dval >= (sizeof(u32) * 8))
101 return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */
102 if (!dval)
103 return 0;
104 return (1 << dval) - 1;
105}
106
74/* defines only for the constants which don't work well as enums */ 107/* defines only for the constants which don't work well as enums */
75#define ATA_TAG_POISON 0xfafbfcfdU 108#define ATA_TAG_POISON 0xfafbfcfdU
76 109
@@ -362,6 +395,8 @@ struct ata_port {
362 unsigned int hsm_task_state; 395 unsigned int hsm_task_state;
363 unsigned long pio_task_timeout; 396 unsigned long pio_task_timeout;
364 397
398 u32 msg_enable;
399
365 void *private_data; 400 void *private_data;
366}; 401};
367 402
@@ -648,9 +683,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
648 683
649 if (status & (ATA_BUSY | ATA_DRQ)) { 684 if (status & (ATA_BUSY | ATA_DRQ)) {
650 unsigned long l = ap->ioaddr.status_addr; 685 unsigned long l = ap->ioaddr.status_addr;
651 printk(KERN_WARNING 686 if (ata_msg_warn(ap))
652 "ATA: abnormal status 0x%X on port 0x%lX\n", 687 printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n",
653 status, l); 688 status, l);
654 } 689 }
655 690
656 return status; 691 return status;
@@ -742,7 +777,8 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
742 777
743 status = ata_busy_wait(ap, bits, 1000); 778 status = ata_busy_wait(ap, bits, 1000);
744 if (status & bits) 779 if (status & bits)
745 DPRINTK("abnormal status 0x%X\n", status); 780 if (ata_msg_err(ap))
781 printk(KERN_ERR "abnormal status 0x%X\n", status);
746 782
747 /* get controller status; clear intr, err bits */ 783 /* get controller status; clear intr, err bits */
748 if (ap->flags & ATA_FLAG_MMIO) { 784 if (ap->flags & ATA_FLAG_MMIO) {
@@ -760,8 +796,10 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
760 post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 796 post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
761 } 797 }
762 798
763 VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", 799 if (ata_msg_intr(ap))
764 host_stat, post_stat, status); 800 printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
801 __FUNCTION__,
802 host_stat, post_stat, status);
765 803
766 return status; 804 return status;
767} 805}