diff options
Diffstat (limited to 'drivers/scsi/ahci.c')
-rw-r--r-- | drivers/scsi/ahci.c | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index c2c8fa828e24..e2a5657d5fdb 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/interrupt.h> | 41 | #include <linux/interrupt.h> |
42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
43 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
44 | #include <linux/device.h> | ||
44 | #include "scsi.h" | 45 | #include "scsi.h" |
45 | #include <scsi/scsi_host.h> | 46 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
@@ -192,7 +193,6 @@ static void ahci_port_stop(struct ata_port *ap); | |||
192 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); | 193 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf); |
193 | static void ahci_qc_prep(struct ata_queued_cmd *qc); | 194 | static void ahci_qc_prep(struct ata_queued_cmd *qc); |
194 | static u8 ahci_check_status(struct ata_port *ap); | 195 | static u8 ahci_check_status(struct ata_port *ap); |
195 | static u8 ahci_check_err(struct ata_port *ap); | ||
196 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 196 | static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
197 | static void ahci_remove_one (struct pci_dev *pdev); | 197 | static void ahci_remove_one (struct pci_dev *pdev); |
198 | 198 | ||
@@ -216,12 +216,11 @@ static Scsi_Host_Template ahci_sht = { | |||
216 | .ordered_flush = 1, | 216 | .ordered_flush = 1, |
217 | }; | 217 | }; |
218 | 218 | ||
219 | static struct ata_port_operations ahci_ops = { | 219 | static const struct ata_port_operations ahci_ops = { |
220 | .port_disable = ata_port_disable, | 220 | .port_disable = ata_port_disable, |
221 | 221 | ||
222 | .check_status = ahci_check_status, | 222 | .check_status = ahci_check_status, |
223 | .check_altstatus = ahci_check_status, | 223 | .check_altstatus = ahci_check_status, |
224 | .check_err = ahci_check_err, | ||
225 | .dev_select = ata_noop_dev_select, | 224 | .dev_select = ata_noop_dev_select, |
226 | 225 | ||
227 | .tf_read = ahci_tf_read, | 226 | .tf_read = ahci_tf_read, |
@@ -407,7 +406,7 @@ static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in) | |||
407 | return 0xffffffffU; | 406 | return 0xffffffffU; |
408 | } | 407 | } |
409 | 408 | ||
410 | return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); | 409 | return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); |
411 | } | 410 | } |
412 | 411 | ||
413 | 412 | ||
@@ -425,7 +424,7 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in, | |||
425 | return; | 424 | return; |
426 | } | 425 | } |
427 | 426 | ||
428 | writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); | 427 | writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); |
429 | } | 428 | } |
430 | 429 | ||
431 | static void ahci_phy_reset(struct ata_port *ap) | 430 | static void ahci_phy_reset(struct ata_port *ap) |
@@ -453,18 +452,11 @@ static void ahci_phy_reset(struct ata_port *ap) | |||
453 | 452 | ||
454 | static u8 ahci_check_status(struct ata_port *ap) | 453 | static u8 ahci_check_status(struct ata_port *ap) |
455 | { | 454 | { |
456 | void *mmio = (void *) ap->ioaddr.cmd_addr; | 455 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr; |
457 | 456 | ||
458 | return readl(mmio + PORT_TFDATA) & 0xFF; | 457 | return readl(mmio + PORT_TFDATA) & 0xFF; |
459 | } | 458 | } |
460 | 459 | ||
461 | static u8 ahci_check_err(struct ata_port *ap) | ||
462 | { | ||
463 | void *mmio = (void *) ap->ioaddr.cmd_addr; | ||
464 | |||
465 | return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF; | ||
466 | } | ||
467 | |||
468 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 460 | static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
469 | { | 461 | { |
470 | struct ahci_port_priv *pp = ap->private_data; | 462 | struct ahci_port_priv *pp = ap->private_data; |
@@ -609,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap) | |||
609 | * not being called from the SCSI EH. | 601 | * not being called from the SCSI EH. |
610 | */ | 602 | */ |
611 | qc->scsidone = scsi_finish_command; | 603 | qc->scsidone = scsi_finish_command; |
612 | ata_qc_complete(qc, ATA_ERR); | 604 | ata_qc_complete(qc, AC_ERR_OTHER); |
613 | } | 605 | } |
614 | 606 | ||
615 | spin_unlock_irqrestore(&host_set->lock, flags); | 607 | spin_unlock_irqrestore(&host_set->lock, flags); |
@@ -638,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
638 | if (status & PORT_IRQ_FATAL) { | 630 | if (status & PORT_IRQ_FATAL) { |
639 | ahci_intr_error(ap, status); | 631 | ahci_intr_error(ap, status); |
640 | if (qc) | 632 | if (qc) |
641 | ata_qc_complete(qc, ATA_ERR); | 633 | ata_qc_complete(qc, AC_ERR_OTHER); |
642 | } | 634 | } |
643 | 635 | ||
644 | return 1; | 636 | return 1; |
@@ -672,17 +664,35 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * | |||
672 | 664 | ||
673 | for (i = 0; i < host_set->n_ports; i++) { | 665 | for (i = 0; i < host_set->n_ports; i++) { |
674 | struct ata_port *ap; | 666 | struct ata_port *ap; |
675 | u32 tmp; | ||
676 | 667 | ||
677 | VPRINTK("port %u\n", i); | 668 | if (!(irq_stat & (1 << i))) |
669 | continue; | ||
670 | |||
678 | ap = host_set->ports[i]; | 671 | ap = host_set->ports[i]; |
679 | tmp = irq_stat & (1 << i); | 672 | if (ap) { |
680 | if (tmp && ap) { | ||
681 | struct ata_queued_cmd *qc; | 673 | struct ata_queued_cmd *qc; |
682 | qc = ata_qc_from_tag(ap, ap->active_tag); | 674 | qc = ata_qc_from_tag(ap, ap->active_tag); |
683 | if (ahci_host_intr(ap, qc)) | 675 | if (!ahci_host_intr(ap, qc)) |
684 | irq_ack |= (1 << i); | 676 | if (ata_ratelimit()) { |
677 | struct pci_dev *pdev = | ||
678 | to_pci_dev(ap->host_set->dev); | ||
679 | dev_printk(KERN_WARNING, &pdev->dev, | ||
680 | "unhandled interrupt on port %u\n", | ||
681 | i); | ||
682 | } | ||
683 | |||
684 | VPRINTK("port %u\n", i); | ||
685 | } else { | ||
686 | VPRINTK("port %u (no irq)\n", i); | ||
687 | if (ata_ratelimit()) { | ||
688 | struct pci_dev *pdev = | ||
689 | to_pci_dev(ap->host_set->dev); | ||
690 | dev_printk(KERN_WARNING, &pdev->dev, | ||
691 | "interrupt on disabled port %u\n", i); | ||
692 | } | ||
685 | } | 693 | } |
694 | |||
695 | irq_ack |= (1 << i); | ||
686 | } | 696 | } |
687 | 697 | ||
688 | if (irq_ack) { | 698 | if (irq_ack) { |
@@ -750,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) | |||
750 | 760 | ||
751 | tmp = readl(mmio + HOST_CTL); | 761 | tmp = readl(mmio + HOST_CTL); |
752 | if (tmp & HOST_RESET) { | 762 | if (tmp & HOST_RESET) { |
753 | printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", | 763 | dev_printk(KERN_ERR, &pdev->dev, |
754 | pci_name(pdev), tmp); | 764 | "controller reset failed (0x%x)\n", tmp); |
755 | return -EIO; | 765 | return -EIO; |
756 | } | 766 | } |
757 | 767 | ||
@@ -779,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent) | |||
779 | if (rc) { | 789 | if (rc) { |
780 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 790 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
781 | if (rc) { | 791 | if (rc) { |
782 | printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", | 792 | dev_printk(KERN_ERR, &pdev->dev, |
783 | pci_name(pdev)); | 793 | "64-bit DMA enable failed\n"); |
784 | return rc; | 794 | return rc; |
785 | } | 795 | } |
786 | } | 796 | } |
787 | } else { | 797 | } else { |
788 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 798 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
789 | if (rc) { | 799 | if (rc) { |
790 | printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", | 800 | dev_printk(KERN_ERR, &pdev->dev, |
791 | pci_name(pdev)); | 801 | "32-bit DMA enable failed\n"); |
792 | return rc; | 802 | return rc; |
793 | } | 803 | } |
794 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 804 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
795 | if (rc) { | 805 | if (rc) { |
796 | printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", | 806 | dev_printk(KERN_ERR, &pdev->dev, |
797 | pci_name(pdev)); | 807 | "32-bit consistent DMA enable failed\n"); |
798 | return rc; | 808 | return rc; |
799 | } | 809 | } |
800 | } | 810 | } |
@@ -897,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) | |||
897 | else | 907 | else |
898 | scc_s = "unknown"; | 908 | scc_s = "unknown"; |
899 | 909 | ||
900 | printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x " | 910 | dev_printk(KERN_INFO, &pdev->dev, |
911 | "AHCI %02x%02x.%02x%02x " | ||
901 | "%u slots %u ports %s Gbps 0x%x impl %s mode\n" | 912 | "%u slots %u ports %s Gbps 0x%x impl %s mode\n" |
902 | , | 913 | , |
903 | pci_name(pdev), | ||
904 | 914 | ||
905 | (vers >> 24) & 0xff, | 915 | (vers >> 24) & 0xff, |
906 | (vers >> 16) & 0xff, | 916 | (vers >> 16) & 0xff, |
@@ -913,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) | |||
913 | impl, | 923 | impl, |
914 | scc_s); | 924 | scc_s); |
915 | 925 | ||
916 | printk(KERN_INFO DRV_NAME "(%s) flags: " | 926 | dev_printk(KERN_INFO, &pdev->dev, |
927 | "flags: " | ||
917 | "%s%s%s%s%s%s" | 928 | "%s%s%s%s%s%s" |
918 | "%s%s%s%s%s%s%s\n" | 929 | "%s%s%s%s%s%s%s\n" |
919 | , | 930 | , |
920 | pci_name(pdev), | ||
921 | 931 | ||
922 | cap & (1 << 31) ? "64bit " : "", | 932 | cap & (1 << 31) ? "64bit " : "", |
923 | cap & (1 << 30) ? "ncq " : "", | 933 | cap & (1 << 30) ? "ncq " : "", |
@@ -950,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
950 | VPRINTK("ENTER\n"); | 960 | VPRINTK("ENTER\n"); |
951 | 961 | ||
952 | if (!printed_version++) | 962 | if (!printed_version++) |
953 | printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); | 963 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
954 | 964 | ||
955 | rc = pci_enable_device(pdev); | 965 | rc = pci_enable_device(pdev); |
956 | if (rc) | 966 | if (rc) |