From patchwork Mon May 15 09:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=SQ0C0PY9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Du7WSd7U; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3S4tPrz20dd for ; Mon, 15 May 2023 19:35:16 +1000 (AEST) 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=jdVswsZ8zO18sKKU/ZkSE8g8HG/8wGZQZG4UskoAFeI=; b=SQ0C0PY9Pt8DIH g8ilQUqZMrpIRJ6tkhRBX1ZgtMHlpQ1vTFklqwTbfcdwlC11IvppFsTFcnY8SRcO/yH9ax5w5dgdP 6Sndgc7U79hghGDzU0+J/nChki33NRT71Ev8iVEnmWLK1wDZ3NgKPwimAvLTBKXL+ZFg+OUeGISWm n+9GOSv8lF9sEaWTUBXFffMLh8lD8c61MAjqrdKYtfWLIS53qxWM51s9UYtaJ3Fxm1zSWKEvd6oOA 0RNf+epDFc5MGZ5P9LV6Wpg4BuJE5kSC3VLInQMGL68RCXYRWt9WbRmLkIUb76Yqe4mvVqGt2k2ZX eDhASA7Go2OpUufVhyNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbc-001ZJd-2b; Mon, 15 May 2023 09:35:00 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbZ-001ZFi-0t for opensbi@lists.infradead.org; Mon, 15 May 2023 09:34:59 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-305f0491e62so12129498f8f.3 for ; Mon, 15 May 2023 02:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143295; x=1686735295; 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=iDEpVqN7plPX5jrqX53ouFke2M87NZ6Nvxm3dZxaJ5w=; b=Du7WSd7Up+EpVc678akokJ3UXDXCrwReEMU6JSQXbhv7SlckRwESKVNtgs5txHdkKD aynxVBChBTuL76vcqA9jsIGBKLTkPCQZ6nYLoaz7CXW9VOOD4GTmVn6LKK059yz9jEyD 1DibtFRzbVk5WO8DhZZNCTFQFc4vjGZ2hQoXYICaBM5M6KXgNvZyMZIkv5DALBWlEKRM HiAWHlqUbxPGmvM+3G6b9Zc6mS9qGBIMq82Z7m5a5In+MVphJUOqdHp0tKJBOf+L74wF wxFmty6PrmdHVj13RXd9VEtMXBpeYfaYg10EaUiZloiBZR2wAZfPYZABgw1BOHbacg4M xJFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143295; x=1686735295; 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=iDEpVqN7plPX5jrqX53ouFke2M87NZ6Nvxm3dZxaJ5w=; b=KQpz6QOsxItvizskuxpHOpiygt9R7M93DyNGv83b5NRPvb5tFnyDVv1dkbmDrJvAeP kqJyM3Rw1eBX7eSj8VHDe3j465kcdrPVFh1/onYMbFh1KjV/7nONm3ZhgSRUnUA6yU7J wP0nCYn+SnyfnQcMylsh4LoamcVQtAWMvZdEESf4xR7Mffai0ML4VMhBWJEioFHSMibJ LaBPG5NaZrphnyjhHXKY8uHFYKI8GZD+qCSGFb9OtFXPM5TANOTTgKOE5I+D2I+58/o2 pwi8Jx1AxMBDRZmIDVQV4jv4CKB9Y5ItKnf3koAU9Q8tRkfW4Rb/Os7CmV/a1iCE34hl kuXw== X-Gm-Message-State: AC+VfDynpX9rgmfZA2T4KjnjQ8IJaidC9TScsd9GCkz18PuMy8mt+RHX M5QHchmeRzJ/wx9yxvJ96ezwnXJtIM3z9jZDE1A= X-Google-Smtp-Source: ACHHUZ4BkBFxJ0ZyYKYSqeLgi36yo3GsCjXTZiaPPrb8b0O18aobVAogL5AmUEaT8kwDaUk1qTaFeQ== X-Received: by 2002:adf:ff85:0:b0:307:92e8:ec60 with SMTP id j5-20020adfff85000000b0030792e8ec60mr18588979wrr.39.1684143294890; Mon, 15 May 2023 02:34:54 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id i8-20020a5d6308000000b003079ed1f0a0sm20963320wru.44.2023.05.15.02.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:34:54 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 1/7] lib: sbi: Introduce register_extensions extension callback Date: Mon, 15 May 2023 11:34:40 +0200 Message-Id: <20230515093446.73123-2-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023457_340405_329C4905 X-CRM114-Status: GOOD ( 13.35 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Rather than registering all extensions on their behalf in sbi_ecall_init(), introduce another extension callback and invoke that instead. For now, implement each callback by simply registering the ext [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Rather than registering all extensions on their behalf in sbi_ecall_init(), introduce another extension callback and invoke that instead. For now, implement each callback by simply registering the extension, which means this patch has no intended functional change. In later patches, extension callbacks will be modified to choose when to register and to possibly narrow the extension ID range prior to registering. When an extension range needs to remove IDs, leaving gaps, then multiple invocations of sbi_ecall_register_extension() may be used. In summary, later patches for current extensions and the introductions of future extensions will use the new callback to ensure that only valid extension IDs from the initial range, which are also available, will be registered. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- include/sbi/sbi_ecall.h | 1 + lib/sbi/sbi_ecall.c | 5 ++++- lib/sbi/sbi_ecall_base.c | 14 +++++++++++--- lib/sbi/sbi_ecall_cppc.c | 16 ++++++++++++---- lib/sbi/sbi_ecall_dbcn.c | 16 ++++++++++++---- lib/sbi/sbi_ecall_hsm.c | 14 +++++++++++--- lib/sbi/sbi_ecall_ipi.c | 14 +++++++++++--- lib/sbi/sbi_ecall_legacy.c | 14 +++++++++++--- lib/sbi/sbi_ecall_pmu.c | 16 ++++++++++++---- lib/sbi/sbi_ecall_rfence.c | 14 +++++++++++--- lib/sbi/sbi_ecall_srst.c | 16 ++++++++++++---- lib/sbi/sbi_ecall_susp.c | 16 ++++++++++++---- lib/sbi/sbi_ecall_time.c | 14 +++++++++++--- lib/sbi/sbi_ecall_vendor.c | 16 ++++++++++++---- 14 files changed, 143 insertions(+), 43 deletions(-) diff --git a/include/sbi/sbi_ecall.h b/include/sbi/sbi_ecall.h index ff9bf8e2b435..fac26429cf5d 100644 --- a/include/sbi/sbi_ecall.h +++ b/include/sbi/sbi_ecall.h @@ -24,6 +24,7 @@ struct sbi_ecall_extension { struct sbi_dlist head; unsigned long extid_start; unsigned long extid_end; + int (* register_extensions)(void); int (* probe)(unsigned long extid, unsigned long *out_val); int (* handle)(unsigned long extid, unsigned long funcid, const struct sbi_trap_regs *regs, diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c index 76a1ae9ab733..3eb4f0addb02 100644 --- a/lib/sbi/sbi_ecall.c +++ b/lib/sbi/sbi_ecall.c @@ -154,7 +154,10 @@ int sbi_ecall_init(void) for (i = 0; i < sbi_ecall_exts_size; i++) { ext = sbi_ecall_exts[i]; - ret = sbi_ecall_register_extension(ext); + ret = SBI_ENODEV; + + if (ext->register_extensions) + ret = ext->register_extensions(); if (ret) return ret; } diff --git a/lib/sbi/sbi_ecall_base.c b/lib/sbi/sbi_ecall_base.c index 786d2ac67924..74f05eb26a35 100644 --- a/lib/sbi/sbi_ecall_base.c +++ b/lib/sbi/sbi_ecall_base.c @@ -72,8 +72,16 @@ static int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_base; + +static int sbi_ecall_base_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_base); +} + struct sbi_ecall_extension ecall_base = { - .extid_start = SBI_EXT_BASE, - .extid_end = SBI_EXT_BASE, - .handle = sbi_ecall_base_handler, + .extid_start = SBI_EXT_BASE, + .extid_end = SBI_EXT_BASE, + .register_extensions = sbi_ecall_base_register_extensions, + .handle = sbi_ecall_base_handler, }; diff --git a/lib/sbi/sbi_ecall_cppc.c b/lib/sbi/sbi_ecall_cppc.c index 91585f3b74e3..42ec744c22ba 100644 --- a/lib/sbi/sbi_ecall_cppc.c +++ b/lib/sbi/sbi_ecall_cppc.c @@ -55,9 +55,17 @@ static int sbi_ecall_cppc_probe(unsigned long extid, unsigned long *out_val) return 0; } +struct sbi_ecall_extension ecall_cppc; + +static int sbi_ecall_cppc_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_cppc); +} + struct sbi_ecall_extension ecall_cppc = { - .extid_start = SBI_EXT_CPPC, - .extid_end = SBI_EXT_CPPC, - .handle = sbi_ecall_cppc_handler, - .probe = sbi_ecall_cppc_probe, + .extid_start = SBI_EXT_CPPC, + .extid_end = SBI_EXT_CPPC, + .register_extensions = sbi_ecall_cppc_register_extensions, + .probe = sbi_ecall_cppc_probe, + .handle = sbi_ecall_cppc_handler, }; diff --git a/lib/sbi/sbi_ecall_dbcn.c b/lib/sbi/sbi_ecall_dbcn.c index fe7e175a64c1..58b19e4468ef 100644 --- a/lib/sbi/sbi_ecall_dbcn.c +++ b/lib/sbi/sbi_ecall_dbcn.c @@ -64,9 +64,17 @@ static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val) return 0; } +struct sbi_ecall_extension ecall_dbcn; + +static int sbi_ecall_dbcn_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_dbcn); +} + struct sbi_ecall_extension ecall_dbcn = { - .extid_start = SBI_EXT_DBCN, - .extid_end = SBI_EXT_DBCN, - .handle = sbi_ecall_dbcn_handler, - .probe = sbi_ecall_dbcn_probe, + .extid_start = SBI_EXT_DBCN, + .extid_end = SBI_EXT_DBCN, + .register_extensions = sbi_ecall_dbcn_register_extensions, + .probe = sbi_ecall_dbcn_probe, + .handle = sbi_ecall_dbcn_handler, }; diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c index f1b41d073b22..20705c395131 100644 --- a/lib/sbi/sbi_ecall_hsm.c +++ b/lib/sbi/sbi_ecall_hsm.c @@ -54,8 +54,16 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_hsm; + +static int sbi_ecall_hsm_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_hsm); +} + struct sbi_ecall_extension ecall_hsm = { - .extid_start = SBI_EXT_HSM, - .extid_end = SBI_EXT_HSM, - .handle = sbi_ecall_hsm_handler, + .extid_start = SBI_EXT_HSM, + .extid_end = SBI_EXT_HSM, + .register_extensions = sbi_ecall_hsm_register_extensions, + .handle = sbi_ecall_hsm_handler, }; diff --git a/lib/sbi/sbi_ecall_ipi.c b/lib/sbi/sbi_ecall_ipi.c index f4797e117a34..a40d6b8cc8a8 100644 --- a/lib/sbi/sbi_ecall_ipi.c +++ b/lib/sbi/sbi_ecall_ipi.c @@ -29,8 +29,16 @@ static int sbi_ecall_ipi_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_ipi; + +static int sbi_ecall_ipi_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_ipi); +} + struct sbi_ecall_extension ecall_ipi = { - .extid_start = SBI_EXT_IPI, - .extid_end = SBI_EXT_IPI, - .handle = sbi_ecall_ipi_handler, + .extid_start = SBI_EXT_IPI, + .extid_end = SBI_EXT_IPI, + .register_extensions = sbi_ecall_ipi_register_extensions, + .handle = sbi_ecall_ipi_handler, }; diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 8237498b538f..99e862e0f19f 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -117,8 +117,16 @@ static int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_legacy; + +static int sbi_ecall_legacy_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_legacy); +} + struct sbi_ecall_extension ecall_legacy = { - .extid_start = SBI_EXT_0_1_SET_TIMER, - .extid_end = SBI_EXT_0_1_SHUTDOWN, - .handle = sbi_ecall_legacy_handler, + .extid_start = SBI_EXT_0_1_SET_TIMER, + .extid_end = SBI_EXT_0_1_SHUTDOWN, + .register_extensions = sbi_ecall_legacy_register_extensions, + .handle = sbi_ecall_legacy_handler, }; diff --git a/lib/sbi/sbi_ecall_pmu.c b/lib/sbi/sbi_ecall_pmu.c index 367e92774261..b0589d0ecfa1 100644 --- a/lib/sbi/sbi_ecall_pmu.c +++ b/lib/sbi/sbi_ecall_pmu.c @@ -88,9 +88,17 @@ static int sbi_ecall_pmu_probe(unsigned long extid, unsigned long *out_val) return 0; } +struct sbi_ecall_extension ecall_pmu; + +static int sbi_ecall_pmu_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_pmu); +} + struct sbi_ecall_extension ecall_pmu = { - .extid_start = SBI_EXT_PMU, - .extid_end = SBI_EXT_PMU, - .handle = sbi_ecall_pmu_handler, - .probe = sbi_ecall_pmu_probe, + .extid_start = SBI_EXT_PMU, + .extid_end = SBI_EXT_PMU, + .register_extensions = sbi_ecall_pmu_register_extensions, + .probe = sbi_ecall_pmu_probe, + .handle = sbi_ecall_pmu_handler, }; diff --git a/lib/sbi/sbi_ecall_rfence.c b/lib/sbi/sbi_ecall_rfence.c index 6334c001d450..22c665227826 100644 --- a/lib/sbi/sbi_ecall_rfence.c +++ b/lib/sbi/sbi_ecall_rfence.c @@ -79,8 +79,16 @@ static int sbi_ecall_rfence_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_rfence; + +static int sbi_ecall_rfence_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_rfence); +} + struct sbi_ecall_extension ecall_rfence = { - .extid_start = SBI_EXT_RFENCE, - .extid_end = SBI_EXT_RFENCE, - .handle = sbi_ecall_rfence_handler, + .extid_start = SBI_EXT_RFENCE, + .extid_end = SBI_EXT_RFENCE, + .register_extensions = sbi_ecall_rfence_register_extensions, + .handle = sbi_ecall_rfence_handler, }; diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c index 93b012ce024c..ad31537604a3 100644 --- a/lib/sbi/sbi_ecall_srst.c +++ b/lib/sbi/sbi_ecall_srst.c @@ -67,9 +67,17 @@ static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val) return 0; } +struct sbi_ecall_extension ecall_srst; + +static int sbi_ecall_srst_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_srst); +} + struct sbi_ecall_extension ecall_srst = { - .extid_start = SBI_EXT_SRST, - .extid_end = SBI_EXT_SRST, - .handle = sbi_ecall_srst_handler, - .probe = sbi_ecall_srst_probe, + .extid_start = SBI_EXT_SRST, + .extid_end = SBI_EXT_SRST, + .register_extensions = sbi_ecall_srst_register_extensions, + .probe = sbi_ecall_srst_probe, + .handle = sbi_ecall_srst_handler, }; diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c index f20126c49a60..bfbdbe648625 100644 --- a/lib/sbi/sbi_ecall_susp.c +++ b/lib/sbi/sbi_ecall_susp.c @@ -40,9 +40,17 @@ static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val) return 0; } +struct sbi_ecall_extension ecall_susp; + +static int sbi_ecall_susp_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_susp); +} + struct sbi_ecall_extension ecall_susp = { - .extid_start = SBI_EXT_SUSP, - .extid_end = SBI_EXT_SUSP, - .handle = sbi_ecall_susp_handler, - .probe = sbi_ecall_susp_probe, + .extid_start = SBI_EXT_SUSP, + .extid_end = SBI_EXT_SUSP, + .register_extensions = sbi_ecall_susp_register_extensions, + .probe = sbi_ecall_susp_probe, + .handle = sbi_ecall_susp_handler, }; diff --git a/lib/sbi/sbi_ecall_time.c b/lib/sbi/sbi_ecall_time.c index 668cb17680c0..e79196f77adc 100644 --- a/lib/sbi/sbi_ecall_time.c +++ b/lib/sbi/sbi_ecall_time.c @@ -33,8 +33,16 @@ static int sbi_ecall_time_handler(unsigned long extid, unsigned long funcid, return ret; } +struct sbi_ecall_extension ecall_time; + +static int sbi_ecall_time_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_time); +} + struct sbi_ecall_extension ecall_time = { - .extid_start = SBI_EXT_TIME, - .extid_end = SBI_EXT_TIME, - .handle = sbi_ecall_time_handler, + .extid_start = SBI_EXT_TIME, + .extid_end = SBI_EXT_TIME, + .register_extensions = sbi_ecall_time_register_extensions, + .handle = sbi_ecall_time_handler, }; diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index 8b8dab00c92d..126156f79a12 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -47,9 +47,17 @@ static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid, out_val, out_trap); } +struct sbi_ecall_extension ecall_vendor; + +static int sbi_ecall_vendor_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_vendor); +} + struct sbi_ecall_extension ecall_vendor = { - .extid_start = SBI_EXT_VENDOR_START, - .extid_end = SBI_EXT_VENDOR_END, - .probe = sbi_ecall_vendor_probe, - .handle = sbi_ecall_vendor_handler, + .extid_start = SBI_EXT_VENDOR_START, + .extid_end = SBI_EXT_VENDOR_END, + .register_extensions = sbi_ecall_vendor_register_extensions, + .probe = sbi_ecall_vendor_probe, + .handle = sbi_ecall_vendor_handler, }; From patchwork Mon May 15 09:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gM+zQwQl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=ofl+3TzZ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3S3VGxz20KF for ; Mon, 15 May 2023 19:35:16 +1000 (AEST) 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=xz3fEYsg3I4T5H8vEiZxAtx6OFRLEirD6q14/lwMlfk=; b=gM+zQwQlrkrTzV pANMaEml/mAsNbKWq9V+awNsWoUQZf6uXTvqgphETJ9OCJhUmtJjAdigkOn+o9Ab7cwFP50MqCo9q IURNbwH4NeRwdAeTLEcG+pk9LFPpFrHL3RUXfXL0kI5YFkwrlsfMmSPWhNMdvkQXvrVaQw3ZNe+wR AHOmSnyu7+1NhFFvhuN4iZfUhqL1FROE8EXvHPBOfdU9a5pjOw63teoT5lI25OPkLXLan95Y5nNJk 91GgBDv4LTk36NbJFfHdepdsQbCHrJcNWGF+eUMCtbXfL/BWHU5VDF+bcSYeJhM3H6hMUCcjvLImC U4FhVzuP7yeYcZUy/cGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbd-001ZJq-0o; Mon, 15 May 2023 09:35:01 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUba-001ZGo-0z for opensbi@lists.infradead.org; Mon, 15 May 2023 09:34:59 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-30789a4c537so6576197f8f.0 for ; Mon, 15 May 2023 02:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143297; x=1686735297; 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=yWDRUMw2EZDmkzPbUIaDmUU2dCKTQVSZ8URZxEkj0Ik=; b=ofl+3TzZXsU9WRe0KEKbuusPt3/LbTfOeRvtQoBIycO0vU2ye8aD1G/EIf4tCyulbs 5EubVQyCGd12IqxpSDsv+kdusj4zR1WcORDgP0Zz/03qtL9D+wvRocVEI84rrtPGk247 Qu75mTgVbvnRmRm8PiI+h+YvtLEget1BBdTfa2RESXSMPSkSLYdjYwCpkMI/hxFhiKlw hCfy+aQIV+nW0ZL+ROY7laceMOsiJQ/XxJyhl9ofGb6JP65lmkRPQjha4uDv4lxMMLoe Ytn46y5Fjf4msXhypZeTRZFocixZLKNPm8Abvmnn6ykTbF/ORxMH3jrLjLEH+LS6rSBQ RJuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143297; x=1686735297; 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=yWDRUMw2EZDmkzPbUIaDmUU2dCKTQVSZ8URZxEkj0Ik=; b=bjen89qo4dvmSPc0U1LJyLOTa2akOFPwgZQ7fzNnWLvqCFZen0q9rVNNe34I/8BX7f JuILyaNYgO8Ww3uuuv9XNs6T3Cb7FcsQlmghquzpZuY9zuvy4dgemGVB6WGVRRBzR5eg I/xYDdoOJUMaghhSgekz4EX5gEU0GZHd8mKrTGbzF+VHeJbZFI+NfXWzlaoke1kSIYYF 8VkoyXfaRjzodRn/WldiMphlf4/vLLFtHjyNk0L8YRmA+IGkiJFUtKs1dA4nTnJuOQAn 46BFv4exFBXjQWm3J8/L5artejSOGIfnBKzrtyJNSN2CAkBkBBA404a2lzlLPMsrS6o0 LF+Q== X-Gm-Message-State: AC+VfDyYIKYokVoiK3f+SNud8NrhHx/6dKYboF1iLwdttpQ3qCD/NB8y bpwqOW0mhyBHP93LP0wvfMcQSXn0s5PB6JV4YiE= X-Google-Smtp-Source: ACHHUZ7G7lcIx33Q633lYTU7MkdWg0nZ7U/VDFvRtpxXtkvgmaL4aSl56Wa5UiOakSWOisiDhLIRzA== X-Received: by 2002:a5d:5285:0:b0:2fe:e435:4a17 with SMTP id c5-20020a5d5285000000b002fee4354a17mr20723053wrv.65.1684143296823; Mon, 15 May 2023 02:34:56 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id i8-20020a5d6308000000b003079ed1f0a0sm20963404wru.44.2023.05.15.02.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:34:56 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 2/7] lib: sbi: Narrow vendor extension range Date: Mon, 15 May 2023 11:34:41 +0200 Message-Id: <20230515093446.73123-3-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023458_370301_7A7DD0AD X-CRM114-Status: GOOD ( 11.80 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The vendor extension ID range is large, but at runtime at most a single ID will be available. Narrow the range in the register_extensions callback. After narrowing, we no longer need to check that the [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The vendor extension ID range is large, but at runtime at most a single ID will be available. Narrow the range in the register_extensions callback. After narrowing, we no longer need to check that the extension ID is correct in the other callbacks, as those callbacks will never be invoked with anything other than the single ID. Signed-off-by: Andrew Jones --- lib/sbi/sbi_ecall_vendor.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index 126156f79a12..39c58c8b6fd5 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -25,8 +25,7 @@ static inline unsigned long sbi_ecall_vendor_id(void) static int sbi_ecall_vendor_probe(unsigned long extid, unsigned long *out_val) { - if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr()) || - extid != sbi_ecall_vendor_id()) + if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr())) *out_val = 0; else *out_val = 1; @@ -38,8 +37,7 @@ static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid, unsigned long *out_val, struct sbi_trap_info *out_trap) { - if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr()) || - extid != sbi_ecall_vendor_id()) + if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr())) return SBI_ERR_NOT_SUPPORTED; return sbi_platform_vendor_ext_provider(sbi_platform_thishart_ptr(), @@ -51,6 +49,11 @@ struct sbi_ecall_extension ecall_vendor; static int sbi_ecall_vendor_register_extensions(void) { + unsigned long extid = sbi_ecall_vendor_id(); + + ecall_vendor.extid_start = extid; + ecall_vendor.extid_end = extid; + return sbi_ecall_register_extension(&ecall_vendor); } From patchwork Mon May 15 09:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=arF7ZPLa; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=MZz+ox6V; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3W27sJz20KF for ; Mon, 15 May 2023 19:35:19 +1000 (AEST) 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=dvkqcydXc+E72Fx3aFS+fkOhwISK1OThXmehL+kCB4A=; b=arF7ZPLa+EP/mg OtqKNatz7FjpupUyOheqEWKgYj8oomRUqiSWd6wgoqIMgXRUiyy/RvPoo5YXPe0NV4NcsqWGSF/pE u0qTqe7M9VoDP/I8f8wxlTyKtdZfZRm7dFV/ISnv47CGHfKV10L7diBPY9H4l1aUX5hk4gOa8KcEu 8vBe71/FEqihNG2F6qBXlmqWYy6eUT2VmZxa0GqPc9CMUnp+0XWB5U7IZlbY1cxcgS/6jcuLOy26M oEnOTJhpY/FdF5xihNE4/+MYhNFEcWf6Tt8LeNCFjJB6ZN5/EKz6PcO7n4jUb4bWkd0EXroEfdjIj OcmPvurOmxpsVbpPLmdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbg-001ZN3-1A; Mon, 15 May 2023 09:35:04 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbc-001ZHk-1a for opensbi@lists.infradead.org; Mon, 15 May 2023 09:35:03 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-306f2b42a86so8158538f8f.3 for ; Mon, 15 May 2023 02:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143298; x=1686735298; 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=tzHCDMaacNPuuBM/3DU+z/rXdOA317R3T6eVlgx/0bc=; b=MZz+ox6VZkhB20ulflnAJmYLHJDAUErjFtw737pR9mkK+lRgc/eKLXVS5c0meQF8q3 MM7ILIXYkp2sWjIkPnjkpJxS9AF92wdzOJLdqkFZtDU0iyCfGqyTE8MlW/AVWbJ56rnS YswkbWxcv/7dLu/ezGLaunBOY7nScUfMAbR1f9WbIMWXGpw0YCaTc7RBM/PNwkDdmQ9I IH60mcHwUVjAkfd/YRWV/l79sOlS6tTD+ipMhtRqy3qnlySaficZhnAVj/FgnL60kxR9 7ohE/yru95nWD9IlV58d6awi7Bizt4EH9CD8C5k8644+LkaiYl45oLKSAoNx6Vjqrmxt JkFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143298; x=1686735298; 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=tzHCDMaacNPuuBM/3DU+z/rXdOA317R3T6eVlgx/0bc=; b=kgizjRtSunTT0n5asQajl2P17+gSfuUgEfDTS8LPxxT4vhFtUSy0c0uEGpl9ykgoAx BcWv+yLxMeJf65Q2DYqlXSt3qO5mp4bNz+TU9b5SlNo3djRCZp7CyuhTzJT+pq6TCG58 G4KdH40NwmJraxlXw1xt6Alm0nL8o63GXclPemKkKAuVdns0Hpg1Ptk2VNx1K7tE8WHH 82KQQSA+pvNCzHRLQtI8R6Yfa4GBxEm5XADlA3V/LWlrZ2TkSQgrnIdpkhrZD64OrNuX OJsTbIIhOqAdxbye2pgYMLpHIWMkwiVmI/2xy2TC63AATS/w30/Bus36g51pTw6oTal5 LxrA== X-Gm-Message-State: AC+VfDxwPMIN1C3V0WKxrb8Zdt1XU6l+HwbWnNmrwu0lhHKJB8LSs3s4 q+MEE36ZcXClXEuSFMe61y1lKguLiTmsAbmQYE4= X-Google-Smtp-Source: ACHHUZ4V8mgwIr5l4NxJY1OZfHAAOUua/DKhs9Sz90KibTEzmpSXr+JLFW8ncmRuHh00Q45Br4xVEQ== X-Received: by 2002:adf:fcc5:0:b0:307:820a:490c with SMTP id f5-20020adffcc5000000b00307820a490cmr23654693wrs.13.1684143298158; Mon, 15 May 2023 02:34:58 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id f5-20020adff985000000b002fda1b12a0bsm32217033wrr.2.2023.05.15.02.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:34:57 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 3/7] lib: sbi: pmu: Remove unnecessary probe function Date: Mon, 15 May 2023 11:34:42 +0200 Message-Id: <20230515093446.73123-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023500_542663_53D73214 X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The absence of a probe implementation means that the extension is always available. Remove the implementation for the PMU extension, which does no checking, and indeed even has a comment saying it's a [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:434 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The absence of a probe implementation means that the extension is always available. Remove the implementation for the PMU extension, which does no checking, and indeed even has a comment saying it's always available. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_ecall_pmu.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/sbi/sbi_ecall_pmu.c b/lib/sbi/sbi_ecall_pmu.c index b0589d0ecfa1..1d5d512eeed7 100644 --- a/lib/sbi/sbi_ecall_pmu.c +++ b/lib/sbi/sbi_ecall_pmu.c @@ -81,13 +81,6 @@ static int sbi_ecall_pmu_handler(unsigned long extid, unsigned long funcid, return ret; } -static int sbi_ecall_pmu_probe(unsigned long extid, unsigned long *out_val) -{ - /* PMU extension is always enabled */ - *out_val = 1; - return 0; -} - struct sbi_ecall_extension ecall_pmu; static int sbi_ecall_pmu_register_extensions(void) @@ -99,6 +92,5 @@ struct sbi_ecall_extension ecall_pmu = { .extid_start = SBI_EXT_PMU, .extid_end = SBI_EXT_PMU, .register_extensions = sbi_ecall_pmu_register_extensions, - .probe = sbi_ecall_pmu_probe, .handle = sbi_ecall_pmu_handler, }; From patchwork Mon May 15 09:34:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wlv23Zl9; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Bro8il3J; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3V0vq9z20dd for ; Mon, 15 May 2023 19:35:17 +1000 (AEST) 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=UhHraRM23hJvwLXduYaKmNjBZib9GsADGmQ6YHEhKA0=; b=wlv23Zl98MNGih cATx/Y2LGb9Sj60eGhATOo/JZV9ddx4LSrgkd837rV4OK8NIrsiM4QOH7jyUS7lKs/XyBK/VUVVoq Asru0EuTnYryv/KYUpccuMU3kuXEnaL/MEgbUfdybj0IS7xZMyecbB6AyUL7WkgNxnT+HCdtPnq5I m40VkdIZgUipK8cebNOGeBkGSwUm7LYK9eFLCatJM4Zg2hw6jrTpltOZj13/3cDTjYHZT3GvwqNlP +46ITpW5ejxpe+g7hjptYZOfcUyCl7euiEX+HR9Cc/wNzl4JVjhYXBFfnhCMW0GkviMHWAJE2EjiM pmjKnms6UTh/8rQkcaZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbg-001ZNW-39; Mon, 15 May 2023 09:35:04 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbd-001ZIu-1P for opensbi@lists.infradead.org; Mon, 15 May 2023 09:35:03 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3063afa2372so11674176f8f.0 for ; Mon, 15 May 2023 02:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143299; x=1686735299; 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=VzHXKQReFewYiZgTkdteJk0TJJYp2JU42GzJ4nyNuJE=; b=Bro8il3JdxOwj34vbedXEFYmguaf7MpMAHogx7d3D4lMH3OAlHpNMBW5TN2QvPxDKk Dc8Vo1VOQYgPjXO2BaXXzqE7c0stSVFwWbCd/H8he8kzRPtLr5Ph3XRiIK6QSNaE3tK/ 6b9DwWXJqFJIaIyyQkSH+FDgteyFscWgLEHr4aL0dGKyr0hT59SOxKsP9fg79Gi1rChy rJ0MD8xFGMViSpEuRwUUOU/DdGQoge18mYgnTFTrWXtGq5AkNWJ3zgcNE4Y/G+9f1d1R oAvJJVO8cnEcGx9aSIHjjZeJR1PpAPs+P1E+u6JEzNcktKmwm0zprMVNg7nsxPYLGA6N 3lHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143299; x=1686735299; 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=VzHXKQReFewYiZgTkdteJk0TJJYp2JU42GzJ4nyNuJE=; b=d1A2YCYyOQmT+i+GAeQyHXj2pKpADFBD+D5dBzAgeGSkQvc1VnPV9ONSCBJaOXT7aq 3EKcLylSOyrBs72JM9Eal10xYj0AkkbHBs7UrFmuY65BhXtwPq6ubwjzMOiFsK+JcH9S yAu/TmOb7WNrXP0agBLJbXCvdDSmbjUzQUQNApLmQ2RLI05LwavEEMM/ai804CD9FRuO C6exblVvgKXR0tQhcpjMCBlNjvFIrWLd/oHT4g1bSPWz55hwo0tROkFJJlmEsfGK1SJN uYudovAgMEah+ugUFQl4yoda4xApCEuDHW/iEXUEu1s5h5QkCnIVvEVydalJIupJODS5 f0Iw== X-Gm-Message-State: AC+VfDzlwMi/Tuyik+1dIeeKd2L15ML6oQ7SWoLG66t4Xdm8XyBMJjFK yOWJhpbGuqAlQ/mGr6gvR8FDvybLemdm7+NTHko= X-Google-Smtp-Source: ACHHUZ6Mg4NZalRFS2GHQl6TuWz9Te87zUI7tDj1TLl+DvUc6AxzyJx7IymTt7H3h3R23wtsdFg7+g== X-Received: by 2002:adf:f2c3:0:b0:305:fbfb:c7d7 with SMTP id d3-20020adff2c3000000b00305fbfbc7d7mr25643648wrp.44.1684143299501; Mon, 15 May 2023 02:34:59 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id g8-20020adff3c8000000b003078354f774sm30368662wrp.36.2023.05.15.02.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:34:59 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 4/7] lib: sbi: Only register available extensions Date: Mon, 15 May 2023 11:34:43 +0200 Message-Id: <20230515093446.73123-5-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023501_511259_3C381F08 X-CRM114-Status: GOOD ( 11.63 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When an extension implements a probe function it means there's a chance that the extension is not available. Use this function in the register_extensions callback to determine if the extension should [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When an extension implements a probe function it means there's a chance that the extension is not available. Use this function in the register_extensions callback to determine if the extension should be registered at all. Where the probe implementation is simple, just open code the check. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_ecall_cppc.c | 3 +++ lib/sbi/sbi_ecall_dbcn.c | 3 +++ lib/sbi/sbi_ecall_srst.c | 6 ++++++ lib/sbi/sbi_ecall_susp.c | 6 ++++++ lib/sbi/sbi_ecall_vendor.c | 3 +++ 5 files changed, 21 insertions(+) diff --git a/lib/sbi/sbi_ecall_cppc.c b/lib/sbi/sbi_ecall_cppc.c index 42ec744c22ba..a6398ac78226 100644 --- a/lib/sbi/sbi_ecall_cppc.c +++ b/lib/sbi/sbi_ecall_cppc.c @@ -59,6 +59,9 @@ struct sbi_ecall_extension ecall_cppc; static int sbi_ecall_cppc_register_extensions(void) { + if (!sbi_cppc_get_device()) + return 0; + return sbi_ecall_register_extension(&ecall_cppc); } diff --git a/lib/sbi/sbi_ecall_dbcn.c b/lib/sbi/sbi_ecall_dbcn.c index 58b19e4468ef..cbb2e802e615 100644 --- a/lib/sbi/sbi_ecall_dbcn.c +++ b/lib/sbi/sbi_ecall_dbcn.c @@ -68,6 +68,9 @@ struct sbi_ecall_extension ecall_dbcn; static int sbi_ecall_dbcn_register_extensions(void) { + if (!sbi_console_get_device()) + return 0; + return sbi_ecall_register_extension(&ecall_dbcn); } diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c index ad31537604a3..ea0dc73f010d 100644 --- a/lib/sbi/sbi_ecall_srst.c +++ b/lib/sbi/sbi_ecall_srst.c @@ -71,6 +71,12 @@ struct sbi_ecall_extension ecall_srst; static int sbi_ecall_srst_register_extensions(void) { + unsigned long out_val; + + sbi_ecall_srst_probe(SBI_EXT_SRST, &out_val); + if (!out_val) + return 0; + return sbi_ecall_register_extension(&ecall_srst); } diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c index bfbdbe648625..c4124046b929 100644 --- a/lib/sbi/sbi_ecall_susp.c +++ b/lib/sbi/sbi_ecall_susp.c @@ -44,6 +44,12 @@ struct sbi_ecall_extension ecall_susp; static int sbi_ecall_susp_register_extensions(void) { + unsigned long out_val; + + sbi_ecall_susp_probe(SBI_EXT_SUSP, &out_val); + if (!out_val) + return 0; + return sbi_ecall_register_extension(&ecall_susp); } diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index 39c58c8b6fd5..c4a4c1c45b14 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -51,6 +51,9 @@ static int sbi_ecall_vendor_register_extensions(void) { unsigned long extid = sbi_ecall_vendor_id(); + if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr())) + return 0; + ecall_vendor.extid_start = extid; ecall_vendor.extid_end = extid; From patchwork Mon May 15 09:34:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=UEN2zs1I; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=O9v4Ev7A; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3X34Glz20KF for ; Mon, 15 May 2023 19:35:20 +1000 (AEST) 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=ROU3/QR6tq8CU9pmGd/q5o+s5p/Y8Y/P85vpxEdZzn8=; b=UEN2zs1Ix8nvxZ TmYDW1lhjplfVHHXbMVdy4vzSn6TdyIYox4nZFQCNSN++yN3fhQTlwTM6GKaE+6wfZu59a1H4sS/E /NL8de11dwCKPuvktc+ZfQcHCI2WLQkT+rnwigbWSLt763cvq9dimfO2XwjfVG4z2lAMjCu7YHw4X 7sFOu/xJ/QKqK/uxjeWelPqC6auRhzilTn45srFLOWnT6dTVRU9d7kJCYpDPx1XElabSN08vYL1fB E9p68WcR0HV4QOfZfpVpOnV+QVLTQB0gfaM6nKsz+czXN4CXr8ApeEcy2TzJOgSiLEs8Zl8FJIrM5 JbRihkNLXCNiemsHgohA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbh-001ZOH-1l; Mon, 15 May 2023 09:35:05 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbd-001ZF6-2W for opensbi@lists.infradead.org; Mon, 15 May 2023 09:35:04 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-30639daee76so8045546f8f.1 for ; Mon, 15 May 2023 02:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143301; x=1686735301; 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=kBT3XPFBWlKz+NiqulX9aGKK61yYeTfHvMNlDcte3OY=; b=O9v4Ev7AEnu6J9+c+NZ9OexNr5FJi8HDxXi18uaxsXiWQgV3IPSSS7MvCGn8v1GV7h i+Mz8s1pdgEk8WdTGmjlFdrYhlLhy5HO5dGy4dwf7mO+Zsp7jIrRe8hsNUIikr41zeFn 2+dNn3D6aAEqEyKVj3OV2b/2u/WuVThyQF0DZUWNutdezF6Dw18MefCU5Cr1OLLXvnym j5EmNdWwWGq7IgGu4eIKWGnT/4LugRaDSPFzRfoqCmskgM3GZKQvPI63/b96PMlxjvBD 9c/FVMhdI7YhPAdz8WUkdsoU10rGuV7j7oIA5Xksm9VVNrjhLd7myX9BqARC87fyweNc aKrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143301; x=1686735301; 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=kBT3XPFBWlKz+NiqulX9aGKK61yYeTfHvMNlDcte3OY=; b=GsMwXOyP8z+Uc4UA4wARBvnD3pDcNOth0WgqNIDqerqHxtvz+jwev0BPMDOwjvpq1g vwJRVUrdM5ldPesLAr4nOsP3r3J14tog44TXIMBl9Q/Z/cgELdfH4BB8w1VcQ4i+acp2 OpnHOhPmemOsbojP6M4GUR60AOIU8mloEB4/hQG5fcTiqApoHGysZaOTAupcSZltWuBT +2+bOXwRGqI+8uJaAsJg1UZRPDNUauNoXnuhBX4zmI5R0I+/nRGI2uBDLVK7jvnONRzD xMT8CpCI0CX6AnzbznM7eoEsN8CFaq43WM6lnluWwhX1/yBi4Rmuvf5/66ebwCZydgi/ NrMQ== X-Gm-Message-State: AC+VfDyU2PRxNrGStmDktdmHtPmcxeWNCOZHbHZJ5eVmuoLgfYo3Uugs 6aRaiYX3XD3vzqUKxMY3aN9kMrqkwixKRpznFsE= X-Google-Smtp-Source: ACHHUZ6q8Ty/cvAyr6Tm588XtKhGNDQeklkh/I5tj6+5R9dRJgAgIWxsCkEB5mmHN1sRywIx9FvtOA== X-Received: by 2002:adf:ee84:0:b0:306:3261:809 with SMTP id b4-20020adfee84000000b0030632610809mr22861103wro.50.1684143301103; Mon, 15 May 2023 02:35:01 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id f8-20020a7bcd08000000b003f42894ebe2sm20670146wmj.23.2023.05.15.02.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:35:00 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 5/7] lib: sbi: Optimize probe of srst/susp Date: Mon, 15 May 2023 11:34:44 +0200 Message-Id: <20230515093446.73123-6-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023501_863151_FE1DD8B7 X-CRM114-Status: GOOD ( 12.80 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Xiang W No need to do a fully comprehensive count, just find a supported reset or suspend type Signed-off-by: Xiang W Signed-off-by: Andrew Jones --- lib/sbi/sbi_ecall_srst.c | 10 ++++++---- lib/sbi/sbi_ecall_susp.c | 10 ++++++---- 2 files changed, 12 [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:429 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Xiang W No need to do a fully comprehensive count, just find a supported reset or suspend type Signed-off-by: Xiang W Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_ecall_srst.c | 10 ++++++---- lib/sbi/sbi_ecall_susp.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c index ea0dc73f010d..fd2dc0d251f3 100644 --- a/lib/sbi/sbi_ecall_srst.c +++ b/lib/sbi/sbi_ecall_srst.c @@ -50,7 +50,7 @@ static int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid, static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val) { - u32 type, count = 0; + u32 type; /* * At least one standard reset types should be supported by @@ -59,11 +59,13 @@ static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val) for (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) { if (sbi_system_reset_supported(type, - SBI_SRST_RESET_REASON_NONE)) - count++; + SBI_SRST_RESET_REASON_NONE)) { + *out_val = 1; + return 0; + } } - *out_val = (count) ? 1 : 0; + *out_val = 0; return 0; } diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c index c4124046b929..716a6d585af7 100644 --- a/lib/sbi/sbi_ecall_susp.c +++ b/lib/sbi/sbi_ecall_susp.c @@ -25,18 +25,20 @@ static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid, static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val) { - u32 type, count = 0; + u32 type; /* * At least one suspend type should be supported by the * platform for the SBI SUSP extension to be usable. */ for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) { - if (sbi_system_suspend_supported(type)) - count++; + if (sbi_system_suspend_supported(type)) { + *out_val = 1; + return 0; + } } - *out_val = count ? 1 : 0; + *out_val = 0; return 0; } From patchwork Mon May 15 09:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=i+5kwgfD; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=oJe1JOUs; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3b5pWKz20KF for ; Mon, 15 May 2023 19:35:23 +1000 (AEST) 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=CIU5twjEK4M4q3Sv+q8yprE/EL/5hdJfYZzSoSwH1vs=; b=i+5kwgfDmtJvTv 3LvI6//mxvOh6/sFf9zVyA3rude3B30GrtnxedYYFMCBzbnaYCuJkH+cZUemZ/qRLRRzIGbSu88UA JQzxpZHFv6EmGR8MDJtQpAD/UMz7tZ+4Sc0kQNqnuFqtIJ7JZflERcv4K6OZQIPNiPql+fZEkWZ/S 2BSGLZ42E0A+DWweJqCjl+H9vGAGPLNy1qAg5Tz9ysDdNaY6pubY0ZE/6+vVePv4mW3o0fKStxThn ikD43NQpp6WLolmHfMc2qsQUB/cl+yeJN/qYHwKT1yrKeSTWQ/FtKTBypEyD4qOH7/FJKNHIeahGw iOwPosDYBrIbz/ZU7CDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbn-001ZUH-10; Mon, 15 May 2023 09:35:11 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbi-001ZMW-1R for opensbi@lists.infradead.org; Mon, 15 May 2023 09:35:09 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3063208beedso11898286f8f.1 for ; Mon, 15 May 2023 02:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143302; x=1686735302; 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=1oRRlSotzJQwLDv1Gncf17a5m8rCQTTdn9BHI4zPjaM=; b=oJe1JOUsO4ItYAoVFE2/UVfS+G7et5sy2Uldvl9UkAdG/IcygLsrqt3ZHA70Ov8xsO CnSM/fyUA0YXZk0m9GOwxTC74xLETG7i5wxZJqGeN/yfAoTY9Y9qxB8bjE2BnI/L+Ehb LvWlBpYG5fVabe0hR7HKdbAQRV7kFE7eMG1K9+RhZY/AtcMR8Q2ioEpjem1arxbjC6yg Y5w+7OYSa3KomK/+dSe5AoNDXmmXzqPAa0kv5fgXWU5OQnfKpKkcRtK/QlkwDZGtOk2i niFEYlefUSCdY3MFKI8uaReHiKRD3slJwGfSLAekHqUPm91yh1sk4syux46vyLhgcYTq 8nnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143302; x=1686735302; 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=1oRRlSotzJQwLDv1Gncf17a5m8rCQTTdn9BHI4zPjaM=; b=RmIYPR+/nSBogGCM3IqR4rLO8F24VfVbHYH4+y+Xbjdg99Cxn0kw8eQyIdf5Cezwam uo2Xpr0DwOREPxPd+ccunD4guF/Oe5ENzAm9ZOLKu9tgAPtqEeetavC9iYUPGib2S5m8 lVXUOQX4KkHyLl4LDT1xfhhHofRED3pCtb3jsQCPDQ9EhwHmJ57Ma7JAxiu29ZCeEK0M 8H3VnZdrzXS9NvjUjzzX7BkbVH6Tzk3O3qAekAcpy+8BZqO2ft8mcWCZ6zhwtjXHBlMU YnVgKW/MnyxlPDB2wn2WpweBaZkrdY9gmFspVhMsCWNhNr8QlDRSAztTOkUVrF07Zxz6 NncQ== X-Gm-Message-State: AC+VfDzK/92lQxt8lKiGdC0wVJo7WUtRCDVey1GKUSKBY+NThSBAPuXU 8+scVUga2f+zdqij3Zo9edsHjXm0i+Bo2wHkfEE= X-Google-Smtp-Source: ACHHUZ4LSAjnvIToKV8i3gn2h5EPjVtpRM7RFz3j+ZBBVn+jX30i+pteSvOkp7Lg7/Qb4aWAUkrqNg== X-Received: by 2002:a5d:4c47:0:b0:306:3a16:1c2 with SMTP id n7-20020a5d4c47000000b003063a1601c2mr19939083wrt.12.1684143302564; Mon, 15 May 2023 02:35:02 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id l18-20020a5d4bd2000000b003078bb639bdsm27601030wrt.68.2023.05.15.02.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:35:02 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 6/7] lib: sbi: Remove 0/1 probe implementations Date: Mon, 15 May 2023 11:34:45 +0200 Message-Id: <20230515093446.73123-7-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023506_493707_CEDE2E0D X-CRM114-Status: GOOD ( 14.28 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When a probe implementation just returns zero for not available and one for available then we don't need it, as the extension won't be registered at all if it would return zero and the Base extension [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:432 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When a probe implementation just returns zero for not available and one for available then we don't need it, as the extension won't be registered at all if it would return zero and the Base extension probe function will already set out_val to 1 if not probe function is implemented. Currently all probe functions only return zero or one, so remove them all. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_ecall_cppc.c | 7 ------- lib/sbi/sbi_ecall_dbcn.c | 7 ------- lib/sbi/sbi_ecall_srst.c | 18 +++++------------- lib/sbi/sbi_ecall_susp.c | 17 +++++------------ lib/sbi/sbi_ecall_vendor.c | 11 ----------- 5 files changed, 10 insertions(+), 50 deletions(-) diff --git a/lib/sbi/sbi_ecall_cppc.c b/lib/sbi/sbi_ecall_cppc.c index a6398ac78226..b54d54ec684c 100644 --- a/lib/sbi/sbi_ecall_cppc.c +++ b/lib/sbi/sbi_ecall_cppc.c @@ -49,12 +49,6 @@ static int sbi_ecall_cppc_handler(unsigned long extid, unsigned long funcid, return ret; } -static int sbi_ecall_cppc_probe(unsigned long extid, unsigned long *out_val) -{ - *out_val = sbi_cppc_get_device() ? 1 : 0; - return 0; -} - struct sbi_ecall_extension ecall_cppc; static int sbi_ecall_cppc_register_extensions(void) @@ -69,6 +63,5 @@ struct sbi_ecall_extension ecall_cppc = { .extid_start = SBI_EXT_CPPC, .extid_end = SBI_EXT_CPPC, .register_extensions = sbi_ecall_cppc_register_extensions, - .probe = sbi_ecall_cppc_probe, .handle = sbi_ecall_cppc_handler, }; diff --git a/lib/sbi/sbi_ecall_dbcn.c b/lib/sbi/sbi_ecall_dbcn.c index cbb2e802e615..e0b892c2ed6b 100644 --- a/lib/sbi/sbi_ecall_dbcn.c +++ b/lib/sbi/sbi_ecall_dbcn.c @@ -58,12 +58,6 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, return SBI_ENOTSUPP; } -static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val) -{ - *out_val = sbi_console_get_device() ? 1 : 0; - return 0; -} - struct sbi_ecall_extension ecall_dbcn; static int sbi_ecall_dbcn_register_extensions(void) @@ -78,6 +72,5 @@ struct sbi_ecall_extension ecall_dbcn = { .extid_start = SBI_EXT_DBCN, .extid_end = SBI_EXT_DBCN, .register_extensions = sbi_ecall_dbcn_register_extensions, - .probe = sbi_ecall_dbcn_probe, .handle = sbi_ecall_dbcn_handler, }; diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c index fd2dc0d251f3..dcd560d22f9d 100644 --- a/lib/sbi/sbi_ecall_srst.c +++ b/lib/sbi/sbi_ecall_srst.c @@ -48,7 +48,7 @@ static int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid, return SBI_ENOTSUPP; } -static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val) +static bool srst_available(void) { u32 type; @@ -56,27 +56,20 @@ static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val) * At least one standard reset types should be supported by * the platform for SBI SRST extension to be usable. */ - for (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) { if (sbi_system_reset_supported(type, - SBI_SRST_RESET_REASON_NONE)) { - *out_val = 1; - return 0; - } + SBI_SRST_RESET_REASON_NONE)) + return true; } - *out_val = 0; - return 0; + return false; } struct sbi_ecall_extension ecall_srst; static int sbi_ecall_srst_register_extensions(void) { - unsigned long out_val; - - sbi_ecall_srst_probe(SBI_EXT_SRST, &out_val); - if (!out_val) + if (!srst_available()) return 0; return sbi_ecall_register_extension(&ecall_srst); @@ -86,6 +79,5 @@ struct sbi_ecall_extension ecall_srst = { .extid_start = SBI_EXT_SRST, .extid_end = SBI_EXT_SRST, .register_extensions = sbi_ecall_srst_register_extensions, - .probe = sbi_ecall_srst_probe, .handle = sbi_ecall_srst_handler, }; diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c index 716a6d585af7..2bfd99ae8720 100644 --- a/lib/sbi/sbi_ecall_susp.c +++ b/lib/sbi/sbi_ecall_susp.c @@ -23,7 +23,7 @@ static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid, return ret; } -static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val) +static bool susp_available(void) { u32 type; @@ -32,24 +32,18 @@ static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val) * platform for the SBI SUSP extension to be usable. */ for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) { - if (sbi_system_suspend_supported(type)) { - *out_val = 1; - return 0; - } + if (sbi_system_suspend_supported(type)) + return true; } - *out_val = 0; - return 0; + return false; } struct sbi_ecall_extension ecall_susp; static int sbi_ecall_susp_register_extensions(void) { - unsigned long out_val; - - sbi_ecall_susp_probe(SBI_EXT_SUSP, &out_val); - if (!out_val) + if (!susp_available()) return 0; return sbi_ecall_register_extension(&ecall_susp); @@ -59,6 +53,5 @@ struct sbi_ecall_extension ecall_susp = { .extid_start = SBI_EXT_SUSP, .extid_end = SBI_EXT_SUSP, .register_extensions = sbi_ecall_susp_register_extensions, - .probe = sbi_ecall_susp_probe, .handle = sbi_ecall_susp_handler, }; diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index c4a4c1c45b14..fc0d43ef7e13 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -22,16 +22,6 @@ static inline unsigned long sbi_ecall_vendor_id(void) (SBI_EXT_VENDOR_END - SBI_EXT_VENDOR_START)); } -static int sbi_ecall_vendor_probe(unsigned long extid, - unsigned long *out_val) -{ - if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr())) - *out_val = 0; - else - *out_val = 1; - return 0; -} - static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid, const struct sbi_trap_regs *regs, unsigned long *out_val, @@ -64,6 +54,5 @@ struct sbi_ecall_extension ecall_vendor = { .extid_start = SBI_EXT_VENDOR_START, .extid_end = SBI_EXT_VENDOR_END, .register_extensions = sbi_ecall_vendor_register_extensions, - .probe = sbi_ecall_vendor_probe, .handle = sbi_ecall_vendor_handler, }; From patchwork Mon May 15 09:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HlVlIYIf; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=PoWr+1Wg; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKZ3Z0Y0Jz20KF for ; Mon, 15 May 2023 19:35:22 +1000 (AEST) 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=f3vVeSl39Pb4qAXaKTnvGCDTZVLCnewo4Qt0t2Cz2lE=; b=HlVlIYIfGpdVv3 61qOmxlvwwREu+Fu7W4aLLdxT7LnpYudGyyKAhgqZMU9QoAl+CdzYqT4c3K9jUB8vTYU/SOHWUMzn rrnfc6WumJ7gB2ZHdj/p6eF1Zl2qh8JXRpUKtIAvMb95kWI8IB8yAtW0QSVrkMvamjPbJE/Q5Hnij 82lMu+7YYsjd+lyUiKsw7M0WKEGfWsBbTFwUCoeuCJNGWsnmawF7BHHRXTdK8bprPdCk9y7JQI5xY 7tLcrZ5UIGUTWxtlmsx+E2NBSAsC7YXJUan95Uey4voYDfFSS7A+hnZsA5fx5Y3RHpBnqs+9dloft e4X7Mz84xq/PAOYw6a/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbl-001ZRz-0G; Mon, 15 May 2023 09:35:09 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyUbi-001ZNi-1B for opensbi@lists.infradead.org; Mon, 15 May 2023 09:35:07 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f42c865534so66576275e9.2 for ; Mon, 15 May 2023 02:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684143304; x=1686735304; 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=RrK+YrsdqCq3LNDOBu2MGrZqeTgUFAQ8NoeSMey1shg=; b=PoWr+1WgnvEopA0lG+++HKY7Hy6G9RzO7tg8/d5OtNvEqEkNWmxRaxrlsbRLgha56g YnFKmJWHTNn0n95CQf3wBOKTPxmnJJqwDNtZ9EYcfDpyqutosalk1wHYA9RzxjhXXdGV cCi3Ystge4Ab0wqNMqCL3gc/laR4Rnqr73M73/FhbjQ3Rq05J6HrVgTnGdU7SkTaWhyI 4EGHb/oNTOcjPS9c4B6Xnn5Y0nbo8dDuD4tmNKaHdIu9vmNz6SkqMsAz8TlysyJ7NPH1 7gZC7lSAPBneCcMEm6KwC5omebbXkFlpYXYOfR/nF0/MMG1MWJ31EykwCpd3bOSDv9HU O0Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143304; x=1686735304; 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=RrK+YrsdqCq3LNDOBu2MGrZqeTgUFAQ8NoeSMey1shg=; b=iCxazhBfWUCgYO2uXmdZ4r9lwlr3DGWwIJ1YEZM/E/TUjX04KmNv2OBPrMT761OeVh FD62eK8U2nMLy1yySPMd079JCXFi7H2k7tlCv4LPfYWTusadC9SY2op2zRCUQXRoaUzk +TPHep2D2kF1WFWcm8Q/SDJ7F6kN+tIi8UyELAFb6x1lGQF4bg+rOS9vGeQFQEjM8HhM lSREFX5qs7QeY9G1nh0L86MNNTUUDY822x9FaJxh0nRvGzorxFF4nf6hKVsnsMIbzBW2 pmxgPUPKJ7qtdVyfAGBWz/B5uq0F2k9LLyMPQv5fWY9PKzkquKvsX4Bjy7BrtoF2rTSh uHzg== X-Gm-Message-State: AC+VfDx5N7XL78FbwKzym28UjpFH3XsdGVQzqfUYGKE9ec3Y/v5Qdv7b AZCbvHgDsiNo4uvxX5eiPAZiLZSWoobjZd+b9OY= X-Google-Smtp-Source: ACHHUZ4tnqqIm6sg+hz3yWiE34h0yW4NgJVP5S9kQuzIEf2FMJ+Z76Ct9yViZT4mpkroV4DBJm6wpw== X-Received: by 2002:a05:600c:2119:b0:3f5:811:5b20 with SMTP id u25-20020a05600c211900b003f508115b20mr3333236wml.25.1684143304111; Mon, 15 May 2023 02:35:04 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id x14-20020adfec0e000000b002ca864b807csm32190676wrn.0.2023.05.15.02.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:35:03 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v5 7/7] lib: sbi: Document sbi_ecall_extension members Date: Mon, 15 May 2023 11:34:46 +0200 Message-Id: <20230515093446.73123-8-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515093446.73123-1-ajones@ventanamicro.com> References: <20230515093446.73123-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_023506_410619_812182B4 X-CRM114-Status: GOOD ( 13.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: With the introduction of the register_extensions callback the range members (extid_start and extid_end) may now change and it has become a bit subtle as to when a probe function should be implemented. [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:331 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org With the introduction of the register_extensions callback the range members (extid_start and extid_end) may now change and it has become a bit subtle as to when a probe function should be implemented. Document all the members and their relationship to the register_extensions callback. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- include/sbi/sbi_ecall.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/sbi/sbi_ecall.h b/include/sbi/sbi_ecall.h index fac26429cf5d..3cb25ae80fb0 100644 --- a/include/sbi/sbi_ecall.h +++ b/include/sbi/sbi_ecall.h @@ -21,11 +21,46 @@ struct sbi_trap_regs; struct sbi_trap_info; struct sbi_ecall_extension { + /* head is used by the extension list */ struct sbi_dlist head; + /* + * extid_start and extid_end specify the range for this extension. + * As the initial range may be wider than the valid runtime range, + * the register_extensions callback is responsible for narrowing + * the range before other callbacks may be invoked. + */ unsigned long extid_start; unsigned long extid_end; + /* + * register_extensions + * + * Calls sbi_ecall_register_extension() one or more times to + * register extension ID range(s) which should be handled by this + * extension. More than one sbi_ecall_extension struct and + * sbi_ecall_register_extension() call is necessary when the supported + * extension ID ranges have gaps. Additionally, extension availability + * must be checked before registering, which means, when this callback + * returns, only valid extension IDs from the initial range, which are + * also available, have been registered. + */ int (* register_extensions)(void); + /* + * probe + * + * Implements the Base extension's probe function for the extension. As + * the register_extensions callback ensures that no other extension + * callbacks will be invoked when the extension is not available, then + * probe can never fail. However, an extension may choose to set out_val + * to a nonzero value other than one. In those cases, it should implement + * this callback. + */ int (* probe)(unsigned long extid, unsigned long *out_val); + /* + * handle + * + * This is the extension handler. register_extensions ensures it is + * never invoked with an invalid or unavailable extension ID. + */ int (* handle)(unsigned long extid, unsigned long funcid, const struct sbi_trap_regs *regs, unsigned long *out_val,