Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2257810ybe; Tue, 3 Sep 2019 10:06:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbhpj+caBclnP6JNsHRcgSROJDNmUAA4x+lcmMXRYtvaJan5FY9/M64dY2Xfm34pQv+xfs X-Received: by 2002:a17:90a:a47:: with SMTP id o65mr334150pjo.90.1567530410714; Tue, 03 Sep 2019 10:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567530410; cv=none; d=google.com; s=arc-20160816; b=jiR4PuHacaWC0haTuE7u7UIdAT00DJDqeEsOsbSQX7u3h1hTqtRvD7Amip6nDC6mPP DtxsydXy14BZ583UMGy9aM46nJdvzklIOaWw41H2dGfxz++2hWwn+YUt9YBhIVwpBLKj a8asYO3+yCQZW/jpwU68vCR++F6pljAFkb7vW1CwpLQtfBdl3H0TwbodLh9+H9KTJxuh dwKiA5d7QMgrVJqO4tguBzfD3AUcivpe9XMV/34bNDb6PZZw8BzR+2A/0Kfc8VBA8e20 iR/4ilCNBGIy7r7i/gdQ/WxKxAE4/ZE9f7jHlWCqHwwl4SHzFJGSb7Q6V4huo+THJZJa hDIg== 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=AnfdWi7CX7QvptJ7TwWSoc3U0kxIA1QpOhq4tZSTQk8=; b=jxr4ZwIyIo4heV2UEXTJ/SUOvSr+rFfsOFtHw/KaIutmDhpIdOkytkdMysayVJSG8J De32v/UrVnBBZbYOZ9IXTvvS6Q57XlK8rgstIn6GHqi5E5kmaf4kAiZdJzYiQhdyu8+A Nb2qSCY26OBpXmX3ozHqcuS15hzdEl7wWelujdwOrwNBkQxICClaoYx+4T6e8wSOfcD6 ti9FEsAUzStxGJgHvsGWqqROf3CA4egkNX/eaJ6ai1pG8kXowjR5588CV7fbNrHaP5Ml UkT4i/OFDQD8iBxuBHQ0wOV1rupGkGiNRHHz9pZC+mNY8ScaPp1H91qlPemMom69lxH7 qnKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=ddSKJmtr; 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 y1si14947653pgg.490.2019.09.03.10.06.23; Tue, 03 Sep 2019 10:06:50 -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=ddSKJmtr; 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 S1729993AbfICRFX (ORCPT + 99 others); Tue, 3 Sep 2019 13:05:23 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:23676 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729056AbfICRFX (ORCPT ); Tue, 3 Sep 2019 13:05:23 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46NCxq6NB6z9ttSV; Tue, 3 Sep 2019 19:05:19 +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=ddSKJmtr; 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 2vuLju-xL0CH; Tue, 3 Sep 2019 19:05:19 +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 46NCxq4srnz9ttSS; Tue, 3 Sep 2019 19:05:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1567530319; bh=AnfdWi7CX7QvptJ7TwWSoc3U0kxIA1QpOhq4tZSTQk8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ddSKJmtrXauwW4OQ6ofNnTtFBI+TtMnI5tc2ICEKqvmDV99s9XBTUUvaCveYJKiOn dYmIPLo+ZtS6vMUnwVYFivmyZt1RnNbsVJ6GjmLVgcgR9Dm/hCzcW2WxA8EJJ9pdsg 5W2eLVduyBHO62mxytTV99pyvo02DZ/JJikdgzLk= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 640B18B881; Tue, 3 Sep 2019 19:05:21 +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 wUZWLHRixqsD; Tue, 3 Sep 2019 19:05:21 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 308678B86E; Tue, 3 Sep 2019 19:05:20 +0200 (CEST) Subject: Re: [PATCH v2 3/6] powerpc: Convert flush_icache_range & friends to C To: Segher Boessenkool Cc: Alastair D'Silva , David Hildenbrand , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Nicholas Piggin , Mike Rapoport , Paul Mackerras , alastair@d-silva.org, Qian Cai , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, Andrew Morton , Allison Randal References: <20190903052407.16638-1-alastair@au1.ibm.com> <20190903052407.16638-4-alastair@au1.ibm.com> <20190903130430.GC31406@gate.crashing.org> <20190903160415.GA9749@gate.crashing.org> From: Christophe Leroy Message-ID: <321b003a-9633-5ff4-c4a2-59a47ec23421@c-s.fr> Date: Tue, 3 Sep 2019 19:05:19 +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: <20190903160415.GA9749@gate.crashing.org> 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 03/09/2019 à 18:04, Segher Boessenkool a écrit : > On Tue, Sep 03, 2019 at 04:28:09PM +0200, Christophe Leroy wrote: >> Le 03/09/2019 à 15:04, Segher Boessenkool a écrit : >>> On Tue, Sep 03, 2019 at 03:23:57PM +1000, Alastair D'Silva wrote: >>>> + asm volatile( >>>> + " mtctr %2;" >>>> + " mtmsr %3;" >>>> + " isync;" >>>> + "0: dcbst 0, %0;" >>>> + " addi %0, %0, %4;" >>>> + " bdnz 0b;" >>>> + " sync;" >>>> + " mtctr %2;" >>>> + "1: icbi 0, %1;" >>>> + " addi %1, %1, %4;" >>>> + " bdnz 1b;" >>>> + " sync;" >>>> + " mtmsr %5;" >>>> + " isync;" >>>> + : "+r" (loop1), "+r" (loop2) >>>> + : "r" (nb), "r" (msr), "i" (bytes), "r" (msr0) >>>> + : "ctr", "memory"); >>> >>> This outputs as one huge assembler statement, all on one line. That's >>> going to be fun to read or debug. >> >> Do you mean \n has to be added after the ; ? > > Something like that. There is no really satisfying way for doing huge > inline asm, and maybe that is a good thing ;-) > > Often people write \n\t at the end of each line of inline asm. This works > pretty well (but then there are labels, oh joy). > >>> loop1 and/or loop2 can be assigned the same register as msr0 or nb. They >>> need to be made earlyclobbers. (msr is fine, all of its reads are before >>> any writes to loop1 or loop2; and bytes is fine, it's not a register). >> >> Can you explicit please ? Doesn't '+r' means that they are input and >> output at the same time ? > > That is what + means, yes -- that this output is an input as well. It is > the same to write > > asm("mov %1,%0 ; mov %0,42" : "+r"(x), "=r"(y)); > or to write > asm("mov %1,%0 ; mov %0,42" : "=r"(x), "=r"(y) : "0"(x)); > > (So not "at the same time" as in "in the same machine instruction", but > more loosely, as in "in the same inline asm statement"). > >> "to be made earlyclobbers", what does this means exactly ? How to do that ? > > You write &, like "+&r" in this case. It means the machine code writes > to this register before it has consumed all asm inputs (remember, GCC > does not understand (or even parse!) the assembler string). > > So just > > : "+&r" (loop1), "+&r" (loop2) > > will do. (Why are they separate though? It could just be one loop var). Yes it could just be a single loop var, but in that case it would have to be reset at the start of the second loop, which means we would have to pass 'addr' for resetting the loop anyway, so I opted to do it outside the inline asm by using to separate loop vars set to their starting value outside the inline asm. Christophe