Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2370685rdb; Tue, 3 Oct 2023 21:22:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGP1kdbmE14Tp5M7+fM99WuF48hKAiCnx8T5I/nxn24qznAIsGyZdfg8o/BL+0Ljnsu8Njg X-Received: by 2002:a05:6a21:3d8d:b0:15c:b7ba:ebda with SMTP id bj13-20020a056a213d8d00b0015cb7baebdamr1143592pzc.55.1696393361374; Tue, 03 Oct 2023 21:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696393361; cv=none; d=google.com; s=arc-20160816; b=G0Z5C9Bq7bfq+mHMxrOnRzJf8ZXlF2oqVQt5iumUjZdXs/b1PO5QWYQcUZo1o5N0P5 SCgFsYyI/bf2e9weqdw7/fiaCaz4xrVLFZuauaR+dPiyfP6Mpa9Yayl+rUz+onVFcum6 1WzNEFliej2gsgWg7Hqw7nI4OjWgdM0jnFKFUhWMNqe094HpiQgZbsJtuwBEdQgciAkZ bR3KKbmljnDHAPy0u7n9ts6t5yOWioiMkt3eqG20wHoH7FIJb7l/SKP7969eQIEipPAh 6tFqlllZDz7vToLh56vpMkEIPvfHHYJzrInSKuMO5JEIIFvKyR0TfTUyT0AHAXZ+Uf/v BF3w== 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=ew3FEUrbn98SAij00MK4fNBMQRr8yEG76Zxf5H8HMB8=; fh=ri+cUjpZsdrbacbK5/0go0pKBDlJ4l/JiLtKvT7tnpQ=; b=U3wRPohbuKR60eHlTxLKN3y6L2iuyrZ8wQkPfr1EVDPJS+VLCJLWIPpGdzvmMu8ryO aOpkDGvNr7Ri5R/PJ2bj+9lpe8hbcXuI9ty+31EB3K6BlOkiMJw3urFEU4V/c+mb+mD8 od/X6YtJ0d8IrXZqOMunIurz+nUwz/eo7x8Q8Akq++0mAQxM8ojZHZepM/p+JAv7LQTn v+5dinsMC6QhMsJm43yitTS/IXZfZZuQQGyx4ssD/8ryg409zaLr5hwzTs85Ocwvz0M+ tab3ULsqT9BXTP9SXZpTc/11fAALgNoNCTk6hJL+bg/jwydcaPXpCwymnJ4DvKvVpCe7 6eAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PFg32twk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id y1-20020a17090322c100b001b878f9e11csi3220416plg.54.2023.10.03.21.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 21:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PFg32twk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6D7B18325D13; Tue, 3 Oct 2023 21:22:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235435AbjJDEWj (ORCPT + 99 others); Wed, 4 Oct 2023 00:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbjJDEWi (ORCPT ); Wed, 4 Oct 2023 00:22:38 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE528B4 for ; Tue, 3 Oct 2023 21:22:34 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-79f95cd15dfso64251439f.0 for ; Tue, 03 Oct 2023 21:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696393354; x=1696998154; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ew3FEUrbn98SAij00MK4fNBMQRr8yEG76Zxf5H8HMB8=; b=PFg32twk3B3UUIr0qqcv4+HxwBnriAs6AfEE086gKLfKkZlNfmRWdWOrllxpVe68CD dVYWQozUw7ihQEsSZ3WkEPpFBcXvh950oiousZmfxfBUFM0tAls9dQm2Tc3xYsVEBka1 J5LQKdfRv2pVqpUxjVCIaCxY2RnbQjwCrweD0RWVD3DnA35XRWPW7CtbfC8FPaIPQefY mHEf84l8jxxlQ9tWfjNFy5SuFPFtrAG/f5xz3z24stT5Z9CBN3Q6YydQoTZyCGG0+v7B mgHGeIiddSWgeQsUgypUeaFao6ulglYvFb5Xyqns8HtV6mGpBAjwHX4qP45h8A4TP0LX 1ogg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696393354; x=1696998154; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ew3FEUrbn98SAij00MK4fNBMQRr8yEG76Zxf5H8HMB8=; b=RrinS4ZBvsT0a7IqL6TN5h2sH8JnXD4d9MokQB0LFNCfUq1qlj4xHk2exBpXLP4lMU 6i5eTCsewFfJ97HQvgwl6xkiwQeqAYA2VaZp+GBmrnNA+Xd8IE7tdCFDU+XOPFA3o7ES T6GJrniSV1UsuJl/e/ztyNBUDYPZdjSiz8/rrUHei3iWoKHfN1PaqYyzahIJ2SkS2zpB uxZFU1Hy2IJx+qWw6NWfHHmcXKsWVLaKLLZZ4eCEyD40OgIOjGPmEKFKGxOodcc5e2Ru BX9ztKl0LBWz3AWt+nhzzZTrfeiUIlmdxLYw9uSSq/KcbTq0u4aB2IOthTiDnUku3uey rVIQ== X-Gm-Message-State: AOJu0YwEmp08uJU1MP6EgRnpsdCYNOSnS/9kwxiarvDBJyTiNIVXJjIK FbpLlRNGeqVkJ/O9MP4NDB/DkRN1XQyJVbC56fI= X-Received: by 2002:a05:6e02:11ad:b0:352:5e6d:b775 with SMTP id 13-20020a056e0211ad00b003525e6db775mr1028822ilj.27.1696393354243; Tue, 03 Oct 2023 21:22:34 -0700 (PDT) Received: from sunil-laptop ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id x9-20020a92d309000000b00351268dfbd5sm762830ila.57.2023.10.03.21.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 21:22:33 -0700 (PDT) Date: Wed, 4 Oct 2023 09:52:23 +0530 From: Sunil V L To: Samuel Holland Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Anup Patel , Albert Ou , Alexandre Ghiti , "Rafael J . Wysocki" , Daniel Lezcano , Atish Kumar Patra , Andy Shevchenko , Conor Dooley , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Andrew Jones , Ard Biesheuvel , Len Brown Subject: Re: [PATCH v2 -next 3/4] RISC-V: cacheflush: Initialize CBO variables on ACPI systems Message-ID: References: <20230927170015.295232-1-sunilvl@ventanamicro.com> <20230927170015.295232-4-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 21:22:40 -0700 (PDT) On Tue, Oct 03, 2023 at 02:50:02PM -0500, Samuel Holland wrote: > On 2023-09-27 12:00 PM, Sunil V L wrote: > > Using new interface to get the CBO block size information in RHCT, > > initialize the variables on ACPI platforms. > > > > Signed-off-by: Sunil V L > > --- > > arch/riscv/mm/cacheflush.c | 37 +++++++++++++++++++++++++++++++------ > > 1 file changed, 31 insertions(+), 6 deletions(-) > > > > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > > index f1387272a551..8e59644e473c 100644 > > --- a/arch/riscv/mm/cacheflush.c > > +++ b/arch/riscv/mm/cacheflush.c > > @@ -3,7 +3,9 @@ > > * Copyright (C) 2017 SiFive > > */ > > > > +#include > > #include > > +#include > > #include > > > > #ifdef CONFIG_SMP > > @@ -124,15 +126,38 @@ void __init riscv_init_cbo_blocksizes(void) > > unsigned long cbom_hartid, cboz_hartid; > > u32 cbom_block_size = 0, cboz_block_size = 0; > > struct device_node *node; > > + struct acpi_table_header *rhct; > > + acpi_status status; > > + unsigned int cpu; > > + > > + if (!acpi_disabled) { > > + status = acpi_get_table(ACPI_SIG_RHCT, 0, &rhct); > > + if (ACPI_FAILURE(status)) > > + return; > > + } > > > > - for_each_of_cpu_node(node) { > > - /* set block-size for cbom and/or cboz extension if available */ > > - cbo_get_block_size(node, "riscv,cbom-block-size", > > - &cbom_block_size, &cbom_hartid); > > - cbo_get_block_size(node, "riscv,cboz-block-size", > > - &cboz_block_size, &cboz_hartid); > > + for_each_possible_cpu(cpu) { > > + if (acpi_disabled) { > > + node = of_cpu_device_node_get(cpu); > > + if (!node) { > > + pr_warn("Unable to find cpu node\n"); > > + continue; > > + } > > + > > + /* set block-size for cbom and/or cboz extension if available */ > > + cbo_get_block_size(node, "riscv,cbom-block-size", > > + &cbom_block_size, &cbom_hartid); > > + cbo_get_block_size(node, "riscv,cboz-block-size", > > + &cboz_block_size, &cboz_hartid); > > This leaks a reference to the device node. > Yep!. I missed of_node_put(). Let me add in next revision. Thanks! > > + } else { > > + acpi_get_cbo_block_size(rhct, cpu, &cbom_block_size, > > + &cboz_block_size, NULL); > > This function loops through the whole RHCT already. Why do we need to call it > for each CPU? Can't we just call it once, and have it do the same consistency > checks as cbo_get_block_size()? > > In that case, the DT path could keep the for_each_of_cpu_node() loop. > I kept the same logic as DT. Basically, by passing the cpu node, we will fetch the exact CPU's CBO property from RHCT. It is not clear to me why we overwrite the same variable with value from another cpu and whether we can return as soon as we get the CBO size for one CPU. Drew, can we exit the loop if we get the CBO size for one CPU? Thanks! Sunil