Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756199AbcC2I3a (ORCPT ); Tue, 29 Mar 2016 04:29:30 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:49826 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753455AbcC2I31 (ORCPT ); Tue, 29 Mar 2016 04:29:27 -0400 Date: Tue, 29 Mar 2016 10:29:12 +0200 From: Ralf Baechle To: Lars Persson Cc: Paul Burton , "Steven J. Hill" , "linux-mips@linux-mips.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/4] MIPS: Flush dcache for flush_kernel_dcache_page Message-ID: <20160329082911.GC11282@linux-mips.org> References: <1456799879-14711-1-git-send-email-paul.burton@imgtec.com> <1456799879-14711-2-git-send-email-paul.burton@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1990 Lines: 44 On Fri, Mar 04, 2016 at 03:09:00PM +0000, Lars Persson wrote: > > 1 mars 2016 kl. 03:38 Paul Burton : > > > > The flush_kernel_dcache_page function was previously essentially a nop. > > This is incorrect for MIPS, where if a page has been modified & either > > it aliases or it's executable & the icache doesn't fill from dcache then > > the content needs to be written back from dcache to the next level of > > the cache hierarchy (which is shared with the icache). > > > > Implement this by simply calling flush_dcache_page, treating this > > kmapped cache flush function (flush_kernel_dcache_page) exactly the same > > as its non-kmapped counterpart (flush_dcache_page). > > > > Signed-off-by: Paul Burton > > --- > > > > arch/mips/include/asm/cacheflush.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h > > index 723229f..7e9f468 100644 > > --- a/arch/mips/include/asm/cacheflush.h > > +++ b/arch/mips/include/asm/cacheflush.h > > @@ -132,6 +132,7 @@ static inline void kunmap_noncoherent(void) > > static inline void flush_kernel_dcache_page(struct page *page) > > { > > BUG_ON(cpu_has_dc_aliases && PageHighMem(page)); > > + flush_dcache_page(page); > > Should we use instead __flush_dcache_page() that flushes immediately for mapped pages ? Steven J Hill's old patch set for highmem had done it like this. Delayed flushing should be ok for lowmem where each page has a permanent virtual address. With highmem the temporary address assigned by the kmap_* function may change so the flush needs to be performed immediately. Special case highmem without cache aliases - the exact virtual address doesn't matter, so this should be fine. Cache flushes are expensive so delaying if possible is always a good thing. Steven's patches afair were trying to tackle the highmem with aliases case so an immediately flush was required. Ralf