Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbcDVHER (ORCPT ); Fri, 22 Apr 2016 03:04:17 -0400 Received: from mail-bl2on0148.outbound.protection.outlook.com ([65.55.169.148]:3251 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751681AbcDVHEO (ORCPT ); Fri, 22 Apr 2016 03:04:14 -0400 Authentication-Results: spf=neutral (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=freescale.com; From: Yunhui Cui To: , , CC: , , , , Yunhui Cui Subject: [PATCH v2 8/9] mtd: fsl-quadspi: disable AHB buffer prefetch Date: Fri, 22 Apr 2016 14:39:51 +0800 Message-ID: <1461307192-866-8-git-send-email-B56489@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1461307192-866-1-git-send-email-B56489@freescale.com> References: <1461307192-866-1-git-send-email-B56489@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(189002)(50944005)(199003)(19580405001)(2950100001)(19580395003)(81166005)(586003)(106466001)(229853001)(1220700001)(105586002)(1096002)(76176999)(50986999)(36756003)(104016004)(6806005)(92566002)(5008740100001)(77096005)(2201001)(575784001)(86362001)(4001450100002)(50226001)(189998001)(5003940100001)(2906002)(48376002)(50466002)(87936001)(11100500001)(47776003)(4326007)(5001770100001)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB066;H:az84smr01.freescale.net;FPR:;SPF:Neutral;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD015;1:Ye8fIPxABzyj7Sw/TZjNVBuQjVM6RqpnEDRa1nXBtUqhP9b2VjRCg+ZE9hkEoh7IPcGsjjVRT2QHsUBxnQtEGQX8OiyV/fsCgdBVG5sdQ0p6LpIb0KJXBWHKK/OwqPOeUfNGMscwBWT22ndug2LdeoquKimY7PwyJaR9vn/3uJGJECJCyqPMXR+F7q4JR8pleVQiQKDzt+UaYZQ95vgdwWQXMTy+DNktTdu137xqDb9mvDTMtKzH+jYw6zdIjbDM5ufTxAOLT0+Au2GwA/cjovCkMUG3Irf3mrGuUxybbTZG3rewUtI7/+Zb9mNYZndOzJs/ii9nY0lvP3EPJX3pg0MKvLBe+qEck3McmWIx2cg7o7udVupwQ9/5tpk2obCASiMX/+dI6mJhv7fASPyqIbRqHaDVRMgL+/wm3kNXhHKbtGZMY294jk7KiCUOu6KkzkUcEKHYoYbeXKG1EHbGRhXYy1RP0OdSrEjHXiwqcSX+BER+qz9l5yoMx58Yq9ZKgKAj0/wTDxTBN0KA8w1GPjkfAve263q9Ml6k7KxGJkcOS3B+h8ZOUGZ3gQNuUhpoKW265j1ZYKeI1JxANhLAoA== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 97f50ac4-842c-4482-7264-08d36a7a42cb X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB066;2:qCCEh3D13XrRVQE5rsVrR0JYUx/FtrALvubu8Xqx2WG9ULBYvvbWP8RmJY76Q2ALJiTmznGJ+S94NincVDGCPwIM441TZN3tlMRJ9ZFlA0Utmjy8dsMZnCiFa5bMTdJEd9raFfJk21MKQvsJNBqwI1qQ/LhLiu9UnkHlLlAS22DHQVNzlCArmFbNzbY1RZpq;3:GIzRZqb4UYqbxKMsEHAYgLlRS6D8hLNaIbI3F+OVHlNnr+jlM48dDwNzYuJUJ7XJmSwyU2jdjUk72NBrDqIEgJNwsJm9i9T0vocKwGs575k18vwOFQRTFOmuO0ZLLBavDWNjKGUQR2G57IoAeSv8mFZhaoTFh3dTXgp174pAaxY215luuNgGRq/7RC7cVD6kHo67EzdDrjP4XYCm7VPgyqsd4ipvhil1JkFfOtZauU0=;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1kMoxCKdPxzC8402qgDUFIqmPz0FDjg8RirS1dbHF74jvJOPJUelrUcpsEKIYHrO5msyhAF+/MoBD4AiXS0xJ57KBhJqG/jpPptv6lngDgNEnZwyW8KuuOjj9IAhFpIswSaFSzCnlqwCYazdh0fZZY0LOX5IHFhVBUeJvPvsXIILwd7yB/kxdcRlb81dx4B2tht0Xtr3VUcaepIJ6DHfBR5qPVj04KsmLweQUHSGlCb3pNfvhgsOuIUlY1HDBKGsUvW25C5oHKeetg4Z/w0Ew5HoILtrU3A2czZEg38NPAL7QUdUMj2LIRQHCum9EQ/x2X595gW X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(13015025)(13017025)(8121501046)(5005006)(13018025)(13024025)(13023025)(3002001)(10201501046)(6055026);SRVR:BLUPR03MB066;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB066; X-Forefront-PRVS: 0920602B08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR03MB066;23:SCesA8M5837GiGbQSZ/i0wIREimosOJaJ2CGxH/0Gx?= =?us-ascii?Q?t67PMjHUV2Ha54hF/3B3tcAe03lVw5I+akatgeSD/JJGFoVY/OBzuz1Y8R/O?= =?us-ascii?Q?faIaZ3/ZWyxt9zTpK+qT0FYpdpkxYjE83AqPONCqJOriHvBp2r3yA2stUBrA?= =?us-ascii?Q?DoNH/0Rf6iLmOU9qP32gxhyCAqB+zlTcVJbt+9i3YfB9HUjQ6lapsPrMUFv7?= =?us-ascii?Q?2oQNvuSEBex0FH5hhNlTIufCMO+du4FPPyJlCiUXwJOCrF8golTYrP0e67Ns?= =?us-ascii?Q?W2iccoLotS7k0mlf48e2vnpv5SAdLJgOb7FMiipM4+PNbsgtqE/S4YlwLe5S?= =?us-ascii?Q?7ejKBay033EB9HCKIoFRUCBWSsSHdyL8Keuu5gNsv3pxSzAiSXuteDXD9C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Sfk/B0HnTyERDtjlFS7T+4LigVWNtTjX1nZgQm4G5LNd27RCSVo2uLZ6WE7VlxAn2FJYuZnpgkIPFNpmgBvj8769KqSdKM5xE=;7:Bqknbx5cEFnq9CdIAaLzoNq3DBoRq85DdqxftVvjX2AREig4Ph9qTNapuela4tiPIO01WqRrQBq6JErT1YGZeUm2bL/6fKqf/vri1Ulrs41B67GLeYeZkQEJv7BoJuLfhausaeoUY7shY1bz0VhhTF3KhXck25LmfbIuoe2ZaWNnvF9/eQK021HWN+rWb/vYQqkRnC9CePjndfbrEvgrcA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2016 06:49:32.6371 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB066 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3339 Lines: 94 From: Yunhui Cui A-009282: QuadSPI: QuadSPI data pre-fetch can result in incorrect data Affects: QuadSPI Description: With AHB buffer prefetch enabled, the QuadSPI may return incorrect data on the AHB interface. The buffer pre-fetch is enabled if the fetch size as configured either in the LUT or in the BUFxCR register is greater than 8 bytes. Impact: Only 64 bit read allowed. Workaround: Keep the read data size to 64 bits (8 Bytes), which disables the prefetch on the AHB buffer, and prevents this issue from occurring. Signed-off-by: Yunhui Cui --- drivers/mtd/spi-nor/fsl-quadspi.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index fea18b6..6a022e7 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -41,6 +41,8 @@ #define QUADSPI_QUIRK_TKT253890 (1 << 2) /* Controller cannot wake up from wait mode, TKT245618 */ #define QUADSPI_QUIRK_TKT245618 (1 << 3) +/*Errata A-009282: disable the AHB buffer prefetch */ +#define QUADSPI_QUIRK_ADASZ_8BYTE_LIMIT (1 << 4) /* QSPI_AMBA_BASE is internally added by SOC design */ #define QUADSPI_AMBA_BASE_INTERNAL (0x10000) @@ -270,7 +272,7 @@ static struct fsl_qspi_devtype_data ls1021a_data = { .rxfifo = 128, .txfifo = 64, .ahb_buf_size = 1024, - .driver_data = 0, + .driver_data = QUADSPI_QUIRK_ADASZ_8BYTE_LIMIT, }; static struct fsl_qspi_devtype_data ls2080a_data = { @@ -278,7 +280,8 @@ static struct fsl_qspi_devtype_data ls2080a_data = { .rxfifo = 128, .txfifo = 64, .ahb_buf_size = 1024, - .driver_data = QUADSPI_AMBA_BASE_INTERNAL, + .driver_data = QUADSPI_AMBA_BASE_INTERNAL + | QUADSPI_QUIRK_ADASZ_8BYTE_LIMIT, }; #define FSL_QSPI_MAX_CHIP 4 @@ -328,6 +331,11 @@ static inline int has_added_amba_base_internal(struct fsl_qspi *q) return q->devtype_data->driver_data & QUADSPI_AMBA_BASE_INTERNAL; } +static inline int needs_disable_ahb_prefetch(struct fsl_qspi *q) +{ + return q->devtype_data->driver_data & QUADSPI_QUIRK_ADASZ_8BYTE_LIMIT; +} + /* * R/W functions for big- or little-endian registers: * The qSPI controller's endian is independent of the CPU core's endian. @@ -757,14 +765,21 @@ static void fsl_qspi_init_abh_read(struct fsl_qspi *q) qspi_writel(q, QUADSPI_BUFXCR_INVALID_MSTRID, base + QUADSPI_BUF0CR); qspi_writel(q, QUADSPI_BUFXCR_INVALID_MSTRID, base + QUADSPI_BUF1CR); qspi_writel(q, QUADSPI_BUFXCR_INVALID_MSTRID, base + QUADSPI_BUF2CR); - /* - * Set ADATSZ with the maximum AHB buffer size to improve the - * read performance. - */ - qspi_writel(q, QUADSPI_BUF3CR_ALLMST_MASK | - ((q->devtype_data->ahb_buf_size / 8) - << QUADSPI_BUF3CR_ADATSZ_SHIFT), + + if (needs_disable_ahb_prefetch(q)) { + qspi_writel(q, QUADSPI_BUF3CR_ALLMST_MASK | + (1 << QUADSPI_BUF3CR_ADATSZ_SHIFT), base + QUADSPI_BUF3CR); + } else { + /* + * Set ADATSZ with the maximum AHB buffer size to improve the + * read performance. + */ + qspi_writel(q, QUADSPI_BUF3CR_ALLMST_MASK | + ((q->devtype_data->ahb_buf_size / 8) + << QUADSPI_BUF3CR_ADATSZ_SHIFT), + base + QUADSPI_BUF3CR); + } /* We only use the buffer3 */ qspi_writel(q, 0, base + QUADSPI_BUF0IND); -- 2.1.0.27.g96db324