Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1040484imm; Fri, 17 Aug 2018 10:47:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzCZyg0mkmeWj4xqSmSKXli4OFBGRK0buLoaD/yuTBE9PHIUFgfeRwkaaUFjHsPH0giVBgW X-Received: by 2002:a17:902:b70f:: with SMTP id d15-v6mr26848434pls.53.1534528026314; Fri, 17 Aug 2018 10:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534528026; cv=none; d=google.com; s=arc-20160816; b=C+OJgiSqlj/EpiZGFCidmJv3D3cYhi1/kFqmW3tF08QciIWLL08nhaeNUfSM4/iR0L f04iKfuNzS+x33hEGeTE2SDcbfhZ9JIYQCYVlQggQmImUaRBqTUZmy697Va2zP6fBioN OR0fOfKH+gNTu5ylrnMRzq3GGkqUmeUaRmJneBCqwpvRD1wwRrHh69gIj9PZiMZR5f9Y q6zSUthm0f0epq4BLI4Z406G5qxt0MjM9uhOwwDkVFKOSxgLD/8nSTbwap3E+Uwq6ONo h07u4FXmrExGt39UkTE1NBXJAfpcO+1TYK6QPpdF5bNsYx3sejYqnFposXNL6Jq5GC6F 7KJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=47bva1FwOvZha3+c6EC0lnETgaFc5rRSsy1ialbGhBQ=; b=vEk9lbZPtBNaAWw71g9gtlLNUfq8MkASDxFbgtVEA+xW1KoyzFGJpvo4jGLxy+2gEv ZMXSamN/C32L6HQUvC2GIwxQimZpifsXZ+dYaHMV2szP+tUUJDrcWI+h4E/ymxXqapVs 09OkqKBfV9Ix5qWSaPWsCeTa+AnkR+wKJt0u8fzIpeiaHraKZa4dFn0KZ88zH6UZ2C/O Cs9NN6+udqWkyg2i6nFzN6xS6/E0vcQ7/j3SNkoFAznsxdKWdFkYnK/Prl59H6tXVz/z b0YC66hAaUOAr1Qh0MlUJezW179Ur8eWwjpsrlXSw6ak9qQRznesZNALbQ22kr2q8YyB 7Cjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tYIbQz41; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20-v6si2561690pgk.120.2018.08.17.10.46.51; Fri, 17 Aug 2018 10:47:06 -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=pass header.i=@gmail.com header.s=20161025 header.b=tYIbQz41; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728115AbeHQUtS (ORCPT + 99 others); Fri, 17 Aug 2018 16:49:18 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:45840 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727365AbeHQUtS (ORCPT ); Fri, 17 Aug 2018 16:49:18 -0400 Received: by mail-oi0-f68.google.com with SMTP id q11-v6so15316413oic.12; Fri, 17 Aug 2018 10:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=47bva1FwOvZha3+c6EC0lnETgaFc5rRSsy1ialbGhBQ=; b=tYIbQz414mOGf2qqXpQVtfWJRjVPqTnFcB5hRqsnJxCVaeydHmpXwTBXhXVBdjAN5R RYUSTJPgMwMfWVIxFt6RMkvHi8ejmwSTBtmvsxRulHo53HxzRc9KsSCYuI2LTkkyjC54 rA9lRwyYvSSrNDj8VI/ZAG0J4pTi/6MvnVR5iPFyikEj4gUifmTBfWhUYzgVWApy6n9w ObzDPQnWUk2x1u8WVgCygVw0pBMceI2d8iBRcK+GUkG2UG1/ABICEv4xVqx8XyFYqtxi f+0UwiUlzhZRBJmo1+xYrSRaPrqapgAZwnaNkQ34M9XLffCboZR9NXHwRogOzzquyR2o NtBQ== 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:content-transfer-encoding; bh=47bva1FwOvZha3+c6EC0lnETgaFc5rRSsy1ialbGhBQ=; b=lmMRBSHB1+etmfO3YnVjxvnC5TPZhiw8GlAbzcNqcoU2B1aSuNKrdTFd3OEQOqqtLN wl8X41GdvpKDN/jhC7WXpmzWAYCqeJIG2c/oU6OEbY/6Qbn6/654mOqXL+wd36pMHl/9 PGXTR9IT6Y9kJqTDL/lNd+RmfuZhVakb+JQ55eT6zrfXaECyQ67XnC+BWHhN9iWJQi5o 9rjCeThzPoFiw1+NNREZL7eirhFm/tD9259Zi5HO5eecRQ1Zlz8IaXW+EBxRKi8iOAAL bu9iLrN27lJvtZyzMN4uoxa/FHZ9F5plOBtWabTQaheFi7sIWeJz3XZAt58KZA5GMHTj eCIQ== X-Gm-Message-State: AOUpUlGy6+UDa3gBQasSpb3RH5++0kNAfqEOa4+ZRZfMjt9nkchHttr+ qWAD7HvO/OUWU+yIEoyWBEb04eyi2RTsTiccDZo= X-Received: by 2002:aca:56d1:: with SMTP id k200-v6mr3553944oib.319.1534527901096; Fri, 17 Aug 2018 10:45:01 -0700 (PDT) MIME-Version: 1.0 References: <66694963.VB7x4V86dC@avalon> In-Reply-To: From: "Matwey V. Kornilov" Date: Fri, 17 Aug 2018 20:44:49 +0300 Message-ID: Subject: Re: [PATCH v4 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer To: Alan Stern Cc: Laurent Pinchart , Linux Media Mailing List , open list , Tomasz Figa , Ezequiel Garcia , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Steven Rostedt , mingo@redhat.com, Mike Isely , Bhumika Goyal , Colin King , Kieran Bingham , keiichiw@chromium.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =D0=BF=D1=82, 10 =D0=B0=D0=B2=D0=B3. 2018 =D0=B3. =D0=B2 17:27, Alan Stern = : > > On Fri, 10 Aug 2018, Laurent Pinchart wrote: > > > > > Aren't you're missing a dma_sync_single_for_device() call before > > > > submitting the URB ? IIRC that's required for correct operation of = the DMA > > > > mapping API on some platforms, depending on the cache architecture.= The > > > > additional sync can affect performances, so it would be useful to r= e-run > > > > the perf test. > > > > > > This was already discussed: > > > > > > https://lkml.org/lkml/2018/7/23/1051 > > > > > > I rely on Alan's reply: > > > > > > > According to Documentation/DMA-API-HOWTO.txt, the CPU should not wr= ite > > > > to a DMA_FROM_DEVICE-mapped area, so dma_sync_single_for_device() i= s > > > > not needed. > > > > I fully agree that the CPU should not write to the buffer. However, I t= hink > > the sync call is still needed. It's been a long time since I touched th= is > > area, but IIRC, some cache architectures (VIVT ?) require both cache cl= ean > > before the transfer and cache invalidation after the transfer. On platf= orms > > where no cache management operation is needed before the transfer in th= e > > DMA_FROM_DEVICE direction, the dma_sync_*_for_device() calls should be = no-ops > > (and if they're not, it's a bug of the DMA mapping implementation). > > In general, I agree that the cache has to be clean before a transfer > starts. This means some sort of mapping operation (like > dma_sync_*_for-device) is indeed required at some point between the > allocation and the first transfer. > > For subsequent transfers, however, the cache is already clean and it > will remain clean because the CPU will not do any writes to the buffer. > (Note: clean !=3D empty. Rather, clean =3D=3D !dirty.) Therefore transf= ers > following the first should not need any dma_sync_*_for_device. > > If you don't accept this reasoning then you should ask the people who > wrote DMA-API-HOWTO.txt. They certainly will know more about this > issue than I do. Laurent, I have not seen any data corruption or glitches without dma_sync_single_for_device() on ARM and x86. It takes additional ~20usec for dma_sync_single_for_device() to run on ARM. So It would be great to ensure that we can reliable save another 15% running time. > > Alan Stern > -- With best regards, Matwey V. Kornilov