Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp918813lqp; Thu, 23 May 2024 04:14:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw70v5QKHGMZdQ27nzzi23MqnsBpAfxbQK9ddCoSRQGyavqeQBIxAf4STxhE1QXM2ZJNX73oUNdIXJLqO7t8Nwdu4OYofpBopilsp8qA== X-Google-Smtp-Source: AGHT+IEcyVe0yWaCXeRU8LT8SfKxgPpAluc3PPd3m6zZ88Y39AGi4tI0QEL+cz7dJEPzefTR/Zvi X-Received: by 2002:a05:6a00:a0a:b0:6f4:7113:5d0a with SMTP id d2e1a72fcca58-6f7727bdd7bmr3362815b3a.11.1716462862905; Thu, 23 May 2024 04:14:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716462862; cv=pass; d=google.com; s=arc-20160816; b=ydYVxJPRXE3+mrhhj0F48l+G+Tg36bHuYsCQo/6s/1A3x9Iaa5ukS4tPbCq3+3FNP3 bTtj2Lt4mdFWAtVnMtDHwJZjzCgX85zCSTvHECsqAUURhLe0uqD2ZUdmi1dJBNIKAFDT jsKqya9RTrGxi7buDLUzq4VsJdOekinDIVQ3isD2gYV4egyLUXcSIh2p3rp+o14SnsSS mjQ04gqRjePt5UOdG+OT/6eaYQsLfnBw3bs3JWwrVoiaytqOV4pQ8HY/gnJIg8RmDVpq gDshM1FBH0IvDdJXUIg3TDR/sywhTcKL4hZ1ZJGM4aBxfeWRTX7l0cBwIN4wwxiSIGj9 gjAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/f2nZESk5IwUhjcBCwDQD5m6WSIwM88cL3SwI9ltT4Q=; fh=NJ8wn0ZfyP288qkhTMAQamWs9XzAl4E7vYpoXy/o9/8=; b=VCHd1zebd+jBgtzsoM6QQwYkljqt/B6tA/cVvZ9ygOjeChC3u8RnVm6F63lKgGIQGG O18uHynkybrOVgHv2filc6XU9tvmZPVNr4NwmxhahRPYvc3nCYvm0mJqJOoiviClNoPW kz9Mu6S6bALqcxbuE+QR25WS9CjAx6jjLJTSPOehWLrkghS2DCP60iqmolSY01PO0+lD 4RZFNYsp6c5bC6812qeP5cFnXqad5B3DyhOG7ms/HClsdigMnieHeS+/6UaUUjJMVAlD AVs+ILN5IstA9VB0krKrlAu0NSCDG7Jg1zbY1DFf8jJLZSOAd7nQHmvazjvjr11yAZvI Nbow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=eUNW5cfh; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-187383-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6597233fc6asi4429070a12.804.2024.05.23.04.14.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 04:14:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187383-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=eUNW5cfh; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-187383-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 26731281E6A for ; Thu, 23 May 2024 11:14:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABA1E146D66; Thu, 23 May 2024 11:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="eUNW5cfh" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CA72146D56 for ; Thu, 23 May 2024 11:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716462832; cv=none; b=BgIeEl4JkgQtc1MB1tzDlt7UkLXfekJKLJYuDnIEIjGGiuPVImACvNbZlJDhfw0g6Z5vwrr8K/PP/4PaP9miTs0z5aiNGK2Gmprp7k/SjEaTrtmdA8TDLywiugzydxfLa/REDBoRgl1RjHFRtIVT67g9vEGu8teB/oyh/kZS9XU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716462832; c=relaxed/simple; bh=+JzJj8ucCazBC6mptHHx0+nGx8xyX4nB++98g/I1ZdM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OAzLMumPkriiAevlUQ+sHYrNP/ldPAXawb0aNbr/+4Fyx4QmjI2OkRGMsM3yb5xoayyor066RD3FuUFhLjMW47+PfuS430QUSBwpW6X4iCgAWhHcWETOxDv/iMEnamGlW7xVDd7wdi2Tc3G7yM8F1STxG+2wZtORTfnrmO1CGjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=eUNW5cfh; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1f3421564d2so3142375ad.1 for ; Thu, 23 May 2024 04:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1716462829; x=1717067629; darn=vger.kernel.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=/f2nZESk5IwUhjcBCwDQD5m6WSIwM88cL3SwI9ltT4Q=; b=eUNW5cfheZqC47sMn4VqXjVInthPc9hTs9fDH0DkY5YD4ETMq7jwZHw5sDLdOawNIF /9KIWy1vFY659hnNF35q+n4ySWfdWhsPag3p2Ef3doH8PRsgcrIo5zFoj2taH+HbRud9 /4c8cF7h8eJVWqs01Or0RKtol7PT0IJ1KuS9YYrT4FWIuXZeTtpqTEgXpJYPEoAA+E5m ulYPwHcihSraBFkQj95DtRL6Amh3PqgqMxbCPbobxURdoqvK2yYMtrKIgDwy1jkEZtat R9NZDH94eDjkJlXOTdzLBob/FYb0KuBM96ZZigNUlcogU1EBTjJMwHZWee8HjT4cgA3G tpPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716462829; x=1717067629; 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=/f2nZESk5IwUhjcBCwDQD5m6WSIwM88cL3SwI9ltT4Q=; b=wDwQKfqdZgi71FoeUnuf5MG+OFwlCByyLGcfL/3uYu5aOnn5cPIf770O+h+AXRgkyy nHjlmvcH0KSx0uCvw0vNfL5IcJmpR/OaS7CiPOep5bJWv+E+XPMeKB+Hy21P63+DnXui 7d36yaBS1lLu6dnoFCDM3YyivNuvu9KN0hIDnq/6fUSQgvFyGevCcIqgOpA76yuFc6LX og9eMnR27XN166yrrynrch8xtDXF9s5PN83AGqZFNSaOYOU30CHBhITqilIUQBoYG5Wt jiwVpvXTtlzMUfDuWAY1bSaruh9pXT9/qvfWdHLidKlr9w30bLO9agwBLcHGWfXvyy/L /hhw== X-Forwarded-Encrypted: i=1; AJvYcCUGlie+EK14aRSeP90lTnmH5x6YED0R4t+CsVzqFPpKIgQz3SkGNjpRvEfqoXwaHwgF2kTsgU+GCdNr1mOzyPFo4KdVpyiP0z49znFn X-Gm-Message-State: AOJu0Yzhg5PT+wMO1zSLBdTv40uUYuXT+meiYVRX96H6lCZi20sySoga Qke6319aJ6aqd3goAJjVLTR6KeMcA4+iD+/TK3h+Bfsm8sYCwndqoz9x6jGAPub0g2xcS190Skp u X-Received: by 2002:a17:902:c942:b0:1f3:830:783e with SMTP id d9443c01a7336-1f339f0d128mr27457195ad.20.1716462829566; Thu, 23 May 2024 04:13:49 -0700 (PDT) Received: from L6YN4KR4K9.bytedance.net ([61.213.176.14]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2fb4ca0ebsm76399555ad.119.2024.05.23.04.13.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 23 May 2024 04:13:49 -0700 (PDT) From: Yunhui Cui To: 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, jeremy.linton@arm.com, Jonathan.Cameron@huawei.com, pierre.gondois@arm.com, sudeep.holla@arm.com, tiantao6@huawei.com Cc: Yunhui Cui , Conor Dooley Subject: [PATCH RESEND v5 2/3] riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT Date: Thu, 23 May 2024 19:13:21 +0800 Message-Id: <20240523111322.19243-2-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240523111322.19243-1-cuiyunhui@bytedance.com> References: <20240523111322.19243-1-cuiyunhui@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jeremy Linton Reviewed-by: Sudeep Holla 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")) -- 2.20.1