Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9300423rwb; Thu, 24 Nov 2022 10:39:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4O+NpDmb/7Y1hM8iNQx5SwCTylYt5l01BO6kY321y38XTfbUmhuRBTdhPcaviknkc0S5nb X-Received: by 2002:a17:902:a9c6:b0:188:52df:769e with SMTP id b6-20020a170902a9c600b0018852df769emr14338378plr.30.1669315171764; Thu, 24 Nov 2022 10:39:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669315171; cv=none; d=google.com; s=arc-20160816; b=sQBqzc8lmCT8YQYx2npAJs8x3kteMIFWHG+P/TVUUDap1VsS/l2ENYd/SnHyKsdsAV aartr/tmhtRLOw5r3123DIqQeZTsGsCiRE0et2qsEPujCxRsVtpZmzeRPStg50b3krwg HMbM6Uj38eoEJc5DaPB9F0jX54m3YFpFYmnjjZHC8TiXboQSXhQV/gYB4MOW5i0cdwie jLXSQR4Afs4Q4XS332XnxcVY2fLorbIj6eXpxllA73pp+1IPYHbWksVn0u/Jnnmf2olY stfKQBQ4YPEhgp/pOFUhmUJDjD3gGgNnSsU0k9GLRw2U5Cp4+DE5wcKYTwyZwzn/t4ph Q0rw== 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=PgjiD3jQ1zxtyxRcUUMUmR+PhgX1aGiC7dYjpZSIPAg=; b=xlBH2cPGYG8Q3nRJsnhKlbfi960crTLYlyLvVjq+9AW66qCQOXjd/PQjoDOyG1rMcf 1/Kbx60/VuvIpF5bwTeYJDXV+PuO7Kaf+mEO2jj2nFV1oIphnY5l5iC4ItFVxN5wCpbD HPQdwjaovQnBzX6IiLM3XC/PMwbTA96wqHbbz0mO6MUCmjOjJtHxp7eUl3Mch2sc5KjB 3ypmteNTZAb6lbnVACgwO3Dl4gySzUVbuxy6upolU+zhQZjr7KQppyP7SmSiYSy4sKxX YU4aYqiePPLp6WpLA13XE9bfmmhNBuiopRhHuSIzlNRht9hYypvCKBpc8FPTJFwsmpm4 /Ukg== 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 nn9-20020a17090b38c900b002131bb4043asi2427470pjb.177.2022.11.24.10.39.20; Thu, 24 Nov 2022 10:39:31 -0800 (PST) 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 S229499AbiKXS34 (ORCPT + 87 others); Thu, 24 Nov 2022 13:29:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiKXS3y (ORCPT ); Thu, 24 Nov 2022 13:29:54 -0500 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41AB7F5B4; Thu, 24 Nov 2022 10:29:51 -0800 (PST) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.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 1oyGye-0007Ir-Oo; Thu, 24 Nov 2022 19:29:36 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Geert Uytterhoeven , Magnus Damm , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Guo Ren , Prabhakar Cc: Jisheng Zhang , Atish Patra , Anup Patel , Andrew Jones , Nathan Chancellor , Philipp Tomsich , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: Re: [PATCH v4 5/7] riscv: mm: dma-noncoherent: Pass direction and operation to ALT_CMO_OP() Date: Thu, 24 Nov 2022 19:29:35 +0100 Message-ID: <3689906.Lt9SDvczpP@diego> In-Reply-To: <20221124172207.153718-6-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20221124172207.153718-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20221124172207.153718-6-prabhakar.mahadev-lad.rj@bp.renesas.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 Am Donnerstag, 24. November 2022, 18:22:05 CET schrieb Prabhakar: > From: Lad Prabhakar > > Pass direction and operation to ALT_CMO_OP() macro. > > This is in preparation for adding errata for the Andes CPU core. can you provide more explanation why that is necessary please? I guess you want to use different cache operations for some cases? Thanks Heiko > Signed-off-by: Lad Prabhakar > --- > RFC v3 -> v4 > * New patch > --- > arch/riscv/include/asm/cacheflush.h | 4 ++++ > arch/riscv/include/asm/errata_list.h | 8 ++++++-- > arch/riscv/mm/dma-noncoherent.c | 15 ++++++++++----- > 3 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index f6fbe7042f1c..4a04d1be7c67 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -8,6 +8,10 @@ > > #include > > +#define NON_COHERENT_SYNC_DMA_FOR_DEVICE 0 > +#define NON_COHERENT_SYNC_DMA_FOR_CPU 1 > +#define NON_COHERENT_DMA_PREP 2 > + > static inline void local_flush_icache_all(void) > { > asm volatile ("fence.i" ::: "memory"); > diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h > index 2ba7e6e74540..48e899a8e7a9 100644 > --- a/arch/riscv/include/asm/errata_list.h > +++ b/arch/riscv/include/asm/errata_list.h > @@ -124,7 +124,7 @@ asm volatile(ALTERNATIVE( \ > #define THEAD_flush_A0 ".long 0x0275000b" > #define THEAD_SYNC_S ".long 0x0190000b" > > -#define ALT_CMO_OP(_op, _start, _size, _cachesize) \ > +#define ALT_CMO_OP(_op, _start, _size, _cachesize, _dir, _ops) \ > asm volatile(ALTERNATIVE_2( \ > __nops(6), \ > "mv a0, %1\n\t" \ > @@ -146,7 +146,11 @@ asm volatile(ALTERNATIVE_2( \ > ERRATA_THEAD_CMO, CONFIG_ERRATA_THEAD_CMO) \ > : : "r"(_cachesize), \ > "r"((unsigned long)(_start) & ~((_cachesize) - 1UL)), \ > - "r"((unsigned long)(_start) + (_size)) \ > + "r"((unsigned long)(_start) + (_size)), \ > + "r"((unsigned long)(_start)), \ > + "r"((unsigned long)(_size)), \ > + "r"((unsigned long)(_dir)), \ > + "r"((unsigned long)(_ops)) \ > : "a0") > > #define THEAD_C9XX_RV_IRQ_PMU 17 > diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-noncoherent.c > index d919efab6eba..e2b82034f504 100644 > --- a/arch/riscv/mm/dma-noncoherent.c > +++ b/arch/riscv/mm/dma-noncoherent.c > @@ -19,13 +19,16 @@ void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, > > switch (dir) { > case DMA_TO_DEVICE: > - ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size); > + ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size, > + dir, NON_COHERENT_SYNC_DMA_FOR_DEVICE); > break; > case DMA_FROM_DEVICE: > - ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size); > + ALT_CMO_OP(clean, vaddr, size, riscv_cbom_block_size, > + dir, NON_COHERENT_SYNC_DMA_FOR_DEVICE); > break; > case DMA_BIDIRECTIONAL: > - ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size); > + ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size, > + dir, NON_COHERENT_SYNC_DMA_FOR_DEVICE); > break; > default: > break; > @@ -42,7 +45,8 @@ void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size, > break; > case DMA_FROM_DEVICE: > case DMA_BIDIRECTIONAL: > - ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size); > + ALT_CMO_OP(flush, vaddr, size, riscv_cbom_block_size, > + dir, NON_COHERENT_SYNC_DMA_FOR_CPU); > break; > default: > break; > @@ -53,7 +57,8 @@ void arch_dma_prep_coherent(struct page *page, size_t size) > { > void *flush_addr = page_address(page); > > - ALT_CMO_OP(flush, flush_addr, size, riscv_cbom_block_size); > + ALT_CMO_OP(flush, flush_addr, size, riscv_cbom_block_size, > + 0, NON_COHERENT_DMA_PREP); > } > > void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, >