Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp756897lqp; Sat, 13 Apr 2024 20:00:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUTy5Ack3UYTgVqEy/y5tAWmlAlMBTrwva1kUKFNTMXPqUA5Bs8vaTvWW9LjcXUOM046zP4mOcr/UYE6sTM0G4zzZwYuOf3YxbnrLPgw== X-Google-Smtp-Source: AGHT+IHoGfKljGEPQwtLOmdRxz41wN9fll5jpKfO8hcoaJpPeSsyFa5rhYwgm4P/0EvIMv9AJRbc X-Received: by 2002:a17:907:a0b:b0:a51:ddc6:f9c0 with SMTP id bb11-20020a1709070a0b00b00a51ddc6f9c0mr4275714ejc.45.1713063606033; Sat, 13 Apr 2024 20:00:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713063606; cv=pass; d=google.com; s=arc-20160816; b=Ki7Pg1PV2jg9BNp+Swr7ww+3FfEVga3o11uHoFxXEPkVZ3Z0SfPFNtijP4Jk+YqjDv kz6L/96+pWt0WiJwHM8rznpN7dgt8K1KYW04sj0K1H+s/TGIa0QJP6ldGWIvzsYxZMe9 UbN+sqg0HocRnzjuSzyhB37XXUDjmyD47JV59efGx475UVZYX9fWBRHVhOF1bqt0RHW5 N1xr2foNqqLOr2JkkRgWNs5Mq7b6Qi7n33+TC+xryK9jaZSMj8XPBa9CLqZ354Xsa7Kg ppZT9sqmi0WauPq1YuCLDQ9b4NUf/0aM+Dm44AFTPhKq77urVxq0xfToejrjtygCQYo7 P5BQ== 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=a+iJ/bWcbs5TbNYkdodB+bg4kp9o+X2TePK5VotNZ5U=; fh=rfNGpx689m0J7vIw6K4HfOMm5Fac9zIyjofvXooDC6I=; b=u9etu/VkMpQzgpZfRiH1fb6NOi9mywOr9PmlFRB7UURmk1+OwwP/SQF6KlWiTvdWLB oh/SR540c4q/L98fkS5xSpe5YilLKykWK3mq234Mn7cILhbtmVkw/6rHFLiO5Q6oKill +BoMFHZ69rsNTMgegz/0qIOGmLo5BAf1HvVsU4VcB+cC3qjXgcj9s0yMD4NIVs9QeZGI tEb/jACONk4vPfpGqjeL0cJHSL3YhqG0RVAx7m5kYjQUlz91NZ7L1GWbLqY41sHIBB9v T+dsSCQADlP9w3Ufj2ncxs2ukm2bRWeZIzf6zlGec9DOtqr6UwqM8l1DqHzRfVGZlXET aV6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=IK2OiGAN; 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-143948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143948-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a2-20020a170906244200b00a51ca3e2ea6si3136080ejb.257.2024.04.13.20.00.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 20:00:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=IK2OiGAN; 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-143948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143948-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 am.mirrors.kernel.org (Postfix) with ESMTPS id BB5691F21F1F for ; Sun, 14 Apr 2024 03:00:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A734917BD2; Sun, 14 Apr 2024 02:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="IK2OiGAN" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 14ACC18E01 for ; Sun, 14 Apr 2024 02:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713063586; cv=none; b=NmJPPH7rFLbh5UXOEDz7mLAxeqCbEfmB69dTnNlyAXHoz6tbUHqb01xa65HV1ODeZD+eLZ7FMtgANq3A4sUa+WCHzfq0G3VqYSZdb6lMqUxWyZqJhyUW0giiRcyT5i3p49yTn8pzlPdjvTkeCR2UcCur76R+bAMefkMIf8G+WPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713063586; c=relaxed/simple; bh=GNxwO8FiM91HhPodNEqh1grX1c2NbQXpFfur+digntU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yfwl/mmam5CpTlyc/4GlL8jW9+ltH3gsykmjnM6e6Qlhvw5m6Y5NTQS9Av5teKxcHB0h8v5bYyW9d+V6uAiG93fnW4H3tb2JOokKcGyCjcniEvCQ5KhhabBjzsVTHmjocg7YZLmjF7L5y+NrFJequ+KgP8EQT+GY7DOo/452GME= 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=IK2OiGAN; arc=none smtp.client-ip=209.85.215.181 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-pg1-f181.google.com with SMTP id 41be03b00d2f7-53fa455cd94so1734252a12.2 for ; Sat, 13 Apr 2024 19:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1713063584; x=1713668384; 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=a+iJ/bWcbs5TbNYkdodB+bg4kp9o+X2TePK5VotNZ5U=; b=IK2OiGAN6NQbyDG1JvzjtEYJ79zVP7XjJeqSP4Xko8J++mC73Vivgs2R8QkUJ+BITx LGNqPcl85iDceypbrSZ7XaFn7m1RzhkFEbZDHEzt4/1/dF3IbCtrN+Vx4g5z9AiuPvU2 M1+OFXpee1cYSVEoQqU2E0c909ylfOMGS9nfNsXTkOBjTOAE5mauGFup1tahk88rSIji TGqqImmeRIjrOpHtSq5TXofa8mWaJqZV/+zJ1vUTIfbfGn6YVQWTgsI8FCBBmpoFkNgH XlrRDEAbOHlLDdf3EqDICDoj93UAC7dYq//CyqP5aIvmCPeGd7aSUSQp8lubCZ7ODnrg JgRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713063584; x=1713668384; 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=a+iJ/bWcbs5TbNYkdodB+bg4kp9o+X2TePK5VotNZ5U=; b=wJXkJawUjfIyqoU1LhhPphPPiw03kET6WjjDcYm2Mg8JsfpNqVbDfryuom+RpeLNOo Fhplwoa5IUbBCWTuKW1uYtVx8iHvRDJRXT7FFy600Fws82X63FXaFfsYWOkLa7CoEk7x ZAUz8f8RFyiCIA9oeJ6y/U5WxLuDPWxrK259zzb1RYcWvehG5179WekGAdCgBLMz59VX pc7CP6RT84aKkx8hWAQ7N3vL4H5onUqkrlja2EO1KMOVW/vol53IZO/g+lbHygEubpwq qacowMULJ6KPg1hdrSir2K7OPnswHOZvcDhbyz/HDuj1HReIwKUJ2+gYOENS8j2i02/i doDw== X-Forwarded-Encrypted: i=1; AJvYcCUyzl+6QjqdJrvtXRZZG13VRuA5VKhL8DDha67CjiosKa7Qj9BvS0SYM8gEj2zSgAZ05w4q4KH/bCc080npUAMQAhtsBpBJgfPjCtOS X-Gm-Message-State: AOJu0YwETTh7ZlbRn5uaW262wN9zOs32MEYeT3UX43XIJ8CumQJr28Sh 3kmROVhWkGl1yUYOSlqqhTpMHvkzYqDm/Oe04PknMk9e1mdHK65xu1zoarq8Kcg= X-Received: by 2002:a17:90b:80a:b0:2a5:513:921e with SMTP id bk10-20020a17090b080a00b002a50513921emr5443131pjb.31.1713063584355; Sat, 13 Apr 2024 19:59:44 -0700 (PDT) Received: from L6YN4KR4K9.bytedance.net ([139.177.225.246]) by smtp.gmail.com with ESMTPSA id cx15-20020a17090afd8f00b002a219f8079fsm4799913pjb.33.2024.04.13.19.59.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 13 Apr 2024 19:59:43 -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 v2 2/3] riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT Date: Sun, 14 Apr 2024 10:58:25 +0800 Message-Id: <20240414025826.64025-2-cuiyunhui@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240414025826.64025-1-cuiyunhui@bytedance.com> References: <20240414025826.64025-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 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c index 30a6878287ad..ece92aa404e3 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,28 @@ 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; + + /* must be set, so we can drop num_leaves assignment below */ + this_cpu_ci->num_leaves = fw_levels + split_levels; + + 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