Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp880801imu; Thu, 13 Dec 2018 06:05:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/UCjKKvyeY81MMO5T4mEK9YGbaJ40pI5wmBVs95FAwg5mXEp7XbCJvx6WJNcQzJEeuOJJ6t X-Received: by 2002:a17:902:2c03:: with SMTP id m3mr24695602plb.125.1544709948915; Thu, 13 Dec 2018 06:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544709948; cv=none; d=google.com; s=arc-20160816; b=RTClgXI+/fyGThxhWXEeV/sjX0UKedoUB3tcPH+xW3lU+h6rT4u3m4VyIxQy4OzG31 ayg0GSPpZf5wmJQsCh4FOWcjnC+cPirBvb2HeAc6WrJ1oDKIPLqe6pWK2RTACbPRMY3m Xv/2ZNDu6pjIAGynnLoQRDaoTT29kuxQDMaUeb2tcSkNyRkmW/VNIGgBbMpp10mm7FhY t+zqdd+gHxZfBQpD3BrlQb9Aelyq1jt+N8B4bjSjJEQptyQDILrMqyj0ZS5QEB9azDtG ougymazV+9oAnmOiJ0dDzxeHDuVWZ4MJV4bLYjKg283djWRa3cgqB+kwxU70L7gGpQBg 7GMQ== 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=/CF9W99XVoYJNDd3+iCcFlq55XNH3VI4Dmssok+metU=; b=QOQWFBTMg24ReJzEgRbQhv1u8a+MdXqolIiJ3L0Bk6Nct3krJryIcEfWWexN/hJErK C7l2RURukgSUHD5gcJhceEitCSNGADrq1nBk5sGjz//H6oEOmc+HwGrp5q4BHrfqxPsO FJVnwydSSaN4kkulvUkNwsJ/yL99DutvP6835qYUt7oaf2wuq9cpR3K6U2qLH01rWWIq SWOtUvao0OA/0cYlZ1Gyw4UUNmDI/7/oAJKKl2OD1VRc90Pd/ze2u8D+cjoIn33mDRxQ e7gMUSYjA9WKItMrFgPIlwUMjyrONB/9ao9AlbAYb4D4IkAOsIH88FARcyuMYLTt/HhC 7IAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=StbrLesM; 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 t2si1588252plz.344.2018.12.13.06.05.22; Thu, 13 Dec 2018 06:05:48 -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=StbrLesM; 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 S1729618AbeLMODf (ORCPT + 99 others); Thu, 13 Dec 2018 09:03:35 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41450 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729568AbeLMODf (ORCPT ); Thu, 13 Dec 2018 09:03:35 -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=/CF9W99XVoYJNDd3+iCcFlq55XNH3VI4Dmssok+metU=; b=StbrLesMyZm3hkPcFR0TlBB1k biToAlqNNAU45exC7ziE3x5zylI/5DM2pEuWQbX+3rIujDKvV4nLE6a76ZP9Hr/lZI40Bet7qMKIl uP3fxp9jCjilL/goM/EICUSBndGtlO/1Wfa5ICoeaS/XYaonlXuKmrb3c0BF1VwgrMFhBTsvHid7W SfxQySuBN38hg/3YQIZAdOK3fARjKc0XymAlAW2zm3VjchDATUpbqTqprgSUcH+2LxaRNI6rTAcNf m4boOKC3D79vEuu733ahoW4FoVXLJcxVHMBF9zV5t0N5yDsUCP5vTwgHCrL3px2Qg8J/tzTjW6jyo xeKh/YU/A==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXRaL-0001kl-9S; Thu, 13 Dec 2018 14:03:29 +0000 Date: Thu, 13 Dec 2018 06:03:29 -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: <20181213140329.GA25339@infradead.org> References: <20180821170629.18408-1-matwey@sai.msu.ru> <20180821170629.18408-3-matwey@sai.msu.ru> <2213616.rQm4DhIJ7U@avalon> <20181207152502.GA30455@infradead.org> <20181212090917.GA30598@infradead.org> <20181212135440.GA6137@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 Thu, Dec 13, 2018 at 12:13:29PM +0900, Tomasz Figa wrote: > Putting aside the problem of memory without struct page, one thing to > note here that what is a contiguous DMA range for device X, may not be > mappable contiguously for device Y and it would still need something > like a scatter list to fully describe the buffer. I think we need to define contiguous here. If the buffer always is physically contiguous, as it is in the currently posted series, we can always map it with a single dma_map_single call (if the hardware can handle that in a single segment is a different question, but out of scope here). If on the other hand we have multiple discontiguous physical address range that are mapped using the iommu and vmap this interface doesn't work anyway. But in that case you should just do multiple allocations and then use dma_map_sg coalescing on the hardware side, and vmap [1] if really needed. I guess for this we want to gurantee that dma_alloc_attrs with the DMA_ATTR_NON_CONSISTENT allows virt_to_page to be used on the return value, which the currently posted implementation does, although I'm a it reluctant about the API guarantee. > Do we already have a structure that would work for this purposes? I'd > assume that we need something like the existing scatterlist but with > page links replaced with something that doesn't require the memory to > have struct page, possibly just PFN? The problem is that just the PFN / physical address isn't enough for most use cases as you also need a kernel virtual address. But moving struct scatterlist to store a pfn instead of a struct page would be pretty nice for various reasons anyway. > > > > > It would also be great to use that opportunity to get rid of all the > > code duplication of almost the same dmabug provides backed by the > > DMA API. > > Could you sched some more light on this? I'm curious what is the code > duplication you're referring to. It seems like a lot of the dmabuf ops are just slight various of dma_alloc + dma_get_sttable + dma_map_sg / dma_unmap_sg. There must be a void to not duplicate that over and over. [1] and use invalidate_kernel_vmap_range and flush_kernel_vmap_range to manually take care of cache flushing.