Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp863020rwe; Thu, 1 Sep 2022 08:42:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR7EUhoKgesKVQgjLpqxpDR9e7DcisTsgvCdVt8khfxAyZ3i4EZHLTL2gJuhskrouP6HnFYy X-Received: by 2002:a05:6402:378f:b0:43a:d3f5:79f2 with SMTP id et15-20020a056402378f00b0043ad3f579f2mr29622201edb.338.1662046968762; Thu, 01 Sep 2022 08:42:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662046968; cv=none; d=google.com; s=arc-20160816; b=nPDQE2fWBhUI93Yh9H7T+WD3Id90Xb44noXGuHaO4xMJw6nT/9WaFSEV9dffVG/FkE bnj8cPfyjr+AFP/KgfLqRy9Eg04dANmn4GHQ5qrFJM9z45WG7RSTXYOg7j4IJH+wT70k jkMe/FuzpwWFhuUe04jYpF8va/8OEVu1MHB7j+8WoDeeFJp4I4rWkM2QOB/cSE2/KrL4 KCXdozPOoaR/B+MwX64E1Eneugfw1AOr5i+altJOKQvW5GRtfJsKz5x8j9laylfBGGdw fvnU6/e/+8+uFWm3CabfGghEq10OY12hBJg/MQAeo+fZwAcEytMIFd5jpSXvwRuMlEWv 8AAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/VmZlnX4lhSsBP5CHX6cJv3DinNHpMlF6SesXQ2VpPc=; b=tu4jrAXsnyZTxQ3J68VFRHMLsxiT30hrLDh3bKFkpKP7tNKvLBFE43lR0qlwIqA/td Tf31kI+WtwyAWHVRB3tQxsf9lt4SryEh2SLB0XrKSXD5e7+Z2Tagfm8aYnXnVidphayP EURBjlxJfGMkWiBeMNrFeSFk7fRgcKiGd2fbUvc+X1SbzsjvEkhdff7wui96q1cmSEkC LtevOtj4ASiCj2nYmJkVk1W+4AS9CWneKKPCtiMWqGZj5kgiMsuNSeqrrWhNy0nN8rpc Bd73OBeIkHn9x3UrBrkGubEStxvrZKZURYkcyfXuj5Lgk4FDUKgTE3uSVaft7KpfblLb /AZA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a056402440f00b00448a15e3cc0si2541317eda.161.2022.09.01.08.42.22; Thu, 01 Sep 2022 08:42:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234476AbiIAP3n (ORCPT + 99 others); Thu, 1 Sep 2022 11:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbiIAP3b (ORCPT ); Thu, 1 Sep 2022 11:29:31 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE7208A1D4 for ; Thu, 1 Sep 2022 08:29:23 -0700 (PDT) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oTm7o-0005k8-P8; Thu, 01 Sep 2022 17:29:00 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Palmer Dabbelt , Paul Walmsley , Anup Patel Cc: Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Mayuresh Chitale Subject: Re: [PATCH v2 2/4] RISC-V: Move riscv_init_cbom_blocksize() to cacheflush.c Date: Thu, 01 Sep 2022 17:29:00 +0200 Message-ID: <5909904.6fTUFtlzNn@diego> In-Reply-To: <20220830044642.566769-3-apatel@ventanamicro.com> References: <20220830044642.566769-1-apatel@ventanamicro.com> <20220830044642.566769-3-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR 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 Hi, Am Dienstag, 30. August 2022, 06:46:40 CEST schrieb Anup Patel: > The riscv_cbom_block_size parsing from DT belongs to cacheflush.c which > is home for all cache maintenance related stuff so let us move the > riscv_init_cbom_blocksize() and riscv_cbom_block_size to cacheflush.c. > > Co-developed-by: Mayuresh Chitale > Signed-off-by: Mayuresh Chitale > Signed-off-by: Anup Patel Makes a lot of sense to keep stuff together. Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner Also, can we handle this as fix patch? I.e. Currently the t-head code somewhat relies on the default value set to L1_CACHE_BYTES. The cache-block-size is static there. Palmers upcoming patch reworking the parsing [0], will remove that default, so having the riscv_cbom_block_size defined in the cacheflush header will allow an easy fix by setting that value from the t-head errata init for those cores. Heiko [0] https://lore.kernel.org/r/20220812154010.18280-1-palmer@rivosinc.com > --- > arch/riscv/include/asm/cacheflush.h | 2 ++ > arch/riscv/mm/cacheflush.c | 39 +++++++++++++++++++++++++++++ > arch/riscv/mm/dma-noncoherent.c | 38 ---------------------------- > 3 files changed, 41 insertions(+), 38 deletions(-) > > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index a60acaecfeda..de55d6b8deeb 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -42,6 +42,8 @@ void flush_icache_mm(struct mm_struct *mm, bool local); > > #endif /* CONFIG_SMP */ > > +extern unsigned int riscv_cbom_block_size; > + > #ifdef CONFIG_RISCV_ISA_ZICBOM > void riscv_init_cbom_blocksize(void); > #else > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > index 6cb7d96ad9c7..336c5deea870 100644 > --- a/arch/riscv/mm/cacheflush.c > +++ b/arch/riscv/mm/cacheflush.c > @@ -3,6 +3,8 @@ > * Copyright (C) 2017 SiFive > */ > > +#include > +#include > #include > > #ifdef CONFIG_SMP > @@ -86,3 +88,40 @@ void flush_icache_pte(pte_t pte) > flush_icache_all(); > } > #endif /* CONFIG_MMU */ > + > +unsigned int riscv_cbom_block_size = L1_CACHE_BYTES; > + > +#ifdef CONFIG_RISCV_ISA_ZICBOM > +void riscv_init_cbom_blocksize(void) > +{ > + struct device_node *node; > + int ret; > + u32 val; > + > + for_each_of_cpu_node(node) { > + unsigned long hartid; > + int cbom_hartid; > + > + ret = riscv_of_processor_hartid(node, &hartid); > + if (ret) > + continue; > + > + if (hartid < 0) > + continue; > + > + /* set block-size for cbom extension if available */ > + ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); > + if (ret) > + continue; > + > + if (!riscv_cbom_block_size) { > + riscv_cbom_block_size = val; > + cbom_hartid = hartid; > + } else { > + if (riscv_cbom_block_size != val) > + pr_warn("cbom-block-size mismatched between harts %d and %lu\n", > + cbom_hartid, hartid); > + } > + } > +} > +#endif > diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-noncoherent.c > index cd2225304c82..3f502a1a68b1 100644 > --- a/arch/riscv/mm/dma-noncoherent.c > +++ b/arch/riscv/mm/dma-noncoherent.c > @@ -8,11 +8,8 @@ > #include > #include > #include > -#include > -#include > #include > > -static unsigned int riscv_cbom_block_size = L1_CACHE_BYTES; > static bool noncoherent_supported; > > void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, > @@ -75,41 +72,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, > dev->dma_coherent = coherent; > } > > -#ifdef CONFIG_RISCV_ISA_ZICBOM > -void riscv_init_cbom_blocksize(void) > -{ > - struct device_node *node; > - int ret; > - u32 val; > - > - for_each_of_cpu_node(node) { > - unsigned long hartid; > - int cbom_hartid; > - > - ret = riscv_of_processor_hartid(node, &hartid); > - if (ret) > - continue; > - > - if (hartid < 0) > - continue; > - > - /* set block-size for cbom extension if available */ > - ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); > - if (ret) > - continue; > - > - if (!riscv_cbom_block_size) { > - riscv_cbom_block_size = val; > - cbom_hartid = hartid; > - } else { > - if (riscv_cbom_block_size != val) > - pr_warn("cbom-block-size mismatched between harts %d and %lu\n", > - cbom_hartid, hartid); > - } > - } > -} > -#endif > - > void riscv_noncoherent_supported(void) > { > noncoherent_supported = true; >