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:
[libata] fix build error on drivers/ata/pata_legacy.c
pata_via: Cache and rewrite the device bit
sata_mv: workaround for multi_count errata sata24
sata_mv: tidy up qc->tf usage in qc_prep() functions

+122 -23
+7 -6
drivers/ata/pata_legacy.c
··· 285 285 unsigned char *buf, unsigned int buflen, int rw) 286 286 { 287 287 int slop = buflen & 3; 288 + struct ata_port *ap = dev->link->ap; 289 + 288 290 /* 32bit I/O capable *and* we need to write a whole number of dwords */ 289 291 if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3) 290 292 && (ap->pflags & ATA_PFLAG_PIO32)) { 291 - struct ata_port *ap = dev->link->ap; 292 293 unsigned long flags; 293 294 294 295 local_irq_save(flags); ··· 867 866 0, 0, NULL }, 868 867 {"PDC20230", &pdc20230_port_ops, 0x7, 869 868 ATA_FLAG_NO_IORDY, 870 - ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, NULL }, 869 + ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, NULL }, 871 870 {"HT6560A", &ht6560a_port_ops, 0x07, 872 871 ATA_FLAG_NO_IORDY, 0, NULL }, 873 872 {"HT6560B", &ht6560b_port_ops, 0x1F, ··· 878 877 0, 0, NULL }, 879 878 {"QDI6500", &qdi6500_port_ops, 0x07, 880 879 ATA_FLAG_NO_IORDY, 881 - ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port }, 880 + ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port }, 882 881 {"QDI6580", &qdi6580_port_ops, 0x1F, 883 - 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port }, 882 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port }, 884 883 {"QDI6580DP", &qdi6580dp_port_ops, 0x1F, 885 - 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, qdi_port }, 884 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port }, 886 885 {"W83759A", &winbond_port_ops, 0x1F, 887 - 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32_CHANGE, 886 + 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, 888 887 winbond_port } 889 888 }; 890 889
+67 -7
drivers/ata/pata_via.c
··· 62 62 #include <linux/dmi.h> 63 63 64 64 #define DRV_NAME "pata_via" 65 - #define DRV_VERSION "0.3.3" 65 + #define DRV_VERSION "0.3.4" 66 66 67 67 /* 68 68 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx ··· 136 136 { NULL } 137 137 }; 138 138 139 + struct via_port { 140 + u8 cached_device; 141 + }; 139 142 140 143 /* 141 144 * Cable special cases ··· 349 346 */ 350 347 static void via_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 351 348 { 352 - struct ata_taskfile tmp_tf; 349 + struct ata_ioports *ioaddr = &ap->ioaddr; 350 + struct via_port *vp = ap->private_data; 351 + unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 352 + int newctl = 0; 353 353 354 - if (ap->ctl != ap->last_ctl && !(tf->flags & ATA_TFLAG_DEVICE)) { 355 - tmp_tf = *tf; 356 - tmp_tf.flags |= ATA_TFLAG_DEVICE; 357 - tf = &tmp_tf; 354 + if (tf->ctl != ap->last_ctl) { 355 + iowrite8(tf->ctl, ioaddr->ctl_addr); 356 + ap->last_ctl = tf->ctl; 357 + ata_wait_idle(ap); 358 + newctl = 1; 358 359 } 359 - ata_sff_tf_load(ap, tf); 360 + 361 + if (tf->flags & ATA_TFLAG_DEVICE) { 362 + iowrite8(tf->device, ioaddr->device_addr); 363 + vp->cached_device = tf->device; 364 + } else if (newctl) 365 + iowrite8(vp->cached_device, ioaddr->device_addr); 366 + 367 + if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 368 + WARN_ON_ONCE(!ioaddr->ctl_addr); 369 + iowrite8(tf->hob_feature, ioaddr->feature_addr); 370 + iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 371 + iowrite8(tf->hob_lbal, ioaddr->lbal_addr); 372 + iowrite8(tf->hob_lbam, ioaddr->lbam_addr); 373 + iowrite8(tf->hob_lbah, ioaddr->lbah_addr); 374 + VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", 375 + tf->hob_feature, 376 + tf->hob_nsect, 377 + tf->hob_lbal, 378 + tf->hob_lbam, 379 + tf->hob_lbah); 380 + } 381 + 382 + if (is_addr) { 383 + iowrite8(tf->feature, ioaddr->feature_addr); 384 + iowrite8(tf->nsect, ioaddr->nsect_addr); 385 + iowrite8(tf->lbal, ioaddr->lbal_addr); 386 + iowrite8(tf->lbam, ioaddr->lbam_addr); 387 + iowrite8(tf->lbah, ioaddr->lbah_addr); 388 + VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", 389 + tf->feature, 390 + tf->nsect, 391 + tf->lbal, 392 + tf->lbam, 393 + tf->lbah); 394 + } 395 + 396 + ata_wait_idle(ap); 397 + } 398 + 399 + static int via_port_start(struct ata_port *ap) 400 + { 401 + struct via_port *vp; 402 + struct pci_dev *pdev = to_pci_dev(ap->host->dev); 403 + 404 + int ret = ata_sff_port_start(ap); 405 + if (ret < 0) 406 + return ret; 407 + 408 + vp = devm_kzalloc(&pdev->dev, sizeof(struct via_port), GFP_KERNEL); 409 + if (vp == NULL) 410 + return -ENOMEM; 411 + ap->private_data = vp; 412 + return 0; 360 413 } 361 414 362 415 static struct scsi_host_template via_sht = { ··· 426 367 .set_dmamode = via_set_dmamode, 427 368 .prereset = via_pre_reset, 428 369 .sff_tf_load = via_tf_load, 370 + .port_start = via_port_start, 429 371 }; 430 372 431 373 static struct ata_port_operations via_port_ops_noirq = {
+48 -10
drivers/ata/sata_mv.c
··· 1881 1881 return status; 1882 1882 } 1883 1883 1884 + static void mv_rw_multi_errata_sata24(struct ata_queued_cmd *qc) 1885 + { 1886 + struct ata_taskfile *tf = &qc->tf; 1887 + /* 1888 + * Workaround for 88SX60x1 FEr SATA#24. 1889 + * 1890 + * Chip may corrupt WRITEs if multi_count >= 4kB. 1891 + * Note that READs are unaffected. 1892 + * 1893 + * It's not clear if this errata really means "4K bytes", 1894 + * or if it always happens for multi_count > 7 1895 + * regardless of device sector_size. 1896 + * 1897 + * So, for safety, any write with multi_count > 7 1898 + * gets converted here into a regular PIO write instead: 1899 + */ 1900 + if ((tf->flags & ATA_TFLAG_WRITE) && is_multi_taskfile(tf)) { 1901 + if (qc->dev->multi_count > 7) { 1902 + switch (tf->command) { 1903 + case ATA_CMD_WRITE_MULTI: 1904 + tf->command = ATA_CMD_PIO_WRITE; 1905 + break; 1906 + case ATA_CMD_WRITE_MULTI_FUA_EXT: 1907 + tf->flags &= ~ATA_TFLAG_FUA; /* ugh */ 1908 + /* fall through */ 1909 + case ATA_CMD_WRITE_MULTI_EXT: 1910 + tf->command = ATA_CMD_PIO_WRITE_EXT; 1911 + break; 1912 + } 1913 + } 1914 + } 1915 + } 1916 + 1884 1917 /** 1885 1918 * mv_qc_prep - Host specific command preparation. 1886 1919 * @qc: queued command to prepare ··· 1931 1898 struct ata_port *ap = qc->ap; 1932 1899 struct mv_port_priv *pp = ap->private_data; 1933 1900 __le16 *cw; 1934 - struct ata_taskfile *tf; 1901 + struct ata_taskfile *tf = &qc->tf; 1935 1902 u16 flags = 0; 1936 1903 unsigned in_index; 1937 1904 1938 - if ((qc->tf.protocol != ATA_PROT_DMA) && 1939 - (qc->tf.protocol != ATA_PROT_NCQ)) 1905 + switch (tf->protocol) { 1906 + case ATA_PROT_DMA: 1907 + case ATA_PROT_NCQ: 1908 + break; /* continue below */ 1909 + case ATA_PROT_PIO: 1910 + mv_rw_multi_errata_sata24(qc); 1940 1911 return; 1912 + default: 1913 + return; 1914 + } 1941 1915 1942 1916 /* Fill in command request block 1943 1917 */ 1944 - if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 1918 + if (!(tf->flags & ATA_TFLAG_WRITE)) 1945 1919 flags |= CRQB_FLAG_READ; 1946 1920 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); 1947 1921 flags |= qc->tag << CRQB_TAG_SHIFT; ··· 1964 1924 pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags); 1965 1925 1966 1926 cw = &pp->crqb[in_index].ata_cmd[0]; 1967 - tf = &qc->tf; 1968 1927 1969 1928 /* Sadly, the CRQB cannot accomodate all registers--there are 1970 1929 * only 11 bytes...so we must pick and choose required ··· 2029 1990 struct ata_port *ap = qc->ap; 2030 1991 struct mv_port_priv *pp = ap->private_data; 2031 1992 struct mv_crqb_iie *crqb; 2032 - struct ata_taskfile *tf; 1993 + struct ata_taskfile *tf = &qc->tf; 2033 1994 unsigned in_index; 2034 1995 u32 flags = 0; 2035 1996 2036 - if ((qc->tf.protocol != ATA_PROT_DMA) && 2037 - (qc->tf.protocol != ATA_PROT_NCQ)) 1997 + if ((tf->protocol != ATA_PROT_DMA) && 1998 + (tf->protocol != ATA_PROT_NCQ)) 2038 1999 return; 2039 2000 2040 2001 /* Fill in Gen IIE command request block */ 2041 - if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 2002 + if (!(tf->flags & ATA_TFLAG_WRITE)) 2042 2003 flags |= CRQB_FLAG_READ; 2043 2004 2044 2005 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); ··· 2054 2015 crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16); 2055 2016 crqb->flags = cpu_to_le32(flags); 2056 2017 2057 - tf = &qc->tf; 2058 2018 crqb->ata_cmd[0] = cpu_to_le32( 2059 2019 (tf->command << 16) | 2060 2020 (tf->feature << 24)