Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9293532rwb; Thu, 24 Nov 2022 10:33:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf7MMANXKWgA0TOFM0TQKFnb63RglMarJcz2pBtcCca92Nt4AK0IBHsAirdGt4LU7hrax/q9 X-Received: by 2002:a63:225d:0:b0:477:beb8:70f8 with SMTP id t29-20020a63225d000000b00477beb870f8mr6937787pgm.281.1669314798615; Thu, 24 Nov 2022 10:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669314798; cv=none; d=google.com; s=arc-20160816; b=YdJI4LcO78izKAjWCAY9E6mkiniAhWVOY03XzLznKNlPhev7aXqwh0J46Ztyt8uIgc nCWpjrNAxgvkB5bIbiCFXiXbMjVTgYgLrynM9uHezH3dTzI1ENuafg79lPFY9Z5B/+Lz Ub0emcaDlEjdCfJ8OdBsY5CKN4ZnXDW5/WntzOoDzNEzsy2s+6AyEOZ/WV2AdBUdaYdp FQng/I3bjVbro+/jxQM55q3JU5YUPDdxLsEReGdhOjz2YvYu7wv1AurstbHgHohqAl2M gL2TFGpflPwhVhukdXRrmQUSp93El+7rmEEk+EYJEzudtyzddiKSKgl8IBIIoUvA4tiG MQbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dLAN1IRp+/pgVe8ccIVKWwtZHHGHUIu5/jR3c6qlxLk=; b=RKbY/8zoefX6JmrKd7l7sLSphTgnrgVW/7m8vxnTfrsQ1CHVLAzU2CZdToV8fYX1si 5JkpOnjIGfxthNKzF+2SdT77Wugq1WlTx0yMYiVmDayAgD6wBGNFpu4rwfgsYQM2jERd PmG4XAjmTWrrGcELCUulXS5xcyvW8MEDs8JZs3XMcD6zc9q7sWKWi4qebVMK47yuh46r EbpX2leEwGT/kAvA4pi6vxz01A7VV1j/rxmegFrWzwNiIL+cyGwFott7AH3aZVN8ES3K f7MgPSQDJP8wvt5mNwFaOo5VFinc+4GuWKXPbvbQ14JzSHwA51u52VwuJJldmKgUWQHZ JREg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170902c11100b00178386d88c6si1498048pli.186.2022.11.24.10.33.07; Thu, 24 Nov 2022 10:33:18 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbiKXSGf (ORCPT + 86 others); Thu, 24 Nov 2022 13:06:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiKXSGe (ORCPT ); Thu, 24 Nov 2022 13:06:34 -0500 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D80D85A2E; Thu, 24 Nov 2022 10:06:31 -0800 (PST) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oyGc0-0007BX-HW; Thu, 24 Nov 2022 19:06:12 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Guo Ren , Prabhakar Cc: Jisheng Zhang , Atish Patra , Anup Patel , Andrew Jones , Nathan Chancellor , Philipp Tomsich , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: Re: [PATCH v4 1/7] riscv: asm: alternative-macros: Introduce ALTERNATIVE_3() macro Date: Thu, 24 Nov 2022 19:06:11 +0100 Message-ID: <11335542.nUPlyArG6x@diego> In-Reply-To: <20221124172207.153718-2-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20221124172207.153718-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20221124172207.153718-2-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR 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 Am Donnerstag, 24. November 2022, 18:22:01 CET schrieb Prabhakar: > From: Lad Prabhakar > > Introduce ALTERNATIVE_3() macro. > > Signed-off-by: Lad Prabhakar Reviewed-by: Heiko Stuebner > --- > RFC v3 -> v4 > * New patch > --- > arch/riscv/include/asm/alternative-macros.h | 94 +++++++++++++++++++++ > 1 file changed, 94 insertions(+) > > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h > index ec2f3f1b836f..1caf4306b3d6 100644 > --- a/arch/riscv/include/asm/alternative-macros.h > +++ b/arch/riscv/include/asm/alternative-macros.h > @@ -69,6 +69,34 @@ > new_c_2, vendor_id_2, errata_id_2, \ > IS_ENABLED(CONFIG_k_2) > > +.macro __ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > + new_c_2, vendor_id_2, errata_id_2, enable_2, \ > + new_c_3, vendor_id_3, errata_id_3, enable_3 > +886 : > + .option push > + .option norvc > + .option norelax > + \old_c > + .option pop > +887 : > + ALT_NEW_CONTENT \vendor_id_1, \errata_id_1, \enable_1, \new_c_1 > + ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > +.endm > + > +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + CONFIG_k_1, \ > + new_c_2, vendor_id_2, errata_id_2, \ > + CONFIG_k_2, \ > + new_c_3, vendor_id_3, errata_id_3, \ > + CONFIG_k_3) \ > + __ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, errata_id_1, \ > + IS_ENABLED(CONFIG_k_1), \ > + new_c_2, vendor_id_2, errata_id_2, \ > + IS_ENABLED(CONFIG_k_2), \ > + new_c_3, vendor_id_3, errata_id_3, \ > + IS_ENABLED(CONFIG_k_3) > + > #else /* !__ASSEMBLY__ */ > > #include > @@ -135,6 +163,36 @@ > new_c_2, vendor_id_2, errata_id_2, \ > IS_ENABLED(CONFIG_k_2)) > > +#define __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + enable_1, \ > + new_c_2, vendor_id_2, errata_id_2, \ > + enable_2, \ > + new_c_3, vendor_id_3, errata_id_3, \ > + enable_3) \ > + "886 :\n" \ > + ".option push\n" \ > + ".option norvc\n" \ > + ".option norelax\n" \ > + old_c "\n" \ > + ".option pop\n" \ > + "887 :\n" \ > + ALT_NEW_CONTENT(vendor_id_1, errata_id_1, enable_1, new_c_1) \ > + ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2) \ > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > + > +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + CONFIG_k_1, \ > + new_c_2, vendor_id_2, errata_id_2, \ > + CONFIG_k_2, \ > + new_c_3, vendor_id_3, errata_id_3, \ > + CONFIG_k_3) \ > + __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + IS_ENABLED(CONFIG_k_1), \ > + new_c_2, vendor_id_2, errata_id_2, \ > + IS_ENABLED(CONFIG_k_2), \ > + new_c_3, vendor_id_3, errata_id_3, \ > + IS_ENABLED(CONFIG_k_3)) > + > #endif /* __ASSEMBLY__ */ > > #else /* CONFIG_RISCV_ALTERNATIVE */ > @@ -153,6 +211,14 @@ > CONFIG_k_2) \ > __ALTERNATIVE_CFG old_c > > +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + CONFIG_k_1, \ > + new_c_2, vendor_id_2, errata_id_2, \ > + CONFIG_k_2, \ > + new_c_3, vendor_id_3, errata_id_3, \ > + CONFIG_k_3) \ > + __ALTERNATIVE_CFG old_c > + > #else /* !__ASSEMBLY__ */ > > #define __ALTERNATIVE_CFG(old_c) \ > @@ -167,6 +233,14 @@ > CONFIG_k_2) \ > __ALTERNATIVE_CFG(old_c) > > +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, \ > + CONFIG_k_1, \ > + new_c_2, vendor_id_2, errata_id_2, \ > + CONFIG_k_2, \ > + new_c_3, vendor_id_3, errata_id_3, \ > + CONFIG_k_3) \ > + __ALTERNATIVE_CFG(old_c) > + > #endif /* __ASSEMBLY__ */ > #endif /* CONFIG_RISCV_ALTERNATIVE */ > > @@ -202,4 +276,24 @@ > new_content_2, vendor_id_2, \ > errata_id_2, CONFIG_k_2) > > +/* > + * A vendor wants to replace an old_content, but another vendor has used > + * ALTERNATIVE_2() to patch its customized content at the same location. In > + * this case, this vendor can create a new macro ALTERNATIVE_3() based > + * on the following sample code and then replace ALTERNATIVE_2() with > + * ALTERNATIVE_3() to append its customized content. > + */ > +#define ALTERNATIVE_3(old_content, new_content_1, vendor_id_1, \ > + errata_id_1, CONFIG_k_1, \ > + new_content_2, vendor_id_2, \ > + errata_id_2, CONFIG_k_2, \ > + new_content_3, vendor_id_3, \ > + errata_id_3, CONFIG_k_3) \ > + _ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, \ > + errata_id_1, CONFIG_k_1, \ > + new_content_2, vendor_id_2, \ > + errata_id_2, CONFIG_k_2, \ > + new_content_3, vendor_id_3, \ > + errata_id_3, CONFIG_k_3) > + > #endif >