From: "Kristian Høgsberg" <krh@bitplanet.net>
To: "David Moore" <dcm@mit.edu>
Cc: "Arjan van de Ven" <arjan@infradead.org>,
linux1394-devel@lists.sourceforge.net,
theSeinfeld@users.sourceforge.net,
"Bill Davidsen" <davidsen@tmr.com>,
linux-kernel@vger.kernel.org,
libdc1394-devel@lists.sourceforge.net
Subject: Re: allocation failed: out of vmalloc space error treating and VIDEO1394 IOC LISTEN CHANNEL ioctl failed problem
Date: Mon, 15 Jan 2007 16:06:00 -0500 [thread overview]
Message-ID: <59ad55d30701151306q492e07aep9c640afd7b6c442f@mail.gmail.com> (raw)
In-Reply-To: <1168890881.10136.29.camel@pisces.mit.edu>
On 1/15/07, David Moore <dcm@mit.edu> wrote:
> On Mon, 2007-01-15 at 10:20 -0800, Arjan van de Ven wrote:
> > if you need that much you probably should redesign your algorithms to
> > not need vmalloc in the first place....
>
> I think you've convinced me that vmalloc is not a good choice when a
> driver needs a large buffer (many megabytes) for DMA.
>
> In this case, we need a large ring buffer for reception of isochronous
> packets from a firewire device. If I understand you correctly, you are
> suggesting that this buffer be obtained as followed:
>
> 1. Application performs malloc() in user-space and mmap()s it.
> 2. Driver uses vmalloc_to_page() on every page of the malloc'ed memory
> and constructs a scatter-gather list.
> 3. Map the sg list with pci_map_sg().
> 4. Commence DMA.
>
> Is that correct? In particular, does it do the right thing in terms of
> pinning the memory and dealing with high memory?
>
> I notice that the block I/O API has some convenience functions for this,
> but this is not a block device. Are there some other convenience
> functions that can be used?
>
> Forgive me if these are obvious questions -- I'm not the developer of
> video1394, but I'd still like get it right for the new firewire stack
> that's being developed.
David, thanks for bringing this up. Indeed if vmalloc is not the
right way for allocating big buffers, we need to figure something else
out. My impression was that the vmalloc group of functions could be
used for big allocations since they don't require the underlying
memory to be physically contiguous.
What I'm doing currently in the new firewire stack is to vmalloc the
memory to be used for isochronous payload and then use
remap_vmalloc_range() to map the memory to the user. I never access
the contents from the kernel side, I just use vmalloc so I can pass
the pointer to remap_vmalloc_range(). Maybe this is overkill and a
better way to do this is to call get_page() a number of times and
manually add these pages to the process address space without ever
setting up a kernel side mapping for these.
However, what I'd really like to do is to leave it to user space to
allocate the memory as David describes. In the transmit case, user
space allocates memory (malloc or mmap) and loads the payload into
that buffer. Then is does an ioctl() on the firewire control device
to indicate the location of this buffer, describe how that payload is
to be split into packets, and optionally a header per packet to
prepend. The kernel side driver then converts the user space
addresses to pages, pins the pages in question, and sets up dma
programs to transmit the packets.
Likewise for reception, user space allocates buffers for receiving the
data and then instructs the kernel the receive a certain amount of
data into this buffer. The kernel pins the pages backing the user
space buffer and sets up dma to received into those pages. Once a
page it full, it's unpinned and userspace is notified.
It's not too difficult from what I'm doing now, I'd just like to give
user space more control over the buffers it uses for streaming (i.e.
letting user space allocate them). What I'm missing here is: how do I
actually pin a page in memory? I'm sure it's not too difficult, but I
haven't yet figured it out and I'm sure somebody knows it off the top
of his head.
cheers,
Kristian
next prev parent reply other threads:[~2007-01-15 21:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.59.1168027378.1221.libdc1394-devel@lists.sourceforge.net>
[not found] ` <200701100023.39964.theSeinfeld@users.sf.net>
2007-01-14 19:19 ` Stefan Richter
2007-01-14 19:28 ` Arjan van de Ven
2007-01-14 20:31 ` Stefan Richter
2007-01-14 20:48 ` Arjan van de Ven
2007-01-15 4:14 ` Peter Antoniac
2007-01-15 6:01 ` Peter Antoniac
2007-01-15 18:02 ` Bill Davidsen
2007-01-15 18:20 ` Arjan van de Ven
2007-01-15 19:54 ` David Moore
2007-01-15 21:06 ` Kristian Høgsberg [this message]
2007-01-15 21:24 ` Arjan van de Ven
2007-01-15 21:43 ` Kristian Høgsberg
2007-01-16 2:40 ` Peter Antoniac
2007-01-16 5:21 ` David Moore
2007-01-16 17:58 ` Arjan van de Ven
2007-01-16 8:16 ` Gerd Hoffmann
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=59ad55d30701151306q492e07aep9c640afd7b6c442f@mail.gmail.com \
--to=krh@bitplanet.net \
--cc=arjan@infradead.org \
--cc=davidsen@tmr.com \
--cc=dcm@mit.edu \
--cc=libdc1394-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=theSeinfeld@users.sourceforge.net \
/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
all inboxes | Powered by JetHome®