aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-08-24 04:28:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-08-24 04:28:14 -0400
commit7bf13484d256e21b4bceb07026ac68dbae9dcce5 (patch)
tree37e76952178ff06eb9d2dc0314be4250ba1cd85b
parent20253de9d566f02b82aa1e0c103f73e80619106a (diff)
parentac2164d5e425fa4755bdbab9641d8dab7239b6f5 (diff)
Merge branch 'upstream-greg' of gregkh@master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
-rw-r--r--drivers/scsi/ata_piix.c84
-rw-r--r--drivers/scsi/libata-core.c2
-rw-r--r--drivers/scsi/pdc_adma.c3
-rw-r--r--drivers/scsi/sata_via.c117
4 files changed, 180 insertions, 26 deletions
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 5e8afc876980..2d20caf377f5 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -390,7 +390,8 @@ static struct ata_port_info piix_port_info[] = {
390 /* ich5_sata */ 390 /* ich5_sata */
391 { 391 {
392 .sht = &piix_sht, 392 .sht = &piix_sht,
393 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR, 393 .host_flags = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR |
394 PIIX_FLAG_IGNORE_PCS,
394 .pio_mask = 0x1f, /* pio0-4 */ 395 .pio_mask = 0x1f, /* pio0-4 */
395 .mwdma_mask = 0x07, /* mwdma0-2 */ 396 .mwdma_mask = 0x07, /* mwdma0-2 */
396 .udma_mask = 0x7f, /* udma0-6 */ 397 .udma_mask = 0x7f, /* udma0-6 */
@@ -467,6 +468,11 @@ MODULE_LICENSE("GPL");
467MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 468MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
468MODULE_VERSION(DRV_VERSION); 469MODULE_VERSION(DRV_VERSION);
469 470
471static int force_pcs = 0;
472module_param(force_pcs, int, 0444);
473MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
474 "device mis-detection (0=default, 1=ignore PCS, 2=honor PCS)");
475
470/** 476/**
471 * piix_pata_cbl_detect - Probe host controller cable detect info 477 * piix_pata_cbl_detect - Probe host controller cable detect info
472 * @ap: Port for which cable detect info is desired 478 * @ap: Port for which cable detect info is desired
@@ -531,27 +537,25 @@ static void piix_pata_error_handler(struct ata_port *ap)
531} 537}
532 538
533/** 539/**
534 * piix_sata_prereset - prereset for SATA host controller 540 * piix_sata_present_mask - determine present mask for SATA host controller
535 * @ap: Target port 541 * @ap: Target port
536 * 542 *
537 * Reads and configures SATA PCI device's PCI config register 543 * Reads SATA PCI device's PCI config register Port Configuration
538 * Port Configuration and Status (PCS) to determine port and 544 * and Status (PCS) to determine port and device availability.
539 * device availability. Return -ENODEV to skip reset if no
540 * device is present.
541 * 545 *
542 * LOCKING: 546 * LOCKING:
543 * None (inherited from caller). 547 * None (inherited from caller).
544 * 548 *
545 * RETURNS: 549 * RETURNS:
546 * 0 if device is present, -ENODEV otherwise. 550 * determined present_mask
547 */ 551 */
548static int piix_sata_prereset(struct ata_port *ap) 552static unsigned int piix_sata_present_mask(struct ata_port *ap)
549{ 553{
550 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); 554 struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
551 struct piix_host_priv *hpriv = ap->host_set->private_data; 555 struct piix_host_priv *hpriv = ap->host_set->private_data;
552 const unsigned int *map = hpriv->map; 556 const unsigned int *map = hpriv->map;
553 int base = 2 * ap->hard_port_no; 557 int base = 2 * ap->hard_port_no;
554 unsigned int present = 0; 558 unsigned int present_mask = 0;
555 int port, i; 559 int port, i;
556 u16 pcs; 560 u16 pcs;
557 561
@@ -564,24 +568,52 @@ static int piix_sata_prereset(struct ata_port *ap)
564 continue; 568 continue;
565 if ((ap->flags & PIIX_FLAG_IGNORE_PCS) || 569 if ((ap->flags & PIIX_FLAG_IGNORE_PCS) ||
566 (pcs & 1 << (hpriv->map_db->present_shift + port))) 570 (pcs & 1 << (hpriv->map_db->present_shift + port)))
567 present = 1; 571 present_mask |= 1 << i;
568 } 572 }
569 573
570 DPRINTK("ata%u: LEAVE, pcs=0x%x present=0x%x\n", 574 DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
571 ap->id, pcs, present); 575 ap->id, pcs, present_mask);
572 576
573 if (!present) { 577 return present_mask;
574 ata_port_printk(ap, KERN_INFO, "SATA port has no device.\n"); 578}
575 ap->eh_context.i.action &= ~ATA_EH_RESET_MASK; 579
576 return 0; 580/**
581 * piix_sata_softreset - reset SATA host port via ATA SRST
582 * @ap: port to reset
583 * @classes: resulting classes of attached devices
584 *
585 * Reset SATA host port via ATA SRST. On controllers with
586 * reliable PCS present bits, the bits are used to determine
587 * device presence.
588 *
589 * LOCKING:
590 * Kernel thread context (may sleep)
591 *
592 * RETURNS:
593 * 0 on success, -errno otherwise.
594 */
595static int piix_sata_softreset(struct ata_port *ap, unsigned int *classes)
596{
597 unsigned int present_mask;
598 int i, rc;
599
600 present_mask = piix_sata_present_mask(ap);
601
602 rc = ata_std_softreset(ap, classes);
603 if (rc)
604 return rc;
605
606 for (i = 0; i < ATA_MAX_DEVICES; i++) {
607 if (!(present_mask & (1 << i)))
608 classes[i] = ATA_DEV_NONE;
577 } 609 }
578 610
579 return ata_std_prereset(ap); 611 return 0;
580} 612}
581 613
582static void piix_sata_error_handler(struct ata_port *ap) 614static void piix_sata_error_handler(struct ata_port *ap)
583{ 615{
584 ata_bmdma_drive_eh(ap, piix_sata_prereset, ata_std_softreset, NULL, 616 ata_bmdma_drive_eh(ap, ata_std_prereset, piix_sata_softreset, NULL,
585 ata_std_postreset); 617 ata_std_postreset);
586} 618}
587 619
@@ -785,6 +817,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
785} 817}
786 818
787static void __devinit piix_init_pcs(struct pci_dev *pdev, 819static void __devinit piix_init_pcs(struct pci_dev *pdev,
820 struct ata_port_info *pinfo,
788 const struct piix_map_db *map_db) 821 const struct piix_map_db *map_db)
789{ 822{
790 u16 pcs, new_pcs; 823 u16 pcs, new_pcs;
@@ -798,6 +831,18 @@ static void __devinit piix_init_pcs(struct pci_dev *pdev,
798 pci_write_config_word(pdev, ICH5_PCS, new_pcs); 831 pci_write_config_word(pdev, ICH5_PCS, new_pcs);
799 msleep(150); 832 msleep(150);
800 } 833 }
834
835 if (force_pcs == 1) {
836 dev_printk(KERN_INFO, &pdev->dev,
837 "force ignoring PCS (0x%x)\n", new_pcs);
838 pinfo[0].host_flags |= PIIX_FLAG_IGNORE_PCS;
839 pinfo[1].host_flags |= PIIX_FLAG_IGNORE_PCS;
840 } else if (force_pcs == 2) {
841 dev_printk(KERN_INFO, &pdev->dev,
842 "force honoring PCS (0x%x)\n", new_pcs);
843 pinfo[0].host_flags &= ~PIIX_FLAG_IGNORE_PCS;
844 pinfo[1].host_flags &= ~PIIX_FLAG_IGNORE_PCS;
845 }
801} 846}
802 847
803static void __devinit piix_init_sata_map(struct pci_dev *pdev, 848static void __devinit piix_init_sata_map(struct pci_dev *pdev,
@@ -906,7 +951,8 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
906 if (host_flags & ATA_FLAG_SATA) { 951 if (host_flags & ATA_FLAG_SATA) {
907 piix_init_sata_map(pdev, port_info, 952 piix_init_sata_map(pdev, port_info,
908 piix_map_db_table[ent->driver_data]); 953 piix_map_db_table[ent->driver_data]);
909 piix_init_pcs(pdev, piix_map_db_table[ent->driver_data]); 954 piix_init_pcs(pdev, port_info,
955 piix_map_db_table[ent->driver_data]);
910 } 956 }
911 957
912 /* On ICH5, some BIOSen disable the interrupt using the 958 /* On ICH5, some BIOSen disable the interrupt using the
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 16fc2dd8f2f7..73dd6c8deede 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2746,7 +2746,7 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
2746 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol))) 2746 if ((rc = sata_scr_read(ap, SCR_CONTROL, &scontrol)))
2747 return rc; 2747 return rc;
2748 2748
2749 scontrol = (scontrol & 0x0f0) | 0x302; 2749 scontrol = (scontrol & 0x0f0) | 0x304;
2750 2750
2751 if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol))) 2751 if ((rc = sata_scr_write(ap, SCR_CONTROL, scontrol)))
2752 return rc; 2752 return rc;
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index d1f38c32aa15..efc8fff1d250 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -183,7 +183,8 @@ static struct ata_port_info adma_port_info[] = {
183 { 183 {
184 .sht = &adma_ata_sht, 184 .sht = &adma_ata_sht,
185 .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | 185 .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST |
186 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO, 186 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO |
187 ATA_FLAG_PIO_POLLING,
187 .pio_mask = 0x10, /* pio4 */ 188 .pio_mask = 0x10, /* pio4 */
188 .udma_mask = 0x1f, /* udma0-4 */ 189 .udma_mask = 0x1f, /* udma0-4 */
189 .port_ops = &adma_ata_ops, 190 .port_ops = &adma_ata_ops,
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 03baec2191bf..01d40369a8a5 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -74,6 +74,7 @@ enum {
74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 74static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg); 75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg);
76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
77static void vt6420_error_handler(struct ata_port *ap);
77 78
78static const struct pci_device_id svia_pci_tbl[] = { 79static const struct pci_device_id svia_pci_tbl[] = {
79 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 }, 80 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 },
@@ -107,7 +108,38 @@ static struct scsi_host_template svia_sht = {
107 .bios_param = ata_std_bios_param, 108 .bios_param = ata_std_bios_param,
108}; 109};
109 110
110static const struct ata_port_operations svia_sata_ops = { 111static const struct ata_port_operations vt6420_sata_ops = {
112 .port_disable = ata_port_disable,
113
114 .tf_load = ata_tf_load,
115 .tf_read = ata_tf_read,
116 .check_status = ata_check_status,
117 .exec_command = ata_exec_command,
118 .dev_select = ata_std_dev_select,
119
120 .bmdma_setup = ata_bmdma_setup,
121 .bmdma_start = ata_bmdma_start,
122 .bmdma_stop = ata_bmdma_stop,
123 .bmdma_status = ata_bmdma_status,
124
125 .qc_prep = ata_qc_prep,
126 .qc_issue = ata_qc_issue_prot,
127 .data_xfer = ata_pio_data_xfer,
128
129 .freeze = ata_bmdma_freeze,
130 .thaw = ata_bmdma_thaw,
131 .error_handler = vt6420_error_handler,
132 .post_internal_cmd = ata_bmdma_post_internal_cmd,
133
134 .irq_handler = ata_interrupt,
135 .irq_clear = ata_bmdma_irq_clear,
136
137 .port_start = ata_port_start,
138 .port_stop = ata_port_stop,
139 .host_stop = ata_host_stop,
140};
141
142static const struct ata_port_operations vt6421_sata_ops = {
111 .port_disable = ata_port_disable, 143 .port_disable = ata_port_disable,
112 144
113 .tf_load = ata_tf_load, 145 .tf_load = ata_tf_load,
@@ -141,13 +173,13 @@ static const struct ata_port_operations svia_sata_ops = {
141 .host_stop = ata_host_stop, 173 .host_stop = ata_host_stop,
142}; 174};
143 175
144static struct ata_port_info svia_port_info = { 176static struct ata_port_info vt6420_port_info = {
145 .sht = &svia_sht, 177 .sht = &svia_sht,
146 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 178 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
147 .pio_mask = 0x1f, 179 .pio_mask = 0x1f,
148 .mwdma_mask = 0x07, 180 .mwdma_mask = 0x07,
149 .udma_mask = 0x7f, 181 .udma_mask = 0x7f,
150 .port_ops = &svia_sata_ops, 182 .port_ops = &vt6420_sata_ops,
151}; 183};
152 184
153MODULE_AUTHOR("Jeff Garzik"); 185MODULE_AUTHOR("Jeff Garzik");
@@ -170,6 +202,81 @@ static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
170 outl(val, ap->ioaddr.scr_addr + (4 * sc_reg)); 202 outl(val, ap->ioaddr.scr_addr + (4 * sc_reg));
171} 203}
172 204
205/**
206 * vt6420_prereset - prereset for vt6420
207 * @ap: target ATA port
208 *
209 * SCR registers on vt6420 are pieces of shit and may hang the
210 * whole machine completely if accessed with the wrong timing.
211 * To avoid such catastrophe, vt6420 doesn't provide generic SCR
212 * access operations, but uses SStatus and SControl only during
213 * boot probing in controlled way.
214 *
215 * As the old (pre EH update) probing code is proven to work, we
216 * strictly follow the access pattern.
217 *
218 * LOCKING:
219 * Kernel thread context (may sleep)
220 *
221 * RETURNS:
222 * 0 on success, -errno otherwise.
223 */
224static int vt6420_prereset(struct ata_port *ap)
225{
226 struct ata_eh_context *ehc = &ap->eh_context;
227 unsigned long timeout = jiffies + (HZ * 5);
228 u32 sstatus, scontrol;
229 int online;
230
231 /* don't do any SCR stuff if we're not loading */
232 if (!ATA_PFLAG_LOADING)
233 goto skip_scr;
234
235 /* Resume phy. This is the old resume sequence from
236 * __sata_phy_reset().
237 */
238 svia_scr_write(ap, SCR_CONTROL, 0x300);
239 svia_scr_read(ap, SCR_CONTROL); /* flush */
240
241 /* wait for phy to become ready, if necessary */
242 do {
243 msleep(200);
244 if ((svia_scr_read(ap, SCR_STATUS) & 0xf) != 1)
245 break;
246 } while (time_before(jiffies, timeout));
247
248 /* open code sata_print_link_status() */
249 sstatus = svia_scr_read(ap, SCR_STATUS);
250 scontrol = svia_scr_read(ap, SCR_CONTROL);
251
252 online = (sstatus & 0xf) == 0x3;
253
254 ata_port_printk(ap, KERN_INFO,
255 "SATA link %s 1.5 Gbps (SStatus %X SControl %X)\n",
256 online ? "up" : "down", sstatus, scontrol);
257
258 /* SStatus is read one more time */
259 svia_scr_read(ap, SCR_STATUS);
260
261 if (!online) {
262 /* tell EH to bail */
263 ehc->i.action &= ~ATA_EH_RESET_MASK;
264 return 0;
265 }
266
267 skip_scr:
268 /* wait for !BSY */
269 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
270
271 return 0;
272}
273
274static void vt6420_error_handler(struct ata_port *ap)
275{
276 return ata_bmdma_drive_eh(ap, vt6420_prereset, ata_std_softreset,
277 NULL, ata_std_postreset);
278}
279
173static const unsigned int svia_bar_sizes[] = { 280static const unsigned int svia_bar_sizes[] = {
174 8, 4, 8, 4, 16, 256 281 8, 4, 8, 4, 16, 256
175}; 282};
@@ -210,7 +317,7 @@ static void vt6421_init_addrs(struct ata_probe_ent *probe_ent,
210static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev) 317static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev)
211{ 318{
212 struct ata_probe_ent *probe_ent; 319 struct ata_probe_ent *probe_ent;
213 struct ata_port_info *ppi = &svia_port_info; 320 struct ata_port_info *ppi = &vt6420_port_info;
214 321
215 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 322 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
216 if (!probe_ent) 323 if (!probe_ent)
@@ -239,7 +346,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev)
239 346
240 probe_ent->sht = &svia_sht; 347 probe_ent->sht = &svia_sht;
241 probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY; 348 probe_ent->host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY;
242 probe_ent->port_ops = &svia_sata_ops; 349 probe_ent->port_ops = &vt6421_sata_ops;
243 probe_ent->n_ports = N_PORTS; 350 probe_ent->n_ports = N_PORTS;
244 probe_ent->irq = pdev->irq; 351 probe_ent->irq = pdev->irq;
245 probe_ent->irq_flags = IRQF_SHARED; 352 probe_ent->irq_flags = IRQF_SHARED;