Message ID | 20221212115505.36770-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 q4csp2199421wrr; Mon, 12 Dec 2022 03:59:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7AfnLy8c3hS8UJJtDR7Ytf9JvRAeZ519rzDl17t33dtITno3/ii9dyyR6pYIEZ5+30Ml70 X-Received: by 2002:a17:906:c2d3:b0:7c0:ff72:e828 with SMTP id ch19-20020a170906c2d300b007c0ff72e828mr12858403ejb.54.1670846361815; Mon, 12 Dec 2022 03:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670846361; cv=none; d=google.com; s=arc-20160816; b=kao+mYESZ1mcaFrEXvF6NnsOaDg1lzhQpbVL6ldt4xpk8FOEX6lRVVY+yLq2XhR64/ 0DOjLge0t8KD/MZ++7AKhYY75y842K5bpDTUndwdTMR8QLEjRvWwcDQ52yqmfwbN2HOH AUDOVt2MJbZkPHawv9Sb1hQo3G6DN7N/uI9YpS27XofSebcKGAKwhUg+QrZ9cEE5c+vJ bb0aLYeQlmPfKaeb93Cy9sn8WyajRBngZAI19WzORWjTY8aUtnH+wezpMJ5IFElH3pWa jYPMKAymUso1FE32epCwyru+t+8o0E6aBrpylqg6xe7Fao6TybXVU47IYnm8TBxgR3Ll VqdQ== 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=WpXOFyKc/JZvQOWHQWc0AJS8A/69Ui8DKNz8njSVnfU=; b=n4MNod/v4+DLr2ouB225FYY6wW+Lukqa7+rN3ijf/NPWbpmOWMedJ2DmgyogflcsDR HYdukV5vLdb32DmQcjdB21yXsLrOYGQOnLlVU87C9G35yyBiLM6lY+N9moWzEvSHJEZO jpIj1DN+4geaXfGWxChWZj6oxAoiHCkpLSUzcnbgCmf/MACKy5wnsSYDu6UJthqZ7Osv H91OoOiBexHNZ2ex+RQpViQXeDFS8aGU6X7gQrWYMmFjgI4rsIabh80tMzB3pWN84Ige 0IVo3G0OrT3v6bCOTyYsgn23ukCYxYq816Rvcys3I5RqLCMc9rCAhMdGstnFn4/PzsF4 YiBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="BJ0Dsjc/"; 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 um28-20020a170906cf9c00b0078a19032c70si5044968ejb.334.2022.12.12.03.58.58; Mon, 12 Dec 2022 03:59:21 -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="BJ0Dsjc/"; 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 S231915AbiLLLzj (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Mon, 12 Dec 2022 06:55:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbiLLLzf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Dec 2022 06:55:35 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81789C35; Mon, 12 Dec 2022 03:55:32 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id bg10so5078607wmb.1; Mon, 12 Dec 2022 03:55:32 -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=WpXOFyKc/JZvQOWHQWc0AJS8A/69Ui8DKNz8njSVnfU=; b=BJ0Dsjc/SFk5h+zyozkC2I4LnZ37r72za6ZXGBwb7D1To2ZeM1nYZW2wsXUMBJYio0 9homQsaxjhwiwUhxzP8KE2uzxGw5O9e4OEaHc23dKcqN3QDZ3b1RypX523NtbTssg/YI aY6ZHSZNKbzbs58UdBwvr5TMENriTjcjLTor/MD/otq+Goe63ci4c71cQUjZpqWbvjUC mZLEmw/tuooCxGDmrDL7p32eX7U4DeY+pIW9sk+GT7x8V2yZCH41vUX8zqds1aseOAaf UbCC22tz3LtgBwzlaiw/x78gfnk8JnGI4ALNgAGhpjJEuyxrYNFvRpV6R9QuVjJR5zPG Lh4Q== 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=WpXOFyKc/JZvQOWHQWc0AJS8A/69Ui8DKNz8njSVnfU=; b=MOEm9gW+Yf7zJ1js02xZeADWRY5DpX9lhdOGbbvCQcisihuxY9CQdaRh2YLjgs6nkB kKIcGpvLqnoQOYW95BWL+0qSi6rf5AXsY1pEy0EcXvi7gKL7E/f3Nq7QjvC3tR1RKtH4 5Rd9kBJUhm+HYdwh5t5/NoqfWpR4Z7AxNLAvQk54IEZwmf6q5dfu4arUvEr3bZ2vKvBp 9Shbkg2DZdNyagtxfBB3sgb61tESiYf1OOR2JwGkC7U85wtjpDGkQ65XPlt9QU6H3ROo bwBkrx7XzVROoAD6xELyjdVoJ4rMXHOhWZhGEo14HLD/LLaFRIiCXutXTxbisx6NlGoh tqdw== X-Gm-Message-State: ANoB5pn81+8I6iVxpISvyCaeaxUnk3HwdwcXALBXj8cCjE8p1dkZLx2n Vb7Rm7b0/PomLQaMmqFQNvE= X-Received: by 2002:a1c:cc1a:0:b0:3cf:5583:8b3f with SMTP id h26-20020a1ccc1a000000b003cf55838b3fmr12615303wmb.20.1670846130885; Mon, 12 Dec 2022 03:55:30 -0800 (PST) Received: from prasmi.home ([2a00:23c8:2501:c701:1484:ef11:b25c:4612]) by smtp.gmail.com with ESMTPSA id j7-20020a05600c190700b003b4cba4ef71sm9793820wmq.41.2022.12.12.03.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 03:55:30 -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>, Conor Dooley <conor.dooley@microchip.com>, Samuel Holland <samuel@sholland.org>, Guo Ren <guoren@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.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-riscv@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-kernel@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 v5 1/6] riscv: asm: alternative-macros: Introduce ALTERNATIVE_3() macro Date: Mon, 12 Dec 2022 11:55:00 +0000 Message-Id: <20221212115505.36770-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221212115505.36770-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20221212115505.36770-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?1752009394937841214?= X-GMAIL-MSGID: =?utf-8?q?1752009394937841214?= |
Series |
AX45MP: Add support to non-coherent DMA
|
|
Commit Message
Lad, Prabhakar
Dec. 12, 2022, 11:55 a.m. UTC
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Introduce ALTERNATIVE_3() macro. 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 use macro ALTERNATIVE_3() and then replace ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. While at it update comment above ALTERNATIVE_2() macro and make it generic so that the comment holds good for any new addition of ALTERNATIVE_X() macros. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> --- v4->v5 * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) * Updated comment for ALTERNATIVE_x() as suggested by Heiko RFC v3 -> v4 * New patch --- arch/riscv/include/asm/alternative-macros.h | 46 ++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)
Comments
Am Montag, 12. Dezember 2022, 12:55:00 CET schrieb Prabhakar: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce ALTERNATIVE_3() macro. > > 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 use macro ALTERNATIVE_3() and then replace > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > While at it update comment above ALTERNATIVE_2() macro and make it generic > so that the comment holds good for any new addition of ALTERNATIVE_X() > macros. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu> > --- > v4->v5 > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > * Updated comment for ALTERNATIVE_x() as suggested by Heiko > > RFC v3 -> v4 > * New patch > --- > arch/riscv/include/asm/alternative-macros.h | 46 ++++++++++++++++++--- > 1 file changed, 41 insertions(+), 5 deletions(-) > > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h > index 7226e2462584..a5b4691520da 100644 > --- a/arch/riscv/include/asm/alternative-macros.h > +++ b/arch/riscv/include/asm/alternative-macros.h > @@ -50,8 +50,17 @@ > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > .endm > > +.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 > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > +.endm > + > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > #else /* !__ASSEMBLY__ */ > > @@ -98,6 +107,13 @@ > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > + > #endif /* __ASSEMBLY__ */ > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > @@ -108,6 +124,13 @@ > __ALTERNATIVE_CFG_2(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)) > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ > #ifdef __ASSEMBLY__ > > @@ -152,15 +175,28 @@ > _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) > > /* > - * A vendor wants to replace an old_content, but another vendor has used > - * ALTERNATIVE() to patch its customized content at the same location. In > - * this case, this vendor can create a new macro ALTERNATIVE_2() based > - * on the following sample code and then replace ALTERNATIVE() with > - * ALTERNATIVE_2() to append its customized content. > + * 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(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) \ > _ALTERNATIVE_CFG_2(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) > > +#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 >
Hi Prabhakar, On Mon, Dec 12, 2022 at 12:58 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce ALTERNATIVE_3() macro. > > 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 use macro ALTERNATIVE_3() and then replace > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > While at it update comment above ALTERNATIVE_2() macro and make it generic > so that the comment holds good for any new addition of ALTERNATIVE_X() > macros. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > v4->v5 > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > * Updated comment for ALTERNATIVE_x() as suggested by Heiko Thanks for the update! > --- a/arch/riscv/include/asm/alternative-macros.h > +++ b/arch/riscv/include/asm/alternative-macros.h > @@ -50,8 +50,17 @@ > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > .endm > > +.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 > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > +.endm > + > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > #else /* !__ASSEMBLY__ */ > > @@ -98,6 +107,13 @@ > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > + > #endif /* __ASSEMBLY__ */ > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > @@ -108,6 +124,13 @@ > __ALTERNATIVE_CFG_2(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)) > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ To avoid breaking the build for K210 (and VexRiscv), you need to provide _ALTERNATIVE_CFG_3() for the !CONFIG_RISCV_ALTERNATIVE case, too: @@ -144,6 +144,9 @@ #define _ALTERNATIVE_CFG_2(old_c, ...) \ ALTERNATIVE_CFG old_c +#define _ALTERNATIVE_CFG_3(old_c, ...) \ + ALTERNATIVE_CFG old_c + #else /* !__ASSEMBLY__ */ #define __ALTERNATIVE_CFG(old_c) \ @@ -155,6 +158,9 @@ #define _ALTERNATIVE_CFG_2(old_c, ...) \ __ALTERNATIVE_CFG(old_c) +#define _ALTERNATIVE_CFG_3(old_c, ...) \ + __ALTERNATIVE_CFG(old_c) + #endif /* __ASSEMBLY__ */ #endif /* CONFIG_RISCV_ALTERNATIVE */ Else it fails (on riscv/for-next) with: arch/riscv/mm/pmem.c: In function ‘arch_wb_cache_pmem’: arch/riscv/include/asm/alternative-macros.h:198:8: error: expected string literal before ‘_ALTERNATIVE_CFG_3’ 198 | _ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1, \ | ^~~~~~~~~~~~~~~~~~ arch/riscv/include/asm/errata_list.h:128:14: note: in expansion of macro ‘ALTERNATIVE_3’ 128 | asm volatile(ALTERNATIVE_3( \ | ^~~~~~~~~~~~~ arch/riscv/mm/pmem.c:13:2: note: in expansion of macro ‘ALT_CMO_OP’ 13 | ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size, 0, 0); | ^~~~~~~~~~ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert, Thank you for the review. On Tue, Dec 13, 2022 at 5:21 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > Hi Prabhakar, > > On Mon, Dec 12, 2022 at 12:58 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Introduce ALTERNATIVE_3() macro. > > > > 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 use macro ALTERNATIVE_3() and then replace > > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > > > While at it update comment above ALTERNATIVE_2() macro and make it generic > > so that the comment holds good for any new addition of ALTERNATIVE_X() > > macros. > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > v4->v5 > > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > > * Updated comment for ALTERNATIVE_x() as suggested by Heiko > > Thanks for the update! > > > --- a/arch/riscv/include/asm/alternative-macros.h > > +++ b/arch/riscv/include/asm/alternative-macros.h > > @@ -50,8 +50,17 @@ > > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > > .endm > > > > +.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 > > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > > +.endm > > + > > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > > > #else /* !__ASSEMBLY__ */ > > > > @@ -98,6 +107,13 @@ > > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > > + > > #endif /* __ASSEMBLY__ */ > > > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > > @@ -108,6 +124,13 @@ > > __ALTERNATIVE_CFG_2(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)) > > > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ > > To avoid breaking the build for K210 (and VexRiscv), you need to provide > _ALTERNATIVE_CFG_3() for the !CONFIG_RISCV_ALTERNATIVE case, too: > Thanks for testing this. > @@ -144,6 +144,9 @@ > #define _ALTERNATIVE_CFG_2(old_c, ...) \ > ALTERNATIVE_CFG old_c > > +#define _ALTERNATIVE_CFG_3(old_c, ...) \ > + ALTERNATIVE_CFG old_c > + > #else /* !__ASSEMBLY__ */ > > #define __ALTERNATIVE_CFG(old_c) \ > @@ -155,6 +158,9 @@ > #define _ALTERNATIVE_CFG_2(old_c, ...) \ > __ALTERNATIVE_CFG(old_c) > > +#define _ALTERNATIVE_CFG_3(old_c, ...) \ > + __ALTERNATIVE_CFG(old_c) > + > #endif /* __ASSEMBLY__ */ > #endif /* CONFIG_RISCV_ALTERNATIVE */ > > Else it fails (on riscv/for-next) with: > I'll include the above hunk in next version. > arch/riscv/mm/pmem.c: In function ‘arch_wb_cache_pmem’: > arch/riscv/include/asm/alternative-macros.h:198:8: error: expected > string literal before ‘_ALTERNATIVE_CFG_3’ > 198 | _ALTERNATIVE_CFG_3(old_content, new_content_1, > vendor_id_1, errata_id_1, CONFIG_k_1, \ > | ^~~~~~~~~~~~~~~~~~ > arch/riscv/include/asm/errata_list.h:128:14: note: in expansion of > macro ‘ALTERNATIVE_3’ > 128 | asm volatile(ALTERNATIVE_3( \ > | ^~~~~~~~~~~~~ > arch/riscv/mm/pmem.c:13:2: note: in expansion of macro ‘ALT_CMO_OP’ > 13 | ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size, 0, 0); > | ^~~~~~~~~~ > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds
On Tue, Dec 13, 2022 at 05:49:32PM +0000, Lad, Prabhakar wrote: > Hi Geert, > > Thank you for the review. > > On Tue, Dec 13, 2022 at 5:21 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > > > Hi Prabhakar, > > > > On Mon, Dec 12, 2022 at 12:58 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > 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 use macro ALTERNATIVE_3() and then replace > > > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > > > > > While at it update comment above ALTERNATIVE_2() macro and make it generic > > > so that the comment holds good for any new addition of ALTERNATIVE_X() > > > macros. > > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > --- > > > v4->v5 > > > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > > > * Updated comment for ALTERNATIVE_x() as suggested by Heiko > > > > Thanks for the update! > > > > > --- a/arch/riscv/include/asm/alternative-macros.h > > > +++ b/arch/riscv/include/asm/alternative-macros.h > > > @@ -50,8 +50,17 @@ > > > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > > > .endm > > > > > > +.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 > > > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > > > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > > > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > > > +.endm > > > + > > > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > > > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > > > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > > > > > #else /* !__ASSEMBLY__ */ > > > > > > @@ -98,6 +107,13 @@ > > > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > > > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > > > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > > > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > > > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > > > + > > > #endif /* __ASSEMBLY__ */ > > > > > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > > > @@ -108,6 +124,13 @@ > > > __ALTERNATIVE_CFG_2(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)) > > > > > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ > > > > To avoid breaking the build for K210 (and VexRiscv), you need to provide > > _ALTERNATIVE_CFG_3() for the !CONFIG_RISCV_ALTERNATIVE case, too: > > > Thanks for testing this. > > > @@ -144,6 +144,9 @@ > > #define _ALTERNATIVE_CFG_2(old_c, ...) \ > > ALTERNATIVE_CFG old_c > > > > +#define _ALTERNATIVE_CFG_3(old_c, ...) \ > > + ALTERNATIVE_CFG old_c > > + > > #else /* !__ASSEMBLY__ */ > > > > #define __ALTERNATIVE_CFG(old_c) \ > > @@ -155,6 +158,9 @@ > > #define _ALTERNATIVE_CFG_2(old_c, ...) \ > > __ALTERNATIVE_CFG(old_c) > > > > +#define _ALTERNATIVE_CFG_3(old_c, ...) \ > > + __ALTERNATIVE_CFG(old_c) > > + > > #endif /* __ASSEMBLY__ */ > > #endif /* CONFIG_RISCV_ALTERNATIVE */ > > > > Else it fails (on riscv/for-next) with: > > > I'll include the above hunk in next version. Yes, those two hunks are in my example in [1] as well. [1] https://lore.kernel.org/all/20221129150053.50464-1-ajones@ventanamicro.com/ Thanks, drew > > > arch/riscv/mm/pmem.c: In function ‘arch_wb_cache_pmem’: > > arch/riscv/include/asm/alternative-macros.h:198:8: error: expected > > string literal before ‘_ALTERNATIVE_CFG_3’ > > 198 | _ALTERNATIVE_CFG_3(old_content, new_content_1, > > vendor_id_1, errata_id_1, CONFIG_k_1, \ > > | ^~~~~~~~~~~~~~~~~~ > > arch/riscv/include/asm/errata_list.h:128:14: note: in expansion of > > macro ‘ALTERNATIVE_3’ > > 128 | asm volatile(ALTERNATIVE_3( \ > > | ^~~~~~~~~~~~~ > > arch/riscv/mm/pmem.c:13:2: note: in expansion of macro ‘ALT_CMO_OP’ > > 13 | ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size, 0, 0); > > | ^~~~~~~~~~ > > > > Gr{oetje,eeting}s, > > > > Geert > > > > -- > > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > > > In personal conversations with technical people, I call myself a hacker. But > > when I'm talking to journalists I just say "programmer" or something like that. > > -- Linus Torvalds
On Mon, Dec 12, 2022 at 11:55:00AM +0000, Prabhakar wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Introduce ALTERNATIVE_3() macro. > > 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 use macro ALTERNATIVE_3() and then replace > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > While at it update comment above ALTERNATIVE_2() macro and make it generic > so that the comment holds good for any new addition of ALTERNATIVE_X() > macros. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > --- > v4->v5 > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > * Updated comment for ALTERNATIVE_x() as suggested by Heiko > > RFC v3 -> v4 > * New patch > --- > arch/riscv/include/asm/alternative-macros.h | 46 ++++++++++++++++++--- > 1 file changed, 41 insertions(+), 5 deletions(-) > > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h > index 7226e2462584..a5b4691520da 100644 > --- a/arch/riscv/include/asm/alternative-macros.h > +++ b/arch/riscv/include/asm/alternative-macros.h > @@ -50,8 +50,17 @@ > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > .endm > > +.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 > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > +.endm > + > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > #else /* !__ASSEMBLY__ */ > > @@ -98,6 +107,13 @@ > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > + > #endif /* __ASSEMBLY__ */ > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > @@ -108,6 +124,13 @@ > __ALTERNATIVE_CFG_2(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)) > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ > #ifdef __ASSEMBLY__ > > @@ -152,15 +175,28 @@ > _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) > > /* > - * A vendor wants to replace an old_content, but another vendor has used > - * ALTERNATIVE() to patch its customized content at the same location. In > - * this case, this vendor can create a new macro ALTERNATIVE_2() based > - * on the following sample code and then replace ALTERNATIVE() with > - * ALTERNATIVE_2() to append its customized content. > + * 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. I think this last sentence should be: "This is helpful if multiple implementation variants exist for the same functionality." I don't think CPU cores is the right level of "granularity". > + * > + * 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(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) \ > _ALTERNATIVE_CFG_2(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) > > +#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) btw, why is this indented with spaces when the line above it is indented with tabs? (At least, that is how it appears in mutt). With those minor bits & the suggested fixes from Drew/Geert: Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. > + > #endif > -- > 2.25.1 >
Hi Conor, Thank you for the review. On Sat, Dec 17, 2022 at 9:41 PM Conor Dooley <conor@kernel.org> wrote: > > On Mon, Dec 12, 2022 at 11:55:00AM +0000, Prabhakar wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > Introduce ALTERNATIVE_3() macro. > > > > 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 use macro ALTERNATIVE_3() and then replace > > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > > > While at it update comment above ALTERNATIVE_2() macro and make it generic > > so that the comment holds good for any new addition of ALTERNATIVE_X() > > macros. > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > --- > > v4->v5 > > * Rebased the patch on top of Andrew's series (now in Palmers for next-branch) > > * Updated comment for ALTERNATIVE_x() as suggested by Heiko > > > > RFC v3 -> v4 > > * New patch > > --- > > arch/riscv/include/asm/alternative-macros.h | 46 ++++++++++++++++++--- > > 1 file changed, 41 insertions(+), 5 deletions(-) > > > > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h > > index 7226e2462584..a5b4691520da 100644 > > --- a/arch/riscv/include/asm/alternative-macros.h > > +++ b/arch/riscv/include/asm/alternative-macros.h > > @@ -50,8 +50,17 @@ > > ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 > > .endm > > > > +.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 > > + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ > > + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 > > + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 > > +.endm > > + > > #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ > > #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ > > +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ > > > > #else /* !__ASSEMBLY__ */ > > > > @@ -98,6 +107,13 @@ > > __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ > > ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ > > + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ > > + new_c_2, vendor_id_2, errata_id_2, enable_2) \ > > + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) > > + > > #endif /* __ASSEMBLY__ */ > > > > #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ > > @@ -108,6 +124,13 @@ > > __ALTERNATIVE_CFG_2(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)) > > > > +#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 /* CONFIG_RISCV_ALTERNATIVE */ > > #ifdef __ASSEMBLY__ > > > > @@ -152,15 +175,28 @@ > > _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) > > > > /* > > - * A vendor wants to replace an old_content, but another vendor has used > > - * ALTERNATIVE() to patch its customized content at the same location. In > > - * this case, this vendor can create a new macro ALTERNATIVE_2() based > > - * on the following sample code and then replace ALTERNATIVE() with > > - * ALTERNATIVE_2() to append its customized content. > > + * 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. > > I think this last sentence should be: > "This is helpful if multiple implementation variants exist for the same > functionality." > I don't think CPU cores is the right level of "granularity". > Ok, I'll update it as above. > > + * > > + * 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(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) \ > > _ALTERNATIVE_CFG_2(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) > > > > +#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) > > btw, why is this indented with spaces when the line above it is indented > with tabs? (At least, that is how it appears in mutt). > I'll update it with spaces. > With those minor bits & the suggested fixes from Drew/Geert: > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > Cheers, Prabhakar
On Mon, Dec 19, 2022 at 11:15:17AM +0000, Lad, Prabhakar wrote: > > On Mon, Dec 12, 2022 at 11:55:00AM +0000, Prabhakar wrote: > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > 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 use macro ALTERNATIVE_3() and then replace > > > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > > > > > While at it update comment above ALTERNATIVE_2() macro and make it generic > > > so that the comment holds good for any new addition of ALTERNATIVE_X() > > > macros. > > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > + * > > > + * 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(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) \ > > > _ALTERNATIVE_CFG_2(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) > > > > > > +#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) > > > > btw, why is this indented with spaces when the line above it is indented > > with tabs? (At least, that is how it appears in mutt). > > > I'll update it with spaces. The file uses tabs, so it'd be switching the spaces you added with tabs, right?
Hi Conor, On Mon, Dec 19, 2022 at 4:22 PM Conor Dooley <conor@kernel.org> wrote: > > On Mon, Dec 19, 2022 at 11:15:17AM +0000, Lad, Prabhakar wrote: > > > On Mon, Dec 12, 2022 at 11:55:00AM +0000, Prabhakar wrote: > > > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > > > > Introduce ALTERNATIVE_3() macro. > > > > > > > > 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 use macro ALTERNATIVE_3() and then replace > > > > ALTERNATIVE_2() with ALTERNATIVE_3() to append its customized content. > > > > > > > > While at it update comment above ALTERNATIVE_2() macro and make it generic > > > > so that the comment holds good for any new addition of ALTERNATIVE_X() > > > > macros. > > > > > > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > > > > + * > > > > + * 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(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) \ > > > > _ALTERNATIVE_CFG_2(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) > > > > > > > > +#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) > > > > > > btw, why is this indented with spaces when the line above it is indented > > > with tabs? (At least, that is how it appears in mutt). > > > > > I'll update it with spaces. > > The file uses tabs, so it'd be switching the spaces you added with tabs, > right? My bad that was a typo, I meant tabs :p Cheers, Prabhakar
diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h index 7226e2462584..a5b4691520da 100644 --- a/arch/riscv/include/asm/alternative-macros.h +++ b/arch/riscv/include/asm/alternative-macros.h @@ -50,8 +50,17 @@ ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2 .endm +.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 + ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1, \ + \new_c_2, \vendor_id_2, \errata_id_2, \enable_2 + ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3 +.endm + #define __ALTERNATIVE_CFG(...) ALTERNATIVE_CFG __VA_ARGS__ #define __ALTERNATIVE_CFG_2(...) ALTERNATIVE_CFG_2 __VA_ARGS__ +#define __ALTERNATIVE_CFG_3(...) ALTERNATIVE_CFG_3 __VA_ARGS__ #else /* !__ASSEMBLY__ */ @@ -98,6 +107,13 @@ __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \ ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_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) \ + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \ + new_c_2, vendor_id_2, errata_id_2, enable_2) \ + ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3) + #endif /* __ASSEMBLY__ */ #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \ @@ -108,6 +124,13 @@ __ALTERNATIVE_CFG_2(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)) +#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 /* CONFIG_RISCV_ALTERNATIVE */ #ifdef __ASSEMBLY__ @@ -152,15 +175,28 @@ _ALTERNATIVE_CFG(old_content, new_content, vendor_id, errata_id, CONFIG_k) /* - * A vendor wants to replace an old_content, but another vendor has used - * ALTERNATIVE() to patch its customized content at the same location. In - * this case, this vendor can create a new macro ALTERNATIVE_2() based - * on the following sample code and then replace ALTERNATIVE() with - * ALTERNATIVE_2() to append its customized content. + * 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(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) \ _ALTERNATIVE_CFG_2(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) +#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