Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2182646ybe; Tue, 3 Sep 2019 09:06:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/QwuqEpPcJpOgv6w4j1HYJ1Ypdkuhl+MEWyLPBclscW3QvQmo4av0poGDYkb2PJmC2Uqq X-Received: by 2002:a17:90a:ca0c:: with SMTP id x12mr3070pjt.61.1567526793250; Tue, 03 Sep 2019 09:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567526793; cv=none; d=google.com; s=arc-20160816; b=KOca8xDovuMJALd91keDvOzgcToGFkKG19B0EuQ+dPIL1z29kbt9pLLF5mpiFvieE5 X8GFn41+6JiigoogQiOZDVMQ0xdMBlLAhwXJKQQUc7oesD3dN9V2MP+M7fMBGB/WfBi/ bGL7BetIzkPGrbAwIejyIhCMS53Dmo4Ty1cpXtwoMb+xR60ed2dtm47yENj8bLFo89N9 orpdHuYP2QPqdy9CwalZT3ocQGXOaizMDl7sihWSBMIg+vuXTo4E/taR44zICVwwpLat y/5G6MUsUVzmlKH9IIzMZR0117QpKw4FNC/1LkEVgZL+2GOay8+gKErF28towM5Yr6+0 1hmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=M4CuniKe7T5n98vdKbY9ELuYOdaBC9KBPqL5kNYt+sY=; b=u5fw+JrnqFTSRevevH0UHy6rZN8OxaZN7r0VklrxfYuKjrhxHtfBRvu0IyqDoFL9Kh UrEtTA8SlZ/EYhTrDfd46uEgd5JB4mHZ0rYB/Zn6lDC7KVKjmSOBtwo8/1R/7IkWpuv9 4SbwvY8dOvcHKQrw4A+ePmNCqdAWrcig7ZzfvV/S/WfWE0YEJqCOnkNisyFTGuBoS5Bf OvT3w5eeUsXS+KF1LfZKZVyaK6WBIzm3D/HjneewUmCvR0LSjETYYnTUUCZvBS4NkTa3 aDEbmHm0/j373DSHFaUoqrdQSusT75+ASe1EkpixJmmFAWCo8cHjCcuvopp+qb7ZAX70 2dHw== ARC-Authentication-Results: i=1; mx.google.com; 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 84si11666526pfw.121.2019.09.03.09.06.16; Tue, 03 Sep 2019 09:06:33 -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; 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 S1729867AbfICQFD (ORCPT + 99 others); Tue, 3 Sep 2019 12:05:03 -0400 Received: from gate.crashing.org ([63.228.1.57]:55972 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728571AbfICQFD (ORCPT ); Tue, 3 Sep 2019 12:05:03 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x83G4HnT010981; Tue, 3 Sep 2019 11:04:17 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x83G4F0O010980; Tue, 3 Sep 2019 11:04:15 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 3 Sep 2019 11:04:15 -0500 From: Segher Boessenkool To: Christophe Leroy 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 Subject: Re: [PATCH v2 3/6] powerpc: Convert flush_icache_range & friends to C Message-ID: <20190903160415.GA9749@gate.crashing.org> References: <20190903052407.16638-1-alastair@au1.ibm.com> <20190903052407.16638-4-alastair@au1.ibm.com> <20190903130430.GC31406@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Segher