diff options
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r-- | drivers/ata/ahci.c | 100 |
1 files changed, 74 insertions, 26 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 1db93b619074..17ee6ed985d9 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -49,6 +49,10 @@ | |||
49 | #define DRV_NAME "ahci" | 49 | #define DRV_NAME "ahci" |
50 | #define DRV_VERSION "3.0" | 50 | #define DRV_VERSION "3.0" |
51 | 51 | ||
52 | static int ahci_skip_host_reset; | ||
53 | module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); | ||
54 | MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); | ||
55 | |||
52 | static int ahci_enable_alpm(struct ata_port *ap, | 56 | static int ahci_enable_alpm(struct ata_port *ap, |
53 | enum link_pm policy); | 57 | enum link_pm policy); |
54 | static void ahci_disable_alpm(struct ata_port *ap); | 58 | static void ahci_disable_alpm(struct ata_port *ap); |
@@ -186,6 +190,7 @@ enum { | |||
186 | AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ | 190 | AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ |
187 | AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ | 191 | AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ |
188 | AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */ | 192 | AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */ |
193 | AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */ | ||
189 | 194 | ||
190 | /* ap->flags bits */ | 195 | /* ap->flags bits */ |
191 | 196 | ||
@@ -255,6 +260,7 @@ static void ahci_vt8251_error_handler(struct ata_port *ap); | |||
255 | static void ahci_p5wdh_error_handler(struct ata_port *ap); | 260 | static void ahci_p5wdh_error_handler(struct ata_port *ap); |
256 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); | 261 | static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); |
257 | static int ahci_port_resume(struct ata_port *ap); | 262 | static int ahci_port_resume(struct ata_port *ap); |
263 | static void ahci_dev_config(struct ata_device *dev); | ||
258 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); | 264 | static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); |
259 | static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, | 265 | static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, |
260 | u32 opts); | 266 | u32 opts); |
@@ -294,6 +300,8 @@ static const struct ata_port_operations ahci_ops = { | |||
294 | .check_altstatus = ahci_check_status, | 300 | .check_altstatus = ahci_check_status, |
295 | .dev_select = ata_noop_dev_select, | 301 | .dev_select = ata_noop_dev_select, |
296 | 302 | ||
303 | .dev_config = ahci_dev_config, | ||
304 | |||
297 | .tf_read = ahci_tf_read, | 305 | .tf_read = ahci_tf_read, |
298 | 306 | ||
299 | .qc_defer = sata_pmp_qc_defer_cmd_switch, | 307 | .qc_defer = sata_pmp_qc_defer_cmd_switch, |
@@ -425,7 +433,7 @@ static const struct ata_port_info ahci_port_info[] = { | |||
425 | /* board_ahci_sb600 */ | 433 | /* board_ahci_sb600 */ |
426 | { | 434 | { |
427 | AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | | 435 | AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | |
428 | AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_PMP), | 436 | AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), |
429 | .flags = AHCI_FLAG_COMMON, | 437 | .flags = AHCI_FLAG_COMMON, |
430 | .link_flags = AHCI_LFLAG_COMMON, | 438 | .link_flags = AHCI_LFLAG_COMMON, |
431 | .pio_mask = 0x1f, /* pio0-4 */ | 439 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -563,6 +571,18 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
563 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ | 571 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ |
564 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ | 572 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ |
565 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ | 573 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ |
574 | { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */ | ||
575 | { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */ | ||
576 | { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */ | ||
577 | { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */ | ||
578 | { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */ | ||
579 | { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ | ||
580 | { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ | ||
581 | { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ | ||
582 | { PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */ | ||
583 | { PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */ | ||
584 | { PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */ | ||
585 | { PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */ | ||
566 | 586 | ||
567 | /* SiS */ | 587 | /* SiS */ |
568 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ | 588 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ |
@@ -571,6 +591,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
571 | 591 | ||
572 | /* Marvell */ | 592 | /* Marvell */ |
573 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ | 593 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ |
594 | { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */ | ||
574 | 595 | ||
575 | /* Generic, PCI class code for AHCI */ | 596 | /* Generic, PCI class code for AHCI */ |
576 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 597 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
@@ -645,6 +666,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
645 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 666 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; |
646 | u32 cap, port_map; | 667 | u32 cap, port_map; |
647 | int i; | 668 | int i; |
669 | int mv; | ||
648 | 670 | ||
649 | /* make sure AHCI mode is enabled before accessing CAP */ | 671 | /* make sure AHCI mode is enabled before accessing CAP */ |
650 | ahci_enable_ahci(mmio); | 672 | ahci_enable_ahci(mmio); |
@@ -668,7 +690,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
668 | cap &= ~HOST_CAP_NCQ; | 690 | cap &= ~HOST_CAP_NCQ; |
669 | } | 691 | } |
670 | 692 | ||
671 | if ((cap && HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { | 693 | if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { |
672 | dev_printk(KERN_INFO, &pdev->dev, | 694 | dev_printk(KERN_INFO, &pdev->dev, |
673 | "controller can't do PMP, turning off CAP_PMP\n"); | 695 | "controller can't do PMP, turning off CAP_PMP\n"); |
674 | cap &= ~HOST_CAP_PMP; | 696 | cap &= ~HOST_CAP_PMP; |
@@ -680,12 +702,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
680 | * presence register, as bit 4 (counting from 0) | 702 | * presence register, as bit 4 (counting from 0) |
681 | */ | 703 | */ |
682 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 704 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
705 | if (pdev->device == 0x6121) | ||
706 | mv = 0x3; | ||
707 | else | ||
708 | mv = 0xf; | ||
683 | dev_printk(KERN_ERR, &pdev->dev, | 709 | dev_printk(KERN_ERR, &pdev->dev, |
684 | "MV_AHCI HACK: port_map %x -> %x\n", | 710 | "MV_AHCI HACK: port_map %x -> %x\n", |
685 | hpriv->port_map, | 711 | port_map, |
686 | hpriv->port_map & 0xf); | 712 | port_map & mv); |
687 | 713 | ||
688 | port_map &= 0xf; | 714 | port_map &= mv; |
689 | } | 715 | } |
690 | 716 | ||
691 | /* cross check port_map and cap.n_ports */ | 717 | /* cross check port_map and cap.n_ports */ |
@@ -1072,29 +1098,35 @@ static int ahci_reset_controller(struct ata_host *host) | |||
1072 | ahci_enable_ahci(mmio); | 1098 | ahci_enable_ahci(mmio); |
1073 | 1099 | ||
1074 | /* global controller reset */ | 1100 | /* global controller reset */ |
1075 | tmp = readl(mmio + HOST_CTL); | 1101 | if (!ahci_skip_host_reset) { |
1076 | if ((tmp & HOST_RESET) == 0) { | 1102 | tmp = readl(mmio + HOST_CTL); |
1077 | writel(tmp | HOST_RESET, mmio + HOST_CTL); | 1103 | if ((tmp & HOST_RESET) == 0) { |
1078 | readl(mmio + HOST_CTL); /* flush */ | 1104 | writel(tmp | HOST_RESET, mmio + HOST_CTL); |
1079 | } | 1105 | readl(mmio + HOST_CTL); /* flush */ |
1106 | } | ||
1080 | 1107 | ||
1081 | /* reset must complete within 1 second, or | 1108 | /* reset must complete within 1 second, or |
1082 | * the hardware should be considered fried. | 1109 | * the hardware should be considered fried. |
1083 | */ | 1110 | */ |
1084 | ssleep(1); | 1111 | ssleep(1); |
1085 | 1112 | ||
1086 | tmp = readl(mmio + HOST_CTL); | 1113 | tmp = readl(mmio + HOST_CTL); |
1087 | if (tmp & HOST_RESET) { | 1114 | if (tmp & HOST_RESET) { |
1088 | dev_printk(KERN_ERR, host->dev, | 1115 | dev_printk(KERN_ERR, host->dev, |
1089 | "controller reset failed (0x%x)\n", tmp); | 1116 | "controller reset failed (0x%x)\n", tmp); |
1090 | return -EIO; | 1117 | return -EIO; |
1091 | } | 1118 | } |
1092 | 1119 | ||
1093 | /* turn on AHCI mode */ | 1120 | /* turn on AHCI mode */ |
1094 | ahci_enable_ahci(mmio); | 1121 | ahci_enable_ahci(mmio); |
1095 | 1122 | ||
1096 | /* some registers might be cleared on reset. restore initial values */ | 1123 | /* Some registers might be cleared on reset. Restore |
1097 | ahci_restore_initial_config(host); | 1124 | * initial values. |
1125 | */ | ||
1126 | ahci_restore_initial_config(host); | ||
1127 | } else | ||
1128 | dev_printk(KERN_INFO, host->dev, | ||
1129 | "skipping global host reset\n"); | ||
1098 | 1130 | ||
1099 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 1131 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
1100 | u16 tmp16; | 1132 | u16 tmp16; |
@@ -1146,9 +1178,14 @@ static void ahci_init_controller(struct ata_host *host) | |||
1146 | int i; | 1178 | int i; |
1147 | void __iomem *port_mmio; | 1179 | void __iomem *port_mmio; |
1148 | u32 tmp; | 1180 | u32 tmp; |
1181 | int mv; | ||
1149 | 1182 | ||
1150 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 1183 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
1151 | port_mmio = __ahci_port_base(host, 4); | 1184 | if (pdev->device == 0x6121) |
1185 | mv = 2; | ||
1186 | else | ||
1187 | mv = 4; | ||
1188 | port_mmio = __ahci_port_base(host, mv); | ||
1152 | 1189 | ||
1153 | writel(0, port_mmio + PORT_IRQ_MASK); | 1190 | writel(0, port_mmio + PORT_IRQ_MASK); |
1154 | 1191 | ||
@@ -1176,6 +1213,14 @@ static void ahci_init_controller(struct ata_host *host) | |||
1176 | VPRINTK("HOST_CTL 0x%x\n", tmp); | 1213 | VPRINTK("HOST_CTL 0x%x\n", tmp); |
1177 | } | 1214 | } |
1178 | 1215 | ||
1216 | static void ahci_dev_config(struct ata_device *dev) | ||
1217 | { | ||
1218 | struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; | ||
1219 | |||
1220 | if (hpriv->flags & AHCI_HFLAG_SECT255) | ||
1221 | dev->max_sectors = 255; | ||
1222 | } | ||
1223 | |||
1179 | static unsigned int ahci_dev_classify(struct ata_port *ap) | 1224 | static unsigned int ahci_dev_classify(struct ata_port *ap) |
1180 | { | 1225 | { |
1181 | void __iomem *port_mmio = ahci_port_base(ap); | 1226 | void __iomem *port_mmio = ahci_port_base(ap); |
@@ -2217,7 +2262,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2217 | if (rc) | 2262 | if (rc) |
2218 | return rc; | 2263 | return rc; |
2219 | 2264 | ||
2220 | rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | 2265 | /* AHCI controllers often implement SFF compatible interface. |
2266 | * Grab all PCI BARs just in case. | ||
2267 | */ | ||
2268 | rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | ||
2221 | if (rc == -EBUSY) | 2269 | if (rc == -EBUSY) |
2222 | pcim_pin_device(pdev); | 2270 | pcim_pin_device(pdev); |
2223 | if (rc) | 2271 | if (rc) |