Received: from mail-wm0-f66.google.com ([74.125.82.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cUKJ7-00046U-Pv for linux-mtd@lists.infradead.org; Thu, 19 Jan 2017 21:31:47 +0000 Received: by mail-wm0-f66.google.com with SMTP id c85so2034727wmi.1 for ; Thu, 19 Jan 2017 13:31:25 -0800 (PST) Subject: Re: [PATCH V2] mtd: bcm47xxsflash: support reading flash out of mapping window To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= References: <20170116220916.2603-1-zajec5@gmail.com> <20170117105110.26328-1-zajec5@gmail.com> <31ca1f51-887d-fce4-400c-cc0f97353eb8@gmail.com> <4e268f6f-42fd-84a8-2b28-6ebb5129d945@gmail.com> Cc: David Woodhouse , Brian Norris , Boris Brezillon , Richard Weinberger , Cyrille Pitchen , "linux-mtd@lists.infradead.org" , Hauke Mehrtens , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= From: Marek Vasut Message-ID: <78f2d03d-e916-c5ea-aea3-c1d860921e7d@gmail.com> Date: Thu, 19 Jan 2017 22:30:21 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 01/17/2017 01:04 PM, Rafał Miłecki wrote: > On 17 January 2017 at 12:49, Marek Vasut wrote: >> On 01/17/2017 12:08 PM, Rafał Miłecki wrote: >>> On 17 January 2017 at 12:00, Marek Vasut wrote: >>>> On 01/17/2017 11:51 AM, Rafał Miłecki wrote: >>>>> From: Rafał Miłecki >>>>> >>>>> For reading flash content we use MMIO but it's possible to read only >>>>> first 16 MiB this way. It's simply an arch design/limitation. >>>>> To support flash sizes bigger than 16 MiB implement indirect access >>>>> using ChipCommon registers. >>>>> This has been tested using MX25L25635F. >>>>> >>>>> Signed-off-by: Rafał Miłecki >>>>> --- >>>>> V2: Simplify line writing to buf >>>>> Add some trivial comment for OPCODE_ST_READ4B >>>>> Both requested by Marek >>>>> --- >>>>> drivers/mtd/devices/bcm47xxsflash.c | 12 +++++++++++- >>>>> drivers/mtd/devices/bcm47xxsflash.h | 3 +++ >>>>> 2 files changed, 14 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c >>>>> index 4decd8c..8d4c1db 100644 >>>>> --- a/drivers/mtd/devices/bcm47xxsflash.c >>>>> +++ b/drivers/mtd/devices/bcm47xxsflash.c >>>>> @@ -110,7 +110,17 @@ static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len, >>>>> if ((from + len) > mtd->size) >>>>> return -EINVAL; >>>>> >>>>> - memcpy_fromio(buf, b47s->window + from, len); >>>>> + if (from + len <= BCM47XXSFLASH_WINDOW_SIZE) { >>>>> + memcpy_fromio(buf, b47s->window + from, len); >>>> >>>> One last nit, what if the read starts < 16 MiB and ends > 16 MiB ? >>>> Shouldn't that use partly the windowed mode and partly the other mode? >>> >>> You'll lost 10ns*... or not as splitting it into 2 code paths could >>> take longer, who knows. Most access are block aligned anyway. I don't >>> think such corner case with doubtful gain is much worth considering & >>> optimizing. >> >> So you can also read the first 16 MiB using the new method , right ? > > I could, but this could be noticeable in performance. Reading 16 MiB > using slower method is different from reading what... a few KiB? Are > you actually sure mtd does unaligned reads at all? No, but I'm quite sure the code above can be pushed to misbehave and I'm trying to confirm/refute that. > Please let's argue about real problems and not few % performance in > some corner case on some obsolete hardware with poor design. OK, real issue: $ dd if=/dev/mtdX of=/dev/null bs=32M How will this driver handle it ? -- Best regards, Marek Vasut