Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2780859imm; Fri, 20 Jul 2018 04:58:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdc93YuJPw8ED9R3UxRQfJehxgIZAYStEebxmqtyEGQ0SqjiIbN3w63hpy38aZ7XYKuGv7O X-Received: by 2002:a62:b40c:: with SMTP id h12-v6mr1957611pfn.18.1532087927845; Fri, 20 Jul 2018 04:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532087927; cv=none; d=google.com; s=arc-20160816; b=GZXqZcM2DS146m3kDNjSub9pOH9Bc/9Cc9l83rW1DRRi9ixgRzkjvU+5AQx5Q5uPnP hBNQtX2DA1xl60HU1gK3sm0LaoqgBSEuU+FSFzHTFY41ntpvRmsQdRohVELrFzPn7Vxp lupeWizH9jKwtJOMPd66HyYpMaTyIfgLzdF3OsDJ/WTq4sxk2CDCSXhD2Jg2qrGNjrkb jIE6KLa++dBfx+/H7pS8uIB1d86Dg+gTeNoTVs55gH981t0Q9oMtal5c19i7MWIYglkh 6GMz3Q0oAx+0ste8lmHQpcRg3Rl6cxyg5M2hGaAlO54Q28SQx56eMYgbpiOyaoe0or8K oACQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=3KBhkYM0//pFIijGA7jXwPIu8+FxotN64wPWzocx7wg=; b=eifRjWLGNYHzK2JgYccCv7r0UjDOBNLe7/cuzLT78mV7bW0T0z5RT49Kp7t03CS5S5 YcIB/Lo+zEoWDNHDXYL29RDLMS8yOhM0FEY7Lsxbqa9Whh8Mq1HvDyzvrRz+ubUTBagn +Mf97izHVK7JGb0id3tM7dqb9SmP/FMRGvX/lCoGf104nkMMo0XHaSEIIjxJdJmz2FHS kWGdTQIwrBBU69CjrlfrkCQtSdHeRi1HF8enTOJw3wIjgjlIl2UOwAeXktQbmbMdy8XI F2Ub/RXM+L9pgH1lvYiOvJDPLkIderYIE6mAYp/6k2mOB4l+PsV5lrPWSZ0di/fE9IeF Jfww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="fE3XC5e/"; 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 v12-v6si1411073plo.264.2018.07.20.04.58.33; Fri, 20 Jul 2018 04:58:47 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="fE3XC5e/"; 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 S1729302AbeGTMpx (ORCPT + 99 others); Fri, 20 Jul 2018 08:45:53 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:39701 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727410AbeGTMpx (ORCPT ); Fri, 20 Jul 2018 08:45:53 -0400 Received: by mail-oi0-f65.google.com with SMTP id d189-v6so20853951oib.6; Fri, 20 Jul 2018 04:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=3KBhkYM0//pFIijGA7jXwPIu8+FxotN64wPWzocx7wg=; b=fE3XC5e//jxx4W0WkPyLjCSTIjgE0s9RMd50WcQ9ii5cNvz3VLjjaSByRHM84fYoas rblk3TVP7PjyvQsZEspLqSSPdjVUDwkcRCGWw7nr3yhsETrJHm9lHWWnMOgOHka//sd7 By+f+QenW3An2m2kAth1As7qFmsx2lqBQ/jcw7uaS7ZjBtzOO3FyDtIQBe/8akzOUHDR QNKahoLMKHSzV2WzjxjtlLH+H5baVljsuXdmxu2ov4hjrOaNQAxTFflCawMO/eZHMMW6 6J5cknRPlTlhFMqMkkQX+896ilqxHUMJ5WRJxkTApoAW3lrFYSM5/izcOP1nKpbu7nOs fqpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=3KBhkYM0//pFIijGA7jXwPIu8+FxotN64wPWzocx7wg=; b=WFeu6LTZzJfUk0o7zTF5UzowNdxtb8rVS26HUkFOmsSwfBqW58+FmyElcp0+VfD3PU hnppf25ZIc8tsMqCU7QQPtyeacyyCD+Q865vJ33u5cA2ZSBFg1U6aOW0F8xty77fHa+i LGFP56zWf5o2v3U8lGGwX44JT1sQks+OeTzkVwVeFJJZ6LfZY7Yvjp2NvnBAtAJSTAyl eh7IXu3jVMsnPH8vZV0vAKR+CJ153AXLm24IFApyGASfXmjkIiih/PcGvgbAhEa25yR9 fm8Ncn1iHdjMszugDxk8IYSJgT6ubdRBXS9asZs2wxxxzJ/ilqy72Jfa8OTkrvlL3MwV OXMw== X-Gm-Message-State: AOUpUlFwVlHM8n8i1DKi9F1kjfZ1GpjDpFvHf8cIXUHxBWymlnH4sI1K 3FA7Rd6eV4SR+tzOxpyFeaWcUYxTlVhexeVPyDM= X-Received: by 2002:aca:c514:: with SMTP id v20-v6mr1889441oif.153.1532087878629; Fri, 20 Jul 2018 04:57:58 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:734:0:0:0:0:0 with HTTP; Fri, 20 Jul 2018 04:57:38 -0700 (PDT) In-Reply-To: References: From: "Matwey V. Kornilov" Date: Fri, 20 Jul 2018 14:57:38 +0300 X-Google-Sender-Auth: eXTOxP4BxIwtNT6Qg6-ENoFIeiM Message-ID: Subject: Re: [PATCH 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer To: Tomasz Figa Cc: Alan Stern , Ezequiel Garcia , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Laurent Pinchart , Steven Rostedt , mingo@redhat.com, Mike Isely , Bhumika Goyal , Colin King , Linux Media Mailing List , Linux Kernel Mailing List , 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 2018-07-20 14:33 GMT+03:00 Tomasz Figa : > On Fri, Jul 20, 2018 at 8:23 PM Matwey V. Kornilov wrote: >> >> 2018-07-20 13:55 GMT+03:00 Tomasz Figa : >> > On Wed, Jul 18, 2018 at 5:51 AM Alan Stern wrote: >> >> >> >> On Tue, 17 Jul 2018, Ezequiel Garcia wrote: >> >> >> >> > Hi Matwey, >> >> > >> >> > First of all, sorry for the delay. >> >> > >> >> > Adding Alan and Hans. Guys, do you have any feedback here? >> >> >> >> ... >> >> >> >> > > > So, what is the benefit of using consistent >> >> > > > for these URBs, as opposed to streaming? >> >> > > >> >> > > I don't know, I think there is no real benefit and all we see is a >> >> > > consequence of copy-pasta when some webcam drivers were inspired by >> >> > > others and development priparily was going at x86 platforms. >> >> > >> >> > You are probably right about the copy-pasta. >> >> > >> >> > > It would >> >> > > be great if somebody corrected me here. DMA Coherence is quite strong >> >> > > property and I cannot figure out how can it help when streaming video. >> >> > > The CPU host always reads from the buffer and never writes to. >> >> > > Hardware perepherial always writes to and never reads from. Moreover, >> >> > > buffer access is mutually exclusive and separated in time by Interrupt >> >> > > fireing and URB starting (when we reuse existing URB for new request). >> >> > > Only single one memory barrier is really required here. >> >> > > >> >> > >> >> > Yeah, and not setting URB_NO_TRANSFER_DMA_MAP makes the USB core >> >> > create DMA mappings and use the streaming API. Which makes more >> >> > sense in hardware without hardware coherency. >> >> >> >> As far as I know, the _only_ advantage to using coherent DMA in this >> >> situation is that you then do not have to pay the overhead of >> >> constantly setting up and tearing down the streaming mappings. So it >> >> depends very much on the platform: If coherent buffers are cached then >> >> it's a slight win and otherwise it's a big lose. >> > >> > Isn't it about usb_alloc_coherent() being backed by DMA coherent API >> > (dma_alloc_coherent/attrs()) and ending up allocating uncached (or >> > write-combine) memory for devices with non-coherent DMAs? I'm not sure >> >> Yes, this is what exactly happens at armv7l platforms. > > Okay, thanks. So this seems to be exactly the same thing that is > happening in the UVC driver. There is quite a bit of random accesses > to extract some header fields and then a big memcpy into VB2 buffer to > assemble final frame. > > If we don't want to pay the cost of creating and destroying the > streaming mapping, we could map (dma_map_single()) once, set > transfer_dma of URB and URB_NO_TRANSFER_DMA_MAP and then just > synchronize the caches (dma_sync_single()) before submitting/after > completing the URB. Thank you. Now it is becoming clearer to me. Please allow me some time to try to sketch the implementation. > > Best regards, > Tomasz > -- With best regards, Matwey V. Kornilov. Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia 119234, Moscow, Universitetsky pr-k 13, +7 (495) 9392382