Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1230350lqo; Thu, 9 May 2024 08:09:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3bn54VcB5eMbiuTVTK1LhCF/1LNiM9O9OusVxNNyDU88wH3sbVSMmVvGKT36BDXea51JNUHwYsYkzsWsu6nB6V53x/vLGspZLyyf7rQ== X-Google-Smtp-Source: AGHT+IH3SUcVLxamDYzAh3YpWV1vI3n+RvKUdQ7SJzytp7LzUCZ3lVMUvDFHeyqkTVE/JB8yYO+a X-Received: by 2002:a17:907:b9d0:b0:a59:dd9d:6da5 with SMTP id a640c23a62f3a-a59fb819a96mr361837666b.3.1715267354315; Thu, 09 May 2024 08:09:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715267354; cv=pass; d=google.com; s=arc-20160816; b=gSph7+AP1TBy/bqEYFez4bGVV9Z80yKXh/Wx44XEu+xsfXVYGz8bBQH8LwxRr8JjJg qWJdXBhJSBX2eoaW3cdqwnRP7wyTq1wOvH5g2iSZMgRsBNnnRYxaKb9YQLvHwZcVn7o/ uZaiRKhBVt9mH9ZTcvU5xRFqybQaRfUoWYriDGOWmOYL+u4XXcnt2qLxdUZXk/SfFByE zKror2wobHq3N3kyWaO41WTrzE1JuOEF9leaKTJubrbaeVyBws/pM9lLpStdrECB52BV ddGxSHl5TDpJ1DKwwxB273dTKHzHu+uHA0NmKmA8iM02firV0VrYWqlboIWctVPWJ1yS oUow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=3IEk3u1PS0Rm3jW1ELuHixYJSPDm2DEcM2oyGOizm24=; fh=8U5LYZ/epJ82kN9I3BJ+q5wf+M65k42S/62ifyo6WoA=; b=kwTLdmMBUW39pty8qQPr3p45A4EDDAj/dMe88Ys3FRYIXbL7mWRGkO64U4qm0VH+sU tebXCyPcI75ej5wDq4SiH1ycJvF9oRtbAmZFOr1HUGKbVN4GrRS6Eqtlm/ZmPg7hwyLi tXb5mVnucIfNy9fGugLjrWk1bnuJh0zmZQEycTGuDA2EG260jcWx2N51EW+ZfmI8A10a qprnwbRifMQH9Wx34B8odogPAJh/QstrhYYarCqPANwuJRBZtO6HUxz9fTXi0WrQ4R83 ozxvPlsr/wBlvxlIPwBNqwVmNbrUH8M9ACuBNHF+gpJWx2zezOXtuWYruAahdoDCVKYC ePlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174617-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a1797b9c3si91095166b.222.2024.05.09.08.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 08:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-174617-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174617-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E7271F21FEC for ; Thu, 9 May 2024 15:09:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E656915E5B1; Thu, 9 May 2024 15:09:06 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A4252BCE3; Thu, 9 May 2024 15:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715267346; cv=none; b=d4oTUf7JvaTeZCfPfuKBpvU0ONEEi57iHxDAbfnc+tK0HuTxoyb9kNKa1P9NHUZzulaEMnRRnG97Wy6gKX3Wr7Fx0ZHWUachqPRohHEAWmdXkb236xQ2qLyRx2C5FOVuCk4zcpkQOmXCmTqYZTCoWunYwU4Nmm1LMa8ftPdBp6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715267346; c=relaxed/simple; bh=XxiTctms0UHhDzc55pGt0O8Wzfmfftzf1auL80To9Ww=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=P2/Go54JA2OWaOP7d033jJbrPrnntYFrrkeTtt+ymqpmpDU5KAFCqPESNHds0cGnhSYT0jRay3K4woK/7d//3yX825agj8uUBR6X/Y6xe9dW9suM//qO5f/PwzFXghZ1C1mgsjZwyW9A8OaPCEL5dkgaxIJLdMz3MZyn9ZP6XYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34D59106F; Thu, 9 May 2024 08:09:29 -0700 (PDT) Received: from [172.27.42.162] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 979AB3F641; Thu, 9 May 2024 08:09:02 -0700 (PDT) Message-ID: <571d0194-dd3e-4a68-8879-d6b66276afe5@arm.com> Date: Thu, 9 May 2024 10:09:01 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/3] riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT Content-Language: en-US To: Yunhui Cui , rafael@kernel.org, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, sunilvl@ventanamicro.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, bhelgaas@google.com, james.morse@arm.com, jhugo@codeaurora.org, john.garry@huawei.com, Jonathan.Cameron@huawei.com, pierre.gondois@arm.com, sudeep.holla@arm.com, tiantao6@huawei.com Cc: Conor Dooley References: <20240509073300.4968-1-cuiyunhui@bytedance.com> <20240509073300.4968-2-cuiyunhui@bytedance.com> From: Jeremy Linton In-Reply-To: <20240509073300.4968-2-cuiyunhui@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 5/9/24 02:32, Yunhui Cui wrote: > Before cacheinfo can be built correctly, we need to initialize level > and type. Since RISC-V currently does not have a register group that > describes cache-related attributes like ARM64, we cannot obtain them > directly, so now we obtain cache leaves from the ACPI PPTT table > (acpi_get_cache_info()) and set the cache type through split_levels. > > Suggested-by: Jeremy Linton > Suggested-by: Sudeep Holla > Reviewed-by: Conor Dooley > Reviewed-by: Sunil V L > Signed-off-by: Yunhui Cui > --- > arch/riscv/kernel/cacheinfo.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c > index 30a6878287ad..d6c108c50cba 100644 > --- a/arch/riscv/kernel/cacheinfo.c > +++ b/arch/riscv/kernel/cacheinfo.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2017 SiFive > */ > > +#include > #include > #include > #include > @@ -78,6 +79,27 @@ int populate_cache_leaves(unsigned int cpu) > struct device_node *prev = NULL; > int levels = 1, level = 1; > > + if (!acpi_disabled) { > + int ret, fw_levels, split_levels; > + > + ret = acpi_get_cache_info(cpu, &fw_levels, &split_levels); > + if (ret) > + return ret; > + > + BUG_ON((split_levels > fw_levels) || > + (split_levels + fw_levels > this_cpu_ci->num_leaves)); > + > + for (; level <= this_cpu_ci->num_levels; level++) { > + if (level <= split_levels) { > + ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level); > + ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level); > + } else { > + ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level); > + } > + } > + return 0; > + } > + > if (of_property_read_bool(np, "cache-size")) > ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level); > if (of_property_read_bool(np, "i-cache-size")) Yes, still looks good. Reviewed-by: Jeremy Linton Thanks,