diff options
-rw-r--r-- | drivers/scsi/ahci.c | 82 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 53 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 58 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 48 | ||||
-rw-r--r-- | include/linux/ata.h | 12 | ||||
-rw-r--r-- | include/linux/libata.h | 52 |
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 | ||
449 | static void ahci_phy_reset(struct ata_port *ap) | 449 | static 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 | |||
474 | static 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 | |||
486 | static 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 | |||
501 | static 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 | ||
629 | static void ahci_eng_timeout(struct ata_port *ap) | 657 | static 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 46c4cdbaee86..a07bd35da912 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -1526,6 +1526,41 @@ void ata_port_probe(struct ata_port *ap) | |||
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | /** | 1528 | /** |
1529 | * sata_print_link_status - Print SATA link status | ||
1530 | * @ap: SATA port to printk link status about | ||
1531 | * | ||
1532 | * This function prints link speed and status of a SATA link. | ||
1533 | * | ||
1534 | * LOCKING: | ||
1535 | * None. | ||
1536 | */ | ||
1537 | static void sata_print_link_status(struct ata_port *ap) | ||
1538 | { | ||
1539 | u32 sstatus, tmp; | ||
1540 | const char *speed; | ||
1541 | |||
1542 | if (!ap->ops->scr_read) | ||
1543 | return; | ||
1544 | |||
1545 | sstatus = scr_read(ap, SCR_STATUS); | ||
1546 | |||
1547 | if (sata_dev_present(ap)) { | ||
1548 | tmp = (sstatus >> 4) & 0xf; | ||
1549 | if (tmp & (1 << 0)) | ||
1550 | speed = "1.5"; | ||
1551 | else if (tmp & (1 << 1)) | ||
1552 | speed = "3.0"; | ||
1553 | else | ||
1554 | speed = "<unknown>"; | ||
1555 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1556 | ap->id, speed, sstatus); | ||
1557 | } else { | ||
1558 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | ||
1559 | ap->id, sstatus); | ||
1560 | } | ||
1561 | } | ||
1562 | |||
1563 | /** | ||
1529 | * __sata_phy_reset - Wake/reset a low-level SATA PHY | 1564 | * __sata_phy_reset - Wake/reset a low-level SATA PHY |
1530 | * @ap: SATA port associated with target SATA PHY. | 1565 | * @ap: SATA port associated with target SATA PHY. |
1531 | * | 1566 | * |
@@ -1559,27 +1594,14 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1559 | break; | 1594 | break; |
1560 | } while (time_before(jiffies, timeout)); | 1595 | } while (time_before(jiffies, timeout)); |
1561 | 1596 | ||
1562 | /* TODO: phy layer with polling, timeouts, etc. */ | 1597 | /* print link status */ |
1563 | sstatus = scr_read(ap, SCR_STATUS); | 1598 | sata_print_link_status(ap); |
1564 | if (sata_dev_present(ap)) { | ||
1565 | const char *speed; | ||
1566 | u32 tmp; | ||
1567 | 1599 | ||
1568 | tmp = (sstatus >> 4) & 0xf; | 1600 | /* TODO: phy layer with polling, timeouts, etc. */ |
1569 | if (tmp & (1 << 0)) | 1601 | if (sata_dev_present(ap)) |
1570 | speed = "1.5"; | ||
1571 | else if (tmp & (1 << 1)) | ||
1572 | speed = "3.0"; | ||
1573 | else | ||
1574 | speed = "<unknown>"; | ||
1575 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1576 | ap->id, speed, sstatus); | ||
1577 | ata_port_probe(ap); | 1602 | ata_port_probe(ap); |
1578 | } else { | 1603 | else |
1579 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | ||
1580 | ap->id, sstatus); | ||
1581 | ata_port_disable(ap); | 1604 | ata_port_disable(ap); |
1582 | } | ||
1583 | 1605 | ||
1584 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1606 | if (ap->flags & ATA_FLAG_PORT_DISABLED) |
1585 | return; | 1607 | 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 94f77cce27fa..a8155ca4947f 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -302,4 +302,16 @@ static inline int ata_ok(u8 status) | |||
302 | == ATA_DRDY); | 302 | == ATA_DRDY); |
303 | } | 303 | } |
304 | 304 | ||
305 | static inline int lba_28_ok(u64 block, u32 n_block) | ||
306 | { | ||
307 | /* check the ending block number */ | ||
308 | return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256); | ||
309 | } | ||
310 | |||
311 | static inline int lba_48_ok(u64 block, u32 n_block) | ||
312 | { | ||
313 | /* check the ending block number */ | ||
314 | return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); | ||
315 | } | ||
316 | |||
305 | #endif /* __LINUX_ATA_H__ */ | 317 | #endif /* __LINUX_ATA_H__ */ |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 9e5db2949c58..46ccea215892 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 | |||
78 | enum { | ||
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 | |||
98 | static 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 | ||
@@ -359,6 +392,8 @@ struct ata_port { | |||
359 | unsigned int hsm_task_state; | 392 | unsigned int hsm_task_state; |
360 | unsigned long pio_task_timeout; | 393 | unsigned long pio_task_timeout; |
361 | 394 | ||
395 | u32 msg_enable; | ||
396 | |||
362 | void *private_data; | 397 | void *private_data; |
363 | }; | 398 | }; |
364 | 399 | ||
@@ -645,9 +680,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
645 | 680 | ||
646 | if (status & (ATA_BUSY | ATA_DRQ)) { | 681 | if (status & (ATA_BUSY | ATA_DRQ)) { |
647 | unsigned long l = ap->ioaddr.status_addr; | 682 | unsigned long l = ap->ioaddr.status_addr; |
648 | printk(KERN_WARNING | 683 | if (ata_msg_warn(ap)) |
649 | "ATA: abnormal status 0x%X on port 0x%lX\n", | 684 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", |
650 | status, l); | 685 | status, l); |
651 | } | 686 | } |
652 | 687 | ||
653 | return status; | 688 | return status; |
@@ -739,7 +774,8 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
739 | 774 | ||
740 | status = ata_busy_wait(ap, bits, 1000); | 775 | status = ata_busy_wait(ap, bits, 1000); |
741 | if (status & bits) | 776 | if (status & bits) |
742 | DPRINTK("abnormal status 0x%X\n", status); | 777 | if (ata_msg_err(ap)) |
778 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
743 | 779 | ||
744 | /* get controller status; clear intr, err bits */ | 780 | /* get controller status; clear intr, err bits */ |
745 | if (ap->flags & ATA_FLAG_MMIO) { | 781 | if (ap->flags & ATA_FLAG_MMIO) { |
@@ -757,8 +793,10 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
757 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 793 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); |
758 | } | 794 | } |
759 | 795 | ||
760 | VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | 796 | if (ata_msg_intr(ap)) |
761 | host_stat, post_stat, status); | 797 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", |
798 | __FUNCTION__, | ||
799 | host_stat, post_stat, status); | ||
762 | 800 | ||
763 | return status; | 801 | return status; |
764 | } | 802 | } |