Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1316315ybl; Wed, 21 Aug 2019 13:29:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9M4mfsFqXjx8ddnJ7APQ0AjHXzL/eFVtxYPMq32IKVxYCaQwlAO/WnElSqrb+VmTcyeqW X-Received: by 2002:a17:902:44f:: with SMTP id 73mr36310983ple.192.1566419397896; Wed, 21 Aug 2019 13:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566419397; cv=none; d=google.com; s=arc-20160816; b=At7oJXcIOiEpXummKXisS3JCSR88t5prDHw+ncwE7L1cbmsOcNbbTZTvERcDMXLats f87en8RBxfmwP/o1bEh9StkyDQkohu76UDObWWKdMHkGx5ru6Fi2t1nTV0Z1BDVvZXm6 mRQs7xgG5zdi0lmmJ13foWJ6FzcZX0gIiC1ryLxFO45fQQfsRCv0DQWfj5ep+E+ku4Fl xj6645auTsW7b1TvF91PdvG6R/UgoRmG4wDx19xbUzeY0OR74qrcsUhLAKNptHpSlmCA G96nTvAN92fiLz26ZXC9hStYESW1116ArKPVxlD49mQud9WCZzw1mHkL6trsAuVSbX8F 8z+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=enIzX4gTmPO57E1bMI8/3i3N4dyfDt6FfgzQCgdsq8c=; b=foAccdN4RQvl3TDAdXjRRTGRvdcIwLK7ei0JPkmHelO3Eavvvbl+yeaB5RTKb1yz+v fFJmqyZ3sizfGwPhlKHAz1xfxJ/1HXzwVdmb2TPg6IUGGG0SC3LkhYUimx5+/YBUJNfx HZC0nuj4powEG14fGGLOkOLyMAOa1Gj3oDNR96HuTLu17sNTStrL/peOw/99hBHrBt64 wGJtLBJu5AsiyIqFRoLZ/8C7vr21kYk+T2FW9CexP5nSf4DLwhZDRnh+C3BwoynquD6b G4N8jTvhiBqrybM7GoD1tTLDaruXVLggycvx9p3YnQgjxSLyAYyC9y6oO1B9I6lCbnn9 cCWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=UEGX7GLD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m190si1086994pga.322.2019.08.21.13.29.38; Wed, 21 Aug 2019 13:29:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=UEGX7GLD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfHUU1G (ORCPT + 99 others); Wed, 21 Aug 2019 16:27:06 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:45376 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726998AbfHUU1G (ORCPT ); Wed, 21 Aug 2019 16:27:06 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46DK2d1nKsz9txLD; Wed, 21 Aug 2019 22:27:05 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=UEGX7GLD; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id omHAs3bIZtOR; Wed, 21 Aug 2019 22:27:05 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 46DK2d0ct3z9txLC; Wed, 21 Aug 2019 22:27:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1566419225; bh=enIzX4gTmPO57E1bMI8/3i3N4dyfDt6FfgzQCgdsq8c=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=UEGX7GLD3G7m5UQVeRbUtXvlSn3u2/0mfAA/bWVbpbl0amwzLCj/Bvno6MzlW48Ht fvD6s2zS7bjFRsNBLRNLJ/wy5O1Rw3WjXClo/3zfsZTXDjbGtB7n+jUN2kqpO1McrW biIyhp/gI7U8HwthutgxFHrgzMNbYHdvaeSySXp4= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2D27A8B7FA; Wed, 21 Aug 2019 22:27:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id eD9Vv9KqC7Og; Wed, 21 Aug 2019 22:27:05 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C6A958B7F9; Wed, 21 Aug 2019 22:27:04 +0200 (CEST) Subject: Re: [RFC PATCH] powerpc: Convert ____flush_dcache_icache_phys() to C To: Alastair D'Silva , Segher Boessenkool Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <9887dada07278cb39051941d1a47d50349d9fde0.camel@au1.ibm.com> From: Christophe Leroy Message-ID: Date: Wed, 21 Aug 2019 22:27:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <9887dada07278cb39051941d1a47d50349d9fde0.camel@au1.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 20/08/2019 à 06:36, Alastair D'Silva a écrit : > On Fri, 2019-08-16 at 15:52 +0000, Christophe Leroy wrote: [...] > > > Thanks Christophe, > > I'm trying a somewhat different approach that requires less knowledge > of assembler. Handling of CPU_FTR_COHERENT_ICACHE is outside this > function. The code below is not a patch as my tree is a bit messy, > sorry: Can we be 100% sure that GCC won't add any code accessing some global data or stack while the Data MMU is OFF ? Christophe > > /** > * flush_dcache_icache_phys() - Flush a page by it's physical address > * @addr: the physical address of the page > */ > static void flush_dcache_icache_phys(unsigned long addr) > { > register unsigned long msr; > register unsigned long dlines = PAGE_SIZE >> l1_dcache_shift(); > register unsigned long dbytes = l1_dcache_bytes(); > register unsigned long ilines = PAGE_SIZE >> l1_icache_shift(); > register unsigned long ibytes = l1_icache_bytes(); > register unsigned long i; > register unsigned long address = addr; > > /* > * Clear the DR bit so that we operate on physical > * rather than virtual addresses > */ > msr = mfmsr(); > mtmsr(msr & ~(MSR_DR)); > > /* Write out the data cache */ > for (i = 0; i < dlines; i++, address += dbytes) > dcbst((void *)address); > > /* Invalidate the instruction cache */ > address = addr; > for (i = 0; i < ilines; i++, address += ibytes) > icbi((void *)address); > > mtmsr(msr); > } > > void test_flush_phys(unsigned long addr) > { > flush_dcache_icache_phys(addr); > } > > > This gives the following assembler (using pmac32_defconfig): > 000003cc : > 3cc: 94 21 ff f0 stwu r1,-16(r1) > 3d0: 7d 00 00 a6 mfmsr r8 > 3d4: 55 09 07 34 rlwinm r9,r8,0,28,26 > 3d8: 7d 20 01 24 mtmsr r9 > 3dc: 39 20 00 80 li r9,128 > 3e0: 7d 29 03 a6 mtctr r9 > 3e4: 39 43 10 00 addi r10,r3,4096 > 3e8: 7c 69 1b 78 mr r9,r3 > 3ec: 7c 00 48 6c dcbst 0,r9 > 3f0: 39 29 00 20 addi r9,r9,32 > 3f4: 42 00 ff f8 bdnz 3ec > 3f8: 7c 00 1f ac icbi 0,r3 > 3fc: 38 63 00 20 addi r3,r3,32 > 400: 7f 8a 18 40 cmplw cr7,r10,r3 > 404: 40 9e ff f4 bne cr7,3f8 > 408: 7d 00 01 24 mtmsr r8 > 40c: 38 21 00 10 addi r1,r1,16 > 410: 4e 80 00 20 blr > >