Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2081024imm; Thu, 20 Sep 2018 07:30:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaVPpTNURaQSa1unfShtOBTHMfl7O2zaEtr4yGYyFiKZQCBiHyIGuEzibQD5TlCEo97sNhw X-Received: by 2002:a17:902:5a87:: with SMTP id r7-v6mr39801055pli.247.1537453844467; Thu, 20 Sep 2018 07:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537453844; cv=none; d=google.com; s=arc-20160816; b=AAZMmZXXI63+0Dw9skrbrYX0enLeZR3CEAOI6CVWkqVhcNgsKqJKDnZxQuuOHjCXLI SKLUMpiWioC/7LM0kO3jzQbcdFPfbAvXi33+SNwlodcToxU1aeDTI6DAqW6nRqw5Lvg2 nlEaL49IRYVtNSwSFPg1yBaWwK6iU2fH4IooOOMqnBXAyzpXi9M/E0y2fkT3h94FO4Dn j98c7B/KjT0YYmLpzgKz9mcKqxJe8yT0q0m/2/uaZMAsUuZN1NLenUySdGPs4mhBn6iW gadoTDWJYbPRpDrm3xv8EcKxWBw02mpt0afTUJQ4Bx+GGbB8q5ZJkEJytZ4SEMU66cBS yr6Q== 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; bh=SOVZl3M+K7vfkjlIHak+2PBXi2r5wy6CyUe/yLQC8sI=; b=RHtImSpZrIlRuQIAm8S9dAFoqG+FRS7sv36D5MyL3VN4hCwv7f8OlaTNDZpt/klq95 BVGLDCLRjou0t/3xdetYsvIXtVAaNOr4m1jo620ERI3QKrWpPaBH6kKrCoAM9By9KNVx lFEx2LCRb7lFH7ZQ8gj9GjPlIqmB+rKj2MxDuN1slLXhHQFmJTaC1xh8LRSdNBlDKQqi udeROpvkZkr2UgOj+FHAYF2bpeMEB4cdxLU90ArWGSFa/8Sfc6508i69Y4JIU+itMgip 33Wzp+3JA9ssWajJ1ar+0dYZwqlu4wjjopnA7Qtm5nfDDZ7NfcVDd3bB5QMEvfOywt4W LZHg== 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 n3-v6si23651486pgh.359.2018.09.20.07.30.28; Thu, 20 Sep 2018 07:30:44 -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 S2387481AbeITUMZ (ORCPT + 99 others); Thu, 20 Sep 2018 16:12:25 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:33320 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1731416AbeITUMY (ORCPT ); Thu, 20 Sep 2018 16:12:24 -0400 Received: (qmail 3386 invoked by uid 2102); 20 Sep 2018 10:28:39 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Sep 2018 10:28:39 -0400 Date: Thu, 20 Sep 2018 10:28:39 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Ezequiel Garcia cc: Laurent Pinchart , "Matwey V. Kornilov" , Linux Media Mailing List , open list , Tomasz Figa , 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: <5b84e0e4f1b0cbfd3cf3e641c41f9fc50a74e6bf.camel@collabora.com> 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 Thu, 20 Sep 2018, Ezequiel Garcia wrote: > 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. I don't have the hardware and I'm not terribly familiar with that part of the code, so it would be better for Laurent to respond. The basic idea seems good, but I'm not looking at the details. Alan Stern