Commit c19f83669a02d4fa047d0d40f518e90f6f19c4c6

Authored by Linus Torvalds

Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
  ata: Report 16/32bit PIO as best we can
  libata: use ATA_ID_CFA_*
  pata_legacy: fix no device fail path
  pata_hpt37x: fix HPT370 DMA timeouts
  libata: handle SEMB signature better

Showing 7 changed files Side-by-side Diff

drivers/ata/libata-core.c
... ... @@ -1231,6 +1231,9 @@
1231 1231 *
1232 1232 * We follow the current spec and consider that 0x69/0x96
1233 1233 * identifies a port multiplier and 0x3c/0xc3 a SEMB device.
  1234 + * Unfortunately, WDC WD1600JS-62MHB5 (a hard drive) reports
  1235 + * SEMB signature. This is worked around in
  1236 + * ata_dev_read_id().
1234 1237 */
1235 1238 if ((tf->lbam == 0) && (tf->lbah == 0)) {
1236 1239 DPRINTK("found ATA device by sig\n");
... ... @@ -1248,8 +1251,8 @@
1248 1251 }
1249 1252  
1250 1253 if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
1251   - printk(KERN_INFO "ata: SEMB device ignored\n");
1252   - return ATA_DEV_SEMB_UNSUP; /* not yet */
  1254 + DPRINTK("found SEMB device by sig (could be ATA device)\n");
  1255 + return ATA_DEV_SEMB;
1253 1256 }
1254 1257  
1255 1258 DPRINTK("unknown device\n");
... ... @@ -1653,8 +1656,8 @@
1653 1656 /*
1654 1657 * Process compact flash extended modes
1655 1658 */
1656   - int pio = id[163] & 0x7;
1657   - int dma = (id[163] >> 3) & 7;
  1659 + int pio = (id[ATA_ID_CFA_MODES] >> 0) & 0x7;
  1660 + int dma = (id[ATA_ID_CFA_MODES] >> 3) & 0x7;
1658 1661  
1659 1662 if (pio)
1660 1663 pio_mask |= (1 << 5);
... ... @@ -2080,6 +2083,7 @@
2080 2083 struct ata_taskfile tf;
2081 2084 unsigned int err_mask = 0;
2082 2085 const char *reason;
  2086 + bool is_semb = class == ATA_DEV_SEMB;
2083 2087 int may_fallback = 1, tried_spinup = 0;
2084 2088 int rc;
2085 2089  
... ... @@ -2090,6 +2094,8 @@
2090 2094 ata_tf_init(dev, &tf);
2091 2095  
2092 2096 switch (class) {
  2097 + case ATA_DEV_SEMB:
  2098 + class = ATA_DEV_ATA; /* some hard drives report SEMB sig */
2093 2099 case ATA_DEV_ATA:
2094 2100 tf.command = ATA_CMD_ID_ATA;
2095 2101 break;
... ... @@ -2126,6 +2132,14 @@
2126 2132 return -ENOENT;
2127 2133 }
2128 2134  
  2135 + if (is_semb) {
  2136 + ata_dev_printk(dev, KERN_INFO, "IDENTIFY failed on "
  2137 + "device w/ SEMB sig, disabled\n");
  2138 + /* SEMB is not supported yet */
  2139 + *p_class = ATA_DEV_SEMB_UNSUP;
  2140 + return 0;
  2141 + }
  2142 +
2129 2143 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
2130 2144 /* Device or controller might have reported
2131 2145 * the wrong device class. Give a shot at the
... ... @@ -2412,7 +2426,8 @@
2412 2426 /* ATA-specific feature tests */
2413 2427 if (dev->class == ATA_DEV_ATA) {
2414 2428 if (ata_id_is_cfa(id)) {
2415   - if (id[162] & 1) /* CPRM may make this media unusable */
  2429 + /* CPRM may make this media unusable */
  2430 + if (id[ATA_ID_CFA_KEY_MGMT] & 1)
2416 2431 ata_dev_printk(dev, KERN_WARNING,
2417 2432 "supports DRM functions and may "
2418 2433 "not be fully accessable.\n");
drivers/ata/libata-scsi.c
... ... @@ -647,23 +647,45 @@
647 647 return rc;
648 648 }
649 649  
  650 +static int ata_ioc32(struct ata_port *ap)
  651 +{
  652 + if (ap->flags & ATA_FLAG_PIO_DMA)
  653 + return 1;
  654 + if (ap->pflags & ATA_PFLAG_PIO32)
  655 + return 1;
  656 + return 0;
  657 +}
  658 +
650 659 int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev,
651 660 int cmd, void __user *arg)
652 661 {
653 662 int val = -EINVAL, rc = -EINVAL;
  663 + unsigned long flags;
654 664  
655 665 switch (cmd) {
656 666 case ATA_IOC_GET_IO32:
657   - val = 0;
  667 + spin_lock_irqsave(ap->lock, flags);
  668 + val = ata_ioc32(ap);
  669 + spin_unlock_irqrestore(ap->lock, flags);
658 670 if (copy_to_user(arg, &val, 1))
659 671 return -EFAULT;
660 672 return 0;
661 673  
662 674 case ATA_IOC_SET_IO32:
663 675 val = (unsigned long) arg;
664   - if (val != 0)
665   - return -EINVAL;
666   - return 0;
  676 + rc = 0;
  677 + spin_lock_irqsave(ap->lock, flags);
  678 + if (ap->pflags & ATA_PFLAG_PIO32CHANGE) {
  679 + if (val)
  680 + ap->pflags |= ATA_PFLAG_PIO32;
  681 + else
  682 + ap->pflags &= ~ATA_PFLAG_PIO32;
  683 + } else {
  684 + if (val != ata_ioc32(ap))
  685 + rc = -EINVAL;
  686 + }
  687 + spin_unlock_irqrestore(ap->lock, flags);
  688 + return rc;
667 689  
668 690 case HDIO_GET_IDENTITY:
669 691 return ata_get_identity(ap, scsidev, arg);
drivers/ata/libata-sff.c
... ... @@ -87,6 +87,7 @@
87 87 .inherits = &ata_bmdma_port_ops,
88 88  
89 89 .sff_data_xfer = ata_sff_data_xfer32,
  90 + .port_start = ata_sff_port_start32,
90 91 };
91 92 EXPORT_SYMBOL_GPL(ata_bmdma32_port_ops);
92 93  
... ... @@ -769,6 +770,9 @@
769 770 void __iomem *data_addr = ap->ioaddr.data_addr;
770 771 unsigned int words = buflen >> 2;
771 772 int slop = buflen & 3;
  773 +
  774 + if (!(ap->pflags & ATA_PFLAG_PIO32))
  775 + return ata_sff_data_xfer(dev, buf, buflen, rw);
772 776  
773 777 /* Transfer multiple of 4 bytes */
774 778 if (rw == READ)
... ... @@ -2400,6 +2404,29 @@
2400 2404 return 0;
2401 2405 }
2402 2406 EXPORT_SYMBOL_GPL(ata_sff_port_start);
  2407 +
  2408 +/**
  2409 + * ata_sff_port_start32 - Set port up for dma.
  2410 + * @ap: Port to initialize
  2411 + *
  2412 + * Called just after data structures for each port are
  2413 + * initialized. Allocates space for PRD table if the device
  2414 + * is DMA capable SFF.
  2415 + *
  2416 + * May be used as the port_start() entry in ata_port_operations for
  2417 + * devices that are capable of 32bit PIO.
  2418 + *
  2419 + * LOCKING:
  2420 + * Inherited from caller.
  2421 + */
  2422 +int ata_sff_port_start32(struct ata_port *ap)
  2423 +{
  2424 + ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
  2425 + if (ap->ioaddr.bmdma_addr)
  2426 + return ata_port_start(ap);
  2427 + return 0;
  2428 +}
  2429 +EXPORT_SYMBOL_GPL(ata_sff_port_start32);
2403 2430  
2404 2431 /**
2405 2432 * ata_sff_std_ports - initialize ioaddr with standard port offsets.
drivers/ata/pata_hpt37x.c
... ... @@ -8,7 +8,7 @@
8 8 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
9 9 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
10 10 * Portions Copyright (C) 2003 Red Hat Inc
11   - * Portions Copyright (C) 2005-2007 MontaVista Software, Inc.
  11 + * Portions Copyright (C) 2005-2009 MontaVista Software, Inc.
12 12 *
13 13 * TODO
14 14 * Look into engine reset on timeout errors. Should not be required.
... ... @@ -24,7 +24,7 @@
24 24 #include <linux/libata.h>
25 25  
26 26 #define DRV_NAME "pata_hpt37x"
27   -#define DRV_VERSION "0.6.11"
  27 +#define DRV_VERSION "0.6.12"
28 28  
29 29 struct hpt_clock {
30 30 u8 xfer_speed;
... ... @@ -445,23 +445,6 @@
445 445 }
446 446  
447 447 /**
448   - * hpt370_bmdma_start - DMA engine begin
449   - * @qc: ATA command
450   - *
451   - * The 370 and 370A want us to reset the DMA engine each time we
452   - * use it. The 372 and later are fine.
453   - */
454   -
455   -static void hpt370_bmdma_start(struct ata_queued_cmd *qc)
456   -{
457   - struct ata_port *ap = qc->ap;
458   - struct pci_dev *pdev = to_pci_dev(ap->host->dev);
459   - pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
460   - udelay(10);
461   - ata_bmdma_start(qc);
462   -}
463   -
464   -/**
465 448 * hpt370_bmdma_end - DMA engine stop
466 449 * @qc: ATA command
467 450 *
... ... @@ -598,7 +581,6 @@
598 581 static struct ata_port_operations hpt370_port_ops = {
599 582 .inherits = &ata_bmdma_port_ops,
600 583  
601   - .bmdma_start = hpt370_bmdma_start,
602 584 .bmdma_stop = hpt370_bmdma_stop,
603 585  
604 586 .mode_filter = hpt370_filter,
drivers/ata/pata_legacy.c
... ... @@ -108,6 +108,7 @@
108 108 struct ata_port_operations *ops;
109 109 unsigned int pio_mask;
110 110 unsigned int flags;
  111 + unsigned int pflags;
111 112 int (*setup)(struct platform_device *, struct legacy_probe *probe,
112 113 struct legacy_data *data);
113 114 };
... ... @@ -285,7 +286,8 @@
285 286 {
286 287 int slop = buflen & 3;
287 288 /* 32bit I/O capable *and* we need to write a whole number of dwords */
288   - if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3)) {
  289 + if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3)
  290 + && (ap->pflags & ATA_PFLAG_PIO32)) {
289 291 struct ata_port *ap = dev->link->ap;
290 292 unsigned long flags;
291 293  
... ... @@ -736,7 +738,8 @@
736 738 struct ata_port *ap = adev->link->ap;
737 739 int slop = buflen & 3;
738 740  
739   - if (ata_id_has_dword_io(adev->id) && (slop == 0 || slop == 3)) {
  741 + if (ata_id_has_dword_io(adev->id) && (slop == 0 || slop == 3)
  742 + && (ap->pflags & ATA_PFLAG_PIO32)) {
740 743 if (rw == WRITE)
741 744 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
742 745 else
743 746  
744 747  
745 748  
746 749  
747 750  
748 751  
749 752  
750 753  
751 754  
752 755  
... ... @@ -858,27 +861,30 @@
858 861  
859 862 static struct legacy_controller controllers[] = {
860 863 {"BIOS", &legacy_port_ops, 0x1F,
861   - ATA_FLAG_NO_IORDY, NULL },
  864 + ATA_FLAG_NO_IORDY, 0, NULL },
862 865 {"Snooping", &simple_port_ops, 0x1F,
863   - 0 , NULL },
  866 + 0, 0, NULL },
864 867 {"PDC20230", &pdc20230_port_ops, 0x7,
865   - ATA_FLAG_NO_IORDY, NULL },
  868 + ATA_FLAG_NO_IORDY,
  869 + ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, NULL },
866 870 {"HT6560A", &ht6560a_port_ops, 0x07,
867   - ATA_FLAG_NO_IORDY, NULL },
  871 + ATA_FLAG_NO_IORDY, 0, NULL },
868 872 {"HT6560B", &ht6560b_port_ops, 0x1F,
869   - ATA_FLAG_NO_IORDY, NULL },
  873 + ATA_FLAG_NO_IORDY, 0, NULL },
870 874 {"OPTI82C611A", &opti82c611a_port_ops, 0x0F,
871   - 0 , NULL },
  875 + 0, 0, NULL },
872 876 {"OPTI82C46X", &opti82c46x_port_ops, 0x0F,
873   - 0 , NULL },
  877 + 0, 0, NULL },
874 878 {"QDI6500", &qdi6500_port_ops, 0x07,
875   - ATA_FLAG_NO_IORDY, qdi_port },
  879 + ATA_FLAG_NO_IORDY,
  880 + ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port },
876 881 {"QDI6580", &qdi6580_port_ops, 0x1F,
877   - 0 , qdi_port },
  882 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port },
878 883 {"QDI6580DP", &qdi6580dp_port_ops, 0x1F,
879   - 0 , qdi_port },
  884 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port },
880 885 {"W83759A", &winbond_port_ops, 0x1F,
881   - 0 , winbond_port }
  886 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE,
  887 + winbond_port }
882 888 };
883 889  
884 890 /**
... ... @@ -1008,6 +1014,7 @@
1008 1014 ap->ops = ops;
1009 1015 ap->pio_mask = pio_modes;
1010 1016 ap->flags |= ATA_FLAG_SLAVE_POSS | iordy;
  1017 + ap->pflags |= controller->pflags;
1011 1018 ap->ioaddr.cmd_addr = io_addr;
1012 1019 ap->ioaddr.altstatus_addr = ctrl_addr;
1013 1020 ap->ioaddr.ctl_addr = ctrl_addr;
... ... @@ -1032,6 +1039,7 @@
1032 1039 return 0;
1033 1040 }
1034 1041 }
  1042 + ata_host_detach(host);
1035 1043 fail:
1036 1044 platform_device_unregister(pdev);
1037 1045 return ret;
drivers/ata/pata_ninja32.c
... ... @@ -44,7 +44,7 @@
44 44 #include <linux/libata.h>
45 45  
46 46 #define DRV_NAME "pata_ninja32"
47   -#define DRV_VERSION "0.1.3"
  47 +#define DRV_VERSION "0.1.5"
48 48  
49 49  
50 50 /**
... ... @@ -86,6 +86,7 @@
86 86 .sff_dev_select = ninja32_dev_select,
87 87 .cable_detect = ata_cable_40wire,
88 88 .set_piomode = ninja32_set_piomode,
  89 + .sff_data_xfer = ata_sff_data_xfer32
89 90 };
90 91  
91 92 static void ninja32_program(void __iomem *base)
... ... @@ -144,6 +145,7 @@
144 145 ap->ioaddr.altstatus_addr = base + 0x1E;
145 146 ap->ioaddr.bmdma_addr = base;
146 147 ata_sff_std_ports(&ap->ioaddr);
  148 + ap->pflags = ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
147 149  
148 150 ninja32_program(base);
149 151 /* FIXME: Should we disable them at remove ? */
include/linux/libata.h
... ... @@ -209,6 +209,7 @@
209 209  
210 210 /* bits 24:31 of ap->flags are reserved for LLD specific flags */
211 211  
  212 +
212 213 /* struct ata_port pflags */
213 214 ATA_PFLAG_EH_PENDING = (1 << 0), /* EH pending */
214 215 ATA_PFLAG_EH_IN_PROGRESS = (1 << 1), /* EH in progress */
... ... @@ -225,6 +226,9 @@
225 226 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */
226 227 ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */
227 228  
  229 + ATA_PFLAG_PIO32 = (1 << 20), /* 32bit PIO */
  230 + ATA_PFLAG_PIO32CHANGE = (1 << 21), /* 32bit PIO can be turned on/off */
  231 +
228 232 /* struct ata_queued_cmd flags */
229 233 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
230 234 ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */
231 235  
... ... @@ -689,7 +693,10 @@
689 693 struct Scsi_Host *scsi_host; /* our co-allocated scsi host */
690 694 struct ata_port_operations *ops;
691 695 spinlock_t *lock;
  696 + /* Flags owned by the EH context. Only EH should touch these once the
  697 + port is active */
692 698 unsigned long flags; /* ATA_FLAG_xxx */
  699 + /* Flags that change dynamically, protected by ap->lock */
693 700 unsigned int pflags; /* ATA_PFLAG_xxx */
694 701 unsigned int print_id; /* user visible unique port ID */
695 702 unsigned int port_no; /* 0 based port no. inside the host */
... ... @@ -1595,6 +1602,7 @@
1595 1602 extern void ata_sff_error_handler(struct ata_port *ap);
1596 1603 extern void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc);
1597 1604 extern int ata_sff_port_start(struct ata_port *ap);
  1605 +extern int ata_sff_port_start32(struct ata_port *ap);
1598 1606 extern void ata_sff_std_ports(struct ata_ioports *ioaddr);
1599 1607 extern unsigned long ata_bmdma_mode_filter(struct ata_device *dev,
1600 1608 unsigned long xfer_mask);