All of lore.kernel.org
 help / color / mirror / Atom feed
* 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
* 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, 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-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-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: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
* 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

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.