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, };