Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp903792ybx; Thu, 7 Nov 2019 04:26:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwNQ7z6O4aAbl4LxhBr4sN3CadGz+DLv/DMyMaqwop+W/ntx3lr0Oywbk/zzGDpp/ZXCbcR X-Received: by 2002:a17:906:5502:: with SMTP id r2mr2770010ejp.3.1573129595625; Thu, 07 Nov 2019 04:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573129595; cv=none; d=google.com; s=arc-20160816; b=AennxDhdWjBV2B9FbVHcICau6BNIegnttuoRj5PBrKW4+tbm8N02EfJBdUYZZeG/Gy 0l9UM01ICpHzqKMTb5/2tbyIOh0SGBTxWl1YZbMy0uOTNFm5qlRdtfSSZMQ3jEOZtdIY VplVac7ETnJmM0VZN6tA2pLYFYB958ZzkpKVrtkIz5OhpMwGR2CdTySctw8Z8yPIGqsw tl/7yfHUZ3tt2jSazk+c6NZQ1ph7gEvLDaoaptVKl15UJAPjviusoaAScECWj1rpar3e y5uTlu9cSxyzV4TK5Y1oXkEUsNTDMgEl0LG6038eUdymMi8Df+ywRUaw0yjpjdrBa4Bs J8Ug== 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=E4MS55kwaW5g/5KMrdjN4z1SWbBuXuTiMq2j/PcjEiY=; b=FzmGHs8TFLJi7X2PFnm//Z7ga5qRWxCLqofDR7rFeNoWvOtbi6EaAduSxXwUyhN8tZ tp1JDu2aRLW5STgk0RjmHjnBoHlms/JWnLRnX58JBm9rMlvJUqKNEqNpXwhAmBkJ6Cnf bjYaxAmpbc464aJTt4epRwkMRd5BZeN+mu+Ba7YUt8NPYARlYxM4+235S7PkjxPrxAd+ 6veDyjA0EwaAu82aPYLmWSBC1DOsuftVMk4ZF7kez46TPhcBmFpDUTRehI8BOB83+Mvh rpgg3UZ0T5JUQfPznLgXYcAxMFP7qEiXutp+MMWvvBW+obdcVl1EVVQbUtTKnrUk2SOZ UutA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UW+6NMZI; 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 g20si1318771eda.229.2019.11.07.04.26.12; Thu, 07 Nov 2019 04:26:35 -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=UW+6NMZI; 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 S2388307AbfKGMZh (ORCPT + 99 others); Thu, 7 Nov 2019 07:25:37 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:46334 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbfKGMZh (ORCPT ); Thu, 7 Nov 2019 07:25:37 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA7CPAai081212; Thu, 7 Nov 2019 06:25:10 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573129510; bh=E4MS55kwaW5g/5KMrdjN4z1SWbBuXuTiMq2j/PcjEiY=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=UW+6NMZI2DNcg8/Yc8M2AkH9YUhIjG0ug6zMpSF8759STfMnQIXvG15KKYOZAgo98 va4Aooa7y2zRrtfb1gpbKTaiyzGKmaUyAAewm0RR+d6N0Q1IJ5hL9uzN+uqqMCbNdy RhjwN1TNyhG3OWeWQSVS9D3FIK/DfoxqTx5ovUFo= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA7CPAqU108742 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 7 Nov 2019 06:25:10 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE100.ent.ti.com (10.64.6.21) 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 06:24:55 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE112.ent.ti.com (10.64.6.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 06:24:55 -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 xA7CP57p097478; Thu, 7 Nov 2019 06:25:06 -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 , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , , , open list References: <20191106140748.13100-1-gch981213@gmail.com> <20191106140748.13100-2-gch981213@gmail.com> From: Vignesh Raghavendra Message-ID: Date: Thu, 7 Nov 2019 17:55:40 +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: 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 On 07/11/19 3:01 PM, Chuanhong Guo wrote: > Hi! > > On Thu, Nov 7, 2019 at 2:05 PM Vignesh Raghavendra wrote: >>> @@ -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? > > The mapped area is 256MB and I don't quite believe there will be such > a big NOR flash. > I'll add a check here in the next version. > There are 256MB (2GiB) NORs out there in market already. So, pretty soon, 256MB window won't be big enough :) >> >>> 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(). > > Cool. I'll change it. > Should I add another patch to change the same mapping operation right > above this piece of code? > That would be nice to do too, please send a separate patch. -- Regards Vignesh