From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B243C4338F for ; Mon, 26 Jul 2021 07:00:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73D8360F38 for ; Mon, 26 Jul 2021 07:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231728AbhGZGUH (ORCPT ); Mon, 26 Jul 2021 02:20:07 -0400 Received: from verein.lst.de ([213.95.11.211]:43938 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231570AbhGZGUG (ORCPT ); Mon, 26 Jul 2021 02:20:06 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id DA9D068B05; Mon, 26 Jul 2021 09:00:30 +0200 (CEST) Date: Mon, 26 Jul 2021 09:00:30 +0200 From: Christoph Hellwig To: Atish Patra Cc: linux-kernel@vger.kernel.org, Albert Ou , Christoph Hellwig , devicetree@vger.kernel.org, Dmitry Vyukov , Frank Rowand , Guo Ren , iommu@lists.linux-foundation.org, linux-riscv@lists.infradead.org, Marek Szyprowski , Palmer Dabbelt , Paul Walmsley , Rob Herring , Robin Murphy , Tobias Klauser Subject: Re: [RFC 3/5] dma-mapping: Enable global non-coherent pool support for RISC-V Message-ID: <20210726070030.GB9035@lst.de> References: <20210723214031.3251801-1-atish.patra@wdc.com> <20210723214031.3251801-4-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210723214031.3251801-4-atish.patra@wdc.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Fri, Jul 23, 2021 at 02:40:29PM -0700, Atish Patra wrote: > Currently, linux,dma-default is used to reserve a global non-coherent pool > to allocate memory for dma operations. This can be useful for RISC-V as > well as the ISA specification doesn't specify a method to modify PMA > attributes or page table entries to define non-cacheable area yet. > A non-cacheable memory window is an alternate options for vendors to > support non-coherent devices. Please explain why you do not want to use the simply non-cachable window support using arch_dma_set_uncached as used by mips, niops2 and xtensa. > +static int __dma_init_global_coherent(phys_addr_t phys_addr, dma_addr_t device_addr, size_t size) > { > struct dma_coherent_mem *mem; > > - mem = dma_init_coherent_memory(phys_addr, phys_addr, size, true); > + if (phys_addr == device_addr) > + mem = dma_init_coherent_memory(phys_addr, device_addr, size, true); > + else > + mem = dma_init_coherent_memory(phys_addr, device_addr, size, false); Nak. The phys_addr != device_addr support is goign away. This needs to be filled in using dma-ranges property hanging of the struct device.