linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matwey V. Kornilov" <matwey.kornilov@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Tomasz Figa <tfiga@chromium.org>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	mingo@redhat.com, Mike Isely <isely@pobox.com>,
	Bhumika Goyal <bhumirks@gmail.com>,
	Colin King <colin.king@canonical.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	keiichiw@chromium.org
Subject: Re: [PATCH v4 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer
Date: Fri, 17 Aug 2018 20:44:49 +0300	[thread overview]
Message-ID: <CAJs94EYH2BrHseveJV_xqYs5zK0NxrdQ8NhjrCp7tytK=KsF0g@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1808101019550.1425-100000@iolanthe.rowland.org>

пт, 10 авг. 2018 г. в 17:27, Alan Stern <stern@rowland.harvard.edu>:
>
> 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.

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

  reply	other threads:[~2018-08-17 17:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 18:11 [PATCH v4 0/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer Matwey V. Kornilov
2018-08-09 18:11 ` [PATCH v4 1/2] media: usb: pwc: Introduce TRACE_EVENTs for pwc_isoc_handler() Matwey V. Kornilov
2018-08-09 18:26   ` Steven Rostedt
2018-08-09 18:39     ` Matwey V. Kornilov
2018-08-09 18:11 ` [PATCH v4 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer Matwey V. Kornilov
2018-08-10  8:53   ` Laurent Pinchart
2018-08-10  9:38     ` Matwey V. Kornilov
2018-08-10  9:49       ` Laurent Pinchart
2018-08-10 14:27         ` Alan Stern
2018-08-17 17:44           ` Matwey V. Kornilov [this message]
2018-08-21  8:36             ` Matwey V. Kornilov
2018-09-20 13:55           ` Ezequiel Garcia
2018-09-20 14:28             ` Alan Stern
2018-08-09 19:31 ` [PATCH v4 0/2] " Linus Torvalds
2018-08-10  8:28   ` Matwey V. Kornilov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJs94EYH2BrHseveJV_xqYs5zK0NxrdQ8NhjrCp7tytK=KsF0g@mail.gmail.com' \
    --to=matwey.kornilov@gmail.com \
    --cc=bhumirks@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=ezequiel@collabora.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=isely@pobox.com \
    --cc=keiichiw@chromium.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).