Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2459026rdb; Wed, 4 Oct 2023 01:33:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK/uwQjK8jE4Vfq+j7gES9mmWJ03uAklxwhAj+auUGmptG9WAh1Z+RurE17ztWly8j3IgE X-Received: by 2002:a17:902:ea09:b0:1c8:7bb8:321a with SMTP id s9-20020a170902ea0900b001c87bb8321amr511217plg.27.1696408430375; Wed, 04 Oct 2023 01:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696408430; cv=none; d=google.com; s=arc-20160816; b=dgoJ8gEVxbGLaOI8/mozVHcYvd6u+7Ng0Hldn5pqviXqjxCoHA34QYryWEHHAPdgiw 4uD5CHGeXTMm+5HWFAQbXAX7xb8rmSAGkJpU8bgDv8cGHJkrf/NjuQnpthqhK7Quhf61 CYLujEWoY9iC0g/6rnZzH8Pt2EpRxZo4M61wiAc0QbOWQHwPzrpuWQXtWql0jdm7EdzJ QQmOg7c9NidzVrYXbN4RV/B84haoL/Yhbg/ZlIJJfdDhtsT/sd2K94ArIhXsotb0bONw oe8Zep9AVtFXr/rz9vVa2PbGhszGpRJ2uuTD/33pz2JPOZvRRnVMDAaXZYnYyr2KiTqv 1DhA== 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=ESJK41d6OgR3seh2ygAk4MlFIHKl40A8SsuP64iwTcA=; fh=K0MUMRrOEswQxRuCTrqfQerdnw2/cgCzVOWKZ6CXqLc=; b=ZqN4SpShOz+H7K+EdOhjvWC06xPTXM0KDKCt2N5NBvc3+Xw4LdSEWsx8DrvoEP3wXJ b4nP9KaLNxdBTYYXlCO9FxWMcLan7nx8EDjwIXIB191HI7BcOowFOpJVhm4yJkoaZwz/ Pe3Gemw+5wpEOtL1AVDPkV/4a90Xq54dYjyAMURyMX7AYlipRGvYw8JIx231IKWS+bQI ffwjtxEiNJTACgnQuONhzrXuG0EaNmQk0nUJQpVQbUxBJ2kOtLLo+yKrx4Uuixl1apk9 P0r2wlhVG6EfHerbBIZOh/Q5SXI/LVm1rGGvWO0Zo2SZAmAvVxHovFVn5RD1u3MQ1/66 5QiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jYhf+MF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id cp6-20020a170902e78600b001c0cb378f04si3173845plb.335.2023.10.04.01.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=jYhf+MF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 4A60281A05A5; Wed, 4 Oct 2023 01:33:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241697AbjJDIdk (ORCPT + 99 others); Wed, 4 Oct 2023 04:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241688AbjJDIdj (ORCPT ); Wed, 4 Oct 2023 04:33:39 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFFBEC9 for ; Wed, 4 Oct 2023 01:33:34 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-538e8eca9c1so367782a12.3 for ; Wed, 04 Oct 2023 01:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696408413; x=1697013213; 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=ESJK41d6OgR3seh2ygAk4MlFIHKl40A8SsuP64iwTcA=; b=jYhf+MF52bILhuLEoUu1mLqPNjCIC+W+TJae5eYCN0nlEZeim8Jzpctr6k6U7WGmyw 15oWtSpHGF7Njob+3o+7WTgaJn4FfS2FiE7LQntORR5qkPeyNnELyFd0fOkzINWW9QrH C9Xlw92txGykMY+FyRfXzJZEq1SgvCf+idYYWCn32JbNeymJPb8gvwEOgaaT4tZb2pur 7xOe0rFPB0ADTZbca0PEnPpT3Ep1oBpOLNIVhzi8DYH/SzNXmR/sDgmWzwZidXLUdYuk +iWRyy8PtllPa9O8VFIO6KIJN328mYIkYBEK38G/1GIIe7ye6BLo030clbtTyVauHTt+ 88tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696408413; x=1697013213; 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=ESJK41d6OgR3seh2ygAk4MlFIHKl40A8SsuP64iwTcA=; b=eZ+YHduPARYHKgi4BmNrb1FUqEkgbgnA7ErC61t+Dp14ssTC/rGlO7rZ8uckI/pI4j wxbuJBhx9B1gWC2Hbyr1k0oB8MZNg+62dQPx6LfKuIS5sPdF3ufqxzlU/MgnsRoBlzlc P5woKjnDQDXVcg280OtxDXWlq+udmo7YnAXFPoKR3DFX9H4sqqKvf67B6BefV86H6Owb CcaeZrlFwvO/mBtdowmusAp4y0QYyLPgKj4R/c1fc9gMXIqNMSPUktrXF80zKluFLxd3 o937LAdXNMXGLK6hVNUhZM4OvzvCIoLhRejv/9vEf95kH/pPhC3r22mv4Wqh7mVsAEPz 0Cqw== X-Gm-Message-State: AOJu0YyCxpqft9B+oSYzcqRX+/g4KdG3GT5TLUIJ/b6MDuTsrTJL7abH h5MFV0E5hus5oWWqf8aWWQLfyQ== X-Received: by 2002:a05:6402:1843:b0:522:580f:8c75 with SMTP id v3-20020a056402184300b00522580f8c75mr1245485edy.17.1696408412466; Wed, 04 Oct 2023 01:33:32 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id w9-20020aa7dcc9000000b00537708be5c6sm2069890edu.73.2023.10.04.01.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:33:32 -0700 (PDT) Date: Wed, 4 Oct 2023 10:33:31 +0200 From: Andrew Jones To: Sunil V L Cc: Samuel Holland , 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 , Ard Biesheuvel , Len Brown Subject: Re: [PATCH v2 -next 3/4] RISC-V: cacheflush: Initialize CBO variables on ACPI systems Message-ID: <20231004-58af76b11b3db2e64a93fd55@orel> 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=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 01:33:47 -0700 (PDT) On Wed, Oct 04, 2023 at 09:52:23AM +0530, Sunil V L wrote: > 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? We want to compare the values for each CPU with the first one we find in order to ensure they are consistent. I think Samuel is suggesting that we leave the DT path here the same, i.e. keep the for_each_of_cpu_node() loop, and then change acpi_get_cbo_block_size() to *not* take a cpu as input, but rather follow the same pattern as DT, which is to loop over all cpus doing a consistency check against the first cpu's CBO info. Thanks, drew