Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp977007lqo; Thu, 9 May 2024 00:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsqxD0S73gEnvLZwUASFGYzPldf4zD9EVXN2xsbv38zhoOE8jTQis/StoeHqgMhXpFzj0F8F9m/B48ilhEb2fu2DLrdgVqcgFMb709jg== X-Google-Smtp-Source: AGHT+IGYaCsCs92pIFndBHZDWWfKpVHEmdTynSAYBIaY/rAvKbjK0mcRwNmUW84grAv/vj7v+Z9p X-Received: by 2002:ac8:5fcf:0:b0:43d:e8cb:e283 with SMTP id d75a77b69052e-43de8cbe4f5mr26407341cf.0.1715240052746; Thu, 09 May 2024 00:34:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715240052; cv=pass; d=google.com; s=arc-20160816; b=AjU3Lc0/4a2/2UBNSRvImFxkyQ0+nwYimZSJQHY4vjNwfjgMj2kAzcfq0k6fznYwew dotnR00yCpUM+w6TTC1WsNVueIPmcp5vVGwUoSMrn4v0+TUc1KlTajfOyGpLxFXkX3pH C1Hu6uA9A/m1sFZZNUMDzOllRH+t4yPji68vWfY5Oj/nWwj+AECy5gJD0b9RGpYGWUYt LE5md/1Dn++cy5CYCqMyMILfT1BJqXcbWdBo+VWHK0mTCUYbl2fnE0xK00Yo3enkMc5d IUzuKRGmpjYKoJQ1F8rNfUY7Cor7drX54WD/0k28TcnfPH1xc2CyvGA/48GuOR1E9aB1 Xwpg== 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=7cwpsa2HL8S5jIz0x6grJAB8mOqnJkhHeKGCfgHpfOE=; fh=s4OzrlEi95dViRwDdLK7bsQRWzqc8TOnDydnti3Wt7M=; b=MA4VJi8/tI5YJ81/68Hb+AK7hr75VMxPfc0rKBd6/mdM4UkQLN7P4U0IeqSs+uB00d STOCj+QVfLNgKR7Zxmr2WLgO6o03DSqxsPskRSj2xVUbOCztHltdjRNoDDoqIHEe4Ape 4cv4dp36BGZn752QVfTEMIbEzwWilO+pGi7+ouOMOwVIwBs9BYHRILr4oAxZw/jhBLzq S9bRusz8CMniWF4mlr8SOm2FlwF1Midr/he8ozEjE8HJGDvGc8pvOHw9z1v1DCH+Pe/X 8vGjbgYhAvit+/twh0V7K7+enFc9XUBDHq0d8K6nNx2IahGKADF5rwzGlAkmHb6XTttd ad1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Rctwutpa; 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-174237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174237-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df56e3e5csi7953231cf.758.2024.05.09.00.34.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 00:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Rctwutpa; 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-174237-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174237-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7B51B1C213B8 for ; Thu, 9 May 2024 07:34:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85C1A149C50; Thu, 9 May 2024 07:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Rctwutpa" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 4AE51148318 for ; Thu, 9 May 2024 07:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715240040; cv=none; b=TXy1dYfQQIflelwOiUaaLBIZth/eZoCTuXPlIVQKRi5c0jA9kXrqzJahPB6OOAZHWdydHFRQGCY942+Cgq22ZOZ8ipIoOOJ0LWd8UsczGUBmHalM2jeGX53qvVzfQ1uMaWuUyAQZAO0wvFI29AS18b8Hgyz4TAUgZ3Wpb9zcUTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715240040; c=relaxed/simple; bh=sCpUWY3HzIVMI3TbeegEZ/zm4GDQ+yecC/8p7PvVbno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XGdkQquqBB7kgePmBpdUpZo0g1rTAaCMMpxRFlnZUdVW91hQcdxfwtZgzRRKKm2YgQGhwh04zfWO48iRb7gNZLYAGC7qJF7IN1AxMB7DFCGR24b3YdNJxjTlG/wXnnT3BmxcsB7uxiMaRIfdyUD6rAqUgCyNTAQ05FFcfsmIpns= 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=Rctwutpa; arc=none smtp.client-ip=209.85.214.176 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-f176.google.com with SMTP id d9443c01a7336-1ec486198b6so4302615ad.1 for ; Thu, 09 May 2024 00:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1715240038; x=1715844838; 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=7cwpsa2HL8S5jIz0x6grJAB8mOqnJkhHeKGCfgHpfOE=; b=RctwutpaGCvx7q08udDRVSsO3Q3+gNTCiU23tJP2hz1rw5/i6fVG+5C57Ncpelc+Tv mmufeibCLuk+luPj67E/El5R/duxtkqPnfSEK4ypc2t9NFQHxUecykK5RiSqkJG/hudE ebODZcSBAkVbXYag1S1ZKpF6WjPtVoA/H5BvoWf7hf9nCAPXiuXPIt9jv5IuK8FjcD8T 7EBzbkOUtEV57TaS8C1iiHq+x/T4UW7l/gmMFPtK3K96wOzhLtLi2G/WLzxaPR3HcAk1 SzqprbkBsHweEBmV+k4oyVD2OKxmgru9V/0jUo7qBaqpCocAR82Wi/nB0f9Lf/3ZQf3V eAjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715240038; x=1715844838; 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=7cwpsa2HL8S5jIz0x6grJAB8mOqnJkhHeKGCfgHpfOE=; b=Bzt140Qn5zRQvcYGBMuh6bFdAaUZxMeRG4LISbPWFMtJuojlFXWNmKNx6uvUTmmyQ7 Kvz1zEd+hhQZOghBN2LolalnKDiJDbYATvq7VhFFBzU10K0gvklhWxbABPsAqC3fmf+C 9/K7FmOTS9oIjKHXLXoW7gF5XmFxsJ9+isoLWzeM/FirQw2UD27+wPyckUvETpf4ml/v RsPl5YCqJqdF3VEQS1eMyGlDwD/akT3uCwciIM3KcZ4e0quPM7INSOiVA7aGLB2Nez+f 2c/rCjbikTo7qeK6awWn99cILnIBpEu6jfSs1GDSvQJOhJoKvfDLcbi73GnErghyqx82 0J1Q== X-Forwarded-Encrypted: i=1; AJvYcCU2Ih1cv+B5TEOpjL9rSzdb0w0QxsMjySPlEJppJblfIEIVer7ku1FZCJRA5oUHCu0QuMrBEtO+OxPWBLEUnhcVnnIlKL4N3W4sdJvq X-Gm-Message-State: AOJu0Yz6FeOFoeD4MU7q6M0/Ic3C7e3kVXH3C5XkyxDdkzSaqyrK8Ylp zW7Z3PF+mr308paFZI4dFNF6NYpbnVrv77dwzJ1xEGJC3itbvfoLoyUrI+tpq9U= X-Received: by 2002:a17:903:258f:b0:1ed:1d37:267e with SMTP id d9443c01a7336-1eeb05919damr43288965ad.16.1715240038702; Thu, 09 May 2024 00:33:58 -0700 (PDT) Received: from L6YN4KR4K9.bytedance.net ([61.213.176.14]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0badcbacsm7519045ad.97.2024.05.09.00.33.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 May 2024 00:33:58 -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, jhugo@codeaurora.org, jeremy.linton@arm.com, john.garry@huawei.com, Jonathan.Cameron@huawei.com, pierre.gondois@arm.com, sudeep.holla@arm.com, tiantao6@huawei.com Cc: Yunhui Cui , Conor Dooley Subject: [PATCH v5 2/3] riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT Date: Thu, 9 May 2024 15:32:59 +0800 Message-Id: <20240509073300.4968-2-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240509073300.4968-1-cuiyunhui@bytedance.com> References: <20240509073300.4968-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 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