diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-26 17:58:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-26 17:58:03 -0500 |
commit | 6f366c1c751454df3d1c0f25f15ee0164821112a (patch) | |
tree | a609adb9ead12ec0df5dcadaa11133f92a442466 | |
parent | 221dee285ee38099b82437531bcae9fa9cb64cc4 (diff) | |
parent | cb48cab7f363014e0a5dc21f7b4892c15d626d41 (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev: (51 commits)
[libata] bump versions
[libata] Trim trailing whitespace.
[libata] sata_mv: Fix 50xx irq mask
[libata] sata_mv: don't touch reserved bits in EDMA config register
libata: Use new id_to_dma_mode function to tidy reporting in more drivers (minimally tested)
pata_pcmcia: Fix oops in 2.6.21-rc1
Add id_to_dma_mode function for printing DMA modes
sata_promise: simplify port setup
sata_promise: fix 20619 new EH merge error
[libata] ACPI: remove needless ->qc_issue hook existence test
sata_vsc: refactor vsc_sata_interrupt and hook up error handling
sata_sil: ignore and clear spurious IRQs while executing commands by polling
sata_mv: fix pci_enable_msi() error handling
pata_amd: fix an obvious bug in cable detection
[libata] ata_piix: remove duplicate PCI IDs
sata_nv: complain on spurious completion notifiers
libata: test major version in ata_id_is_sata()
sata_nv: kill old private BMDMA helper functions
libata: fix remaining ap->id
ahci: consider SDB FIS containing spurious NCQ completions HSM violation (regenerated)
...
53 files changed, 2014 insertions, 558 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 4af0a4bb5780..d16b5b0c8b76 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -562,6 +562,15 @@ config PATA_IXP4XX_CF | |||
562 | 562 | ||
563 | If unsure, say N. | 563 | If unsure, say N. |
564 | 564 | ||
565 | config PATA_SCC | ||
566 | tristate "Toshiba's Cell Reference Set IDE support" | ||
567 | depends on PCI && PPC_IBM_CELL_BLADE | ||
568 | help | ||
569 | This option enables support for the built-in IDE controller on | ||
570 | Toshiba Cell Reference Board. | ||
571 | |||
572 | If unsure, say N. | ||
573 | |||
565 | endif | 574 | endif |
566 | endmenu | 575 | endmenu |
567 | 576 | ||
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 74298afbbaa7..13d7397e0008 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -59,6 +59,7 @@ obj-$(CONFIG_PATA_WINBOND_VLB) += pata_winbond.o | |||
59 | obj-$(CONFIG_PATA_SIS) += pata_sis.o | 59 | obj-$(CONFIG_PATA_SIS) += pata_sis.o |
60 | obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o | 60 | obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o |
61 | obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o | 61 | obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o |
62 | obj-$(CONFIG_PATA_SCC) += pata_scc.o | ||
62 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o | 63 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o |
63 | # Should be last but one libata driver | 64 | # Should be last but one libata driver |
64 | obj-$(CONFIG_ATA_GENERIC) += ata_generic.o | 65 | obj-$(CONFIG_ATA_GENERIC) += ata_generic.o |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6a3543e06241..6d932409aadd 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "ahci" | 48 | #define DRV_NAME "ahci" |
49 | #define DRV_VERSION "2.0" | 49 | #define DRV_VERSION "2.1" |
50 | 50 | ||
51 | 51 | ||
52 | enum { | 52 | enum { |
@@ -198,7 +198,6 @@ struct ahci_port_priv { | |||
198 | void *rx_fis; | 198 | void *rx_fis; |
199 | dma_addr_t rx_fis_dma; | 199 | dma_addr_t rx_fis_dma; |
200 | /* for NCQ spurious interrupt analysis */ | 200 | /* for NCQ spurious interrupt analysis */ |
201 | int ncq_saw_spurious_sdb_cnt; | ||
202 | unsigned int ncq_saw_d2h:1; | 201 | unsigned int ncq_saw_d2h:1; |
203 | unsigned int ncq_saw_dmas:1; | 202 | unsigned int ncq_saw_dmas:1; |
204 | }; | 203 | }; |
@@ -1160,23 +1159,24 @@ static void ahci_host_intr(struct ata_port *ap) | |||
1160 | known_irq = 1; | 1159 | known_irq = 1; |
1161 | } | 1160 | } |
1162 | 1161 | ||
1163 | if (status & PORT_IRQ_SDB_FIS && | 1162 | if (status & PORT_IRQ_SDB_FIS) { |
1164 | pp->ncq_saw_spurious_sdb_cnt < 10) { | ||
1165 | /* SDB FIS containing spurious completions might be | 1163 | /* SDB FIS containing spurious completions might be |
1166 | * dangerous, we need to know more about them. Print | 1164 | * dangerous, whine and fail commands with HSM |
1167 | * more of it. | 1165 | * violation. EH will turn off NCQ after several such |
1168 | */ | 1166 | * failures. |
1167 | */ | ||
1169 | const __le32 *f = pp->rx_fis + RX_FIS_SDB; | 1168 | const __le32 *f = pp->rx_fis + RX_FIS_SDB; |
1170 | 1169 | ||
1171 | ata_port_printk(ap, KERN_INFO, "Spurious SDB FIS during NCQ " | 1170 | ata_ehi_push_desc(ehi, "spurious completion during NCQ " |
1172 | "issue=0x%x SAct=0x%x FIS=%08x:%08x%s\n", | 1171 | "issue=0x%x SAct=0x%x FIS=%08x:%08x", |
1173 | readl(port_mmio + PORT_CMD_ISSUE), | 1172 | readl(port_mmio + PORT_CMD_ISSUE), |
1174 | readl(port_mmio + PORT_SCR_ACT), | 1173 | readl(port_mmio + PORT_SCR_ACT), |
1175 | le32_to_cpu(f[0]), le32_to_cpu(f[1]), | 1174 | le32_to_cpu(f[0]), le32_to_cpu(f[1])); |
1176 | pp->ncq_saw_spurious_sdb_cnt < 10 ? | 1175 | |
1177 | "" : ", shutting up"); | 1176 | ehi->err_mask |= AC_ERR_HSM; |
1177 | ehi->action |= ATA_EH_SOFTRESET; | ||
1178 | ata_port_freeze(ap); | ||
1178 | 1179 | ||
1179 | pp->ncq_saw_spurious_sdb_cnt++; | ||
1180 | known_irq = 1; | 1180 | known_irq = 1; |
1181 | } | 1181 | } |
1182 | 1182 | ||
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index be66ea08da55..f48b4883c930 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/libata.h> | 26 | #include <linux/libata.h> |
27 | 27 | ||
28 | #define DRV_NAME "ata_generic" | 28 | #define DRV_NAME "ata_generic" |
29 | #define DRV_VERSION "0.2.10" | 29 | #define DRV_VERSION "0.2.11" |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * A generic parallel ATA driver using libata | 32 | * A generic parallel ATA driver using libata |
@@ -90,10 +90,10 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
90 | /* We do need the right mode information for DMA or PIO | 90 | /* We do need the right mode information for DMA or PIO |
91 | and this comes from the current configuration flags */ | 91 | and this comes from the current configuration flags */ |
92 | if (dma_enabled & (1 << (5 + i))) { | 92 | if (dma_enabled & (1 << (5 + i))) { |
93 | dev->xfer_mode = XFER_MW_DMA_0; | 93 | ata_id_to_dma_mode(dev, XFER_MW_DMA_0); |
94 | dev->xfer_shift = ATA_SHIFT_MWDMA; | ||
95 | dev->flags &= ~ATA_DFLAG_PIO; | 94 | dev->flags &= ~ATA_DFLAG_PIO; |
96 | } else { | 95 | } else { |
96 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
97 | dev->xfer_mode = XFER_PIO_0; | 97 | dev->xfer_mode = XFER_PIO_0; |
98 | dev->xfer_shift = ATA_SHIFT_PIO; | 98 | dev->xfer_shift = ATA_SHIFT_PIO; |
99 | dev->flags |= ATA_DFLAG_PIO; | 99 | dev->flags |= ATA_DFLAG_PIO; |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 4d716c7347e7..61572d8c78ad 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -93,7 +93,7 @@ | |||
93 | #include <linux/libata.h> | 93 | #include <linux/libata.h> |
94 | 94 | ||
95 | #define DRV_NAME "ata_piix" | 95 | #define DRV_NAME "ata_piix" |
96 | #define DRV_VERSION "2.00ac7" | 96 | #define DRV_VERSION "2.10" |
97 | 97 | ||
98 | enum { | 98 | enum { |
99 | PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ | 99 | PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ |
@@ -169,8 +169,6 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
169 | /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */ | 169 | /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */ |
170 | /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */ | 170 | /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */ |
171 | { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 }, | 171 | { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 }, |
172 | { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, | ||
173 | { 0x8086, 0x25a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, | ||
174 | /* Intel PIIX4 */ | 172 | /* Intel PIIX4 */ |
175 | { 0x8086, 0x7199, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 }, | 173 | { 0x8086, 0x7199, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 }, |
176 | /* Intel PIIX4 */ | 174 | /* Intel PIIX4 */ |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index b4e8be5d292c..d14a48e75f1b 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -294,9 +294,8 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, | |||
294 | return 0; | 294 | return 0; |
295 | 295 | ||
296 | if (ata_msg_probe(ap)) | 296 | if (ata_msg_probe(ap)) |
297 | ata_dev_printk(atadev, KERN_DEBUG, | 297 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
298 | "%s: ENTER: ap->id: %d, port#: %d\n", | 298 | __FUNCTION__, ap->port_no); |
299 | __FUNCTION__, ap->id, ap->port_no); | ||
300 | 299 | ||
301 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { | 300 | if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { |
302 | if (ata_msg_probe(ap)) | 301 | if (ata_msg_probe(ap)) |
@@ -456,6 +455,9 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
456 | struct ata_device *atadev, | 455 | struct ata_device *atadev, |
457 | const struct taskfile_array *gtf) | 456 | const struct taskfile_array *gtf) |
458 | { | 457 | { |
458 | struct ata_taskfile tf; | ||
459 | unsigned int err; | ||
460 | |||
459 | if (ata_msg_probe(ap)) | 461 | if (ata_msg_probe(ap)) |
460 | ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " | 462 | ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " |
461 | "%02x %02x %02x %02x %02x %02x %02x\n", | 463 | "%02x %02x %02x %02x %02x %02x %02x\n", |
@@ -468,35 +470,25 @@ static void taskfile_load_raw(struct ata_port *ap, | |||
468 | && (gtf->tfa[6] == 0)) | 470 | && (gtf->tfa[6] == 0)) |
469 | return; | 471 | return; |
470 | 472 | ||
471 | if (ap->ops->qc_issue) { | 473 | ata_tf_init(atadev, &tf); |
472 | struct ata_taskfile tf; | 474 | |
473 | unsigned int err; | 475 | /* convert gtf to tf */ |
474 | 476 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ | |
475 | ata_tf_init(atadev, &tf); | 477 | tf.protocol = atadev->class == ATA_DEV_ATAPI ? |
476 | 478 | ATA_PROT_ATAPI_NODATA : ATA_PROT_NODATA; | |
477 | /* convert gtf to tf */ | 479 | tf.feature = gtf->tfa[0]; /* 0x1f1 */ |
478 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ | 480 | tf.nsect = gtf->tfa[1]; /* 0x1f2 */ |
479 | tf.protocol = atadev->class == ATA_DEV_ATAPI ? | 481 | tf.lbal = gtf->tfa[2]; /* 0x1f3 */ |
480 | ATA_PROT_ATAPI_NODATA : ATA_PROT_NODATA; | 482 | tf.lbam = gtf->tfa[3]; /* 0x1f4 */ |
481 | tf.feature = gtf->tfa[0]; /* 0x1f1 */ | 483 | tf.lbah = gtf->tfa[4]; /* 0x1f5 */ |
482 | tf.nsect = gtf->tfa[1]; /* 0x1f2 */ | 484 | tf.device = gtf->tfa[5]; /* 0x1f6 */ |
483 | tf.lbal = gtf->tfa[2]; /* 0x1f3 */ | 485 | tf.command = gtf->tfa[6]; /* 0x1f7 */ |
484 | tf.lbam = gtf->tfa[3]; /* 0x1f4 */ | 486 | |
485 | tf.lbah = gtf->tfa[4]; /* 0x1f5 */ | 487 | err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); |
486 | tf.device = gtf->tfa[5]; /* 0x1f6 */ | 488 | if (err && ata_msg_probe(ap)) |
487 | tf.command = gtf->tfa[6]; /* 0x1f7 */ | 489 | ata_dev_printk(atadev, KERN_ERR, |
488 | 490 | "%s: ata_exec_internal failed: %u\n", | |
489 | err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); | 491 | __FUNCTION__, err); |
490 | if (err && ata_msg_probe(ap)) | ||
491 | ata_dev_printk(atadev, KERN_ERR, | ||
492 | "%s: ata_exec_internal failed: %u\n", | ||
493 | __FUNCTION__, err); | ||
494 | } else | ||
495 | if (ata_msg_warn(ap)) | ||
496 | ata_dev_printk(atadev, KERN_WARNING, | ||
497 | "%s: SATA driver is missing qc_issue function" | ||
498 | " entry points\n", | ||
499 | __FUNCTION__); | ||
500 | } | 492 | } |
501 | 493 | ||
502 | /** | 494 | /** |
@@ -521,9 +513,8 @@ static int do_drive_set_taskfiles(struct ata_port *ap, | |||
521 | struct taskfile_array *gtf; | 513 | struct taskfile_array *gtf; |
522 | 514 | ||
523 | if (ata_msg_probe(ap)) | 515 | if (ata_msg_probe(ap)) |
524 | ata_dev_printk(atadev, KERN_DEBUG, | 516 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", |
525 | "%s: ENTER: ap->id: %d, port#: %d\n", | 517 | __FUNCTION__, ap->port_no); |
526 | __FUNCTION__, ap->id, ap->port_no); | ||
527 | 518 | ||
528 | if (noacpi || !(ap->cbl == ATA_CBL_SATA)) | 519 | if (noacpi || !(ap->cbl == ATA_CBL_SATA)) |
529 | return 0; | 520 | return 0; |
@@ -627,9 +618,8 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | |||
627 | return 0; | 618 | return 0; |
628 | 619 | ||
629 | if (ata_msg_probe(ap)) | 620 | if (ata_msg_probe(ap)) |
630 | ata_dev_printk(atadev, KERN_DEBUG, | 621 | ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", |
631 | "%s: ap->id: %d, ix = %d, port#: %d\n", | 622 | __FUNCTION__, ix, ap->port_no); |
632 | __FUNCTION__, ap->id, ix, ap->port_no); | ||
633 | 623 | ||
634 | /* Don't continue if not a SATA device. */ | 624 | /* Don't continue if not a SATA device. */ |
635 | if (!(ap->cbl == ATA_CBL_SATA)) { | 625 | if (!(ap->cbl == ATA_CBL_SATA)) { |
@@ -685,9 +675,8 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) | |||
685 | if (err < 0) { | 675 | if (err < 0) { |
686 | if (ata_msg_probe(ap)) | 676 | if (ata_msg_probe(ap)) |
687 | ata_dev_printk(atadev, KERN_DEBUG, | 677 | ata_dev_printk(atadev, KERN_DEBUG, |
688 | "ata%u(%u): %s _SDD error: status = 0x%x\n", | 678 | "%s _SDD error: status = 0x%x\n", |
689 | ap->id, ap->device->devno, | 679 | __FUNCTION__, status); |
690 | __FUNCTION__, status); | ||
691 | } | 680 | } |
692 | 681 | ||
693 | /* always return success */ | 682 | /* always return success */ |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index e900c5edefc4..c8d44a7c403f 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -59,7 +59,7 @@ | |||
59 | 59 | ||
60 | #include "libata.h" | 60 | #include "libata.h" |
61 | 61 | ||
62 | #define DRV_VERSION "2.10" /* must be exactly four chars */ | 62 | #define DRV_VERSION "2.20" /* must be exactly four chars */ |
63 | 63 | ||
64 | 64 | ||
65 | /* debounce timing parameters in msecs { interval, duration, timeout } */ | 65 | /* debounce timing parameters in msecs { interval, duration, timeout } */ |
@@ -72,7 +72,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, | |||
72 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); | 72 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); |
73 | static void ata_dev_xfermask(struct ata_device *dev); | 73 | static void ata_dev_xfermask(struct ata_device *dev); |
74 | 74 | ||
75 | static unsigned int ata_unique_id = 1; | 75 | static unsigned int ata_print_id = 1; |
76 | static struct workqueue_struct *ata_wq; | 76 | static struct workqueue_struct *ata_wq; |
77 | 77 | ||
78 | struct workqueue_struct *ata_aux_wq; | 78 | struct workqueue_struct *ata_aux_wq; |
@@ -315,9 +315,7 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, | |||
315 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 315 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
316 | tf->flags |= tf_flags; | 316 | tf->flags |= tf_flags; |
317 | 317 | ||
318 | if ((dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | | 318 | if (ata_ncq_enabled(dev) && likely(tag != ATA_TAG_INTERNAL)) { |
319 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ && | ||
320 | likely(tag != ATA_TAG_INTERNAL)) { | ||
321 | /* yay, NCQ */ | 319 | /* yay, NCQ */ |
322 | if (!lba_48_ok(block, n_block)) | 320 | if (!lba_48_ok(block, n_block)) |
323 | return -ERANGE; | 321 | return -ERANGE; |
@@ -600,6 +598,8 @@ void ata_dev_disable(struct ata_device *dev) | |||
600 | { | 598 | { |
601 | if (ata_dev_enabled(dev) && ata_msg_drv(dev->ap)) { | 599 | if (ata_dev_enabled(dev) && ata_msg_drv(dev->ap)) { |
602 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); | 600 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); |
601 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | | ||
602 | ATA_DNXFER_QUIET); | ||
603 | dev->class++; | 603 | dev->class++; |
604 | } | 604 | } |
605 | } | 605 | } |
@@ -708,7 +708,7 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf) | |||
708 | * Device type - %ATA_DEV_ATA, %ATA_DEV_ATAPI or %ATA_DEV_NONE. | 708 | * Device type - %ATA_DEV_ATA, %ATA_DEV_ATAPI or %ATA_DEV_NONE. |
709 | */ | 709 | */ |
710 | 710 | ||
711 | static unsigned int | 711 | unsigned int |
712 | ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err) | 712 | ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err) |
713 | { | 713 | { |
714 | struct ata_taskfile tf; | 714 | struct ata_taskfile tf; |
@@ -824,6 +824,48 @@ static u64 ata_id_n_sectors(const u16 *id) | |||
824 | } | 824 | } |
825 | 825 | ||
826 | /** | 826 | /** |
827 | * ata_id_to_dma_mode - Identify DMA mode from id block | ||
828 | * @dev: device to identify | ||
829 | * @mode: mode to assume if we cannot tell | ||
830 | * | ||
831 | * Set up the timing values for the device based upon the identify | ||
832 | * reported values for the DMA mode. This function is used by drivers | ||
833 | * which rely upon firmware configured modes, but wish to report the | ||
834 | * mode correctly when possible. | ||
835 | * | ||
836 | * In addition we emit similarly formatted messages to the default | ||
837 | * ata_dev_set_mode handler, in order to provide consistency of | ||
838 | * presentation. | ||
839 | */ | ||
840 | |||
841 | void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown) | ||
842 | { | ||
843 | unsigned int mask; | ||
844 | u8 mode; | ||
845 | |||
846 | /* Pack the DMA modes */ | ||
847 | mask = ((dev->id[63] >> 8) << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA; | ||
848 | if (dev->id[53] & 0x04) | ||
849 | mask |= ((dev->id[88] >> 8) << ATA_SHIFT_UDMA) & ATA_MASK_UDMA; | ||
850 | |||
851 | /* Select the mode in use */ | ||
852 | mode = ata_xfer_mask2mode(mask); | ||
853 | |||
854 | if (mode != 0) { | ||
855 | ata_dev_printk(dev, KERN_INFO, "configured for %s\n", | ||
856 | ata_mode_string(mask)); | ||
857 | } else { | ||
858 | /* SWDMA perhaps ? */ | ||
859 | mode = unknown; | ||
860 | ata_dev_printk(dev, KERN_INFO, "configured for DMA\n"); | ||
861 | } | ||
862 | |||
863 | /* Configure the device reporting */ | ||
864 | dev->xfer_mode = mode; | ||
865 | dev->xfer_shift = ata_xfer_mode2shift(mode); | ||
866 | } | ||
867 | |||
868 | /** | ||
827 | * ata_noop_dev_select - Select device 0/1 on ATA bus | 869 | * ata_noop_dev_select - Select device 0/1 on ATA bus |
828 | * @ap: ATA channel to manipulate | 870 | * @ap: ATA channel to manipulate |
829 | * @device: ATA device (numbered from zero) to select | 871 | * @device: ATA device (numbered from zero) to select |
@@ -891,8 +933,8 @@ void ata_dev_select(struct ata_port *ap, unsigned int device, | |||
891 | unsigned int wait, unsigned int can_sleep) | 933 | unsigned int wait, unsigned int can_sleep) |
892 | { | 934 | { |
893 | if (ata_msg_probe(ap)) | 935 | if (ata_msg_probe(ap)) |
894 | ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: " | 936 | ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, " |
895 | "device %u, wait %u\n", ap->id, device, wait); | 937 | "device %u, wait %u\n", device, wait); |
896 | 938 | ||
897 | if (wait) | 939 | if (wait) |
898 | ata_wait_idle(ap); | 940 | ata_wait_idle(ap); |
@@ -1392,8 +1434,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1392 | int rc; | 1434 | int rc; |
1393 | 1435 | ||
1394 | if (ata_msg_ctl(ap)) | 1436 | if (ata_msg_ctl(ap)) |
1395 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", | 1437 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); |
1396 | __FUNCTION__, ap->id, dev->devno); | ||
1397 | 1438 | ||
1398 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ | 1439 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ |
1399 | 1440 | ||
@@ -1430,7 +1471,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1430 | if (err_mask) { | 1471 | if (err_mask) { |
1431 | if (err_mask & AC_ERR_NODEV_HINT) { | 1472 | if (err_mask & AC_ERR_NODEV_HINT) { |
1432 | DPRINTK("ata%u.%d: NODEV after polling detection\n", | 1473 | DPRINTK("ata%u.%d: NODEV after polling detection\n", |
1433 | ap->id, dev->devno); | 1474 | ap->print_id, dev->devno); |
1434 | return -ENOENT; | 1475 | return -ENOENT; |
1435 | } | 1476 | } |
1436 | 1477 | ||
@@ -1558,15 +1599,13 @@ int ata_dev_configure(struct ata_device *dev) | |||
1558 | int rc; | 1599 | int rc; |
1559 | 1600 | ||
1560 | if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { | 1601 | if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { |
1561 | ata_dev_printk(dev, KERN_INFO, | 1602 | ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", |
1562 | "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", | 1603 | __FUNCTION__); |
1563 | __FUNCTION__, ap->id, dev->devno); | ||
1564 | return 0; | 1604 | return 0; |
1565 | } | 1605 | } |
1566 | 1606 | ||
1567 | if (ata_msg_probe(ap)) | 1607 | if (ata_msg_probe(ap)) |
1568 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", | 1608 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); |
1569 | __FUNCTION__, ap->id, dev->devno); | ||
1570 | 1609 | ||
1571 | /* set _SDD */ | 1610 | /* set _SDD */ |
1572 | rc = ata_acpi_push_id(ap, dev->devno); | 1611 | rc = ata_acpi_push_id(ap, dev->devno); |
@@ -1610,8 +1649,9 @@ int ata_dev_configure(struct ata_device *dev) | |||
1610 | if (dev->class == ATA_DEV_ATA) { | 1649 | if (dev->class == ATA_DEV_ATA) { |
1611 | if (ata_id_is_cfa(id)) { | 1650 | if (ata_id_is_cfa(id)) { |
1612 | if (id[162] & 1) /* CPRM may make this media unusable */ | 1651 | if (id[162] & 1) /* CPRM may make this media unusable */ |
1613 | ata_dev_printk(dev, KERN_WARNING, "ata%u: device %u supports DRM functions and may not be fully accessable.\n", | 1652 | ata_dev_printk(dev, KERN_WARNING, |
1614 | ap->id, dev->devno); | 1653 | "supports DRM functions and may " |
1654 | "not be fully accessable.\n"); | ||
1615 | snprintf(revbuf, 7, "CFA"); | 1655 | snprintf(revbuf, 7, "CFA"); |
1616 | } | 1656 | } |
1617 | else | 1657 | else |
@@ -1679,7 +1719,7 @@ int ata_dev_configure(struct ata_device *dev) | |||
1679 | "%s: %s, %s, max %s\n", | 1719 | "%s: %s, %s, max %s\n", |
1680 | revbuf, modelbuf, fwrevbuf, | 1720 | revbuf, modelbuf, fwrevbuf, |
1681 | ata_mode_string(xfer_mask)); | 1721 | ata_mode_string(xfer_mask)); |
1682 | ata_dev_printk(dev, KERN_INFO, | 1722 | ata_dev_printk(dev, KERN_INFO, |
1683 | "%Lu sectors, multi %u, CHS %u/%u/%u\n", | 1723 | "%Lu sectors, multi %u, CHS %u/%u/%u\n", |
1684 | (unsigned long long)dev->n_sectors, | 1724 | (unsigned long long)dev->n_sectors, |
1685 | dev->multi_count, dev->cylinders, | 1725 | dev->multi_count, dev->cylinders, |
@@ -1778,7 +1818,7 @@ int ata_bus_probe(struct ata_port *ap) | |||
1778 | { | 1818 | { |
1779 | unsigned int classes[ATA_MAX_DEVICES]; | 1819 | unsigned int classes[ATA_MAX_DEVICES]; |
1780 | int tries[ATA_MAX_DEVICES]; | 1820 | int tries[ATA_MAX_DEVICES]; |
1781 | int i, rc, down_xfermask; | 1821 | int i, rc; |
1782 | struct ata_device *dev; | 1822 | struct ata_device *dev; |
1783 | 1823 | ||
1784 | ata_port_probe(ap); | 1824 | ata_port_probe(ap); |
@@ -1787,8 +1827,6 @@ int ata_bus_probe(struct ata_port *ap) | |||
1787 | tries[i] = ATA_PROBE_MAX_TRIES; | 1827 | tries[i] = ATA_PROBE_MAX_TRIES; |
1788 | 1828 | ||
1789 | retry: | 1829 | retry: |
1790 | down_xfermask = 0; | ||
1791 | |||
1792 | /* reset and determine device classes */ | 1830 | /* reset and determine device classes */ |
1793 | ap->ops->phy_reset(ap); | 1831 | ap->ops->phy_reset(ap); |
1794 | 1832 | ||
@@ -1836,10 +1874,8 @@ int ata_bus_probe(struct ata_port *ap) | |||
1836 | 1874 | ||
1837 | /* configure transfer mode */ | 1875 | /* configure transfer mode */ |
1838 | rc = ata_set_mode(ap, &dev); | 1876 | rc = ata_set_mode(ap, &dev); |
1839 | if (rc) { | 1877 | if (rc) |
1840 | down_xfermask = 1; | ||
1841 | goto fail; | 1878 | goto fail; |
1842 | } | ||
1843 | 1879 | ||
1844 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 1880 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
1845 | if (ata_dev_enabled(&ap->device[i])) | 1881 | if (ata_dev_enabled(&ap->device[i])) |
@@ -1851,25 +1887,29 @@ int ata_bus_probe(struct ata_port *ap) | |||
1851 | return -ENODEV; | 1887 | return -ENODEV; |
1852 | 1888 | ||
1853 | fail: | 1889 | fail: |
1890 | tries[dev->devno]--; | ||
1891 | |||
1854 | switch (rc) { | 1892 | switch (rc) { |
1855 | case -EINVAL: | 1893 | case -EINVAL: |
1856 | case -ENODEV: | 1894 | /* eeek, something went very wrong, give up */ |
1857 | tries[dev->devno] = 0; | 1895 | tries[dev->devno] = 0; |
1858 | break; | 1896 | break; |
1897 | |||
1898 | case -ENODEV: | ||
1899 | /* give it just one more chance */ | ||
1900 | tries[dev->devno] = min(tries[dev->devno], 1); | ||
1859 | case -EIO: | 1901 | case -EIO: |
1860 | sata_down_spd_limit(ap); | 1902 | if (tries[dev->devno] == 1) { |
1861 | /* fall through */ | 1903 | /* This is the last chance, better to slow |
1862 | default: | 1904 | * down than lose it. |
1863 | tries[dev->devno]--; | 1905 | */ |
1864 | if (down_xfermask && | 1906 | sata_down_spd_limit(ap); |
1865 | ata_down_xfermask_limit(dev, tries[dev->devno] == 1)) | 1907 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); |
1866 | tries[dev->devno] = 0; | 1908 | } |
1867 | } | 1909 | } |
1868 | 1910 | ||
1869 | if (!tries[dev->devno]) { | 1911 | if (!tries[dev->devno]) |
1870 | ata_down_xfermask_limit(dev, 1); | ||
1871 | ata_dev_disable(dev); | 1912 | ata_dev_disable(dev); |
1872 | } | ||
1873 | 1913 | ||
1874 | goto retry; | 1914 | goto retry; |
1875 | } | 1915 | } |
@@ -2300,7 +2340,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
2300 | /** | 2340 | /** |
2301 | * ata_down_xfermask_limit - adjust dev xfer masks downward | 2341 | * ata_down_xfermask_limit - adjust dev xfer masks downward |
2302 | * @dev: Device to adjust xfer masks | 2342 | * @dev: Device to adjust xfer masks |
2303 | * @force_pio0: Force PIO0 | 2343 | * @sel: ATA_DNXFER_* selector |
2304 | * | 2344 | * |
2305 | * Adjust xfer masks of @dev downward. Note that this function | 2345 | * Adjust xfer masks of @dev downward. Note that this function |
2306 | * does not apply the change. Invoking ata_set_mode() afterwards | 2346 | * does not apply the change. Invoking ata_set_mode() afterwards |
@@ -2312,37 +2352,78 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
2312 | * RETURNS: | 2352 | * RETURNS: |
2313 | * 0 on success, negative errno on failure | 2353 | * 0 on success, negative errno on failure |
2314 | */ | 2354 | */ |
2315 | int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0) | 2355 | int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel) |
2316 | { | 2356 | { |
2317 | unsigned long xfer_mask; | 2357 | char buf[32]; |
2318 | int highbit; | 2358 | unsigned int orig_mask, xfer_mask; |
2359 | unsigned int pio_mask, mwdma_mask, udma_mask; | ||
2360 | int quiet, highbit; | ||
2319 | 2361 | ||
2320 | xfer_mask = ata_pack_xfermask(dev->pio_mask, dev->mwdma_mask, | 2362 | quiet = !!(sel & ATA_DNXFER_QUIET); |
2321 | dev->udma_mask); | 2363 | sel &= ~ATA_DNXFER_QUIET; |
2322 | 2364 | ||
2323 | if (!xfer_mask) | 2365 | xfer_mask = orig_mask = ata_pack_xfermask(dev->pio_mask, |
2324 | goto fail; | 2366 | dev->mwdma_mask, |
2325 | /* don't gear down to MWDMA from UDMA, go directly to PIO */ | 2367 | dev->udma_mask); |
2326 | if (xfer_mask & ATA_MASK_UDMA) | 2368 | ata_unpack_xfermask(xfer_mask, &pio_mask, &mwdma_mask, &udma_mask); |
2327 | xfer_mask &= ~ATA_MASK_MWDMA; | ||
2328 | 2369 | ||
2329 | highbit = fls(xfer_mask) - 1; | 2370 | switch (sel) { |
2330 | xfer_mask &= ~(1 << highbit); | 2371 | case ATA_DNXFER_PIO: |
2331 | if (force_pio0) | 2372 | highbit = fls(pio_mask) - 1; |
2332 | xfer_mask &= 1 << ATA_SHIFT_PIO; | 2373 | pio_mask &= ~(1 << highbit); |
2333 | if (!xfer_mask) | 2374 | break; |
2334 | goto fail; | 2375 | |
2376 | case ATA_DNXFER_DMA: | ||
2377 | if (udma_mask) { | ||
2378 | highbit = fls(udma_mask) - 1; | ||
2379 | udma_mask &= ~(1 << highbit); | ||
2380 | if (!udma_mask) | ||
2381 | return -ENOENT; | ||
2382 | } else if (mwdma_mask) { | ||
2383 | highbit = fls(mwdma_mask) - 1; | ||
2384 | mwdma_mask &= ~(1 << highbit); | ||
2385 | if (!mwdma_mask) | ||
2386 | return -ENOENT; | ||
2387 | } | ||
2388 | break; | ||
2389 | |||
2390 | case ATA_DNXFER_40C: | ||
2391 | udma_mask &= ATA_UDMA_MASK_40C; | ||
2392 | break; | ||
2393 | |||
2394 | case ATA_DNXFER_FORCE_PIO0: | ||
2395 | pio_mask &= 1; | ||
2396 | case ATA_DNXFER_FORCE_PIO: | ||
2397 | mwdma_mask = 0; | ||
2398 | udma_mask = 0; | ||
2399 | break; | ||
2400 | |||
2401 | default: | ||
2402 | BUG(); | ||
2403 | } | ||
2404 | |||
2405 | xfer_mask &= ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask); | ||
2406 | |||
2407 | if (!(xfer_mask & ATA_MASK_PIO) || xfer_mask == orig_mask) | ||
2408 | return -ENOENT; | ||
2409 | |||
2410 | if (!quiet) { | ||
2411 | if (xfer_mask & (ATA_MASK_MWDMA | ATA_MASK_UDMA)) | ||
2412 | snprintf(buf, sizeof(buf), "%s:%s", | ||
2413 | ata_mode_string(xfer_mask), | ||
2414 | ata_mode_string(xfer_mask & ATA_MASK_PIO)); | ||
2415 | else | ||
2416 | snprintf(buf, sizeof(buf), "%s", | ||
2417 | ata_mode_string(xfer_mask)); | ||
2418 | |||
2419 | ata_dev_printk(dev, KERN_WARNING, | ||
2420 | "limiting speed to %s\n", buf); | ||
2421 | } | ||
2335 | 2422 | ||
2336 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, | 2423 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, |
2337 | &dev->udma_mask); | 2424 | &dev->udma_mask); |
2338 | 2425 | ||
2339 | ata_dev_printk(dev, KERN_WARNING, "limiting speed to %s\n", | ||
2340 | ata_mode_string(xfer_mask)); | ||
2341 | |||
2342 | return 0; | 2426 | return 0; |
2343 | |||
2344 | fail: | ||
2345 | return -EINVAL; | ||
2346 | } | 2427 | } |
2347 | 2428 | ||
2348 | static int ata_dev_set_mode(struct ata_device *dev) | 2429 | static int ata_dev_set_mode(struct ata_device *dev) |
@@ -2609,7 +2690,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2609 | { | 2690 | { |
2610 | struct ata_ioports *ioaddr = &ap->ioaddr; | 2691 | struct ata_ioports *ioaddr = &ap->ioaddr; |
2611 | 2692 | ||
2612 | DPRINTK("ata%u: bus reset via SRST\n", ap->id); | 2693 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); |
2613 | 2694 | ||
2614 | /* software reset. causes dev0 to be selected */ | 2695 | /* software reset. causes dev0 to be selected */ |
2615 | iowrite8(ap->ctl, ioaddr->ctl_addr); | 2696 | iowrite8(ap->ctl, ioaddr->ctl_addr); |
@@ -2669,7 +2750,7 @@ void ata_bus_reset(struct ata_port *ap) | |||
2669 | u8 err; | 2750 | u8 err; |
2670 | unsigned int dev0, dev1 = 0, devmask = 0; | 2751 | unsigned int dev0, dev1 = 0, devmask = 0; |
2671 | 2752 | ||
2672 | DPRINTK("ENTER, host %u, port %u\n", ap->id, ap->port_no); | 2753 | DPRINTK("ENTER, host %u, port %u\n", ap->print_id, ap->port_no); |
2673 | 2754 | ||
2674 | /* determine if device 0/1 are present */ | 2755 | /* determine if device 0/1 are present */ |
2675 | if (ap->flags & ATA_FLAG_SATA_RESET) | 2756 | if (ap->flags & ATA_FLAG_SATA_RESET) |
@@ -3256,7 +3337,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3256 | { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA }, | 3337 | { "WPI CDD-820", NULL, ATA_HORKAGE_NODMA }, |
3257 | { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA }, | 3338 | { "SAMSUNG CD-ROM SC-148C", NULL, ATA_HORKAGE_NODMA }, |
3258 | { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA }, | 3339 | { "SAMSUNG CD-ROM SC", NULL, ATA_HORKAGE_NODMA }, |
3259 | { "SanDisk SDP3B-64", NULL, ATA_HORKAGE_NODMA }, | ||
3260 | { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, | 3340 | { "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,ATA_HORKAGE_NODMA }, |
3261 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, | 3341 | { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, |
3262 | { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, | 3342 | { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, |
@@ -3739,7 +3819,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
3739 | struct scatterlist *lsg = &sg[qc->n_elem - 1]; | 3819 | struct scatterlist *lsg = &sg[qc->n_elem - 1]; |
3740 | int n_elem, pre_n_elem, dir, trim_sg = 0; | 3820 | int n_elem, pre_n_elem, dir, trim_sg = 0; |
3741 | 3821 | ||
3742 | VPRINTK("ENTER, ata%u\n", ap->id); | 3822 | VPRINTK("ENTER, ata%u\n", ap->print_id); |
3743 | WARN_ON(!(qc->flags & ATA_QCFLAG_SG)); | 3823 | WARN_ON(!(qc->flags & ATA_QCFLAG_SG)); |
3744 | 3824 | ||
3745 | /* we must lengthen transfers to end on a 32-bit boundary */ | 3825 | /* we must lengthen transfers to end on a 32-bit boundary */ |
@@ -4140,7 +4220,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
4140 | if (do_write != i_write) | 4220 | if (do_write != i_write) |
4141 | goto err_out; | 4221 | goto err_out; |
4142 | 4222 | ||
4143 | VPRINTK("ata%u: xfering %d bytes\n", ap->id, bytes); | 4223 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); |
4144 | 4224 | ||
4145 | __atapi_pio_bytes(qc, bytes); | 4225 | __atapi_pio_bytes(qc, bytes); |
4146 | 4226 | ||
@@ -4257,7 +4337,7 @@ int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | |||
4257 | 4337 | ||
4258 | fsm_start: | 4338 | fsm_start: |
4259 | DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n", | 4339 | DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n", |
4260 | ap->id, qc->tf.protocol, ap->hsm_task_state, status); | 4340 | ap->print_id, qc->tf.protocol, ap->hsm_task_state, status); |
4261 | 4341 | ||
4262 | switch (ap->hsm_task_state) { | 4342 | switch (ap->hsm_task_state) { |
4263 | case HSM_ST_FIRST: | 4343 | case HSM_ST_FIRST: |
@@ -4290,8 +4370,8 @@ fsm_start: | |||
4290 | * let the EH abort the command or reset the device. | 4370 | * let the EH abort the command or reset the device. |
4291 | */ | 4371 | */ |
4292 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | 4372 | if (unlikely(status & (ATA_ERR | ATA_DF))) { |
4293 | printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n", | 4373 | ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device " |
4294 | ap->id, status); | 4374 | "error, dev_stat 0x%X\n", status); |
4295 | qc->err_mask |= AC_ERR_HSM; | 4375 | qc->err_mask |= AC_ERR_HSM; |
4296 | ap->hsm_task_state = HSM_ST_ERR; | 4376 | ap->hsm_task_state = HSM_ST_ERR; |
4297 | goto fsm_start; | 4377 | goto fsm_start; |
@@ -4348,8 +4428,9 @@ fsm_start: | |||
4348 | * let the EH abort the command or reset the device. | 4428 | * let the EH abort the command or reset the device. |
4349 | */ | 4429 | */ |
4350 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | 4430 | if (unlikely(status & (ATA_ERR | ATA_DF))) { |
4351 | printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n", | 4431 | ata_port_printk(ap, KERN_WARNING, "DRQ=1 with " |
4352 | ap->id, status); | 4432 | "device error, dev_stat 0x%X\n", |
4433 | status); | ||
4353 | qc->err_mask |= AC_ERR_HSM; | 4434 | qc->err_mask |= AC_ERR_HSM; |
4354 | ap->hsm_task_state = HSM_ST_ERR; | 4435 | ap->hsm_task_state = HSM_ST_ERR; |
4355 | goto fsm_start; | 4436 | goto fsm_start; |
@@ -4435,7 +4516,7 @@ fsm_start: | |||
4435 | 4516 | ||
4436 | /* no more data to transfer */ | 4517 | /* no more data to transfer */ |
4437 | DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", | 4518 | DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", |
4438 | ap->id, qc->dev->devno, status); | 4519 | ap->print_id, qc->dev->devno, status); |
4439 | 4520 | ||
4440 | WARN_ON(qc->err_mask); | 4521 | WARN_ON(qc->err_mask); |
4441 | 4522 | ||
@@ -4977,7 +5058,7 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
4977 | u8 status, host_stat = 0; | 5058 | u8 status, host_stat = 0; |
4978 | 5059 | ||
4979 | VPRINTK("ata%u: protocol %d task_state %d\n", | 5060 | VPRINTK("ata%u: protocol %d task_state %d\n", |
4980 | ap->id, qc->tf.protocol, ap->hsm_task_state); | 5061 | ap->print_id, qc->tf.protocol, ap->hsm_task_state); |
4981 | 5062 | ||
4982 | /* Check whether we are expecting interrupt in this state */ | 5063 | /* Check whether we are expecting interrupt in this state */ |
4983 | switch (ap->hsm_task_state) { | 5064 | switch (ap->hsm_task_state) { |
@@ -4998,7 +5079,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
4998 | qc->tf.protocol == ATA_PROT_ATAPI_DMA) { | 5079 | qc->tf.protocol == ATA_PROT_ATAPI_DMA) { |
4999 | /* check status of DMA engine */ | 5080 | /* check status of DMA engine */ |
5000 | host_stat = ap->ops->bmdma_status(ap); | 5081 | host_stat = ap->ops->bmdma_status(ap); |
5001 | VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat); | 5082 | VPRINTK("ata%u: host_stat 0x%X\n", |
5083 | ap->print_id, host_stat); | ||
5002 | 5084 | ||
5003 | /* if it's not our irq... */ | 5085 | /* if it's not our irq... */ |
5004 | if (!(host_stat & ATA_DMA_INTR)) | 5086 | if (!(host_stat & ATA_DMA_INTR)) |
@@ -5457,7 +5539,7 @@ void ata_port_init(struct ata_port *ap, struct ata_host *host, | |||
5457 | 5539 | ||
5458 | ap->lock = &host->lock; | 5540 | ap->lock = &host->lock; |
5459 | ap->flags = ATA_FLAG_DISABLED; | 5541 | ap->flags = ATA_FLAG_DISABLED; |
5460 | ap->id = ata_unique_id++; | 5542 | ap->print_id = ata_print_id++; |
5461 | ap->ctl = ATA_DEVCTL_OBS; | 5543 | ap->ctl = ATA_DEVCTL_OBS; |
5462 | ap->host = host; | 5544 | ap->host = host; |
5463 | ap->dev = ent->dev; | 5545 | ap->dev = ent->dev; |
@@ -5528,7 +5610,7 @@ static void ata_port_init_shost(struct ata_port *ap, struct Scsi_Host *shost) | |||
5528 | { | 5610 | { |
5529 | ap->scsi_host = shost; | 5611 | ap->scsi_host = shost; |
5530 | 5612 | ||
5531 | shost->unique_id = ap->id; | 5613 | shost->unique_id = ap->print_id; |
5532 | shost->max_id = 16; | 5614 | shost->max_id = 16; |
5533 | shost->max_lun = 1; | 5615 | shost->max_lun = 1; |
5534 | shost->max_channel = 1; | 5616 | shost->max_channel = 1; |
@@ -5792,9 +5874,9 @@ int ata_device_add(const struct ata_probe_ent *ent) | |||
5792 | /* wait for EH to finish */ | 5874 | /* wait for EH to finish */ |
5793 | ata_port_wait_eh(ap); | 5875 | ata_port_wait_eh(ap); |
5794 | } else { | 5876 | } else { |
5795 | DPRINTK("ata%u: bus probe begin\n", ap->id); | 5877 | DPRINTK("ata%u: bus probe begin\n", ap->print_id); |
5796 | rc = ata_bus_probe(ap); | 5878 | rc = ata_bus_probe(ap); |
5797 | DPRINTK("ata%u: bus probe end\n", ap->id); | 5879 | DPRINTK("ata%u: bus probe end\n", ap->print_id); |
5798 | 5880 | ||
5799 | if (rc) { | 5881 | if (rc) { |
5800 | /* FIXME: do something useful here? | 5882 | /* FIXME: do something useful here? |
@@ -5905,11 +5987,7 @@ ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port) | |||
5905 | { | 5987 | { |
5906 | struct ata_probe_ent *probe_ent; | 5988 | struct ata_probe_ent *probe_ent; |
5907 | 5989 | ||
5908 | /* XXX - the following if can go away once all LLDs are managed */ | 5990 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
5909 | if (!list_empty(&dev->devres_head)) | ||
5910 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); | ||
5911 | else | ||
5912 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | ||
5913 | if (!probe_ent) { | 5991 | if (!probe_ent) { |
5914 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", | 5992 | printk(KERN_ERR DRV_NAME "(%s): out of memory\n", |
5915 | kobject_name(&(dev->kobj))); | 5993 | kobject_name(&(dev->kobj))); |
@@ -6015,11 +6093,10 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) | |||
6015 | void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) | 6093 | void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg) |
6016 | { | 6094 | { |
6017 | pci_save_state(pdev); | 6095 | pci_save_state(pdev); |
6096 | pci_disable_device(pdev); | ||
6018 | 6097 | ||
6019 | if (mesg.event == PM_EVENT_SUSPEND) { | 6098 | if (mesg.event == PM_EVENT_SUSPEND) |
6020 | pci_disable_device(pdev); | ||
6021 | pci_set_power_state(pdev, PCI_D3hot); | 6099 | pci_set_power_state(pdev, PCI_D3hot); |
6022 | } | ||
6023 | } | 6100 | } |
6024 | 6101 | ||
6025 | int ata_pci_device_do_resume(struct pci_dev *pdev) | 6102 | int ata_pci_device_do_resume(struct pci_dev *pdev) |
@@ -6241,6 +6318,7 @@ EXPORT_SYMBOL_GPL(ata_bmdma_drive_eh); | |||
6241 | EXPORT_SYMBOL_GPL(ata_bmdma_error_handler); | 6318 | EXPORT_SYMBOL_GPL(ata_bmdma_error_handler); |
6242 | EXPORT_SYMBOL_GPL(ata_bmdma_post_internal_cmd); | 6319 | EXPORT_SYMBOL_GPL(ata_bmdma_post_internal_cmd); |
6243 | EXPORT_SYMBOL_GPL(ata_port_probe); | 6320 | EXPORT_SYMBOL_GPL(ata_port_probe); |
6321 | EXPORT_SYMBOL_GPL(ata_dev_disable); | ||
6244 | EXPORT_SYMBOL_GPL(sata_set_spd); | 6322 | EXPORT_SYMBOL_GPL(sata_set_spd); |
6245 | EXPORT_SYMBOL_GPL(sata_phy_debounce); | 6323 | EXPORT_SYMBOL_GPL(sata_phy_debounce); |
6246 | EXPORT_SYMBOL_GPL(sata_phy_resume); | 6324 | EXPORT_SYMBOL_GPL(sata_phy_resume); |
@@ -6275,6 +6353,7 @@ EXPORT_SYMBOL_GPL(ata_host_suspend); | |||
6275 | EXPORT_SYMBOL_GPL(ata_host_resume); | 6353 | EXPORT_SYMBOL_GPL(ata_host_resume); |
6276 | EXPORT_SYMBOL_GPL(ata_id_string); | 6354 | EXPORT_SYMBOL_GPL(ata_id_string); |
6277 | EXPORT_SYMBOL_GPL(ata_id_c_string); | 6355 | EXPORT_SYMBOL_GPL(ata_id_c_string); |
6356 | EXPORT_SYMBOL_GPL(ata_id_to_dma_mode); | ||
6278 | EXPORT_SYMBOL_GPL(ata_device_blacklisted); | 6357 | EXPORT_SYMBOL_GPL(ata_device_blacklisted); |
6279 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 6358 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
6280 | 6359 | ||
@@ -6311,3 +6390,4 @@ EXPORT_SYMBOL_GPL(ata_irq_on); | |||
6311 | EXPORT_SYMBOL_GPL(ata_dummy_irq_on); | 6390 | EXPORT_SYMBOL_GPL(ata_dummy_irq_on); |
6312 | EXPORT_SYMBOL_GPL(ata_irq_ack); | 6391 | EXPORT_SYMBOL_GPL(ata_irq_ack); |
6313 | EXPORT_SYMBOL_GPL(ata_dummy_irq_ack); | 6392 | EXPORT_SYMBOL_GPL(ata_dummy_irq_ack); |
6393 | EXPORT_SYMBOL_GPL(ata_dev_try_classify); | ||
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 52c85af7fe99..cad0d6db6df5 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -44,6 +44,12 @@ | |||
44 | 44 | ||
45 | #include "libata.h" | 45 | #include "libata.h" |
46 | 46 | ||
47 | enum { | ||
48 | ATA_EH_SPDN_NCQ_OFF = (1 << 0), | ||
49 | ATA_EH_SPDN_SPEED_DOWN = (1 << 1), | ||
50 | ATA_EH_SPDN_FALLBACK_TO_PIO = (1 << 2), | ||
51 | }; | ||
52 | |||
47 | static void __ata_port_freeze(struct ata_port *ap); | 53 | static void __ata_port_freeze(struct ata_port *ap); |
48 | static void ata_eh_finish(struct ata_port *ap); | 54 | static void ata_eh_finish(struct ata_port *ap); |
49 | static void ata_eh_handle_port_suspend(struct ata_port *ap); | 55 | static void ata_eh_handle_port_suspend(struct ata_port *ap); |
@@ -65,12 +71,9 @@ static void ata_ering_record(struct ata_ering *ering, int is_io, | |||
65 | ent->timestamp = get_jiffies_64(); | 71 | ent->timestamp = get_jiffies_64(); |
66 | } | 72 | } |
67 | 73 | ||
68 | static struct ata_ering_entry * ata_ering_top(struct ata_ering *ering) | 74 | static void ata_ering_clear(struct ata_ering *ering) |
69 | { | 75 | { |
70 | struct ata_ering_entry *ent = &ering->ring[ering->cursor]; | 76 | memset(ering, 0, sizeof(*ering)); |
71 | if (!ent->err_mask) | ||
72 | return NULL; | ||
73 | return ent; | ||
74 | } | 77 | } |
75 | 78 | ||
76 | static int ata_ering_map(struct ata_ering *ering, | 79 | static int ata_ering_map(struct ata_ering *ering, |
@@ -585,7 +588,7 @@ static void __ata_port_freeze(struct ata_port *ap) | |||
585 | 588 | ||
586 | ap->pflags |= ATA_PFLAG_FROZEN; | 589 | ap->pflags |= ATA_PFLAG_FROZEN; |
587 | 590 | ||
588 | DPRINTK("ata%u port frozen\n", ap->id); | 591 | DPRINTK("ata%u port frozen\n", ap->print_id); |
589 | } | 592 | } |
590 | 593 | ||
591 | /** | 594 | /** |
@@ -658,7 +661,7 @@ void ata_eh_thaw_port(struct ata_port *ap) | |||
658 | 661 | ||
659 | spin_unlock_irqrestore(ap->lock, flags); | 662 | spin_unlock_irqrestore(ap->lock, flags); |
660 | 663 | ||
661 | DPRINTK("ata%u port thawed\n", ap->id); | 664 | DPRINTK("ata%u port thawed\n", ap->print_id); |
662 | } | 665 | } |
663 | 666 | ||
664 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | 667 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) |
@@ -1159,87 +1162,99 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, | |||
1159 | return action; | 1162 | return action; |
1160 | } | 1163 | } |
1161 | 1164 | ||
1162 | static int ata_eh_categorize_ering_entry(struct ata_ering_entry *ent) | 1165 | static int ata_eh_categorize_error(int is_io, unsigned int err_mask) |
1163 | { | 1166 | { |
1164 | if (ent->err_mask & (AC_ERR_ATA_BUS | AC_ERR_TIMEOUT)) | 1167 | if (err_mask & AC_ERR_ATA_BUS) |
1165 | return 1; | 1168 | return 1; |
1166 | 1169 | ||
1167 | if (ent->is_io) { | 1170 | if (err_mask & AC_ERR_TIMEOUT) |
1168 | if (ent->err_mask & AC_ERR_HSM) | 1171 | return 2; |
1169 | return 1; | 1172 | |
1170 | if ((ent->err_mask & | 1173 | if (is_io) { |
1171 | (AC_ERR_DEV|AC_ERR_MEDIA|AC_ERR_INVALID)) == AC_ERR_DEV) | 1174 | if (err_mask & AC_ERR_HSM) |
1172 | return 2; | 1175 | return 2; |
1176 | if ((err_mask & | ||
1177 | (AC_ERR_DEV|AC_ERR_MEDIA|AC_ERR_INVALID)) == AC_ERR_DEV) | ||
1178 | return 3; | ||
1173 | } | 1179 | } |
1174 | 1180 | ||
1175 | return 0; | 1181 | return 0; |
1176 | } | 1182 | } |
1177 | 1183 | ||
1178 | struct speed_down_needed_arg { | 1184 | struct speed_down_verdict_arg { |
1179 | u64 since; | 1185 | u64 since; |
1180 | int nr_errors[3]; | 1186 | int nr_errors[4]; |
1181 | }; | 1187 | }; |
1182 | 1188 | ||
1183 | static int speed_down_needed_cb(struct ata_ering_entry *ent, void *void_arg) | 1189 | static int speed_down_verdict_cb(struct ata_ering_entry *ent, void *void_arg) |
1184 | { | 1190 | { |
1185 | struct speed_down_needed_arg *arg = void_arg; | 1191 | struct speed_down_verdict_arg *arg = void_arg; |
1192 | int cat = ata_eh_categorize_error(ent->is_io, ent->err_mask); | ||
1186 | 1193 | ||
1187 | if (ent->timestamp < arg->since) | 1194 | if (ent->timestamp < arg->since) |
1188 | return -1; | 1195 | return -1; |
1189 | 1196 | ||
1190 | arg->nr_errors[ata_eh_categorize_ering_entry(ent)]++; | 1197 | arg->nr_errors[cat]++; |
1191 | return 0; | 1198 | return 0; |
1192 | } | 1199 | } |
1193 | 1200 | ||
1194 | /** | 1201 | /** |
1195 | * ata_eh_speed_down_needed - Determine wheter speed down is necessary | 1202 | * ata_eh_speed_down_verdict - Determine speed down verdict |
1196 | * @dev: Device of interest | 1203 | * @dev: Device of interest |
1197 | * | 1204 | * |
1198 | * This function examines error ring of @dev and determines | 1205 | * This function examines error ring of @dev and determines |
1199 | * whether speed down is necessary. Speed down is necessary if | 1206 | * whether NCQ needs to be turned off, transfer speed should be |
1200 | * there have been more than 3 of Cat-1 errors or 10 of Cat-2 | 1207 | * stepped down, or falling back to PIO is necessary. |
1201 | * errors during last 15 minutes. | ||
1202 | * | 1208 | * |
1203 | * Cat-1 errors are ATA_BUS, TIMEOUT for any command and HSM | 1209 | * Cat-1 is ATA_BUS error for any command. |
1204 | * violation for known supported commands. | ||
1205 | * | 1210 | * |
1206 | * Cat-2 errors are unclassified DEV error for known supported | 1211 | * Cat-2 is TIMEOUT for any command or HSM violation for known |
1212 | * supported commands. | ||
1213 | * | ||
1214 | * Cat-3 is is unclassified DEV error for known supported | ||
1207 | * command. | 1215 | * command. |
1208 | * | 1216 | * |
1217 | * NCQ needs to be turned off if there have been more than 3 | ||
1218 | * Cat-2 + Cat-3 errors during last 10 minutes. | ||
1219 | * | ||
1220 | * Speed down is necessary if there have been more than 3 Cat-1 + | ||
1221 | * Cat-2 errors or 10 Cat-3 errors during last 10 minutes. | ||
1222 | * | ||
1223 | * Falling back to PIO mode is necessary if there have been more | ||
1224 | * than 10 Cat-1 + Cat-2 + Cat-3 errors during last 5 minutes. | ||
1225 | * | ||
1209 | * LOCKING: | 1226 | * LOCKING: |
1210 | * Inherited from caller. | 1227 | * Inherited from caller. |
1211 | * | 1228 | * |
1212 | * RETURNS: | 1229 | * RETURNS: |
1213 | * 1 if speed down is necessary, 0 otherwise | 1230 | * OR of ATA_EH_SPDN_* flags. |
1214 | */ | 1231 | */ |
1215 | static int ata_eh_speed_down_needed(struct ata_device *dev) | 1232 | static unsigned int ata_eh_speed_down_verdict(struct ata_device *dev) |
1216 | { | 1233 | { |
1217 | const u64 interval = 15LLU * 60 * HZ; | 1234 | const u64 j5mins = 5LLU * 60 * HZ, j10mins = 10LLU * 60 * HZ; |
1218 | static const int err_limits[3] = { -1, 3, 10 }; | 1235 | u64 j64 = get_jiffies_64(); |
1219 | struct speed_down_needed_arg arg; | 1236 | struct speed_down_verdict_arg arg; |
1220 | struct ata_ering_entry *ent; | 1237 | unsigned int verdict = 0; |
1221 | int err_cat; | ||
1222 | u64 j64; | ||
1223 | 1238 | ||
1224 | ent = ata_ering_top(&dev->ering); | 1239 | /* scan past 10 mins of error history */ |
1225 | if (!ent) | 1240 | memset(&arg, 0, sizeof(arg)); |
1226 | return 0; | 1241 | arg.since = j64 - min(j64, j10mins); |
1242 | ata_ering_map(&dev->ering, speed_down_verdict_cb, &arg); | ||
1227 | 1243 | ||
1228 | err_cat = ata_eh_categorize_ering_entry(ent); | 1244 | if (arg.nr_errors[2] + arg.nr_errors[3] > 3) |
1229 | if (err_cat == 0) | 1245 | verdict |= ATA_EH_SPDN_NCQ_OFF; |
1230 | return 0; | 1246 | if (arg.nr_errors[1] + arg.nr_errors[2] > 3 || arg.nr_errors[3] > 10) |
1247 | verdict |= ATA_EH_SPDN_SPEED_DOWN; | ||
1231 | 1248 | ||
1249 | /* scan past 3 mins of error history */ | ||
1232 | memset(&arg, 0, sizeof(arg)); | 1250 | memset(&arg, 0, sizeof(arg)); |
1251 | arg.since = j64 - min(j64, j5mins); | ||
1252 | ata_ering_map(&dev->ering, speed_down_verdict_cb, &arg); | ||
1233 | 1253 | ||
1234 | j64 = get_jiffies_64(); | 1254 | if (arg.nr_errors[1] + arg.nr_errors[2] + arg.nr_errors[3] > 10) |
1235 | if (j64 >= interval) | 1255 | verdict |= ATA_EH_SPDN_FALLBACK_TO_PIO; |
1236 | arg.since = j64 - interval; | ||
1237 | else | ||
1238 | arg.since = 0; | ||
1239 | |||
1240 | ata_ering_map(&dev->ering, speed_down_needed_cb, &arg); | ||
1241 | 1256 | ||
1242 | return arg.nr_errors[err_cat] > err_limits[err_cat]; | 1257 | return verdict; |
1243 | } | 1258 | } |
1244 | 1259 | ||
1245 | /** | 1260 | /** |
@@ -1257,31 +1272,80 @@ static int ata_eh_speed_down_needed(struct ata_device *dev) | |||
1257 | * Kernel thread context (may sleep). | 1272 | * Kernel thread context (may sleep). |
1258 | * | 1273 | * |
1259 | * RETURNS: | 1274 | * RETURNS: |
1260 | * 0 on success, -errno otherwise | 1275 | * Determined recovery action. |
1261 | */ | 1276 | */ |
1262 | static int ata_eh_speed_down(struct ata_device *dev, int is_io, | 1277 | static unsigned int ata_eh_speed_down(struct ata_device *dev, int is_io, |
1263 | unsigned int err_mask) | 1278 | unsigned int err_mask) |
1264 | { | 1279 | { |
1265 | if (!err_mask) | 1280 | unsigned int verdict; |
1281 | unsigned int action = 0; | ||
1282 | |||
1283 | /* don't bother if Cat-0 error */ | ||
1284 | if (ata_eh_categorize_error(is_io, err_mask) == 0) | ||
1266 | return 0; | 1285 | return 0; |
1267 | 1286 | ||
1268 | /* record error and determine whether speed down is necessary */ | 1287 | /* record error and determine whether speed down is necessary */ |
1269 | ata_ering_record(&dev->ering, is_io, err_mask); | 1288 | ata_ering_record(&dev->ering, is_io, err_mask); |
1289 | verdict = ata_eh_speed_down_verdict(dev); | ||
1270 | 1290 | ||
1271 | if (!ata_eh_speed_down_needed(dev)) | 1291 | /* turn off NCQ? */ |
1272 | return 0; | 1292 | if ((verdict & ATA_EH_SPDN_NCQ_OFF) && |
1293 | (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ | | ||
1294 | ATA_DFLAG_NCQ_OFF)) == ATA_DFLAG_NCQ) { | ||
1295 | dev->flags |= ATA_DFLAG_NCQ_OFF; | ||
1296 | ata_dev_printk(dev, KERN_WARNING, | ||
1297 | "NCQ disabled due to excessive errors\n"); | ||
1298 | goto done; | ||
1299 | } | ||
1273 | 1300 | ||
1274 | /* speed down SATA link speed if possible */ | 1301 | /* speed down? */ |
1275 | if (sata_down_spd_limit(dev->ap) == 0) | 1302 | if (verdict & ATA_EH_SPDN_SPEED_DOWN) { |
1276 | return ATA_EH_HARDRESET; | 1303 | /* speed down SATA link speed if possible */ |
1304 | if (sata_down_spd_limit(dev->ap) == 0) { | ||
1305 | action |= ATA_EH_HARDRESET; | ||
1306 | goto done; | ||
1307 | } | ||
1277 | 1308 | ||
1278 | /* lower transfer mode */ | 1309 | /* lower transfer mode */ |
1279 | if (ata_down_xfermask_limit(dev, 0) == 0) | 1310 | if (dev->spdn_cnt < 2) { |
1280 | return ATA_EH_SOFTRESET; | 1311 | static const int dma_dnxfer_sel[] = |
1312 | { ATA_DNXFER_DMA, ATA_DNXFER_40C }; | ||
1313 | static const int pio_dnxfer_sel[] = | ||
1314 | { ATA_DNXFER_PIO, ATA_DNXFER_FORCE_PIO0 }; | ||
1315 | int sel; | ||
1316 | |||
1317 | if (dev->xfer_shift != ATA_SHIFT_PIO) | ||
1318 | sel = dma_dnxfer_sel[dev->spdn_cnt]; | ||
1319 | else | ||
1320 | sel = pio_dnxfer_sel[dev->spdn_cnt]; | ||
1321 | |||
1322 | dev->spdn_cnt++; | ||
1323 | |||
1324 | if (ata_down_xfermask_limit(dev, sel) == 0) { | ||
1325 | action |= ATA_EH_SOFTRESET; | ||
1326 | goto done; | ||
1327 | } | ||
1328 | } | ||
1329 | } | ||
1330 | |||
1331 | /* Fall back to PIO? Slowing down to PIO is meaningless for | ||
1332 | * SATA. Consider it only for PATA. | ||
1333 | */ | ||
1334 | if ((verdict & ATA_EH_SPDN_FALLBACK_TO_PIO) && (dev->spdn_cnt >= 2) && | ||
1335 | (dev->ap->cbl != ATA_CBL_SATA) && | ||
1336 | (dev->xfer_shift != ATA_SHIFT_PIO)) { | ||
1337 | if (ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO) == 0) { | ||
1338 | dev->spdn_cnt = 0; | ||
1339 | action |= ATA_EH_SOFTRESET; | ||
1340 | goto done; | ||
1341 | } | ||
1342 | } | ||
1281 | 1343 | ||
1282 | ata_dev_printk(dev, KERN_ERR, | ||
1283 | "speed down requested but no transfer mode left\n"); | ||
1284 | return 0; | 1344 | return 0; |
1345 | done: | ||
1346 | /* device has been slowed down, blow error history */ | ||
1347 | ata_ering_clear(&dev->ering); | ||
1348 | return action; | ||
1285 | } | 1349 | } |
1286 | 1350 | ||
1287 | /** | 1351 | /** |
@@ -1964,7 +2028,7 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
1964 | { | 2028 | { |
1965 | struct ata_eh_context *ehc = &ap->eh_context; | 2029 | struct ata_eh_context *ehc = &ap->eh_context; |
1966 | struct ata_device *dev; | 2030 | struct ata_device *dev; |
1967 | int down_xfermask, i, rc; | 2031 | int i, rc; |
1968 | 2032 | ||
1969 | DPRINTK("ENTER\n"); | 2033 | DPRINTK("ENTER\n"); |
1970 | 2034 | ||
@@ -1993,7 +2057,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
1993 | } | 2057 | } |
1994 | 2058 | ||
1995 | retry: | 2059 | retry: |
1996 | down_xfermask = 0; | ||
1997 | rc = 0; | 2060 | rc = 0; |
1998 | 2061 | ||
1999 | /* if UNLOADING, finish immediately */ | 2062 | /* if UNLOADING, finish immediately */ |
@@ -2038,10 +2101,8 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2038 | /* configure transfer mode if necessary */ | 2101 | /* configure transfer mode if necessary */ |
2039 | if (ehc->i.flags & ATA_EHI_SETMODE) { | 2102 | if (ehc->i.flags & ATA_EHI_SETMODE) { |
2040 | rc = ata_set_mode(ap, &dev); | 2103 | rc = ata_set_mode(ap, &dev); |
2041 | if (rc) { | 2104 | if (rc) |
2042 | down_xfermask = 1; | ||
2043 | goto dev_fail; | 2105 | goto dev_fail; |
2044 | } | ||
2045 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 2106 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
2046 | } | 2107 | } |
2047 | 2108 | ||
@@ -2053,20 +2114,27 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
2053 | goto out; | 2114 | goto out; |
2054 | 2115 | ||
2055 | dev_fail: | 2116 | dev_fail: |
2117 | ehc->tries[dev->devno]--; | ||
2118 | |||
2056 | switch (rc) { | 2119 | switch (rc) { |
2057 | case -ENODEV: | ||
2058 | /* device missing, schedule probing */ | ||
2059 | ehc->i.probe_mask |= (1 << dev->devno); | ||
2060 | case -EINVAL: | 2120 | case -EINVAL: |
2121 | /* eeek, something went very wrong, give up */ | ||
2061 | ehc->tries[dev->devno] = 0; | 2122 | ehc->tries[dev->devno] = 0; |
2062 | break; | 2123 | break; |
2124 | |||
2125 | case -ENODEV: | ||
2126 | /* device missing or wrong IDENTIFY data, schedule probing */ | ||
2127 | ehc->i.probe_mask |= (1 << dev->devno); | ||
2128 | /* give it just one more chance */ | ||
2129 | ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); | ||
2063 | case -EIO: | 2130 | case -EIO: |
2064 | sata_down_spd_limit(ap); | 2131 | if (ehc->tries[dev->devno] == 1) { |
2065 | default: | 2132 | /* This is the last chance, better to slow |
2066 | ehc->tries[dev->devno]--; | 2133 | * down than lose it. |
2067 | if (down_xfermask && | 2134 | */ |
2068 | ata_down_xfermask_limit(dev, ehc->tries[dev->devno] == 1)) | 2135 | sata_down_spd_limit(ap); |
2069 | ehc->tries[dev->devno] = 0; | 2136 | ata_down_xfermask_limit(dev, ATA_DNXFER_PIO); |
2137 | } | ||
2070 | } | 2138 | } |
2071 | 2139 | ||
2072 | if (ata_dev_enabled(dev) && !ehc->tries[dev->devno]) { | 2140 | if (ata_dev_enabled(dev) && !ehc->tries[dev->devno]) { |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 0009818a4306..00a9a6c8f83c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -333,6 +333,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
333 | scsi_cmd[8] = args[3]; | 333 | scsi_cmd[8] = args[3]; |
334 | scsi_cmd[10] = args[4]; | 334 | scsi_cmd[10] = args[4]; |
335 | scsi_cmd[12] = args[5]; | 335 | scsi_cmd[12] = args[5]; |
336 | scsi_cmd[13] = args[6] & 0x0f; | ||
336 | scsi_cmd[14] = args[0]; | 337 | scsi_cmd[14] = args[0]; |
337 | 338 | ||
338 | /* Good values for timeout and retries? Values below | 339 | /* Good values for timeout and retries? Values below |
@@ -781,7 +782,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) | |||
781 | */ | 782 | */ |
782 | if (qc->err_mask || | 783 | if (qc->err_mask || |
783 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 784 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
784 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 785 | ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, |
785 | &sb[1], &sb[2], &sb[3], verbose); | 786 | &sb[1], &sb[2], &sb[3], verbose); |
786 | sb[1] &= 0x0f; | 787 | sb[1] &= 0x0f; |
787 | } | 788 | } |
@@ -854,7 +855,7 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) | |||
854 | */ | 855 | */ |
855 | if (qc->err_mask || | 856 | if (qc->err_mask || |
856 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 857 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
857 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 858 | ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, |
858 | &sb[1], &sb[2], &sb[3], verbose); | 859 | &sb[1], &sb[2], &sb[3], verbose); |
859 | sb[1] &= 0x0f; | 860 | sb[1] &= 0x0f; |
860 | } | 861 | } |
@@ -986,29 +987,32 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
986 | struct ata_port *ap = ata_shost_to_port(sdev->host); | 987 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
987 | struct ata_device *dev; | 988 | struct ata_device *dev; |
988 | unsigned long flags; | 989 | unsigned long flags; |
989 | int max_depth; | ||
990 | 990 | ||
991 | if (queue_depth < 1) | 991 | if (queue_depth < 1 || queue_depth == sdev->queue_depth) |
992 | return sdev->queue_depth; | 992 | return sdev->queue_depth; |
993 | 993 | ||
994 | dev = ata_scsi_find_dev(ap, sdev); | 994 | dev = ata_scsi_find_dev(ap, sdev); |
995 | if (!dev || !ata_dev_enabled(dev)) | 995 | if (!dev || !ata_dev_enabled(dev)) |
996 | return sdev->queue_depth; | 996 | return sdev->queue_depth; |
997 | 997 | ||
998 | max_depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id)); | 998 | /* NCQ enabled? */ |
999 | max_depth = min(ATA_MAX_QUEUE - 1, max_depth); | ||
1000 | if (queue_depth > max_depth) | ||
1001 | queue_depth = max_depth; | ||
1002 | |||
1003 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth); | ||
1004 | |||
1005 | spin_lock_irqsave(ap->lock, flags); | 999 | spin_lock_irqsave(ap->lock, flags); |
1006 | if (queue_depth > 1) | 1000 | dev->flags &= ~ATA_DFLAG_NCQ_OFF; |
1007 | dev->flags &= ~ATA_DFLAG_NCQ_OFF; | 1001 | if (queue_depth == 1 || !ata_ncq_enabled(dev)) { |
1008 | else | ||
1009 | dev->flags |= ATA_DFLAG_NCQ_OFF; | 1002 | dev->flags |= ATA_DFLAG_NCQ_OFF; |
1003 | queue_depth = 1; | ||
1004 | } | ||
1010 | spin_unlock_irqrestore(ap->lock, flags); | 1005 | spin_unlock_irqrestore(ap->lock, flags); |
1011 | 1006 | ||
1007 | /* limit and apply queue depth */ | ||
1008 | queue_depth = min(queue_depth, sdev->host->can_queue); | ||
1009 | queue_depth = min(queue_depth, ata_id_queue_depth(dev->id)); | ||
1010 | queue_depth = min(queue_depth, ATA_MAX_QUEUE - 1); | ||
1011 | |||
1012 | if (sdev->queue_depth == queue_depth) | ||
1013 | return -EINVAL; | ||
1014 | |||
1015 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth); | ||
1012 | return queue_depth; | 1016 | return queue_depth; |
1013 | } | 1017 | } |
1014 | 1018 | ||
@@ -1469,7 +1473,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1469 | } | 1473 | } |
1470 | 1474 | ||
1471 | if (need_sense && !ap->ops->error_handler) | 1475 | if (need_sense && !ap->ops->error_handler) |
1472 | ata_dump_status(ap->id, &qc->result_tf); | 1476 | ata_dump_status(ap->print_id, &qc->result_tf); |
1473 | 1477 | ||
1474 | qc->scsidone(cmd); | 1478 | qc->scsidone(cmd); |
1475 | 1479 | ||
@@ -1495,11 +1499,9 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1495 | static int ata_scmd_need_defer(struct ata_device *dev, int is_io) | 1499 | static int ata_scmd_need_defer(struct ata_device *dev, int is_io) |
1496 | { | 1500 | { |
1497 | struct ata_port *ap = dev->ap; | 1501 | struct ata_port *ap = dev->ap; |
1502 | int is_ncq = is_io && ata_ncq_enabled(dev); | ||
1498 | 1503 | ||
1499 | if (!(dev->flags & ATA_DFLAG_NCQ)) | 1504 | if (is_ncq) { |
1500 | return 0; | ||
1501 | |||
1502 | if (is_io) { | ||
1503 | if (!ata_tag_valid(ap->active_tag)) | 1505 | if (!ata_tag_valid(ap->active_tag)) |
1504 | return 0; | 1506 | return 0; |
1505 | } else { | 1507 | } else { |
@@ -2774,7 +2776,7 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
2774 | u8 *scsicmd = cmd->cmnd; | 2776 | u8 *scsicmd = cmd->cmnd; |
2775 | 2777 | ||
2776 | DPRINTK("CDB (%u:%d,%d,%d) %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 2778 | DPRINTK("CDB (%u:%d,%d,%d) %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
2777 | ap->id, | 2779 | ap->print_id, |
2778 | scsidev->channel, scsidev->id, scsidev->lun, | 2780 | scsidev->channel, scsidev->id, scsidev->lun, |
2779 | scsicmd[0], scsicmd[1], scsicmd[2], scsicmd[3], | 2781 | scsicmd[0], scsicmd[1], scsicmd[2], scsicmd[3], |
2780 | scsicmd[4], scsicmd[5], scsicmd[6], scsicmd[7], | 2782 | scsicmd[4], scsicmd[5], scsicmd[6], scsicmd[7], |
@@ -3234,7 +3236,7 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host, | |||
3234 | 3236 | ||
3235 | ata_port_init(ap, host, ent, 0); | 3237 | ata_port_init(ap, host, ent, 0); |
3236 | ap->lock = shost->host_lock; | 3238 | ap->lock = shost->host_lock; |
3237 | kfree(ent); | 3239 | devm_kfree(host->dev, ent); |
3238 | return ap; | 3240 | return ap; |
3239 | } | 3241 | } |
3240 | EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | 3242 | EXPORT_SYMBOL_GPL(ata_sas_port_alloc); |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 16bc3e35bdd4..2ffcca063d80 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -175,7 +175,7 @@ void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) | |||
175 | */ | 175 | */ |
176 | void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) | 176 | void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) |
177 | { | 177 | { |
178 | DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); | 178 | DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command); |
179 | 179 | ||
180 | iowrite8(tf->command, ap->ioaddr.command_addr); | 180 | iowrite8(tf->command, ap->ioaddr.command_addr); |
181 | ata_pause(ap); | 181 | ata_pause(ap); |
@@ -521,7 +521,7 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc) | |||
521 | static int ata_resources_present(struct pci_dev *pdev, int port) | 521 | static int ata_resources_present(struct pci_dev *pdev, int port) |
522 | { | 522 | { |
523 | int i; | 523 | int i; |
524 | 524 | ||
525 | /* Check the PCI resources for this channel are enabled */ | 525 | /* Check the PCI resources for this channel are enabled */ |
526 | port = port * 2; | 526 | port = port * 2; |
527 | for (i = 0; i < 2; i ++) { | 527 | for (i = 0; i < 2; i ++) { |
@@ -531,7 +531,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port) | |||
531 | } | 531 | } |
532 | return 1; | 532 | return 1; |
533 | } | 533 | } |
534 | 534 | ||
535 | /** | 535 | /** |
536 | * ata_pci_init_native_mode - Initialize native-mode driver | 536 | * ata_pci_init_native_mode - Initialize native-mode driver |
537 | * @pdev: pci device to be initialized | 537 | * @pdev: pci device to be initialized |
@@ -576,7 +576,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int | |||
576 | 576 | ||
577 | probe_ent->irq = pdev->irq; | 577 | probe_ent->irq = pdev->irq; |
578 | probe_ent->irq_flags = IRQF_SHARED; | 578 | probe_ent->irq_flags = IRQF_SHARED; |
579 | 579 | ||
580 | /* Discard disabled ports. Some controllers show their | 580 | /* Discard disabled ports. Some controllers show their |
581 | unused channels this way */ | 581 | unused channels this way */ |
582 | if (ata_resources_present(pdev, 0) == 0) | 582 | if (ata_resources_present(pdev, 0) == 0) |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 0ad7781d72a3..c42671493e8c 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -41,6 +41,15 @@ struct ata_scsi_args { | |||
41 | enum { | 41 | enum { |
42 | /* flags for ata_dev_read_id() */ | 42 | /* flags for ata_dev_read_id() */ |
43 | ATA_READID_POSTRESET = (1 << 0), /* reading ID after reset */ | 43 | ATA_READID_POSTRESET = (1 << 0), /* reading ID after reset */ |
44 | |||
45 | /* selector for ata_down_xfermask_limit() */ | ||
46 | ATA_DNXFER_PIO = 0, /* speed down PIO */ | ||
47 | ATA_DNXFER_DMA = 1, /* speed down DMA */ | ||
48 | ATA_DNXFER_40C = 2, /* apply 40c cable limit */ | ||
49 | ATA_DNXFER_FORCE_PIO = 3, /* force PIO */ | ||
50 | ATA_DNXFER_FORCE_PIO0 = 4, /* force PIO0 */ | ||
51 | |||
52 | ATA_DNXFER_QUIET = (1 << 31), | ||
44 | }; | 53 | }; |
45 | 54 | ||
46 | extern struct workqueue_struct *ata_aux_wq; | 55 | extern struct workqueue_struct *ata_aux_wq; |
@@ -69,7 +78,7 @@ extern int ata_dev_revalidate(struct ata_device *dev, unsigned int flags); | |||
69 | extern int ata_dev_configure(struct ata_device *dev); | 78 | extern int ata_dev_configure(struct ata_device *dev); |
70 | extern int sata_down_spd_limit(struct ata_port *ap); | 79 | extern int sata_down_spd_limit(struct ata_port *ap); |
71 | extern int sata_set_spd_needed(struct ata_port *ap); | 80 | extern int sata_set_spd_needed(struct ata_port *ap); |
72 | extern int ata_down_xfermask_limit(struct ata_device *dev, int force_pio0); | 81 | extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); |
73 | extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); | 82 | extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); |
74 | extern void ata_sg_clean(struct ata_queued_cmd *qc); | 83 | extern void ata_sg_clean(struct ata_queued_cmd *qc); |
75 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 84 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
@@ -150,7 +159,5 @@ extern void ata_qc_schedule_eh(struct ata_queued_cmd *qc); | |||
150 | /* libata-sff.c */ | 159 | /* libata-sff.c */ |
151 | extern u8 ata_irq_on(struct ata_port *ap); | 160 | extern u8 ata_irq_on(struct ata_port *ap); |
152 | 161 | ||
153 | /* pata_sis.c */ | ||
154 | extern struct ata_port_info sis_info133; | ||
155 | 162 | ||
156 | #endif /* __LIBATA_H__ */ | 163 | #endif /* __LIBATA_H__ */ |
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index ab44d18850f6..a90ed00c07e0 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/dmi.h> | 34 | #include <linux/dmi.h> |
35 | 35 | ||
36 | #define DRV_NAME "pata_ali" | 36 | #define DRV_NAME "pata_ali" |
37 | #define DRV_VERSION "0.7.2" | 37 | #define DRV_VERSION "0.7.3" |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * Cable special cases | 40 | * Cable special cases |
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 619e44b04032..3c760d0f4717 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/libata.h> | 25 | #include <linux/libata.h> |
26 | 26 | ||
27 | #define DRV_NAME "pata_amd" | 27 | #define DRV_NAME "pata_amd" |
28 | #define DRV_VERSION "0.2.7" | 28 | #define DRV_VERSION "0.2.8" |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * timing_setup - shared timing computation and load | 31 | * timing_setup - shared timing computation and load |
@@ -128,7 +128,7 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse | |||
128 | 128 | ||
129 | static int amd_pre_reset(struct ata_port *ap) | 129 | static int amd_pre_reset(struct ata_port *ap) |
130 | { | 130 | { |
131 | static const u32 bitmask[2] = {0x03, 0xC0}; | 131 | static const u32 bitmask[2] = {0x03, 0x0C}; |
132 | static const struct pci_bits amd_enable_bits[] = { | 132 | static const struct pci_bits amd_enable_bits[] = { |
133 | { 0x40, 1, 0x02, 0x02 }, | 133 | { 0x40, 1, 0x02, 0x02 }, |
134 | { 0x40, 1, 0x01, 0x01 } | 134 | { 0x40, 1, 0x01, 0x01 } |
@@ -247,7 +247,7 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev) | |||
247 | */ | 247 | */ |
248 | 248 | ||
249 | static int nv_pre_reset(struct ata_port *ap) { | 249 | static int nv_pre_reset(struct ata_port *ap) { |
250 | static const u8 bitmask[2] = {0x03, 0xC0}; | 250 | static const u8 bitmask[2] = {0x03, 0x0C}; |
251 | static const struct pci_bits nv_enable_bits[] = { | 251 | static const struct pci_bits nv_enable_bits[] = { |
252 | { 0x50, 1, 0x02, 0x02 }, | 252 | { 0x50, 1, 0x02, 0x02 }, |
253 | { 0x50, 1, 0x01, 0x01 } | 253 | { 0x50, 1, 0x01, 0x01 } |
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c index 1ce8fcfd7826..c1334c6c4156 100644 --- a/drivers/ata/pata_cs5520.c +++ b/drivers/ata/pata_cs5520.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/libata.h> | 41 | #include <linux/libata.h> |
42 | 42 | ||
43 | #define DRV_NAME "pata_cs5520" | 43 | #define DRV_NAME "pata_cs5520" |
44 | #define DRV_VERSION "0.6.3" | 44 | #define DRV_VERSION "0.6.4" |
45 | 45 | ||
46 | struct pio_clocks | 46 | struct pio_clocks |
47 | { | 47 | { |
@@ -325,6 +325,30 @@ static int cs5520_reinit_one(struct pci_dev *pdev) | |||
325 | pci_write_config_byte(pdev, 0x60, pcicfg | 0x40); | 325 | pci_write_config_byte(pdev, 0x60, pcicfg | 0x40); |
326 | return ata_pci_device_resume(pdev); | 326 | return ata_pci_device_resume(pdev); |
327 | } | 327 | } |
328 | |||
329 | /** | ||
330 | * cs5520_pci_device_suspend - device suspend | ||
331 | * @pdev: PCI device | ||
332 | * | ||
333 | * We have to cut and waste bits from the standard method because | ||
334 | * the 5520 is a bit odd and not just a pure ATA device. As a result | ||
335 | * we must not disable it. The needed code is short and this avoids | ||
336 | * chip specific mess in the core code. | ||
337 | */ | ||
338 | |||
339 | static int cs5520_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) | ||
340 | { | ||
341 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
342 | int rc = 0; | ||
343 | |||
344 | rc = ata_host_suspend(host, mesg); | ||
345 | if (rc) | ||
346 | return rc; | ||
347 | |||
348 | pci_save_state(pdev); | ||
349 | return 0; | ||
350 | } | ||
351 | |||
328 | /* For now keep DMA off. We can set it for all but A rev CS5510 once the | 352 | /* For now keep DMA off. We can set it for all but A rev CS5510 once the |
329 | core ATA code can handle it */ | 353 | core ATA code can handle it */ |
330 | 354 | ||
@@ -340,7 +364,7 @@ static struct pci_driver cs5520_pci_driver = { | |||
340 | .id_table = pata_cs5520, | 364 | .id_table = pata_cs5520, |
341 | .probe = cs5520_init_one, | 365 | .probe = cs5520_init_one, |
342 | .remove = cs5520_remove_one, | 366 | .remove = cs5520_remove_one, |
343 | .suspend = ata_pci_device_suspend, | 367 | .suspend = cs5520_pci_device_suspend, |
344 | .resume = cs5520_reinit_one, | 368 | .resume = cs5520_reinit_one, |
345 | }; | 369 | }; |
346 | 370 | ||
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 3d7b7d87ec6f..78c7cdfff69d 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/dmi.h> | 35 | #include <linux/dmi.h> |
36 | 36 | ||
37 | #define DRV_NAME "pata_cs5530" | 37 | #define DRV_NAME "pata_cs5530" |
38 | #define DRV_VERSION "0.7.1" | 38 | #define DRV_VERSION "0.7.2" |
39 | 39 | ||
40 | static void __iomem *cs5530_port_base(struct ata_port *ap) | 40 | static void __iomem *cs5530_port_base(struct ata_port *ap) |
41 | { | 41 | { |
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index 27d724b5eea2..e7d33c628a61 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/libata.h> | 27 | #include <linux/libata.h> |
28 | 28 | ||
29 | #define DRV_NAME "pata_hpt366" | 29 | #define DRV_NAME "pata_hpt366" |
30 | #define DRV_VERSION "0.5.3" | 30 | #define DRV_VERSION "0.6.0" |
31 | 31 | ||
32 | struct hpt_clock { | 32 | struct hpt_clock { |
33 | u8 xfer_speed; | 33 | u8 xfer_speed; |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 4ffc392052c0..f331eeeafa0f 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/libata.h> | 25 | #include <linux/libata.h> |
26 | 26 | ||
27 | #define DRV_NAME "pata_hpt37x" | 27 | #define DRV_NAME "pata_hpt37x" |
28 | #define DRV_VERSION "0.5.2" | 28 | #define DRV_VERSION "0.6.0" |
29 | 29 | ||
30 | struct hpt_clock { | 30 | struct hpt_clock { |
31 | u8 xfer_speed; | 31 | u8 xfer_speed; |
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c index 1bf5ec18b2e3..d5f2e85e28f3 100644 --- a/drivers/ata/pata_isapnp.c +++ b/drivers/ata/pata_isapnp.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/libata.h> | 17 | #include <linux/libata.h> |
18 | 18 | ||
19 | #define DRV_NAME "pata_isapnp" | 19 | #define DRV_NAME "pata_isapnp" |
20 | #define DRV_VERSION "0.1.5" | 20 | #define DRV_VERSION "0.2.0" |
21 | 21 | ||
22 | static struct scsi_host_template isapnp_sht = { | 22 | static struct scsi_host_template isapnp_sht = { |
23 | .module = THIS_MODULE, | 23 | .module = THIS_MODULE, |
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index 73394c75be42..903137a6da5e 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -80,7 +80,7 @@ | |||
80 | 80 | ||
81 | 81 | ||
82 | #define DRV_NAME "pata_it821x" | 82 | #define DRV_NAME "pata_it821x" |
83 | #define DRV_VERSION "0.3.3" | 83 | #define DRV_VERSION "0.3.4" |
84 | 84 | ||
85 | struct it821x_dev | 85 | struct it821x_dev |
86 | { | 86 | { |
@@ -503,10 +503,12 @@ static int it821x_smart_set_mode(struct ata_port *ap, struct ata_device **unused | |||
503 | /* We do need the right mode information for DMA or PIO | 503 | /* We do need the right mode information for DMA or PIO |
504 | and this comes from the current configuration flags */ | 504 | and this comes from the current configuration flags */ |
505 | if (dma_enabled & (1 << (5 + i))) { | 505 | if (dma_enabled & (1 << (5 + i))) { |
506 | ata_dev_printk(dev, KERN_INFO, "configured for DMA\n"); | ||
506 | dev->xfer_mode = XFER_MW_DMA_0; | 507 | dev->xfer_mode = XFER_MW_DMA_0; |
507 | dev->xfer_shift = ATA_SHIFT_MWDMA; | 508 | dev->xfer_shift = ATA_SHIFT_MWDMA; |
508 | dev->flags &= ~ATA_DFLAG_PIO; | 509 | dev->flags &= ~ATA_DFLAG_PIO; |
509 | } else { | 510 | } else { |
511 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
510 | dev->xfer_mode = XFER_PIO_0; | 512 | dev->xfer_mode = XFER_PIO_0; |
511 | dev->xfer_shift = ATA_SHIFT_PIO; | 513 | dev->xfer_shift = ATA_SHIFT_PIO; |
512 | dev->flags |= ATA_DFLAG_PIO; | 514 | dev->flags |= ATA_DFLAG_PIO; |
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 3222ac7b945d..9a0523b5c947 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -23,15 +23,16 @@ | |||
23 | #include <scsi/scsi_host.h> | 23 | #include <scsi/scsi_host.h> |
24 | 24 | ||
25 | #define DRV_NAME "pata_ixp4xx_cf" | 25 | #define DRV_NAME "pata_ixp4xx_cf" |
26 | #define DRV_VERSION "0.1.1ac1" | 26 | #define DRV_VERSION "0.1.2" |
27 | 27 | ||
28 | static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device *adev) | 28 | static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) |
29 | { | 29 | { |
30 | int i; | 30 | int i; |
31 | 31 | ||
32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 32 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
33 | struct ata_device *dev = &ap->device[i]; | 33 | struct ata_device *dev = &ap->device[i]; |
34 | if (ata_dev_enabled(dev)) { | 34 | if (ata_dev_ready(dev)) { |
35 | ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); | ||
35 | dev->pio_mode = XFER_PIO_0; | 36 | dev->pio_mode = XFER_PIO_0; |
36 | dev->xfer_mode = XFER_PIO_0; | 37 | dev->xfer_mode = XFER_PIO_0; |
37 | dev->xfer_shift = ATA_SHIFT_PIO; | 38 | dev->xfer_shift = ATA_SHIFT_PIO; |
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 98c1fee4b305..6ee61c67163a 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -64,7 +64,7 @@ | |||
64 | #include <linux/platform_device.h> | 64 | #include <linux/platform_device.h> |
65 | 65 | ||
66 | #define DRV_NAME "pata_legacy" | 66 | #define DRV_NAME "pata_legacy" |
67 | #define DRV_VERSION "0.5.3" | 67 | #define DRV_VERSION "0.5.4" |
68 | 68 | ||
69 | #define NR_HOST 6 | 69 | #define NR_HOST 6 |
70 | 70 | ||
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index 45215aa05e72..2389107a2006 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/ata.h> | 25 | #include <linux/ata.h> |
26 | 26 | ||
27 | #define DRV_NAME "pata_oldpiix" | 27 | #define DRV_NAME "pata_oldpiix" |
28 | #define DRV_VERSION "0.5.3" | 28 | #define DRV_VERSION "0.5.4" |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * oldpiix_pre_reset - probe begin | 31 | * oldpiix_pre_reset - probe begin |
@@ -209,10 +209,9 @@ static unsigned int oldpiix_qc_issue_prot(struct ata_queued_cmd *qc) | |||
209 | struct ata_device *adev = qc->dev; | 209 | struct ata_device *adev = qc->dev; |
210 | 210 | ||
211 | if (adev != ap->private_data) { | 211 | if (adev != ap->private_data) { |
212 | oldpiix_set_piomode(ap, adev); | ||
212 | if (adev->dma_mode) | 213 | if (adev->dma_mode) |
213 | oldpiix_set_dmamode(ap, adev); | 214 | oldpiix_set_dmamode(ap, adev); |
214 | else if (adev->pio_mode) | ||
215 | oldpiix_set_piomode(ap, adev); | ||
216 | } | 215 | } |
217 | return ata_qc_issue_prot(qc); | 216 | return ata_qc_issue_prot(qc); |
218 | } | 217 | } |
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index da1aa148b37d..1b3cd5369f03 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/libata.h> | 34 | #include <linux/libata.h> |
35 | 35 | ||
36 | #define DRV_NAME "pata_opti" | 36 | #define DRV_NAME "pata_opti" |
37 | #define DRV_VERSION "0.2.7" | 37 | #define DRV_VERSION "0.2.8" |
38 | 38 | ||
39 | enum { | 39 | enum { |
40 | READ_REG = 0, /* index of Read cycle timing register */ | 40 | READ_REG = 0, /* index of Read cycle timing register */ |
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index d80b36e209cc..b76c976e505c 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/libata.h> | 33 | #include <linux/libata.h> |
34 | 34 | ||
35 | #define DRV_NAME "pata_optidma" | 35 | #define DRV_NAME "pata_optidma" |
36 | #define DRV_VERSION "0.2.3" | 36 | #define DRV_VERSION "0.2.4" |
37 | 37 | ||
38 | enum { | 38 | enum { |
39 | READ_REG = 0, /* index of Read cycle timing register */ | 39 | READ_REG = 0, /* index of Read cycle timing register */ |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 8928a6dfac50..103720f873c8 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | 43 | ||
44 | #define DRV_NAME "pata_pcmcia" | 44 | #define DRV_NAME "pata_pcmcia" |
45 | #define DRV_VERSION "0.2.11" | 45 | #define DRV_VERSION "0.3.0" |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Private data structure to glue stuff together | 48 | * Private data structure to glue stuff together |
@@ -319,14 +319,17 @@ static void pcmcia_remove_one(struct pcmcia_device *pdev) | |||
319 | static struct pcmcia_device_id pcmcia_devices[] = { | 319 | static struct pcmcia_device_id pcmcia_devices[] = { |
320 | PCMCIA_DEVICE_FUNC_ID(4), | 320 | PCMCIA_DEVICE_FUNC_ID(4), |
321 | PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */ | 321 | PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */ |
322 | PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */ | ||
323 | PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */ | ||
322 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), | 324 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), |
323 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), | 325 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ |
324 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ | 326 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ |
325 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), | 327 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), |
326 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ | 328 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ |
327 | PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ | 329 | PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ |
328 | PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), | 330 | PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), |
329 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ | 331 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */ |
332 | PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */ | ||
330 | PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), | 333 | PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), |
331 | PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), | 334 | PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), |
332 | PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), | 335 | PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), |
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 61537873d28e..93bcdadb7be3 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/libata.h> | 35 | #include <linux/libata.h> |
36 | 36 | ||
37 | #define DRV_NAME "pata_pdc2027x" | 37 | #define DRV_NAME "pata_pdc2027x" |
38 | #define DRV_VERSION "0.74-ac5" | 38 | #define DRV_VERSION "0.8" |
39 | #undef PDC_DEBUG | 39 | #undef PDC_DEBUG |
40 | 40 | ||
41 | #ifdef PDC_DEBUG | 41 | #ifdef PDC_DEBUG |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index 6dd63413a523..80685388c2bd 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/libata.h> | 21 | #include <linux/libata.h> |
22 | 22 | ||
23 | #define DRV_NAME "pata_pdc202xx_old" | 23 | #define DRV_NAME "pata_pdc202xx_old" |
24 | #define DRV_VERSION "0.2.3" | 24 | #define DRV_VERSION "0.3.0" |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * pdc2024x_pre_reset - probe begin | 27 | * pdc2024x_pre_reset - probe begin |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 479a326114e0..02ea95fcba69 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -42,6 +42,7 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse | |||
42 | dev->pio_mode = dev->xfer_mode = XFER_PIO_0; | 42 | dev->pio_mode = dev->xfer_mode = XFER_PIO_0; |
43 | dev->xfer_shift = ATA_SHIFT_PIO; | 43 | dev->xfer_shift = ATA_SHIFT_PIO; |
44 | dev->flags |= ATA_DFLAG_PIO; | 44 | dev->flags |= ATA_DFLAG_PIO; |
45 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
45 | } | 46 | } |
46 | } | 47 | } |
47 | return 0; | 48 | return 0; |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index 4362141976ad..c2f87da60336 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | 27 | ||
28 | #define DRV_NAME "pata_qdi" | 28 | #define DRV_NAME "pata_qdi" |
29 | #define DRV_VERSION "0.2.4" | 29 | #define DRV_VERSION "0.3.0" |
30 | 30 | ||
31 | #define NR_HOST 4 /* Two 6580s */ | 31 | #define NR_HOST 4 /* Two 6580s */ |
32 | 32 | ||
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 71a2bac09e0d..60fc598f765d 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c | |||
@@ -71,6 +71,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
71 | dev->xfer_mode = XFER_PIO_0; | 71 | dev->xfer_mode = XFER_PIO_0; |
72 | dev->xfer_shift = ATA_SHIFT_PIO; | 72 | dev->xfer_shift = ATA_SHIFT_PIO; |
73 | dev->flags |= ATA_DFLAG_PIO; | 73 | dev->flags |= ATA_DFLAG_PIO; |
74 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
74 | } | 75 | } |
75 | } | 76 | } |
76 | return 0; | 77 | return 0; |
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c new file mode 100644 index 000000000000..45866098fbf9 --- /dev/null +++ b/drivers/ata/pata_scc.c | |||
@@ -0,0 +1,1228 @@ | |||
1 | /* | ||
2 | * Support for IDE interfaces on Celleb platform | ||
3 | * | ||
4 | * (C) Copyright 2006 TOSHIBA CORPORATION | ||
5 | * | ||
6 | * This code is based on drivers/ata/ata_piix.c: | ||
7 | * Copyright 2003-2005 Red Hat Inc | ||
8 | * Copyright 2003-2005 Jeff Garzik | ||
9 | * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer | ||
10 | * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> | ||
11 | * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> | ||
12 | * | ||
13 | * and drivers/ata/ahci.c: | ||
14 | * Copyright 2004-2005 Red Hat, Inc. | ||
15 | * | ||
16 | * and drivers/ata/libata-core.c: | ||
17 | * Copyright 2003-2004 Red Hat, Inc. All rights reserved. | ||
18 | * Copyright 2003-2004 Jeff Garzik | ||
19 | * | ||
20 | * This program is free software; you can redistribute it and/or modify | ||
21 | * it under the terms of the GNU General Public License as published by | ||
22 | * the Free Software Foundation; either version 2 of the License, or | ||
23 | * (at your option) any later version. | ||
24 | * | ||
25 | * This program is distributed in the hope that it will be useful, | ||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | * GNU General Public License for more details. | ||
29 | * | ||
30 | * You should have received a copy of the GNU General Public License along | ||
31 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
32 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/module.h> | ||
37 | #include <linux/pci.h> | ||
38 | #include <linux/init.h> | ||
39 | #include <linux/blkdev.h> | ||
40 | #include <linux/delay.h> | ||
41 | #include <linux/device.h> | ||
42 | #include <scsi/scsi_host.h> | ||
43 | #include <linux/libata.h> | ||
44 | |||
45 | #define DRV_NAME "pata_scc" | ||
46 | #define DRV_VERSION "0.1" | ||
47 | |||
48 | #define PCI_DEVICE_ID_TOSHIBA_SCC_ATA 0x01b4 | ||
49 | |||
50 | /* PCI BARs */ | ||
51 | #define SCC_CTRL_BAR 0 | ||
52 | #define SCC_BMID_BAR 1 | ||
53 | |||
54 | /* offset of CTRL registers */ | ||
55 | #define SCC_CTL_PIOSHT 0x000 | ||
56 | #define SCC_CTL_PIOCT 0x004 | ||
57 | #define SCC_CTL_MDMACT 0x008 | ||
58 | #define SCC_CTL_MCRCST 0x00C | ||
59 | #define SCC_CTL_SDMACT 0x010 | ||
60 | #define SCC_CTL_SCRCST 0x014 | ||
61 | #define SCC_CTL_UDENVT 0x018 | ||
62 | #define SCC_CTL_TDVHSEL 0x020 | ||
63 | #define SCC_CTL_MODEREG 0x024 | ||
64 | #define SCC_CTL_ECMODE 0xF00 | ||
65 | #define SCC_CTL_MAEA0 0xF50 | ||
66 | #define SCC_CTL_MAEC0 0xF54 | ||
67 | #define SCC_CTL_CCKCTRL 0xFF0 | ||
68 | |||
69 | /* offset of BMID registers */ | ||
70 | #define SCC_DMA_CMD 0x000 | ||
71 | #define SCC_DMA_STATUS 0x004 | ||
72 | #define SCC_DMA_TABLE_OFS 0x008 | ||
73 | #define SCC_DMA_INTMASK 0x010 | ||
74 | #define SCC_DMA_INTST 0x014 | ||
75 | #define SCC_DMA_PTERADD 0x018 | ||
76 | #define SCC_REG_CMD_ADDR 0x020 | ||
77 | #define SCC_REG_DATA 0x000 | ||
78 | #define SCC_REG_ERR 0x004 | ||
79 | #define SCC_REG_FEATURE 0x004 | ||
80 | #define SCC_REG_NSECT 0x008 | ||
81 | #define SCC_REG_LBAL 0x00C | ||
82 | #define SCC_REG_LBAM 0x010 | ||
83 | #define SCC_REG_LBAH 0x014 | ||
84 | #define SCC_REG_DEVICE 0x018 | ||
85 | #define SCC_REG_STATUS 0x01C | ||
86 | #define SCC_REG_CMD 0x01C | ||
87 | #define SCC_REG_ALTSTATUS 0x020 | ||
88 | |||
89 | /* register value */ | ||
90 | #define TDVHSEL_MASTER 0x00000001 | ||
91 | #define TDVHSEL_SLAVE 0x00000004 | ||
92 | |||
93 | #define MODE_JCUSFEN 0x00000080 | ||
94 | |||
95 | #define ECMODE_VALUE 0x01 | ||
96 | |||
97 | #define CCKCTRL_ATARESET 0x00040000 | ||
98 | #define CCKCTRL_BUFCNT 0x00020000 | ||
99 | #define CCKCTRL_CRST 0x00010000 | ||
100 | #define CCKCTRL_OCLKEN 0x00000100 | ||
101 | #define CCKCTRL_ATACLKOEN 0x00000002 | ||
102 | #define CCKCTRL_LCLKEN 0x00000001 | ||
103 | |||
104 | #define QCHCD_IOS_SS 0x00000001 | ||
105 | |||
106 | #define QCHSD_STPDIAG 0x00020000 | ||
107 | |||
108 | #define INTMASK_MSK 0xD1000012 | ||
109 | #define INTSTS_SERROR 0x80000000 | ||
110 | #define INTSTS_PRERR 0x40000000 | ||
111 | #define INTSTS_RERR 0x10000000 | ||
112 | #define INTSTS_ICERR 0x01000000 | ||
113 | #define INTSTS_BMSINT 0x00000010 | ||
114 | #define INTSTS_BMHE 0x00000008 | ||
115 | #define INTSTS_IOIRQS 0x00000004 | ||
116 | #define INTSTS_INTRQ 0x00000002 | ||
117 | #define INTSTS_ACTEINT 0x00000001 | ||
118 | |||
119 | |||
120 | /* PIO transfer mode table */ | ||
121 | /* JCHST */ | ||
122 | static const unsigned long JCHSTtbl[2][7] = { | ||
123 | {0x0E, 0x05, 0x02, 0x03, 0x02, 0x00, 0x00}, /* 100MHz */ | ||
124 | {0x13, 0x07, 0x04, 0x04, 0x03, 0x00, 0x00} /* 133MHz */ | ||
125 | }; | ||
126 | |||
127 | /* JCHHT */ | ||
128 | static const unsigned long JCHHTtbl[2][7] = { | ||
129 | {0x0E, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00}, /* 100MHz */ | ||
130 | {0x13, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00} /* 133MHz */ | ||
131 | }; | ||
132 | |||
133 | /* JCHCT */ | ||
134 | static const unsigned long JCHCTtbl[2][7] = { | ||
135 | {0x1D, 0x1D, 0x1C, 0x0B, 0x06, 0x00, 0x00}, /* 100MHz */ | ||
136 | {0x27, 0x26, 0x26, 0x0E, 0x09, 0x00, 0x00} /* 133MHz */ | ||
137 | }; | ||
138 | |||
139 | /* DMA transfer mode table */ | ||
140 | /* JCHDCTM/JCHDCTS */ | ||
141 | static const unsigned long JCHDCTxtbl[2][7] = { | ||
142 | {0x0A, 0x06, 0x04, 0x03, 0x01, 0x00, 0x00}, /* 100MHz */ | ||
143 | {0x0E, 0x09, 0x06, 0x04, 0x02, 0x01, 0x00} /* 133MHz */ | ||
144 | }; | ||
145 | |||
146 | /* JCSTWTM/JCSTWTS */ | ||
147 | static const unsigned long JCSTWTxtbl[2][7] = { | ||
148 | {0x06, 0x04, 0x03, 0x02, 0x02, 0x02, 0x00}, /* 100MHz */ | ||
149 | {0x09, 0x06, 0x04, 0x02, 0x02, 0x02, 0x02} /* 133MHz */ | ||
150 | }; | ||
151 | |||
152 | /* JCTSS */ | ||
153 | static const unsigned long JCTSStbl[2][7] = { | ||
154 | {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00}, /* 100MHz */ | ||
155 | {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05} /* 133MHz */ | ||
156 | }; | ||
157 | |||
158 | /* JCENVT */ | ||
159 | static const unsigned long JCENVTtbl[2][7] = { | ||
160 | {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}, /* 100MHz */ | ||
161 | {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02} /* 133MHz */ | ||
162 | }; | ||
163 | |||
164 | /* JCACTSELS/JCACTSELM */ | ||
165 | static const unsigned long JCACTSELtbl[2][7] = { | ||
166 | {0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00}, /* 100MHz */ | ||
167 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} /* 133MHz */ | ||
168 | }; | ||
169 | |||
170 | static const struct pci_device_id scc_pci_tbl[] = { | ||
171 | {PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SCC_ATA, | ||
172 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | ||
173 | { } /* terminate list */ | ||
174 | }; | ||
175 | |||
176 | /** | ||
177 | * scc_set_piomode - Initialize host controller PATA PIO timings | ||
178 | * @ap: Port whose timings we are configuring | ||
179 | * @adev: um | ||
180 | * | ||
181 | * Set PIO mode for device. | ||
182 | * | ||
183 | * LOCKING: | ||
184 | * None (inherited from caller). | ||
185 | */ | ||
186 | |||
187 | static void scc_set_piomode (struct ata_port *ap, struct ata_device *adev) | ||
188 | { | ||
189 | unsigned int pio = adev->pio_mode - XFER_PIO_0; | ||
190 | void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR]; | ||
191 | void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL; | ||
192 | void __iomem *piosht_port = ctrl_base + SCC_CTL_PIOSHT; | ||
193 | void __iomem *pioct_port = ctrl_base + SCC_CTL_PIOCT; | ||
194 | unsigned long reg; | ||
195 | int offset; | ||
196 | |||
197 | reg = in_be32(cckctrl_port); | ||
198 | if (reg & CCKCTRL_ATACLKOEN) | ||
199 | offset = 1; /* 133MHz */ | ||
200 | else | ||
201 | offset = 0; /* 100MHz */ | ||
202 | |||
203 | reg = JCHSTtbl[offset][pio] << 16 | JCHHTtbl[offset][pio]; | ||
204 | out_be32(piosht_port, reg); | ||
205 | reg = JCHCTtbl[offset][pio]; | ||
206 | out_be32(pioct_port, reg); | ||
207 | } | ||
208 | |||
209 | /** | ||
210 | * scc_set_dmamode - Initialize host controller PATA DMA timings | ||
211 | * @ap: Port whose timings we are configuring | ||
212 | * @adev: um | ||
213 | * @udma: udma mode, 0 - 6 | ||
214 | * | ||
215 | * Set UDMA mode for device. | ||
216 | * | ||
217 | * LOCKING: | ||
218 | * None (inherited from caller). | ||
219 | */ | ||
220 | |||
221 | static void scc_set_dmamode (struct ata_port *ap, struct ata_device *adev) | ||
222 | { | ||
223 | unsigned int udma = adev->dma_mode; | ||
224 | unsigned int is_slave = (adev->devno != 0); | ||
225 | u8 speed = udma; | ||
226 | void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR]; | ||
227 | void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL; | ||
228 | void __iomem *mdmact_port = ctrl_base + SCC_CTL_MDMACT; | ||
229 | void __iomem *mcrcst_port = ctrl_base + SCC_CTL_MCRCST; | ||
230 | void __iomem *sdmact_port = ctrl_base + SCC_CTL_SDMACT; | ||
231 | void __iomem *scrcst_port = ctrl_base + SCC_CTL_SCRCST; | ||
232 | void __iomem *udenvt_port = ctrl_base + SCC_CTL_UDENVT; | ||
233 | void __iomem *tdvhsel_port = ctrl_base + SCC_CTL_TDVHSEL; | ||
234 | int offset, idx; | ||
235 | |||
236 | if (in_be32(cckctrl_port) & CCKCTRL_ATACLKOEN) | ||
237 | offset = 1; /* 133MHz */ | ||
238 | else | ||
239 | offset = 0; /* 100MHz */ | ||
240 | |||
241 | if (speed >= XFER_UDMA_0) | ||
242 | idx = speed - XFER_UDMA_0; | ||
243 | else | ||
244 | return; | ||
245 | |||
246 | if (is_slave) { | ||
247 | out_be32(sdmact_port, JCHDCTxtbl[offset][idx]); | ||
248 | out_be32(scrcst_port, JCSTWTxtbl[offset][idx]); | ||
249 | out_be32(tdvhsel_port, | ||
250 | (in_be32(tdvhsel_port) & ~TDVHSEL_SLAVE) | (JCACTSELtbl[offset][idx] << 2)); | ||
251 | } else { | ||
252 | out_be32(mdmact_port, JCHDCTxtbl[offset][idx]); | ||
253 | out_be32(mcrcst_port, JCSTWTxtbl[offset][idx]); | ||
254 | out_be32(tdvhsel_port, | ||
255 | (in_be32(tdvhsel_port) & ~TDVHSEL_MASTER) | JCACTSELtbl[offset][idx]); | ||
256 | } | ||
257 | out_be32(udenvt_port, | ||
258 | JCTSStbl[offset][idx] << 16 | JCENVTtbl[offset][idx]); | ||
259 | } | ||
260 | |||
261 | /** | ||
262 | * scc_tf_load - send taskfile registers to host controller | ||
263 | * @ap: Port to which output is sent | ||
264 | * @tf: ATA taskfile register set | ||
265 | * | ||
266 | * Note: Original code is ata_tf_load(). | ||
267 | */ | ||
268 | |||
269 | static void scc_tf_load (struct ata_port *ap, const struct ata_taskfile *tf) | ||
270 | { | ||
271 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
272 | unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; | ||
273 | |||
274 | if (tf->ctl != ap->last_ctl) { | ||
275 | out_be32(ioaddr->ctl_addr, tf->ctl); | ||
276 | ap->last_ctl = tf->ctl; | ||
277 | ata_wait_idle(ap); | ||
278 | } | ||
279 | |||
280 | if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { | ||
281 | out_be32(ioaddr->feature_addr, tf->hob_feature); | ||
282 | out_be32(ioaddr->nsect_addr, tf->hob_nsect); | ||
283 | out_be32(ioaddr->lbal_addr, tf->hob_lbal); | ||
284 | out_be32(ioaddr->lbam_addr, tf->hob_lbam); | ||
285 | out_be32(ioaddr->lbah_addr, tf->hob_lbah); | ||
286 | VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", | ||
287 | tf->hob_feature, | ||
288 | tf->hob_nsect, | ||
289 | tf->hob_lbal, | ||
290 | tf->hob_lbam, | ||
291 | tf->hob_lbah); | ||
292 | } | ||
293 | |||
294 | if (is_addr) { | ||
295 | out_be32(ioaddr->feature_addr, tf->feature); | ||
296 | out_be32(ioaddr->nsect_addr, tf->nsect); | ||
297 | out_be32(ioaddr->lbal_addr, tf->lbal); | ||
298 | out_be32(ioaddr->lbam_addr, tf->lbam); | ||
299 | out_be32(ioaddr->lbah_addr, tf->lbah); | ||
300 | VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", | ||
301 | tf->feature, | ||
302 | tf->nsect, | ||
303 | tf->lbal, | ||
304 | tf->lbam, | ||
305 | tf->lbah); | ||
306 | } | ||
307 | |||
308 | if (tf->flags & ATA_TFLAG_DEVICE) { | ||
309 | out_be32(ioaddr->device_addr, tf->device); | ||
310 | VPRINTK("device 0x%X\n", tf->device); | ||
311 | } | ||
312 | |||
313 | ata_wait_idle(ap); | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * scc_check_status - Read device status reg & clear interrupt | ||
318 | * @ap: port where the device is | ||
319 | * | ||
320 | * Note: Original code is ata_check_status(). | ||
321 | */ | ||
322 | |||
323 | static u8 scc_check_status (struct ata_port *ap) | ||
324 | { | ||
325 | return in_be32(ap->ioaddr.status_addr); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * scc_tf_read - input device's ATA taskfile shadow registers | ||
330 | * @ap: Port from which input is read | ||
331 | * @tf: ATA taskfile register set for storing input | ||
332 | * | ||
333 | * Note: Original code is ata_tf_read(). | ||
334 | */ | ||
335 | |||
336 | static void scc_tf_read (struct ata_port *ap, struct ata_taskfile *tf) | ||
337 | { | ||
338 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
339 | |||
340 | tf->command = scc_check_status(ap); | ||
341 | tf->feature = in_be32(ioaddr->error_addr); | ||
342 | tf->nsect = in_be32(ioaddr->nsect_addr); | ||
343 | tf->lbal = in_be32(ioaddr->lbal_addr); | ||
344 | tf->lbam = in_be32(ioaddr->lbam_addr); | ||
345 | tf->lbah = in_be32(ioaddr->lbah_addr); | ||
346 | tf->device = in_be32(ioaddr->device_addr); | ||
347 | |||
348 | if (tf->flags & ATA_TFLAG_LBA48) { | ||
349 | out_be32(ioaddr->ctl_addr, tf->ctl | ATA_HOB); | ||
350 | tf->hob_feature = in_be32(ioaddr->error_addr); | ||
351 | tf->hob_nsect = in_be32(ioaddr->nsect_addr); | ||
352 | tf->hob_lbal = in_be32(ioaddr->lbal_addr); | ||
353 | tf->hob_lbam = in_be32(ioaddr->lbam_addr); | ||
354 | tf->hob_lbah = in_be32(ioaddr->lbah_addr); | ||
355 | } | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * scc_exec_command - issue ATA command to host controller | ||
360 | * @ap: port to which command is being issued | ||
361 | * @tf: ATA taskfile register set | ||
362 | * | ||
363 | * Note: Original code is ata_exec_command(). | ||
364 | */ | ||
365 | |||
366 | static void scc_exec_command (struct ata_port *ap, | ||
367 | const struct ata_taskfile *tf) | ||
368 | { | ||
369 | DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command); | ||
370 | |||
371 | out_be32(ap->ioaddr.command_addr, tf->command); | ||
372 | ata_pause(ap); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * scc_check_altstatus - Read device alternate status reg | ||
377 | * @ap: port where the device is | ||
378 | */ | ||
379 | |||
380 | static u8 scc_check_altstatus (struct ata_port *ap) | ||
381 | { | ||
382 | return in_be32(ap->ioaddr.altstatus_addr); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * scc_std_dev_select - Select device 0/1 on ATA bus | ||
387 | * @ap: ATA channel to manipulate | ||
388 | * @device: ATA device (numbered from zero) to select | ||
389 | * | ||
390 | * Note: Original code is ata_std_dev_select(). | ||
391 | */ | ||
392 | |||
393 | static void scc_std_dev_select (struct ata_port *ap, unsigned int device) | ||
394 | { | ||
395 | u8 tmp; | ||
396 | |||
397 | if (device == 0) | ||
398 | tmp = ATA_DEVICE_OBS; | ||
399 | else | ||
400 | tmp = ATA_DEVICE_OBS | ATA_DEV1; | ||
401 | |||
402 | out_be32(ap->ioaddr.device_addr, tmp); | ||
403 | ata_pause(ap); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * scc_bmdma_setup - Set up PCI IDE BMDMA transaction | ||
408 | * @qc: Info associated with this ATA transaction. | ||
409 | * | ||
410 | * Note: Original code is ata_bmdma_setup(). | ||
411 | */ | ||
412 | |||
413 | static void scc_bmdma_setup (struct ata_queued_cmd *qc) | ||
414 | { | ||
415 | struct ata_port *ap = qc->ap; | ||
416 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); | ||
417 | u8 dmactl; | ||
418 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
419 | |||
420 | /* load PRD table addr */ | ||
421 | out_be32(mmio + SCC_DMA_TABLE_OFS, ap->prd_dma); | ||
422 | |||
423 | /* specify data direction, triple-check start bit is clear */ | ||
424 | dmactl = in_be32(mmio + SCC_DMA_CMD); | ||
425 | dmactl &= ~(ATA_DMA_WR | ATA_DMA_START); | ||
426 | if (!rw) | ||
427 | dmactl |= ATA_DMA_WR; | ||
428 | out_be32(mmio + SCC_DMA_CMD, dmactl); | ||
429 | |||
430 | /* issue r/w command */ | ||
431 | ap->ops->exec_command(ap, &qc->tf); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * scc_bmdma_start - Start a PCI IDE BMDMA transaction | ||
436 | * @qc: Info associated with this ATA transaction. | ||
437 | * | ||
438 | * Note: Original code is ata_bmdma_start(). | ||
439 | */ | ||
440 | |||
441 | static void scc_bmdma_start (struct ata_queued_cmd *qc) | ||
442 | { | ||
443 | struct ata_port *ap = qc->ap; | ||
444 | u8 dmactl; | ||
445 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
446 | |||
447 | /* start host DMA transaction */ | ||
448 | dmactl = in_be32(mmio + SCC_DMA_CMD); | ||
449 | out_be32(mmio + SCC_DMA_CMD, dmactl | ATA_DMA_START); | ||
450 | } | ||
451 | |||
452 | /** | ||
453 | * scc_devchk - PATA device presence detection | ||
454 | * @ap: ATA channel to examine | ||
455 | * @device: Device to examine (starting at zero) | ||
456 | * | ||
457 | * Note: Original code is ata_devchk(). | ||
458 | */ | ||
459 | |||
460 | static unsigned int scc_devchk (struct ata_port *ap, | ||
461 | unsigned int device) | ||
462 | { | ||
463 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
464 | u8 nsect, lbal; | ||
465 | |||
466 | ap->ops->dev_select(ap, device); | ||
467 | |||
468 | out_be32(ioaddr->nsect_addr, 0x55); | ||
469 | out_be32(ioaddr->lbal_addr, 0xaa); | ||
470 | |||
471 | out_be32(ioaddr->nsect_addr, 0xaa); | ||
472 | out_be32(ioaddr->lbal_addr, 0x55); | ||
473 | |||
474 | out_be32(ioaddr->nsect_addr, 0x55); | ||
475 | out_be32(ioaddr->lbal_addr, 0xaa); | ||
476 | |||
477 | nsect = in_be32(ioaddr->nsect_addr); | ||
478 | lbal = in_be32(ioaddr->lbal_addr); | ||
479 | |||
480 | if ((nsect == 0x55) && (lbal == 0xaa)) | ||
481 | return 1; /* we found a device */ | ||
482 | |||
483 | return 0; /* nothing found */ | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * scc_bus_post_reset - PATA device post reset | ||
488 | * | ||
489 | * Note: Original code is ata_bus_post_reset(). | ||
490 | */ | ||
491 | |||
492 | static void scc_bus_post_reset (struct ata_port *ap, unsigned int devmask) | ||
493 | { | ||
494 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
495 | unsigned int dev0 = devmask & (1 << 0); | ||
496 | unsigned int dev1 = devmask & (1 << 1); | ||
497 | unsigned long timeout; | ||
498 | |||
499 | /* if device 0 was found in ata_devchk, wait for its | ||
500 | * BSY bit to clear | ||
501 | */ | ||
502 | if (dev0) | ||
503 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | ||
504 | |||
505 | /* if device 1 was found in ata_devchk, wait for | ||
506 | * register access, then wait for BSY to clear | ||
507 | */ | ||
508 | timeout = jiffies + ATA_TMOUT_BOOT; | ||
509 | while (dev1) { | ||
510 | u8 nsect, lbal; | ||
511 | |||
512 | ap->ops->dev_select(ap, 1); | ||
513 | nsect = in_be32(ioaddr->nsect_addr); | ||
514 | lbal = in_be32(ioaddr->lbal_addr); | ||
515 | if ((nsect == 1) && (lbal == 1)) | ||
516 | break; | ||
517 | if (time_after(jiffies, timeout)) { | ||
518 | dev1 = 0; | ||
519 | break; | ||
520 | } | ||
521 | msleep(50); /* give drive a breather */ | ||
522 | } | ||
523 | if (dev1) | ||
524 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | ||
525 | |||
526 | /* is all this really necessary? */ | ||
527 | ap->ops->dev_select(ap, 0); | ||
528 | if (dev1) | ||
529 | ap->ops->dev_select(ap, 1); | ||
530 | if (dev0) | ||
531 | ap->ops->dev_select(ap, 0); | ||
532 | } | ||
533 | |||
534 | /** | ||
535 | * scc_bus_softreset - PATA device software reset | ||
536 | * | ||
537 | * Note: Original code is ata_bus_softreset(). | ||
538 | */ | ||
539 | |||
540 | static unsigned int scc_bus_softreset (struct ata_port *ap, | ||
541 | unsigned int devmask) | ||
542 | { | ||
543 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
544 | |||
545 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); | ||
546 | |||
547 | /* software reset. causes dev0 to be selected */ | ||
548 | out_be32(ioaddr->ctl_addr, ap->ctl); | ||
549 | udelay(20); | ||
550 | out_be32(ioaddr->ctl_addr, ap->ctl | ATA_SRST); | ||
551 | udelay(20); | ||
552 | out_be32(ioaddr->ctl_addr, ap->ctl); | ||
553 | |||
554 | /* spec mandates ">= 2ms" before checking status. | ||
555 | * We wait 150ms, because that was the magic delay used for | ||
556 | * ATAPI devices in Hale Landis's ATADRVR, for the period of time | ||
557 | * between when the ATA command register is written, and then | ||
558 | * status is checked. Because waiting for "a while" before | ||
559 | * checking status is fine, post SRST, we perform this magic | ||
560 | * delay here as well. | ||
561 | * | ||
562 | * Old drivers/ide uses the 2mS rule and then waits for ready | ||
563 | */ | ||
564 | msleep(150); | ||
565 | |||
566 | /* Before we perform post reset processing we want to see if | ||
567 | * the bus shows 0xFF because the odd clown forgets the D7 | ||
568 | * pulldown resistor. | ||
569 | */ | ||
570 | if (scc_check_status(ap) == 0xFF) | ||
571 | return 0; | ||
572 | |||
573 | scc_bus_post_reset(ap, devmask); | ||
574 | |||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * scc_std_softreset - reset host port via ATA SRST | ||
580 | * @ap: port to reset | ||
581 | * @classes: resulting classes of attached devices | ||
582 | * | ||
583 | * Note: Original code is ata_std_softreset(). | ||
584 | */ | ||
585 | |||
586 | static int scc_std_softreset (struct ata_port *ap, unsigned int *classes) | ||
587 | { | ||
588 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | ||
589 | unsigned int devmask = 0, err_mask; | ||
590 | u8 err; | ||
591 | |||
592 | DPRINTK("ENTER\n"); | ||
593 | |||
594 | if (ata_port_offline(ap)) { | ||
595 | classes[0] = ATA_DEV_NONE; | ||
596 | goto out; | ||
597 | } | ||
598 | |||
599 | /* determine if device 0/1 are present */ | ||
600 | if (scc_devchk(ap, 0)) | ||
601 | devmask |= (1 << 0); | ||
602 | if (slave_possible && scc_devchk(ap, 1)) | ||
603 | devmask |= (1 << 1); | ||
604 | |||
605 | /* select device 0 again */ | ||
606 | ap->ops->dev_select(ap, 0); | ||
607 | |||
608 | /* issue bus reset */ | ||
609 | DPRINTK("about to softreset, devmask=%x\n", devmask); | ||
610 | err_mask = scc_bus_softreset(ap, devmask); | ||
611 | if (err_mask) { | ||
612 | ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n", | ||
613 | err_mask); | ||
614 | return -EIO; | ||
615 | } | ||
616 | |||
617 | /* determine by signature whether we have ATA or ATAPI devices */ | ||
618 | classes[0] = ata_dev_try_classify(ap, 0, &err); | ||
619 | if (slave_possible && err != 0x81) | ||
620 | classes[1] = ata_dev_try_classify(ap, 1, &err); | ||
621 | |||
622 | out: | ||
623 | DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); | ||
624 | return 0; | ||
625 | } | ||
626 | |||
627 | /** | ||
628 | * scc_bmdma_stop - Stop PCI IDE BMDMA transfer | ||
629 | * @qc: Command we are ending DMA for | ||
630 | */ | ||
631 | |||
632 | static void scc_bmdma_stop (struct ata_queued_cmd *qc) | ||
633 | { | ||
634 | struct ata_port *ap = qc->ap; | ||
635 | void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR]; | ||
636 | void __iomem *bmid_base = ap->host->iomap[SCC_BMID_BAR]; | ||
637 | u32 reg; | ||
638 | |||
639 | while (1) { | ||
640 | reg = in_be32(bmid_base + SCC_DMA_INTST); | ||
641 | |||
642 | if (reg & INTSTS_SERROR) { | ||
643 | printk(KERN_WARNING "%s: SERROR\n", DRV_NAME); | ||
644 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_SERROR|INTSTS_BMSINT); | ||
645 | out_be32(bmid_base + SCC_DMA_CMD, | ||
646 | in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START); | ||
647 | continue; | ||
648 | } | ||
649 | |||
650 | if (reg & INTSTS_PRERR) { | ||
651 | u32 maea0, maec0; | ||
652 | maea0 = in_be32(ctrl_base + SCC_CTL_MAEA0); | ||
653 | maec0 = in_be32(ctrl_base + SCC_CTL_MAEC0); | ||
654 | printk(KERN_WARNING "%s: PRERR [addr:%x cmd:%x]\n", DRV_NAME, maea0, maec0); | ||
655 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_PRERR|INTSTS_BMSINT); | ||
656 | out_be32(bmid_base + SCC_DMA_CMD, | ||
657 | in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START); | ||
658 | continue; | ||
659 | } | ||
660 | |||
661 | if (reg & INTSTS_RERR) { | ||
662 | printk(KERN_WARNING "%s: Response Error\n", DRV_NAME); | ||
663 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_RERR|INTSTS_BMSINT); | ||
664 | out_be32(bmid_base + SCC_DMA_CMD, | ||
665 | in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START); | ||
666 | continue; | ||
667 | } | ||
668 | |||
669 | if (reg & INTSTS_ICERR) { | ||
670 | out_be32(bmid_base + SCC_DMA_CMD, | ||
671 | in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START); | ||
672 | printk(KERN_WARNING "%s: Illegal Configuration\n", DRV_NAME); | ||
673 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_ICERR|INTSTS_BMSINT); | ||
674 | continue; | ||
675 | } | ||
676 | |||
677 | if (reg & INTSTS_BMSINT) { | ||
678 | unsigned int classes; | ||
679 | printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME); | ||
680 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT); | ||
681 | /* TBD: SW reset */ | ||
682 | scc_std_softreset(ap, &classes); | ||
683 | continue; | ||
684 | } | ||
685 | |||
686 | if (reg & INTSTS_BMHE) { | ||
687 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMHE); | ||
688 | continue; | ||
689 | } | ||
690 | |||
691 | if (reg & INTSTS_ACTEINT) { | ||
692 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_ACTEINT); | ||
693 | continue; | ||
694 | } | ||
695 | |||
696 | if (reg & INTSTS_IOIRQS) { | ||
697 | out_be32(bmid_base + SCC_DMA_INTST, INTSTS_IOIRQS); | ||
698 | continue; | ||
699 | } | ||
700 | break; | ||
701 | } | ||
702 | |||
703 | /* clear start/stop bit */ | ||
704 | out_be32(bmid_base + SCC_DMA_CMD, | ||
705 | in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START); | ||
706 | |||
707 | /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ | ||
708 | ata_altstatus(ap); /* dummy read */ | ||
709 | } | ||
710 | |||
711 | /** | ||
712 | * scc_bmdma_status - Read PCI IDE BMDMA status | ||
713 | * @ap: Port associated with this ATA transaction. | ||
714 | */ | ||
715 | |||
716 | static u8 scc_bmdma_status (struct ata_port *ap) | ||
717 | { | ||
718 | u8 host_stat; | ||
719 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
720 | |||
721 | host_stat = in_be32(mmio + SCC_DMA_STATUS); | ||
722 | |||
723 | /* Workaround for PTERADD: emulate DMA_INTR when | ||
724 | * - IDE_STATUS[ERR] = 1 | ||
725 | * - INT_STATUS[INTRQ] = 1 | ||
726 | * - DMA_STATUS[IORACTA] = 1 | ||
727 | */ | ||
728 | if (!(host_stat & ATA_DMA_INTR)) { | ||
729 | u32 int_status = in_be32(mmio + SCC_DMA_INTST); | ||
730 | if (ata_altstatus(ap) & ATA_ERR && | ||
731 | int_status & INTSTS_INTRQ && | ||
732 | host_stat & ATA_DMA_ACTIVE) | ||
733 | host_stat |= ATA_DMA_INTR; | ||
734 | } | ||
735 | |||
736 | return host_stat; | ||
737 | } | ||
738 | |||
739 | /** | ||
740 | * scc_data_xfer - Transfer data by PIO | ||
741 | * @adev: device for this I/O | ||
742 | * @buf: data buffer | ||
743 | * @buflen: buffer length | ||
744 | * @write_data: read/write | ||
745 | * | ||
746 | * Note: Original code is ata_data_xfer(). | ||
747 | */ | ||
748 | |||
749 | static void scc_data_xfer (struct ata_device *adev, unsigned char *buf, | ||
750 | unsigned int buflen, int write_data) | ||
751 | { | ||
752 | struct ata_port *ap = adev->ap; | ||
753 | unsigned int words = buflen >> 1; | ||
754 | unsigned int i; | ||
755 | u16 *buf16 = (u16 *) buf; | ||
756 | void __iomem *mmio = ap->ioaddr.data_addr; | ||
757 | |||
758 | /* Transfer multiple of 2 bytes */ | ||
759 | if (write_data) { | ||
760 | for (i = 0; i < words; i++) | ||
761 | out_be32(mmio, cpu_to_le16(buf16[i])); | ||
762 | } else { | ||
763 | for (i = 0; i < words; i++) | ||
764 | buf16[i] = le16_to_cpu(in_be32(mmio)); | ||
765 | } | ||
766 | |||
767 | /* Transfer trailing 1 byte, if any. */ | ||
768 | if (unlikely(buflen & 0x01)) { | ||
769 | u16 align_buf[1] = { 0 }; | ||
770 | unsigned char *trailing_buf = buf + buflen - 1; | ||
771 | |||
772 | if (write_data) { | ||
773 | memcpy(align_buf, trailing_buf, 1); | ||
774 | out_be32(mmio, cpu_to_le16(align_buf[0])); | ||
775 | } else { | ||
776 | align_buf[0] = le16_to_cpu(in_be32(mmio)); | ||
777 | memcpy(trailing_buf, align_buf, 1); | ||
778 | } | ||
779 | } | ||
780 | } | ||
781 | |||
782 | /** | ||
783 | * scc_irq_on - Enable interrupts on a port. | ||
784 | * @ap: Port on which interrupts are enabled. | ||
785 | * | ||
786 | * Note: Original code is ata_irq_on(). | ||
787 | */ | ||
788 | |||
789 | static u8 scc_irq_on (struct ata_port *ap) | ||
790 | { | ||
791 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
792 | u8 tmp; | ||
793 | |||
794 | ap->ctl &= ~ATA_NIEN; | ||
795 | ap->last_ctl = ap->ctl; | ||
796 | |||
797 | out_be32(ioaddr->ctl_addr, ap->ctl); | ||
798 | tmp = ata_wait_idle(ap); | ||
799 | |||
800 | ap->ops->irq_clear(ap); | ||
801 | |||
802 | return tmp; | ||
803 | } | ||
804 | |||
805 | /** | ||
806 | * scc_irq_ack - Acknowledge a device interrupt. | ||
807 | * @ap: Port on which interrupts are enabled. | ||
808 | * | ||
809 | * Note: Original code is ata_irq_ack(). | ||
810 | */ | ||
811 | |||
812 | static u8 scc_irq_ack (struct ata_port *ap, unsigned int chk_drq) | ||
813 | { | ||
814 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; | ||
815 | u8 host_stat, post_stat, status; | ||
816 | |||
817 | status = ata_busy_wait(ap, bits, 1000); | ||
818 | if (status & bits) | ||
819 | if (ata_msg_err(ap)) | ||
820 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
821 | |||
822 | /* get controller status; clear intr, err bits */ | ||
823 | host_stat = in_be32(ap->ioaddr.bmdma_addr + SCC_DMA_STATUS); | ||
824 | out_be32(ap->ioaddr.bmdma_addr + SCC_DMA_STATUS, | ||
825 | host_stat | ATA_DMA_INTR | ATA_DMA_ERR); | ||
826 | |||
827 | post_stat = in_be32(ap->ioaddr.bmdma_addr + SCC_DMA_STATUS); | ||
828 | |||
829 | if (ata_msg_intr(ap)) | ||
830 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | ||
831 | __FUNCTION__, | ||
832 | host_stat, post_stat, status); | ||
833 | |||
834 | return status; | ||
835 | } | ||
836 | |||
837 | /** | ||
838 | * scc_bmdma_freeze - Freeze BMDMA controller port | ||
839 | * @ap: port to freeze | ||
840 | * | ||
841 | * Note: Original code is ata_bmdma_freeze(). | ||
842 | */ | ||
843 | |||
844 | static void scc_bmdma_freeze (struct ata_port *ap) | ||
845 | { | ||
846 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
847 | |||
848 | ap->ctl |= ATA_NIEN; | ||
849 | ap->last_ctl = ap->ctl; | ||
850 | |||
851 | out_be32(ioaddr->ctl_addr, ap->ctl); | ||
852 | |||
853 | /* Under certain circumstances, some controllers raise IRQ on | ||
854 | * ATA_NIEN manipulation. Also, many controllers fail to mask | ||
855 | * previously pending IRQ on ATA_NIEN assertion. Clear it. | ||
856 | */ | ||
857 | ata_chk_status(ap); | ||
858 | |||
859 | ap->ops->irq_clear(ap); | ||
860 | } | ||
861 | |||
862 | /** | ||
863 | * scc_pata_prereset - prepare for reset | ||
864 | * @ap: ATA port to be reset | ||
865 | */ | ||
866 | |||
867 | static int scc_pata_prereset (struct ata_port *ap) | ||
868 | { | ||
869 | ap->cbl = ATA_CBL_PATA80; | ||
870 | return ata_std_prereset(ap); | ||
871 | } | ||
872 | |||
873 | /** | ||
874 | * scc_std_postreset - standard postreset callback | ||
875 | * @ap: the target ata_port | ||
876 | * @classes: classes of attached devices | ||
877 | * | ||
878 | * Note: Original code is ata_std_postreset(). | ||
879 | */ | ||
880 | |||
881 | static void scc_std_postreset (struct ata_port *ap, unsigned int *classes) | ||
882 | { | ||
883 | DPRINTK("ENTER\n"); | ||
884 | |||
885 | /* re-enable interrupts */ | ||
886 | if (!ap->ops->error_handler) | ||
887 | ap->ops->irq_on(ap); | ||
888 | |||
889 | /* is double-select really necessary? */ | ||
890 | if (classes[0] != ATA_DEV_NONE) | ||
891 | ap->ops->dev_select(ap, 1); | ||
892 | if (classes[1] != ATA_DEV_NONE) | ||
893 | ap->ops->dev_select(ap, 0); | ||
894 | |||
895 | /* bail out if no device is present */ | ||
896 | if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) { | ||
897 | DPRINTK("EXIT, no device\n"); | ||
898 | return; | ||
899 | } | ||
900 | |||
901 | /* set up device control */ | ||
902 | if (ap->ioaddr.ctl_addr) | ||
903 | out_be32(ap->ioaddr.ctl_addr, ap->ctl); | ||
904 | |||
905 | DPRINTK("EXIT\n"); | ||
906 | } | ||
907 | |||
908 | /** | ||
909 | * scc_error_handler - Stock error handler for BMDMA controller | ||
910 | * @ap: port to handle error for | ||
911 | */ | ||
912 | |||
913 | static void scc_error_handler (struct ata_port *ap) | ||
914 | { | ||
915 | ata_bmdma_drive_eh(ap, scc_pata_prereset, scc_std_softreset, NULL, | ||
916 | scc_std_postreset); | ||
917 | } | ||
918 | |||
919 | /** | ||
920 | * scc_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt. | ||
921 | * @ap: Port associated with this ATA transaction. | ||
922 | * | ||
923 | * Note: Original code is ata_bmdma_irq_clear(). | ||
924 | */ | ||
925 | |||
926 | static void scc_bmdma_irq_clear (struct ata_port *ap) | ||
927 | { | ||
928 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
929 | |||
930 | if (!mmio) | ||
931 | return; | ||
932 | |||
933 | out_be32(mmio + SCC_DMA_STATUS, in_be32(mmio + SCC_DMA_STATUS)); | ||
934 | } | ||
935 | |||
936 | /** | ||
937 | * scc_port_start - Set port up for dma. | ||
938 | * @ap: Port to initialize | ||
939 | * | ||
940 | * Allocate space for PRD table using ata_port_start(). | ||
941 | * Set PRD table address for PTERADD. (PRD Transfer End Read) | ||
942 | */ | ||
943 | |||
944 | static int scc_port_start (struct ata_port *ap) | ||
945 | { | ||
946 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
947 | int rc; | ||
948 | |||
949 | rc = ata_port_start(ap); | ||
950 | if (rc) | ||
951 | return rc; | ||
952 | |||
953 | out_be32(mmio + SCC_DMA_PTERADD, ap->prd_dma); | ||
954 | return 0; | ||
955 | } | ||
956 | |||
957 | /** | ||
958 | * scc_port_stop - Undo scc_port_start() | ||
959 | * @ap: Port to shut down | ||
960 | * | ||
961 | * Reset PTERADD. | ||
962 | */ | ||
963 | |||
964 | static void scc_port_stop (struct ata_port *ap) | ||
965 | { | ||
966 | void __iomem *mmio = ap->ioaddr.bmdma_addr; | ||
967 | |||
968 | out_be32(mmio + SCC_DMA_PTERADD, 0); | ||
969 | } | ||
970 | |||
971 | static struct scsi_host_template scc_sht = { | ||
972 | .module = THIS_MODULE, | ||
973 | .name = DRV_NAME, | ||
974 | .ioctl = ata_scsi_ioctl, | ||
975 | .queuecommand = ata_scsi_queuecmd, | ||
976 | .can_queue = ATA_DEF_QUEUE, | ||
977 | .this_id = ATA_SHT_THIS_ID, | ||
978 | .sg_tablesize = LIBATA_MAX_PRD, | ||
979 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | ||
980 | .emulated = ATA_SHT_EMULATED, | ||
981 | .use_clustering = ATA_SHT_USE_CLUSTERING, | ||
982 | .proc_name = DRV_NAME, | ||
983 | .dma_boundary = ATA_DMA_BOUNDARY, | ||
984 | .slave_configure = ata_scsi_slave_config, | ||
985 | .slave_destroy = ata_scsi_slave_destroy, | ||
986 | .bios_param = ata_std_bios_param, | ||
987 | .resume = ata_scsi_device_resume, | ||
988 | .suspend = ata_scsi_device_suspend, | ||
989 | }; | ||
990 | |||
991 | static const struct ata_port_operations scc_pata_ops = { | ||
992 | .port_disable = ata_port_disable, | ||
993 | .set_piomode = scc_set_piomode, | ||
994 | .set_dmamode = scc_set_dmamode, | ||
995 | .mode_filter = ata_pci_default_filter, | ||
996 | |||
997 | .tf_load = scc_tf_load, | ||
998 | .tf_read = scc_tf_read, | ||
999 | .exec_command = scc_exec_command, | ||
1000 | .check_status = scc_check_status, | ||
1001 | .check_altstatus = scc_check_altstatus, | ||
1002 | .dev_select = scc_std_dev_select, | ||
1003 | |||
1004 | .bmdma_setup = scc_bmdma_setup, | ||
1005 | .bmdma_start = scc_bmdma_start, | ||
1006 | .bmdma_stop = scc_bmdma_stop, | ||
1007 | .bmdma_status = scc_bmdma_status, | ||
1008 | .data_xfer = scc_data_xfer, | ||
1009 | |||
1010 | .qc_prep = ata_qc_prep, | ||
1011 | .qc_issue = ata_qc_issue_prot, | ||
1012 | |||
1013 | .freeze = scc_bmdma_freeze, | ||
1014 | .error_handler = scc_error_handler, | ||
1015 | .post_internal_cmd = scc_bmdma_stop, | ||
1016 | |||
1017 | .irq_handler = ata_interrupt, | ||
1018 | .irq_clear = scc_bmdma_irq_clear, | ||
1019 | .irq_on = scc_irq_on, | ||
1020 | .irq_ack = scc_irq_ack, | ||
1021 | |||
1022 | .port_start = scc_port_start, | ||
1023 | .port_stop = scc_port_stop, | ||
1024 | }; | ||
1025 | |||
1026 | static struct ata_port_info scc_port_info[] = { | ||
1027 | { | ||
1028 | .sht = &scc_sht, | ||
1029 | .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY, | ||
1030 | .pio_mask = 0x1f, /* pio0-4 */ | ||
1031 | .mwdma_mask = 0x00, | ||
1032 | .udma_mask = ATA_UDMA6, | ||
1033 | .port_ops = &scc_pata_ops, | ||
1034 | }, | ||
1035 | }; | ||
1036 | |||
1037 | /** | ||
1038 | * scc_reset_controller - initialize SCC PATA controller. | ||
1039 | */ | ||
1040 | |||
1041 | static int scc_reset_controller(struct ata_probe_ent *probe_ent) | ||
1042 | { | ||
1043 | void __iomem *ctrl_base = probe_ent->iomap[SCC_CTRL_BAR]; | ||
1044 | void __iomem *bmid_base = probe_ent->iomap[SCC_BMID_BAR]; | ||
1045 | void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL; | ||
1046 | void __iomem *mode_port = ctrl_base + SCC_CTL_MODEREG; | ||
1047 | void __iomem *ecmode_port = ctrl_base + SCC_CTL_ECMODE; | ||
1048 | void __iomem *intmask_port = bmid_base + SCC_DMA_INTMASK; | ||
1049 | void __iomem *dmastatus_port = bmid_base + SCC_DMA_STATUS; | ||
1050 | u32 reg = 0; | ||
1051 | |||
1052 | out_be32(cckctrl_port, reg); | ||
1053 | reg |= CCKCTRL_ATACLKOEN; | ||
1054 | out_be32(cckctrl_port, reg); | ||
1055 | reg |= CCKCTRL_LCLKEN | CCKCTRL_OCLKEN; | ||
1056 | out_be32(cckctrl_port, reg); | ||
1057 | reg |= CCKCTRL_CRST; | ||
1058 | out_be32(cckctrl_port, reg); | ||
1059 | |||
1060 | for (;;) { | ||
1061 | reg = in_be32(cckctrl_port); | ||
1062 | if (reg & CCKCTRL_CRST) | ||
1063 | break; | ||
1064 | udelay(5000); | ||
1065 | } | ||
1066 | |||
1067 | reg |= CCKCTRL_ATARESET; | ||
1068 | out_be32(cckctrl_port, reg); | ||
1069 | out_be32(ecmode_port, ECMODE_VALUE); | ||
1070 | out_be32(mode_port, MODE_JCUSFEN); | ||
1071 | out_be32(intmask_port, INTMASK_MSK); | ||
1072 | |||
1073 | if (in_be32(dmastatus_port) & QCHSD_STPDIAG) { | ||
1074 | printk(KERN_WARNING "%s: failed to detect 80c cable. (PDIAG# is high)\n", DRV_NAME); | ||
1075 | return -EIO; | ||
1076 | } | ||
1077 | |||
1078 | return 0; | ||
1079 | } | ||
1080 | |||
1081 | /** | ||
1082 | * scc_setup_ports - initialize ioaddr with SCC PATA port offsets. | ||
1083 | * @ioaddr: IO address structure to be initialized | ||
1084 | * @base: base address of BMID region | ||
1085 | */ | ||
1086 | |||
1087 | static void scc_setup_ports (struct ata_ioports *ioaddr, void __iomem *base) | ||
1088 | { | ||
1089 | ioaddr->cmd_addr = base + SCC_REG_CMD_ADDR; | ||
1090 | ioaddr->altstatus_addr = ioaddr->cmd_addr + SCC_REG_ALTSTATUS; | ||
1091 | ioaddr->ctl_addr = ioaddr->cmd_addr + SCC_REG_ALTSTATUS; | ||
1092 | ioaddr->bmdma_addr = base; | ||
1093 | ioaddr->data_addr = ioaddr->cmd_addr + SCC_REG_DATA; | ||
1094 | ioaddr->error_addr = ioaddr->cmd_addr + SCC_REG_ERR; | ||
1095 | ioaddr->feature_addr = ioaddr->cmd_addr + SCC_REG_FEATURE; | ||
1096 | ioaddr->nsect_addr = ioaddr->cmd_addr + SCC_REG_NSECT; | ||
1097 | ioaddr->lbal_addr = ioaddr->cmd_addr + SCC_REG_LBAL; | ||
1098 | ioaddr->lbam_addr = ioaddr->cmd_addr + SCC_REG_LBAM; | ||
1099 | ioaddr->lbah_addr = ioaddr->cmd_addr + SCC_REG_LBAH; | ||
1100 | ioaddr->device_addr = ioaddr->cmd_addr + SCC_REG_DEVICE; | ||
1101 | ioaddr->status_addr = ioaddr->cmd_addr + SCC_REG_STATUS; | ||
1102 | ioaddr->command_addr = ioaddr->cmd_addr + SCC_REG_CMD; | ||
1103 | } | ||
1104 | |||
1105 | static int scc_host_init(struct ata_probe_ent *probe_ent) | ||
1106 | { | ||
1107 | struct pci_dev *pdev = to_pci_dev(probe_ent->dev); | ||
1108 | int rc; | ||
1109 | |||
1110 | rc = scc_reset_controller(probe_ent); | ||
1111 | if (rc) | ||
1112 | return rc; | ||
1113 | |||
1114 | probe_ent->n_ports = 1; | ||
1115 | |||
1116 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | ||
1117 | if (rc) | ||
1118 | return rc; | ||
1119 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | ||
1120 | if (rc) | ||
1121 | return rc; | ||
1122 | |||
1123 | scc_setup_ports(&probe_ent->port[0], probe_ent->iomap[SCC_BMID_BAR]); | ||
1124 | |||
1125 | pci_set_master(pdev); | ||
1126 | |||
1127 | return 0; | ||
1128 | } | ||
1129 | |||
1130 | /** | ||
1131 | * scc_init_one - Register SCC PATA device with kernel services | ||
1132 | * @pdev: PCI device to register | ||
1133 | * @ent: Entry in scc_pci_tbl matching with @pdev | ||
1134 | * | ||
1135 | * LOCKING: | ||
1136 | * Inherited from PCI layer (may sleep). | ||
1137 | * | ||
1138 | * RETURNS: | ||
1139 | * Zero on success, or -ERRNO value. | ||
1140 | */ | ||
1141 | |||
1142 | static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | ||
1143 | { | ||
1144 | static int printed_version; | ||
1145 | unsigned int board_idx = (unsigned int) ent->driver_data; | ||
1146 | struct device *dev = &pdev->dev; | ||
1147 | struct ata_probe_ent *probe_ent; | ||
1148 | int rc; | ||
1149 | |||
1150 | if (!printed_version++) | ||
1151 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
1152 | "version " DRV_VERSION "\n"); | ||
1153 | |||
1154 | rc = pcim_enable_device(pdev); | ||
1155 | if (rc) | ||
1156 | return rc; | ||
1157 | |||
1158 | rc = pcim_iomap_regions(pdev, (1 << SCC_CTRL_BAR) | (1 << SCC_BMID_BAR), DRV_NAME); | ||
1159 | if (rc == -EBUSY) | ||
1160 | pcim_pin_device(pdev); | ||
1161 | if (rc) | ||
1162 | return rc; | ||
1163 | |||
1164 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); | ||
1165 | if (!probe_ent) | ||
1166 | return -ENOMEM; | ||
1167 | |||
1168 | probe_ent->dev = dev; | ||
1169 | INIT_LIST_HEAD(&probe_ent->node); | ||
1170 | |||
1171 | probe_ent->sht = scc_port_info[board_idx].sht; | ||
1172 | probe_ent->port_flags = scc_port_info[board_idx].flags; | ||
1173 | probe_ent->pio_mask = scc_port_info[board_idx].pio_mask; | ||
1174 | probe_ent->udma_mask = scc_port_info[board_idx].udma_mask; | ||
1175 | probe_ent->port_ops = scc_port_info[board_idx].port_ops; | ||
1176 | |||
1177 | probe_ent->irq = pdev->irq; | ||
1178 | probe_ent->irq_flags = IRQF_SHARED; | ||
1179 | probe_ent->iomap = pcim_iomap_table(pdev); | ||
1180 | |||
1181 | rc = scc_host_init(probe_ent); | ||
1182 | if (rc) | ||
1183 | return rc; | ||
1184 | |||
1185 | if (!ata_device_add(probe_ent)) | ||
1186 | return -ENODEV; | ||
1187 | |||
1188 | devm_kfree(dev, probe_ent); | ||
1189 | return 0; | ||
1190 | } | ||
1191 | |||
1192 | static struct pci_driver scc_pci_driver = { | ||
1193 | .name = DRV_NAME, | ||
1194 | .id_table = scc_pci_tbl, | ||
1195 | .probe = scc_init_one, | ||
1196 | .remove = ata_pci_remove_one, | ||
1197 | #ifdef CONFIG_PM | ||
1198 | .suspend = ata_pci_device_suspend, | ||
1199 | .resume = ata_pci_device_resume, | ||
1200 | #endif | ||
1201 | }; | ||
1202 | |||
1203 | static int __init scc_init (void) | ||
1204 | { | ||
1205 | int rc; | ||
1206 | |||
1207 | DPRINTK("pci_register_driver\n"); | ||
1208 | rc = pci_register_driver(&scc_pci_driver); | ||
1209 | if (rc) | ||
1210 | return rc; | ||
1211 | |||
1212 | DPRINTK("done\n"); | ||
1213 | return 0; | ||
1214 | } | ||
1215 | |||
1216 | static void __exit scc_exit (void) | ||
1217 | { | ||
1218 | pci_unregister_driver(&scc_pci_driver); | ||
1219 | } | ||
1220 | |||
1221 | module_init(scc_init); | ||
1222 | module_exit(scc_exit); | ||
1223 | |||
1224 | MODULE_AUTHOR("Toshiba corp"); | ||
1225 | MODULE_DESCRIPTION("SCSI low-level driver for Toshiba SCC PATA controller"); | ||
1226 | MODULE_LICENSE("GPL"); | ||
1227 | MODULE_DEVICE_TABLE(pci, scc_pci_tbl); | ||
1228 | MODULE_VERSION(DRV_VERSION); | ||
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index ad5b43fef3d1..dde7eb9f72bb 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/libata.h> | 41 | #include <linux/libata.h> |
42 | 42 | ||
43 | #define DRV_NAME "pata_serverworks" | 43 | #define DRV_NAME "pata_serverworks" |
44 | #define DRV_VERSION "0.3.9" | 44 | #define DRV_VERSION "0.4.0" |
45 | 45 | ||
46 | #define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ | 46 | #define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ |
47 | #define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ | 47 | #define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index ed79fabe025c..1cb67b221c28 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/libata.h> | 33 | #include <linux/libata.h> |
34 | 34 | ||
35 | #define DRV_NAME "pata_sil680" | 35 | #define DRV_NAME "pata_sil680" |
36 | #define DRV_VERSION "0.4.1" | 36 | #define DRV_VERSION "0.4.5" |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * sil680_selreg - return register base | 39 | * sil680_selreg - return register base |
@@ -139,10 +139,13 @@ static void sil680_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
139 | 139 | ||
140 | unsigned long tfaddr = sil680_selreg(ap, 0x02); | 140 | unsigned long tfaddr = sil680_selreg(ap, 0x02); |
141 | unsigned long addr = sil680_seldev(ap, adev, 0x04); | 141 | unsigned long addr = sil680_seldev(ap, adev, 0x04); |
142 | unsigned long addr_mask = 0x80 + 4 * ap->port_no; | ||
142 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | 143 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); |
143 | int pio = adev->pio_mode - XFER_PIO_0; | 144 | int pio = adev->pio_mode - XFER_PIO_0; |
144 | int lowest_pio = pio; | 145 | int lowest_pio = pio; |
146 | int port_shift = 4 * adev->devno; | ||
145 | u16 reg; | 147 | u16 reg; |
148 | u8 mode; | ||
146 | 149 | ||
147 | struct ata_device *pair = ata_dev_pair(adev); | 150 | struct ata_device *pair = ata_dev_pair(adev); |
148 | 151 | ||
@@ -153,10 +156,17 @@ static void sil680_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
153 | pci_write_config_word(pdev, tfaddr, speed_t[lowest_pio]); | 156 | pci_write_config_word(pdev, tfaddr, speed_t[lowest_pio]); |
154 | 157 | ||
155 | pci_read_config_word(pdev, tfaddr-2, ®); | 158 | pci_read_config_word(pdev, tfaddr-2, ®); |
159 | pci_read_config_byte(pdev, addr_mask, &mode); | ||
160 | |||
156 | reg &= ~0x0200; /* Clear IORDY */ | 161 | reg &= ~0x0200; /* Clear IORDY */ |
157 | if (ata_pio_need_iordy(adev)) | 162 | mode &= ~(3 << port_shift); /* Clear IORDY and DMA bits */ |
163 | |||
164 | if (ata_pio_need_iordy(adev)) { | ||
158 | reg |= 0x0200; /* Enable IORDY */ | 165 | reg |= 0x0200; /* Enable IORDY */ |
166 | mode |= 1 << port_shift; | ||
167 | } | ||
159 | pci_write_config_word(pdev, tfaddr-2, reg); | 168 | pci_write_config_word(pdev, tfaddr-2, reg); |
169 | pci_write_config_byte(pdev, addr_mask, mode); | ||
160 | } | 170 | } |
161 | 171 | ||
162 | /** | 172 | /** |
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index 560103d55b2e..be300923b27e 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -32,11 +32,10 @@ | |||
32 | #include <scsi/scsi_host.h> | 32 | #include <scsi/scsi_host.h> |
33 | #include <linux/libata.h> | 33 | #include <linux/libata.h> |
34 | #include <linux/ata.h> | 34 | #include <linux/ata.h> |
35 | #include "libata.h" | 35 | #include "sis.h" |
36 | 36 | ||
37 | #undef DRV_NAME /* already defined in libata.h, for libata-core */ | ||
38 | #define DRV_NAME "pata_sis" | 37 | #define DRV_NAME "pata_sis" |
39 | #define DRV_VERSION "0.4.5" | 38 | #define DRV_VERSION "0.5.0" |
40 | 39 | ||
41 | struct sis_chipset { | 40 | struct sis_chipset { |
42 | u16 device; /* PCI host ID */ | 41 | u16 device; /* PCI host ID */ |
@@ -151,7 +150,7 @@ static int sis_66_pre_reset(struct ata_port *ap) | |||
151 | 150 | ||
152 | if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) { | 151 | if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) { |
153 | ata_port_disable(ap); | 152 | ata_port_disable(ap); |
154 | printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id); | 153 | ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n"); |
155 | return 0; | 154 | return 0; |
156 | } | 155 | } |
157 | /* Older chips keep cable detect in bits 4/5 of reg 0x48 */ | 156 | /* Older chips keep cable detect in bits 4/5 of reg 0x48 */ |
@@ -197,7 +196,7 @@ static int sis_old_pre_reset(struct ata_port *ap) | |||
197 | 196 | ||
198 | if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) { | 197 | if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) { |
199 | ata_port_disable(ap); | 198 | ata_port_disable(ap); |
200 | printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id); | 199 | ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n"); |
201 | return 0; | 200 | return 0; |
202 | } | 201 | } |
203 | ap->cbl = ATA_CBL_PATA40; | 202 | ap->cbl = ATA_CBL_PATA40; |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index 96e890fd645b..13e81f0ef1f7 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -7,6 +7,13 @@ | |||
7 | * SL82C105/Winbond 553 IDE driver | 7 | * SL82C105/Winbond 553 IDE driver |
8 | * | 8 | * |
9 | * and in part on the documentation and errata sheet | 9 | * and in part on the documentation and errata sheet |
10 | * | ||
11 | * | ||
12 | * Note: The controller like many controllers has shared timings for | ||
13 | * PIO and DMA. We thus flip to the DMA timings in dma_start and flip back | ||
14 | * in the dma_stop function. Thus we actually don't need a set_dmamode | ||
15 | * method as the PIO method is always called and will set the right PIO | ||
16 | * timing parameters. | ||
10 | */ | 17 | */ |
11 | 18 | ||
12 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -19,7 +26,7 @@ | |||
19 | #include <linux/libata.h> | 26 | #include <linux/libata.h> |
20 | 27 | ||
21 | #define DRV_NAME "pata_sl82c105" | 28 | #define DRV_NAME "pata_sl82c105" |
22 | #define DRV_VERSION "0.2.3" | 29 | #define DRV_VERSION "0.3.0" |
23 | 30 | ||
24 | enum { | 31 | enum { |
25 | /* | 32 | /* |
@@ -126,33 +133,6 @@ static void sl82c105_configure_dmamode(struct ata_port *ap, struct ata_device *a | |||
126 | } | 133 | } |
127 | 134 | ||
128 | /** | 135 | /** |
129 | * sl82c105_set_dmamode - set initial DMA mode data | ||
130 | * @ap: ATA interface | ||
131 | * @adev: ATA device | ||
132 | * | ||
133 | * Called to do the DMA mode setup. This replaces the PIO timings | ||
134 | * for the device in question. Set appropriate PIO timings not DMA | ||
135 | * timings at this point. | ||
136 | */ | ||
137 | |||
138 | static void sl82c105_set_dmamode(struct ata_port *ap, struct ata_device *adev) | ||
139 | { | ||
140 | switch(adev->dma_mode) { | ||
141 | case XFER_MW_DMA_0: | ||
142 | sl82c105_configure_piomode(ap, adev, 0); | ||
143 | break; | ||
144 | case XFER_MW_DMA_1: | ||
145 | sl82c105_configure_piomode(ap, adev, 3); | ||
146 | break; | ||
147 | case XFER_MW_DMA_2: | ||
148 | sl82c105_configure_piomode(ap, adev, 4); | ||
149 | break; | ||
150 | default: | ||
151 | BUG(); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * sl82c105_reset_engine - Reset the DMA engine | 136 | * sl82c105_reset_engine - Reset the DMA engine |
157 | * @ap: ATA interface | 137 | * @ap: ATA interface |
158 | * | 138 | * |
@@ -222,7 +202,7 @@ static void sl82c105_bmdma_stop(struct ata_queued_cmd *qc) | |||
222 | 202 | ||
223 | /* This will redo the initial setup of the DMA device to matching | 203 | /* This will redo the initial setup of the DMA device to matching |
224 | PIO timings */ | 204 | PIO timings */ |
225 | sl82c105_set_dmamode(ap, qc->dev); | 205 | sl82c105_set_piomode(ap, qc->dev); |
226 | } | 206 | } |
227 | 207 | ||
228 | static struct scsi_host_template sl82c105_sht = { | 208 | static struct scsi_host_template sl82c105_sht = { |
@@ -246,7 +226,6 @@ static struct scsi_host_template sl82c105_sht = { | |||
246 | static struct ata_port_operations sl82c105_port_ops = { | 226 | static struct ata_port_operations sl82c105_port_ops = { |
247 | .port_disable = ata_port_disable, | 227 | .port_disable = ata_port_disable, |
248 | .set_piomode = sl82c105_set_piomode, | 228 | .set_piomode = sl82c105_set_piomode, |
249 | .set_dmamode = sl82c105_set_dmamode, | ||
250 | .mode_filter = ata_pci_default_filter, | 229 | .mode_filter = ata_pci_default_filter, |
251 | 230 | ||
252 | .tf_load = ata_tf_load, | 231 | .tf_load = ata_tf_load, |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 220fcd6c5492..20fc2d0dcfa1 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -170,7 +170,7 @@ static int via_pre_reset(struct ata_port *ap) | |||
170 | ap->cbl = ATA_CBL_PATA40; | 170 | ap->cbl = ATA_CBL_PATA40; |
171 | else | 171 | else |
172 | ap->cbl = ATA_CBL_PATA_UNK; | 172 | ap->cbl = ATA_CBL_PATA_UNK; |
173 | 173 | ||
174 | 174 | ||
175 | return ata_std_prereset(ap); | 175 | return ata_std_prereset(ap); |
176 | } | 176 | } |
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 0888b4f19f4c..6c111035fc84 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | 18 | ||
19 | #define DRV_NAME "pata_winbond" | 19 | #define DRV_NAME "pata_winbond" |
20 | #define DRV_VERSION "0.0.1" | 20 | #define DRV_VERSION "0.0.2" |
21 | 21 | ||
22 | #define NR_HOST 4 /* Two winbond controllers, two channels each */ | 22 | #define NR_HOST 4 /* Two winbond controllers, two channels each */ |
23 | 23 | ||
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c index 857ac23217ab..5dd3ca8b5f29 100644 --- a/drivers/ata/pdc_adma.c +++ b/drivers/ata/pdc_adma.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
45 | 45 | ||
46 | #define DRV_NAME "pdc_adma" | 46 | #define DRV_NAME "pdc_adma" |
47 | #define DRV_VERSION "0.04" | 47 | #define DRV_VERSION "0.05" |
48 | 48 | ||
49 | /* macro to calculate base address for ATA regs */ | 49 | /* macro to calculate base address for ATA regs */ |
50 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) | 50 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) |
@@ -498,7 +498,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host *host) | |||
498 | if ((status & ATA_BUSY)) | 498 | if ((status & ATA_BUSY)) |
499 | continue; | 499 | continue; |
500 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", | 500 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", |
501 | ap->id, qc->tf.protocol, status); | 501 | ap->print_id, qc->tf.protocol, status); |
502 | 502 | ||
503 | /* complete taskfile transaction */ | 503 | /* complete taskfile transaction */ |
504 | pp->state = adma_state_idle; | 504 | pp->state = adma_state_idle; |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index d689df52eae3..a65ba636aaa8 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/libata.h> | 35 | #include <linux/libata.h> |
36 | 36 | ||
37 | #define DRV_NAME "sata_mv" | 37 | #define DRV_NAME "sata_mv" |
38 | #define DRV_VERSION "0.7" | 38 | #define DRV_VERSION "0.8" |
39 | 39 | ||
40 | enum { | 40 | enum { |
41 | /* BAR's are enumerated in terms of pci_resource_start() terms */ | 41 | /* BAR's are enumerated in terms of pci_resource_start() terms */ |
@@ -137,14 +137,19 @@ enum { | |||
137 | PCI_ERR = (1 << 18), | 137 | PCI_ERR = (1 << 18), |
138 | TRAN_LO_DONE = (1 << 19), /* 6xxx: IRQ coalescing */ | 138 | TRAN_LO_DONE = (1 << 19), /* 6xxx: IRQ coalescing */ |
139 | TRAN_HI_DONE = (1 << 20), /* 6xxx: IRQ coalescing */ | 139 | TRAN_HI_DONE = (1 << 20), /* 6xxx: IRQ coalescing */ |
140 | PORTS_0_3_COAL_DONE = (1 << 8), | ||
141 | PORTS_4_7_COAL_DONE = (1 << 17), | ||
140 | PORTS_0_7_COAL_DONE = (1 << 21), /* 6xxx: IRQ coalescing */ | 142 | PORTS_0_7_COAL_DONE = (1 << 21), /* 6xxx: IRQ coalescing */ |
141 | GPIO_INT = (1 << 22), | 143 | GPIO_INT = (1 << 22), |
142 | SELF_INT = (1 << 23), | 144 | SELF_INT = (1 << 23), |
143 | TWSI_INT = (1 << 24), | 145 | TWSI_INT = (1 << 24), |
144 | HC_MAIN_RSVD = (0x7f << 25), /* bits 31-25 */ | 146 | HC_MAIN_RSVD = (0x7f << 25), /* bits 31-25 */ |
147 | HC_MAIN_RSVD_5 = (0x1fff << 19), /* bits 31-19 */ | ||
145 | HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE | | 148 | HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE | |
146 | PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT | | 149 | PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT | |
147 | HC_MAIN_RSVD), | 150 | HC_MAIN_RSVD), |
151 | HC_MAIN_MASKED_IRQS_5 = (PORTS_0_3_COAL_DONE | PORTS_4_7_COAL_DONE | | ||
152 | HC_MAIN_RSVD_5), | ||
148 | 153 | ||
149 | /* SATAHC registers */ | 154 | /* SATAHC registers */ |
150 | HC_CFG_OFS = 0, | 155 | HC_CFG_OFS = 0, |
@@ -814,23 +819,27 @@ static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio) | |||
814 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); | 819 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); |
815 | 820 | ||
816 | /* set up non-NCQ EDMA configuration */ | 821 | /* set up non-NCQ EDMA configuration */ |
817 | cfg &= ~0x1f; /* clear queue depth */ | ||
818 | cfg &= ~EDMA_CFG_NCQ; /* clear NCQ mode */ | ||
819 | cfg &= ~(1 << 9); /* disable equeue */ | 822 | cfg &= ~(1 << 9); /* disable equeue */ |
820 | 823 | ||
821 | if (IS_GEN_I(hpriv)) | 824 | if (IS_GEN_I(hpriv)) { |
825 | cfg &= ~0x1f; /* clear queue depth */ | ||
822 | cfg |= (1 << 8); /* enab config burst size mask */ | 826 | cfg |= (1 << 8); /* enab config burst size mask */ |
827 | } | ||
823 | 828 | ||
824 | else if (IS_GEN_II(hpriv)) | 829 | else if (IS_GEN_II(hpriv)) { |
830 | cfg &= ~0x1f; /* clear queue depth */ | ||
825 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; | 831 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; |
832 | cfg &= ~(EDMA_CFG_NCQ | EDMA_CFG_NCQ_GO_ON_ERR); /* clear NCQ */ | ||
833 | } | ||
826 | 834 | ||
827 | else if (IS_GEN_IIE(hpriv)) { | 835 | else if (IS_GEN_IIE(hpriv)) { |
828 | cfg |= (1 << 23); /* dis RX PM port mask */ | 836 | cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ |
829 | cfg &= ~(1 << 16); /* dis FIS-based switching (for now) */ | 837 | cfg |= (1 << 22); /* enab 4-entry host queue cache */ |
830 | cfg &= ~(1 << 19); /* dis 128-entry queue (for now?) */ | 838 | cfg &= ~(1 << 19); /* dis 128-entry queue (for now?) */ |
831 | cfg |= (1 << 18); /* enab early completion */ | 839 | cfg |= (1 << 18); /* enab early completion */ |
832 | cfg |= (1 << 17); /* enab host q cache */ | 840 | cfg |= (1 << 17); /* enab cut-through (dis stor&forwrd) */ |
833 | cfg |= (1 << 22); /* enab cutthrough */ | 841 | cfg &= ~(1 << 16); /* dis FIS-based switching (for now) */ |
842 | cfg &= ~(EDMA_CFG_NCQ | EDMA_CFG_NCQ_GO_ON_ERR); /* clear NCQ */ | ||
834 | } | 843 | } |
835 | 844 | ||
836 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); | 845 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); |
@@ -1276,7 +1285,7 @@ static void mv_err_intr(struct ata_port *ap, int reset_allowed) | |||
1276 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 1285 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
1277 | } | 1286 | } |
1278 | DPRINTK(KERN_ERR "ata%u: port error; EDMA err cause: 0x%08x " | 1287 | DPRINTK(KERN_ERR "ata%u: port error; EDMA err cause: 0x%08x " |
1279 | "SERR: 0x%08x\n", ap->id, edma_err_cause, serr); | 1288 | "SERR: 0x%08x\n", ap->print_id, edma_err_cause, serr); |
1280 | 1289 | ||
1281 | /* Clear EDMA now that SERR cleanup done */ | 1290 | /* Clear EDMA now that SERR cleanup done */ |
1282 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); | 1291 | writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); |
@@ -2052,7 +2061,7 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio) | |||
2052 | port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS; | 2061 | port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS; |
2053 | 2062 | ||
2054 | /* unused: */ | 2063 | /* unused: */ |
2055 | port->cmd_addr = port->bmdma_addr = port->scr_addr = 0; | 2064 | port->cmd_addr = port->bmdma_addr = port->scr_addr = NULL; |
2056 | 2065 | ||
2057 | /* Clear any currently outstanding port interrupt conditions */ | 2066 | /* Clear any currently outstanding port interrupt conditions */ |
2058 | serr_ofs = mv_scr_offset(SCR_ERROR); | 2067 | serr_ofs = mv_scr_offset(SCR_ERROR); |
@@ -2240,7 +2249,11 @@ static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent, | |||
2240 | 2249 | ||
2241 | /* and unmask interrupt generation for host regs */ | 2250 | /* and unmask interrupt generation for host regs */ |
2242 | writelfl(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS); | 2251 | writelfl(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS); |
2243 | writelfl(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS); | 2252 | |
2253 | if (IS_50XX(hpriv)) | ||
2254 | writelfl(~HC_MAIN_MASKED_IRQS_5, mmio + HC_MAIN_IRQ_MASK_OFS); | ||
2255 | else | ||
2256 | writelfl(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS); | ||
2244 | 2257 | ||
2245 | VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x " | 2258 | VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x " |
2246 | "PCI int cause/mask=0x%08x/0x%08x\n", | 2259 | "PCI int cause/mask=0x%08x/0x%08x\n", |
@@ -2347,7 +2360,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2347 | return rc; | 2360 | return rc; |
2348 | 2361 | ||
2349 | /* Enable interrupts */ | 2362 | /* Enable interrupts */ |
2350 | if (msi && !pci_enable_msi(pdev)) | 2363 | if (msi && pci_enable_msi(pdev)) |
2351 | pci_intx(pdev, 1); | 2364 | pci_intx(pdev, 1); |
2352 | 2365 | ||
2353 | mv_dump_pci_cfg(pdev, 0x68); | 2366 | mv_dump_pci_cfg(pdev, 0x68); |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index ab92f208dae2..30eed12b3631 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -219,6 +219,7 @@ struct nv_adma_port_priv { | |||
219 | void __iomem * gen_block; | 219 | void __iomem * gen_block; |
220 | void __iomem * notifier_clear_block; | 220 | void __iomem * notifier_clear_block; |
221 | u8 flags; | 221 | u8 flags; |
222 | int last_issue_ncq; | ||
222 | }; | 223 | }; |
223 | 224 | ||
224 | struct nv_host_priv { | 225 | struct nv_host_priv { |
@@ -254,10 +255,7 @@ static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg); | |||
254 | static int nv_adma_port_resume(struct ata_port *ap); | 255 | static int nv_adma_port_resume(struct ata_port *ap); |
255 | static void nv_adma_error_handler(struct ata_port *ap); | 256 | static void nv_adma_error_handler(struct ata_port *ap); |
256 | static void nv_adma_host_stop(struct ata_host *host); | 257 | static void nv_adma_host_stop(struct ata_host *host); |
257 | static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc); | 258 | static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc); |
258 | static void nv_adma_bmdma_start(struct ata_queued_cmd *qc); | ||
259 | static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc); | ||
260 | static u8 nv_adma_bmdma_status(struct ata_port *ap); | ||
261 | 259 | ||
262 | enum nv_host_type | 260 | enum nv_host_type |
263 | { | 261 | { |
@@ -432,16 +430,16 @@ static const struct ata_port_operations nv_adma_ops = { | |||
432 | .exec_command = ata_exec_command, | 430 | .exec_command = ata_exec_command, |
433 | .check_status = ata_check_status, | 431 | .check_status = ata_check_status, |
434 | .dev_select = ata_std_dev_select, | 432 | .dev_select = ata_std_dev_select, |
435 | .bmdma_setup = nv_adma_bmdma_setup, | 433 | .bmdma_setup = ata_bmdma_setup, |
436 | .bmdma_start = nv_adma_bmdma_start, | 434 | .bmdma_start = ata_bmdma_start, |
437 | .bmdma_stop = nv_adma_bmdma_stop, | 435 | .bmdma_stop = ata_bmdma_stop, |
438 | .bmdma_status = nv_adma_bmdma_status, | 436 | .bmdma_status = ata_bmdma_status, |
439 | .qc_prep = nv_adma_qc_prep, | 437 | .qc_prep = nv_adma_qc_prep, |
440 | .qc_issue = nv_adma_qc_issue, | 438 | .qc_issue = nv_adma_qc_issue, |
441 | .freeze = nv_ck804_freeze, | 439 | .freeze = nv_ck804_freeze, |
442 | .thaw = nv_ck804_thaw, | 440 | .thaw = nv_ck804_thaw, |
443 | .error_handler = nv_adma_error_handler, | 441 | .error_handler = nv_adma_error_handler, |
444 | .post_internal_cmd = nv_adma_bmdma_stop, | 442 | .post_internal_cmd = nv_adma_post_internal_cmd, |
445 | .data_xfer = ata_data_xfer, | 443 | .data_xfer = ata_data_xfer, |
446 | .irq_handler = nv_adma_interrupt, | 444 | .irq_handler = nv_adma_interrupt, |
447 | .irq_clear = nv_adma_irq_clear, | 445 | .irq_clear = nv_adma_irq_clear, |
@@ -661,30 +659,31 @@ static unsigned int nv_adma_tf_to_cpb(struct ata_taskfile *tf, __le16 *cpb) | |||
661 | { | 659 | { |
662 | unsigned int idx = 0; | 660 | unsigned int idx = 0; |
663 | 661 | ||
664 | cpb[idx++] = cpu_to_le16((ATA_REG_DEVICE << 8) | tf->device | WNB); | 662 | if(tf->flags & ATA_TFLAG_ISADDR) { |
665 | 663 | if (tf->flags & ATA_TFLAG_LBA48) { | |
666 | if ((tf->flags & ATA_TFLAG_LBA48) == 0) { | 664 | cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->hob_feature | WNB); |
667 | cpb[idx++] = cpu_to_le16(IGN); | 665 | cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->hob_nsect); |
668 | cpb[idx++] = cpu_to_le16(IGN); | 666 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->hob_lbal); |
669 | cpb[idx++] = cpu_to_le16(IGN); | 667 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->hob_lbam); |
670 | cpb[idx++] = cpu_to_le16(IGN); | 668 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->hob_lbah); |
671 | cpb[idx++] = cpu_to_le16(IGN); | 669 | cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->feature); |
672 | } | 670 | } else |
673 | else { | 671 | cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->feature | WNB); |
674 | cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->hob_feature); | 672 | |
675 | cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->hob_nsect); | 673 | cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->nsect); |
676 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->hob_lbal); | 674 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->lbal); |
677 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->hob_lbam); | 675 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->lbam); |
678 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->hob_lbah); | 676 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->lbah); |
679 | } | 677 | } |
680 | cpb[idx++] = cpu_to_le16((ATA_REG_ERR << 8) | tf->feature); | 678 | |
681 | cpb[idx++] = cpu_to_le16((ATA_REG_NSECT << 8) | tf->nsect); | 679 | if(tf->flags & ATA_TFLAG_DEVICE) |
682 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAL << 8) | tf->lbal); | 680 | cpb[idx++] = cpu_to_le16((ATA_REG_DEVICE << 8) | tf->device); |
683 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAM << 8) | tf->lbam); | ||
684 | cpb[idx++] = cpu_to_le16((ATA_REG_LBAH << 8) | tf->lbah); | ||
685 | 681 | ||
686 | cpb[idx++] = cpu_to_le16((ATA_REG_CMD << 8) | tf->command | CMDEND); | 682 | cpb[idx++] = cpu_to_le16((ATA_REG_CMD << 8) | tf->command | CMDEND); |
687 | 683 | ||
684 | while(idx < 12) | ||
685 | cpb[idx++] = cpu_to_le16(IGN); | ||
686 | |||
688 | return idx; | 687 | return idx; |
689 | } | 688 | } |
690 | 689 | ||
@@ -741,6 +740,17 @@ static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) | |||
741 | DPRINTK("Completing qc from tag %d with err_mask %u\n",cpb_num, | 740 | DPRINTK("Completing qc from tag %d with err_mask %u\n",cpb_num, |
742 | qc->err_mask); | 741 | qc->err_mask); |
743 | ata_qc_complete(qc); | 742 | ata_qc_complete(qc); |
743 | } else { | ||
744 | struct ata_eh_info *ehi = &ap->eh_info; | ||
745 | /* Notifier bits set without a command may indicate the drive | ||
746 | is misbehaving. Raise host state machine violation on this | ||
747 | condition. */ | ||
748 | ata_port_printk(ap, KERN_ERR, "notifier for tag %d with no command?\n", | ||
749 | cpb_num); | ||
750 | ehi->err_mask |= AC_ERR_HSM; | ||
751 | ehi->action |= ATA_EH_SOFTRESET; | ||
752 | ata_port_freeze(ap); | ||
753 | return 1; | ||
744 | } | 754 | } |
745 | } | 755 | } |
746 | return 0; | 756 | return 0; |
@@ -852,22 +862,14 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
852 | 862 | ||
853 | if (status & (NV_ADMA_STAT_DONE | | 863 | if (status & (NV_ADMA_STAT_DONE | |
854 | NV_ADMA_STAT_CPBERR)) { | 864 | NV_ADMA_STAT_CPBERR)) { |
865 | u32 check_commands = notifier | notifier_error; | ||
866 | int pos, error = 0; | ||
855 | /** Check CPBs for completed commands */ | 867 | /** Check CPBs for completed commands */ |
856 | 868 | while ((pos = ffs(check_commands)) && !error) { | |
857 | if (ata_tag_valid(ap->active_tag)) { | 869 | pos--; |
858 | /* Non-NCQ command */ | 870 | error = nv_adma_check_cpb(ap, pos, |
859 | nv_adma_check_cpb(ap, ap->active_tag, | 871 | notifier_error & (1 << pos) ); |
860 | notifier_error & (1 << ap->active_tag)); | 872 | check_commands &= ~(1 << pos ); |
861 | } else { | ||
862 | int pos, error = 0; | ||
863 | u32 active = ap->sactive; | ||
864 | |||
865 | while ((pos = ffs(active)) && !error) { | ||
866 | pos--; | ||
867 | error = nv_adma_check_cpb(ap, pos, | ||
868 | notifier_error & (1 << pos) ); | ||
869 | active &= ~(1 << pos ); | ||
870 | } | ||
871 | } | 873 | } |
872 | } | 874 | } |
873 | } | 875 | } |
@@ -905,73 +907,12 @@ static void nv_adma_irq_clear(struct ata_port *ap) | |||
905 | iowrite8(ioread8(dma_stat_addr), dma_stat_addr); | 907 | iowrite8(ioread8(dma_stat_addr), dma_stat_addr); |
906 | } | 908 | } |
907 | 909 | ||
908 | static void nv_adma_bmdma_setup(struct ata_queued_cmd *qc) | 910 | static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc) |
909 | { | ||
910 | struct ata_port *ap = qc->ap; | ||
911 | unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE); | ||
912 | struct nv_adma_port_priv *pp = ap->private_data; | ||
913 | u8 dmactl; | ||
914 | |||
915 | if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { | ||
916 | WARN_ON(1); | ||
917 | return; | ||
918 | } | ||
919 | |||
920 | /* load PRD table addr. */ | ||
921 | iowrite32(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS); | ||
922 | |||
923 | /* specify data direction, triple-check start bit is clear */ | ||
924 | dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | ||
925 | dmactl &= ~(ATA_DMA_WR | ATA_DMA_START); | ||
926 | if (!rw) | ||
927 | dmactl |= ATA_DMA_WR; | ||
928 | |||
929 | iowrite8(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | ||
930 | |||
931 | /* issue r/w command */ | ||
932 | ata_exec_command(ap, &qc->tf); | ||
933 | } | ||
934 | |||
935 | static void nv_adma_bmdma_start(struct ata_queued_cmd *qc) | ||
936 | { | ||
937 | struct ata_port *ap = qc->ap; | ||
938 | struct nv_adma_port_priv *pp = ap->private_data; | ||
939 | u8 dmactl; | ||
940 | |||
941 | if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) { | ||
942 | WARN_ON(1); | ||
943 | return; | ||
944 | } | ||
945 | |||
946 | /* start host DMA transaction */ | ||
947 | dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | ||
948 | iowrite8(dmactl | ATA_DMA_START, | ||
949 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | ||
950 | } | ||
951 | |||
952 | static void nv_adma_bmdma_stop(struct ata_queued_cmd *qc) | ||
953 | { | ||
954 | struct ata_port *ap = qc->ap; | ||
955 | struct nv_adma_port_priv *pp = ap->private_data; | ||
956 | |||
957 | if(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)) | ||
958 | return; | ||
959 | |||
960 | /* clear start/stop bit */ | ||
961 | iowrite8(ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START, | ||
962 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | ||
963 | |||
964 | /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ | ||
965 | ata_altstatus(ap); /* dummy read */ | ||
966 | } | ||
967 | |||
968 | static u8 nv_adma_bmdma_status(struct ata_port *ap) | ||
969 | { | 911 | { |
970 | struct nv_adma_port_priv *pp = ap->private_data; | 912 | struct nv_adma_port_priv *pp = qc->ap->private_data; |
971 | |||
972 | WARN_ON(!(pp->flags & NV_ADMA_PORT_REGISTER_MODE)); | ||
973 | 913 | ||
974 | return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 914 | if(pp->flags & NV_ADMA_PORT_REGISTER_MODE) |
915 | ata_bmdma_post_internal_cmd(qc); | ||
975 | } | 916 | } |
976 | 917 | ||
977 | static int nv_adma_port_start(struct ata_port *ap) | 918 | static int nv_adma_port_start(struct ata_port *ap) |
@@ -1040,14 +981,15 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
1040 | 981 | ||
1041 | /* clear GO for register mode, enable interrupt */ | 982 | /* clear GO for register mode, enable interrupt */ |
1042 | tmp = readw(mmio + NV_ADMA_CTL); | 983 | tmp = readw(mmio + NV_ADMA_CTL); |
1043 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL); | 984 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
985 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | ||
1044 | 986 | ||
1045 | tmp = readw(mmio + NV_ADMA_CTL); | 987 | tmp = readw(mmio + NV_ADMA_CTL); |
1046 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 988 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1047 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 989 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1048 | udelay(1); | 990 | udelay(1); |
1049 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 991 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1050 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 992 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1051 | 993 | ||
1052 | return 0; | 994 | return 0; |
1053 | } | 995 | } |
@@ -1099,14 +1041,15 @@ static int nv_adma_port_resume(struct ata_port *ap) | |||
1099 | 1041 | ||
1100 | /* clear GO for register mode, enable interrupt */ | 1042 | /* clear GO for register mode, enable interrupt */ |
1101 | tmp = readw(mmio + NV_ADMA_CTL); | 1043 | tmp = readw(mmio + NV_ADMA_CTL); |
1102 | writew((tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN, mmio + NV_ADMA_CTL); | 1044 | writew( (tmp & ~NV_ADMA_CTL_GO) | NV_ADMA_CTL_AIEN | |
1045 | NV_ADMA_CTL_HOTPLUG_IEN, mmio + NV_ADMA_CTL); | ||
1103 | 1046 | ||
1104 | tmp = readw(mmio + NV_ADMA_CTL); | 1047 | tmp = readw(mmio + NV_ADMA_CTL); |
1105 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1048 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1106 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1049 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1107 | udelay(1); | 1050 | udelay(1); |
1108 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1051 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1109 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1052 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1110 | 1053 | ||
1111 | return 0; | 1054 | return 0; |
1112 | } | 1055 | } |
@@ -1163,11 +1106,7 @@ static void nv_adma_fill_aprd(struct ata_queued_cmd *qc, | |||
1163 | int idx, | 1106 | int idx, |
1164 | struct nv_adma_prd *aprd) | 1107 | struct nv_adma_prd *aprd) |
1165 | { | 1108 | { |
1166 | u8 flags; | 1109 | u8 flags = 0; |
1167 | |||
1168 | memset(aprd, 0, sizeof(struct nv_adma_prd)); | ||
1169 | |||
1170 | flags = 0; | ||
1171 | if (qc->tf.flags & ATA_TFLAG_WRITE) | 1110 | if (qc->tf.flags & ATA_TFLAG_WRITE) |
1172 | flags |= NV_APRD_WRITE; | 1111 | flags |= NV_APRD_WRITE; |
1173 | if (idx == qc->n_elem - 1) | 1112 | if (idx == qc->n_elem - 1) |
@@ -1178,6 +1117,7 @@ static void nv_adma_fill_aprd(struct ata_queued_cmd *qc, | |||
1178 | aprd->addr = cpu_to_le64(((u64)sg_dma_address(sg))); | 1117 | aprd->addr = cpu_to_le64(((u64)sg_dma_address(sg))); |
1179 | aprd->len = cpu_to_le32(((u32)sg_dma_len(sg))); /* len in bytes */ | 1118 | aprd->len = cpu_to_le32(((u32)sg_dma_len(sg))); /* len in bytes */ |
1180 | aprd->flags = flags; | 1119 | aprd->flags = flags; |
1120 | aprd->packet_len = 0; | ||
1181 | } | 1121 | } |
1182 | 1122 | ||
1183 | static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) | 1123 | static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) |
@@ -1198,6 +1138,8 @@ static void nv_adma_fill_sg(struct ata_queued_cmd *qc, struct nv_adma_cpb *cpb) | |||
1198 | } | 1138 | } |
1199 | if (idx > 5) | 1139 | if (idx > 5) |
1200 | cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag))); | 1140 | cpb->next_aprd = cpu_to_le64(((u64)(pp->aprd_dma + NV_ADMA_SGTBL_SZ * qc->tag))); |
1141 | else | ||
1142 | cpb->next_aprd = cpu_to_le64(0); | ||
1201 | } | 1143 | } |
1202 | 1144 | ||
1203 | static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) | 1145 | static int nv_adma_use_reg_mode(struct ata_queued_cmd *qc) |
@@ -1230,7 +1172,10 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) | |||
1230 | return; | 1172 | return; |
1231 | } | 1173 | } |
1232 | 1174 | ||
1233 | memset(cpb, 0, sizeof(struct nv_adma_cpb)); | 1175 | cpb->resp_flags = NV_CPB_RESP_DONE; |
1176 | wmb(); | ||
1177 | cpb->ctl_flags = 0; | ||
1178 | wmb(); | ||
1234 | 1179 | ||
1235 | cpb->len = 3; | 1180 | cpb->len = 3; |
1236 | cpb->tag = qc->tag; | 1181 | cpb->tag = qc->tag; |
@@ -1254,12 +1199,15 @@ static void nv_adma_qc_prep(struct ata_queued_cmd *qc) | |||
1254 | finished filling in all of the contents */ | 1199 | finished filling in all of the contents */ |
1255 | wmb(); | 1200 | wmb(); |
1256 | cpb->ctl_flags = ctl_flags; | 1201 | cpb->ctl_flags = ctl_flags; |
1202 | wmb(); | ||
1203 | cpb->resp_flags = 0; | ||
1257 | } | 1204 | } |
1258 | 1205 | ||
1259 | static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) | 1206 | static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) |
1260 | { | 1207 | { |
1261 | struct nv_adma_port_priv *pp = qc->ap->private_data; | 1208 | struct nv_adma_port_priv *pp = qc->ap->private_data; |
1262 | void __iomem *mmio = pp->ctl_block; | 1209 | void __iomem *mmio = pp->ctl_block; |
1210 | int curr_ncq = (qc->tf.protocol == ATA_PROT_NCQ); | ||
1263 | 1211 | ||
1264 | VPRINTK("ENTER\n"); | 1212 | VPRINTK("ENTER\n"); |
1265 | 1213 | ||
@@ -1274,6 +1222,14 @@ static unsigned int nv_adma_qc_issue(struct ata_queued_cmd *qc) | |||
1274 | /* write append register, command tag in lower 8 bits | 1222 | /* write append register, command tag in lower 8 bits |
1275 | and (number of cpbs to append -1) in top 8 bits */ | 1223 | and (number of cpbs to append -1) in top 8 bits */ |
1276 | wmb(); | 1224 | wmb(); |
1225 | |||
1226 | if(curr_ncq != pp->last_issue_ncq) { | ||
1227 | /* Seems to need some delay before switching between NCQ and non-NCQ | ||
1228 | commands, else we get command timeouts and such. */ | ||
1229 | udelay(20); | ||
1230 | pp->last_issue_ncq = curr_ncq; | ||
1231 | } | ||
1232 | |||
1277 | writew(qc->tag, mmio + NV_ADMA_APPEND); | 1233 | writew(qc->tag, mmio + NV_ADMA_APPEND); |
1278 | 1234 | ||
1279 | DPRINTK("Issued tag %u\n",qc->tag); | 1235 | DPRINTK("Issued tag %u\n",qc->tag); |
@@ -1447,6 +1403,30 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1447 | int i; | 1403 | int i; |
1448 | u16 tmp; | 1404 | u16 tmp; |
1449 | 1405 | ||
1406 | if(ata_tag_valid(ap->active_tag) || ap->sactive) { | ||
1407 | u32 notifier = readl(mmio + NV_ADMA_NOTIFIER); | ||
1408 | u32 notifier_error = readl(mmio + NV_ADMA_NOTIFIER_ERROR); | ||
1409 | u32 gen_ctl = readl(pp->gen_block + NV_ADMA_GEN_CTL); | ||
1410 | u32 status = readw(mmio + NV_ADMA_STAT); | ||
1411 | u8 cpb_count = readb(mmio + NV_ADMA_CPB_COUNT); | ||
1412 | u8 next_cpb_idx = readb(mmio + NV_ADMA_NEXT_CPB_IDX); | ||
1413 | |||
1414 | ata_port_printk(ap, KERN_ERR, "EH in ADMA mode, notifier 0x%X " | ||
1415 | "notifier_error 0x%X gen_ctl 0x%X status 0x%X " | ||
1416 | "next cpb count 0x%X next cpb idx 0x%x\n", | ||
1417 | notifier, notifier_error, gen_ctl, status, | ||
1418 | cpb_count, next_cpb_idx); | ||
1419 | |||
1420 | for( i=0;i<NV_ADMA_MAX_CPBS;i++) { | ||
1421 | struct nv_adma_cpb *cpb = &pp->cpb[i]; | ||
1422 | if( (ata_tag_valid(ap->active_tag) && i == ap->active_tag) || | ||
1423 | ap->sactive & (1 << i) ) | ||
1424 | ata_port_printk(ap, KERN_ERR, | ||
1425 | "CPB %d: ctl_flags 0x%x, resp_flags 0x%x\n", | ||
1426 | i, cpb->ctl_flags, cpb->resp_flags); | ||
1427 | } | ||
1428 | } | ||
1429 | |||
1450 | /* Push us back into port register mode for error handling. */ | 1430 | /* Push us back into port register mode for error handling. */ |
1451 | nv_adma_register_mode(ap); | 1431 | nv_adma_register_mode(ap); |
1452 | 1432 | ||
@@ -1460,10 +1440,10 @@ static void nv_adma_error_handler(struct ata_port *ap) | |||
1460 | /* Reset channel */ | 1440 | /* Reset channel */ |
1461 | tmp = readw(mmio + NV_ADMA_CTL); | 1441 | tmp = readw(mmio + NV_ADMA_CTL); |
1462 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1442 | writew(tmp | NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1463 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1443 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1464 | udelay(1); | 1444 | udelay(1); |
1465 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); | 1445 | writew(tmp & ~NV_ADMA_CTL_CHANNEL_RESET, mmio + NV_ADMA_CTL); |
1466 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 1446 | readw( mmio + NV_ADMA_CTL ); /* flush posted write */ |
1467 | } | 1447 | } |
1468 | 1448 | ||
1469 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, | 1449 | ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index cf9ed8c39301..2339813ce9f6 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #include "sata_promise.h" | 45 | #include "sata_promise.h" |
46 | 46 | ||
47 | #define DRV_NAME "sata_promise" | 47 | #define DRV_NAME "sata_promise" |
48 | #define DRV_VERSION "1.05" | 48 | #define DRV_VERSION "2.00" |
49 | 49 | ||
50 | 50 | ||
51 | enum { | 51 | enum { |
@@ -218,6 +218,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
218 | .freeze = pdc_freeze, | 218 | .freeze = pdc_freeze, |
219 | .thaw = pdc_thaw, | 219 | .thaw = pdc_thaw, |
220 | .error_handler = pdc_error_handler, | 220 | .error_handler = pdc_error_handler, |
221 | .post_internal_cmd = pdc_post_internal_cmd, | ||
221 | .data_xfer = ata_data_xfer, | 222 | .data_xfer = ata_data_xfer, |
222 | .irq_handler = pdc_interrupt, | 223 | .irq_handler = pdc_interrupt, |
223 | .irq_clear = pdc_irq_clear, | 224 | .irq_clear = pdc_irq_clear, |
@@ -776,7 +777,8 @@ static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc) | |||
776 | return pdc_check_atapi_dma(qc); | 777 | return pdc_check_atapi_dma(qc); |
777 | } | 778 | } |
778 | 779 | ||
779 | static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base) | 780 | static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base, |
781 | void __iomem *scr_addr) | ||
780 | { | 782 | { |
781 | port->cmd_addr = base; | 783 | port->cmd_addr = base; |
782 | port->data_addr = base; | 784 | port->data_addr = base; |
@@ -791,6 +793,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base) | |||
791 | port->status_addr = base + 0x1c; | 793 | port->status_addr = base + 0x1c; |
792 | port->altstatus_addr = | 794 | port->altstatus_addr = |
793 | port->ctl_addr = base + 0x38; | 795 | port->ctl_addr = base + 0x38; |
796 | port->scr_addr = scr_addr; | ||
794 | } | 797 | } |
795 | 798 | ||
796 | 799 | ||
@@ -903,11 +906,8 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
903 | 906 | ||
904 | base = probe_ent->iomap[PDC_MMIO_BAR]; | 907 | base = probe_ent->iomap[PDC_MMIO_BAR]; |
905 | 908 | ||
906 | pdc_ata_setup_port(&probe_ent->port[0], base + 0x200); | 909 | pdc_ata_setup_port(&probe_ent->port[0], base + 0x200, base + 0x400); |
907 | pdc_ata_setup_port(&probe_ent->port[1], base + 0x280); | 910 | pdc_ata_setup_port(&probe_ent->port[1], base + 0x280, base + 0x500); |
908 | |||
909 | probe_ent->port[0].scr_addr = base + 0x400; | ||
910 | probe_ent->port[1].scr_addr = base + 0x500; | ||
911 | 911 | ||
912 | /* notice 4-port boards */ | 912 | /* notice 4-port boards */ |
913 | switch (board_idx) { | 913 | switch (board_idx) { |
@@ -916,12 +916,8 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
916 | /* Fall through */ | 916 | /* Fall through */ |
917 | case board_20319: | 917 | case board_20319: |
918 | probe_ent->n_ports = 4; | 918 | probe_ent->n_ports = 4; |
919 | 919 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, base + 0x600); | |
920 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); | 920 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380, base + 0x700); |
921 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380); | ||
922 | |||
923 | probe_ent->port[2].scr_addr = base + 0x600; | ||
924 | probe_ent->port[3].scr_addr = base + 0x700; | ||
925 | break; | 921 | break; |
926 | case board_2057x: | 922 | case board_2057x: |
927 | hp->flags |= PDC_FLAG_GEN_II; | 923 | hp->flags |= PDC_FLAG_GEN_II; |
@@ -931,7 +927,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
931 | tmp = readb(base + PDC_FLASH_CTL+1); | 927 | tmp = readb(base + PDC_FLASH_CTL+1); |
932 | if (!(tmp & 0x80)) { | 928 | if (!(tmp & 0x80)) { |
933 | probe_ent->n_ports = 3; | 929 | probe_ent->n_ports = 3; |
934 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); | 930 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, NULL); |
935 | hp->port_flags[2] = ATA_FLAG_SLAVE_POSS; | 931 | hp->port_flags[2] = ATA_FLAG_SLAVE_POSS; |
936 | printk(KERN_INFO DRV_NAME " PATA port found\n"); | 932 | printk(KERN_INFO DRV_NAME " PATA port found\n"); |
937 | } else | 933 | } else |
@@ -941,12 +937,8 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
941 | break; | 937 | break; |
942 | case board_20619: | 938 | case board_20619: |
943 | probe_ent->n_ports = 4; | 939 | probe_ent->n_ports = 4; |
944 | 940 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300, NULL); | |
945 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); | 941 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380, NULL); |
946 | pdc_ata_setup_port(&probe_ent->port[3], base + 0x380); | ||
947 | |||
948 | probe_ent->port[2].scr_addr = base + 0x600; | ||
949 | probe_ent->port[3].scr_addr = base + 0x700; | ||
950 | break; | 942 | break; |
951 | default: | 943 | default: |
952 | BUG(); | 944 | BUG(); |
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index 6097d8f2a0c0..8786b45f291b 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/libata.h> | 39 | #include <linux/libata.h> |
40 | 40 | ||
41 | #define DRV_NAME "sata_qstor" | 41 | #define DRV_NAME "sata_qstor" |
42 | #define DRV_VERSION "0.06" | 42 | #define DRV_VERSION "0.07" |
43 | 43 | ||
44 | enum { | 44 | enum { |
45 | QS_MMIO_BAR = 4, | 45 | QS_MMIO_BAR = 4, |
@@ -446,7 +446,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host *host) | |||
446 | if ((status & ATA_BUSY)) | 446 | if ((status & ATA_BUSY)) |
447 | continue; | 447 | continue; |
448 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", | 448 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", |
449 | ap->id, qc->tf.protocol, status); | 449 | ap->print_id, qc->tf.protocol, status); |
450 | 450 | ||
451 | /* complete taskfile transaction */ | 451 | /* complete taskfile transaction */ |
452 | pp->state = qs_state_idle; | 452 | pp->state = qs_state_idle; |
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index dca3d3749f06..f7179c646bef 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "sata_sil" | 48 | #define DRV_NAME "sata_sil" |
49 | #define DRV_VERSION "2.0" | 49 | #define DRV_VERSION "2.1" |
50 | 50 | ||
51 | enum { | 51 | enum { |
52 | SIL_MMIO_BAR = 5, | 52 | SIL_MMIO_BAR = 5, |
@@ -339,7 +339,7 @@ static inline void __iomem *sil_scr_addr(struct ata_port *ap, unsigned int sc_re | |||
339 | break; | 339 | break; |
340 | } | 340 | } |
341 | 341 | ||
342 | return 0; | 342 | return NULL; |
343 | } | 343 | } |
344 | 344 | ||
345 | static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) | 345 | static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) |
@@ -386,9 +386,15 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2) | |||
386 | goto freeze; | 386 | goto freeze; |
387 | } | 387 | } |
388 | 388 | ||
389 | if (unlikely(!qc || qc->tf.ctl & ATA_NIEN)) | 389 | if (unlikely(!qc)) |
390 | goto freeze; | 390 | goto freeze; |
391 | 391 | ||
392 | if (unlikely(qc->tf.flags & ATA_TFLAG_POLLING)) { | ||
393 | /* this sometimes happens, just clear IRQ */ | ||
394 | ata_chk_status(ap); | ||
395 | return; | ||
396 | } | ||
397 | |||
392 | /* Check whether we are expecting interrupt in this state */ | 398 | /* Check whether we are expecting interrupt in this state */ |
393 | switch (ap->hsm_task_state) { | 399 | switch (ap->hsm_task_state) { |
394 | case HSM_ST_FIRST: | 400 | case HSM_ST_FIRST: |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index e65e8d55da3e..5d083f43f90d 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/libata.h> | 30 | #include <linux/libata.h> |
31 | 31 | ||
32 | #define DRV_NAME "sata_sil24" | 32 | #define DRV_NAME "sata_sil24" |
33 | #define DRV_VERSION "0.3" | 33 | #define DRV_VERSION "0.8" |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * Port request block (PRB) 32 bytes | 36 | * Port request block (PRB) 32 bytes |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index 49c9e2bd706f..1879e0cd56aa 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -40,9 +40,8 @@ | |||
40 | #include <linux/device.h> | 40 | #include <linux/device.h> |
41 | #include <scsi/scsi_host.h> | 41 | #include <scsi/scsi_host.h> |
42 | #include <linux/libata.h> | 42 | #include <linux/libata.h> |
43 | #include "libata.h" | 43 | #include "sis.h" |
44 | 44 | ||
45 | #undef DRV_NAME /* already defined in libata.h, for libata-core */ | ||
46 | #define DRV_NAME "sata_sis" | 45 | #define DRV_NAME "sata_sis" |
47 | #define DRV_VERSION "0.7" | 46 | #define DRV_VERSION "0.7" |
48 | 47 | ||
@@ -310,7 +309,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
310 | case 0x10: | 309 | case 0x10: |
311 | ppi[1] = &sis_info133; | 310 | ppi[1] = &sis_info133; |
312 | break; | 311 | break; |
313 | 312 | ||
314 | case 0x30: | 313 | case 0x30: |
315 | ppi[0] = &sis_info133; | 314 | ppi[0] = &sis_info133; |
316 | break; | 315 | break; |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 4e4289994204..b121195cc598 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #endif /* CONFIG_PPC_OF */ | 53 | #endif /* CONFIG_PPC_OF */ |
54 | 54 | ||
55 | #define DRV_NAME "sata_svw" | 55 | #define DRV_NAME "sata_svw" |
56 | #define DRV_VERSION "2.0" | 56 | #define DRV_VERSION "2.1" |
57 | 57 | ||
58 | enum { | 58 | enum { |
59 | K2_FLAG_NO_ATAPI_DMA = (1 << 29), | 59 | K2_FLAG_NO_ATAPI_DMA = (1 << 29), |
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index 0ebd77b080d6..1a081c3a8c06 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include "sata_promise.h" | 44 | #include "sata_promise.h" |
45 | 45 | ||
46 | #define DRV_NAME "sata_sx4" | 46 | #define DRV_NAME "sata_sx4" |
47 | #define DRV_VERSION "0.9" | 47 | #define DRV_VERSION "0.10" |
48 | 48 | ||
49 | 49 | ||
50 | enum { | 50 | enum { |
@@ -421,7 +421,7 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc) | |||
421 | 421 | ||
422 | WARN_ON(!(qc->flags & ATA_QCFLAG_DMAMAP)); | 422 | WARN_ON(!(qc->flags & ATA_QCFLAG_DMAMAP)); |
423 | 423 | ||
424 | VPRINTK("ata%u: ENTER\n", ap->id); | 424 | VPRINTK("ata%u: ENTER\n", ap->print_id); |
425 | 425 | ||
426 | /* hard-code chip #0 */ | 426 | /* hard-code chip #0 */ |
427 | mmio += PDC_CHIP0_OFS; | 427 | mmio += PDC_CHIP0_OFS; |
@@ -478,7 +478,7 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc) | |||
478 | unsigned int portno = ap->port_no; | 478 | unsigned int portno = ap->port_no; |
479 | unsigned int i; | 479 | unsigned int i; |
480 | 480 | ||
481 | VPRINTK("ata%u: ENTER\n", ap->id); | 481 | VPRINTK("ata%u: ENTER\n", ap->print_id); |
482 | 482 | ||
483 | /* hard-code chip #0 */ | 483 | /* hard-code chip #0 */ |
484 | mmio += PDC_CHIP0_OFS; | 484 | mmio += PDC_CHIP0_OFS; |
@@ -605,7 +605,7 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc) | |||
605 | /* hard-code chip #0 */ | 605 | /* hard-code chip #0 */ |
606 | mmio += PDC_CHIP0_OFS; | 606 | mmio += PDC_CHIP0_OFS; |
607 | 607 | ||
608 | VPRINTK("ata%u: ENTER\n", ap->id); | 608 | VPRINTK("ata%u: ENTER\n", ap->print_id); |
609 | 609 | ||
610 | wmb(); /* flush PRD, pkt writes */ | 610 | wmb(); /* flush PRD, pkt writes */ |
611 | 611 | ||
@@ -672,7 +672,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
672 | 672 | ||
673 | /* step two - DMA from DIMM to host */ | 673 | /* step two - DMA from DIMM to host */ |
674 | if (doing_hdma) { | 674 | if (doing_hdma) { |
675 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, | 675 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->print_id, |
676 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 676 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
677 | /* get drive status; clear intr; complete txn */ | 677 | /* get drive status; clear intr; complete txn */ |
678 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); | 678 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
@@ -683,7 +683,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
683 | /* step one - exec ATA command */ | 683 | /* step one - exec ATA command */ |
684 | else { | 684 | else { |
685 | u8 seq = (u8) (port_no + 1 + 4); | 685 | u8 seq = (u8) (port_no + 1 + 4); |
686 | VPRINTK("ata%u: read ata, 0x%x 0x%x\n", ap->id, | 686 | VPRINTK("ata%u: read ata, 0x%x 0x%x\n", ap->print_id, |
687 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 687 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
688 | 688 | ||
689 | /* submit hdma pkt */ | 689 | /* submit hdma pkt */ |
@@ -698,7 +698,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
698 | /* step one - DMA from host to DIMM */ | 698 | /* step one - DMA from host to DIMM */ |
699 | if (doing_hdma) { | 699 | if (doing_hdma) { |
700 | u8 seq = (u8) (port_no + 1); | 700 | u8 seq = (u8) (port_no + 1); |
701 | VPRINTK("ata%u: write hdma, 0x%x 0x%x\n", ap->id, | 701 | VPRINTK("ata%u: write hdma, 0x%x 0x%x\n", ap->print_id, |
702 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 702 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
703 | 703 | ||
704 | /* submit ata pkt */ | 704 | /* submit ata pkt */ |
@@ -711,7 +711,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
711 | 711 | ||
712 | /* step two - execute ATA command */ | 712 | /* step two - execute ATA command */ |
713 | else { | 713 | else { |
714 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, | 714 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->print_id, |
715 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 715 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
716 | /* get drive status; clear intr; complete txn */ | 716 | /* get drive status; clear intr; complete txn */ |
717 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); | 717 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index 80131eec68f4..d659ace80f4f 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/libata.h> | 36 | #include <linux/libata.h> |
37 | 37 | ||
38 | #define DRV_NAME "sata_uli" | 38 | #define DRV_NAME "sata_uli" |
39 | #define DRV_VERSION "1.0" | 39 | #define DRV_VERSION "1.1" |
40 | 40 | ||
41 | enum { | 41 | enum { |
42 | uli_5289 = 0, | 42 | uli_5289 = 0, |
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index baca6d79bb0b..598e6a26a481 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "sata_via" | 48 | #define DRV_NAME "sata_via" |
49 | #define DRV_VERSION "2.0" | 49 | #define DRV_VERSION "2.1" |
50 | 50 | ||
51 | enum board_ids_enum { | 51 | enum board_ids_enum { |
52 | vt6420, | 52 | vt6420, |
@@ -60,7 +60,7 @@ enum { | |||
60 | SATA_PATA_SHARING = 0x49, /* PATA/SATA sharing func ctrl */ | 60 | SATA_PATA_SHARING = 0x49, /* PATA/SATA sharing func ctrl */ |
61 | PATA_UDMA_TIMING = 0xB3, /* PATA timing for DMA/ cable detect */ | 61 | PATA_UDMA_TIMING = 0xB3, /* PATA timing for DMA/ cable detect */ |
62 | PATA_PIO_TIMING = 0xAB, /* PATA timing register */ | 62 | PATA_PIO_TIMING = 0xAB, /* PATA timing register */ |
63 | 63 | ||
64 | PORT0 = (1 << 1), | 64 | PORT0 = (1 << 1), |
65 | PORT1 = (1 << 0), | 65 | PORT1 = (1 << 0), |
66 | ALL_PORTS = PORT0 | PORT1, | 66 | ALL_PORTS = PORT0 | PORT1, |
@@ -151,7 +151,7 @@ static const struct ata_port_operations vt6420_sata_ops = { | |||
151 | 151 | ||
152 | static const struct ata_port_operations vt6421_pata_ops = { | 152 | static const struct ata_port_operations vt6421_pata_ops = { |
153 | .port_disable = ata_port_disable, | 153 | .port_disable = ata_port_disable, |
154 | 154 | ||
155 | .set_piomode = vt6421_set_pio_mode, | 155 | .set_piomode = vt6421_set_pio_mode, |
156 | .set_dmamode = vt6421_set_dma_mode, | 156 | .set_dmamode = vt6421_set_dma_mode, |
157 | 157 | ||
@@ -185,7 +185,7 @@ static const struct ata_port_operations vt6421_pata_ops = { | |||
185 | 185 | ||
186 | static const struct ata_port_operations vt6421_sata_ops = { | 186 | static const struct ata_port_operations vt6421_sata_ops = { |
187 | .port_disable = ata_port_disable, | 187 | .port_disable = ata_port_disable, |
188 | 188 | ||
189 | .tf_load = ata_tf_load, | 189 | .tf_load = ata_tf_load, |
190 | .tf_read = ata_tf_read, | 190 | .tf_read = ata_tf_read, |
191 | .check_status = ata_check_status, | 191 | .check_status = ata_check_status, |
@@ -423,16 +423,21 @@ static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev) | |||
423 | { | 423 | { |
424 | struct ata_probe_ent *probe_ent; | 424 | struct ata_probe_ent *probe_ent; |
425 | struct ata_port_info *ppi[2]; | 425 | struct ata_port_info *ppi[2]; |
426 | void __iomem * const *iomap; | 426 | void __iomem *bar5; |
427 | 427 | ||
428 | ppi[0] = ppi[1] = &vt6420_port_info; | 428 | ppi[0] = ppi[1] = &vt6420_port_info; |
429 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 429 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
430 | if (!probe_ent) | 430 | if (!probe_ent) |
431 | return NULL; | 431 | return NULL; |
432 | 432 | ||
433 | iomap = pcim_iomap_table(pdev); | 433 | bar5 = pcim_iomap(pdev, 5, 0); |
434 | probe_ent->port[0].scr_addr = svia_scr_addr(iomap[5], 0); | 434 | if (!bar5) { |
435 | probe_ent->port[1].scr_addr = svia_scr_addr(iomap[5], 1); | 435 | dev_printk(KERN_ERR, &pdev->dev, "failed to iomap PCI BAR 5\n"); |
436 | return NULL; | ||
437 | } | ||
438 | |||
439 | probe_ent->port[0].scr_addr = svia_scr_addr(bar5, 0); | ||
440 | probe_ent->port[1].scr_addr = svia_scr_addr(bar5, 1); | ||
436 | 441 | ||
437 | return probe_ent; | 442 | return probe_ent; |
438 | } | 443 | } |
@@ -460,6 +465,13 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev) | |||
460 | probe_ent->mwdma_mask = 0x07; | 465 | probe_ent->mwdma_mask = 0x07; |
461 | probe_ent->udma_mask = 0x7f; | 466 | probe_ent->udma_mask = 0x7f; |
462 | 467 | ||
468 | for (i = 0; i < 6; i++) | ||
469 | if (!pcim_iomap(pdev, i, 0)) { | ||
470 | dev_printk(KERN_ERR, &pdev->dev, | ||
471 | "failed to iomap PCI BAR %d\n", i); | ||
472 | return NULL; | ||
473 | } | ||
474 | |||
463 | for (i = 0; i < N_PORTS; i++) | 475 | for (i = 0; i < N_PORTS; i++) |
464 | vt6421_init_addrs(probe_ent, pcim_iomap_table(pdev), i); | 476 | vt6421_init_addrs(probe_ent, pcim_iomap_table(pdev), i); |
465 | 477 | ||
@@ -522,7 +534,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
522 | if (rc) | 534 | if (rc) |
523 | return rc; | 535 | return rc; |
524 | 536 | ||
525 | rc = pcim_iomap_regions(pdev, 0x1f, DRV_NAME); | 537 | rc = pci_request_regions(pdev, DRV_NAME); |
526 | if (rc) { | 538 | if (rc) { |
527 | pcim_pin_device(pdev); | 539 | pcim_pin_device(pdev); |
528 | return rc; | 540 | return rc; |
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 2fd037bde090..170bad1b415b 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
48 | 48 | ||
49 | #define DRV_NAME "sata_vsc" | 49 | #define DRV_NAME "sata_vsc" |
50 | #define DRV_VERSION "2.0" | 50 | #define DRV_VERSION "2.1" |
51 | 51 | ||
52 | enum { | 52 | enum { |
53 | VSC_MMIO_BAR = 0, | 53 | VSC_MMIO_BAR = 0, |
@@ -98,10 +98,6 @@ enum { | |||
98 | VSC_SATA_INT_PHY_CHANGE), | 98 | VSC_SATA_INT_PHY_CHANGE), |
99 | }; | 99 | }; |
100 | 100 | ||
101 | #define is_vsc_sata_int_err(port_idx, int_status) \ | ||
102 | (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx))) | ||
103 | |||
104 | |||
105 | static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | 101 | static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) |
106 | { | 102 | { |
107 | if (sc_reg > SCR_CONTROL) | 103 | if (sc_reg > SCR_CONTROL) |
@@ -119,6 +115,28 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, | |||
119 | } | 115 | } |
120 | 116 | ||
121 | 117 | ||
118 | static void vsc_freeze(struct ata_port *ap) | ||
119 | { | ||
120 | void __iomem *mask_addr; | ||
121 | |||
122 | mask_addr = ap->host->iomap[VSC_MMIO_BAR] + | ||
123 | VSC_SATA_INT_MASK_OFFSET + ap->port_no; | ||
124 | |||
125 | writeb(0, mask_addr); | ||
126 | } | ||
127 | |||
128 | |||
129 | static void vsc_thaw(struct ata_port *ap) | ||
130 | { | ||
131 | void __iomem *mask_addr; | ||
132 | |||
133 | mask_addr = ap->host->iomap[VSC_MMIO_BAR] + | ||
134 | VSC_SATA_INT_MASK_OFFSET + ap->port_no; | ||
135 | |||
136 | writeb(0xff, mask_addr); | ||
137 | } | ||
138 | |||
139 | |||
122 | static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) | 140 | static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) |
123 | { | 141 | { |
124 | void __iomem *mask_addr; | 142 | void __iomem *mask_addr; |
@@ -203,6 +221,36 @@ static void vsc_sata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
203 | } | 221 | } |
204 | } | 222 | } |
205 | 223 | ||
224 | static inline void vsc_error_intr(u8 port_status, struct ata_port *ap) | ||
225 | { | ||
226 | if (port_status & (VSC_SATA_INT_PHY_CHANGE | VSC_SATA_INT_ERROR_M)) | ||
227 | ata_port_freeze(ap); | ||
228 | else | ||
229 | ata_port_abort(ap); | ||
230 | } | ||
231 | |||
232 | static void vsc_port_intr(u8 port_status, struct ata_port *ap) | ||
233 | { | ||
234 | struct ata_queued_cmd *qc; | ||
235 | int handled = 0; | ||
236 | |||
237 | if (unlikely(port_status & VSC_SATA_INT_ERROR)) { | ||
238 | vsc_error_intr(port_status, ap); | ||
239 | return; | ||
240 | } | ||
241 | |||
242 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
243 | if (qc && likely(!(qc->tf.flags & ATA_TFLAG_POLLING))) | ||
244 | handled = ata_host_intr(ap, qc); | ||
245 | |||
246 | /* We received an interrupt during a polled command, | ||
247 | * or some other spurious condition. Interrupt reporting | ||
248 | * with this hardware is fairly reliable so it is safe to | ||
249 | * simply clear the interrupt | ||
250 | */ | ||
251 | if (unlikely(!handled)) | ||
252 | ata_chk_status(ap); | ||
253 | } | ||
206 | 254 | ||
207 | /* | 255 | /* |
208 | * vsc_sata_interrupt | 256 | * vsc_sata_interrupt |
@@ -214,59 +262,36 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance) | |||
214 | struct ata_host *host = dev_instance; | 262 | struct ata_host *host = dev_instance; |
215 | unsigned int i; | 263 | unsigned int i; |
216 | unsigned int handled = 0; | 264 | unsigned int handled = 0; |
217 | u32 int_status; | 265 | u32 status; |
218 | |||
219 | spin_lock(&host->lock); | ||
220 | 266 | ||
221 | int_status = readl(host->iomap[VSC_MMIO_BAR] + | 267 | status = readl(host->iomap[VSC_MMIO_BAR] + VSC_SATA_INT_STAT_OFFSET); |
222 | VSC_SATA_INT_STAT_OFFSET); | ||
223 | 268 | ||
224 | for (i = 0; i < host->n_ports; i++) { | 269 | if (unlikely(status == 0xffffffff || status == 0)) { |
225 | if (int_status & ((u32) 0xFF << (8 * i))) { | 270 | if (status) |
226 | struct ata_port *ap; | 271 | dev_printk(KERN_ERR, host->dev, |
272 | ": IRQ status == 0xffffffff, " | ||
273 | "PCI fault or device removal?\n"); | ||
274 | goto out; | ||
275 | } | ||
227 | 276 | ||
228 | ap = host->ports[i]; | 277 | spin_lock(&host->lock); |
229 | 278 | ||
230 | if (is_vsc_sata_int_err(i, int_status)) { | 279 | for (i = 0; i < host->n_ports; i++) { |
231 | u32 err_status; | 280 | u8 port_status = (status >> (8 * i)) & 0xff; |
232 | printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); | 281 | if (port_status) { |
233 | err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0; | 282 | struct ata_port *ap = host->ports[i]; |
234 | vsc_sata_scr_write(ap, SCR_ERROR, err_status); | ||
235 | handled++; | ||
236 | } | ||
237 | 283 | ||
238 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { | 284 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { |
239 | struct ata_queued_cmd *qc; | 285 | vsc_port_intr(port_status, ap); |
240 | 286 | handled++; | |
241 | qc = ata_qc_from_tag(ap, ap->active_tag); | 287 | } else |
242 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) | 288 | dev_printk(KERN_ERR, host->dev, |
243 | handled += ata_host_intr(ap, qc); | 289 | ": interrupt from disabled port %d\n", i); |
244 | else if (is_vsc_sata_int_err(i, int_status)) { | ||
245 | /* | ||
246 | * On some chips (i.e. Intel 31244), an error | ||
247 | * interrupt will sneak in at initialization | ||
248 | * time (phy state changes). Clearing the SCR | ||
249 | * error register is not required, but it prevents | ||
250 | * the phy state change interrupts from recurring | ||
251 | * later. | ||
252 | */ | ||
253 | u32 err_status; | ||
254 | err_status = vsc_sata_scr_read(ap, SCR_ERROR); | ||
255 | printk(KERN_DEBUG "%s: clearing interrupt, " | ||
256 | "status %x; sata err status %x\n", | ||
257 | __FUNCTION__, | ||
258 | int_status, err_status); | ||
259 | vsc_sata_scr_write(ap, SCR_ERROR, err_status); | ||
260 | /* Clear interrupt status */ | ||
261 | ata_chk_status(ap); | ||
262 | handled++; | ||
263 | } | ||
264 | } | ||
265 | } | 290 | } |
266 | } | 291 | } |
267 | 292 | ||
268 | spin_unlock(&host->lock); | 293 | spin_unlock(&host->lock); |
269 | 294 | out: | |
270 | return IRQ_RETVAL(handled); | 295 | return IRQ_RETVAL(handled); |
271 | } | 296 | } |
272 | 297 | ||
@@ -304,8 +329,8 @@ static const struct ata_port_operations vsc_sata_ops = { | |||
304 | .qc_prep = ata_qc_prep, | 329 | .qc_prep = ata_qc_prep, |
305 | .qc_issue = ata_qc_issue_prot, | 330 | .qc_issue = ata_qc_issue_prot, |
306 | .data_xfer = ata_data_xfer, | 331 | .data_xfer = ata_data_xfer, |
307 | .freeze = ata_bmdma_freeze, | 332 | .freeze = vsc_freeze, |
308 | .thaw = ata_bmdma_thaw, | 333 | .thaw = vsc_thaw, |
309 | .error_handler = ata_bmdma_error_handler, | 334 | .error_handler = ata_bmdma_error_handler, |
310 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | 335 | .post_internal_cmd = ata_bmdma_post_internal_cmd, |
311 | .irq_handler = vsc_sata_interrupt, | 336 | .irq_handler = vsc_sata_interrupt, |
diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h new file mode 100644 index 000000000000..231da8fc2200 --- /dev/null +++ b/drivers/ata/sis.h | |||
@@ -0,0 +1,5 @@ | |||
1 | |||
2 | struct ata_port_info; | ||
3 | |||
4 | /* pata_sis.c */ | ||
5 | extern struct ata_port_info sis_info133; | ||
diff --git a/include/linux/ata.h b/include/linux/ata.h index 272736e37990..c331da2da5f7 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -282,7 +282,6 @@ struct ata_taskfile { | |||
282 | }; | 282 | }; |
283 | 283 | ||
284 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) | 284 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) |
285 | #define ata_id_is_sata(id) ((id)[93] == 0) | ||
286 | #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) | 285 | #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) |
287 | #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) | 286 | #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) |
288 | #define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10)) | 287 | #define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10)) |
@@ -324,6 +323,11 @@ static inline unsigned int ata_id_major_version(const u16 *id) | |||
324 | return mver; | 323 | return mver; |
325 | } | 324 | } |
326 | 325 | ||
326 | static inline int ata_id_is_sata(const u16 *id) | ||
327 | { | ||
328 | return ata_id_major_version(id) >= 5 && id[93] == 0; | ||
329 | } | ||
330 | |||
327 | static inline int ata_id_current_chs_valid(const u16 *id) | 331 | static inline int ata_id_current_chs_valid(const u16 *id) |
328 | { | 332 | { |
329 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command | 333 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command |
@@ -350,7 +354,7 @@ static inline int ata_id_is_cfa(const u16 *id) | |||
350 | 354 | ||
351 | static inline int ata_drive_40wire(const u16 *dev_id) | 355 | static inline int ata_drive_40wire(const u16 *dev_id) |
352 | { | 356 | { |
353 | if (ata_id_major_version(dev_id) >= 5 && ata_id_is_sata(dev_id)) | 357 | if (ata_id_is_sata(dev_id)) |
354 | return 0; /* SATA */ | 358 | return 0; /* SATA */ |
355 | if ((dev_id[93] & 0xE000) == 0x6000) | 359 | if ((dev_id[93] & 0xE000) == 0x6000) |
356 | return 0; /* 80 wire */ | 360 | return 0; /* 80 wire */ |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 86762a9f52ba..045fb3a72d59 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -495,6 +495,7 @@ struct ata_device { | |||
495 | 495 | ||
496 | /* error history */ | 496 | /* error history */ |
497 | struct ata_ering ering; | 497 | struct ata_ering ering; |
498 | int spdn_cnt; | ||
498 | unsigned int horkage; /* List of broken features */ | 499 | unsigned int horkage; /* List of broken features */ |
499 | #ifdef CONFIG_SATA_ACPI | 500 | #ifdef CONFIG_SATA_ACPI |
500 | /* ACPI objects info */ | 501 | /* ACPI objects info */ |
@@ -535,8 +536,8 @@ struct ata_port { | |||
535 | spinlock_t *lock; | 536 | spinlock_t *lock; |
536 | unsigned long flags; /* ATA_FLAG_xxx */ | 537 | unsigned long flags; /* ATA_FLAG_xxx */ |
537 | unsigned int pflags; /* ATA_PFLAG_xxx */ | 538 | unsigned int pflags; /* ATA_PFLAG_xxx */ |
538 | unsigned int id; /* unique id req'd by scsi midlyr */ | 539 | unsigned int print_id; /* user visible unique port ID */ |
539 | unsigned int port_no; /* unique port #; from zero */ | 540 | unsigned int port_no; /* 0 based port no. inside the host */ |
540 | 541 | ||
541 | struct ata_prd *prd; /* our SG list */ | 542 | struct ata_prd *prd; /* our SG list */ |
542 | dma_addr_t prd_dma; /* and its DMA mapping */ | 543 | dma_addr_t prd_dma; /* and its DMA mapping */ |
@@ -759,6 +760,7 @@ extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, | |||
759 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | 760 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, |
760 | unsigned long interval_msec, | 761 | unsigned long interval_msec, |
761 | unsigned long timeout_msec); | 762 | unsigned long timeout_msec); |
763 | extern unsigned int ata_dev_try_classify(struct ata_port *, unsigned int, u8 *); | ||
762 | 764 | ||
763 | /* | 765 | /* |
764 | * Default driver ops implementations | 766 | * Default driver ops implementations |
@@ -786,10 +788,12 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, | |||
786 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 788 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
787 | unsigned int n_elem); | 789 | unsigned int n_elem); |
788 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); | 790 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); |
791 | extern void ata_dev_disable(struct ata_device *adev); | ||
789 | extern void ata_id_string(const u16 *id, unsigned char *s, | 792 | extern void ata_id_string(const u16 *id, unsigned char *s, |
790 | unsigned int ofs, unsigned int len); | 793 | unsigned int ofs, unsigned int len); |
791 | extern void ata_id_c_string(const u16 *id, unsigned char *s, | 794 | extern void ata_id_c_string(const u16 *id, unsigned char *s, |
792 | unsigned int ofs, unsigned int len); | 795 | unsigned int ofs, unsigned int len); |
796 | extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown); | ||
793 | extern unsigned long ata_device_blacklisted(const struct ata_device *dev); | 797 | extern unsigned long ata_device_blacklisted(const struct ata_device *dev); |
794 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); | 798 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); |
795 | extern void ata_bmdma_start (struct ata_queued_cmd *qc); | 799 | extern void ata_bmdma_start (struct ata_queued_cmd *qc); |
@@ -890,10 +894,10 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
890 | * printk helpers | 894 | * printk helpers |
891 | */ | 895 | */ |
892 | #define ata_port_printk(ap, lv, fmt, args...) \ | 896 | #define ata_port_printk(ap, lv, fmt, args...) \ |
893 | printk(lv"ata%u: "fmt, (ap)->id , ##args) | 897 | printk(lv"ata%u: "fmt, (ap)->print_id , ##args) |
894 | 898 | ||
895 | #define ata_dev_printk(dev, lv, fmt, args...) \ | 899 | #define ata_dev_printk(dev, lv, fmt, args...) \ |
896 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) | 900 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->print_id, (dev)->devno , ##args) |
897 | 901 | ||
898 | /* | 902 | /* |
899 | * ata_eh_info helpers | 903 | * ata_eh_info helpers |
@@ -1031,6 +1035,21 @@ static inline u8 ata_chk_status(struct ata_port *ap) | |||
1031 | return ap->ops->check_status(ap); | 1035 | return ap->ops->check_status(ap); |
1032 | } | 1036 | } |
1033 | 1037 | ||
1038 | /** | ||
1039 | * ata_ncq_enabled - Test whether NCQ is enabled | ||
1040 | * @dev: ATA device to test for | ||
1041 | * | ||
1042 | * LOCKING: | ||
1043 | * spin_lock_irqsave(host lock) | ||
1044 | * | ||
1045 | * RETURNS: | ||
1046 | * 1 if NCQ is enabled for @dev, 0 otherwise. | ||
1047 | */ | ||
1048 | static inline int ata_ncq_enabled(struct ata_device *dev) | ||
1049 | { | ||
1050 | return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | | ||
1051 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; | ||
1052 | } | ||
1034 | 1053 | ||
1035 | /** | 1054 | /** |
1036 | * ata_pause - Flush writes and pause 400 nanoseconds. | 1055 | * ata_pause - Flush writes and pause 400 nanoseconds. |