Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2040025imm; Thu, 20 Sep 2018 06:56:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZbF6h4Z+GUMWOlI7W43q8RxUo3kPX+kNTl8okIP5K5YEDYf5fmmtGxsJu15gLONuUYcSMy X-Received: by 2002:a62:b0e:: with SMTP id t14-v6mr40927346pfi.36.1537451785569; Thu, 20 Sep 2018 06:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537451785; cv=none; d=google.com; s=arc-20160816; b=N2iX/mQJjyXm83Nxm3ueJSoh06AIXy4o7ukUnHznxKZAdlcifaAdqyn/aeEkxdFFOn 1q4J7uMWlTRT9+CqqtHcBlqCc8enNVwSfRMb5KXuPWcEKBsHbBuFjHOwiJBvnDYBLv/v WoYGQqPcfqyviSqByb8zH8yvRjwIXDCuoeLZuNBTXQDXO8QyEooISVLrbpkDxPh8WI0T Wdh4M+FtH1QkT4TsPHrcsVyW0VvKwdnedV7MmG1tT2DAjIeAFz0kHPWnk6YOOwBhuD1c XT4pkYk9QxgB1BdjDhg6UjBc3BsaZEzfprhbDBO3FJGzKKnFJxeQ7JRNGeowwfakXGVp M6qg== 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:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id; bh=l0pNoX2VysAMtsymfej0A4eFEnzqNtlEHea6ycuJuDU=; b=K4bDpQcfvTteHk/b5kBscKdxSngRaE7aXFAp+u5VVPnYgROqQDZx9jlQzgqkO97RoF StlQ3cw+nxHzJj6lcvJ7e/0LO9MAhmC8zp6wMEyWQrPAKM9W21LO5IHDvlAlClmbpifk FhmQvRR35iBvHRf9OYhnnLwX04wi0cLIyp1I9snITPQkYflC43R/XBWjy0sdOKgRkFsJ KX933TF6hdJHia+tHgDw3GpnCH1Htb71KHCaZkbsusF0u/pOiXLIILJ1He+aX8/kJJp2 8SrhiYVcQwjoG0dx51gFJloq2XUbkKgQFvZvN987zMcl8xkkKc6C88B4t3U5tNDuGdWm oEHA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i90-v6si23713342pli.274.2018.09.20.06.56.00; Thu, 20 Sep 2018 06:56:25 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732555AbeITTja (ORCPT + 99 others); Thu, 20 Sep 2018 15:39:30 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45790 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731223AbeITTja (ORCPT ); Thu, 20 Sep 2018 15:39:30 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id BA7D427D89E Message-ID: <5b84e0e4f1b0cbfd3cf3e641c41f9fc50a74e6bf.camel@collabora.com> Subject: Re: [PATCH v4 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer From: Ezequiel Garcia To: Alan Stern , Laurent Pinchart Cc: "Matwey V. Kornilov" , Linux Media Mailing List , open list , Tomasz Figa , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Steven Rostedt , mingo@redhat.com, Mike Isely , Bhumika Goyal , Colin King , Kieran Bingham , keiichiw@chromium.org Date: Thu, 20 Sep 2018 10:55:43 -0300 In-Reply-To: References: Organization: Collabora Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alan, Laurent: On Fri, 2018-08-10 at 10:27 -0400, Alan Stern wrote: > 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. > Can either of you ack or nack this change? I'd like to see this merged, or either re-worked, so we can merge it. Thanks! Eze