From patchwork Wed Oct 19 13:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 5464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp331625wrs; Wed, 19 Oct 2022 06:37:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6TurtumSm4Y1yZoGxyiQcRubf5zwUbWIgp8lfr40edDQqWYVuMC+qEqGcfkjdrMvQvnr+M X-Received: by 2002:a17:903:1c6:b0:185:47ce:f4f0 with SMTP id e6-20020a17090301c600b0018547cef4f0mr8612758plh.132.1666186621820; Wed, 19 Oct 2022 06:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186621; cv=none; d=google.com; s=arc-20160816; b=bli+NCC6v+OB2y4uoJX4XbN5A0XlYNkVJOHA6gNag8ZgTa0SrrcXJDZtlrCDGHhDdz w69dJfzgyvWu+QjdOc4VfPstMivlfEF/cwf1D1u4zzYhQjIW2lklOAhAFrjCu1FdMUxf WMGEWtdhNB4du3lgskUMc/ITvvnlDofsv/3g9hF/5KTd/aFUL3Y5PQc5tE9/+Qw0kaOF nqQnohyUHJdrD96MIMVSiJCAAgfmOcH9dVQK2j1i+WbHbTpDlmvwe4LlFWv5Eq4g/KOB mUMPrEEXuanhqD2Nndmvh5HG3YuyqjjWqk/D0xrmLO4g/Wd12sc5UcwYlbfUlJe1W2IE /5zA== 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 :dkim-signature; bh=rh1RnpsntJfELASsE5PqiwcPYKRcDpF732XU4z7NxZA=; b=D9swIFk/AtzsfT022cvKkSz4YkQnP1kLC9rRONjACMJZ/OY2JDNanfKi8WdePoqfbE CK/+6o3CTIcBpwxxJ3Lv+I+VFvgzwhVF6LSJoATn7oUk6U2/BXuIVQrkr0ZyX/EjCli1 XLuYJ4twX+kpsPdxe7ER/xCey+mLJzvrS91ljR25uvQp9aFgg/ZoVVmKaxnvdn1yIobz 2CYWsqdJmapTJ7Pl1Mxbw/4OxQBJGoURLiocokfiEjNPAL3k04VR6bwkXyeLXeaHJk7K Oe0N27YyPNlBalms7dc9X0Jg6F8AHGRvacMQxeW3Floee8+PmNpH7uko554Tvzg1A/UE 9UwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Wcyhp1LT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bb5-20020a170902bc8500b00181bcfcaa6csi17175001plb.45.2022.10.19.06.36.48; Wed, 19 Oct 2022 06:37:01 -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=Wcyhp1LT; 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 S230171AbiJSN0j (ORCPT + 99 others); Wed, 19 Oct 2022 09:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbiJSN0S (ORCPT ); Wed, 19 Oct 2022 09:26:18 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7381DC4E1 for ; Wed, 19 Oct 2022 06:12:47 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id i6so17172224pli.12 for ; Wed, 19 Oct 2022 06:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rh1RnpsntJfELASsE5PqiwcPYKRcDpF732XU4z7NxZA=; b=Wcyhp1LTucgrnH6f1PPH+sYeTNlqJGZ0rALt4DLvQwuGHO8D3wJ5CNzyJRYu7X9Ke/ MbTeah1+aXgUqp8DjaId+4YLIm1qTyJJwoP0gsjFnrHELrXE4VP18rsyQ42+siIw+Nic k+zMguu48+H+c6VfVVcl31JGio6i8qBgk67cNpJzvi3HPQKTTzr/zV0Ivi3drxqtYeyo xj5YK9j7ijzFamxSrgSlT11MEm+8b57VTmuhP03hBoOtKCc6/K1Mi4nHb1UnXqfVsytQ J0dCBVWqSEpKr/dh1D/5iLLtv9KzGZbaHUkcwPdiYZpsLO5kc/pl9I1r4/RekkVHkpDd L7TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rh1RnpsntJfELASsE5PqiwcPYKRcDpF732XU4z7NxZA=; b=hY4y/bw9vy8b3TnbXFWEM0V67Kh0ao8MiXDA1iHwFk7HqK2/Qn7lttHWW8JavAnXWj xH5PZ1b87F8IiUzegGk1MqTNU7dr9+68QwmMurtxtNEOq7EoIXiDFHwnz404rc5eyWgM os4STr2TboAK4Zw81Py7eZOiQgKV1aZEEtZrcCzjxebCFOUPF18WTEgMHH4hXW8em5vA HLXF74+Erb0nT+i/NSZcGTH/Vf+xh/hvAQKV+6672c3FlpOuhxF/+9EKi3c1ACKN1Mzi zIy5KRH5WY9TWIicXtxksylsIr5fI1M5b9n1EEkQL5h0Ixjn83opkDZg2cPEM3Ujra5Y YThA== X-Gm-Message-State: ACrzQf3hvXvYgMdEDJfwXTuGXjuI+ZJgSOOd5PPq3KO7bJcGbj91Rsla Ujhp4pYL2tCfMhGA2SdH7F6AGg== X-Received: by 2002:a17:90b:128d:b0:20a:da54:788 with SMTP id fw13-20020a17090b128d00b0020ada540788mr9966123pjb.65.1666185101695; Wed, 19 Oct 2022 06:11:41 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b00172897952a0sm10934478plc.283.2022.10.19.06.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:11:41 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Jones , kernel test robot , Anup Patel , Conor Dooley Subject: [PATCH v4 1/4] RISC-V: Fix compilation without RISCV_ISA_ZICBOM Date: Wed, 19 Oct 2022 18:41:25 +0530 Message-Id: <20221019131128.237026-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019131128.237026-1-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123302971130020?= X-GMAIL-MSGID: =?utf-8?q?1747123302971130020?= 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. 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 Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner --- arch/riscv/include/asm/cacheflush.h | 8 ------ arch/riscv/mm/cacheflush.c | 38 ++++++++++++++++++++++++++ arch/riscv/mm/dma-noncoherent.c | 41 ----------------------------- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index 8a5c246b0a21..f6fbe7042f1c 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -42,16 +42,8 @@ void flush_icache_mm(struct mm_struct *mm, bool local); #endif /* CONFIG_SMP */ -/* - * The T-Head CMO errata internally probe the CBOM block size, but otherwise - * don't depend on Zicbom. - */ extern unsigned int riscv_cbom_block_size; -#ifdef CONFIG_RISCV_ISA_ZICBOM void riscv_init_cbom_blocksize(void); -#else -static inline void riscv_init_cbom_blocksize(void) { } -#endif #ifdef CONFIG_RISCV_DMA_NONCOHERENT void riscv_noncoherent_supported(void); diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 6cb7d96ad9c7..57b40a350420 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive */ +#include #include #ifdef CONFIG_SMP @@ -86,3 +87,40 @@ 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); + +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; +} 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,