From patchwork Mon May 15 11:12:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1781323 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=F7iAnEpc; 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=pKSIU8Fu; 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 4QKcDQ1Sg4z20dj for ; Mon, 15 May 2023 21:13:10 +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=Q8wySFs2Vy8JWQnDJbG6hPAupmsl2x8aw0/hO0+gzgA=; b=F7iAnEpcnfC4Wu 3YjVvI9dT2pjqE9cZGD0NlFlGgC0JH+tuIpN/UnIo22n0h5PPDDUFffVQHjhkBOlJ1OBAH5V6xPvb 3YvPKT2thjbfbAt2TuRI2cIegD6TjINbCBoBdzbSkKh9HLYGbX0EC5Dhz5CX9/kDW0SCDwRGVA3/I +pusctM8Sx9QvIaUWdAxZXhozcdc2Yno8vkDS51/C5JHKEWlmQHft8u47kvzi9E7nKt1JshIBXlg8 fi0L3E5EPslunmfp01IGqJGGdmfdoXzkHYzabz2hLl/2rSPn7hB6/5+JW0r2jMnnW6ZRF3wA/B85W s1q3RbCUmb2fmyb4PBYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyW8M-001wPK-0y; Mon, 15 May 2023 11:12:54 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyW8J-001wMz-1F for opensbi@lists.infradead.org; Mon, 15 May 2023 11:12:52 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f42b984405so46388715e9.3 for ; Mon, 15 May 2023 04:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1684149170; x=1686741170; 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=xpLCnRmjN3qBWaUv4w2q6dOim2Q6W2T3ezSffyAoY5Y=; b=pKSIU8FuE9exGmUixPNPo/AnpwjST8O76cL8xSfcvQFv99T9tjTZebylwKd+Y0Rm5Y 2zuoNspwK4p+Ige3Yj/0+sglkWdscNCJ6TeLWzT7Cjubu5PwsQk2bEB/6k7ZelP35myr 0lu6TWb3wYUtb+P6vJr+JYiYOD0pFSJniaqLJI9aew5PFJgzZMcG+r88syTvzmdyTDgb bvMvdHkOcWFtYvpKJku/tyzkMUFjg9oyd3r11PIHQj3jrtXQ5Ekv8VfkiYkf0soDkOOI qiEKkEFl/PI5+YVtwa84BHT4lZLvmrfLEIPuIL2eX9GCu74yTRfCQi6aoPf10QAaloJF 6yKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684149170; x=1686741170; 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=xpLCnRmjN3qBWaUv4w2q6dOim2Q6W2T3ezSffyAoY5Y=; b=bUGWbG8whS61FI9p1Vpdl0U5xhZxPTabp4fS+IoCCRSjwKb2AsEraWQZaEbJIJyqBi 06Su/TAqFIG+XjuhXbvyGYdRwEvCKTn1BVIdU2fjqH0IXRDzs60zFRtWFQjYwJcEuXf7 3vbdBvG0Yt+L8KweviJtsKQphzqotGaxSG9Rv87KsLIKe2m4maWyYgoU6Hz/WWr3EtVR O76tKo2WQ3oxhLMyQwrKnbRARQUKrl/NDh7f4c3CzPZApz6om+qfook+ZoaWW5OREY/6 fNAmvWtNzdXtqbvGCaKFp1iLvWAIR5EV9NNcnDRx0AbwNmkXYOjp/FRnQkA8P7xMW83J MDMQ== X-Gm-Message-State: AC+VfDyowV1kzJeGvJ95HQ0jmsmnuFGvn9QoZ6YXDdwTieA8sIbvcNy9 32L6nhy+lHO1HcZmut8vudYKkVS++IK/gqWKGO0= X-Google-Smtp-Source: ACHHUZ78dRluJZWka0WuQCE61uTYLUcPvhSmxIG/Yu6JGNIPxDHzsh/4aM7yl8wCUkuKLOTagEWdNA== X-Received: by 2002:a7b:cb91:0:b0:3f4:e70c:219f with SMTP id m17-20020a7bcb91000000b003f4e70c219fmr9567942wmi.6.1684149169935; Mon, 15 May 2023 04:12:49 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm36655240wmk.35.2023.05.15.04.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 04:12:49 -0700 (PDT) From: Andrew Jones To: opensbi@lists.infradead.org Cc: Xiang W , Anup Patel Subject: [PATCH v6 5/7] lib: sbi: Optimize probe of srst/susp Date: Mon, 15 May 2023 13:12:38 +0200 Message-Id: <20230515111240.95059-6-ajones@ventanamicro.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230515111240.95059-1-ajones@ventanamicro.com> References: <20230515111240.95059-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_041251_419932_8056EE3D 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 Reviewed-by: Anup Patel --- lib/sbi/sbi_ecall_srst.c | 10 ++++++---- lib/sbi/sbi_eca [...] 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:333 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; }