Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1062564rwi; Wed, 19 Oct 2022 06:21:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57JsqsgDuxOY0Rw6c64X7GD0gsHqAjhJkUeL0IKqvl6WFf296p6RUDPO/tXarAdGEZ3rvU X-Received: by 2002:a17:906:eec1:b0:782:6384:76be with SMTP id wu1-20020a170906eec100b00782638476bemr6754732ejb.756.1666185680569; Wed, 19 Oct 2022 06:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666185680; cv=none; d=google.com; s=arc-20160816; b=ZsjuS/Su1zba0rscNGmZTHpKzRrZbgULr7kEkqKQ7cU4Xo0oLuFxWI0hMozxjEZ/FE N+oYuW3uGkfLXydbm6ps+Av0s/JbDVcDp821y0o0vmJ7tRlIH7HDPUfVVepsWoth3mK6 UTRMHu0XuxThNBS+UATBBqrJm14lIAJzj7FrWPb6Wgbrec/X+aim3aYBBbOQP3+GX25u bH3+JeTNMiNkwngw4rnkdadqCYnyKJsnAYCdb73TDv8h97u5slSPs+rkNxF3kCJ+tfDW AhUhyL5e03lVcSwIC28Dg9REiWvW2w6WzbcGC9WmaSrTuP+1ppHHodwJsGauyssbT2Lq 45Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oYN264dQZ8nr4oIPkUkzpYJVPgC0y1gnv/lMRuwW2jE=; b=EqtvuqgpAN6Bi05CBRunTBzmogjXZzLpvhofswHQWLctyHmRc7gsLSE+yvFb9B8mni DGGi8pWEM1QU8JwIJlikWwBBDwsA5Tz+h8heGrYrzEydSlF+N7oWqJ8mVblizsESS538 NVFKrgiVW3E1EXZJpho5oRcwrfKSegko7L5JT7ABqEfohkciyf/XIpZASQBG04jNpB0i qQLV/BXGLzPJidL/dZxxflcOpJC0cgqhXYWdS4ABd3LFpUhYfzYnoe1PhVGB8pHIrqhS zRNttEreV24Y5skEBp807M2ZSiik+09CnmvOrbztu5ewwxIrbaR/NuZBMbOpQNyaCuse umUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Zs+cwTqR; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cf20-20020a170906b2d400b0078043d1e9fbsi10720377ejb.354.2022.10.19.06.20.52; Wed, 19 Oct 2022 06:21:20 -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; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Zs+cwTqR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232789AbiJSMyq (ORCPT + 99 others); Wed, 19 Oct 2022 08:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233700AbiJSMyR (ORCPT ); Wed, 19 Oct 2022 08:54:17 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7496981126 for ; Wed, 19 Oct 2022 05:37:22 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id be13so12222470lfb.4 for ; Wed, 19 Oct 2022 05:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oYN264dQZ8nr4oIPkUkzpYJVPgC0y1gnv/lMRuwW2jE=; b=Zs+cwTqRv3wsVXoxiS5bQeSD4Ce0xvVSTIvcUm9QZfLJ6SO7YHqwWqJl7Wa3DL8RSS n0dr67t6CBQYCtayX/KqWHUsphREEIFbvqVBOPVOR4NDt38eP9kFQl2HZfpracREfht7 /5vDDtMutFZkiduO0IzNJiyoYc6EUb0kbUUljaBE1PGsub9WyyTmHlhANP2BLCa+PYfN X7tiAi1wEKlI2BAGfTyr9lk9fwPNjV3NyDvs3Xc0nl0EoygfBEK5w3+kyFUvNgg5GjLU xlJj6sSfYx0BEzmbcv+Iy1pK/dM6NjzNGqlRxOZCNXlTAbVhvf+ax5j6XljeAiCMYxKP 17Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oYN264dQZ8nr4oIPkUkzpYJVPgC0y1gnv/lMRuwW2jE=; b=t0nd04X9d0uEW0Y3NceoncamvHz73rR96tb30xbwcPAmYQOq7XAGQzIXITDvXVFQlg sKijGqT/jgi838rJg7kYuZxC9Puo8od32JKH6Bhpjwf/rcKgC4U2TOFw5k6zKdXwstHJ 3UXYh7+/FWykA5808gUNDZnwmGx4HEyz7abU/Vw1+sLkFP/ohEg1UpITmjSKbeFpUO3W /rzOK74MRPH1Fwttk9t678KdOr0OgmtqTdsTpxvVCuB7EDc3q7XEIdMTQsM3q6BXZ96Q 3XiJOkODT9E/4ZDjdIhqLkjMLENBVjEHQVVaM0xAoQsfxR3ZynyFRucQKGS/I/W80fVs AV3w== X-Gm-Message-State: ACrzQf0jrdREm90pXlmhesgn0kYeO1gkRyU0w9kIY4TH+SoHT8f/9QuZ ZQ3CQbN8Cc1atdsjfOzwrt2DrDzLh/vbZsuRf7es2g== X-Received: by 2002:a05:6512:31c9:b0:4a2:5349:7103 with SMTP id j9-20020a05651231c900b004a253497103mr2734896lfe.497.1666182975312; Wed, 19 Oct 2022 05:36:15 -0700 (PDT) MIME-Version: 1.0 References: <20221019121622.179024-1-apatel@ventanamicro.com> <20221019121622.179024-2-apatel@ventanamicro.com> <5869751.lOV4Wx5bFT@phil> In-Reply-To: <5869751.lOV4Wx5bFT@phil> From: Anup Patel Date: Wed, 19 Oct 2022 18:06:04 +0530 Message-ID: Subject: Re: [PATCH v3 1/4] RISC-V: Fix compilation without RISCV_ISA_ZICBOM To: Heiko Stuebner Cc: Palmer Dabbelt , Paul Walmsley , Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Jones , kernel test robot , Conor Dooley Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,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 Wed, Oct 19, 2022 at 6:01 PM Heiko Stuebner wrote: > > 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: The Guest might have pass-through access to a device which is not cache-coherent whereas Host might have all devices cache-coherent. > > +#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? Argh, I mixed changes from my previous patch and Drew's patch. I will quickly send v4. Thanks for catching. Regards, Anup > > > 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, > > > > > >