Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3036758imw; Wed, 6 Jul 2022 16:24:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ut3iw/G3tS3BQmYUFpScHzYVlz7buJz58IF83nFOW+2rQd1BAtti3ZqDLRRf0jaSDo5SMS X-Received: by 2002:a17:902:ba94:b0:16b:fa16:15ed with SMTP id k20-20020a170902ba9400b0016bfa1615edmr9152171pls.8.1657149890268; Wed, 06 Jul 2022 16:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657149890; cv=none; d=google.com; s=arc-20160816; b=Y+rb+HJG3pufnNO1fjV4JHUOotk+6Uj7r5gXwMOjIyJOhkA5BOGEmPcs39brT7WDzR GJe/WZXvjQYn6wTfaOKYLISSaegwo9vgiih+D5FaUmwBmsABY9/BgmXc6Qw+IIhuTLLS PR9tH2/4MMnzEmvsQlKO0f2ikmmHBzdM4Ip796cQa8y8q4iFKxqD+L1K+uaffsqW3g6b AZEgeEeh33ETgXYZT8fE7sFreYF4dBBy7cGiIMGlnhTql1RAWvabqDxyfuRxD8r5J4+F KISVe7nOMhEiTgp4Rw/ydrkvAbNktSkaPHLml6DhjQ9AfR/SAutdvBTj63LBJcsk/3tu dYlQ== 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 :message-id:date:subject:cc:to:from; bh=4wf8gc3/rzs82N5p6pTSY3bupsgSSpMeMcKhjwo2DBo=; b=0qla0XuvDh5GmKUKO0PDVgYzYH2XjmPKk7KhbNEsKMxPOx3Ie+bV2qN9ZIu27D59j9 1OZvctanYTbPIyd1KGoiM2cn4iX9TWsMRXfT3+pIyEGyWc5+mi7ytquS88CnQiOauAxQ DN2BUNSSHfmy6igc4rZXI37Xc+QRjHxyCtbEmExmuUOPbEFT7SSr8BpG+I5NoP2uQiuO GUKUYsjK7tJ2na7k40k+UG1x4/CTfCIopFTqAp5PX/d5CtGyjFHhFL3wElNsMyd8RkpJ DUZNoH9PAdIHDGgSmP/zD8kyIHt7+IkLRgfHRyps29JfvNmmLTR1GIXKDR2cvs9CIDHd RNfw== 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 y191-20020a638ac8000000b0040ce2432b6csi2762479pgd.586.2022.07.06.16.24.30; Wed, 06 Jul 2022 16:24:50 -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 S234389AbiGFXQB (ORCPT + 99 others); Wed, 6 Jul 2022 19:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233992AbiGFXP4 (ORCPT ); Wed, 6 Jul 2022 19:15:56 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF642B610; Wed, 6 Jul 2022 16:15:55 -0700 (PDT) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1o9EFC-0002yn-Oq; Thu, 07 Jul 2022 01:15:42 +0200 From: Heiko Stuebner To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, wefu@redhat.com, guoren@kernel.org, cmuellner@linux.com, philipp.tomsich@vrull.eu, hch@lst.de, samuel@sholland.org, atishp@atishpatra.org, anup@brainfault.org, mick@ics.forth.gr, robh+dt@kernel.org, krzk+dt@kernel.org, devicetree@vger.kernel.org, drew@beagleboard.org, rdunlap@infradead.org, Heiko Stuebner Subject: [PATCH v7 0/4] riscv: implement Zicbom-based CMO instructions + the t-head variant Date: Thu, 7 Jul 2022 01:15:32 +0200 Message-Id: <20220706231536.2041855-1-heiko@sntech.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This series is based on the alternatives changes done in my svpbmt series and thus also depends on Atish's isa-extension parsing series. It implements using the cache-management instructions from the Zicbom- extension to handle cache flush, etc actions on platforms needing them. SoCs using cpu cores from T-Head like the Allwinne D1 implement a different set of cache instructions. But while they are different, instructions they provide the same functionality, so a variant can easly hook into the existing alternatives mechanism on those. An ongoing discussion is about the currently used pre-coded instructions. Palmer's current thinking is that we should wait until the relevant instructions have landed in binutils. The main Zicbom instructions are in toolchains now and at least Debian also carries a binutils snapshot with it, but the T-Head variant still uses pre-coded instructions for now. The series sits on top of my svpbmt fixup series, which for example includes the conversion away from function pointers for the check-functions. It also uses my nops-series to shorten multiple nop statements: https://lore.kernel.org/r/20220607143059.1054074-1-heiko@sntech.de A new dma-noncoherent property was added for the devicetree-specification and dt-schema in: - https://www.spinics.net/lists/devicetree-spec/msg01053.html - https://github.com/devicetree-org/dt-schema/pull/78 The dtschema-patch was already merged and patch1 in this series got a reviewed-by from Rob, so I guess that new property should be ok to use. changes in v7: - add recently received review-tags - fix wrong rv32 mabi when testing for Zicbom in Kconfig changes in v6: - add recently received review-tags - adapt non-coherent patch subject as suggested by Christoph Hellwig changes in v5: - beautify of_dma_is_coherent as suggested by Christoph Hellwig - WARN_TAINT when ARCH_DMA_MINALIGN smaller than riscv,cbom-block-size (similar to how arm64 does this) - add a function to track if non-coherent handling is available - WARN_TAINT if a device is non-coherent but no non-coherent handling - use clean instead of inval in arch_sync_dma_for_device:DMA_FROM_DEVICE hopefully I understood https://lore.kernel.org/linux-arm-kernel/20220610151228.4562-1-will@kernel.org/T/ correctly in this changes in v4: - modify of_dma_is_coherent() also handle coherent system with maybe noncoherent devices - move Zicbom to use real instructions - split off the actual dma-noncoherent code from the Zicbom extension - Don't assumes devices are non-coherent, instead default to coherent and require the non-coherent ones to be marked - CPUFEATURE_ZICBOM instead of CPUFEATURE_CMO - fix used cache addresses - drop some unused headers from dma-noncoherent.c - move unsigned long cast when calling ALT_CMO_OP - remove unneeded memset-0 - define ARCH_DMA_MINALIGN - use flush instead of inval in arch_sync_dma_for_cpu() - depend on !XIP_KERNEL - trim some line lengths - improve Kconfig description changes in v3: - rebase onto 5.19-rc1 + svpbmt-fixup-series - adapt wording for block-size binding - include asm/cacheflush.h into dma-noncoherent to fix the no-prototype error clang seems to generate - use __nops macro for readability - add some received tags - add a0 to the clobber list changes in v2: - cbom-block-size is hardware-specific and comes from firmware - update Kconfig name to use the ISA extension name - select the ALTERNATIVES symbol when enabled - shorten the line lengths of the errata-assembly Heiko Stuebner (4): of: also handle dma-noncoherent in of_dma_is_coherent() dt-bindings: riscv: document cbom-block-size riscv: Add support for non-coherent devices using zicbom extension riscv: implement cache-management errata for T-Head SoCs .../devicetree/bindings/riscv/cpus.yaml | 5 + arch/riscv/Kconfig | 31 +++++ arch/riscv/Kconfig.erratas | 11 ++ arch/riscv/Makefile | 4 + arch/riscv/errata/thead/errata.c | 20 ++++ arch/riscv/include/asm/cache.h | 4 + arch/riscv/include/asm/cacheflush.h | 10 ++ arch/riscv/include/asm/errata_list.h | 59 ++++++++- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 24 ++++ arch/riscv/kernel/setup.c | 2 + arch/riscv/mm/Makefile | 1 + arch/riscv/mm/dma-noncoherent.c | 112 ++++++++++++++++++ drivers/of/address.c | 17 +-- 15 files changed, 293 insertions(+), 9 deletions(-) create mode 100644 arch/riscv/mm/dma-noncoherent.c -- 2.35.1