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