From patchwork Sat Nov 2 00:08:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13859846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2896E6F096 for ; Sat, 2 Nov 2024 00:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZhuAZUdQl7hHgxOKSrvjGXreoeFBUSkV1xBC9AAOvfw=; b=rtKT2Gn3NE3luW aplrNCSCyCkpqCP++b8g+oLA8R7STtItTDywKPx3Q8gB746qDzELH68thAr+HxyF1D05doml1nyb0 8gf1ReE7Rt0WBG3XZebjZPEKyA2xSAUH56Dx7q21GfiwHczMaSEAnCFqhUn0D+wTnrTCIOEh73BZY 1QFAtyka57fEHxvEO0f3STZ010Y8K44i8fZVjMrbs5NQn6GgVurJdKPzJWV3OQoHpMnjUa4EZ/VjS eBo28yFcVAbHoeB+qbVUk8yD3t2z3JyGAtv9I8xFlsL5C9gnETOAtAsJnvxu7zKCi8hdcd/R9aY/o akPR1fXHb2bJ6T1GIXlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t71hO-00000008a6a-36jQ; Sat, 02 Nov 2024 00:09:02 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t71hJ-00000008a2q-3pP7 for linux-riscv@lists.infradead.org; Sat, 02 Nov 2024 00:08:59 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2e2e8c8915eso1870202a91.3 for ; Fri, 01 Nov 2024 17:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1730506137; x=1731110937; darn=lists.infradead.org; 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=JRtASMxkZ2ldGOvfeerHbEGvM2z0DU3xjXzdLsuPJUE=; b=ZtwPQS+ReCuHug4myEESvla0Rd/gGFG8U8qSopqKZs8BEYs8LyrmE9zQPtgLIMlt4u TCYNNaxLdiCBx59pKE6GpyF+N+/w5UEQwbkrnMpZbzTdchay5oriljvH/jt66akAnQtL exHKtD7hcUAHN1cBGtRCv/s9AOwDO2uUMcN/+A3ZQCaqH/rmWYouo/Mk4Tcnkx+vTxYY tcD6gdlwvew8b+zdUNmvdUOD6zKBhxa0t3jyzBzztyOGfi9GmNDHP/QZ9A8chUp5402w 0Bu/zv1wkjPM/HVCg9ikdtJtpv2I4L/MS+KhABI0PfjJyYOBF23+VhDj80XcE2xVJGS/ CQxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730506137; x=1731110937; 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=JRtASMxkZ2ldGOvfeerHbEGvM2z0DU3xjXzdLsuPJUE=; b=mfuLPQp4g1t7r0gCxyxlyUiycmhkiWNNlreqqkV2ugsVJesiYfzsqmC1bOfGt5Og4/ wBUOdkLvPk5I5+e8UclAc+dWx/YbXBVONsWNLNQZPjxrN8Ac7gA19Z8D28tbCIXtpjFL n9r1mjwewPdpkF36EDwoXqAp3LDD8lK7+KxU3dFy5sFc8L2rV0cM081UBcNYzEmTXpHC QraSk1og1u8nWYrU5pN6P8NDUW654hGOoN/OeAKe2XEINDVByLEkzQWC0bnAS0f07yAb KGQC4Ktm6OtEmVQQjUYl/4dIhkzsRjYEuQr0vBXb2YcTrO8c4HSDCeYoQtp7MeQa0Q1g DimA== X-Forwarded-Encrypted: i=1; AJvYcCXeY71+YrsGtdu8UY4L87Svs16NsTvn6wwD2n9tJDQkskiqrRATxUhVg3AzQE+EvGB4E5ZG65wvpRSnOQ==@lists.infradead.org X-Gm-Message-State: AOJu0YxQABWiwviHiNuGp5J8Ed08twSI2/wvhPsqQW0U/4z9tbYzzxAC k3+6S5+BWB0utHJO+nMd8zB1toGHpDk3sLuIF6DLItH/QUbrGzDDStiTs7rzOVo= X-Google-Smtp-Source: AGHT+IH5KcByeEBw2OOY5V7H9n30x3o1ATzmOMlVsm210lwm8Cl0yUhEsGHB9DB3VS3H/jnYnQ0xAQ== X-Received: by 2002:a17:90b:4c11:b0:2e2:e6bf:cd64 with SMTP id 98e67ed59e1d1-2e94c2a15e2mr7677527a91.5.1730506137321; Fri, 01 Nov 2024 17:08:57 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e92fc00856sm5505749a91.54.2024.11.01.17.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 17:08:56 -0700 (PDT) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org, Conor Dooley Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Ghiti , Lad Prabhakar , Emil Renner Berthing , Rob Herring , Krzysztof Kozlowski , Samuel Holland Subject: [PATCH 08/11] riscv: alternative: Add an ALTERNATIVE_3 macro Date: Fri, 1 Nov 2024 17:08:02 -0700 Message-ID: <20241102000843.1301099-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241102000843.1301099-1-samuel.holland@sifive.com> References: <20241102000843.1301099-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241101_170858_081473_FED29B34 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ALT_FIXUP_PMA() is already using ALTERNATIVE_2(), but needs to be extended to handle a fourth case. Add ALTERNATIVE_3(), which extends ALTERNATIVE_2() with another block of new content. Signed-off-by: Samuel Holland --- arch/riscv/include/asm/alternative-macros.h | 45 ++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h index 721ec275ce57..b6027a8b6b50 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, \patch_id_2, \enable_2, "\new_c_2" .endm +.macro ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \ + new_c_2, vendor_id_2, patch_id_2, enable_2, \ + new_c_3, vendor_id_3, patch_id_3, enable_3 + ALTERNATIVE_CFG_2 "\old_c", "\new_c_1", \vendor_id_1, \patch_id_1, \enable_1 \ + "\new_c_2", \vendor_id_2, \patch_id_2, \enable_2 \ + ALT_NEW_CONTENT \vendor_id_3, \patch_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, patch_id_1, enable_1) \ ALT_NEW_CONTENT(vendor_id_2, patch_id_2, enable_2, new_c_2) +#define __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \ + new_c_2, vendor_id_2, patch_id_2, enable_2, \ + new_c_3, vendor_id_3, patch_id_3, enable_3) \ + __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, patch_id_1, enable_1, \ + new_c_2, vendor_id_2, patch_id_2, enable_2) \ + ALT_NEW_CONTENT(vendor_id_3, patch_id_3, enable_3, new_c_3) + #endif /* __ASSEMBLY__ */ #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, patch_id, CONFIG_k) \ @@ -108,6 +124,13 @@ __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, patch_id_1, IS_ENABLED(CONFIG_k_1), \ new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2)) +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, patch_id_1, CONFIG_k_1, \ + new_c_2, vendor_id_2, patch_id_2, CONFIG_k_2, \ + new_c_3, vendor_id_3, patch_id_3, CONFIG_k_3) \ + __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, patch_id_1, IS_ENABLED(CONFIG_k_1), \ + new_c_2, vendor_id_2, patch_id_2, IS_ENABLED(CONFIG_k_2), \ + new_c_3, vendor_id_3, patch_id_3, IS_ENABLED(CONFIG_k_3)) + #else /* CONFIG_RISCV_ALTERNATIVE */ #ifdef __ASSEMBLY__ @@ -121,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) \ @@ -132,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 */ @@ -152,15 +181,21 @@ _ALTERNATIVE_CFG(old_content, new_content, vendor_id, patch_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. + * Variant of ALTERNATIVE() that supports two sets of replacement content. */ #define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \ new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2) \ _ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \ new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2) +/* + * Variant of ALTERNATIVE() that supports three sets of replacement content. + */ +#define ALTERNATIVE_3(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \ + new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2, \ + new_content_3, vendor_id_3, patch_id_3, CONFIG_k_3) \ + _ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, patch_id_1, CONFIG_k_1, \ + new_content_2, vendor_id_2, patch_id_2, CONFIG_k_2, \ + new_content_3, vendor_id_3, patch_id_3, CONFIG_k_3) + #endif