From: Hans Verkuil <hverkuil@xs4all.nl>
To: Ran Shalit <ranshalit@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: cobalt & dma
Date: Fri, 20 Nov 2015 17:25:07 +0100 [thread overview]
Message-ID: <564F4963.5050902@xs4all.nl> (raw)
In-Reply-To: <CAJ2oMhLWHCNxDmwOnwBxPdjjqbcO6Q2khBrzohMET=LsQ_AQjg@mail.gmail.com>
On 11/20/2015 05:14 PM, Ran Shalit wrote:
>>>
>>> 1. I tried to understand the code implementation of videobuf2 with
>>> regards to read():
>>> read() ->
>>> vb2_read() ->
>>> __vb2_perform_fileio()->
>>> vb2_internal_dqbuf() & copy_to_user()
>>>
>>> Where is the actual allocation of dma contiguous memory ? Is done with
>>> the userspace calloc() call in userspace (as shown in the v4l2 API
>>> example) ? As I understand the calloc/malloc are not guaranteed to be
>>> contiguous.
>>> How do I know if the try to allocate contigious memory has failed or not ?
>>
>> The actual allocation happens in videobuf2-vmalloc/dma-contig/dma-sg depending
>> on the flavor of buffers you want (virtual memory, DMA into physically contiguous
>> memory or DMA into scatter-gather memory). The alloc operation is the one that
>> allocates the memory.
>
>
> Thank you very much for the time.
>
> Just to be sure I understand the general mechanism of DMA with regards
> to the read() operation and in the case of using contiguous memory,
> I try to draw the general sequence as I understand it from the code
> and reading on this issue:
>
> read() into user memory buffer ->
> vb2_read() ->
> __vb2_perform_fileio() ->
> deaque buffer with: vb2_internal_dqbuf() into
> contiguous DMA memory (kernel) ->
> copy_to_user() will actually copy from
> the contigious dma memory(kernel) into user buffer (userspace)
>
> 1. Is the above sequence correct ?
Yes.
> 2. When talking about contiguous dma memory (or scatter-gatther) we
> actually always refer to memory allocated in kernel, right ?
Usually. With the V4L2_MEMORY_USERPTR stream I/O mode it is userspace
that allocates the memory, but when using physically contiguous DMA
this particular streaming mode is normally not supported.
With V4L2_MEMORY_MMAP it is always the kernel that allocates the memory.
Regards,
Hans
prev parent reply other threads:[~2015-11-20 16:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 7:39 cobalt & dma Ran Shalit
2015-11-17 7:53 ` Hans Verkuil
2015-11-17 13:15 ` Ran Shalit
2015-11-17 13:32 ` Steven Toth
2015-11-17 13:54 ` Hans Verkuil
2015-11-17 21:43 ` Ran Shalit
2015-11-20 14:49 ` Ran Shalit
2015-11-20 14:55 ` Hans Verkuil
2015-11-20 16:14 ` Ran Shalit
2015-11-20 16:25 ` Hans Verkuil [this message]
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=564F4963.5050902@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=ranshalit@gmail.com \
/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