Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932916AbdGKOTj (ORCPT ); Tue, 11 Jul 2017 10:19:39 -0400 Received: from verein.lst.de ([213.95.11.211]:52962 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932653AbdGKOTi (ORCPT ); Tue, 11 Jul 2017 10:19:38 -0400 Date: Tue, 11 Jul 2017 16:19:37 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Vladimir Murzin , Christoph Hellwig , Vitaly Kuzmichev , gregkh@linuxfoundation.org, m.szyprowski@samsung.com, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, "George G. Davis" Subject: Re: [PATCH v2 1/2] drivers: dma-coherent: Fix dev->cma_area vs dev->dma_mem breakage Message-ID: <20170711141937.GA12884@lst.de> References: <1499433759-16397-1-git-send-email-vitaly_kuzmichev@mentor.com> <1499433779-16437-1-git-send-email-vitaly_kuzmichev@mentor.com> <20170707142746.GB10818@lst.de> <6f26f0d9-506a-76bf-1410-19b00162c4a1@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f26f0d9-506a-76bf-1410-19b00162c4a1@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1185 Lines: 29 On Fri, Jul 07, 2017 at 05:06:52PM +0100, Robin Murphy wrote: > I don't think we need to go that far, I reckon it would be clear enough > to just split the per-device vs. global pool interfaces, something like > I've sketched out below (such that the ops->alloc implementation calls > dma_alloc_from_global_coherent() if dma_alloc_from_contiguous() fails). > > If anyone wants to take that and run with it, feel free. I like this basic idea. It also fits into one of my plans for the 4.14 merge window - I want to enhance the lib/dma-noop.c so that it can use different allocators and mapping helpers, e.g. for the allocators what makes sense is: (1) simple page allocator (as-is) (2) CMA (3) swiotlb (4) the OF coherent allocator from your draft patch and then for the mapping into phys space we can use (1) virto_to_phys (as-is) (2) arch helper (e.g. like done in mips plat support) (3) maybe some common form of ioremap / vmap instead of various duplicates With that we should be able to cosolidate most direct mapped dma_ops for architectures that do not require cache flushing into common code. As a next step we could think about useful cache flushing hooks.