Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp352524rdb; Mon, 29 Jan 2024 04:31:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3me26I+iHzMFZR+TajmSmI2m+a36+zfzATLzLjNwauNfmweWc030EfcWRTevugoAWTSIe X-Received: by 2002:a05:6a00:c8e:b0:6dd:c35c:e7c5 with SMTP id a14-20020a056a000c8e00b006ddc35ce7c5mr5375773pfv.18.1706531467498; Mon, 29 Jan 2024 04:31:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706531467; cv=pass; d=google.com; s=arc-20160816; b=KFa9X6hYHKZQdSVmlFUZoGcYsoaWKKy/oxhdb7GWS1N9UR8R13/1XKIJIaybIOweaN 2oZwziJUw3gDW1lcYuAisaQ0qefPY9Td74bldai6+HSvVqCuwnp8dA6BTk08OHmIjKx9 xFS18Ehg1obYtmb8vjAJdWzc+n41lvBxcVqZL1pb6CE89NYE5HI7mtbah1LI7Sf87Rzp ZwUi6usjo4CiOmQHA+Pi2zZjyrNgqhKEVI9q4LvPJa9CfSfqRW2qmXv1BxdCaT3xV/1e c0khg0vHK+RUqnNcPDWDn73pKNHValpMW9Fzd/cV8fk5MsuwLF27m3bj68iuIDWBuxB4 QA2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=i9MY62nLG6SDcgj8fJG647loTyI9zJFU6asFDx/5ohE=; fh=zqonmRcfT2K9WK4X5Vtu2XCE+3SmUiJduBtqnEZE/eo=; b=tj2AkV1jhEBWeK3yhpr0mKgRS3ImCrw/vBo4iIeftiPnn09GONaHIXZcSHvORMyrB2 vyb2EJazGPtIrHd99xbqQfbDTfGajfJ1qOGZbnmxqKTnJ4RA/7q1/7XdNCVEU+WYA2xG IRdmX3mbAdtkk/et8yO8bhSpNPIFhIAAbABPXlEEc0kb7rOcz6EUCb+JDUZCCSrL1Aip 4JtF3leJ+TC4ELBYUssdRwYpuPzRI+KRpEKTFOrJkdd6XxKkVykk1NaWz/GU+0p7hU12 fFJoY+vP3+EHORVBgVReAQOF1zMdrgsOY08Sa25famwJ9fp4MfamHc5tT4iBsiH7/cTP z+bw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mpESaN2A; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-42689-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w19-20020a056a0014d300b006db9cce8e2fsi5696061pfu.280.2024.01.29.04.31.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 04:31:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42689-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=@kernel.org header.s=k20201202 header.b=mpESaN2A; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-42689-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 F1E6C2843D9 for ; Mon, 29 Jan 2024 12:31:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F9B060DFE; Mon, 29 Jan 2024 12:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mpESaN2A" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDBFA3527A for ; Mon, 29 Jan 2024 12:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706531463; cv=none; b=e41JgxZPfPN7itRf6tsWzBIeiS62cIt1dlyif8A0DwJB3ioKwVcL5zqt/mQFWcgtWe4BD3kQdTfgBTUyLMRT05NijiuJdEKH7x308vNv4EJG9DO9VKg26PcTvHCwNhPt8HbsVoW/QEOyP7DprgR00RmKrGSO5q1Cg6AS1IQpkrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706531463; c=relaxed/simple; bh=OMjG087pQhKBaSUbWJ01ewqPvsYZPCOIy7ZK/xWIyLM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lLw2Gv8fd4CFJpm2+jl8xbVGPMaavoRmN8Ai4AZiiSqDuISfbD20mMGVj0KKeIdcnlJbh9wBimm9BaWpZaztmoyBJTGaQbRvOHSLqqaL5rDJt0UssFQVJy/D4KKJzjaiKPCfbYIODjd/Bdjr3zKzJYS9WIDATTglyfkAqOh1cFw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mpESaN2A; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8200AC433C7; Mon, 29 Jan 2024 12:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706531463; bh=OMjG087pQhKBaSUbWJ01ewqPvsYZPCOIy7ZK/xWIyLM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mpESaN2AmpfQFQYUKYs+EQbLWFkPPNM+IzD4Jn9kW1zbuPrDWsV+go03/pzx2lFuF r2X09hQBKVNvGDGOs1+Jn+JF1KLoqQ/J5L0aI3h/1p0CxRKVfD2z4m1NfxDlHiFU2h xGCenlPZpg72QOMHycpLzAMC/TzA8H+aScDbhWO4M7zIhh9gisOoIRhGZ8k1ug62rX DRlzGBJqjSv75FCBDIG5xdWJEmhIo2uAKAsKDwtav/ouSgPRfVL3useLSi2i0cxBrL JWX6m2gs0/H8gCAU4Aac91MhjZgp+0KjWEi99pX2j98Wg9YMgWEgQ1GJRh44yWUxp0 unmvaNfw68XKw== Date: Mon, 29 Jan 2024 12:30:59 +0000 From: Conor Dooley To: Sia Jee Heng Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, robh@kernel.org, conor.dooley@microchip.com, suagrfillet@gmail.com Subject: Re: [RFC v1 2/2] riscv: cacheinfo: Refactor populate_cache_leaves() Message-ID: <20240129-parrot-dropout-c4ece33a98da@spud> References: <20240129075957.116033-1-jeeheng.sia@starfivetech.com> <20240129075957.116033-3-jeeheng.sia@starfivetech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vVQN45TubuFKPBU4" Content-Disposition: inline In-Reply-To: <20240129075957.116033-3-jeeheng.sia@starfivetech.com> --vVQN45TubuFKPBU4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey, Firstly, the $subject should really mention that the motivation for the refactoring is ACPI support. On Sun, Jan 28, 2024 at 11:59:57PM -0800, Sia Jee Heng wrote: > Refactoring the cache population function to support both DT and > ACPI-based platforms. >=20 > Signed-off-by: Sia Jee Heng > --- > arch/riscv/kernel/cacheinfo.c | 47 ++++++++++++++--------------------- > 1 file changed, 19 insertions(+), 28 deletions(-) >=20 > diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c > index 30a6878287ad..f10e26fb75b6 100644 > --- a/arch/riscv/kernel/cacheinfo.c > +++ b/arch/riscv/kernel/cacheinfo.c > @@ -74,36 +74,27 @@ int populate_cache_leaves(unsigned int cpu) > { > struct cpu_cacheinfo *this_cpu_ci =3D get_cpu_cacheinfo(cpu); > struct cacheinfo *this_leaf =3D this_cpu_ci->info_list; > - struct device_node *np =3D of_cpu_device_node_get(cpu); > - struct device_node *prev =3D NULL; > - int levels =3D 1, level =3D 1; > - > - 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")) > - ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level); > - if (of_property_read_bool(np, "d-cache-size")) > - ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level); > - > - prev =3D np; > - while ((np =3D of_find_next_cache_node(np))) { > - of_node_put(prev); > - prev =3D np; > - if (!of_device_is_compatible(np, "cache")) > - break; > - if (of_property_read_u32(np, "cache-level", &level)) > - break; > - if (level <=3D levels) > - break; > - 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")) > - ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level); > - if (of_property_read_bool(np, "d-cache-size")) > + unsigned int level, idx; > + > + for (idx =3D 0, level =3D 1; level <=3D this_cpu_ci->num_levels && > + idx < this_cpu_ci->num_leaves; idx++, level++) { > + /* > + * Since the RISC-V architecture doesn't provide any register for dete= cting the > + * Cache Level and Cache type, this assumes that: > + * - There cannot be any split caches (data/instruction) above a unifi= ed cache. > + * - Data/instruction caches come in pairs. > + * - Significant work is required elsewhere to fully support data/inst= ruction-only > + * type caches. > + * - The above assumptions are based on conventional system design and= known > + * examples. I don't think this comment matches what you are doing. For example, the comment only requires that split caches cannot be above unified ones, but the code will always make a level 1 cache be split and higher level caches unified. The place you took the comment about the split caches from does not enforce the type of cache layout that you do where the 1st level is always split and anything else is unified. populate_cache_leaves() only gets called in a fallback path when the information has not already been configured by other means (and as you probably noticed on things like arm64 it uses some other means to fill in the data). Is there a reason why we would not just return -ENOENT for ACPI systems if this has not been populated earlier in boot and leave the DT code here alone? Thanks, Conor. > + */ > + if (level =3D=3D 1) { > ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level); > - levels =3D level; > + ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level); > + } else { > + ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level); > + } > } > - of_node_put(np); > =20 > return 0; > } > --=20 > 2.34.1 >=20 >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv --vVQN45TubuFKPBU4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZbeagwAKCRB4tDGHoIJi 0p2vAP91xqgYKdI5R4E8M2TeUKf7W4MillrhtPoe4A++bU5YagD+NYICS59UguEb kC/D3NRlCAVajtBJRjiLWpUC77PETws= =E7YN -----END PGP SIGNATURE----- --vVQN45TubuFKPBU4--