Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp719206ybx; Thu, 7 Nov 2019 01:34:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyWs4/J73+fdv6+kN8/L5QYjPrwg8FKXkOd9RaOJMXQNssn7ucfdevj9rWpI68IikC2EMg2 X-Received: by 2002:a17:906:48b:: with SMTP id f11mr1990020eja.225.1573119280550; Thu, 07 Nov 2019 01:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573119280; cv=none; d=google.com; s=arc-20160816; b=uTb45+di+s1AxZifiDF6GUrtl6Uc3gbh5bpJl1eLfLgn7mcDr9Z1a5gflOuy6zpmdq cGX8sPmFlDVMRrKn9r9ji7BKlz809i/OaC7eDsbPjJr0xCsdArE8XA1OQeC64mf0ssle lugekeEBCrLxkyPbRQnqQpd5Oev/UuNCVx9X4to7JZ3oOxdm3XLKRB8bPrIkfb+uE5sZ 3G4r0JwFIwZtNjsbRJxadiwZ6yBNojZ09RCPWqx6B8wCnKafmykWlJzdj9tULJG3KBjq F11hVi9yzOWgfzlVWhPjAOKLzUkn1NvqIYzat6aUWd2Bm4phYJsUspLsHOnB2+5KJhRx caIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Iuasj2afgMJAzja6uysg+1QDLDZRD47UOISLXL9pb2M=; b=nq/kd7/ti3R3KcCG03EWK2RcAwMNE1hFtLCnsa0M7vSWh7aaSI8/3XXFiHhZEon+hx 6CPtkb3rwICQyWqrBDlGXzCP4m1zORUpYH+8sKZkYhGGSH6vRrROblUsvLRWSbQLPkKx 86STltQqnwKWjuSE8qrGDCz80V0nr9jKnR4X4/EIgOalPBcqHv1GefuwFBzJPL8Csv72 nbekVjAEwb/K48FMKp978N9cTPn2xfsmPLSfd4G2/UMrwQeDQflti+FVzJFeJ+ojdnkT WRqc30NSmfUQ1jUljkwMhpm35EVHrpeiM0ZZk2h+vItMy8Syzpug4loPJWXmOF+OquY0 QMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mAChVYxc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx16si1065117ejb.353.2019.11.07.01.34.17; Thu, 07 Nov 2019 01:34:40 -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=@gmail.com header.s=20161025 header.b=mAChVYxc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733205AbfKGJbs (ORCPT + 99 others); Thu, 7 Nov 2019 04:31:48 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:44538 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbfKGJbr (ORCPT ); Thu, 7 Nov 2019 04:31:47 -0500 Received: by mail-ot1-f65.google.com with SMTP id c19so1400191otr.11; Thu, 07 Nov 2019 01:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Iuasj2afgMJAzja6uysg+1QDLDZRD47UOISLXL9pb2M=; b=mAChVYxcoSkGwnhp7ff0QokhxUd9QPmLoT9Cn1E5xIr6i0h+cx4rUyZ+2s5Xciwe/i Kq4kM1DVxxmaURAxoZGrw+n/+u10deLVn2EQpK/BzXp8JvX+qpdFP6mu/BJgzNKVqvus Zf8mTPaeOflRCP43BUE0t5I5xFGekUFkw0KjgYSTC3QxMZV3o/1Hm4mLGZ2ntTOtERUF F7kYt6w5xMOSvINLjuEcwvaqvMMNY6g6uy/k2pa3Gv9Gd4uBV6k2YrUj+N+54vPfLVnB Movv9Q+DXqaspibA9j9xhl8o1i20Y1d74H70SIvtktZr5MOD0HjDgGD8jXq9Rm6axuHc h2eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Iuasj2afgMJAzja6uysg+1QDLDZRD47UOISLXL9pb2M=; b=euef7+ndpJZuI+gpbtn9hNwciUDDyo2j3bmmw/6iSfCtpPNWdso3nuvjLgyRPYupho Lb0TuFKiooQkK1TmlKxnwnrGJScyZZdxwmplODlJFB99ElJXhpWfMyAjJ2FVLg6yExWw wbPb4fJ8eTHWgvGOP/nEDf2cCoq935L3N1bKQWgMmCAD/iN/oOy3rWFlV7kf1BaeIuxi n5rqd+GaJFBvXphFhrym/VFHBn1D9FNJW84WEWEHJUw30HmqkF5Y83f0GqfokW6oHKC6 VfHZgJNtFYtYoEV22qjnyCPcObgtwW6ckIVU98wQBwaTdZIETrkygBzWzmek1AektT9s b8Ow== X-Gm-Message-State: APjAAAXFgPV706cUm2AXOMx56hFL9PF5SCycCkebNfiviHawPGgTCZKJ O+meNXNwIIvRVNZp6Ay2Flt6e+uhKZ//iyxEasY= X-Received: by 2002:a9d:1b0d:: with SMTP id l13mr193968otl.84.1573119106712; Thu, 07 Nov 2019 01:31:46 -0800 (PST) MIME-Version: 1.0 References: <20191106140748.13100-1-gch981213@gmail.com> <20191106140748.13100-2-gch981213@gmail.com> In-Reply-To: From: Chuanhong Guo Date: Thu, 7 Nov 2019 17:31:35 +0800 Message-ID: Subject: Re: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading To: Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, 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" , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > 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? Regards, Chuanhong Guo