From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751620AbcAXJoR (ORCPT ); Sun, 24 Jan 2016 04:44:17 -0500 Received: from mail-ig0-f180.google.com ([209.85.213.180]:34064 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbcAXJoH convert rfc822-to-8bit (ORCPT ); Sun, 24 Jan 2016 04:44:07 -0500 MIME-Version: 1.0 In-Reply-To: <20160123214918.GC24744@localhost> References: <1444813494-14985-1-git-send-email-javier@osg.samsung.com> <20151104185341.GN7274@google.com> <20160107230513.GL109450@google.com> <20160108185120.GQ109450@google.com> <20160123214918.GC24744@localhost> Date: Sun, 24 Jan 2016 10:44:06 +0100 Message-ID: Subject: Re: [PATCH] mtd: bcm47xxsflash: use devm_ioremap_nocache() instead of KSEG0ADDR() From: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= To: Brian Norris , Hauke Mehrtens Cc: "Maciej W. Rozycki" , Ralf Baechle , Javier Martinez Canillas , Linux Kernel Mailing List , Fengguang Wu , Michael Ellerman , Luis de Bethencourt , Jeremy Kerr , Neelesh Gupta , "linux-mtd@lists.infradead.org" , David Woodhouse , Cyril Bur Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23 January 2016 at 22:49, Brian Norris wrote: > On Sat, Jan 16, 2016 at 01:38:11AM +0100, Rafał Miłecki wrote: >> So I wanted to stick to the cached mapping, [...] > > I mentioned this earlier on, but I don't feel like I've gotten a clear > answer. Is a cached mapping actually safe here? From the looks of it, > the memory mapping is a read-only memory-mapped flash, and flash writes > / erasures are done through a different bus (register writes vis BCMA > bus). So if we have a cached mapping of that memory, it doens't > naturally synchronize with any write/erase operations. Doesn't this mean > you might get stale data if you do a sequence of read / erase / read, > for instance, since the 2nd read will return cached data from the 1st > read? > > IIUC, this could be solved by: > (a) using an uncached mapping or > (b) explicitly invalidating the relevant region after doing flash writes > or erasures > > But I wonder why you haven't seen any problems if you've been using > KSEG0 (cached) this whole time. Maybe just luck? Or you don't actually > write to the flash that much? Now you pointed this difference between reads and writes I sounds worrying indeed. I'm not aware of ever hitting this problem but maybe I just didn't use flash in a way triggering it? I'm looking for a way to test it. Using user space I could try doing something like: echo foo > a.txt cat a.txt echo bar > a.txt cat a.txt I guess even more reliable test would to be test in in kernel space. I guess I could modify bcm47xxsflash_write to read flash region that is going to be modified: before modification and after. Both reads using KSEG0ADDR. Then compare if the second read matches was was written. Does my idea for tests make sense? -- Rafał