Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14124283rwd; Sat, 24 Jun 2023 12:33:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PB5oxp9uOrNe/jSskqplzaSxxsqpQrHT/d0QNlgnATsD8Dp1z/DxG/mnuid2ENF/38/zB X-Received: by 2002:a05:6808:c2:b0:3a1:a3ea:1c8e with SMTP id t2-20020a05680800c200b003a1a3ea1c8emr5893842oic.41.1687635214853; Sat, 24 Jun 2023 12:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687635214; cv=none; d=google.com; s=arc-20160816; b=GjQat4zXn6FlamtnqXR3p2NwHLPuaARjaE7+Fb0TFp9fNa7zyEwndLtzL7kCy+r+m2 HHtuKCyZll+t/dGnMOZ4coZs5r8U5G/X1NG6litU7yElIP3Q37af9v3QxzqIVirE5C5m N1APc1KONSirTtAV/BS9iemTvZGv8xiouZ1ipKllwcBjfVNmCltZ+BvVfF8dIhwnckr6 S0RGyGw0plOhuDn3/mXwix/0s0AdRpmjw0fHoJpfGU6q+WBaW2Qd4rdNPhchQV4/IvWB CXAnTS/Ct2lBfOybQTH9jiCrYftJQF87vJC2w6E7D0m/9QKZIOuOgqjsj20vPeX7/9ja oEmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=rAV7UtHSuw0mLmYs0UW2+0Do5DZlDbBrRa4hdB5RS58=; fh=yQQm085ioXeenTQpQW4eH7wf7q1HFY1xXvabjgASDoo=; b=cvPC29aQnLNQqS137VdiJKuoSpER7S+h0DnmwJpcuBnQwys0xboQ5Q22pYUODaI2m0 twX/Y2mE4Th/5XJRQQ/i4KiPXGbTw/IeDJjuN1IbUIDUW6URjmDIkjBAPt0JwmrlXBiE wrEiXLAqGszt4vGqlD+LbvAcn/DeLux5GoQXYE4g57LJUtMhExdroIhK5ayLykBVDlGB ppRyT6aDk5JKnlKZAbMgjhDPLwvLFk6YYgieQ8Gv3gXHzMMx+mKdqd7lZJNOrlJcCJx9 8iZWaqRfQbrfIM6NHrC/Zme5V3yv436xkhKtVtKrOmePTTfU9oLDT2uRrgzMJpbv9lbr EK8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=aHiBj05Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a17090a1a5d00b0025be125bda9si2077792pjl.38.2023.06.24.12.33.22; Sat, 24 Jun 2023 12:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=aHiBj05Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbjFXSzM (ORCPT + 99 others); Sat, 24 Jun 2023 14:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230402AbjFXSzL (ORCPT ); Sat, 24 Jun 2023 14:55:11 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3910510C1; Sat, 24 Jun 2023 11:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1687632909; bh=oo6VmKW0AOTDXj8uyzFXInC7kU3r7LeBNtZEkPWntsw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=aHiBj05YaEhpfOsbFJ3nN1slNomy2D3xL//GZz9GuDUEj0fYrrruvMNhRU8c88ByC H74ORg9kq5QkCCbZP7V7rKkyJw2X4TgZpKPk5kh6DNdyAQau+mSjV1XbdF6zmU1Red 2IXXgDqfzWKpgJBTsVWc/qobPlKXxTDaqSb+EZyE= Received: from [IPv6:240e:358:11d2:6c00:dc73:854d:832e:2] (unknown [IPv6:240e:358:11d2:6c00:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 2D2CE65EC2; Sat, 24 Jun 2023 14:55:05 -0400 (EDT) Message-ID: Subject: Re: [PATCH v2 5/9] LoongArch: Simplify the invtlb wrappers From: Xi Ruoyao To: WANG Xuerui , Huacai Chen Cc: WANG Rui , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Date: Sun, 25 Jun 2023 02:55:01 +0800 In-Reply-To: <20230624184055.3000636-6-kernel@xen0n.name> References: <20230624184055.3000636-1-kernel@xen0n.name> <20230624184055.3000636-6-kernel@xen0n.name> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.3 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2023-06-25 at 02:40 +0800, WANG Xuerui wrote: > From: WANG Xuerui >=20 > The invtlb instruction has been supported by upstream LoongArch > toolchains from day one, so ditch the raw opcode trickery and just use > plain inline asm for it. >=20 > While at it, also make the invtlb asm statements barriers, for proper > modeling of the side effects. >=20 > The signature of the other more specific invtlb wrappers contain unused > arguments right now, but these are not removed right away in order for > the patch to be focused. In the meantime, assertions are added to ensure > no accidental misuse happens before the refactor. (The more specific > wrappers cannot re-use the generic invtlb wrapper, because the ISA > manual says $zero shall be used in case a particular op does not take > the respective argument: re-using the generic wrapper would mean losing > control over the register usage.) >=20 > Signed-off-by: WANG Xuerui > --- > =C2=A0arch/loongarch/include/asm/tlb.h | 39 ++++++++++++++++-------------= --- > =C2=A01 file changed, 19 insertions(+), 20 deletions(-) >=20 > diff --git a/arch/loongarch/include/asm/tlb.h b/arch/loongarch/include/as= m/tlb.h > index 0dc9ee2b05d2..15750900540c 100644 > --- a/arch/loongarch/include/asm/tlb.h > +++ b/arch/loongarch/include/asm/tlb.h > @@ -88,52 +88,51 @@ enum invtlb_ops { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0INVTLB_GID_ADDR =3D 0x16, > =C2=A0}; > =C2=A0 > -/* > - * invtlb op info addr > - * (0x1 << 26) | (0x24 << 20) | (0x13 << 15) | > - * (addr << 10) | (info << 5) | op > - */ > =C2=A0static inline void invtlb(u32 op, u32 info, u64 addr) Oh, technically these wrappers should be __always_inline, not only inline because they don't work at all if not inlined. Should we change them to __always_inline in this patch by the way? > =C2=A0{ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BUILD_BUG_ON(!__builtin_consta= nt_p(op)); Hmm, I guess it's redundant. If op is not a compile-time constant, it won't satisfy the "i" constraint then the compiler will complain anyway. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0__asm__ __volatile__( > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0"parse_r addr,%0\n\t" > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0"parse_r info,%1\n\t" > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0".word ((0x6498000) | (addr << 10) | (info << 5) | %2)\n\= t" > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0: > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0: "r"(addr), "r"(info), "i"(op) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0"invtlb %0, %1, %2\n\t" > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0: "i"(op), "r"(info), "r"(addr) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0: "memory" > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0); > =C2=A0} Likewise for other wrappers. /* snip */ --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University