diff options
-rw-r--r-- | drivers/ata/ahci.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index b697da483b70..35ede5c31b9f 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -169,14 +169,16 @@ enum { | |||
169 | PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ | 169 | PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ |
170 | PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ | 170 | PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ |
171 | 171 | ||
172 | /* hpriv->flags bits */ | ||
173 | AHCI_HFLAG_NO_NCQ = (1 << 0), | ||
174 | AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */ | ||
175 | AHCI_HFLAG_IGN_SERR_INTERNAL = (1 << 2), /* ignore SERR_INTERNAL */ | ||
176 | AHCI_HFLAG_32BIT_ONLY = (1 << 3), /* force 32bit */ | ||
177 | AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ | ||
178 | AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ | ||
179 | |||
172 | /* ap->flags bits */ | 180 | /* ap->flags bits */ |
173 | AHCI_FLAG_NO_NCQ = (1 << 24), | 181 | AHCI_FLAG_NO_HOTPLUG = (1 << 24), /* ignore PxSERR.DIAG.N */ |
174 | AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */ | ||
175 | AHCI_FLAG_IGN_SERR_INTERNAL = (1 << 27), /* ignore SERR_INTERNAL */ | ||
176 | AHCI_FLAG_32BIT_ONLY = (1 << 28), /* force 32bit */ | ||
177 | AHCI_FLAG_MV_PATA = (1 << 29), /* PATA port */ | ||
178 | AHCI_FLAG_NO_MSI = (1 << 30), /* no PCI MSI */ | ||
179 | AHCI_FLAG_NO_HOTPLUG = (1 << 31), /* ignore PxSERR.DIAG.N */ | ||
180 | 182 | ||
181 | AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 183 | AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
182 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | 184 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | |
@@ -200,6 +202,7 @@ struct ahci_sg { | |||
200 | }; | 202 | }; |
201 | 203 | ||
202 | struct ahci_host_priv { | 204 | struct ahci_host_priv { |
205 | unsigned int flags; /* AHCI_HFLAG_* */ | ||
203 | u32 cap; /* cap to use */ | 206 | u32 cap; /* cap to use */ |
204 | u32 port_map; /* port map to use */ | 207 | u32 port_map; /* port map to use */ |
205 | u32 saved_cap; /* saved initial cap */ | 208 | u32 saved_cap; /* saved initial cap */ |
@@ -341,6 +344,8 @@ static const struct ata_port_operations ahci_vt8251_ops = { | |||
341 | .port_stop = ahci_port_stop, | 344 | .port_stop = ahci_port_stop, |
342 | }; | 345 | }; |
343 | 346 | ||
347 | #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) | ||
348 | |||
344 | static const struct ata_port_info ahci_port_info[] = { | 349 | static const struct ata_port_info ahci_port_info[] = { |
345 | /* board_ahci */ | 350 | /* board_ahci */ |
346 | { | 351 | { |
@@ -352,7 +357,8 @@ static const struct ata_port_info ahci_port_info[] = { | |||
352 | }, | 357 | }, |
353 | /* board_ahci_vt8251 */ | 358 | /* board_ahci_vt8251 */ |
354 | { | 359 | { |
355 | .flags = AHCI_FLAG_COMMON | AHCI_FLAG_NO_NCQ, | 360 | AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), |
361 | .flags = AHCI_FLAG_COMMON, | ||
356 | .link_flags = AHCI_LFLAG_COMMON | ATA_LFLAG_HRST_TO_RESUME, | 362 | .link_flags = AHCI_LFLAG_COMMON | ATA_LFLAG_HRST_TO_RESUME, |
357 | .pio_mask = 0x1f, /* pio0-4 */ | 363 | .pio_mask = 0x1f, /* pio0-4 */ |
358 | .udma_mask = ATA_UDMA6, | 364 | .udma_mask = ATA_UDMA6, |
@@ -360,7 +366,8 @@ static const struct ata_port_info ahci_port_info[] = { | |||
360 | }, | 366 | }, |
361 | /* board_ahci_ign_iferr */ | 367 | /* board_ahci_ign_iferr */ |
362 | { | 368 | { |
363 | .flags = AHCI_FLAG_COMMON | AHCI_FLAG_IGN_IRQ_IF_ERR, | 369 | AHCI_HFLAGS (AHCI_HFLAG_IGN_IRQ_IF_ERR), |
370 | .flags = AHCI_FLAG_COMMON, | ||
364 | .link_flags = AHCI_LFLAG_COMMON, | 371 | .link_flags = AHCI_LFLAG_COMMON, |
365 | .pio_mask = 0x1f, /* pio0-4 */ | 372 | .pio_mask = 0x1f, /* pio0-4 */ |
366 | .udma_mask = ATA_UDMA6, | 373 | .udma_mask = ATA_UDMA6, |
@@ -368,9 +375,9 @@ static const struct ata_port_info ahci_port_info[] = { | |||
368 | }, | 375 | }, |
369 | /* board_ahci_sb600 */ | 376 | /* board_ahci_sb600 */ |
370 | { | 377 | { |
371 | .flags = AHCI_FLAG_COMMON | | 378 | AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | |
372 | AHCI_FLAG_IGN_SERR_INTERNAL | | 379 | AHCI_HFLAG_32BIT_ONLY), |
373 | AHCI_FLAG_32BIT_ONLY, | 380 | .flags = AHCI_FLAG_COMMON, |
374 | .link_flags = AHCI_LFLAG_COMMON, | 381 | .link_flags = AHCI_LFLAG_COMMON, |
375 | .pio_mask = 0x1f, /* pio0-4 */ | 382 | .pio_mask = 0x1f, /* pio0-4 */ |
376 | .udma_mask = ATA_UDMA6, | 383 | .udma_mask = ATA_UDMA6, |
@@ -378,11 +385,10 @@ static const struct ata_port_info ahci_port_info[] = { | |||
378 | }, | 385 | }, |
379 | /* board_ahci_mv */ | 386 | /* board_ahci_mv */ |
380 | { | 387 | { |
381 | .sht = &ahci_sht, | 388 | AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI | |
389 | AHCI_HFLAG_MV_PATA), | ||
382 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 390 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
383 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | 391 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, |
384 | AHCI_FLAG_NO_NCQ | AHCI_FLAG_NO_MSI | | ||
385 | AHCI_FLAG_MV_PATA, | ||
386 | .link_flags = AHCI_LFLAG_COMMON, | 392 | .link_flags = AHCI_LFLAG_COMMON, |
387 | .pio_mask = 0x1f, /* pio0-4 */ | 393 | .pio_mask = 0x1f, /* pio0-4 */ |
388 | .udma_mask = ATA_UDMA6, | 394 | .udma_mask = ATA_UDMA6, |
@@ -534,7 +540,6 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap) | |||
534 | /** | 540 | /** |
535 | * ahci_save_initial_config - Save and fixup initial config values | 541 | * ahci_save_initial_config - Save and fixup initial config values |
536 | * @pdev: target PCI device | 542 | * @pdev: target PCI device |
537 | * @pi: associated ATA port info | ||
538 | * @hpriv: host private area to store config values | 543 | * @hpriv: host private area to store config values |
539 | * | 544 | * |
540 | * Some registers containing configuration info might be setup by | 545 | * Some registers containing configuration info might be setup by |
@@ -548,7 +553,6 @@ static inline void __iomem *ahci_port_base(struct ata_port *ap) | |||
548 | * None. | 553 | * None. |
549 | */ | 554 | */ |
550 | static void ahci_save_initial_config(struct pci_dev *pdev, | 555 | static void ahci_save_initial_config(struct pci_dev *pdev, |
551 | const struct ata_port_info *pi, | ||
552 | struct ahci_host_priv *hpriv) | 556 | struct ahci_host_priv *hpriv) |
553 | { | 557 | { |
554 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 558 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; |
@@ -562,13 +566,13 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
562 | hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL); | 566 | hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL); |
563 | 567 | ||
564 | /* some chips have errata preventing 64bit use */ | 568 | /* some chips have errata preventing 64bit use */ |
565 | if ((cap & HOST_CAP_64) && (pi->flags & AHCI_FLAG_32BIT_ONLY)) { | 569 | if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) { |
566 | dev_printk(KERN_INFO, &pdev->dev, | 570 | dev_printk(KERN_INFO, &pdev->dev, |
567 | "controller can't do 64bit DMA, forcing 32bit\n"); | 571 | "controller can't do 64bit DMA, forcing 32bit\n"); |
568 | cap &= ~HOST_CAP_64; | 572 | cap &= ~HOST_CAP_64; |
569 | } | 573 | } |
570 | 574 | ||
571 | if ((cap & HOST_CAP_NCQ) && (pi->flags & AHCI_FLAG_NO_NCQ)) { | 575 | if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) { |
572 | dev_printk(KERN_INFO, &pdev->dev, | 576 | dev_printk(KERN_INFO, &pdev->dev, |
573 | "controller can't do NCQ, turning off CAP_NCQ\n"); | 577 | "controller can't do NCQ, turning off CAP_NCQ\n"); |
574 | cap &= ~HOST_CAP_NCQ; | 578 | cap &= ~HOST_CAP_NCQ; |
@@ -579,7 +583,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
579 | * is asserted through the standard AHCI port | 583 | * is asserted through the standard AHCI port |
580 | * presence register, as bit 4 (counting from 0) | 584 | * presence register, as bit 4 (counting from 0) |
581 | */ | 585 | */ |
582 | if (pi->flags & AHCI_FLAG_MV_PATA) { | 586 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
583 | dev_printk(KERN_ERR, &pdev->dev, | 587 | dev_printk(KERN_ERR, &pdev->dev, |
584 | "MV_AHCI HACK: port_map %x -> %x\n", | 588 | "MV_AHCI HACK: port_map %x -> %x\n", |
585 | hpriv->port_map, | 589 | hpriv->port_map, |
@@ -919,13 +923,14 @@ static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap, | |||
919 | 923 | ||
920 | static void ahci_init_controller(struct ata_host *host) | 924 | static void ahci_init_controller(struct ata_host *host) |
921 | { | 925 | { |
926 | struct ahci_host_priv *hpriv = host->private_data; | ||
922 | struct pci_dev *pdev = to_pci_dev(host->dev); | 927 | struct pci_dev *pdev = to_pci_dev(host->dev); |
923 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; | 928 | void __iomem *mmio = host->iomap[AHCI_PCI_BAR]; |
924 | int i; | 929 | int i; |
925 | void __iomem *port_mmio; | 930 | void __iomem *port_mmio; |
926 | u32 tmp; | 931 | u32 tmp; |
927 | 932 | ||
928 | if (host->ports[0]->flags & AHCI_FLAG_MV_PATA) { | 933 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
929 | port_mmio = __ahci_port_base(host, 4); | 934 | port_mmio = __ahci_port_base(host, 4); |
930 | 935 | ||
931 | writel(0, port_mmio + PORT_IRQ_MASK); | 936 | writel(0, port_mmio + PORT_IRQ_MASK); |
@@ -1307,6 +1312,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc) | |||
1307 | 1312 | ||
1308 | static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) | 1313 | static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) |
1309 | { | 1314 | { |
1315 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
1310 | struct ahci_port_priv *pp = ap->private_data; | 1316 | struct ahci_port_priv *pp = ap->private_data; |
1311 | struct ata_eh_info *host_ehi = &ap->link.eh_info; | 1317 | struct ata_eh_info *host_ehi = &ap->link.eh_info; |
1312 | struct ata_link *link = NULL; | 1318 | struct ata_link *link = NULL; |
@@ -1334,7 +1340,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) | |||
1334 | host_ehi->serror |= serror; | 1340 | host_ehi->serror |= serror; |
1335 | 1341 | ||
1336 | /* some controllers set IRQ_IF_ERR on device errors, ignore it */ | 1342 | /* some controllers set IRQ_IF_ERR on device errors, ignore it */ |
1337 | if (ap->flags & AHCI_FLAG_IGN_IRQ_IF_ERR) | 1343 | if (hpriv->flags & AHCI_HFLAG_IGN_IRQ_IF_ERR) |
1338 | irq_stat &= ~PORT_IRQ_IF_ERR; | 1344 | irq_stat &= ~PORT_IRQ_IF_ERR; |
1339 | 1345 | ||
1340 | if (irq_stat & PORT_IRQ_TF_ERR) { | 1346 | if (irq_stat & PORT_IRQ_TF_ERR) { |
@@ -1347,7 +1353,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat) | |||
1347 | else | 1353 | else |
1348 | active_ehi->err_mask |= AC_ERR_DEV; | 1354 | active_ehi->err_mask |= AC_ERR_DEV; |
1349 | 1355 | ||
1350 | if (ap->flags & AHCI_FLAG_IGN_SERR_INTERNAL) | 1356 | if (hpriv->flags & AHCI_HFLAG_IGN_SERR_INTERNAL) |
1351 | host_ehi->serror &= ~SERR_INTERNAL; | 1357 | host_ehi->serror &= ~SERR_INTERNAL; |
1352 | } | 1358 | } |
1353 | 1359 | ||
@@ -1977,15 +1983,16 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1977 | if (rc) | 1983 | if (rc) |
1978 | return rc; | 1984 | return rc; |
1979 | 1985 | ||
1980 | if ((pi.flags & AHCI_FLAG_NO_MSI) || pci_enable_msi(pdev)) | ||
1981 | pci_intx(pdev, 1); | ||
1982 | |||
1983 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); | 1986 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
1984 | if (!hpriv) | 1987 | if (!hpriv) |
1985 | return -ENOMEM; | 1988 | return -ENOMEM; |
1989 | hpriv->flags |= (unsigned long)pi.private_data; | ||
1990 | |||
1991 | if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) | ||
1992 | pci_intx(pdev, 1); | ||
1986 | 1993 | ||
1987 | /* save initial config */ | 1994 | /* save initial config */ |
1988 | ahci_save_initial_config(pdev, &pi, hpriv); | 1995 | ahci_save_initial_config(pdev, hpriv); |
1989 | 1996 | ||
1990 | /* prepare host */ | 1997 | /* prepare host */ |
1991 | if (hpriv->cap & HOST_CAP_NCQ) | 1998 | if (hpriv->cap & HOST_CAP_NCQ) |