Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp523384ybx; Wed, 6 Nov 2019 22:09:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyijOkthQGFVhC9M3KrMNZJAjmVef77YzWL4H7sb9dNNxttTuMn7if8rDy/kDSxm3sttBLI X-Received: by 2002:a17:906:80c1:: with SMTP id a1mr1441657ejx.37.1573106956109; Wed, 06 Nov 2019 22:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573106956; cv=none; d=google.com; s=arc-20160816; b=JHMqi68DbexDiWhznxMy4j4cxfHItwavqgfdCyjZK9yLxNi+nIocZt6o6oOyAmaCz6 +y163eA6buRpYgcWPnobb+kNGD4X2Gv1n5dnwHeYqj3LenN4bDQHaYU/TG85PLul4g3E j5CARfos29Ja6y4colyw0lpzRSxFkxZ0r8Zq1e1FUkH1igXYWVl13cpIX04jnFTxZIDU pwZcqdkSH+w2IfPiczBPpGUOpeROTvDzyEjQnCTLLw+X0iGlLSILT0khXzhhyoUV1Cc/ /7wvzlEeVBCv0alFrsQQW8QeKBjIy9dfMQTltmtvrTOCv6lTZFx3fdLBHFn7D4a53CuM L6iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=YkH6IrLLDyFL1c+gPK30RscWok8biguT1gLAoAK04AQ=; b=efHqPO10zLfUvQtCgIdR5RdD8jTX8HcMGEZrkeagnwND+7x673up3K/ImmsSHZJTxo w5SgwjPIRoBhCOXL5P90JuK8rheSw4yGvao4lh2cKDOMsVhRHbg9cjQd4hilax0TcXOL C5g4lIWaguAfic1P4JkYMxBOrRtcuLw7ncjTPf6nTBwHrPfbwjsiuZWmAV3hjusoGd6q wKt7dBmTVGJdXW6yw0t8aYMN0Xmw2A7DAq6DcVYkh3zMAUYtqvG9LYxO8hHwELk2IuOD jHDY8HYljokHlsebCElyvzfqUnrKL2+Wxsf+VbPFM3jVkJVbJUNHDwzouLiYQCVRw/8q YmlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JyLxr2bS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si764374eju.310.2019.11.06.22.08.52; Wed, 06 Nov 2019 22:09:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=JyLxr2bS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbfKGGF7 (ORCPT + 99 others); Thu, 7 Nov 2019 01:05:59 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:57202 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbfKGGF7 (ORCPT ); Thu, 7 Nov 2019 01:05:59 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA765W3J009455; Thu, 7 Nov 2019 00:05:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573106732; bh=YkH6IrLLDyFL1c+gPK30RscWok8biguT1gLAoAK04AQ=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=JyLxr2bSWrMfVthmAEKDODjrRZchD+nNQJMItKW8Ks3I7yHaZWFw/NTIXH9LXMMTV AWIDb9F9kpT/SN5TyhUkE9A3n9+YvhAFnqXIVAhig0y+YtQuKiXYnB8pXVCcFtPIRZ hkM+tcR7Sy5I+tIxRrSnbGDOEawmANuil8TnT33M= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA765W5w098483; Thu, 7 Nov 2019 00:05:32 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Thu, 7 Nov 2019 00:05:16 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 7 Nov 2019 00:05:16 -0600 Received: from [172.24.145.136] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA765RSj099257; Thu, 7 Nov 2019 00:05:28 -0600 Subject: Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading To: Chuanhong Guo , CC: David Woodhouse , Brian Norris , Miquel Raynal , Richard Weinberger , Rob Herring , Mark Rutland , Matthias Brugger , Tudor Ambarus , , , , References: <20191106140748.13100-1-gch981213@gmail.com> <20191106140748.13100-2-gch981213@gmail.com> From: Vignesh Raghavendra Message-ID: Date: Thu, 7 Nov 2019 11:36:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191106140748.13100-2-gch981213@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 06/11/19 7:37 PM, Chuanhong Guo wrote: > PIO reading mode on this controller is ridiculously inefficient > (one cmd+addr+dummy sequence reads only one byte) > This patch adds support for reading from memory-mapped flash area > which increases reading speed from 1MB/s to 5.6MB/s > > Signed-off-by: Chuanhong Guo > --- > drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c > index 34db01ab6cab..ba8b3be39896 100644 > --- a/drivers/mtd/spi-nor/mtk-quadspi.c > +++ b/drivers/mtd/spi-nor/mtk-quadspi.c > @@ -106,6 +106,7 @@ struct mtk_nor { > struct spi_nor nor; > struct device *dev; > void __iomem *base; /* nor flash base address */ > + void __iomem *flash_base; > struct clk *spi_clk; > struct clk *nor_clk; > }; > @@ -272,6 +273,11 @@ static ssize_t mtk_nor_read(struct spi_nor *nor, loff_t from, size_t length, > mtk_nor_set_read_mode(mtk_nor); > mtk_nor_set_addr(mtk_nor, addr); > > + if (mtk_nor->flash_base) { > + memcpy_fromio(buffer, mtk_nor->flash_base + from, length); > + return length; > + } > + Don't you need to check if access is still within valid memory mapped window? > for (i = 0; i < length; i++) { > ret = mtk_nor_execute_cmd(mtk_nor, MTK_NOR_PIO_READ_CMD); > if (ret < 0) > @@ -475,6 +481,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) > if (IS_ERR(mtk_nor->base)) > return PTR_ERR(mtk_nor->base); > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > + mtk_nor->flash_base = devm_ioremap_resource(&pdev->dev, res); There is a single API now: devm_platform_ioremap_resource(). > + if (IS_ERR(mtk_nor->flash_base)) > + mtk_nor->flash_base = NULL; > + > mtk_nor->spi_clk = devm_clk_get(&pdev->dev, "spi"); > if (IS_ERR(mtk_nor->spi_clk)) > return PTR_ERR(mtk_nor->spi_clk); > -- Regards Vignesh