Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1058542rwi; Wed, 19 Oct 2022 06:18:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7NYQErqMhqKABv7JUSKMRD0OFPpvUp9duMRSrM0VDI4aKjVovQDg1EN/ffUQ5B628YE1kt X-Received: by 2002:a05:6402:11ce:b0:45c:a364:2c3d with SMTP id j14-20020a05640211ce00b0045ca3642c3dmr7608218edw.204.1666185525191; Wed, 19 Oct 2022 06:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666185525; cv=none; d=google.com; s=arc-20160816; b=QW9uv6JajMG3kxCdoE+QLC5sdeEGk+ancwqOY23oKrJGYwiKlae6Z9VcbEp4xJoGyS wBLL820v/6eVrgauCRoTTdBLD3QI5xk4XY9S5XljGuwamjoH7N52nOJ3v/gRohe0OK/0 W48TumFBqRPm4bt5YvK7p8PT0NW1n0jgL4K/QsnxowhE07qVg1YHXEADDREtduIMnK91 xTEPzoqiz5E4G3uq6XjoKJsYjPiWhsYADUfJ7N1NUPhWOi+XQDmE5XoxCpEUxMMwbynP iOLQhuADWAM6lO4e+SvgAe4rDYNymOayPsP8L88Ri/fNAhWtL0884EesF/YyVERaxO9U UYBA== 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=KVjTmEpIVxVI1QjjOVEaR6dUBmxfAeeooc7yUeODigc=; b=K6zzEi4NPSgNEUpsQz5PcTM79NT0+Zv4fmNFV/upU39ZlWcEr8UA5+a1UhHZ1OmrgY qjIBvE08W/BkH5rXsBXFFQld2u2Yw7PR/hUmJlpzRICwrhqVfo3mJ3C3Ln8NzkZHIoMi 7Qt5k/qhQtZBDx3UHVcQv2UZ/rNFYgUZ+uhHrm8WZ2NZi+C6jnY/pUbn4mrflp94hycy WuxnTCf307BdqW/Sgugg/aM506x1cJbeXiN+mjk/mgkiPKP3keqoUZEbrIB/KgMpA9vV 8M4zniSiPUZtBL5JhdflGuwHy5PnWFfaj1Ual3+E/WIkdj0ch72CdnEiGYUGXUESn1zB T7RQ== 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 c8-20020a50d648000000b004597fa7ee6csi13089778edj.108.2022.10.19.06.18.19; Wed, 19 Oct 2022 06:18:45 -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 S233446AbiJSMuO (ORCPT + 99 others); Wed, 19 Oct 2022 08:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233620AbiJSMtN (ORCPT ); Wed, 19 Oct 2022 08:49:13 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3BE15E657 for ; Wed, 19 Oct 2022 05:31:54 -0700 (PDT) Received: from p508fdae2.dip0.t-ipconnect.de ([80.143.218.226] helo=phil.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 1ol8Dj-0005cC-Eg; Wed, 19 Oct 2022 14:30:51 +0200 From: Heiko Stuebner To: Palmer Dabbelt , Paul Walmsley , Anup Patel Cc: Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Jones , kernel test robot , Anup Patel , Conor Dooley Subject: Re: [PATCH v3 1/4] RISC-V: Fix compilation without RISCV_ISA_ZICBOM Date: Wed, 19 Oct 2022 14:30:50 +0200 Message-ID: <5869751.lOV4Wx5bFT@phil> In-Reply-To: <20221019121622.179024-2-apatel@ventanamicro.com> References: <20221019121622.179024-1-apatel@ventanamicro.com> <20221019121622.179024-2-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_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 Anup, Am Mittwoch, 19. Oktober 2022, 14:16:19 CEST schrieb Anup Patel: > From: Andrew Jones > > riscv_cbom_block_size and riscv_init_cbom_blocksize() should always > be available and riscv_init_cbom_blocksize() should always be > invoked, even when compiling without RISCV_ISA_ZICBOM enabled. This > is because disabling RISCV_ISA_ZICBOM means "don't use zicbom > instructions in the kernel" not "pretend there isn't zicbom, even > when there is". When zicbom is available, whether the kernel enables > its use with RISCV_ISA_ZICBOM or not, KVM will offer it to guests. > Ensure we can build KVM and that the block size is initialized even > when compiling without RISCV_ISA_ZICBOM. either I'm way very low on coffee or something is strange here :-) . I can fully grasp the need to init the cbom blocksize for guests, even when the main kernel isn't using it, but below in the patch itself it is still: +#ifdef CONFIG_RISCV_ISA_ZICBOM +void riscv_init_cbom_blocksize(void) +{ [...] so the init_cbom_blocksize function is still inside a RISCV_ISA_ZICBOM ifdef? Heiko > > Fixes: 8f7e001e0325 ("RISC-V: Clean up the Zicbom block size probing") > Reported-by: kernel test robot > Signed-off-by: Andrew Jones > Signed-off-by: Anup Patel > Reviewed-by: Conor Dooley > --- > arch/riscv/mm/cacheflush.c | 41 +++++++++++++++++++++++++++++++++ > arch/riscv/mm/dma-noncoherent.c | 41 --------------------------------- > 2 files changed, 41 insertions(+), 41 deletions(-) > > diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c > index 6cb7d96ad9c7..f318b2553612 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,42 @@ void flush_icache_pte(pte_t pte) > flush_icache_all(); > } > #endif /* CONFIG_MMU */ > + > +unsigned int riscv_cbom_block_size; > +EXPORT_SYMBOL_GPL(riscv_cbom_block_size); > + > +#ifdef CONFIG_RISCV_ISA_ZICBOM > +void riscv_init_cbom_blocksize(void) > +{ > + struct device_node *node; > + unsigned long cbom_hartid; > + u32 val, probed_block_size; > + int ret; > + > + probed_block_size = 0; > + for_each_of_cpu_node(node) { > + unsigned long hartid; > + > + ret = riscv_of_processor_hartid(node, &hartid); > + if (ret) > + continue; > + > + /* set block-size for cbom extension if available */ > + ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); > + if (ret) > + continue; > + > + if (!probed_block_size) { > + probed_block_size = val; > + cbom_hartid = hartid; > + } else { > + if (probed_block_size != val) > + pr_warn("cbom-block-size mismatched between harts %lu and %lu\n", > + cbom_hartid, hartid); > + } > + } > + > + if (probed_block_size) > + riscv_cbom_block_size = probed_block_size; > +} > +#endif > diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-noncoherent.c > index b0add983530a..d919efab6eba 100644 > --- a/arch/riscv/mm/dma-noncoherent.c > +++ b/arch/riscv/mm/dma-noncoherent.c > @@ -8,13 +8,8 @@ > #include > #include > #include > -#include > -#include > #include > > -unsigned int riscv_cbom_block_size; > -EXPORT_SYMBOL_GPL(riscv_cbom_block_size); > - > static bool noncoherent_supported; > > void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, > @@ -77,42 +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; > - unsigned long cbom_hartid; > - u32 val, probed_block_size; > - int ret; > - > - probed_block_size = 0; > - for_each_of_cpu_node(node) { > - unsigned long hartid; > - > - ret = riscv_of_processor_hartid(node, &hartid); > - if (ret) > - continue; > - > - /* set block-size for cbom extension if available */ > - ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); > - if (ret) > - continue; > - > - if (!probed_block_size) { > - probed_block_size = val; > - cbom_hartid = hartid; > - } else { > - if (probed_block_size != val) > - pr_warn("cbom-block-size mismatched between harts %lu and %lu\n", > - cbom_hartid, hartid); > - } > - } > - > - if (probed_block_size) > - riscv_cbom_block_size = probed_block_size; > -} > -#endif > - > void riscv_noncoherent_supported(void) > { > WARN(!riscv_cbom_block_size, >