Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4858499imu; Wed, 19 Dec 2018 01:17:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/XUCqtIcBvx0em9tF5RZCKJw/5IPDaGsJkKL5viQYp2pTlXw7w7DFNtM4EdjsPZSktBp3Tj X-Received: by 2002:a63:f901:: with SMTP id h1mr18710537pgi.154.1545211035789; Wed, 19 Dec 2018 01:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545211035; cv=none; d=google.com; s=arc-20160816; b=A9pFlQv1y0a7YiOxkO9CncnW5q7W2rHZ5vSRreqwFeISrA56V1wHIC2zMjigYwcicO 7KGn+L7fzv2UHSE/JLaH52H6VPRrg5r2HsrGicwtD9x4Y6A5TQBFep9ek1MiiR+8walA n+YIGVZ8mpmAwnSXgLwSxnZ2QXA4tIbkb3FlKvFiK+s4WJ/WbOnOsR1qwrduKYOVw5t0 hdGydOQZ/wUZDsmEOnsJsvMussXZWTygskWX5/xF/gMVO/KWpZwpuD2TrrT3W17yzJmt OMrTmDXsFyifrXHTSx+km76Dz+rPRy/Ah5eBVRc51kIUwsnCuNYlt1SOGwxnDWQMbCTW 4GKA== 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:dkim-signature; bh=E8s0pTXCClRjqdCV/nUnzdAXumVNkERnmd8w/qjr6Eo=; b=T53KotuDB1BLwzoEtLAB1XzW4gFqEoVB96jwlM9DVZJUYKiRqVWIZEJtrcmqU1JP2R It1avMPDKTpL4iOGcI/SGM9e15wbsE0iRBveyBJvIm8MxwHAseSodvUOitS3qIgc/C34 UE5tBrp4+tvWBx4vGMzmOJ+4U9qwQl+xQRFu48pDr+QveWPoT/McTcMRAc5c4r0YM3Pf wtteJxiovSbMH/IyNuEGdU2427gEBETDKPMrkYY2DvVBvRiZjopjqsgkcqXUZx3aD5Gt v5Q1PfsM9qy0Y7IVUPdtvgihzAlLb+3Q2suqDYvhf5Xj7QHkW74f6Ef6oPtAftH4Lvu1 WV2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Vjr7hpPO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si14971847pff.126.2018.12.19.01.16.59; Wed, 19 Dec 2018 01:17:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Vjr7hpPO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbeLSHv4 (ORCPT + 99 others); Wed, 19 Dec 2018 02:51:56 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:46632 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbeLSHvz (ORCPT ); Wed, 19 Dec 2018 02:51:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=E8s0pTXCClRjqdCV/nUnzdAXumVNkERnmd8w/qjr6Eo=; b=Vjr7hpPOXwFuR4XENuWTBnhHa dtZLoxBJNx8NNfpsuf/FyqY0aR0g6TuViDPcutmXiKFfBRK669hj1v9qiXh8LiayBVTCT2IIjlzx9 XYIgzqgdkvB8HqfzK4SkqYIejKlqPoDF22GWP75OJ4UXQz8s14vKwtuxCdvzbTdYSSO6zOyQy5Qu6 7DA93lXUnHYctUQRyqArMQs5/Ye5OvhU4F7CijO9ZdHIZ6G95yEp2Kgm1dtYlavFWGBd5BXiXEK2C 5myP1wLZFR+J0Zi1CK54JB8p48xy1HPbAYMpQqPcGbnFwZckiZ5zmVMyEdL4aGoWF4rKNucr71VNn t1hNq8hBg==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZWdy-0000Qs-Ux; Wed, 19 Dec 2018 07:51:50 +0000 Date: Tue, 18 Dec 2018 23:51:50 -0800 From: Christoph Hellwig To: Tomasz Figa Cc: Christoph Hellwig , Laurent Pinchart , "Matwey V. Kornilov" , Linux Media Mailing List , Linux Kernel Mailing List , "Matwey V. Kornilov" , Alan Stern , Ezequiel Garcia , hdegoede@redhat.com, Hans Verkuil , Mauro Carvalho Chehab , rostedt@goodmis.org, mingo@redhat.com, Mike Isely , Bhumika Goyal , Colin King , Kieran Bingham , keiichiw@chromium.org Subject: Re: [PATCH v5 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer Message-ID: <20181219075150.GA26656@infradead.org> References: <20181212090917.GA30598@infradead.org> <20181212135440.GA6137@infradead.org> <20181213140329.GA25339@infradead.org> <20181214123624.GA5824@infradead.org> <20181218073847.GA4552@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 18, 2018 at 06:48:03PM +0900, Tomasz Figa wrote: > > So as I said you can call dma_alloc_attrs with DMA_ATTR_NON_CONSISTENT > > in a loop with a suitably small chunk size, then stuff the results into > > a scatterlist and map that again for the device share with if you don't > > want a single contigous region. You just have to either deal with > > non-contigous access from the kernel or use vmap and the right vmap > > cache flushing helpers. > > The point is that you didn't have to do this small chunk loop without > DMA_ATTR_NON_CONSISTENT, so it's at least inconsistent now and not > sure why it could be better than just a loop of alloc_page(). You have to do it if you want to map the addresses for a second device. > > I would advice against new non-consistent users until this series > > goes through, mostly because dma_cache_sync is such an amazing bad > > API. Otherwise things will just work at the allocation side, you'll > > just need to be careful to transfer ownership between the cpu and > > the device(s) carefully using the dma_sync_* APIs. > > Just to clarify, the actual code isn't very likely to surface any time > soon. so I assume it would be after this series lands. > > We will however need an API that can transparently handle both cases > of contiguous (without IOMMU) and page-by-page allocations (with > IOMMU) behind the scenes, like the current dma_alloc_attrs() without > DMA_ATTR_NON_CONSISTENT. Is the use case to then share the memory between multiples devices or just for a single device? The latter case is generally easy, the former is rather more painful.