From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754266AbcAXXHb (ORCPT ); Sun, 24 Jan 2016 18:07:31 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:13067 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751501AbcAXXH2 (ORCPT ); Sun, 24 Jan 2016 18:07:28 -0500 Date: Sun, 24 Jan 2016 23:07:54 +0000 From: "Maciej W. Rozycki" To: =?ISO-8859-2?Q?Rafa=B3_Mi=B3ecki?= CC: Brian Norris , 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 , "Maciej W. Rozycki" Subject: Re: [PATCH] mtd: bcm47xxsflash: use devm_ioremap_nocache() instead of KSEG0ADDR() In-Reply-To: Message-ID: 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> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-2" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.100.200.15] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 24 Jan 2016, Rafał Miłecki wrote: > On 24 January 2016 at 21:26, Maciej W. Rozycki wrote: > > On Sat, 23 Jan 2016, Brian Norris wrote: > > > >> IIUC, this could be solved by: > >> (a) using an uncached mapping or > >> (b) explicitly invalidating the relevant region after doing flash writes > >> or erasures > > > > Flash writes are usually much, much less frequent than reads, so > > optimising for reads is IMO the right direction. So a cached mapping is a > > good choice, however invalidation must then be done after a write. > > Can you give me some hint where to look at for cache invalidation? There is `flush_data_cache_page' only it would seem, which is also supported by the MIPS platform only. It makes unnecessary writebacks before invalidation, however these aren't really supposed to happen as no cache line involved is expected to be dirty. Implementing `invalidate_data_cache_page', which would avoid these unnecessary writebacks, should be straightforward as hardware provides the necessary operations and actually the MIPS port has suitable low-level helpers already implemented, for use by `dma_cache_inv'. So that would merely be a semi-mechanical copy, paste, rename operation applied to our source. The bigger problem is the lack of portability of this interface to other platforms, although I suspect some hardware may simply fail to provide required operations. For example x86 only defines the sledgehammer INVD/WBINVD instructions, which operate on the whole cache hierarchy at once rather than on a line-by-line and cache level/part basis. Maciej