Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp53950imm; Fri, 10 Aug 2018 07:31:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzwp5JZx9zbfmM9pAoqKKIy6Tpky4wO7djBNTqUfBA4hKT8leQwYwsK/G5ElEQA5B2YbK/e X-Received: by 2002:a62:3001:: with SMTP id w1-v6mr7331823pfw.19.1533911466407; Fri, 10 Aug 2018 07:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533911466; cv=none; d=google.com; s=arc-20160816; b=Cl+l62M1G7zkjwrWk0NjsnH57Phii/86Yigpv275HCq+toDWFzhedVLGcfSCtYlyab f0j5BFsviiPkjFc6Lm8BDl90Ou1ZiuIJAzVD6ymEkr8jquZqR/wt2it6Z5mFsLAsxM77 S8LqLhhnaQhxAaG9tF+KyJmWldOn7+VMXmEHgwOuWE8lEg4Ft/XTl5DaGoNSDUA8/D6u XRx8z80Azl/fRRDRHIrArU6utBpwaI/2N1Y/YwdW1Sp5Vxw9GTNBk4ln5q8asW4Ju0ns DsARC1cP7BZcxOYXAhgx4Inc5x44h03lG0y+LwTM6XIlw7EB3e3LJJP4ienoGMd4qkVq sSSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=2ynoeR7pWeEGq4BXmn4XxUtSahU6nt5qKcJFVAe+Um8=; b=0mROZE6zqpaolKdarVXEc2AXD/3JX8fdbIimtRIGj8LgiUe++wiXEoXBK36IBAgviy PRSX5m8D1Rx3MA2WTLDm7WlAxzsOWuivtwfarhIA4nqtlPMJJDjFZrUhLXiFyxuH+zwU mk/+bPnPOGS46ANVeKCRaJcEW520kMPFgydCzCG2FXuYKjGQmcvI57r3JEwg87rqtRPo Fj+0fxSeBeqJB3N3epgMRZvvYiU+ZAApCwOC8nHlaM+V4u9mTtqz+84+3CbLAZyHPajz W/puUrM/KQJneTz4q4VZ60WaaPJavyLS9p65+WiPJaZaFvx65vhSTXZSbbHKJpg1900Y ax5g== ARC-Authentication-Results: i=1; mx.google.com; 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 n1-v6si7767149pld.429.2018.08.10.07.30.43; Fri, 10 Aug 2018 07:31: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; 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 S1728153AbeHJQ5q (ORCPT + 99 others); Fri, 10 Aug 2018 12:57:46 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:57368 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727432AbeHJQ5q (ORCPT ); Fri, 10 Aug 2018 12:57:46 -0400 Received: (qmail 1602 invoked by uid 2102); 10 Aug 2018 10:27:37 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 10 Aug 2018 10:27:37 -0400 Date: Fri, 10 Aug 2018 10:27:37 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Laurent Pinchart cc: "Matwey V. Kornilov" , Linux Media Mailing List , open list , Tomasz Figa , Ezequiel Garcia , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Steven Rostedt , , Mike Isely , Bhumika Goyal , Colin King , Kieran Bingham , Subject: Re: [PATCH v4 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer In-Reply-To: <66694963.VB7x4V86dC@avalon> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 re-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 write > > > to a DMA_FROM_DEVICE-mapped area, so dma_sync_single_for_device() is > > > not needed. > > I fully agree that the CPU should not write to the buffer. However, I think > the sync call is still needed. It's been a long time since I touched this > area, but IIRC, some cache architectures (VIVT ?) require both cache clean > before the transfer and cache invalidation after the transfer. On platforms > where no cache management operation is needed before the transfer in the > 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 != empty. Rather, clean == !dirty.) Therefore transfers 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. Alan Stern