All of lore.kernel.org
 help / color / mirror / Atom feed
* Reserving a fixed physical address page of RAM.
@ 2006-11-27 16:31 Jon Ringle
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-27 16:31 UTC (permalink / raw)
  To: linux-kernel

Hi,

I need to reserve a page of memory at a specific area of RAM that will
be used as a "shared memory" with another processor over PCI. How can I
ensure that the this area of RAM gets reseved so that the Linux's memory
management (kmalloc() and friends) don't use it?

Some things that I've considered are iotable_init() and ioremap().
However, I've seen these used for memory mapped IO devices which are
outside of the RAM memory. Can I use them for reseving RAM too?

I appreciate any advice in this regard.

Thanks,

Jon

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

* Re: Reserving a fixed physical address page of RAM.
       [not found] <fa.LC2HgQx8572p2lwOKfUm6cxg95s@ifi.uio.no>
@ 2006-11-28  0:38 ` Robert Hancock
  2006-11-28  3:36   ` Jon Ringle
  0 siblings, 1 reply; 16+ messages in thread
From: Robert Hancock @ 2006-11-28  0:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jon Ringle

Jon Ringle wrote:
> Hi,
> 
> I need to reserve a page of memory at a specific area of RAM that will
> be used as a "shared memory" with another processor over PCI. How can I
> ensure that the this area of RAM gets reseved so that the Linux's memory
> management (kmalloc() and friends) don't use it?
> 
> Some things that I've considered are iotable_init() and ioremap().
> However, I've seen these used for memory mapped IO devices which are
> outside of the RAM memory. Can I use them for reseving RAM too?
> 
> I appreciate any advice in this regard.

Sounds to me like dma_alloc_coherent is what you want..

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/


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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  0:38 ` Reserving a fixed physical address page of RAM Robert Hancock
@ 2006-11-28  3:36   ` Jon Ringle
  2006-11-28  5:19     ` Robert Hancock
                       ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-28  3:36 UTC (permalink / raw)
  To: Robert Hancock; +Cc: linux-kernel

Robert Hancock wrote:
> Jon Ringle wrote:
>> Hi,
>>
>> I need to reserve a page of memory at a specific area of RAM that will
>> be used as a "shared memory" with another processor over PCI. How can I
>> ensure that the this area of RAM gets reseved so that the Linux's memory
>> management (kmalloc() and friends) don't use it?
>>
>> Some things that I've considered are iotable_init() and ioremap().
>> However, I've seen these used for memory mapped IO devices which are
>> outside of the RAM memory. Can I use them for reseving RAM too?
>>
>> I appreciate any advice in this regard.
>
> Sounds to me like dma_alloc_coherent is what you want..
>
It looks promising, however, I need to reserve a physical address area 
that is well known (so that the code running on the other processor 
knows where in PCI memory to write to). It appears that 
dma_alloc_coherent returns the address that it allocated. Instead I need 
something where I can tell it what physical address and range I want to use.

Jon

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  3:36   ` Jon Ringle
@ 2006-11-28  5:19     ` Robert Hancock
  2006-11-28  5:34     ` Dave Airlie
  2006-11-28 13:04     ` linux-os (Dick Johnson)
  2 siblings, 0 replies; 16+ messages in thread
From: Robert Hancock @ 2006-11-28  5:19 UTC (permalink / raw)
  To: Jon Ringle; +Cc: linux-kernel

Jon Ringle wrote:
> Robert Hancock wrote:
>> Jon Ringle wrote:
>>> Hi,
>>>
>>> I need to reserve a page of memory at a specific area of RAM that will
>>> be used as a "shared memory" with another processor over PCI. How can I
>>> ensure that the this area of RAM gets reseved so that the Linux's memory
>>> management (kmalloc() and friends) don't use it?
>>>
>>> Some things that I've considered are iotable_init() and ioremap().
>>> However, I've seen these used for memory mapped IO devices which are
>>> outside of the RAM memory. Can I use them for reseving RAM too?
>>>
>>> I appreciate any advice in this regard.
>>
>> Sounds to me like dma_alloc_coherent is what you want..
>>
> It looks promising, however, I need to reserve a physical address area 
> that is well known (so that the code running on the other processor 
> knows where in PCI memory to write to). It appears that 
> dma_alloc_coherent returns the address that it allocated. Instead I need 
> something where I can tell it what physical address and range I want to 
> use.

I don't think this is possible in the general case, as there's no 
mechanism for moving things out of the way if they might be in use. Your 
best solution is likely to use dma_alloc_coherent and pass the bus 
address returned into the other processor to tell it where to write..

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/



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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  3:36   ` Jon Ringle
  2006-11-28  5:19     ` Robert Hancock
@ 2006-11-28  5:34     ` Dave Airlie
  2006-11-28  6:51       ` Fawad Lateef
  2006-11-28 13:04     ` linux-os (Dick Johnson)
  2 siblings, 1 reply; 16+ messages in thread
From: Dave Airlie @ 2006-11-28  5:34 UTC (permalink / raw)
  To: Jon Ringle; +Cc: Robert Hancock, linux-kernel

On 11/28/06, Jon Ringle <jringle@vertical.com> wrote:
> Robert Hancock wrote:
> > Jon Ringle wrote:
> >> Hi,
> >>
> >> I need to reserve a page of memory at a specific area of RAM that will
> >> be used as a "shared memory" with another processor over PCI. How can I
> >> ensure that the this area of RAM gets reseved so that the Linux's memory
> >> management (kmalloc() and friends) don't use it?
> >>
> >> Some things that I've considered are iotable_init() and ioremap().
> >> However, I've seen these used for memory mapped IO devices which are
> >> outside of the RAM memory. Can I use them for reseving RAM too?
> >>
> >> I appreciate any advice in this regard.
> >
> > Sounds to me like dma_alloc_coherent is what you want..
> >
> It looks promising, however, I need to reserve a physical address area
> that is well known (so that the code running on the other processor
> knows where in PCI memory to write to). It appears that
> dma_alloc_coherent returns the address that it allocated. Instead I need
> something where I can tell it what physical address and range I want to use.
>

I've seen other projects just boot a 128M board with mem=120M and just
use the 8MB at 120 to talk to the other processor..

Dave.

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  5:34     ` Dave Airlie
@ 2006-11-28  6:51       ` Fawad Lateef
  2006-11-28 10:14         ` Jesper Juhl
  0 siblings, 1 reply; 16+ messages in thread
From: Fawad Lateef @ 2006-11-28  6:51 UTC (permalink / raw)
  To: Dave Airlie; +Cc: Jon Ringle, Robert Hancock, linux-kernel

On 11/28/06, Dave Airlie <airlied@gmail.com> wrote:
> On 11/28/06, Jon Ringle <jringle@vertical.com> wrote:
<snip>
> > It looks promising, however, I need to reserve a physical address area
> > that is well known (so that the code running on the other processor
> > knows where in PCI memory to write to). It appears that
> > dma_alloc_coherent returns the address that it allocated. Instead I need
> > something where I can tell it what physical address and range I want to use.
> >
>
> I've seen other projects just boot a 128M board with mem=120M and just
> use the 8MB at 120 to talk to the other processor..
>

Yes, this can be used if required physical-memory exists in the last
part of RAM as if you use mem=<xxxM> then kernel will only use memory
less than or equal-to <xxxM> and above can be used by drivers (or any
kernel module) might be through ioremap which takes physical-address.

But if lets say we need only 1MB portion of specific physical-memory
region then AFAIK it must be done by hacking in kernel code during
memory-initialization (mem_init function) where it is marking/checking
pages as/are reserved; you can simply mark you required pages as
reserved too and set their count to some-value if you want to know
later which pages are reserved by you. (can do this reservation work
here: http://lxr.free-electrons.com/source/arch/i386/mm/init.c#605).
CMIIW


-- 
Fawad Lateef

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  6:51       ` Fawad Lateef
@ 2006-11-28 10:14         ` Jesper Juhl
  0 siblings, 0 replies; 16+ messages in thread
From: Jesper Juhl @ 2006-11-28 10:14 UTC (permalink / raw)
  To: Fawad Lateef; +Cc: Dave Airlie, Jon Ringle, Robert Hancock, linux-kernel

On 28/11/06, Fawad Lateef <fawadlateef@gmail.com> wrote:
> On 11/28/06, Dave Airlie <airlied@gmail.com> wrote:
> > On 11/28/06, Jon Ringle <jringle@vertical.com> wrote:
> <snip>
> > > It looks promising, however, I need to reserve a physical address area
> > > that is well known (so that the code running on the other processor
> > > knows where in PCI memory to write to). It appears that
> > > dma_alloc_coherent returns the address that it allocated. Instead I need
> > > something where I can tell it what physical address and range I want to use.
> > >
> >
> > I've seen other projects just boot a 128M board with mem=120M and just
> > use the 8MB at 120 to talk to the other processor..
> >
>
> Yes, this can be used if required physical-memory exists in the last
> part of RAM as if you use mem=<xxxM> then kernel will only use memory
> less than or equal-to <xxxM> and above can be used by drivers (or any
> kernel module) might be through ioremap which takes physical-address.
>
> But if lets say we need only 1MB portion of specific physical-memory
> region then AFAIK it must be done by hacking in kernel code during
> memory-initialization (mem_init function) where it is marking/checking
> pages as/are reserved; you can simply mark you required pages as
> reserved too and set their count to some-value if you want to know
> later which pages are reserved by you. (can do this reservation work
> here: http://lxr.free-electrons.com/source/arch/i386/mm/init.c#605).
> CMIIW
>

Can you not use the 'memmap=' kernel option to reserve the specific
area you need?
(See Documentation/kernel-parameters.txt for details)

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-28  3:36   ` Jon Ringle
  2006-11-28  5:19     ` Robert Hancock
  2006-11-28  5:34     ` Dave Airlie
@ 2006-11-28 13:04     ` linux-os (Dick Johnson)
  2 siblings, 0 replies; 16+ messages in thread
From: linux-os (Dick Johnson) @ 2006-11-28 13:04 UTC (permalink / raw)
  To: Jon Ringle; +Cc: Robert Hancock, linux-kernel


On Mon, 27 Nov 2006, Jon Ringle wrote:

> Robert Hancock wrote:
>> Jon Ringle wrote:
>>> Hi,
>>>
>>> I need to reserve a page of memory at a specific area of RAM that will
>>> be used as a "shared memory" with another processor over PCI. How can I
>>> ensure that the this area of RAM gets reseved so that the Linux's memory
>>> management (kmalloc() and friends) don't use it?
>>>
>>> Some things that I've considered are iotable_init() and ioremap().
>>> However, I've seen these used for memory mapped IO devices which are
>>> outside of the RAM memory. Can I use them for reseving RAM too?
>>>
>>> I appreciate any advice in this regard.
>>
>> Sounds to me like dma_alloc_coherent is what you want..
>>
> It looks promising, however, I need to reserve a physical address area
> that is well known (so that the code running on the other processor
> knows where in PCI memory to write to). It appears that
> dma_alloc_coherent returns the address that it allocated. Instead I need
> something where I can tell it what physical address and range I want to use.
>
> Jon

First, "PCI memory" is some memory inside a board that is addressed through the 
PCI bus. This address is allocated upon machine start and is available though 
the PCI interface (check any of the PCI card drivers). If you want to access 
this memory, you need to follow the same procedures that other boards use.

However, perhaps you don't mean "PCI memory". Perhaps you mean real memory
in the address-space, and you need to reserve it and give its physical address 
to something inside a PCI-bus card, perhaps for DMA. In that case, you can 
either memory-map some physical memory (get_dma_pages()) or you can tell the 
kernel you have less memory than you really have, and use the memory the kernel 
doesn't know about for your own private purposes. To access this private memory 
you use ioremap() and friends. This can be memory-mapped to user-space as well 
so you can perform DMA directly to user-space buffers. You can find the highest 
address that the kernel uses by reading kernel variable num_physpages. This 
tells the number of pages the kernel uses. The kernel does write to the next one 
so you need to start using pages that are two higher than num_physpages.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.24 on an i686 machine (5592.72 BogoMips).
New book: http://www.AbominableFirebug.com/
_
\x1a\x04

****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

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

* RE: Reserving a fixed physical address page of RAM.
@ 2006-11-28 19:26 Jon Ringle
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-28 19:26 UTC (permalink / raw)
  To: Robert Hancock; +Cc: linux-kernel

Robert Hancock wrote:
> Jon Ringle wrote:
> > Robert Hancock wrote:
> >> Jon Ringle wrote:
> >>> Hi,
> >>>
> >>> I need to reserve a page of memory at a specific area of RAM that 
> >>> will be used as a "shared memory" with another processor 
> over PCI. 
> >>> How can I ensure that the this area of RAM gets reseved 
> so that the 
> >>> Linux's memory management (kmalloc() and friends) don't use it?
> >>>
> >>> Some things that I've considered are iotable_init() and ioremap().
> >>> However, I've seen these used for memory mapped IO 
> devices which are 
> >>> outside of the RAM memory. Can I use them for reseving RAM too?
> >>>
> >>> I appreciate any advice in this regard.
> >>
> >> Sounds to me like dma_alloc_coherent is what you want..
> >>
> > It looks promising, however, I need to reserve a physical 
> address area 
> > that is well known (so that the code running on the other processor 
> > knows where in PCI memory to write to). It appears that 
> > dma_alloc_coherent returns the address that it allocated. Instead I 
> > need something where I can tell it what physical address 
> and range I 
> > want to use.
> 
> I don't think this is possible in the general case, as 
> there's no mechanism for moving things out of the way if they 
> might be in use. Your best solution is likely to use 
> dma_alloc_coherent and pass the bus address returned into the 
> other processor to tell it where to write..

I can't do that because my mechanism to talk to the other processor is
exactly what I'm trying to setup. Catch-22 :)

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

* RE: Reserving a fixed physical address page of RAM.
@ 2006-11-28 19:37 Jon Ringle
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-28 19:37 UTC (permalink / raw)
  To: Jesper Juhl, Fawad Lateef; +Cc: Dave Airlie, Robert Hancock, linux-kernel

Jesper Juhl wrote:
> On 28/11/06, Fawad Lateef <fawadlateef@gmail.com> wrote:
> > On 11/28/06, Dave Airlie <airlied@gmail.com> wrote:
> > > On 11/28/06, Jon Ringle <jringle@vertical.com> wrote:
> > <snip>
> > > > It looks promising, however, I need to reserve a 
> physical address 
> > > > area that is well known (so that the code running on the other 
> > > > processor knows where in PCI memory to write to). It 
> appears that 
> > > > dma_alloc_coherent returns the address that it 
> allocated. Instead 
> > > > I need something where I can tell it what physical 
> address and range I want to use.
> > > >
> > >
> > > I've seen other projects just boot a 128M board with mem=120M and 
> > > just use the 8MB at 120 to talk to the other processor..
> > >
> >
> > Yes, this can be used if required physical-memory exists in 
> the last 
> > part of RAM as if you use mem=<xxxM> then kernel will only 
> use memory 
> > less than or equal-to <xxxM> and above can be used by 
> drivers (or any 
> > kernel module) might be through ioremap which takes 
> physical-address.
> >
> > But if lets say we need only 1MB portion of specific 
> physical-memory 
> > region then AFAIK it must be done by hacking in kernel code during 
> > memory-initialization (mem_init function) where it is 
> marking/checking 
> > pages as/are reserved; you can simply mark you required pages as 
> > reserved too and set their count to some-value if you want to know 
> > later which pages are reserved by you. (can do this reservation work
> > here: http://lxr.free-electrons.com/source/arch/i386/mm/init.c#605).
> > CMIIW
> >
> 
> Can you not use the 'memmap=' kernel option to reserve the 
> specific area you need?
> (See Documentation/kernel-parameters.txt for details)

This looks like what I want, but after searching for this, I found that
memmap= is implemented for i386 and ia64 only. My arch is arm (processor
is an IXP455).

I'll explore the mem= option to see if it will work out.

Jon

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

* RE: Reserving a fixed physical address page of RAM.
@ 2006-11-28 19:52 Jon Ringle
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-28 19:52 UTC (permalink / raw)
  To: linux-os (Dick Johnson); +Cc: Robert Hancock, linux-kernel

linux-os (Dick Johnson) wrote:
> On Mon, 27 Nov 2006, Jon Ringle wrote:
> 
> > Robert Hancock wrote:
> >> Jon Ringle wrote:
> >>> Hi,
> >>>
> >>> I need to reserve a page of memory at a specific area of RAM that 
> >>> will be used as a "shared memory" with another processor 
> over PCI. 
> >>> How can I ensure that the this area of RAM gets reseved 
> so that the 
> >>> Linux's memory management (kmalloc() and friends) don't use it?
> >>>
> >>> Some things that I've considered are iotable_init() and ioremap().
> >>> However, I've seen these used for memory mapped IO 
> devices which are 
> >>> outside of the RAM memory. Can I use them for reseving RAM too?
> >>>
> >>> I appreciate any advice in this regard.
> >>
> >> Sounds to me like dma_alloc_coherent is what you want..
> >>
> > It looks promising, however, I need to reserve a physical 
> address area 
> > that is well known (so that the code running on the other processor 
> > knows where in PCI memory to write to). It appears that 
> > dma_alloc_coherent returns the address that it allocated. Instead I 
> > need something where I can tell it what physical address 
> and range I want to use.
> >
> > Jon
> 
> First, "PCI memory" is some memory inside a board that is 
> addressed through the PCI bus. This address is allocated upon 
> machine start and is available though the PCI interface 
> (check any of the PCI card drivers). If you want to access 
> this memory, you need to follow the same procedures that 
> other boards use.

In my hardware setup, Linux is running in PCI option mode on a IXP455
processor and it exposes a segment of the IXP455's memory so that it is
available on the PCI bus. The other processor (a pentium M running
Windows OS) sees this exposed IXP455 memory as PCI memory from it's
perspective.

> 
> However, perhaps you don't mean "PCI memory". Perhaps you 
> mean real memory in the address-space, and you need to 
> reserve it and give its physical address to something inside 
> a PCI-bus card, perhaps for DMA. In that case, you can either 
> memory-map some physical memory (get_dma_pages()) or you can 
> tell the kernel you have less memory than you really have, 
> and use the memory the kernel doesn't know about for your own 
> private purposes. To access this private memory you use 
> ioremap() and friends. This can be memory-mapped to 
> user-space as well so you can perform DMA directly to 
> user-space buffers. You can find the highest address that the 
> kernel uses by reading kernel variable num_physpages. This 
> tells the number of pages the kernel uses. The kernel does 
> write to the next one so you need to start using pages that 
> are two higher than num_physpages.

I'll take a look telling the kernel it has less memory that there
physically exists and use ioremap() to map it in.

Thanks,
Jon 

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

* Re: Reserving a fixed physical address page of RAM.
@ 2006-11-30 17:47 Jon Ringle
  2006-11-30 18:32 ` Fawad Lateef
  0 siblings, 1 reply; 16+ messages in thread
From: Jon Ringle @ 2006-11-30 17:47 UTC (permalink / raw)
  To: Fawad Lateef; +Cc: Dave Airlie, Robert Hancock, linux-kernel

Fawad Lateef wrote:
> On 11/30/06, Jon Ringle <JRingle@vertical.com> wrote:
> > Fawad Lateef wrote:
> > > Yes, this can be used if required physical-memory exists 
> in the last 
> > > part of RAM as if you use mem=<xxxM> then kernel will only use 
> > > memory less than or equal-to <xxxM> and above can be used 
> by drivers 
> > > (or any kernel module) might be through ioremap which takes 
> > > physical-address.
> >
> > Seems that using mem= has to be in 1MB increments, where I 
> only need 4K.
> >
> 
> No AFAIK you can specify it in KBs (see
> http://sosdg.org/~coywolf/lxr/source/Documentation/kernel-para
> meters.txt#L869)

Yes, you can specify the mem= using K notation, but there is a test in
arch/arm/mm/mm-armv.c:create_mapping() that prevents the mapping from
being created if the boundaries are not MB aligned:

	if (mem_types[md->type].prot_l1 == 0 &&
	    (virt & 0xfffff || (virt + off) & 0xfffff || (virt + length)
& 0xfffff)) {
		printk(KERN_WARNING "BUG: map for 0x%08lx at 0x%08lx can
not "
		       "be mapped using pages, ignoring.\n",
		       __pfn_to_phys(md->pfn), md->virtual);
		return;
	}

This is in linux-2.6.16.29.

> 
> > >
> > > But if lets say we need only 1MB portion of specific 
> physical-memory 
> > > region then AFAIK it must be done by hacking in kernel 
> code during 
> > > memory-initialization (mem_init
> > > function) where it is marking/checking pages as/are reserved; you 
> > > can simply mark you required pages as reserved too and set their 
> > > count to some-value if you want to know later which pages are 
> > > reserved by you. (can do this reservation work
> > > here: 
> http://lxr.free-electrons.com/source/arch/i386/mm/init.c#605).
> >
> > Do you think that the following would work to properly reserve the 
> > memory. If it does, then I think I can just do a ioremap(0x0ffff000,
> > 0x1000) to obtain a virtual address. (Ofcourse I would actually use 
> > symbolic names rather than the hardcoded addesses shown here).
> >
> > Index: linux/arch/arm/mm/init.c
> > ===================================================================
> > --- linux.orig/arch/arm/mm/init.c       2006-11-30 
> 11:03:00.000000000
> > -0500
> > +++ linux/arch/arm/mm/init.c    2006-11-30 11:09:09.000000000 -0500
> > @@ -429,6 +429,10 @@
> >         unsigned long addr;
> >         void *vectors;
> >
> > +#ifdef CONFIG_MACH_VERTICAL_RSC4
> > +       reserve_bootmem (0x0ffff000, 0x1000); #endif
> > +
> >         /*
> >          * Allocate the vector page early.
> >          */
> >
> >
> 
> I think you can do like this but can't say accurately because 
> I havn't worked on arm architecture and also you havn't 
> mentioned your kernel-version or function (in file 
> arch/arm/mm/init.c) which you are going to do call reserve_bootmem !

Kernel version is 2.6.16.29 and the reserve_bootmem() call above is at
the top of the function devicemaps_init().

Jon

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

* RE: Reserving a fixed physical address page of RAM.
@ 2006-11-30 18:31 Jon Ringle
  2006-11-30 18:56 ` Fawad Lateef
  0 siblings, 1 reply; 16+ messages in thread
From: Jon Ringle @ 2006-11-30 18:31 UTC (permalink / raw)
  To: Jon Ringle, Fawad Lateef; +Cc: Dave Airlie, Robert Hancock, linux-kernel

Jon Ringle wrote:
> Fawad Lateef wrote:
> > On 11/30/06, Jon Ringle <JRingle@vertical.com> wrote:
> > > Do you think that the following would work to properly 
> reserve the 
> > > memory. If it does, then I think I can just do a 
> ioremap(0x0ffff000,
> > > 0x1000) to obtain a virtual address. (Ofcourse I would 
> actually use 
> > > symbolic names rather than the hardcoded addesses shown here).
> > >
> > > Index: linux/arch/arm/mm/init.c
> > > 
> ===================================================================
> > > --- linux.orig/arch/arm/mm/init.c       2006-11-30 
> > 11:03:00.000000000
> > > -0500
> > > +++ linux/arch/arm/mm/init.c    2006-11-30 
> 11:09:09.000000000 -0500
> > > @@ -429,6 +429,10 @@
> > >         unsigned long addr;
> > >         void *vectors;
> > >
> > > +#ifdef CONFIG_MACH_VERTICAL_RSC4
> > > +       reserve_bootmem (0x0ffff000, 0x1000); #endif
> > > +
> > >         /*
> > >          * Allocate the vector page early.
> > >          */
> > >
> > >
> > 
> > I think you can do like this but can't say accurately 
> because I havn't 
> > worked on arm architecture and also you havn't mentioned your 
> > kernel-version or function (in file
> > arch/arm/mm/init.c) which you are going to do call reserve_bootmem !
> 
> Kernel version is 2.6.16.29 and the reserve_bootmem() call 
> above is at the top of the function devicemaps_init().

Is there some way I can verify that the above works? I've tried the
following to try to get info on the reservation:
	# cat /proc/iomem
	# cat /proc/meminfo
	# cat /proc/slabinfo
	# echo m > /proc/sysrq-trigger

The only one that hints that this might have worked is the `echo m >
/proc/sysrq-trigger` in that I see the reserved pages count one larger
than using a kernel without this patch. Does this mean that the page I
reserved won't get used by Linux for any purpose?

Jon

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-30 17:47 Jon Ringle
@ 2006-11-30 18:32 ` Fawad Lateef
  0 siblings, 0 replies; 16+ messages in thread
From: Fawad Lateef @ 2006-11-30 18:32 UTC (permalink / raw)
  To: Jon Ringle; +Cc: Dave Airlie, Robert Hancock, linux-kernel

On 11/30/06, Jon Ringle <JRingle@vertical.com> wrote:
> Fawad Lateef wrote:
> > On 11/30/06, Jon Ringle <JRingle@vertical.com> wrote:
> > > Fawad Lateef wrote:
> > > > Yes, this can be used if required physical-memory exists
> > in the last
> > > > part of RAM as if you use mem=<xxxM> then kernel will only use
> > > > memory less than or equal-to <xxxM> and above can be used
> > by drivers
> > > > (or any kernel module) might be through ioremap which takes
> > > > physical-address.
> > >
> > > Seems that using mem= has to be in 1MB increments, where I
> > only need 4K.
> > >
> >
> > No AFAIK you can specify it in KBs (see
> > http://sosdg.org/~coywolf/lxr/source/Documentation/kernel-para
> > meters.txt#L869)
>
> Yes, you can specify the mem= using K notation, but there is a test in
> arch/arm/mm/mm-armv.c:create_mapping() that prevents the mapping from
> being created if the boundaries are not MB aligned:
>
>         if (mem_types[md->type].prot_l1 == 0 &&
>             (virt & 0xfffff || (virt + off) & 0xfffff || (virt + length)
> & 0xfffff)) {
>                 printk(KERN_WARNING "BUG: map for 0x%08lx at 0x%08lx can
> not "
>                        "be mapped using pages, ignoring.\n",
>                        __pfn_to_phys(md->pfn), md->virtual);
>                 return;
>         }
>
> This is in linux-2.6.16.29.
>

Ohh ok, I don't know about this architecture related information.

> >
> > > >
> > > > But if lets say we need only 1MB portion of specific
> > physical-memory
> > > > region then AFAIK it must be done by hacking in kernel
> > code during
> > > > memory-initialization (mem_init
> > > > function) where it is marking/checking pages as/are reserved; you
> > > > can simply mark you required pages as reserved too and set their
> > > > count to some-value if you want to know later which pages are
> > > > reserved by you. (can do this reservation work
> > > > here:
> > http://lxr.free-electrons.com/source/arch/i386/mm/init.c#605).
> > >
> > > Do you think that the following would work to properly reserve the
> > > memory. If it does, then I think I can just do a ioremap(0x0ffff000,
> > > 0x1000) to obtain a virtual address. (Ofcourse I would actually use
> > > symbolic names rather than the hardcoded addesses shown here).
> > >
> > > Index: linux/arch/arm/mm/init.c
> > > ===================================================================
> > > --- linux.orig/arch/arm/mm/init.c       2006-11-30
> > 11:03:00.000000000
> > > -0500
> > > +++ linux/arch/arm/mm/init.c    2006-11-30 11:09:09.000000000 -0500
> > > @@ -429,6 +429,10 @@
> > >         unsigned long addr;
> > >         void *vectors;
> > >
> > > +#ifdef CONFIG_MACH_VERTICAL_RSC4
> > > +       reserve_bootmem (0x0ffff000, 0x1000); #endif
> > > +
> > >         /*
> > >          * Allocate the vector page early.
> > >          */
> > >
> > >
> >
> > I think you can do like this but can't say accurately because
> > I havn't worked on arm architecture and also you havn't
> > mentioned your kernel-version or function (in file
> > arch/arm/mm/init.c) which you are going to do call reserve_bootmem !
>
> Kernel version is 2.6.16.29 and the reserve_bootmem() call above is at
> the top of the function devicemaps_init().
>

reserving_bootmem in devicemaps_init will work but I think it will be
better if you do this in mem_init function (here:
http://sosdg.org/~coywolf/lxr/source/arch/arm/mm/init.c?v=2.6.16;a=arm#L620),
so that all the paging and other map related stuff completes. (CMIIW)

-- 
Fawad Lateef

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

* Re: Reserving a fixed physical address page of RAM.
  2006-11-30 18:31 Jon Ringle
@ 2006-11-30 18:56 ` Fawad Lateef
  0 siblings, 0 replies; 16+ messages in thread
From: Fawad Lateef @ 2006-11-30 18:56 UTC (permalink / raw)
  To: Jon Ringle; +Cc: Dave Airlie, Robert Hancock, linux-kernel

On 11/30/06, Jon Ringle <JRingle@vertical.com> wrote:
> Jon Ringle wrote:
> > Fawad Lateef wrote:
<snip>
> > > >
> > > > Index: linux/arch/arm/mm/init.c
> > > >
> > ===================================================================
> > > > --- linux.orig/arch/arm/mm/init.c       2006-11-30
> > > 11:03:00.000000000
> > > > -0500
> > > > +++ linux/arch/arm/mm/init.c    2006-11-30
> > 11:09:09.000000000 -0500
> > > > @@ -429,6 +429,10 @@
> > > >         unsigned long addr;
> > > >         void *vectors;
> > > >
> > > > +#ifdef CONFIG_MACH_VERTICAL_RSC4
> > > > +       reserve_bootmem (0x0ffff000, 0x1000); #endif
> > > > +
> > > >         /*
> > > >          * Allocate the vector page early.
> > > >          */
> > > >
> > > >
> > >
> > > I think you can do like this but can't say accurately
> > because I havn't
> > > worked on arm architecture and also you havn't mentioned your
> > > kernel-version or function (in file
> > > arch/arm/mm/init.c) which you are going to do call reserve_bootmem !
> >
> > Kernel version is 2.6.16.29 and the reserve_bootmem() call
> > above is at the top of the function devicemaps_init().
>
> Is there some way I can verify that the above works? I've tried the
> following to try to get info on the reservation:
>         # cat /proc/iomem
>         # cat /proc/meminfo
>         # cat /proc/slabinfo
>         # echo m > /proc/sysrq-trigger
>
> The only one that hints that this might have worked is the `echo m >
> /proc/sysrq-trigger` in that I see the reserved pages count one larger
> than using a kernel without this patch. Does this mean that the page I
> reserved won't get used by Linux for any purpose?
>

I havn't looked at " # echo m /proc/sysrq-trigger" till now but I am
almost sure that it will reserve/work because calling reserve_bootmem
internally sets the bit representing physical memory page (CMIIW).


-- 
Fawad Lateef

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

* RE: Reserving a fixed physical address page of RAM.
@ 2006-11-30 21:51 Jon Ringle
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Ringle @ 2006-11-30 21:51 UTC (permalink / raw)
  To: Fawad Lateef; +Cc: Dave Airlie, Robert Hancock, linux-kernel

Fawad Lateef wrote:
> reserving_bootmem in devicemaps_init will work but I think it 
> will be better if you do this in mem_init function (here:
> http://sosdg.org/~coywolf/lxr/source/arch/arm/mm/init.c?v=2.6.
> 16;a=arm#L620),
> so that all the paging and other map related stuff completes. (CMIIW)

Ok. That seems to work ok too. Thanks.

Jon

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

end of thread, other threads:[~2006-11-30 21:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fa.LC2HgQx8572p2lwOKfUm6cxg95s@ifi.uio.no>
2006-11-28  0:38 ` Reserving a fixed physical address page of RAM Robert Hancock
2006-11-28  3:36   ` Jon Ringle
2006-11-28  5:19     ` Robert Hancock
2006-11-28  5:34     ` Dave Airlie
2006-11-28  6:51       ` Fawad Lateef
2006-11-28 10:14         ` Jesper Juhl
2006-11-28 13:04     ` linux-os (Dick Johnson)
2006-11-30 21:51 Jon Ringle
  -- strict thread matches above, loose matches on Subject: below --
2006-11-30 18:31 Jon Ringle
2006-11-30 18:56 ` Fawad Lateef
2006-11-30 17:47 Jon Ringle
2006-11-30 18:32 ` Fawad Lateef
2006-11-28 19:52 Jon Ringle
2006-11-28 19:37 Jon Ringle
2006-11-28 19:26 Jon Ringle
2006-11-27 16:31 Jon Ringle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.