Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1817133lqp; Mon, 15 Apr 2024 20:15:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAAYaQFyRhLFfjvtmxr9WeRm3Nzd7j9r+rc143A1l+7acBRfasOkrC8udM2KppYZCEsu48wXGd9Uz/57Z3KfqKjOCppwWYf1euGLbjEA== X-Google-Smtp-Source: AGHT+IEBkgQiJiKsp8+BwJVq/Zkv//qsC7igDGEAxTwOC2HKwTLwJR8zwyUflrwkKEJhhpnple+8 X-Received: by 2002:a17:902:ea12:b0:1e3:dfdc:6972 with SMTP id s18-20020a170902ea1200b001e3dfdc6972mr16333859plg.9.1713237325633; Mon, 15 Apr 2024 20:15:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713237325; cv=pass; d=google.com; s=arc-20160816; b=rrDMBJkfrzeBSZastqR1++s+TqN5LqssPVlhjwZL4obXXgW0ms9C9pm7ZyM3e0LAW4 UWaet/lWlIp0m1I6B461jC2hLx7sXt3dR/Ru5indse50D4oiTRqHV98vb2oQ1I8cyBvj H6wVIhPufb891JzPRr3UG3blAo+EyUMK1KrcgPJIJBFNMU9nfsEmvc+6bvuZVo3ORIum v7KhiYOWxiHS+Yq6wj+Bqni3bt9D4UeJK/eZe9oZghmJ2050jjykdMBpbYZTNTZdCwtL ofdpvhDVkJjEmJZFcGEXJReY/9+Ry/EGNWM+R5UjI1TbYJCm8MCUfs3R9wgUqE9Qw20t 39zA== 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=9yve68TeIN/f8pyzLtfbyGcp16m/kz9ccR5yLCEIe7Y=; fh=NkeiEIp5E0I16K/J/EpF0fOcMu5ycxmOD/3cpFTa3wA=; b=zlacde3zq0adedt/ysUSvjvkQ6WtbjIUmjs20xRiAzYbviEGem/BzPG5TRZM95ItI/ TLz5tubAOIT1VFIzMPCdxErkccCJzZeGFJrT82oaQUujhjYcqFPjFM2mvTUw5DZH2FKI DKr+iRD9rhTea7vIpTfwmLxcM8FcfCZiLSFhxrD/LTV8YKbQk3TZ9uIozwuhrKcXeUuz WOHREZXUJUrDRSEr1Mm83t81WNyEzevYLN3/abtHc5/iO0cNGMoPMim0j1CR6wh6svCi j4JCnNHESEmjVXO0Au2D62eVtamdplGOgg9MGzovsqn08+/D2vdR1SZnMo+YkNbTkhXq AQJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UCOOCnh+; 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-146148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h7-20020a170902680700b001e2a0f5c170si8650701plk.505.2024.04.15.20.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 20:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=UCOOCnh+; 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-146148-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146148-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 00FE1B216D6 for ; Tue, 16 Apr 2024 03:15:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACE63171AB; Tue, 16 Apr 2024 03:14:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="UCOOCnh+" Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 7CDEC1B5A4 for ; Tue, 16 Apr 2024 03:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237296; cv=none; b=fEufkFq91TV71oNI3bobmLscCEwlMXcZ7lkzJ1MNOj5jCfjGP77AP4RMjSkf8zvBCK2LOPDv9yeuJuMpGXktuRd4gI3nLnwGLa2WIWcwfz7k6RwbRkyux5CwXDqYhjfpXN3aEEUeBaaQC9NaknagvCblnvl9lCatwSQw8A6UPBk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713237296; c=relaxed/simple; bh=73Ooj+OaJJIoBwEkContTKxHyybH+bNX3xJA/ldJcL0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=upKQjUW7udnfPRYIH3nXuWNduN/UJUG4jxkuMKogycx7gNW8S9z4TbxEG7OroqxE+6dTTyRly+dFLb8H/vBnw8k0mxlkWPKQcV525bkm0fL6X0Ly0AYD1HotS+D5Flixivqd12z6di93YNLx7/dMEiTIbQQ/bzJ+WpW8mh5NVtE= 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=UCOOCnh+; arc=none smtp.client-ip=209.85.210.47 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-ot1-f47.google.com with SMTP id 46e09a7af769-6eb8ea5ac95so262937a34.2 for ; Mon, 15 Apr 2024 20:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1713237294; x=1713842094; 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=9yve68TeIN/f8pyzLtfbyGcp16m/kz9ccR5yLCEIe7Y=; b=UCOOCnh+dsL7jY9IXyUpbhZA/SsvalP0hXaB/QD8bBU3ooMgftD2ByoAj3Lys4ZXvD aEg2RCI2UQCExpRDRcAKCZUe4r3sWWV5aXhksFjefoIPWgHKyZ7rQTiTED48cZL+I3S8 /tSRS+Aj50yIArYYjrOplBcCPOQwRZ8GxvKyuC74PeVx+64M2R7LcgBbQSxhUuJKyqEd NT2/bXyt/50uYWWm6RT5620BCA3T23C0z6+Y4DATdmFq19qK/qpH/wR5yrvjxJcX94cC N9yzbMVbw5ICwZjurG88OaEzbvs71ocfheqXGhg3Vl0fWdQ/oQG4oAJvGRcgKedvKc0S JfNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713237294; x=1713842094; 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=9yve68TeIN/f8pyzLtfbyGcp16m/kz9ccR5yLCEIe7Y=; b=gHLKKIlYfzKBFzfYzSfUJ3BDt+eGlugxeApbMdXeNFluW8+8XltguIb9nSyoAIGJXX pE+IK5wMQH14WMMnsPb3f8VDMbDBaq+w10gcSQXj2WtodNBj6mAMF6WL6LBeHKWJDkSY zlUBdcuGpB5XmS2vNuh9FnSxyFhtphlSC0j/1l4SehILK4SJchX8JPoIue1wGdkh18ZJ J2xq/AfABmYxLcUmDtlzpBmdgMAUl4MVWEvPQPRn2/x0aVVKUylBqC51rMEUN6Oy0BdT eCKPJGXY/fvn/M1jxdHGR6549bie0OJR9RjralnhnnHomH+z5bNaX5wSNEBaGhNjQu0r 2wYQ== X-Forwarded-Encrypted: i=1; AJvYcCWu263l9UnHCXqqgck25YGRG3TgFn6Hltlg0ayYfEswc7cJ2AaIBbRrDqZvhSff8zoQMsAmPkMH4tKYdQ3TytS+EEso58EeT9ud5Gmk X-Gm-Message-State: AOJu0YwwDiLRyjX+2hgMbZrE114OV5Ew7qHQJea/HerGrLUTv8tuiJL4 tS/jUyu0HOMrZYw72Qe3rL/fOQ+yghB9s7ZoK4I1oaPsH7zr/mHI1mvo3UIBUT8= X-Received: by 2002:a05:6808:6044:b0:3c5:fb09:aeea with SMTP id dd4-20020a056808604400b003c5fb09aeeamr11353481oib.35.1713237294624; Mon, 15 Apr 2024 20:14:54 -0700 (PDT) Received: from L6YN4KR4K9.bytedance.net ([61.213.176.12]) by smtp.gmail.com with ESMTPSA id d20-20020aa78694000000b006e6adfb8897sm7907983pfo.156.2024.04.15.20.14.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 15 Apr 2024 20:14:54 -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, 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 Subject: [PATCH v3 2/3] riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT Date: Tue, 16 Apr 2024 11:14:37 +0800 Message-Id: <20240416031438.7637-2-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240416031438.7637-1-cuiyunhui@bytedance.com> References: <20240416031438.7637-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 RSIC-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 Signed-off-by: Yunhui Cui --- arch/riscv/kernel/cacheinfo.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c index 30a6878287ad..dc5fb70362f1 100644 --- a/arch/riscv/kernel/cacheinfo.c +++ b/arch/riscv/kernel/cacheinfo.c @@ -6,6 +6,7 @@ #include #include #include +#include static struct riscv_cacheinfo_ops *rv_cache_ops; @@ -78,6 +79,25 @@ int populate_cache_leaves(unsigned int cpu) struct device_node *prev = NULL; int levels = 1, level = 1; + if (!acpi_disabled) { + int ret, idx, fw_levels, split_levels; + + ret = acpi_get_cache_info(cpu, &fw_levels, &split_levels); + if (ret) + return ret; + + for (idx = 0; level <= this_cpu_ci->num_levels && + idx < this_cpu_ci->num_leaves; idx++, 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