From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932147AbcBZKln (ORCPT ); Fri, 26 Feb 2016 05:41:43 -0500 Received: from mail-ig0-f178.google.com ([209.85.213.178]:33660 "EHLO mail-ig0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251AbcBZKlk convert rfc822-to-8bit (ORCPT ); Fri, 26 Feb 2016 05:41:40 -0500 MIME-Version: 1.0 In-Reply-To: References: <1452991370-20121-1-git-send-email-zajec5@gmail.com> Date: Fri, 26 Feb 2016 11:41:39 +0100 Message-ID: Subject: Re: [PATCH] mtd: bcm47xxsflash: use ioremap_cachable() instead of KSEG0ADDR() From: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= To: "Maciej W. Rozycki" Cc: Brian Norris , "linux-mtd@lists.infradead.org" , Javier Martinez Canillas , Linux Kernel Mailing List , Fengguang Wu , Michael Ellerman , Luis de Bethencourt , Jeremy Kerr , Neelesh Gupta , David Woodhouse , Cyril Bur , Ralf Baechle 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 24 January 2016 at 21:17, Maciej W. Rozycki wrote: > On Sun, 17 Jan 2016, Rafał Miłecki wrote: > >> KSEG0ADDR was translating 0x1c000000 into 0x9c000000. With >> ioremap_cachable we use MIPS's __ioremap (and remap_area_pages). This >> results in different address (e.g. 0xc0080000) but it still should be >> cached as expected and it was successfully tested with BCM47186B0. > > This is due to this piece: > > /* > * Map uncached objects in the low 512mb of address space using KSEG1, > * otherwise map using page tables. > */ > if (IS_LOW512(phys_addr) && IS_LOW512(last_addr) && > flags == _CACHE_UNCACHED) > return (void __iomem *) CKSEG1ADDR(phys_addr); > > special-casing uncached mapping only (replicated in 2 places). I think > there will really be no harm from returning a KSEG0 mapping for calls > requesting a caching mode equal to `_page_cachable_default', which -- > depending on the cache architecture -- will have been either hardwired or > prearranged via Config.K0. I think there's really no need to put pressure > on the TLB, which may be small, in cases where a fixed mapping will do. No, it isn't hitting condition you pointed. We call ioremap_cachable which uses _page_cachable_default as a flag. This flag (_page_cachable_default) isn't equal to the _CACHE_UNCACHED. Moreover code you pointed uses CKSEG1ADDR which would result in setting bit KSEG1 (0xa0000000). As I pointed in the commit message address it ORed with KSEG2 (0xc0000000). So what really happens is what my commit message says: ioremap_cachable -> __ioremap -> remap_area_pages