Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp572397rdb; Thu, 21 Dec 2023 20:14:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHt7IwOp0dWcyjf8QLW/vXU0WH5ZVcitOJt2C7IjvyuPXaf01HGFuQzF6Du8EtmNfyC/Hp X-Received: by 2002:a17:906:b0d8:b0:9fe:81a:c258 with SMTP id bk24-20020a170906b0d800b009fe081ac258mr466117ejb.26.1703218485545; Thu, 21 Dec 2023 20:14:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703218485; cv=none; d=google.com; s=arc-20160816; b=UUy1abzotX1KZCl0R30+icx1SjTLpfgtPBdsMGre+rdVZMe127/+P6oa5MjhsokZ0k QIiBo88Ke/TPXCQH6u28pyVxGhCgH73Yn8PUN1naMREa9U/X34IOF30YVrJ96b7WthfR l/AyfwlENsTfT/K9wBPmv7KJ66WwW0f5QfLy4Q7S1iTwaRSg8F2Qt7/Ib7O7bJ/oHM1K KRvJ0LsBKleumyAHzvPIeh6KZD1HnG2Fzvk9CEXcOIhJH7AWeAKyq2Gon3L8JNv56bJJ 5GEIgkirSmUUkreCqEDLyqFx0qwZ5tEaFyRsmxn6F/oLVlAVFlYnx593cZPpqM4A2+QL 8E9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=QFyVMNNV1ZaPz/rJkV0UpR6HkwKloDLX4HyE4Zu4p2o=; fh=//dToIrABsXhZnMefctOEULslf9+TMlfcOjcFGPsxms=; b=tCSctumOcjaemkZN1Srcj5BER+3HQJJJESxd1tV/1epih1p9vp63oaq5r8ldjKX8gJ RWdUfnsjPMte6j5gEbnH9qqMpbkeuASUerZZgfdAquriKqfkz4g+XEsM52InXsxgaEyI xXXDUKVQce3i0oqls1iC0/ZajaeJ+LSmVY0xcRvHEOi1JqAZ94J3kKb4L59sAwhdPDxr vAiBsLvBekXSgbFaRwEnEFYkvRsxtTxhQZPo7JbBxVg/ivvVMa9t04Y3x2xRSnfKkPCd F1lb/fkx16mrxeGHzlodKbOb1cZgqVp6yGxWW/xCtUiNGU//9KaHCXqtm6GfgdHWUhpu TZ8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9307-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9307-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a22-20020a170906469600b00a235a0716b8si1416314ejr.879.2023.12.21.20.14.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 20:14:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9307-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9307-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9307-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 293F71F2560B for ; Fri, 22 Dec 2023 04:14:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E46CC63A4; Fri, 22 Dec 2023 04:14:36 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8F356120 for ; Fri, 22 Dec 2023 04:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 6048B68AFE; Fri, 22 Dec 2023 05:14:28 +0100 (CET) Date: Fri, 22 Dec 2023 05:14:28 +0100 From: Christoph Hellwig To: Jiaxun Yang Cc: Maxim Kochetkov , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, robh@kernel.org, mpe@ellerman.id.au, aou@eecs.berkeley.edu, palmer@dabbelt.com, paul.walmsley@sifive.com, Conor Dooley , hch@lst.de Subject: Re: [PATCH 1/1] riscv: set ARCH_DMA_DEFAULT_COHERENT if RISCV_DMA_NONCOHERENT is not set Message-ID: <20231222041428.GA2803@lst.de> References: <20231221185152.327231-1-fido_max@inbox.ru> <20231221-discount-decade-e306e5878c46@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) On Thu, Dec 21, 2023 at 10:27:33PM +0000, Jiaxun Yang wrote: > > > 在 2023/12/21 20:29, Conor Dooley 写道: >> + Christoph >> >> I don't think this patch is correct. Regardless of whether we support >> cache management operations, DMA is assumed to be coherent unless >> peripherals etc are specified to otherwise in DT (or however ACPI deals >> with that kind of thing). >> >> What problem are you trying to solve here? >> >> On Thu, Dec 21, 2023 at 09:51:52PM +0300, Maxim Kochetkov wrote: >>> Not all the RISCV are DMA coherent by default. > > Sorry for chime in here. > IMO if your platform is not coherent by default, just insert > "dma-noncoherent" > at devicetree root node. Exactly. ARCH_DMA_DEFAULT_COHERENTis a setting that just says for a given architecture assumes coherent unless otherwise specified, which has historically been the case for mips. Not setting it means non-coherent unless specified, which has historially been the case for arm. RISC-V starte out without support for non-coherent DMA, and high ups in RISCV still told me in 2019 that RISC-V doesn't need cache management instructions because no new hardware would ever not be dma coherent. Yeah, right.. Anyay, Linux for RISC-V has historically been coherent only and then coherent default, so this option is wrong, and you need to mark you platform as non-coherent by inserting dma-noncoherent somewhere.