linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Memory Mapping Buffers smaller than page size?
@ 2010-07-28 13:14 Ravi Gupta
  2010-07-28 14:21 ` Simon Richter
  0 siblings, 1 reply; 3+ messages in thread
From: Ravi Gupta @ 2010-07-28 13:14 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Hi,

I am new to linux device drivers development. I have created 16 buffers of
size 256 bytes each(using kmalloc()) in my device driver code. I want to
memory map these buffers to user space. Now is it possible to memory map
these buffer(16*256 = 4096 = 1 page on 32 bit linux) into a single page in
user space OR i have to map them in individual pages in user space? Note,
all the buffers may not be stored in continuous memory location.

Thanks in advance
Ravi Gupta

[-- Attachment #2: Type: text/html, Size: 492 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memory Mapping Buffers smaller than page size?
  2010-07-28 13:14 Memory Mapping Buffers smaller than page size? Ravi Gupta
@ 2010-07-28 14:21 ` Simon Richter
  2010-07-29  6:15   ` Ravi Gupta
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Richter @ 2010-07-28 14:21 UTC (permalink / raw)
  To: Ravi Gupta; +Cc: linuxppc-dev

Hi,

On Wed, Jul 28, 2010 at 06:44:10PM +0530, Ravi Gupta wrote:

> I am new to linux device drivers development. I have created 16 buffers of
> size 256 bytes each(using kmalloc()) in my device driver code. I want to
> memory map these buffers to user space. Now is it possible to memory map
> these buffer(16*256 = 4096 = 1 page on 32 bit linux) into a single page in
> user space OR i have to map them in individual pages in user space? Note,
> all the buffers may not be stored in continuous memory location.

Pages are the smallest unit for mappings, so each buffer would end up in
its own mapping. If you want the buffers to be accessible without an
offset, then you cannot have them in continuous locations, as you cannot
map memory from the middle of a page to the beginning either.

So your options are: one page per buffer (wasteful, but gives you
granular access control), or allocating all the buffers as a single
block.

   Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Memory Mapping Buffers smaller than page size?
  2010-07-28 14:21 ` Simon Richter
@ 2010-07-29  6:15   ` Ravi Gupta
  0 siblings, 0 replies; 3+ messages in thread
From: Ravi Gupta @ 2010-07-29  6:15 UTC (permalink / raw)
  To: Simon Richter; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

Hi Simon,

Thanks for the quick reply. One more thing I want to ask is what if I create
a dma pool (using pci_pool_create()), allocate dma buffers from that pool
and then try to memory map them? will the buffers in that case will be
continuous and is it possible to memory map them in a single user space
page?

Thanks in advance
Ravi Gupta

On Wed, Jul 28, 2010 at 7:51 PM, Simon Richter <Simon.Richter@hogyros.de>wrote:

> Hi,
>
> On Wed, Jul 28, 2010 at 06:44:10PM +0530, Ravi Gupta wrote:
>
> > I am new to linux device drivers development. I have created 16 buffers
> of
> > size 256 bytes each(using kmalloc()) in my device driver code. I want to
> > memory map these buffers to user space. Now is it possible to memory map
> > these buffer(16*256 = 4096 = 1 page on 32 bit linux) into a single page
> in
> > user space OR i have to map them in individual pages in user space? Note,
> > all the buffers may not be stored in continuous memory location.
>
> Pages are the smallest unit for mappings, so each buffer would end up in
> its own mapping. If you want the buffers to be accessible without an
> offset, then you cannot have them in continuous locations, as you cannot
> map memory from the middle of a page to the beginning either.
>
> So your options are: one page per buffer (wasteful, but gives you
> granular access control), or allocating all the buffers as a single
> block.
>
>   Simon
>

[-- Attachment #2: Type: text/html, Size: 1848 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-29  6:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-28 13:14 Memory Mapping Buffers smaller than page size? Ravi Gupta
2010-07-28 14:21 ` Simon Richter
2010-07-29  6:15   ` Ravi Gupta

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).