From patchwork Wed Sep 26 22:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 975465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tXbM7Mhe"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42LC6l3xLvz9s3x for ; Thu, 27 Sep 2018 08:19:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=46eqhOMsHvh45oVdXudRTTq5t6lKQHQ37W2ij4FtGqE=; b=tXbM7Mhe+EfHdzFihsoaLAlLkG MFnDrdRvktwOIyFgXwnATNyt4/g4RER1yDFwGWY3r8HcO9yhYGfrw3Jcm4U87PdE5yUFEBjvcnFqw 1LPVBOrfae6GvVrCg4K11hNbb2UsfJrDuti3k7giEnG8zNei9fjc4V46pJrFQO3Jg3yEXtetDhQzV 1rza7Slr+3ZOmubRhWj39Pmp0T3CN9YHFS2zs/XNnjfl2Ib54sXO1UTs/ToUUfKgt09lc0pp3yYyE 8jxAHlpr++Q2iqqAhATbl7gV/KFoAbDoC9FKzlhDbh5VaElA6eSneYXNOKQW5FyjnaRmzj2HudvJ4 cga5fSAw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5I9t-00033y-4P; Wed, 26 Sep 2018 22:19:49 +0000 Received: from mail-out.m-online.net ([212.18.0.9]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5HzU-0005j8-67 for linux-mtd@lists.infradead.org; Wed, 26 Sep 2018 22:09:08 +0000 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42LBsK56v8z1qyLM; Thu, 27 Sep 2018 00:08:21 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42LBsK3TQ2z1qql9; Thu, 27 Sep 2018 00:08:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id sEcYjIMFJ6Wj; Thu, 27 Sep 2018 00:08:19 +0200 (CEST) X-Auth-Info: +VfsWiVnptGs8R0euN51ovntDv15rdXxE4yZJw5LG28= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 27 Sep 2018 00:08:19 +0200 (CEST) From: Lukasz Majewski To: Frieder Schrempf , boris.brezillon@bootlin.com, Mark Rutland Subject: [RFC/RFT PATCH v1 8/9] mtd: spi: Allocate memory corresponding to maximal fsl-quadspi.c controller area Date: Thu, 27 Sep 2018 00:07:38 +0200 Message-Id: <20180926220739.620-9-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180926220739.620-1-lukma@denx.de> References: <20180926220739.620-1-lukma@denx.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180926_150904_571185_8890D453 X-CRM114-Status: GOOD ( 11.92 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.18.0.9 listed in list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yogeshnarayan.gaur@nxp.com, richard@nod.at, broonie@kernel.org, linux-kernel@vger.kernel.org, Stefan Agner , linux-spi@vger.kernel.org, albert.aribaud@3adev.fr, prabhakar.kushwaha@nxp.com, linux-mtd@lists.infradead.org, david.wolfe@nxp.com, Fabio Estevam , han.xu@nxp.com, computersforpeace@gmail.com, Fabio Estevam , dwmw2@infradead.org, Lukasz Majewski MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This commit changes the way how QUADSPI controller allocates memory for reading data via AHB. After this change it is a fixed buffer with maximal size (for up to four SPI-NOR memories connected). In my case: ----------------- 0x0 SPI0 (QSPI0, A1 -> QUAD) ----------------- 0x1000000 HOLE ----------------- 0x2000000 SPI1 (QSPI0, B1 -> DUAL) ----------------- 0x3000000 HOLE ----------------- 0x4000000 Without this change, some single bytes are missing when reading single bytes from 256B buffer. dd if=/dev/mtd7 of=aaa.img bs=1 count=256 root@nix:~# hexdump aaa.img 0000000 464c eec0 baa5 c5ff 7b99 4dfb e0b6 8a2e 0000010 e98e 5265 683c a635 c069 e402 303f d936 0000020 c243 01a7 7064 fce8 e3a9 200a 7e85 28bc 0000030 4296 a30e 1bb4 88d4 b456 b4a6 f3aa 8cff 0000040 01c9 462d 0a43 f893 0e42 67f1 57f0 787c 0000050 49c0 fb2a e514 e954 1d21 affa bac4 38f1 0000060 1ca5 ec46 77eb a854 98b6 e71a c1cb 876c 0000070 b441 2baf ee33 596c 98b6 e71a c1cb 876c 0000080 7d8b 5739 5cca 873f c3df 8aca 2d5b 2bbb 0000090 5afe 6ad9 6072 b092 5ace 905b e217 faee 00000a0 58c6 6851 a1b9 c756 5ace 905b e217 faee 00000b0 b3dd 98be 0412 73d2 cbca c47c 6ab0 7c6d 00000c0 65cf b1e2 1457 a3cf 502b 6449 9a84 d83f 00000d0 a6e7 df30 b0e6 ea23 502b 6449 9a84 d83f 00000e0 5638 26bf d680 c47a 0225 6762 cf65 75fc 00000f0 2faa edf1 f8b6 dc13 ffff ffff ffff ffff 0000100 Signed-off-by: Lukasz Majewski --- drivers/mtd/spi-nor/fsl-quadspi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 97546fa70b79..915e5a203895 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -908,6 +908,9 @@ static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, struct fsl_qspi *q = nor->priv; u8 cmd = nor->read_opcode; int seqid; + size_t qlen = q->nor_size * 4; + int nor_idx = nor - q->nor; + size_t nor_ofs = q->nor_size * nor_idx; /* Set the actual lut sequence for AHB Read from the considered nor. */ seqid = fsl_qspi_get_seqid(q, nor->read_opcode); @@ -926,8 +929,9 @@ static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, /* if necessary,ioremap buffer before AHB read, */ if (!q->ahb_addr) { - q->memmap_offs = q->chip_base_addr + from; - q->memmap_len = len > QUADSPI_MIN_IOMAP ? len : QUADSPI_MIN_IOMAP; + q->memmap_offs = q->chip_base_addr; + q->memmap_len = qlen > QUADSPI_MIN_IOMAP ? + qlen : QUADSPI_MIN_IOMAP; q->ahb_addr = ioremap_nocache( q->memmap_phy + q->memmap_offs, @@ -942,8 +946,9 @@ static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, q->memmap_offs + q->memmap_len) { iounmap(q->ahb_addr); - q->memmap_offs = q->chip_base_addr + from; - q->memmap_len = len > QUADSPI_MIN_IOMAP ? len : QUADSPI_MIN_IOMAP; + q->memmap_offs = q->chip_base_addr; + q->memmap_len = qlen > QUADSPI_MIN_IOMAP ? + qlen : QUADSPI_MIN_IOMAP; q->ahb_addr = ioremap_nocache( q->memmap_phy + q->memmap_offs, q->memmap_len); @@ -954,12 +959,11 @@ static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, } dev_dbg(q->dev, "cmd [%x],read from %p, len:%zd\n", - cmd, q->ahb_addr + q->chip_base_addr + from - q->memmap_offs, + cmd, q->ahb_addr + nor_ofs + from - q->memmap_offs, len); /* Read out the data directly from the AHB buffer.*/ - memcpy(buf, q->ahb_addr + q->chip_base_addr + from - q->memmap_offs, - len); + memcpy(buf, q->ahb_addr + nor_ofs + from - q->memmap_offs, len); return len; }