Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3596911rwb; Tue, 8 Nov 2022 06:24:13 -0800 (PST) X-Google-Smtp-Source: AMsMyM6Xm538zhM21C4dQpgu7y1VFaxik/iBQryCtbQLGhwcwulR6Y1h/lRMJn12dRonn/xlP+Xh X-Received: by 2002:a17:90b:400d:b0:213:be60:b0d2 with SMTP id ie13-20020a17090b400d00b00213be60b0d2mr54888423pjb.75.1667917452813; Tue, 08 Nov 2022 06:24:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667917452; cv=none; d=google.com; s=arc-20160816; b=xwiWu8MIeTaSnwI2hdMLE1RmHJTIdhG4zEXmtM2kWjHufdWZZ5IVYIKld4sVm/Z6Dq PSoV5NaHva6goLxi9ecMVe3tpCAFXCmqpLd+OfkIpc7VyCIEsXjjXmJpU2XsgkecBrn1 e62KgxeIKP2rgeC0t3xqErzOuTDh5GCPJWmVN7LqnmKEDVXbB47ha4w6c3Vmk2qSjKp/ +aKbSoQywuNSxQuKlRlfrAKKRjnA6cacOLzMEuTHkXD98noH7jsiz9bPzc7ABBLB0CRm S62opXmvzmg9WgHpnpa25YAywNA+jAgWkovetlFFHG46o0ooesxCN6N4JZcCgGp0N2lL oL4w== 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=jHHULPp2QOzSWgCBRRmi0oacznM0OAhUZ/bbwDcCgvk=; b=CsGpp/F5gLlEklle7j7XI0LJ9+k0k+JDguuEkKlrfRvi7vneeg4WV0MeS7N9ls4Qsl lk+qS0AQPoOqSueju7rAHhsJUPG/F7WoxkefqI+c8/fkVAtcTEgY0OLYL6qcbdVv/PnT 0oX1Wj4OdtPzphNqF+txlmt2H5WV63kwYSNTfURclr5oUSvBmIHTo3KYnJcpW8qd/w0m m6LsIn1zCIu9ATTvemSOdvuxqEy0PvrvlSM6WqjgYU8Eja9oEup/n93RkcmJhu30HRJn U+LwHo4P0kxiesHcJj47gz/iXuMfcrblfbN5QZNu6xmVMUHFhhJ4csYFTSmZdMHOXhTr dXNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=1JPjPzwP; 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 ik9-20020a170902ab0900b00176a8746df6si12902113plb.433.2022.11.08.06.24.00; Tue, 08 Nov 2022 06:24:12 -0800 (PST) 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=1JPjPzwP; 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 S235145AbiKHOIT (ORCPT + 90 others); Tue, 8 Nov 2022 09:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbiKHOIC (ORCPT ); Tue, 8 Nov 2022 09:08:02 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720D870571; Tue, 8 Nov 2022 06:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1667916481; x=1699452481; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=xOw7QIJLsuxkX05KFxFMzYRYL4KbLRoTNIigZpHSnz8=; b=1JPjPzwPDkiTcntCM6W7ih29NJEyYuaTFVpLN/S0ItOZKFLbUxk+N5EW EhkkpP7jmiUReU1y9Qq0SR+DetG4dDyuWffI96F7j55ewXVqoA1AxdfLd B+Vtw0Owcg/lDgyN1Ya8+/yt0GoEKATrRWak/d+JnKPEsJJ+rc/jsmOER 8PDakYlUzi75iBSHHyfj97D347mRZvKzegg7DsvnKVGWyVhIcn+h5dMtE 4RJPon1w0C94bIh8mFamzjLVmCmhoZqXIyCMHm6thlgKp0XUPmnwBZIge g1tOhOsLrb1G7conEs70Z66X9N8LzVICVMp8sbrxjP0jDN06MIzNtZZP/ Q==; X-IronPort-AV: E=Sophos;i="5.96,147,1665471600"; d="scan'208";a="198904540" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 08 Nov 2022 07:08:00 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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.12; Tue, 8 Nov 2022 07:08:00 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12 via Frontend Transport; Tue, 8 Nov 2022 07:07:57 -0700 Date: Tue, 8 Nov 2022 14:07:41 +0000 From: Conor Dooley To: Pierre Gondois CC: , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J. Wysocki" , Len Brown , Sudeep Holla , Greg Kroah-Hartman , Gavin Shan , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Jani Nikula , Jakub Kicinski , , , Subject: Re: [PATCH 1/5] cacheinfo: Use riscv's init_cache_level() as generic OF implem Message-ID: References: <20221108110424.166896-1-pierre.gondois@arm.com> <20221108110424.166896-2-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20221108110424.166896-2-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 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 On Tue, Nov 08, 2022 at 12:04:17PM +0100, Pierre Gondois wrote: > Riscv's implementation of init_of_cache_level() is following heh, "Riscv" always looks a bit odd! Code movement looks fine, nothing surface level is broken on RISC-V. Reviewed-by: Conor Dooley > the Devicetree Specification v0.3 regarding caches, cf.: > - s3.7.3 'Internal (L1) Cache Properties' > - s3.8 'Multi-level and Shared Cache Nodes' > > Allow reusing the implementation by moving it. > > Signed-off-by: Pierre Gondois > --- > arch/riscv/kernel/cacheinfo.c | 39 +------------------------------ > drivers/base/cacheinfo.c | 44 +++++++++++++++++++++++++++++++++++ > include/linux/cacheinfo.h | 1 + > 3 files changed, 46 insertions(+), 38 deletions(-) > > diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c > index 90deabfe63ea..440a3df5944c 100644 > --- a/arch/riscv/kernel/cacheinfo.c > +++ b/arch/riscv/kernel/cacheinfo.c > @@ -115,44 +115,7 @@ static void fill_cacheinfo(struct cacheinfo **this_leaf, > > int init_cache_level(unsigned int cpu) > { > - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); > - struct device_node *np = of_cpu_device_node_get(cpu); > - struct device_node *prev = NULL; > - int levels = 0, leaves = 0, level; > - > - if (of_property_read_bool(np, "cache-size")) > - ++leaves; > - if (of_property_read_bool(np, "i-cache-size")) > - ++leaves; > - if (of_property_read_bool(np, "d-cache-size")) > - ++leaves; > - if (leaves > 0) > - levels = 1; > - > - prev = np; > - while ((np = of_find_next_cache_node(np))) { > - of_node_put(prev); > - prev = np; > - if (!of_device_is_compatible(np, "cache")) > - break; > - if (of_property_read_u32(np, "cache-level", &level)) > - break; > - if (level <= levels) > - break; > - if (of_property_read_bool(np, "cache-size")) > - ++leaves; > - if (of_property_read_bool(np, "i-cache-size")) > - ++leaves; > - if (of_property_read_bool(np, "d-cache-size")) > - ++leaves; > - levels = level; > - } > - > - of_node_put(np); > - this_cpu_ci->num_levels = levels; > - this_cpu_ci->num_leaves = leaves; > - > - return 0; > + return init_of_cache_level(cpu); > } > > int populate_cache_leaves(unsigned int cpu) > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > index 4b5cd08c5a65..a4308b48dd3e 100644 > --- a/drivers/base/cacheinfo.c > +++ b/drivers/base/cacheinfo.c > @@ -224,8 +224,52 @@ static int cache_setup_of_node(unsigned int cpu) > > return 0; > } > + > +int init_of_cache_level(unsigned int cpu) > +{ > + struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); > + struct device_node *np = of_cpu_device_node_get(cpu); > + struct device_node *prev = NULL; > + int levels = 0, leaves = 0, level; > + > + if (of_property_read_bool(np, "cache-size")) > + ++leaves; > + if (of_property_read_bool(np, "i-cache-size")) > + ++leaves; > + if (of_property_read_bool(np, "d-cache-size")) > + ++leaves; > + if (leaves > 0) > + levels = 1; > + > + prev = np; > + while ((np = of_find_next_cache_node(np))) { > + of_node_put(prev); > + prev = np; > + if (!of_device_is_compatible(np, "cache")) > + break; > + if (of_property_read_u32(np, "cache-level", &level)) > + break; > + if (level <= levels) > + break; > + if (of_property_read_bool(np, "cache-size")) > + ++leaves; > + if (of_property_read_bool(np, "i-cache-size")) > + ++leaves; > + if (of_property_read_bool(np, "d-cache-size")) > + ++leaves; > + levels = level; > + } > + > + of_node_put(np); > + this_cpu_ci->num_levels = levels; > + this_cpu_ci->num_leaves = leaves; > + > + return 0; > +} > + > #else > static inline int cache_setup_of_node(unsigned int cpu) { return 0; } > +int init_of_cache_level(unsigned int cpu) { return 0; } > #endif > > int __weak cache_setup_acpi(unsigned int cpu) > diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h > index 00b7a6ae8617..ff0328f3fbb0 100644 > --- a/include/linux/cacheinfo.h > +++ b/include/linux/cacheinfo.h > @@ -80,6 +80,7 @@ struct cpu_cacheinfo { > > struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu); > int init_cache_level(unsigned int cpu); > +int init_of_cache_level(unsigned int cpu); > int populate_cache_leaves(unsigned int cpu); > int cache_setup_acpi(unsigned int cpu); > bool last_level_cache_is_valid(unsigned int cpu); > -- > 2.25.1 >