Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp379373imu; Wed, 12 Dec 2018 19:15:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfzCh8rVRtuvT8oYMzWaTYqmhTVRbmxKRW53RCdLNGQOlrvDGdljMLPuPKvRxkwBh4UUlj X-Received: by 2002:a63:fa02:: with SMTP id y2mr20627455pgh.177.1544670905555; Wed, 12 Dec 2018 19:15:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544670905; cv=none; d=google.com; s=arc-20160816; b=CxdiyhvHoFQZT7o7/gZIJiv0o11M1rMWCBCxvOr1DCtwi+jVzoSnTml5BSdBhqPPbj fJux1iCOjb0NV5bje+7bXzDrDxH6j0kSdbV2UXg2d0KasHwEsgaAGyJB+1i9vlamAD8C oZmpgmnS8R4wC+5o7pdtM2bT35MOW+mw3cF1Aws3vA84MRBef6xFDc53cf+olmBlsD9H dcmZjYZffBQT1+LwzZJcwqe++rIguI7oSLo7h81KfG2kDGHjE+GZRrmeDEWuuRWUcAbe A1fEJ+NCneeai9SvQ3wMlPNnw5ymE5yuOqjVH5GNX3kz9dDdE8ebII6XTbwLv8zE5ZZ7 fDUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=MldMfPal7dPKOr4CmHsfYUHEZUZOt1yez2Jjq7koQXo=; b=LyJKyW86PEgvLplfpt0P1yQ1Qvuztd1cINFxdZ5NfBZGflE/9Y2znrKgINUqrERCG2 9kLRYKekazSFy5xVfw+8CbLOCpP78NBVmHQLd2yzlsKHKx+SyAwYRBCZFEwkrxa3b1hH /GgYU3hoWFMAlhvgu8UYjN8LoUlFyMw+BvKoL6USntjkzgA9i98fhYffEeX5JScxf1TI 6KQTYX/mDRagfSi69fPbwMd0B8vTCPr+BeHumefDNXCDEZQ2mItRbXKPbUeUTAU7bPSP /4PuZGEolhXeWRQsi0zzL02cNonw3sQ4aj8LGH5uGnkghF0zgncreEIRWVmW+O00Svh1 oXHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FfMIJow9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n30si516317pgb.406.2018.12.12.19.14.50; Wed, 12 Dec 2018 19:15:05 -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=pass header.i=@chromium.org header.s=google header.b=FfMIJow9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbeLMDNn (ORCPT + 99 others); Wed, 12 Dec 2018 22:13:43 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:47008 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbeLMDNn (ORCPT ); Wed, 12 Dec 2018 22:13:43 -0500 Received: by mail-yb1-f195.google.com with SMTP id f9so226364ybm.13 for ; Wed, 12 Dec 2018 19:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MldMfPal7dPKOr4CmHsfYUHEZUZOt1yez2Jjq7koQXo=; b=FfMIJow9xXjJOb9uv+S19WVho/xpoSYdlRYljj8NsdspAOdNL73U6VH+gl/3OTmdRQ ynJzdHPThQIJ4l/PQWrQuC36P5q2EnvePsoGDEMF3Fx61d1sy8GUptwnACHS+q112Vbo YfbkFbVMptj9BV93h65Mhgrl2Ane1hawHzGIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MldMfPal7dPKOr4CmHsfYUHEZUZOt1yez2Jjq7koQXo=; b=R9mJm60EVnrWK9y8++a71m/12x78LH6hTXcp0HQxKWz2nN2eHRy0tTNQHgQFZlk45j okqNbHJbdqmJ1ls2zyA6vGwEZAzTCvzeIa5irNPcikKx+n/zQVNE2U8XKYLo/5XKlQnD ELly9vUaml5sUr/KQXlS5ozQKkibVReIOICzAgp6RaMFI5kZ9HysUDdivg/vhI4r06bn 6+Kw4xO+KrlNhPu/VUpJ5887IYfzOMXLfQdCRVPEP37nMGkcxmxaXcImygO0uhgamZds cSTf/vk/PSy3yGKhWhsBEqaJ7oFRW3aJl3MhTRZRW4D4DDY7Niqv1+sIuTvk4cviwzKr lbmA== X-Gm-Message-State: AA+aEWbnYtC4X6npEXop3c31qmuJuTXdhKFqz64MEUSzzjiT5DzmcNDo mk6Nm6NHG7/W8UdRqO9MZaSi+1HE+NdEEQ== X-Received: by 2002:a5b:648:: with SMTP id o8mr11325287ybq.504.1544670822354; Wed, 12 Dec 2018 19:13:42 -0800 (PST) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id 136sm229518ywm.28.2018.12.12.19.13.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 19:13:41 -0800 (PST) Received: by mail-yb1-f176.google.com with SMTP id d187so243518ybb.5 for ; Wed, 12 Dec 2018 19:13:41 -0800 (PST) X-Received: by 2002:a25:a44:: with SMTP id 65-v6mr22661413ybk.373.1544670820921; Wed, 12 Dec 2018 19:13:40 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20181212135440.GA6137@infradead.org> From: Tomasz Figa Date: Thu, 13 Dec 2018 12:13:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer To: Christoph Hellwig Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 12, 2018 at 10:54 PM Christoph Hellwig wrote: > > On Wed, Dec 12, 2018 at 06:34:25PM +0900, Tomasz Figa wrote: > > The typical DMA-buf import/export flow is as follows: > > 1) Driver X allocates buffer A using this API for device x and gets a > > DMA address inside x's DMA (or IOVA) address space. > > 2) Driver X creates a dma_buf D(A), backed by buffer A and gives the > > user space process a file descriptor FD(A) referring to it. > > 3) Driver Y gets FD(A) from the user space and needs to map it into > > the DMA/IOVA address space of device y. It doe it by calling > > dma_buf_map_attachment() which returns an sg_table describing the > > mapping. > > And just as I said last time I think we need to fix the dmabuf code > to not rely on struct scatterlist. struct scatterlist is an interface > that is fundamentally page based, while the dma coherent allocator > only gives your a kernel virtual and dma address (and the option to > map the buffer into userspace). So we need to fix to get the interface > right as we already have DMAable memory withour a struct page and we > are bound to get more of those. Nevermind all the caching implications > even if we have a struct page. 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. 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? > > 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. Best regards, Tomasz