From patchwork Mon Mar 18 14:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1913148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=0d5MVlvb; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=GgE7HAwc; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TyySF1LbWz23sG for ; Tue, 19 Mar 2024 01:49:49 +1100 (AEDT) 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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LJKcRkbiPB3akt00cldjVsOIWgOrsJYnwtiCRvmvNss=; b=0d5MVlvbm43LIf Kkkx+lWcKoDGhu9gtumvJRgO6MhCta/ery6ri3IJteyqNrC0lgE0BLYwyhj+pb9cOCPVXOksNlKNm eCC7vEtw2m5hfCnUNbKHTRg8ZORJRccwpHWsL2Lq0V/PygRF8bwBbW0+SVfiQb/U8Iv9hHDNRYfFm VVHdHQdeNH2zC+C1VkfJ6A0APtrWY6fNe8mkg6qU5AwY5W1k1dLWoWwG9hXY9UC+2pxvrPPgdUSBC rBOXycnJ45nJcqWwxiGH7j9m5IDjT8kMugGRNP3hdPKotqSkCwIfc8pVaFU88SQyI5gb3ZLiGxHdP zVgyWSlJFZllNaoB+iMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmEJ2-00000008rmK-3bVz; Mon, 18 Mar 2024 14:49:40 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmEJ0-00000008rl6-1g1y for opensbi@lists.infradead.org; Mon, 18 Mar 2024 14:49:39 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e00d1e13acso6598375ad.0 for ; Mon, 18 Mar 2024 07:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1710773376; x=1711378176; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h9OfN1tyBS4KPcZ8n5Uxw48lKlNVkCiVgtdkSdWt4rI=; b=GgE7HAwckMEgEoj5N5rqRhfL/5BLNwV0xhFCSJ1tl+d2/+EsXkYk2mEepstLjiqxlG Bl2RlV4M2AWG+mcYBpoaCahqPWxy4c38o4MwTLUONMfC8eDK+Vw9U2E0LOiV4wCbaVom n+nqUklJPOsHavDqcSRt57euGZF8Ad/sz69Sh3FrqAQHanZwdbLnYKEYVBNLXst2SnNc eF+b6RUv/rJiG8FsAz7ZIzQKkgObJahWKxEruytYLqnJzbMmERmpZNukdpDyDeuPFICk PvmlNva+9a3ONpPeQaon+9WNVDhJP+mKz2HYRCAegfzbwos6ksImoCIzxd6uuGEnL09F IUlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710773376; x=1711378176; 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=h9OfN1tyBS4KPcZ8n5Uxw48lKlNVkCiVgtdkSdWt4rI=; b=DR/AlhOtAz03SZ5w5SNW4dMN4Bq0Vryh6H73uMoXWVDbUBn61NrIr+9RQq6wkCTvIp GG9HlnZHg3yobkSnNJCsftnGB5sqyHkUfGmo2vRWgF6lBsATw6Ql2xMeNQYl2P6Xll/A 1lSvZIPG7Oy+ulfF2a/2Q8GmKdh1SB1802tUb9PgE3MvQuah2sYBv5Q0d0IKXU5hWKHo 9LM5k58DCSrqz/O54HysqOEIMvxju7pfp2QyzpSY8HvDIEP7bxksOD7sfBa/bT6/dO+X FL3veCFjiFmtBj90A4vpOmnKHENvR9lR4iAttT4EbQ/ak2gTGK466hPMWelBRBaP9m5k gvRg== X-Gm-Message-State: AOJu0YwKCzs4O0Qc3o31U0t7kd9Bj9t7sHk3eHsHffu6AvhykI3yFfbf Sid0fpIJYgjqYEHaKpNTwdvwUVjsNHKodbggmDqIq3L8ST8WJD8XjBvoOrfpjqeP2+2adEZ1XLD PTEB7qPVbl8es4wW0ErQ9s64kiXcKmHbMq+6bticsLPLUiGUT3bzbTUWvUItSlfsPCgzNLcmA+e ID8cDYuq5FCy3CQeA4CgoWWJMUOaIQiMTlMi2NHcCUq4HTYPBmhaY= X-Google-Smtp-Source: AGHT+IF1QX8W1+IRGfNUk2HtHony7cHJbOIc1oZdgAuLI/r+Ip97+LgFCEKDpXgxBPgatz4cPxKLfQ== X-Received: by 2002:a17:903:24e:b0:1dd:b728:b890 with SMTP id j14-20020a170903024e00b001ddb728b890mr15440747plh.18.1710773375828; Mon, 18 Mar 2024 07:49:35 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d9-20020a170902654900b001dd0d0d26a4sm9567170pln.147.2024.03.18.07.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 07:49:35 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 1/2] lib: utils/timer: Optimize current hart scratch access Date: Mon, 18 Mar 2024 07:49:28 -0700 Message-ID: <20240318144932.4165729-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240318144932.4165729-1-samuel.holland@sifive.com> References: <20240318144932.4165729-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240318_074938_464198_3E362FB3 X-CRM114-Status: GOOD ( 10.75 ) 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 address of the local scratch area is stored in each hart's mscratch CSR. It is more efficient to read the CSR than to compute the address from the hart ID. Signed-off-by: Samuel Holland --- Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62c listed in] [list.dnswl.org] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 address of the local scratch area is stored in each hart's mscratch CSR. It is more efficient to read the CSR than to compute the address from the hart ID. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- lib/utils/timer/aclint_mtimer.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index 271e6252..9acb26eb 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -72,14 +72,10 @@ static u64 mtimer_value(void) static void mtimer_event_stop(void) { u32 target_hart = current_hartid(); - struct sbi_scratch *scratch; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct aclint_mtimer_data *mt; u64 *time_cmp; - scratch = sbi_hartid_to_scratch(target_hart); - if (!scratch) - return; - mt = mtimer_get_hart_data_ptr(scratch); if (!mt) return; @@ -92,14 +88,10 @@ static void mtimer_event_stop(void) static void mtimer_event_start(u64 next_event) { u32 target_hart = current_hartid(); - struct sbi_scratch *scratch; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct aclint_mtimer_data *mt; u64 *time_cmp; - scratch = sbi_hartid_to_scratch(target_hart); - if (!scratch) - return; - mt = mtimer_get_hart_data_ptr(scratch); if (!mt) return; @@ -155,13 +147,9 @@ int aclint_mtimer_warm_init(void) { u64 *mt_time_cmp; u32 target_hart = current_hartid(); - struct sbi_scratch *scratch; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct aclint_mtimer_data *mt; - scratch = sbi_hartid_to_scratch(target_hart); - if (!scratch) - return SBI_ENOENT; - mt = mtimer_get_hart_data_ptr(scratch); if (!mt) return SBI_ENODEV;