Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1287391rwb; Thu, 6 Oct 2022 10:47:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6l9wDvY6fdWxRDjSV4f5ygefKjIYc2ETyiN/RmC8uzYEE1TXn1uDm67x5fukcgHh9oIhb5 X-Received: by 2002:a17:907:a06f:b0:78c:369e:e24f with SMTP id ia15-20020a170907a06f00b0078c369ee24fmr795093ejc.523.1665078459717; Thu, 06 Oct 2022 10:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665078459; cv=none; d=google.com; s=arc-20160816; b=wpkGiZ+plmazc+LNS19W3vutCh2xT71BI75sfpKDMA6xT65Rfp+zXOyGCqZhR/FM+k xbVF2U7JquOuyD1naLxuE+LRIKntysurAMDfVce/KYUPJy/tDapQ2yzDNvWIL1tYfQCH vXPnv8TfHp6cq9kQmr/pMW8UKAZFYiixppLATl07oFwuhGomH2E0uy1BEaPJgBeUBNN5 lvIVr9048swYwj8vAMHCiqzDzgA0v6+05tW4hbtFblEjjM70SBevDUn6XeQFZeegzc4L GDWxKdLx7oL8SrNjBjF1/v5R03i9kjCtMuICBQg/y+Whg/I1YsfjcQor9PRArO7hehEG Qlsw== 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=RkwBIUQf0wv1ODUcxn0uf4stM6Qt+rAXYpfxK3Q9Uig=; b=zJ8wnhSYOBidca/muzH6lo4j7MQ+SfYBkDPPbotvVZc0qi4v/aexXphgpb0uo3mcO7 SjSpDrNK6EOAk0B5WUHRWtyNmwPU9W4tjiYe8vrpY6NKdkF5tFNq56G560pe76zNPv0X dtEElzJBWLNfoIeEVam/PuQmTKUvjXUAGqiwXFrZTj+lNHvvzvWpyGNasykVIPW6W3Tj 27nunqADvKDt+tBPjH8x3rEN9Bx0iIoCplMvSuMYrPV9UmRCsq/VMjZ2ZvBHfFH6ERVl NKlV2wmmGnc66rszCcztkwF9yOySq65RiGRGArXOpQWyu0EgB8tEc/zBME/WnEbp9JKw +W1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hB1YD1Qs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a05640227c800b00459ee392e46si2288274ede.7.2022.10.06.10.47.01; Thu, 06 Oct 2022 10:47:39 -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=@kernel.org header.s=k20201202 header.b=hB1YD1Qs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbiJFRg0 (ORCPT + 99 others); Thu, 6 Oct 2022 13:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiJFRgS (ORCPT ); Thu, 6 Oct 2022 13:36:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A996CBBE1A for ; Thu, 6 Oct 2022 10:36:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B5C79619DD for ; Thu, 6 Oct 2022 17:36:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DEAC433D7; Thu, 6 Oct 2022 17:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665077774; bh=GUqme/r7hbePZuQzyMvKMjER/L3r6OTCMSjziwbypbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hB1YD1QsXMXEUG8+CI+yIvHJLLXcoRa28R6F7dyiEAtLgiMQIBASVBkqwjlyfuzFG yT5j8D33eqwtp7xui9Cyz5HD0nCV6rKGbLVQNYJTgvw1wefN48tWSRovPei/2phycr ZblITCOSvP9eI0XVai8y2ELGvw4JrEneHcXfH1LKorrfcF8hBUefacu4SotJT8FhEs fkGDkn3xaWUirMVvO5InMxKZO6pdBCzfOKl8gsnqzdarcIXE+MKtv6hyl4OMAufsUt 7V5vOGUl+l4KpzMmo7g+bdOTPsWHohrw6oUqkQT5AKrWkhvJuG02GNoOJp6NClyhCL Biktb2YOhAeIg== From: Conor Dooley To: Palmer Dabbelt , Nathan Chancellor , Nick Desaulniers Cc: Tom Rix , Conor Dooley , Dao Lu , Heiko Stuebner , Guo Ren , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Kevin Hilman Subject: [PATCH 1/2] riscv: fix detection of toolchain Zicbom support Date: Thu, 6 Oct 2022 18:35:20 +0100 Message-Id: <20221006173520.1785507-2-conor@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221006173520.1785507-1-conor@kernel.org> References: <20221006173520.1785507-1-conor@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Conor Dooley It is not sufficient to check if a toolchain supports a particular extension without checking if the linker supports that extension too. For example, Clang 15 supports Zicbom but GNU bintutils 2.35.2 does not, leading build errors like so: riscv64-linux-gnu-ld: -march=rv64i2p0_m2p0_a2p0_c2p0_zicbom1p0_zihintpause2p0: Invalid or unknown z ISA extension: 'zicbom' Convert CC_HAS_ZICBOM to TOOLCHAIN_HAS_ZICBOM & check if the linker also supports Zicbom. Reported-by: Kevin Hilman Link: https://github.com/ClangBuiltLinux/linux/issues/1714 Link: https://storage.kernelci.org/next/master/next-20220920/riscv/defconfig+CONFIG_EFI=n/clang-16/logs/kernel.log Fixes: 1631ba1259d6 ("riscv: Add support for non-coherent devices using zicbom extension") Signed-off-by: Conor Dooley --- arch/riscv/Kconfig | 10 ++++++---- arch/riscv/Makefile | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d557cc50295d..6da36553158b 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -401,14 +401,16 @@ config RISCV_ISA_SVPBMT If you don't know what to do here, say Y. -config CC_HAS_ZICBOM +config TOOLCHAIN_HAS_ZICBOM bool - default y if 64BIT && $(cc-option,-mabi=lp64 -march=rv64ima_zicbom) - default y if 32BIT && $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom) + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom) + depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900 config RISCV_ISA_ZICBOM bool "Zicbom extension support for non-coherent DMA operation" - depends on CC_HAS_ZICBOM + depends on TOOLCHAIN_HAS_ZICBOM depends on !XIP_KERNEL && MMU select RISCV_DMA_NONCOHERENT select RISCV_ALTERNATIVE diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 3fa8ef336822..3607d38edb4f 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -57,8 +57,7 @@ toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zi riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei # Check if the toolchain supports Zicbom extension -toolchain-supports-zicbom := $(call cc-option-yn, -march=$(riscv-march-y)_zicbom) -riscv-march-$(toolchain-supports-zicbom) := $(riscv-march-y)_zicbom +riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZICBOM) := $(riscv-march-y)_zicbom # Check if the toolchain supports Zihintpause extension toolchain-supports-zihintpause := $(call cc-option-yn, -march=$(riscv-march-y)_zihintpause) -- 2.37.3