Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4227004pxv; Tue, 27 Jul 2021 01:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK+MaEmUk4PSWvXZrOYRvyGISpqQgpprFEgL6JDlrETO0hXGcjCQgd82CKwjYY+9grPkQD X-Received: by 2002:aa7:cd5c:: with SMTP id v28mr5313343edw.305.1627376093946; Tue, 27 Jul 2021 01:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627376093; cv=none; d=google.com; s=arc-20160816; b=BmzrgfNFvMcnLMzE7z4QwhxD9604tgTRILZzGa5zprbWIu26u5tW6WQ4adR5sG2KK8 G6GKrbK6Erav6YysIIJDTVqKgBnEHw9kuuGVEa/7zebgGhTc8JGaiVz244mTdpDHtMXw p3/PbeqpLsK+yE51WIZE/Jq0Jz3WoCF7EAlu1e/ZthmoC4BakDgNZEotMMunGOXuLGci SbtauiZW+HY92YpPAEnyJu/24JbojLz5Qz8gx52iLZuQEu90oDeVRg4TV4vlQ5Ymnbkk inlGSq8y/iVRfTbS2i9Ao0DE6h80ICF4SYblouzZCBB9JghELr+BM6H9olNOwoVcwWqF w5Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=pGZcjt7+U8IEJ2GtyPrB2CGmde9ZjrHYydtf9uQbC0o=; b=vvkXXyRc46YkCVD0I7DJutvaFkIjP6FerGSUjwn5ABYpjSRqhJ0wD69KbcDdgkr++F 9WVJt5gbzXKtAdOAppy1wZ3pWiukCfmyoApNGpv9bdi2+tXNOCj7ExpZBGnTzUTYj49B yJSbQxmx3ycgz4401K2uy9jxgAJfB+dmv7TB7x8DDYacuvOkQUHes1MaBtoUNEVmDJC9 uFNVvU5FlyDs7k3Bn9raaTcZWHxrfTl+DReU7Sx1edY8n3nfngmdauQ5dk4CfAIEK2Qb Fq6PB0ScPrnxmuLqiFjX5lczQeuRSpYuq7ZKnioz2qs6GuAlDPiQmQxgPyQwVpLDzg6t vNTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si2582718ejj.616.2021.07.27.01.54.29; Tue, 27 Jul 2021 01:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235942AbhG0Iws (ORCPT + 99 others); Tue, 27 Jul 2021 04:52:48 -0400 Received: from verein.lst.de ([213.95.11.211]:48928 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235885AbhG0Iwr (ORCPT ); Tue, 27 Jul 2021 04:52:47 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 9A8A16736F; Tue, 27 Jul 2021 10:52:44 +0200 (CEST) Date: Tue, 27 Jul 2021 10:52:44 +0200 From: Christoph Hellwig To: Atish Patra Cc: Christoph Hellwig , Atish Patra , devicetree , Albert Ou , Tobias Klauser , Robin Murphy , "linux-kernel@vger.kernel.org List" , Rob Herring , iommu@lists.linux-foundation.org, Guo Ren , Palmer Dabbelt , Paul Walmsley , linux-riscv , Frank Rowand , Dmitry Vyukov Subject: Re: [RFC 3/5] dma-mapping: Enable global non-coherent pool support for RISC-V Message-ID: <20210727085244.GA20609@lst.de> References: <20210723214031.3251801-1-atish.patra@wdc.com> <20210723214031.3251801-4-atish.patra@wdc.com> <20210726070030.GB9035@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 26, 2021 at 03:47:54PM -0700, Atish Patra wrote: > arch_dma_set_uncached works as well in this case. However, mips, > niops2 & xtensa uses a > fixed (via config) value for the offset. Similar approach can't be > used here because the platform specific > offset value has to be determined at runtime so that a single kernel > image can boot on all platforms. Nothing in the interface requires a fixed offset. And using the offset has one enormous advantage in that there is no need to declare a statically sized pool - allocations are fully dynamic. And any kind of fixed pool tends to cause huge problems. > 1. a new DT property so that arch specific code is aware of the > non-cacheable window offset. Yes. > individual device if a per-device non-cacheable > window support is required in future. As of now, the beagleV memory If you require a per-device noncachable area you can use the per-device coherent pools. But why would you want that? > region lies in 0x10_0000_00000 - x17_FFFF_FFFF > which is mapped to start of DRAM 0x80000000. All of the > non-coherent devices can do 32bit DMA only. Adjust ZONE_DMA32 so that it takes the uncached offset into account. > > > - 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 > > ok. > > > to be filled in using dma-ranges property hanging of the struct device. > > struct device is only accessible in rmem_dma_device_init. I couldn't > find a proper way to access it during > dma_reserved_default_memory setup under global pool. > > Does that mean we should use a per-device memory pool instead of a > global non-coherent pool ? Indeed, that would be a problem in this case. But if we can just use the uncached offset directly I think everything will be much simpler.