From patchwork Mon Sep 4 04:03:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1829299 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=kCj1cYy2; 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=oC4I+ea4; 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 4RfFQD223gz26jR for ; Mon, 4 Sep 2023 14:04:36 +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=1BVqj8M1wahRcqBC2G4FJXjT8/cHFNcOdHwNjje2AJw=; b=kCj1cYy2Q8hdmZ 5e1pSWlopF/UXTDP9U6+j7fqkZ1TzIzVsZl55UZaj+hWkoRpuLGzQAD0nlxzCfi2zz6nGJtUAmMY5 srajmvvwAMB4sc0YQcy7oVbV4JBIWcrvwXXcUY84ieJCwH4ukeKiCXK2hlGVyWV6pbc6ugBNQwZ6E 8oaTuH/0rC3Ki6BAfD9SmiWBVNAd29/qnTJd0Lh70zj6Tjsy6KE/aKgIYtD6qBEZte/XWPvQt6Cl2 h3L9wrXpp3riVQuhKiH2+aSe2jybU7isfPsv+LYHSh77NURGBIRLzde+CWeGLWph4UwT55E6RZ9XL TIn1OcrPXxYnjhvAdhuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qd0p1-003E0p-13; Mon, 04 Sep 2023 04:04:19 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qd0oy-003Dx6-24 for opensbi@lists.infradead.org; Mon, 04 Sep 2023 04:04:18 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5650ef42f6dso292029a12.0 for ; Sun, 03 Sep 2023 21:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693800253; x=1694405053; 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=vjDcbBwDS0oYq4YiH/Q8ed+WoT+xX709FBiVGNgc05I=; b=oC4I+ea4cNtM3OlxSk//y9PUlhYq0ZUvEry6FqNttaOH6PISvLevw96GO4VCH4T/VW 8/uzSU/Vc61LDFk6PpNNToAmfsu8VrNJpOharjPP1y30HZ8n0K5m0Dj7gk2G6fmRY2nj CiNTfa75gwkne5L1gXWED7/0ZjrUtx59P+2Bq54OmP6MEFeEDKBzdN/49+w7EfMy2wIT zzZpoKiXjdGqiKYygQrkiJMrcmQ4n+G7Gp1MUadYz5k+PnyLu3a5WlNhCIK/8uZm12T5 S5r5tD5ukjBfF5nuOyZ/l2vgUWp2dFEWAsKZy12cwk7FfDQzBVU54NLMYF/1qKMes8ME RREw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693800253; x=1694405053; 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=vjDcbBwDS0oYq4YiH/Q8ed+WoT+xX709FBiVGNgc05I=; b=WCNH12mrOsstVe7BrLzwCFPWHBWwtbsCRaU2rJHoiwX2KF2NJ3l0EVdqXyriAJLavk B/MtwdJtCnL05Uq/1/y9mhSnY3w+380OXgyonvdlo24qXgbxCl5HCH/wt5HWPEBQQFjE 57jClm40R9bePu0WTuroTu4XuYzHoIxgB1mofg6CKFG9tzRkOhkc8CNIrz82qPsl0qEu xm7G1IZqnlZZ7o0fwdYNimBr/WVJptgZ+naH8ku7dOS14zsNMw3R4SSZHNbuDDqavvle 6/jskUP8OVPvM9xaZy1Pg+jw0Jb4MhX3bqhdMvI9OkEoE4VQGCXZsAi82SLmkEHBmeDt fIyg== X-Gm-Message-State: AOJu0YxVXnr+WZv2K3zPlyouL2SFEj0urK+bK/VJhFAHY3yCdu3PtbMr LXzuAblAnoJTDq4crtXOuOIdCQ== X-Google-Smtp-Source: AGHT+IFOedqP8VEUuiEUOClMlDSNnJdbiQVGEvn1Jzip9CSfWGh/7xwe8wfdHFCy7ct/Y23KPLTIdg== X-Received: by 2002:a05:6a21:3e01:b0:147:5ab9:8496 with SMTP id bk1-20020a056a213e0100b001475ab98496mr6621993pzc.55.1693800252845; Sun, 03 Sep 2023 21:04:12 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.80.37]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b9dadf8bd2sm6561224plb.190.2023.09.03.21.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Sep 2023 21:04:12 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH 7/8] lib: sbi: Maximize the use of HART index in sbi_domain Date: Mon, 4 Sep 2023 09:33:45 +0530 Message-Id: <20230904040346.118604-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230904040346.118604-1-apatel@ventanamicro.com> References: <20230904040346.118604-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230903_210416_682589_10BAB792 X-CRM114-Status: GOOD ( 17.64 ) 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: Let us maximize the use of HART index in sbi_domain because hartindex based hartmask access and sbi_scratch lookup is faster. Signed-off-by: Anup Patel --- include/sbi/sbi_domain.h | 6 ++--- lib/sbi/sbi_domain.c | 56 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 29 dele [...] 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 [2607:f8b0:4864:20:0:0:0:532 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 Let us maximize the use of HART index in sbi_domain because hartindex based hartmask access and sbi_scratch lookup is faster. Signed-off-by: Anup Patel --- include/sbi/sbi_domain.h | 6 ++--- lib/sbi/sbi_domain.c | 56 +++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index da2a65a..e10daff 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -201,12 +201,12 @@ struct sbi_domain { /** The root domain instance */ extern struct sbi_domain root; -/** Get pointer to sbi_domain from HART id */ -struct sbi_domain *sbi_hartid_to_domain(u32 hartid); +/** Get pointer to sbi_domain from HART index */ +struct sbi_domain *sbi_hartindex_to_domain(u32 hartindex); /** Get pointer to sbi_domain for current HART */ #define sbi_domain_thishart_ptr() \ - sbi_hartid_to_domain(current_hartid()) + sbi_hartindex_to_domain(sbi_hartid_to_hartindex(current_hartid())) /** Index to domain table */ extern struct sbi_domain *domidx_to_domain_table[]; diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index ee3a5e9..b1f485d 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -40,22 +40,22 @@ struct sbi_domain root = { static unsigned long domain_hart_ptr_offset; -struct sbi_domain *sbi_hartid_to_domain(u32 hartid) +struct sbi_domain *sbi_hartindex_to_domain(u32 hartindex) { struct sbi_scratch *scratch; - scratch = sbi_hartid_to_scratch(hartid); + scratch = sbi_hartindex_to_scratch(hartindex); if (!scratch || !domain_hart_ptr_offset) return NULL; return sbi_scratch_read_type(scratch, void *, domain_hart_ptr_offset); } -static void update_hartid_to_domain(u32 hartid, struct sbi_domain *dom) +static void update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom) { struct sbi_scratch *scratch; - scratch = sbi_hartid_to_scratch(hartid); + scratch = sbi_hartindex_to_scratch(hartindex); if (!scratch) return; @@ -268,10 +268,11 @@ static int sanitize_domain(const struct sbi_platform *plat, __func__, dom->name); return SBI_EINVAL; } - sbi_hartmask_for_each_hart(i, j, dom->possible_harts) { - if (!sbi_hartid_valid(i)) { + sbi_hartmask_for_each_hartindex(i, dom->possible_harts) { + if (!sbi_hartindex_valid(i)) { sbi_printf("%s: %s possible HART mask has invalid " - "hart %d\n", __func__, dom->name, i); + "hart %d\n", __func__, + dom->name, sbi_hartindex_to_hartid(i)); return SBI_EINVAL; } } @@ -404,9 +405,11 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) k = 0; sbi_printf("Domain%d HARTs %s: ", dom->index, suffix); - sbi_hartmask_for_each_hart(i, j, dom->possible_harts) + sbi_hartmask_for_each_hartindex(i, dom->possible_harts) { + j = sbi_hartindex_to_hartid(i); sbi_printf("%s%d%s", (k++) ? "," : "", - i, sbi_domain_is_assigned_hart(dom, i) ? "*" : ""); + j, sbi_domain_is_assigned_hart(dom, j) ? "*" : ""); + } sbi_printf("\n"); i = 0; @@ -487,7 +490,7 @@ void sbi_domain_dump_all(const char *suffix) int sbi_domain_register(struct sbi_domain *dom, const struct sbi_hartmask *assign_mask) { - u32 i, j; + u32 i; int rc; struct sbi_domain *tdom; u32 cold_hartid = current_hartid(); @@ -530,22 +533,22 @@ int sbi_domain_register(struct sbi_domain *dom, sbi_hartmask_clear_all(&dom->assigned_harts); /* Assign domain to HART if HART is a possible HART */ - sbi_hartmask_for_each_hart(i, j, assign_mask) { - if (!sbi_hartmask_test_hartid(i, dom->possible_harts)) + sbi_hartmask_for_each_hartindex(i, assign_mask) { + if (!sbi_hartmask_test_hartindex(i, dom->possible_harts)) continue; - tdom = sbi_hartid_to_domain(i); + tdom = sbi_hartindex_to_domain(i); if (tdom) - sbi_hartmask_clear_hartid(i, + sbi_hartmask_clear_hartindex(i, &tdom->assigned_harts); - update_hartid_to_domain(i, dom); - sbi_hartmask_set_hartid(i, &dom->assigned_harts); + update_hartindex_to_domain(i, dom); + sbi_hartmask_set_hartindex(i, &dom->assigned_harts); /* * If cold boot HART is assigned to this domain then * override boot HART of this domain. */ - if (i == cold_hartid && + if (sbi_hartindex_to_hartid(i) == cold_hartid && dom->boot_hartid != cold_hartid) { sbi_printf("Domain%d Boot HARTID forced to" " %d\n", dom->index, cold_hartid); @@ -665,36 +668,37 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) /* Startup boot HART of domains */ sbi_domain_for_each(i, dom) { - /* Domain boot HART */ - dhart = dom->boot_hartid; + /* Domain boot HART index */ + dhart = sbi_hartid_to_hartindex(dom->boot_hartid); /* Ignore of boot HART is off limits */ - if (SBI_HARTMASK_MAX_BITS <= dhart) + if (!sbi_hartindex_valid(dhart)) continue; /* Ignore if boot HART not possible for this domain */ - if (!sbi_hartmask_test_hartid(dhart, dom->possible_harts)) + if (!sbi_hartmask_test_hartindex(dhart, dom->possible_harts)) continue; /* Ignore if boot HART assigned different domain */ - if (sbi_hartid_to_domain(dhart) != dom || - !sbi_hartmask_test_hartid(dhart, &dom->assigned_harts)) + if (sbi_hartindex_to_domain(dhart) != dom || + !sbi_hartmask_test_hartindex(dhart, &dom->assigned_harts)) continue; /* Startup boot HART of domain */ - if (dhart == cold_hartid) { + if (dom->boot_hartid == cold_hartid) { scratch->next_addr = dom->next_addr; scratch->next_mode = dom->next_mode; scratch->next_arg1 = dom->next_arg1; } else { - rc = sbi_hsm_hart_start(scratch, NULL, dhart, + rc = sbi_hsm_hart_start(scratch, NULL, + dom->boot_hartid, dom->next_addr, dom->next_mode, dom->next_arg1); if (rc) { sbi_printf("%s: failed to start boot HART %d" " for %s (error %d)\n", __func__, - dhart, dom->name, rc); + dom->boot_hartid, dom->name, rc); return rc; } }