Message ID | 20221124172207.153718-2-prabhakar.mahadev-lad.rj@bp.renesas.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3522044wrr; Thu, 24 Nov 2022 09:25:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ovqQzrO5Ja2Ir35srVn2L4OB6SJNTxgs1u84BOJQcqtCbqMiOsJkkKPlHViwUtHzTdxWc X-Received: by 2002:aa7:dc0c:0:b0:461:6f87:20bb with SMTP id b12-20020aa7dc0c000000b004616f8720bbmr30931469edu.300.1669310747073; Thu, 24 Nov 2022 09:25:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669310747; cv=none; d=google.com; s=arc-20160816; b=t2v/rCps7Y4XjwI2QCotcg9riwI8iyqhEcQ64t4vtlXE9jPS+ihsJ+EYiCXPvThW8l madyxn52bx6vtHGY1ZuALey5cJBDNaDWTcUPJr7JdRDOSgJfcyTj84lmPhD0k0WB6po6 Y8N597nkBnYriKEK6Z2hJY8LXhI+Ef7/pQ84Qf7Z+082uIuG6j7VNJB82F8jjPY10mUj YNOxGWNpR2Pc9ChqYMf6My+fig5mtFudBtGwk3DbKVpsRNFBewO3MrpmOOteWCaQysrG CZYgD2o6nwJ2f6fsuUnKKapF70NPnW3dlxXRc3QQxMi8ewD/qmjYL2mB6WAdGhKyOfZY /ZKg== 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 :dkim-signature; bh=vGTeIsZb6dwV09Jxzafi+tDu+2zt3FcJZOZJD63Nq5c=; b=WhKr2KzdK6ozO5+VeXr/CkzLW6hRASdtAyuFfOqiYJBSA42ntLSAKBXEb24TSKcapg bwjjiKlCwmjadtmugQBxvYxJoTBjXfEmUWuNVo3/zxSmW6AZBHESCke2dcuTs5yxangB nMwzLavQr8ExuH1S1CukEouppzPt1pBODw0RrfkSz08foeGNkCQyT+6H3jSh5gD9nfn/ snNY+FzD+QOa+2/MSb8EE1QtcQhusFtrL7yxRLK7EnLzBHeUjdvbrdaLIS8/D9HFCPE9 /raHQ9dYhzKJzHqtA51dKQY73miKegfA7U22RwpNwPTSFgUgEl45pDdQpSusXTZi6pnR ZXSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A8LwDLVi; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht20-20020a170907609400b007ac60b82ea5si1698524ejc.96.2022.11.24.09.25.20; Thu, 24 Nov 2022 09:25:47 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A8LwDLVi; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbiKXRXL (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Thu, 24 Nov 2022 12:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiKXRWq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 24 Nov 2022 12:22:46 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540FB5C0CF; Thu, 24 Nov 2022 09:22:40 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id t4so1743154wmj.5; Thu, 24 Nov 2022 09:22:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vGTeIsZb6dwV09Jxzafi+tDu+2zt3FcJZOZJD63Nq5c=; b=A8LwDLViXjTFC1n697iLKxetZVRA1pt1BHLBlG57fgEUyDIx3T36ft5hVIQ4PWKzmP SEWBgibKQyMivuFK3DxZaAUP+1xQfM5MQm5PUNzOwwhy6pinBh7c1A0N00k+eca3HU40 doCckp/rLWs5W8eYAuB/1QNLKN/T2K5t5LgTEMO5dl+cSkBD6azgc26KjPazGrTu7tBe UsuuPUnMpPH8o+flRy/pS+igcqSvnvLnemkQvzO0njGh16HP33hXmD6NolW8/jx5CwlA 9zZE/8pwDgITjGWh7k23C+uldZMkh2eXjUJ6lumuOfiz8TNIFPPedzTKOpaKWlvQq5nQ +MHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vGTeIsZb6dwV09Jxzafi+tDu+2zt3FcJZOZJD63Nq5c=; b=Sf6gnxly9SDTUEJDO4DKYvP8gkO+j+2f8IovApg9YuYOKc0xKyDiDMq1IghpGC+023 VRmN4jEWgtWyyVcUlrx6KGKDN4AU/5papyomvP9MrfcidXsW3FDD062t/EsWLKERLGpk u8gl4DdNHxOIwQYagfc3D2HLRyylLwZJGcPGr2liI1fbvaDOU+8WrKusWEoU4BB02p0n X5Bn4t+aMuVCVoEfw0JssB1vTPRHjnAeHcrNN6vgmaIK99bz4lkxDpThoO0otQb92rsg xjrG4zR7zSTl7wuAySNlhuv4VTY6y3I3iRJc94+tUxSv7l9Qwi2zJRLTt5g/0waPYs2L geag== X-Gm-Message-State: ANoB5pl/xeBQwaZ6L8arMcmuNI2A4G2wpimq9Wk38izb16K2ZEVtSkPF QFMS6t5FtfUUCKAXdo1aMKU= X-Received: by 2002:a05:600c:3108:b0:3cf:8058:43b8 with SMTP id g8-20020a05600c310800b003cf805843b8mr12220757wmo.95.1669310559371; Thu, 24 Nov 2022 09:22:39 -0800 (PST) Received: from prasmi.home ([2a00:23c8:2501:c701:89ee:3f5d:1c99:35d8]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c445100b003c64c186206sm2698086wmn.16.2022.11.24.09.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:22:38 -0800 (PST) From: Prabhakar <prabhakar.csengg@gmail.com> X-Google-Original-From: Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Geert Uytterhoeven <geert+renesas@glider.be>, Magnus Damm <magnus.damm@gmail.com>, Heiko Stuebner <heiko@sntech.de>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor.dooley@microchip.com>, Guo Ren <guoren@kernel.org> Cc: Jisheng Zhang <jszhang@kernel.org>, Atish Patra <atishp@rivosinc.com>, Anup Patel <apatel@ventanamicro.com>, Andrew Jones <ajones@ventanamicro.com>, Nathan Chancellor <nathan@kernel.org>, Philipp Tomsich <philipp.tomsich@vrull.eu>, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Prabhakar <prabhakar.csengg@gmail.com>, Biju Das <biju.das.jz@bp.renesas.com>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Subject: [PATCH v4 1/7] riscv: asm: alternative-macros: Introduce ALTERNATIVE_3() macro Date: Thu, 24 Nov 2022 17:22:01 +0000 Message-Id: <20221124172207.153718-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124172207.153718-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20221124172207.153718-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750399185727967438?= X-GMAIL-MSGID: =?utf-8?q?1750399185727967438?= |
Series |
AX45MP: Add support to non-coherent DMA
|
|
Commit Message
Lad, Prabhakar
Nov. 24, 2022, 5:22 p.m. UTC
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Introduce ALTERNATIVE_3() macro. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> --- RFC v3 -> v4 * New patch --- arch/riscv/include/asm/alternative-macros.h | 94 +++++++++++++++++++++ 1 file changed, 94 insertions(+)
Comments
Am Donnerstag, 24. November 2022, 18:22:01 CET schrieb Prabhakar: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce ALTERNATIVE_3() macro. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> > --- > 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 <asm/asm.h> > @@ -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 >
On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce ALTERNATIVE_3() macro. Bit perfunctory I think! There's a lovely comment down below that would make for a better commit message if you were to yoink it. Content looks about what I'd expect to see though. > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > 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 <asm/asm.h> > @@ -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 > -- > 2.25.1 >
Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Introduce ALTERNATIVE_3() macro. > > Bit perfunctory I think! There's a lovely comment down below that would > make for a better commit message if you were to yoink it. > Content looks about what I'd expect to see though. Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 should probably be merged into a single comment explaining this once for all ALTERNATIVE_x variants. Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 if not even more ;-) . So we defnitly don't want to repeat this multiple times. Heiko > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > 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 <asm/asm.h> > > @@ -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 >
On Thu, Nov 24, 2022 at 08:58:41PM +0100, Heiko Stübner wrote: > Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > Introduce ALTERNATIVE_3() macro. > > > > Bit perfunctory I think! There's a lovely comment down below that would > > make for a better commit message if you were to yoink it. > > Content looks about what I'd expect to see though. > > Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > should probably be merged into a single comment explaining this once for all > ALTERNATIVE_x variants. > > Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > if not even more ;-) . So we defnitly don't want to repeat this multiple times. Oh I can promise you that there'll be a #4 ;) I do find the comment's wording to be quite odd though.. > + * 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 In particular this bit about "at the same location" does not make all that much sense. What "at the same location" means in this context should be expanded on imo. Effectively it boils down to someone else is already replacing the same things you want to replace - it's just the word "location" that might make sense if you're an old hand but not otherwise? > + * this case, this vendor can create a new macro ALTERNATIVE_3() based Also, using the word "can". Is it not a "must" rather than a "can", since this stuff needs to be multiplatform? > + * on the following sample code and then replace ALTERNATIVE_2() with > + * ALTERNATIVE_3() to append its customized content.
On 24/11/2022 20:05, Conor Dooley wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > On Thu, Nov 24, 2022 at 08:58:41PM +0100, Heiko Stübner wrote: >> Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: >>> On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: >>>> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> >>>> >>>> Introduce ALTERNATIVE_3() macro. >>> >>> Bit perfunctory I think! There's a lovely comment down below that would >>> make for a better commit message if you were to yoink it. >>> Content looks about what I'd expect to see though. >> >> Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 >> should probably be merged into a single comment explaining this once for all >> ALTERNATIVE_x variants. >> >> Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 >> if not even more ;-) . So we defnitly don't want to repeat this multiple times. > > Oh I can promise you that there'll be a #4 ;) I do find the comment's > wording to be quite odd though.. > >> + * 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 > > In particular this bit about "at the same location" does not make all > that much sense. What "at the same location" means in this context > should be expanded on imo. Effectively it boils down to someone else is > already replacing the same things you want to replace - it's just the > word "location" that might make sense if you're an old hand but not > otherwise? Or maybe I am just biased because I tried to explain this to someone recently and the language in the comments didn't make sense to them, and anyone meddling with this code should be able to understand it? >> + * this case, this vendor can create a new macro ALTERNATIVE_3() based > > Also, using the word "can". Is it not a "must" rather than a "can", > since this stuff needs to be multiplatform? > >> + * on the following sample code and then replace ALTERNATIVE_2() with >> + * ALTERNATIVE_3() to append its customized content. > >
Am Donnerstag, 24. November 2022, 21:08:17 CET schrieb Conor Dooley: > On 24/11/2022 20:05, Conor Dooley wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > On Thu, Nov 24, 2022 at 08:58:41PM +0100, Heiko Stübner wrote: > >> Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > >>> On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > >>>> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > >>>> > >>>> Introduce ALTERNATIVE_3() macro. > >>> > >>> Bit perfunctory I think! There's a lovely comment down below that would > >>> make for a better commit message if you were to yoink it. > >>> Content looks about what I'd expect to see though. > >> > >> Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > >> should probably be merged into a single comment explaining this once for all > >> ALTERNATIVE_x variants. > >> > >> Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > >> if not even more ;-) . So we defnitly don't want to repeat this multiple times. > > > > Oh I can promise you that there'll be a #4 ;) I do find the comment's > > wording to be quite odd though.. > > > >> + * 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 > > > > In particular this bit about "at the same location" does not make all > > that much sense. What "at the same location" means in this context > > should be expanded on imo. Effectively it boils down to someone else is > > already replacing the same things you want to replace - it's just the > > word "location" that might make sense if you're an old hand but not > > otherwise? > > Or maybe I am just biased because I tried to explain this to someone > recently and the language in the comments didn't make sense to them, > and anyone meddling with this code should be able to understand it? When I first looked at the whole alternatives / patching thing, the whole thing looked like dark magic to me ;-) . But yeah, the comment here, but also the original one above ALTERNATIVE_2 could use improvements to explain better what it tries to do. > >> + * this case, this vendor can create a new macro ALTERNATIVE_3() based > > > > Also, using the word "can". Is it not a "must" rather than a "can", > > since this stuff needs to be multiplatform? > > > >> + * on the following sample code and then replace ALTERNATIVE_2() with > >> + * ALTERNATIVE_3() to append its customized content. > > > > > >
Hi Heiko, On Thu, Nov 24, 2022 at 7:58 PM Heiko Stübner <heiko@sntech.de> wrote: > > Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > Introduce ALTERNATIVE_3() macro. > > > > Bit perfunctory I think! There's a lovely comment down below that would > > make for a better commit message if you were to yoink it. > > Content looks about what I'd expect to see though. > > Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > should probably be merged into a single comment explaining this once for all > ALTERNATIVE_x variants. > > Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > if not even more ;-) . So we defnitly don't want to repeat this multiple times. > Do agree. How about the below? /* * Similar to what ALTERNATIVE_2() macro does but with an additional * vendor content. */ So the other ALTERNATIVE_2+() macros will keep on building on it. Cheers, Prabhakar
Am Freitag, 25. November 2022, 11:02:21 CET schrieb Lad, Prabhakar: > Hi Heiko, > > On Thu, Nov 24, 2022 at 7:58 PM Heiko Stübner <heiko@sntech.de> wrote: > > > > Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > > > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > Bit perfunctory I think! There's a lovely comment down below that would > > > make for a better commit message if you were to yoink it. > > > Content looks about what I'd expect to see though. > > > > Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > > should probably be merged into a single comment explaining this once for all > > ALTERNATIVE_x variants. > > > > Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > > if not even more ;-) . So we defnitly don't want to repeat this multiple times. > > > Do agree. How about the below? > > /* > * Similar to what ALTERNATIVE_2() macro does but with an additional > * vendor content. > */ > > So the other ALTERNATIVE_2+() macros will keep on building on it. My idea was more like having _one_ comment block of something like ----- /* * ALTERNATIVE_x macros allow providing multiple replacement options * for an ALTERNATIVE code section. This is helpful if multiple * implementation variants for the same functionality exist for * different cpu cores. * * Usage: * ALTERNATIVE_x(old_content, * new_content1, vendor_id1, errata_id1, CONFIG_k1, * new_content2, vendor_id2, errata_id2, CONFIG_k2, * ... * new_contentx, vendor_idx, errata_idx, CONFIG_kx) */ #define ALTERNATIVE_2(...) #define ALTERNATIVE_3(...) etc ----- So this would include dropping the old comment over ALTERNATIVE2 Heiko
Hi Heiko, On Fri, Nov 25, 2022 at 10:20 AM Heiko Stübner <heiko@sntech.de> wrote: > > Am Freitag, 25. November 2022, 11:02:21 CET schrieb Lad, Prabhakar: > > Hi Heiko, > > > > On Thu, Nov 24, 2022 at 7:58 PM Heiko Stübner <heiko@sntech.de> wrote: > > > > > > Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > > > > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > > > Bit perfunctory I think! There's a lovely comment down below that would > > > > make for a better commit message if you were to yoink it. > > > > Content looks about what I'd expect to see though. > > > > > > Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > > > should probably be merged into a single comment explaining this once for all > > > ALTERNATIVE_x variants. > > > > > > Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > > > if not even more ;-) . So we defnitly don't want to repeat this multiple times. > > > > > Do agree. How about the below? > > > > /* > > * Similar to what ALTERNATIVE_2() macro does but with an additional > > * vendor content. > > */ > > > > So the other ALTERNATIVE_2+() macros will keep on building on it. > > My idea was more like having _one_ comment block of something like > > ----- > /* > * ALTERNATIVE_x macros allow providing multiple replacement options > * for an ALTERNATIVE code section. This is helpful if multiple > * implementation variants for the same functionality exist for > * different cpu cores. > * > * Usage: > * ALTERNATIVE_x(old_content, > * new_content1, vendor_id1, errata_id1, CONFIG_k1, > * new_content2, vendor_id2, errata_id2, CONFIG_k2, > * ... > * new_contentx, vendor_idx, errata_idx, CONFIG_kx) > */ > > #define ALTERNATIVE_2(...) > #define ALTERNATIVE_3(...) > etc > ----- > LGTM, I'll include the above in the next version. > So this would include dropping the old comment over ALTERNATIVE2 > Agreed, I'll drop it in the same patch. Cheers, Prabhakar
On Thu, Nov 24, 2022 at 08:05:40PM +0000, Conor Dooley wrote: > On Thu, Nov 24, 2022 at 08:58:41PM +0100, Heiko Stübner wrote: > > Am Donnerstag, 24. November 2022, 20:52:33 CET schrieb Conor Dooley: > > > On Thu, Nov 24, 2022 at 05:22:01PM +0000, Prabhakar wrote: > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > Bit perfunctory I think! There's a lovely comment down below that would > > > make for a better commit message if you were to yoink it. > > > Content looks about what I'd expect to see though. > > > > Also both the comment on the original ALTERNATIVE_2 and the new ALTERNATIVE_3 > > should probably be merged into a single comment explaining this once for all > > ALTERNATIVE_x variants. > > > > Especially with the dma stuff, I'm pretty sure we'll get at least an ALTERNATIVE_4 > > if not even more ;-) . So we defnitly don't want to repeat this multiple times. > > Oh I can promise you that there'll be a #4 ;) I took a stab[*] at cleaning up alternative-macros.h a bit in order to prepare for _3, _4, ..., _42. The idea was to try and find a way to reduce as much duplication as possible, both in the current code and in the new macros. [*] https://lore.kernel.org/all/20221125113959.35328-1-ajones@ventanamicro.com/ Thanks, drew
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 <asm/asm.h> @@ -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