Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp972546pxa; Wed, 19 Aug 2020 22:03:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRm2ea2tyiLRTnaK/70fJncLjxl/+0jjy3jytNH2tlAEs/gZLIvtJBE1L4+X4YenHLXn5M X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr1651874ejc.512.1597899810211; Wed, 19 Aug 2020 22:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597899810; cv=none; d=google.com; s=arc-20160816; b=JfOlS155rplOM7kj+d1cmrlTjhrjvGVca4bJvEM1jonn+jgy4287fNphId959CXnG1 JpWpvydORRQgIAm6dONIUcmRYMv6vl/UwB2NuYWR6XIYpAEPOGr5l7GsYzw5lo6ZG5g1 mTJgMLkoBLtHM8BDwgnkfiTdlpjWnVh994CrA1azeZCMrCce6XR9M2nIP5eoGZf6QG3H WVQDYwmqLBOrKi8QeyB4mk0VgaFDtV6GZEfnFabL9wKP27aj90WeTOjRrQcR8FoUV0W/ BN0Utk654Ij+5g09sImXVhGlsaorjVjyEH3syAy5LJHb1SP+DT/RxcX+SV20MKP+9bSl 7rjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+KSomakp0sPSUnENdcj4AvWU1MfuyTZ652I1qrO36V8=; b=uC8TgWRgTlWPEmJTsS/zDYGqhEWX7/QhQ4TDLaHYOJYH+v1Tl3HsM2OjujHa1Wcc0e CxkFK6vCasdrqgPY4bR93B2M4QcuK8YZjBegAbMl5wqpkFZM5MleBlHDafiA/+KadbJa UTzguEfu6Vt+IsTcBiLYppAF6pwjGiz3ZmaWkNfVjNz7NbwQW9kD6GT3ws8gWP4Yv0nU CBOtxsFFuEoq/h1doagnHhGK4bCKGcm/EFHHqHOCahT3+hLy8OM+r34EGzHobk6FOFpU Zo3CWrOjwnVKqglTzcZVMbyNwj4AUWTlpQ1qiCoV7/J2YnOm21ekDFek1QkcyuM6S7I6 G5uw== 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 le18si449549ejb.705.2020.08.19.22.03.05; Wed, 19 Aug 2020 22:03:30 -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 S1725885AbgHTFCW (ORCPT + 99 others); Thu, 20 Aug 2020 01:02:22 -0400 Received: from verein.lst.de ([213.95.11.211]:40485 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgHTFCU (ORCPT ); Thu, 20 Aug 2020 01:02:20 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 7DCC068BEB; Thu, 20 Aug 2020 07:02:14 +0200 (CEST) Date: Thu, 20 Aug 2020 07:02:14 +0200 From: Christoph Hellwig To: Robin Murphy Cc: Tomasz Figa , Christoph Hellwig , alsa-devel@alsa-project.org, linux-ia64@vger.kernel.org, Linux Doc Mailing List , nouveau@lists.freedesktop.org, linux-nvme@lists.infradead.org, Linux Kernel Mailing List , "James E.J. Bottomley" , linux-mm@kvack.org, Marek Szyprowski , linux-samsung-soc , Joonyoung Shim , linux-scsi@vger.kernel.org, Kyungmin Park , Ben Skeggs , Matt Porter , Linux Media Mailing List , Tom Lendacky , Pawel Osciak , Mauro Carvalho Chehab , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Thomas Bogendoerfer , linux-parisc@vger.kernel.org, netdev@vger.kernel.org, Seung-Woo Kim , linux-mips@vger.kernel.org Subject: Re: [PATCH 05/28] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT Message-ID: <20200820050214.GA4815@lst.de> References: <20200819065555.1802761-1-hch@lst.de> <20200819065555.1802761-6-hch@lst.de> <62e4f4fc-c8a5-3ee8-c576-fe7178cb4356@arm.com> <2b32f1d8-16f7-3352-40a5-420993d52fb5@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b32f1d8-16f7-3352-40a5-420993d52fb5@arm.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 03:07:04PM +0100, Robin Murphy wrote: >> FWIW, I asked back in time what the plan is for non-coherent >> allocations and it seemed like DMA_ATTR_NON_CONSISTENT and >> dma_sync_*() was supposed to be the right thing to go with. [2] The >> same thread also explains why dma_alloc_pages() isn't suitable for the >> users of dma_alloc_attrs() and DMA_ATTR_NON_CONSISTENT. > > AFAICS even back then Christoph was implying getting rid of NON_CONSISTENT > and *replacing* it with something streaming-API-based - i.e. this series - > not encouraging mixing the existing APIs. It doesn't seem impossible to > implement a remapping version of this new dma_alloc_pages() for > IOMMU-backed ops if it's really warranted (although at that point it seems > like "non-coherent" vb2-dc starts to have significant conceptual overlap > with vb2-sg). You can alway vmap the returned pages from dma_alloc_pages, but it will make cache invalidation hell - you'll need to use invalidate_kernel_vmap_range and flush_kernel_vmap_range to properly handle virtually indexed caches. Or with remapping you mean using the iommu do de-scatter/gather? You can implement that trivially implement it yourself for the iommu case: { merge_boundary = dma_get_merge_boundary(dev); if (!merge_boundary || merge_boundary > chunk_size - 1) { /* can't coalesce */ return -EINVAL; } nents = DIV_ROUND_UP(total_size, chunk_size); sg = sgl_alloc(); for_each_sgl() { sg->page = __alloc_pages(get_order(chunk_size)) sg->len = chunk_size; } dma_map_sg(sg, DMA_ATTR_SKIP_CPU_SYNC); // you are guaranteed to get a single dma_addr out } Of course this still uses the scatterlist structure with its annoying mix of input and output parametes, so I'd rather not expose it as an official API at the DMA layer.