Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9221613rwb; Thu, 24 Nov 2022 09:35:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iDZY31LonYdWKXYhf1ZToAtznaRPeMUj9nZ+AwvEXzj6OzbnQ6pnT5zDJWvJUGmOKkIDg X-Received: by 2002:a63:530f:0:b0:476:bfca:38ad with SMTP id h15-20020a63530f000000b00476bfca38admr13501274pgb.576.1669311321208; Thu, 24 Nov 2022 09:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669311321; cv=none; d=google.com; s=arc-20160816; b=CmRPE5WDAkg4PhgGxM+oMx5F3nI5A0ZGOh8/QyPENjq+DyUWUHQ1Jp1XqhPwtABjjg BOYOLv3UXLvgRXvQPrlynuARfg6nG4nGXRz4elThWz6OpjCj/ueHgI7PKc74Z2qkIsJ4 VpM2CeB5CEBleNIHvuMuVRfGu1POop0ioC7ldOxq9nmtjGnuYIHf+JFDQ9l5h2zxxZ6g U28+ZSRA+kY/xZNb3w4GdQ//Sl6NmHw21OdoMEydSg2KkZR3KsJWbsPbOYX7B3pwvyfu 7JgtE9Qx885AAHOc5Z7SjkYZ4QaPwbb8HzHpQWEMVcfytbd5d+D4ESGow5hi5PpkoY7d t/jA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a655949000000b0046f729604f6si1959278pgu.174.2022.11.24.09.35.09; Thu, 24 Nov 2022 09:35: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=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 + 86 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 ); 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 X-Google-Original-From: Prabhakar To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Geert Uytterhoeven , Magnus Damm , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Guo Ren 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: [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: X-Mailing-List: linux-kernel@vger.kernel.org From: Lad Prabhakar Introduce ALTERNATIVE_3() macro. Signed-off-by: Lad Prabhakar --- 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 -- 2.25.1