aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_mv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_mv.c')
-rw-r--r--drivers/ata/sata_mv.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 37ae5dc1070c..870dcfd82357 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -1881,6 +1881,39 @@ static u8 mv_bmdma_status(struct ata_port *ap)
1881 return status; 1881 return status;
1882} 1882}
1883 1883
1884static 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 * mv_qc_prep - Host specific command preparation. 1918 * mv_qc_prep - Host specific command preparation.
1886 * @qc: queued command to prepare 1919 * @qc: queued command to prepare
@@ -1898,17 +1931,24 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
1898 struct ata_port *ap = qc->ap; 1931 struct ata_port *ap = qc->ap;
1899 struct mv_port_priv *pp = ap->private_data; 1932 struct mv_port_priv *pp = ap->private_data;
1900 __le16 *cw; 1933 __le16 *cw;
1901 struct ata_taskfile *tf; 1934 struct ata_taskfile *tf = &qc->tf;
1902 u16 flags = 0; 1935 u16 flags = 0;
1903 unsigned in_index; 1936 unsigned in_index;
1904 1937
1905 if ((qc->tf.protocol != ATA_PROT_DMA) && 1938 switch (tf->protocol) {
1906 (qc->tf.protocol != ATA_PROT_NCQ)) 1939 case ATA_PROT_DMA:
1940 case ATA_PROT_NCQ:
1941 break; /* continue below */
1942 case ATA_PROT_PIO:
1943 mv_rw_multi_errata_sata24(qc);
1944 return;
1945 default:
1907 return; 1946 return;
1947 }
1908 1948
1909 /* Fill in command request block 1949 /* Fill in command request block
1910 */ 1950 */
1911 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 1951 if (!(tf->flags & ATA_TFLAG_WRITE))
1912 flags |= CRQB_FLAG_READ; 1952 flags |= CRQB_FLAG_READ;
1913 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); 1953 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
1914 flags |= qc->tag << CRQB_TAG_SHIFT; 1954 flags |= qc->tag << CRQB_TAG_SHIFT;
@@ -1924,7 +1964,6 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
1924 pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags); 1964 pp->crqb[in_index].ctrl_flags = cpu_to_le16(flags);
1925 1965
1926 cw = &pp->crqb[in_index].ata_cmd[0]; 1966 cw = &pp->crqb[in_index].ata_cmd[0];
1927 tf = &qc->tf;
1928 1967
1929 /* Sadly, the CRQB cannot accomodate all registers--there are 1968 /* Sadly, the CRQB cannot accomodate all registers--there are
1930 * only 11 bytes...so we must pick and choose required 1969 * only 11 bytes...so we must pick and choose required
@@ -1990,16 +2029,16 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
1990 struct ata_port *ap = qc->ap; 2029 struct ata_port *ap = qc->ap;
1991 struct mv_port_priv *pp = ap->private_data; 2030 struct mv_port_priv *pp = ap->private_data;
1992 struct mv_crqb_iie *crqb; 2031 struct mv_crqb_iie *crqb;
1993 struct ata_taskfile *tf; 2032 struct ata_taskfile *tf = &qc->tf;
1994 unsigned in_index; 2033 unsigned in_index;
1995 u32 flags = 0; 2034 u32 flags = 0;
1996 2035
1997 if ((qc->tf.protocol != ATA_PROT_DMA) && 2036 if ((tf->protocol != ATA_PROT_DMA) &&
1998 (qc->tf.protocol != ATA_PROT_NCQ)) 2037 (tf->protocol != ATA_PROT_NCQ))
1999 return; 2038 return;
2000 2039
2001 /* Fill in Gen IIE command request block */ 2040 /* Fill in Gen IIE command request block */
2002 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 2041 if (!(tf->flags & ATA_TFLAG_WRITE))
2003 flags |= CRQB_FLAG_READ; 2042 flags |= CRQB_FLAG_READ;
2004 2043
2005 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); 2044 WARN_ON(MV_MAX_Q_DEPTH <= qc->tag);
@@ -2015,7 +2054,6 @@ static void mv_qc_prep_iie(struct ata_queued_cmd *qc)
2015 crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16); 2054 crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma[qc->tag] >> 16) >> 16);
2016 crqb->flags = cpu_to_le32(flags); 2055 crqb->flags = cpu_to_le32(flags);
2017 2056
2018 tf = &qc->tf;
2019 crqb->ata_cmd[0] = cpu_to_le32( 2057 crqb->ata_cmd[0] = cpu_to_le32(
2020 (tf->command << 16) | 2058 (tf->command << 16) |
2021 (tf->feature << 24) 2059 (tf->feature << 24)