Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp600032rwl; Wed, 12 Apr 2023 01:05:17 -0700 (PDT) X-Google-Smtp-Source: AKy350bb16ID4hctYEU6govA6L433vXiKGGHu29qgneeVL6PqSuOMuwWtrE242nNfhgnd6QQkQBC X-Received: by 2002:a17:906:1cd2:b0:94a:a462:8e64 with SMTP id i18-20020a1709061cd200b0094aa4628e64mr1231507ejh.20.1681286716668; Wed, 12 Apr 2023 01:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681286716; cv=none; d=google.com; s=arc-20160816; b=Lep7G81z6mSY9PDGWzKVjnenvO5wOxk23PgHM/zzpX2Rou0ZPOXHWbrf7YHM7DvsLg PCzrose5v/8VH2R6+gESsd7JNCafh71R+Qz/05s8kyYeQqdBKAD2V+Z1+FB+Ceh7i1F+ zSJ5xR+DuPOm3MDHl4ujiim+cVNGwlY3zX91jATWH8EEXgdTeZGZi0CHJvj/5ViAN687 ZTfS5dhk0leGisB0L9F+d4PjSIvc3HWiiKWxAUHx79WFUmppVd9/GEVzRJJtFY0EeW0H WsF0hPxNPAPwXMpZXtIm0lyDpJtg8N2dK/HGzly0cX66+7Ardcd1MKjKCBikOcIAT6ng w9iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r2OUhMGA0CTCYdgHnGDB9lfjR0uR/rNipk7gnP7kjK8=; b=eMTTbSHu0e+Vx0gYwU+aaUmd5XB/sz69znju1HihrsgL01IlEwXqFjSQG1/NOHie1O 8jIryrBCe0fwXaVmAfEsHj0EnJQA2629BeJnK4YYBeTL2Ns2ZpJ7ltqlp/2MxYh2AMfH D17sbXBmrNiZhUF2COL/5B3GHnoFvEz16+okqFvzX6Ony2IAVOHj1O2p3MrZ9Sftlds/ ja24qa6HEjKR44150DlrZ86RF617Oy/dBN9Dczkl2jEzKzMywoGV90BhrACuhh9AxINy jsYjdsAUJn99fQZBY22gzf2JJ0oAOzJqlVnKDNLlYkuipp9v6IBRpxwNih+mmV+g1OSW ZynQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="z2pDQDv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bi7-20020a170906a24700b009314c7ae06csi8740126ejb.191.2023.04.12.01.04.52; Wed, 12 Apr 2023 01:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="z2pDQDv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjDLHz6 (ORCPT + 99 others); Wed, 12 Apr 2023 03:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbjDLHz4 (ORCPT ); Wed, 12 Apr 2023 03:55:56 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF55C3 for ; Wed, 12 Apr 2023 00:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1681286154; x=1712822154; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=L4GRltKsC62Qcydnf2jlGg6qLDDSoBJwtyiadtuogUc=; b=z2pDQDv/s+4oidr72Ok4FseUekdLwUoKfBjf3Gw+UObv4M5GC0ygJy+C ZolvU8yDTosK3mCQ/ngUxnTZWD8Z+uNCgILt3LRHxuI96RtPhue0tTQlb sQCEAiVdPI59eJ8R1K4Ipnpzy/zCIfuAB0SHPM9RzhHKaQisVDpDd2Pjt y/M5e4/oAH7cCppXOfrMd1y7FAJdmJr5Iu2UocSVY2QiOFLUiw/77aIZf ba8dlKqerdRBILDoBgwbZ61MbZZ9puA+2E6ch61OVCkCeLDbzcqslQC3e flObQNTebHAtbi5xpy6yGGjHX3PeaD42w8B2FAC/BpHRbQWbo5ja0uuri Q==; X-IronPort-AV: E=Sophos;i="5.98,338,1673938800"; d="asc'?scan'208";a="220513235" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Apr 2023 00:55:54 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 12 Apr 2023 00:55:51 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Wed, 12 Apr 2023 00:55:49 -0700 Date: Wed, 12 Apr 2023 08:55:34 +0100 From: Conor Dooley To: Pierre Gondois CC: , Radu Rendec , Alexandre Ghiti , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Palmer Dabbelt , Gavin Shan Subject: Re: [PATCH v2 2/3] cacheinfo: Check cache properties are present in DT Message-ID: <20230412-cone-mousiness-23326e149592@wendy> References: <20230412071809.12670-1-pierre.gondois@arm.com> <20230412071809.12670-3-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tpBqFoyWWsu1/B9s" Content-Disposition: inline In-Reply-To: <20230412071809.12670-3-pierre.gondois@arm.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --tpBqFoyWWsu1/B9s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Pierre! On Wed, Apr 12, 2023 at 09:18:05AM +0200, Pierre Gondois wrote: > If a Device Tree (DT) is used, the presence of cache properties is > assumed. Not finding any is not considered. For arm64 platforms, > cache information can be fetched from the clidr_el1 register. > Checking whether cache information is available in the DT > allows to switch to using clidr_el1. >=20 > init_of_cache_level() > \-of_count_cache_leaves() > will assume there a 2 cache leaves (L1 data/instruction caches), which > can be different from clidr_el1 information. >=20 > cache_setup_of_node() tries to read cache properties in the DT. > If there are none, this is considered a success. Knowing no > information was available would allow to switch to using clidr_el1. Hmm, w/ this series I am still seeing a: [ 0.306736] Early cacheinfo failed, ret =3D -22 Not finding any cacheinfo is totally valid, right? A basic RISC-V QEMU setup is sufficient to reproduce, for instance: | $(qemu) \ | -m 2G -smp 5 \ | -M virt -nographic \ | -kernel $(vmlinux_bin) Cheers, Conor. > Fixes: de0df442ee49 ("cacheinfo: Check 'cache-unified' property to count = cache leaves") > Reported-by: Alexandre Ghiti > Link: https://lore.kernel.org/all/20230404-hatred-swimmer-6fecdf33b57a@sp= ud/ > Signed-off-by: Pierre Gondois > --- > drivers/base/cacheinfo.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) >=20 > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > index e7ad6aba5f97..6749dc6ebf50 100644 > --- a/drivers/base/cacheinfo.c > +++ b/drivers/base/cacheinfo.c > @@ -78,6 +78,9 @@ bool last_level_cache_is_shared(unsigned int cpu_x, uns= igned int cpu_y) > } > =20 > #ifdef CONFIG_OF > + > +static bool of_check_cache_nodes(struct device_node *np); > + > /* OF properties to query for a given cache type */ > struct cache_type_info { > const char *size_prop; > @@ -205,6 +208,11 @@ static int cache_setup_of_node(unsigned int cpu) > return -ENOENT; > } > =20 > + if (!of_check_cache_nodes(np)) { > + of_node_put(np); > + return -ENOENT; > + } > + > prev =3D np; > =20 > while (index < cache_leaves(cpu)) { > @@ -229,6 +237,25 @@ static int cache_setup_of_node(unsigned int cpu) > return 0; > } > =20 > +static bool of_check_cache_nodes(struct device_node *np) > +{ > + struct device_node *next; > + > + if (of_property_present(np, "cache-size") || > + of_property_present(np, "i-cache-size") || > + of_property_present(np, "d-cache-size") || > + of_property_present(np, "cache-unified")) > + return true; > + > + next =3D of_find_next_cache_node(np); > + if (next) { > + of_node_put(next); > + return true; > + } > + > + return false; > +} > + > static int of_count_cache_leaves(struct device_node *np) > { > unsigned int leaves =3D 0; > @@ -260,6 +287,9 @@ int init_of_cache_level(unsigned int cpu) > struct device_node *prev =3D NULL; > unsigned int levels =3D 0, leaves, level; > =20 > + if (!of_check_cache_nodes(np)) > + goto err_out; > + > leaves =3D of_count_cache_leaves(np); > if (leaves > 0) > levels =3D 1; > --=20 > 2.25.1 >=20 --tpBqFoyWWsu1/B9s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZDZj6wAKCRB4tDGHoIJi 0gzZAQCtwuxJautzYqFuN7VC/ZYl6n7d0LPrNnGsMKUqwAi5aQEAyhOatu3EX+Mn zZYrA/9ULoFq3teGuZ56XdEU0BrIJAg= =GpdU -----END PGP SIGNATURE----- --tpBqFoyWWsu1/B9s--